From b9ad7e80a5ec37f59f39858dd5eef7e519afffa2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 17 Oct 2013 20:24:17 +0000 Subject: ZVISION: screenSpaceToImageSpace return 0,0 when pointer outside working window. --- engines/zvision/render_manager.cpp | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index af8ca7fd64..cb13606b11 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -385,30 +385,34 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com } const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) { - // Convert from screen space to working window space - Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top)); + if (_workingWindow.contains(point)) { + // Convert from screen space to working window space + Common::Point newPoint(point - Common::Point(_workingWindow.left, _workingWindow.top)); - RenderTable::RenderState state = _renderTable.getRenderState(); - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint); - } + RenderTable::RenderState state = _renderTable.getRenderState(); + if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + newPoint = _renderTable.convertWarpedCoordToFlatCoord(newPoint); + } - if (state == RenderTable::PANORAMA) { - newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset); - } else if (state == RenderTable::TILT) { - newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset); - } + if (state == RenderTable::PANORAMA) { + newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset); + } else if (state == RenderTable::TILT) { + newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset); + } - if (newPoint.x < 0) - newPoint.x += _backgroundWidth; - else if (newPoint.x >= _backgroundWidth) - newPoint.x -= _backgroundWidth; - if (newPoint.y < 0) - newPoint.y += _backgroundHeight; - else if (newPoint.y >= _backgroundHeight) - newPoint.y -= _backgroundHeight; + if (newPoint.x < 0) + newPoint.x += _backgroundWidth; + else if (newPoint.x >= _backgroundWidth) + newPoint.x -= _backgroundWidth; + if (newPoint.y < 0) + newPoint.y += _backgroundHeight; + else if (newPoint.y >= _backgroundHeight) + newPoint.y -= _backgroundHeight; - return newPoint; + return newPoint; + } else { + return Common::Point(0, 0); + } } const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) { -- cgit v1.2.3 From 4baa1801fe13e2dafe5317d57dfc9e4fe10bc809 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 15 Oct 2013 15:26:26 +0700 Subject: ZVISION: Don't need to set push flag in cursorDown because it's block change cursor image. --- engines/zvision/cursor_manager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index 595e7946dd..4c5ae5e80f 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -120,7 +120,6 @@ void CursorManager::cursorDown(bool pushed) { if (_cursorIsPushed == pushed) return; - _cursorIsPushed = pushed; changeCursor(_currentCursor, pushed); } -- cgit v1.2.3 From cf99a88322474f2412edc737b9a0c6a38f373610 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 15 Oct 2013 15:44:02 +0700 Subject: ZVISION: Change platform detection of ZGI, dos->win. --- engines/zvision/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 06e921dfa8..49664935e1 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -80,7 +80,7 @@ static const ZVisionGameDescription gameDescriptions[] = { 0, AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944), Common::EN_ANY, - Common::kPlatformDOS, + Common::kPlatformWindows, ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, -- cgit v1.2.3 From f1c6b58a943689c35bb448094577cfede19b92fc Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 17 Oct 2013 20:33:41 +0000 Subject: ZVISION: Select needed workingWindow for ZGI and Nemesis. --- engines/zvision/zvision.cpp | 4 +++- engines/zvision/zvision.h | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 6d8ae6d5a7..940e01ae20 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -51,7 +51,9 @@ namespace ZVision { ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), - _workingWindow((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), + _workingWindow_ZGI((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), + _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT), + _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI), _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ _desiredFrameTime(33), /* ~30 fps */ _clock(_system), diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 84784d9a89..89aa60fe73 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -63,15 +63,21 @@ public: * are given in this coordinate space. Also, all images are clipped to the * edges of this Rectangle */ - const Common::Rect _workingWindow; + const Common::Rect &_workingWindow; const Graphics::PixelFormat _pixelFormat; private: enum { WINDOW_WIDTH = 640, WINDOW_HEIGHT = 480, - WORKING_WINDOW_WIDTH = 512, - WORKING_WINDOW_HEIGHT = 320, + + //Zork nemesis working window sizes + ZNM_WORKING_WINDOW_WIDTH = 512, + ZNM_WORKING_WINDOW_HEIGHT = 320, + + //ZGI(and default) working window sizes + WORKING_WINDOW_WIDTH = 640, + WORKING_WINDOW_HEIGHT = 344, ROTATION_SCREEN_EDGE_OFFSET = 60, MAX_ROTATION_SPEED = 400 // Pixels per second @@ -98,6 +104,8 @@ private: // To prevent allocation every time we process events Common::Event _event; + const Common::Rect _workingWindow_ZGI; + const Common::Rect _workingWindow_ZNM; public: uint32 getFeatures() const; Common::Language getLanguage() const; -- cgit v1.2.3 From 7a3518d7c3c81b2e34dcbba0682dd8dc6e43b80d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 17 Oct 2013 21:24:50 +0000 Subject: ZVISION: Streamvideo alwayas skippable. Skippable flag renamed to skipline. --- engines/zvision/actions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index eae4ec2ed5..fbf2a58ad6 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -354,12 +354,12 @@ bool ActionSetScreen::execute(ZVision *engine) { ActionStreamVideo::ActionStreamVideo(const Common::String &line) { char fileName[25]; - uint skippable; + uint skipline; //skipline - render video with skip every second line, not skippable. - sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skippable); + sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); _fileName = Common::String(fileName); - _skippable = (skippable == 0) ? false : true; + _skippable = true; } bool ActionStreamVideo::execute(ZVision *engine) { -- cgit v1.2.3 From 2050987fa1ecc347bdc707b58d185804a875106d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 17 Oct 2013 21:03:08 +0000 Subject: ZVISION: Detach raw stream reader from RawZorkStream for creating correct avi raw reader. --- engines/zvision/zork_avi_decoder.cpp | 8 ++- engines/zvision/zork_avi_decoder.h | 22 ++++-- engines/zvision/zork_raw.cpp | 130 ++++++++++++++++++++++------------- engines/zvision/zork_raw.h | 51 +++++++++++--- 4 files changed, 145 insertions(+), 66 deletions(-) diff --git a/engines/zvision/zork_avi_decoder.cpp b/engines/zvision/zork_avi_decoder.cpp index a614f77bb7..0711cdf9d7 100644 --- a/engines/zvision/zork_avi_decoder.cpp +++ b/engines/zvision/zork_avi_decoder.cpp @@ -30,6 +30,7 @@ #include "common/stream.h" #include "audio/audiostream.h" +#include "audio/decoders/raw.h" namespace ZVision { @@ -43,9 +44,14 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s if (_audStream) { if (_wvInfo.tag == kWaveFormatZorkPCM) { assert(_wvInfo.size == 8); - _audStream->queueAudioStream(makeRawZorkStream(stream, _wvInfo.samplesPerSec, _audStream->isStereo(), DisposeAfterUse::YES), DisposeAfterUse::YES); + RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream); + delete stream; + + if (chunk.data) + _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO); } } else { + warning("Got %d wave format in AVI\n", _wvInfo.tag); delete stream; } } diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h index ec2be1bb13..dc3e3327ed 100644 --- a/engines/zvision/zork_avi_decoder.h +++ b/engines/zvision/zork_avi_decoder.h @@ -25,25 +25,35 @@ #define ZORK_AVI_DECODER_H #include "video/avi_decoder.h" - +#include "zork_raw.h" namespace ZVision { class ZorkAVIDecoder : public Video::AVIDecoder { public: ZorkAVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType) : - Video::AVIDecoder(soundType) {} + Video::AVIDecoder(soundType) {} - virtual ~ZorkAVIDecoder() {} + virtual ~ZorkAVIDecoder() {} private: class ZorkAVIAudioTrack : public Video::AVIDecoder::AVIAudioTrack { public: ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : - Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType) {} - virtual ~ZorkAVIAudioTrack() {} + Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), + decoder(NULL) { + if (_audStream) { + decoder = new RawChunkStream(_audStream->isStereo()); + } + } + virtual ~ZorkAVIAudioTrack() { + if (decoder) + delete decoder; + } void queueSound(Common::SeekableReadStream *stream); + private: + RawChunkStream *decoder; }; Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo); @@ -51,7 +61,7 @@ private: private: // Audio Codecs enum { - kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM) + kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM) }; }; diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp index 21613d9043..029600b758 100644 --- a/engines/zvision/zork_raw.cpp +++ b/engines/zvision/zork_raw.cpp @@ -41,65 +41,62 @@ namespace ZVision { -const int16 RawZorkStream::_stepAdjustmentTable[8] = {-1, -1, -1, 1, 4, 7, 10, 12}; - -const int32 RawZorkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, - 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, - 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, - 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, - 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, - 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, - 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, - 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, - 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, - 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, - 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF}; - -const SoundParams RawZorkStream::_zNemSoundParamLookupTable[6] = {{'6', 0x2B11, false, false}, - {'a', 0x5622, false, true}, - {'b', 0x5622, true, true}, - {'n', 0x2B11, false, true}, - {'s', 0x5622, false, true}, - {'t', 0x5622, true, true} -}; - -const SoundParams RawZorkStream::_zgiSoundParamLookupTable[5] = {{'a',0x5622, false, false}, - {'k',0x2B11, true, true}, - {'p',0x5622, false, true}, - {'q',0x5622, true, true}, - {'u',0xAC44, true, true} -}; - -RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream) - : _rate(rate), - _stereo(0), - _stream(stream, disposeStream), - _endOfData(false) { +const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12}; + +const int32 RawChunkStream::_amplitudeLookupTable[89] = {0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, + 0x0010, 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, + 0x0022, 0x0025, 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, + 0x0049, 0x0050, 0x0058, 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, + 0x009D, 0x00AD, 0x00BE, 0x00D1, 0x00E6, 0x00FD, 0x0117, 0x0133, + 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, 0x0220, 0x0256, 0x0292, + 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, 0x0502, 0x0583, + 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, 0x0BD0, + 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, + 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, + 0x3BB9, 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF + }; + +RawChunkStream::RawChunkStream(bool stereo) { if (stereo) _stereo = 1; + else + _stereo = 0; + + init(); +} +void RawChunkStream::init() { _lastSample[0].index = 0; _lastSample[0].sample = 0; _lastSample[1].index = 0; _lastSample[1].sample = 0; +} - // Calculate the total playtime of the stream - if (stereo) - _playtime = Audio::Timestamp(0, _stream->size() / 2, rate); - else - _playtime = Audio::Timestamp(0, _stream->size(), rate); +RawChunkStream::RawChunk RawChunkStream::readNextChunk(Common::SeekableReadStream *stream) { + RawChunk tmp; + tmp.size = 0; + tmp.data = NULL; + + if (stream && (stream->size() == 0 || stream->eos())) + return tmp; + + tmp.size = (stream->size() - stream->pos()) * 2; + tmp.data = (int16 *)calloc(tmp.size, 1); + + readBuffer(tmp.data, stream, stream->size() - stream->pos()); + + return tmp; } -int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) { - int bytesRead = 0; +int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples) { + int32 bytesRead = 0; // 0: Left, 1: Right uint channel = 0; while (bytesRead < numSamples) { - byte encodedSample = _stream->readByte(); - if (_stream->eos()) { - _endOfData = true; + byte encodedSample = stream->readByte(); + if (stream->eos()) { return bytesRead; } bytesRead++; @@ -140,6 +137,46 @@ int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) { // Increment and wrap the channel channel = (channel + 1) & _stereo; } + return bytesRead; +} + +const SoundParams RawZorkStream::_zNemSoundParamLookupTable[6] = {{'6', 0x2B11, false, false}, + {'a', 0x5622, false, true}, + {'b', 0x5622, true, true}, + {'n', 0x2B11, false, true}, + {'s', 0x5622, false, true}, + {'t', 0x5622, true, true} +}; + +const SoundParams RawZorkStream::_zgiSoundParamLookupTable[5] = {{'a', 0x5622, false, false}, + {'k', 0x2B11, true, true}, + {'p', 0x5622, false, true}, + {'q', 0x5622, true, true}, + {'u', 0xAC44, true, true} +}; + +RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream) + : _rate(rate), + _stereo(0), + _stream(stream, disposeStream), + _endOfData(false), + _streamReader(stereo) { + if (stereo) + _stereo = 1; + + // Calculate the total playtime of the stream + if (stereo) + _playtime = Audio::Timestamp(0, _stream->size() / 2, rate); + else + _playtime = Audio::Timestamp(0, _stream->size(), rate); +} + +int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) { + + int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples); + + if (_stream->eos()) + _endOfData = true; return bytesRead; } @@ -148,10 +185,7 @@ bool RawZorkStream::rewind() { _stream->seek(0, 0); _stream->clearErr(); _endOfData = false; - _lastSample[0].index = 0; - _lastSample[0].sample = 0; - _lastSample[1].index = 0; - _lastSample[1].sample = 0; + _streamReader.init(); return true; } diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h index 481ea79f2d..1f261ae139 100644 --- a/engines/zvision/zork_raw.h +++ b/engines/zvision/zork_raw.h @@ -41,6 +41,45 @@ struct SoundParams { bool packed; }; + +/** + * This is a ADPCM stream-reader, this class holds context for multi-chunk reading and no buffers. + */ +class RawChunkStream { +public: + RawChunkStream(bool stereo); + + ~RawChunkStream() { + } +private: + uint _stereo; + + /** + * Holds the frequency and index from the last sample + * 0 holds the left channel, 1 holds the right channel + */ + struct { + int32 sample; + int16 index; + } _lastSample[2]; + + static const int16 _stepAdjustmentTable[8]; + static const int32 _amplitudeLookupTable[89]; + +public: + + struct RawChunk { + int16 *data; + uint32 size; + }; + + void init(); + //Read next audio portion in new stream (needed for avi), return structure with buffer + RawChunk readNextChunk(Common::SeekableReadStream *stream); + //Read numSamples from stream to buffer + int readBuffer(int16 *buffer, Common::SeekableReadStream *stream, const int numSamples); +}; + /** * This is a stream, which allows for playing raw ADPCM data from a stream. */ @@ -62,17 +101,7 @@ private: bool _endOfData; // Whether the stream end has been reached uint _stereo; - /** - * Holds the frequency and index from the last sample - * 0 holds the left channel, 1 holds the right channel - */ - struct { - int32 sample; - int16 index; - } _lastSample[2]; - - static const int16 _stepAdjustmentTable[8]; - static const int32 _amplitudeLookupTable[89]; + RawChunkStream _streamReader; public: int readBuffer(int16 *buffer, const int numSamples); -- cgit v1.2.3 From 82348a74df8edd2f9e628ec939ba515c1703bc70 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 18:44:40 +0000 Subject: ZVISION: New base class similar to control for handling timers, music, etc... --- engines/zvision/module.mk | 3 +- engines/zvision/sidefx.cpp | 36 ++++++++++++++++++ engines/zvision/sidefx.h | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/sidefx.cpp create mode 100644 engines/zvision/sidefx.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 261168f133..edd08c8e9f 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -29,7 +29,8 @@ MODULE_OBJS := \ zvision.o \ zfs_archive.o \ zork_avi_decoder.o \ - zork_raw.o + zork_raw.o \ + sidefx.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp new file mode 100644 index 0000000000..3874c86485 --- /dev/null +++ b/engines/zvision/sidefx.cpp @@ -0,0 +1,36 @@ +/* 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 "common/scummsys.h" + +#include "zvision/sidefx.h" + +#include "zvision/zvision.h" +#include "zvision/render_manager.h" +#include "zvision/utility.h" + +#include "common/stream.h" + +namespace ZVision { + + +} // End of namespace ZVision diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h new file mode 100644 index 0000000000..7047982fda --- /dev/null +++ b/engines/zvision/sidefx.h @@ -0,0 +1,95 @@ +/* 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 SIDEFX_H_INCLUDED +#define SIDEFX_H_INCLUDED + +namespace Common { +class SeekableReadStream; +struct Point; +class WriteStream; +} + +namespace ZVision { + +class ZVision; + +class SideFX { +public: + SideFX() : _engine(0), _key(0) {} + SideFX(ZVision *engine, uint32 key) : _engine(engine), _key(key) {} + virtual ~SideFX() {} + + uint32 getKey() { return _key; } + + virtual bool process(uint32 deltaTimeInMillis) { return false; } + /** + * Serialize a Control for save game use. This should only be used if a Control needs + * to save values that would be different from initialization. AKA a TimerNode needs to + * store the amount of time left on the timer. Any Controls overriding this *MUST* write + * their key as the first data outputted. The default implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override deserialize() + * and needsSerialization() + * + * @param stream Stream to write any needed data to + */ + virtual void serialize(Common::WriteStream *stream) {} + /** + * De-serialize data from a save game stream. This should only be implemented if the + * Control also implements serialize(). The calling method assumes the size of the + * data read from the stream exactly equals that written in serialize(). The default + * implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override serialize() + * and needsSerialization() + * + * @param stream Save game file stream + */ + virtual void deserialize(Common::SeekableReadStream *stream) {} + /** + * If a Control overrides serialize() and deserialize(), this should return true + * + * @return Does the Control need save game serialization? + */ + virtual inline bool needsSerialization() { return false; } + +protected: + ZVision * _engine; + uint32 _key; + +// Static member functions +public: +}; + +// TODO: Implement InputControl +// TODO: Implement SaveControl +// TODO: Implement SlotControl +// TODO: Implement SafeControl +// TODO: Implement FistControl +// TODO: Implement HotMovieControl +// TODO: Implement PaintControl +// TODO: Implement TilterControl + +} // End of namespace ZVision + +#endif // SIDEFX_H_INCLUDED -- cgit v1.2.3 From a6f025c74f7aac95154d56dc23a7b62eca965dd4 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 20:11:33 +0000 Subject: ZVISION: Basic integration of SideFX into scriptManager. --- engines/zvision/script_manager.cpp | 26 +++++++++++++++++++++++++- engines/zvision/script_manager.h | 9 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 66a54088fd..4b4f1303aa 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -108,6 +108,16 @@ void ScriptManager::createReferenceTable() { } void ScriptManager::updateNodes(uint deltaTimeMillis) { + // If process() returns true, it means the node can be deleted + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { + if ((*iter)->process(deltaTimeMillis)) { + delete (*iter); + // Remove the node + iter = _activeSideFx.erase(iter); + } else { + ++iter; + } + } // If process() returns true, it means the node can be deleted for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { if ((*iter)->process(deltaTimeMillis)) { @@ -262,7 +272,7 @@ void ScriptManager::disableControl(uint32 key) { void ScriptManager::focusControl(uint32 key) { for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { uint32 controlKey = (*iter)->getKey(); - + if (controlKey == key) { (*iter)->focus(); } else if (controlKey == _currentlyFocusedControl) { @@ -273,6 +283,20 @@ void ScriptManager::focusControl(uint32 key) { _currentlyFocusedControl = key; } +void ScriptManager::addSideFX(SideFX *fx) { + _activeSideFx.push_back(fx); +} + +SideFX *ScriptManager::getSideFX(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + return (*iter); + } + } + + return nullptr; +} + void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 388d0805e0..c29bc57d03 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -25,6 +25,7 @@ #include "zvision/puzzle.h" #include "zvision/control.h" +#include "zvision/sidefx.h" #include "common/hashmap.h" #include "common/queue.h" @@ -54,6 +55,7 @@ typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; typedef Common::HashMap StateMap; +typedef Common::List SideFXList; class ScriptManager { public: @@ -78,6 +80,8 @@ private: PuzzleList _globalPuzzles; /** Holds the currently active controls */ ControlList _activeControls; + /** Holds the currently active timers, musics, other */ + SideFXList _activeSideFx; Location _currentLocation; @@ -99,6 +103,9 @@ public: void focusControl(uint32 key); + void addSideFX(SideFX *fx); + SideFX *getSideFX(uint32 key); + /** * Called when LeftMouse is pushed. * @@ -140,7 +147,7 @@ public: void deserializeStateTable(Common::SeekableReadStream *stream); void serializeControls(Common::WriteStream *stream); void deserializeControls(Common::SeekableReadStream *stream); - + Location getCurrentLocation() const; private: -- cgit v1.2.3 From 96ac92aae3bd3cb195abcc73f4df16864c0e3738 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 20:43:04 +0000 Subject: ZVISION: Added type field for SideFX --- engines/zvision/sidefx.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 7047982fda..35d25d4431 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -35,15 +35,21 @@ class ZVision; class SideFX { public: - SideFX() : _engine(0), _key(0) {} - SideFX(ZVision *engine, uint32 key) : _engine(engine), _key(key) {} + + enum SideFXType{ + SIDEFX_UNK = 0 + }; + + SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} + SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {} virtual ~SideFX() {} uint32 getKey() { return _key; } + SideFXType getType() { return _type; } virtual bool process(uint32 deltaTimeInMillis) { return false; } /** - * Serialize a Control for save game use. This should only be used if a Control needs + * Serialize a SideFX for save game use. This should only be used if a SideFX needs * to save values that would be different from initialization. AKA a TimerNode needs to * store the amount of time left on the timer. Any Controls overriding this *MUST* write * their key as the first data outputted. The default implementation is NOP. @@ -56,7 +62,7 @@ public: virtual void serialize(Common::WriteStream *stream) {} /** * De-serialize data from a save game stream. This should only be implemented if the - * Control also implements serialize(). The calling method assumes the size of the + * SideFX also implements serialize(). The calling method assumes the size of the * data read from the stream exactly equals that written in serialize(). The default * implementation is NOP. * @@ -67,18 +73,20 @@ public: */ virtual void deserialize(Common::SeekableReadStream *stream) {} /** - * If a Control overrides serialize() and deserialize(), this should return true + * If a SideFX overrides serialize() and deserialize(), this should return true * - * @return Does the Control need save game serialization? + * @return Does the SideFX need save game serialization? */ virtual inline bool needsSerialization() { return false; } protected: ZVision * _engine; uint32 _key; + SideFXType _type; // Static member functions public: + }; // TODO: Implement InputControl -- cgit v1.2.3 From 4ac2c3e93bd78d4e151035fcde0dae9f17eeb11a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 22:44:33 +0000 Subject: ZVISION: Move TimerNode to SideFX-based class. --- engines/zvision/actions.cpp | 2 +- engines/zvision/sidefx.h | 3 ++- engines/zvision/timer_node.cpp | 5 +++-- engines/zvision/timer_node.h | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index fbf2a58ad6..fb4034fbdb 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -387,7 +387,7 @@ ActionTimer::ActionTimer(const Common::String &line) { } bool ActionTimer::execute(ZVision *engine) { - engine->getScriptManager()->addControl(new TimerNode(engine, _key, _time)); + engine->getScriptManager()->addSideFX(new TimerNode(engine, _key, _time)); return true; } diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 35d25d4431..d495655a22 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -37,7 +37,8 @@ class SideFX { public: enum SideFXType{ - SIDEFX_UNK = 0 + SIDEFX_UNK = 0, + SIDEFX_TIMER = 1 }; SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index 55dfa51dfe..7fc3199a8a 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -32,8 +32,9 @@ namespace ZVision { -TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) - : Control(engine, key), _timeLeft(timeInSeconds * 1000) { +TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) + : SideFX(engine, key, SIDEFX_TIMER) { + _timeLeft = timeInSeconds * 1000; } bool TimerNode::process(uint32 deltaTimeInMillis) { diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h index 32dca71548..afdbd39803 100644 --- a/engines/zvision/timer_node.h +++ b/engines/zvision/timer_node.h @@ -23,13 +23,13 @@ #ifndef ZVISION_TIMER_NODE_H #define ZVISION_TIMER_NODE_H -#include "zvision/control.h" +#include "zvision/sidefx.h" namespace ZVision { class ZVision; -class TimerNode : public Control { +class TimerNode : public SideFX { public: TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); -- cgit v1.2.3 From aefa58f5a4470b1ba2e275c62aa1a7a0cec76539 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 18 Oct 2013 22:58:02 +0000 Subject: ZVISION: Correcting TimerNode behavior. --- engines/zvision/timer_node.cpp | 15 ++++++++++++--- engines/zvision/timer_node.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index 7fc3199a8a..dc7dd5b38c 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -34,16 +34,25 @@ namespace ZVision { TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) : SideFX(engine, key, SIDEFX_TIMER) { + if (_engine->getGameId() == GID_NEMESIS) _timeLeft = timeInSeconds * 1000; + else if (_engine->getGameId() == GID_GRANDINQUISITOR) + _timeLeft = timeInSeconds * 100; + _engine->getScriptManager()->setStateValue(_key, 1); +} + +TimerNode::~TimerNode() { + if (_timeLeft <= 0) + _engine->getScriptManager()->setStateValue(_key, 2); + else + _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill } bool TimerNode::process(uint32 deltaTimeInMillis) { _timeLeft -= deltaTimeInMillis; - if (_timeLeft <= 0) { - _engine->getScriptManager()->setStateValue(_key, 0); + if (_timeLeft <= 0) return true; - } return false; } diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h index afdbd39803..2caf43ad3c 100644 --- a/engines/zvision/timer_node.h +++ b/engines/zvision/timer_node.h @@ -32,6 +32,7 @@ class ZVision; class TimerNode : public SideFX { public: TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); + ~TimerNode(); /** * Decrement the timer by the delta time. If the timer is finished, set the status -- cgit v1.2.3 From 25834faf0738ae6c33819b196fdfb8ab5e8f1888 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 20 Oct 2013 18:39:06 +0000 Subject: ZVISION: Style modifing by astyle. --- engines/zvision/actions.cpp | 18 ++--- engines/zvision/actions.h | 2 +- engines/zvision/animation_control.cpp | 14 ++-- engines/zvision/animation_control.h | 22 ++++-- engines/zvision/clock.cpp | 2 +- engines/zvision/clock.h | 12 ++-- engines/zvision/control.h | 20 ++++-- engines/zvision/cursor.cpp | 12 ++-- engines/zvision/cursor.h | 26 +++++-- engines/zvision/cursor_manager.cpp | 15 ++-- engines/zvision/cursor_manager.h | 8 +-- engines/zvision/detection.cpp | 116 +++++++++++++++---------------- engines/zvision/detection.h | 6 +- engines/zvision/input_control.cpp | 12 ++-- engines/zvision/input_control.h | 8 ++- engines/zvision/lever_control.cpp | 32 ++++----- engines/zvision/lever_control.h | 8 +-- engines/zvision/lzss_read_stream.cpp | 12 ++-- engines/zvision/lzss_read_stream.h | 6 +- engines/zvision/push_toggle_control.cpp | 6 +- engines/zvision/puzzle.h | 16 ++--- engines/zvision/render_manager.cpp | 34 ++++----- engines/zvision/render_manager.h | 28 +++++--- engines/zvision/render_table.cpp | 20 +++--- engines/zvision/render_table.h | 12 ++-- engines/zvision/rlf_animation.cpp | 28 ++++---- engines/zvision/rlf_animation.h | 24 +++++-- engines/zvision/save_manager.cpp | 4 +- engines/zvision/save_manager.h | 4 +- engines/zvision/scr_file_handling.cpp | 6 +- engines/zvision/script_manager.cpp | 18 ++--- engines/zvision/script_manager.h | 12 ++-- engines/zvision/sidefx.h | 24 ++++--- engines/zvision/single_value_container.h | 44 ++++++------ engines/zvision/string_manager.cpp | 6 +- engines/zvision/string_manager.h | 2 +- engines/zvision/timer_node.cpp | 14 ++-- engines/zvision/timer_node.h | 4 +- engines/zvision/truetype_font.cpp | 12 ++-- engines/zvision/truetype_font.h | 6 +- engines/zvision/utility.cpp | 12 ++-- engines/zvision/utility.h | 6 +- engines/zvision/video.cpp | 2 +- engines/zvision/zfs_archive.cpp | 6 +- engines/zvision/zfs_archive.h | 2 +- engines/zvision/zork_avi_decoder.h | 2 +- engines/zvision/zork_raw.cpp | 17 +++-- engines/zvision/zork_raw.h | 28 +++++--- engines/zvision/zvision.cpp | 40 +++++------ engines/zvision/zvision.h | 52 +++++++++----- 50 files changed, 465 insertions(+), 377 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index fb4034fbdb..1d4ce9c604 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -103,8 +103,8 @@ bool ActionChangeLocation::execute(ZVision *engine) { ActionCrossfade::ActionCrossfade(const Common::String &line) { sscanf(line.c_str(), - "%*[^(](%u %u %u %u %u %u %u)", - &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); + "%*[^(](%u %u %u %u %u %u %u)", + &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); } bool ActionCrossfade::execute(ZVision *engine) { @@ -123,7 +123,7 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) { bool ActionDisableControl::execute(ZVision *engine) { debug("Disabling control %u", _key); - + engine->getScriptManager()->disableControl(_key); return true; @@ -189,7 +189,7 @@ bool ActionMusic::execute(ZVision *engine) { } else { audioStream = makeRawZorkStream(_fileName, engine); } - + if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume); @@ -235,8 +235,8 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) { // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)", - &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate); + "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)", + &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate); _fileName = Common::String(fileName); } @@ -253,8 +253,8 @@ bool ActionPlayAnimation::execute(ZVision *engine) { ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) { sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)", - &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); + "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)", + &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); } bool ActionPlayPreloadAnimation::execute(ZVision *engine) { @@ -320,7 +320,7 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) { bool ActionSetPartialScreen::execute(ZVision *engine) { RenderManager *renderManager = engine->getRenderManager(); - + if (_backgroundColor > 0) { renderManager->clearWorkingWindowTo555Color(_backgroundColor); } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index afa3e3a2ac..e7a4ea302f 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -319,7 +319,7 @@ public: private: enum { - DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions + DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions }; Common::String _fileName; diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 1143380501..66eefd7ce6 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -38,13 +38,13 @@ namespace ZVision { AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName) - : Control(engine, controlKey), - _fileType(RLF), - _loopCount(1), - _currentLoop(0), - _accumulatedTime(0), - _cachedFrame(0), - _cachedFrameNeedsDeletion(false) { + : Control(engine, controlKey), + _fileType(RLF), + _loopCount(1), + _currentLoop(0), + _accumulatedTime(0), + _cachedFrame(0), + _cachedFrameNeedsDeletion(false) { if (fileName.hasSuffix(".rlf")) { _fileType = RLF; _animation.rlf = new RlfAnimation(fileName, false); diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h index 2ac3691483..247fbf765d 100644 --- a/engines/zvision/animation_control.h +++ b/engines/zvision/animation_control.h @@ -50,13 +50,13 @@ public: private: enum FileType { - RLF = 1, - AVI = 2 + RLF = 1, + AVI = 2 }; private: uint32 _animationKey; - + union { RlfAnimation *rlf; Video::VideoDecoder *avi; @@ -76,10 +76,18 @@ private: public: bool process(uint32 deltaTimeInMillis); - void setAnimationKey(uint32 animationKey) { _animationKey = animationKey; } - void setLoopCount(uint loopCount) { _loopCount = loopCount; } - void setXPos(int32 x) { _x = x; } - void setYPost(int32 y) { _y = y; } + void setAnimationKey(uint32 animationKey) { + _animationKey = animationKey; + } + void setLoopCount(uint loopCount) { + _loopCount = loopCount; + } + void setXPos(int32 x) { + _x = x; + } + void setYPost(int32 y) { + _y = y; + } }; } // End of namespace ZVision diff --git a/engines/zvision/clock.cpp b/engines/zvision/clock.cpp index c8ee717a33..d78cf6e2c1 100644 --- a/engines/zvision/clock.cpp +++ b/engines/zvision/clock.cpp @@ -30,7 +30,7 @@ namespace ZVision { -Clock::Clock(OSystem *system) +Clock::Clock(OSystem *system) : _system(system), _lastTime(0), _deltaTime(0), diff --git a/engines/zvision/clock.h b/engines/zvision/clock.h index 3939ba1612..3740e07881 100644 --- a/engines/zvision/clock.h +++ b/engines/zvision/clock.h @@ -53,22 +53,26 @@ public: * * @return Delta time since the last frame (in milliseconds) */ - uint32 getDeltaTime() const { return _deltaTime; } + uint32 getDeltaTime() const { + return _deltaTime; + } /** * Get the time from the program starting to the last update() call * * @return Time from program start to last update() call (in milliseconds) */ - uint32 getLastMeasuredTime() { return _lastTime; } + uint32 getLastMeasuredTime() { + return _lastTime; + } /** * Pause the clock. Any future delta times will take this pause into account. - * Has no effect if the clock is already paused. + * Has no effect if the clock is already paused. */ void start(); /** * Un-pause the clock. - * Has no effect if the clock is already un-paused. + * Has no effect if the clock is already un-paused. */ void stop(); }; diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 770c540a12..ab55763a20 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -42,7 +42,9 @@ public: Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {} virtual ~Control() {} - uint32 getKey() { return _key; } + uint32 getKey() { + return _key; + } virtual void enable(); virtual void disable(); @@ -69,7 +71,9 @@ public: * @param backgroundImageSpacePos The position of the mouse in background image space * @return Was the cursor changed? */ - virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { return false; } + virtual bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + return false; + } /** * Called when a key is pressed. Default is NOP. * @@ -88,14 +92,16 @@ public: * @param deltaTimeInMillis The number of milliseconds that have passed since last frame * @return If true, the node can be deleted after process() finishes */ - virtual bool process(uint32 deltaTimeInMillis) { return false; } + virtual bool process(uint32 deltaTimeInMillis) { + return false; + } /** * Serialize a Control for save game use. This should only be used if a Control needs * to save values that would be different from initialization. AKA a TimerNode needs to * store the amount of time left on the timer. Any Controls overriding this *MUST* write * their key as the first data outputted. The default implementation is NOP. * - * NOTE: If this method is overridden, you MUST also override deserialize() + * NOTE: If this method is overridden, you MUST also override deserialize() * and needsSerialization() * * @param stream Stream to write any needed data to @@ -118,10 +124,12 @@ public: * * @return Does the Control need save game serialization? */ - virtual inline bool needsSerialization() { return false; } + virtual inline bool needsSerialization() { + return false; + } protected: - ZVision * _engine; + ZVision *_engine; uint32 _key; bool _enabled; diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp index 9023d97e0d..5386c8ead6 100644 --- a/engines/zvision/cursor.cpp +++ b/engines/zvision/cursor.cpp @@ -30,18 +30,18 @@ namespace ZVision { -ZorkCursor::ZorkCursor() +ZorkCursor::ZorkCursor() : _width(0), _height(0), _hotspotX(0), _hotspotY(0) { } -ZorkCursor::ZorkCursor(const Common::String &fileName) - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { +ZorkCursor::ZorkCursor(const Common::String &fileName) + : _width(0), + _height(0), + _hotspotX(0), + _hotspotY(0) { Common::File file; if (!file.open(fileName)) return; diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h index 18ac28ce8b..8f119c8982 100644 --- a/engines/zvision/cursor.h +++ b/engines/zvision/cursor.h @@ -32,7 +32,7 @@ class String; namespace ZVision { -/** +/** * Utility class to parse and hold cursor data * Modeled off Graphics::Cursor */ @@ -53,12 +53,24 @@ private: public: ZorkCursor &operator=(const ZorkCursor &other); - uint16 getWidth() const { return _width; } - uint16 getHeight() const { return _height; } - uint16 getHotspotX() const { return _hotspotX; } - uint16 getHotspotY() const { return _hotspotY; } - byte getKeyColor() const { return 0; } - const byte *getSurface() const { return (const byte *)_surface.getPixels(); } + uint16 getWidth() const { + return _width; + } + uint16 getHeight() const { + return _height; + } + uint16 getHotspotX() const { + return _hotspotX; + } + uint16 getHotspotY() const { + return _hotspotY; + } + byte getKeyColor() const { + return 0; + } + const byte *getSurface() const { + return (const byte *)_surface.getPixels(); + } }; } // End of namespace ZVision diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index 4c5ae5e80f..015e2b014f 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -35,19 +35,22 @@ namespace ZVision { const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" }; + "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" + }; const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", - "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" }; + "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" + }; const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" }; + "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" + }; CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) - : _engine(engine), - _pixelFormat(pixelFormat), - _cursorIsPushed(false) { + : _engine(engine), + _pixelFormat(pixelFormat), + _cursorIsPushed(false) { // WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly if (_engine->getGameId() == GID_NEMESIS) { Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX])); diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h index 0a369aaf9e..0173bf810c 100644 --- a/engines/zvision/cursor_manager.h +++ b/engines/zvision/cursor_manager.h @@ -48,9 +48,9 @@ public: private: enum { - NUM_CURSORS = 18, - // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly - IDLE_CURSOR_INDEX = 11 + NUM_CURSORS = 18, + // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly + IDLE_CURSOR_INDEX = 11 }; ZVision *_engine; @@ -77,7 +77,7 @@ public: /** * Parses a cursor name into a cursor file then creates and shows that cursor. * - * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[] + * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[] * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) */ void changeCursor(const Common::String &cursorName, bool pushed); diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 49664935e1..4ab0d6c85d 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -134,22 +134,22 @@ public: bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const { return false; - /* - (f == kSupportsListSaves) || - (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate) || - (f == kSavesSupportPlayTime); - */ + /* + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate) || + (f == kSavesSupportPlayTime); + */ } /*bool ZVision::ZVision::hasFeature(EngineFeature f) const { - return - (f == kSupportsRTL) || - (f == kSupportsLoadingDuringRuntime) || - (f == kSupportsSavingDuringRuntime); + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); }*/ bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { @@ -174,23 +174,23 @@ SaveStateList ZVisionMetaEngine::listSaves(const char *target) const { Common::StringArray filenames; filenames = saveFileMan->listSavefiles(pattern.c_str()); - Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/ + Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/ SaveStateList saveList; -/* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) { - // Obtain the last 3 digits of the filename, since they correspond to the save slot - int slotNum = atoi(file->c_str() + file->size() - 3); - - if (slotNum >= 0 && slotNum <= 999) { - Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); - if (in) { - if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) { - saveList.push_back(SaveStateDescriptor(slotNum, header.description)); - } - delete in; - } - } - }*/ + /* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); + if (in) { + if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) { + saveList.push_back(SaveStateDescriptor(slotNum, header.description)); + } + delete in; + } + } + }*/ return saveList; } @@ -210,17 +210,17 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const { Common::String pattern = target; pattern += ".???"; filenames = saveFileMan->listSavefiles(pattern.c_str()); - Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { - // Obtain the last 3 digits of the filename, since they correspond to the save slot - int slotNum = atoi(file->c_str() + file->size() - 3); - - // Rename every slot greater than the deleted slot, - if (slotNum > slot) { - saveFileMan->renameSavefile(file->c_str(), filename.c_str()); - filename = ZVision::ZVision::getSavegameFilename(target, ++slot); - } + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + // Rename every slot greater than the deleted slot, + if (slotNum > slot) { + saveFileMan->renameSavefile(file->c_str(), filename.c_str()); + filename = ZVision::ZVision::getSavegameFilename(target, ++slot); + } } */ } @@ -231,34 +231,34 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str()); if (in) { - ZVision::ZVision::SaveHeader header; - ZVision::ZVision::kReadSaveHeaderError error; + ZVision::ZVision::SaveHeader header; + ZVision::ZVision::kReadSaveHeaderError error; - error = ZVision::ZVision::readSaveHeader(in, true, header); - delete in; + error = ZVision::ZVision::readSaveHeader(in, true, header); + delete in; - if (error == ZVision::ZVision::kRSHENoError) { - SaveStateDescriptor desc(slot, header.description); + if (error == ZVision::ZVision::kRSHENoError) { + SaveStateDescriptor desc(slot, header.description); - desc.setThumbnail(header.thumbnail); + desc.setThumbnail(header.thumbnail); - if (header.version > 0) { - int day = (header.saveDate >> 24) & 0xFF; - int month = (header.saveDate >> 16) & 0xFF; - int year = header.saveDate & 0xFFFF; + if (header.version > 0) { + int day = (header.saveDate >> 24) & 0xFF; + int month = (header.saveDate >> 16) & 0xFF; + int year = header.saveDate & 0xFFFF; - desc.setSaveDate(year, month, day); + desc.setSaveDate(year, month, day); - int hour = (header.saveTime >> 16) & 0xFF; - int minutes = (header.saveTime >> 8) & 0xFF; + int hour = (header.saveTime >> 16) & 0xFF; + int minutes = (header.saveTime >> 8) & 0xFF; - desc.setSaveTime(hour, minutes); + desc.setSaveTime(hour, minutes); - desc.setPlayTime(header.playTime * 1000); - } + desc.setPlayTime(header.playTime * 1000); + } - return desc; - } + return desc; + } } */ @@ -266,7 +266,7 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in } #if PLUGIN_ENABLED_DYNAMIC(ZVISION) - REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine); +REGISTER_PLUGIN_DYNAMIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine); #else - REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine); +REGISTER_PLUGIN_STATIC(ZVISION, PLUGIN_TYPE_ENGINE, ZVisionMetaEngine); #endif diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h index 34417601e8..1f430dac1c 100644 --- a/engines/zvision/detection.h +++ b/engines/zvision/detection.h @@ -29,9 +29,9 @@ namespace ZVision { enum ZVisionGameId { - GID_NONE = 0, - GID_NEMESIS = 1, - GID_GRANDINQUISITOR = 2 + GID_NONE = 0, + GID_NEMESIS = 1, + GID_GRANDINQUISITOR = 2 }; struct ZVisionGameDescription { diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp index a445e1aae5..5723a4e4a4 100644 --- a/engines/zvision/input_control.cpp +++ b/engines/zvision/input_control.cpp @@ -37,12 +37,12 @@ namespace ZVision { -InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key), - _nextTabstop(0), - _focused(false), - _textChanged(false), - _cursorOffset(0) { +InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key), + _nextTabstop(0), + _focused(false), + _textChanged(false), + _cursorOffset(0) { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h index aab2c991dc..3d7db747d7 100644 --- a/engines/zvision/input_control.h +++ b/engines/zvision/input_control.h @@ -48,8 +48,12 @@ private: uint _cursorOffset; public: - void focus() { _focused = true; } - void unfocus() { _focused = false; } + void focus() { + _focused = true; + } + void unfocus() { + _focused = false; + } void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); void onKeyDown(Common::KeyState keyState); bool process(uint32 deltaTimeInMillis); diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index 79049b8fcb..b0f9417042 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -43,16 +43,16 @@ namespace ZVision { LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key), - _frameInfo(0), - _frameCount(0), - _startFrame(0), - _currentFrame(0), - _lastRenderedFrame(0), - _mouseIsCaptured(false), - _isReturning(false), - _accumulatedTime(0), - _returnRoutesCurrentFrame(0) { + : Control(engine, key), + _frameInfo(0), + _frameCount(0), + _startFrame(0), + _currentFrame(0), + _lastRenderedFrame(0), + _mouseIsCaptured(false), + _isReturning(false), + _accumulatedTime(0), + _returnRoutesCurrentFrame(0) { // Loop until we find the closing brace Common::String line = stream.readLine(); @@ -84,7 +84,7 @@ LeverControl::~LeverControl() { } else if (_fileType == RLF) { delete _animation.rlf; } - + delete[] _frameInfo; } @@ -194,7 +194,7 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common if (!_enabled) { return; } - + if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { _mouseIsCaptured = true; _lastMousePos = backgroundImageSpacePos; @@ -205,7 +205,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: if (!_enabled) { return; } - + if (_mouseIsCaptured) { _mouseIsCaptured = false; _engine->getScriptManager()->setStateValue(_key, _currentFrame); @@ -220,7 +220,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common if (!_enabled) { return false; } - + bool cursorWasChanged = false; if (_mouseIsCaptured) { @@ -276,7 +276,7 @@ bool LeverControl::process(uint32 deltaTimeInMillis) { renderFrame(_returnRoutesCurrentFrame); } } - + return false; } @@ -387,7 +387,7 @@ void LeverControl::renderFrame(uint frameNumber) { // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can frameData = (const uint16 *)_animation.rlf->getFrameData(frameNumber)->getPixels(); width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width() - height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height() + height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height() } else if (_fileType == AVI) { _animation.avi->seekToFrame(frameNumber); const Graphics::Surface *surface = _animation.avi->decodeNextFrame(); diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h index 8ef8f06fec..94d23c1f95 100644 --- a/engines/zvision/lever_control.h +++ b/engines/zvision/lever_control.h @@ -41,8 +41,8 @@ public: private: enum FileType { - RLF = 1, - AVI = 2 + RLF = 1, + AVI = 2 }; struct Direction { @@ -59,8 +59,8 @@ private: }; enum { - ANGLE_DELTA = 30, // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA) - ANIMATION_FRAME_TIME = 30 // In millis + ANGLE_DELTA = 30, // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA) + ANIMATION_FRAME_TIME = 30 // In millis }; private: diff --git a/engines/zvision/lzss_read_stream.cpp b/engines/zvision/lzss_read_stream.cpp index bbbda6f526..b36bf5f7c0 100644 --- a/engines/zvision/lzss_read_stream.cpp +++ b/engines/zvision/lzss_read_stream.cpp @@ -28,10 +28,10 @@ namespace ZVision { LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) - : _source(source), - // It's convention to set the starting cursor position to blockSize - 16 - _windowCursor(0x0FEE), - _eosFlag(false) { + : _source(source), + // It's convention to set the starting cursor position to blockSize - 16 + _windowCursor(0x0FEE), + _eosFlag(false) { // Clear the window to null memset(_window, 0, BLOCK_SIZE); } @@ -69,9 +69,9 @@ uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) } uint16 length = (high & 0xF) + 2; - uint16 offset = low | ((high & 0xF0)<<4); + uint16 offset = low | ((high & 0xF0) << 4); - for(int j = 0; j <= length; ++j) { + for (int j = 0; j <= length; ++j) { byte temp = _window[(offset + j) & 0xFFF]; _window[_windowCursor] = temp; destination[destinationCursor++] = temp; diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index f6b1eb1a65..1f7df9d4e0 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -36,7 +36,7 @@ namespace ZVision { class LzssReadStream : public Common::ReadStream { public: /** - * A class that decompresses LZSS data and implements ReadStream for easy access + * A class that decompresses LZSS data and implements ReadStream for easy access * to the decompiled data. * * @param source The source data @@ -45,7 +45,7 @@ public: private: enum { - BLOCK_SIZE = 0x1000 + BLOCK_SIZE = 0x1000 }; private: @@ -64,7 +64,7 @@ private: * * @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes */ - uint32 decompressBytes(byte* destination, uint32 numberOfBytes); + uint32 decompressBytes(byte *destination, uint32 numberOfBytes); }; } diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 689311ba5b..21a1c41548 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -35,7 +35,7 @@ namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key) { + : Control(engine, key) { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -76,7 +76,7 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com if (!_enabled) { return; } - + if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getScriptManager()->setStateValue(_key, 1); } @@ -86,7 +86,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C if (!_enabled) { return false; } - + if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_hoverCursor); return true; diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index 1e730365dc..2eea52f80b 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -42,17 +42,17 @@ struct Puzzle { /** How criteria should be decided */ enum CriteriaOperator { - EQUAL_TO, - NOT_EQUAL_TO, - GREATER_THAN, - LESS_THAN + EQUAL_TO, + NOT_EQUAL_TO, + GREATER_THAN, + LESS_THAN }; /** Criteria for a Puzzle result to be fired */ struct CriteriaEntry { /** The key of a global state */ uint32 key; - /** + /** * What we're comparing the value of the global state against * This can either be a pure value or it can be the key of another global state */ @@ -64,9 +64,9 @@ struct Puzzle { }; enum StateFlags { - ONCE_PER_INST = 0x01, - DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria - DISABLED = 0x04 + ONCE_PER_INST = 0x01, + DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria + DISABLED = 0x04 }; uint32 key; diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index cb13606b11..1406fbc828 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -38,19 +38,19 @@ namespace ZVision { RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) - : _system(system), - _workingWidth(workingWindow.width()), - _workingHeight(workingWindow.height()), - _screenCenterX(_workingWidth / 2), - _screenCenterY(_workingHeight / 2), - _workingWindow(workingWindow), - _pixelFormat(pixelFormat), - _backgroundWidth(0), - _backgroundHeight(0), - _backgroundInverseVelocity(0), - _backgroundOffset(0, 0), - _accumulatedVelocityMilliseconds(0), - _renderTable(_workingWidth, _workingHeight) { + : _system(system), + _workingWidth(workingWindow.width()), + _workingHeight(workingWindow.height()), + _screenCenterX(_workingWidth / 2), + _screenCenterY(_workingHeight / 2), + _workingWindow(workingWindow), + _pixelFormat(pixelFormat), + _backgroundWidth(0), + _backgroundHeight(0), + _backgroundInverseVelocity(0), + _backgroundOffset(0, 0), + _accumulatedVelocityMilliseconds(0), + _renderTable(_workingWidth, _workingHeight) { _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat); _backBuffer.create(windowWidth, windowHeight, pixelFormat); @@ -159,7 +159,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) { } } -void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { +void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { int16 subRectX = 0; int16 subRectY = 0; @@ -184,8 +184,8 @@ void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 dest if (wrap) { _backgroundWidth = surface.w; _backgroundHeight = surface.h; - - if (destinationX > 0) { + + if (destinationX > 0) { // Move destinationX to 0 subRectX = surface.w - destinationX; destinationX = 0; @@ -373,7 +373,7 @@ Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Com entry.alphaColor = 0; entry.destX = destX; entry.destY = destY; - + // Draw the text to the working window entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap); entry.width = entry.data->w; diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 111bf6276c..9fedd1d8dd 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -89,7 +89,7 @@ private: /** Center of the screen in the y direction */ const int _screenCenterY; - /** + /** * A Rectangle centered inside the actual window. All in-game coordinates * are given in this coordinate space. Also, all images are clipped to the * edges of this Rectangle @@ -106,7 +106,7 @@ private: /** The height of the current background image */ uint16 _backgroundHeight; - /** + /** * The "velocity" at which the background image is panning. We actually store the inverse of velocity (ms/pixel instead of pixels/ms) * because it allows you to accumulate whole pixels 'steps' instead of rounding pixels every frame */ @@ -135,13 +135,17 @@ public: /** * Clears the AlphaEntry list */ - void clearAlphaEntries() { _alphaDataEntries.clear(); } + void clearAlphaEntries() { + _alphaDataEntries.clear(); + } /** * Removes a specific AlphaEntry from the list * * @param idNumber The id number identifing the AlphaEntry */ - void removeAlphaEntry(uint32 idNumber) { _alphaDataEntries.erase(idNumber); } + void removeAlphaEntry(uint32 idNumber) { + _alphaDataEntries.erase(idNumber); + } /** * Copies a sub-rectangle of a buffer to the working window @@ -224,17 +228,17 @@ public: /** * Set the background position (_backgroundOffset). If the current RenderState is PANORAMA, the offset * will be in the horizontal direction. If the current RenderState is TILT, the offset will be in the - * vertical direction. + * vertical direction. * - * This method will not render anything on the screen. So if nothing else is called that renders the + * This method will not render anything on the screen. So if nothing else is called that renders the * background, the change won't be seen until next frame. * * @param offset The amount to offset the background */ void setBackgroundPosition(int offset); - + /** - * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and + * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and * positive velocities correspond to right / down scrolling * * @param velocity Velocity @@ -249,7 +253,7 @@ public: */ const Common::Point screenSpaceToImageSpace(const Common::Point &point); /** - * Converts a point in image coordinate space to ***PRE-WARP*** + * Converts a point in image coordinate space to ***PRE-WARP*** * working window coordinate space * * @param point Point in image coordinate space @@ -268,7 +272,9 @@ public: RenderTable *getRenderTable(); uint32 getCurrentBackgroundOffset(); - const Graphics::Surface *getBackBuffer() { return &_backBuffer; } + const Graphics::Surface *getBackBuffer() { + return &_backBuffer; + } /** * Creates a copy of surface and transposes the data. @@ -313,7 +319,7 @@ private: * Move the background image by an offset. If we are currently in Panorama mode, * the offset will correspond to a horizontal motion. If we are currently in Tilt mode, * the offset will correspond to a vertical motion. This function should not be called - * if we are in Flat mode. + * if we are in Flat mode. * * The RenderManager will take care of wrapping the image. * Ex: If the image has width 1400px, it is legal to offset 1500px. diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp index b6a6a3d2bb..5a0bae7c22 100644 --- a/engines/zvision/render_table.cpp +++ b/engines/zvision/render_table.cpp @@ -32,9 +32,9 @@ namespace ZVision { RenderTable::RenderTable(uint numColumns, uint numRows) - : _numRows(numRows), - _numColumns(numColumns), - _renderState(FLAT) { + : _numRows(numRows), + _numColumns(numColumns), + _renderState(FLAT) { assert(numRows != 0 && numColumns != 0); _internalBuffer = new Common::Point[numRows * numColumns]; @@ -97,12 +97,12 @@ uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) { uint16 returnColor = (byte(rFinal + 0.5f) << Graphics::ColorMasks<555>::kRedShift) | (byte(gFinal + 0.5f) << Graphics::ColorMasks<555>::kGreenShift) | - (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift); + (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift); return returnColor; } -void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect) { +void RenderTable::mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect) { uint32 destOffset = 0; for (int16 y = subRect.top; y < subRect.bottom; ++y) { @@ -115,7 +115,7 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 d // RenderTable only stores offsets from the original coordinates uint32 sourceYIndex = y + _internalBuffer[index].y; uint32 sourceXIndex = x + _internalBuffer[index].x; - + destBuffer[destOffset + normalizedX] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex]; } @@ -154,11 +154,11 @@ void RenderTable::generatePanoramaLookupTable() { // To get x in cylinder coordinates, we just need to calculate the arc length // We also scale it by _panoramaOptions.linearScale int32 xInCylinderCoords = int32(floor((cylinderRadius * _panoramaOptions.linearScale * alpha) + halfWidth)); - + float cosAlpha = cos(alpha); for (uint y = 0; y < _numRows; ++y) { - // To calculate y in cylinder coordinates, we can do similar triangles comparison, + // To calculate y in cylinder coordinates, we can do similar triangles comparison, // comparing the triangle from the center to the screen and from the center to the edge of the cylinder int32 yInCylinderCoords = int32(floor(halfHeight + ((float)y - halfHeight) * cosAlpha)); @@ -179,7 +179,7 @@ void RenderTable::generateTiltLookupTable() { float cylinderRadius = halfWidth / tan(fovInRadians); for (uint y = 0; y < _numRows; ++y) { - + // Add an offset of 0.01 to overcome zero tan/atan issue (horizontal line on half of screen) // Alpha represents the vertical angle between the viewer at the center of a cylinder and y float alpha = atan(((float)y - halfHeight + 0.01f) / cylinderRadius); @@ -192,7 +192,7 @@ void RenderTable::generateTiltLookupTable() { uint32 columnIndex = y * _numColumns; for (uint x = 0; x < _numColumns; ++x) { - // To calculate x in cylinder coordinates, we can do similar triangles comparison, + // To calculate x in cylinder coordinates, we can do similar triangles comparison, // comparing the triangle from the center to the screen and from the center to the edge of the cylinder int32 xInCylinderCoords = int32(floor(halfWidth + ((float)x - halfWidth) * cosAlpha)); diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h index 898091193a..401e627747 100644 --- a/engines/zvision/render_table.h +++ b/engines/zvision/render_table.h @@ -35,9 +35,9 @@ public: public: enum RenderState { - PANORAMA, - TILT, - FLAT + PANORAMA, + TILT, + FLAT }; private: @@ -59,12 +59,14 @@ private: } _tiltOptions; public: - RenderState getRenderState() { return _renderState; } + RenderState getRenderState() { + return _renderState; + } void setRenderState(RenderState newState); const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point); - void mutateImage(uint16 *sourceBuffer, uint16* destBuffer, uint32 destWidth, const Common::Rect &subRect); + void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect); void generateRenderTable(); void setPanoramaFoV(float fov); diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index 5f1d41daae..795167e572 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -35,16 +35,16 @@ namespace ZVision { -RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) - : _stream(stream), - _lastFrameRead(0), - _frameCount(0), - _width(0), - _height(0), - _frameTime(0), - _frames(0), - _currentFrame(-1), - _frameBufferByteSize(0) { +RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) + : _stream(stream), + _lastFrameRead(0), + _frameCount(0), + _width(0), + _height(0), + _frameTime(0), + _frames(0), + _currentFrame(-1), + _frameBufferByteSize(0) { if (!_file.open(fileName)) { warning("RLF animation file %s could not be opened", fileName.c_str()); return; @@ -255,8 +255,8 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3 numberOfSamples--; } - // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2) - // This function assumes the dest buffer has been memset with 0's. + // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2) + // This function assumes the dest buffer has been memset with 0's. } else { if (sourceOffset + 1 >= sourceSize) { return; @@ -301,8 +301,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3 numberOfSamples--; } - // If numberOfSamples is >= 0, copy one sample from source to the - // next (numberOfSamples + 2) dest spots + // If numberOfSamples is >= 0, copy one sample from source to the + // next (numberOfSamples + 2) dest spots } else { if (sourceOffset + 1 >= sourceSize) { return; diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index fe5b0d68b4..b0f7ee204e 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -41,8 +41,8 @@ public: private: enum EncodingType { - Masked, - Simple + Masked, + Simple }; struct Frame { @@ -68,10 +68,18 @@ private: uint32 _frameBufferByteSize; public: - uint frameCount() { return _frameCount; } - uint width() { return _width; } - uint height() { return _height; } - uint32 frameTime() { return _frameTime; } + uint frameCount() { + return _frameCount; + } + uint width() { + return _width; + } + uint height() { + return _height; + } + uint32 frameTime() { + return _frameTime; + } /** * Seeks to the frameNumber and updates the internal Surface with @@ -104,7 +112,9 @@ public: /** * @return Is the currentFrame is the last frame in the animation? */ - bool endOfAnimation() { return _currentFrame == (int)_frameCount - 1; } + bool endOfAnimation() { + return _currentFrame == (int)_frameCount - 1; + } private: /** diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp index c3deadd703..528dd0f35b 100644 --- a/engines/zvision/save_manager.cpp +++ b/engines/zvision/save_manager.cpp @@ -106,7 +106,7 @@ void SaveManager::autoSave() { void SaveManager::writeSaveGameData(Common::OutSaveFile *file) { // Create a thumbnail and save it Graphics::saveThumbnail(*file); - + // Write out the save date/time TimeDate td; g_system->getTimeAndDate(td); @@ -171,7 +171,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea warning("File is not a ZVision save file. Aborting load"); return false; } - + // Read in the version header.version = in->readByte(); diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h index b4770e68b2..9de1c51900 100644 --- a/engines/zvision/save_manager.h +++ b/engines/zvision/save_manager.h @@ -54,13 +54,13 @@ private: static const uint32 SAVEGAME_ID; enum { - SAVE_VERSION = 1 + SAVE_VERSION = 1 }; public: /** * Called every room change. Saves the state of the room just before - * we switched rooms. Uses ZVision::generateAutoSaveFileName() to + * we switched rooms. Uses ZVision::generateAutoSaveFileName() to * create the save file name. */ void autoSave(); diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index e90408cf0d..5fed820103 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -44,7 +44,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) return; } - while(!file.eos()) { + while (!file.eos()) { Common::String line = file.readLine(); if (file.err()) { warning("Error parsing scr file: %s", fileName.c_str()); @@ -57,7 +57,7 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) if (line.matchString("puzzle:*", true)) { Puzzle *puzzle = new Puzzle(); - sscanf(line.c_str(),"puzzle:%u",&(puzzle->key)); + sscanf(line.c_str(), "puzzle:%u", &(puzzle->key)); parsePuzzle(puzzle, file); if (isGlobal) { @@ -236,7 +236,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:ttytext*", true)) { // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { - // TODO: Implement ActionUniverseMusic + // TODO: Implement ActionUniverseMusic } else if (line.matchString("*:copy_file*", true)) { // Not used. Purposely left empty } else { diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 4b4f1303aa..72e67bfa7f 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -46,13 +46,13 @@ ScriptManager::ScriptManager(ZVision *engine) ScriptManager::~ScriptManager() { for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { - delete (*iter); + delete(*iter); } for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) { - delete (*iter); + delete(*iter); } for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - delete (*iter); + delete(*iter); } } @@ -108,10 +108,10 @@ void ScriptManager::createReferenceTable() { } void ScriptManager::updateNodes(uint deltaTimeMillis) { - // If process() returns true, it means the node can be deleted + // If process() returns true, it means the node can be deleted for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { if ((*iter)->process(deltaTimeMillis)) { - delete (*iter); + delete(*iter); // Remove the node iter = _activeSideFx.erase(iter); } else { @@ -121,7 +121,7 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) { // If process() returns true, it means the node can be deleted for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { if ((*iter)->process(deltaTimeMillis)) { - delete (*iter); + delete(*iter); // Remove the node iter = _activeControls.erase(iter); } else { @@ -137,7 +137,7 @@ void ScriptManager::checkPuzzleCriteria() { // Check if the puzzle is already finished // Also check that the puzzle isn't disabled if (getStateValue(puzzle->key) == 1 && - (puzzle->flags & Puzzle::DISABLED) == 0) { + (puzzle->flags & Puzzle::DISABLED) == 0) { continue; } @@ -341,11 +341,11 @@ void ScriptManager::changeLocation(char world, char room, char node, char view, _referenceTable.clear(); _puzzlesToCheck.clear(); for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { - delete (*iter); + delete(*iter); } _activePuzzles.clear(); for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - delete (*iter); + delete(*iter); } _activeControls.clear(); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index c29bc57d03..d47ee94da4 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -64,9 +64,9 @@ public: private: ZVision *_engine; - /** - * Holds the global state variable. Do NOT directly modify this. Use the accessors and - * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a + /** + * Holds the global state variable. Do NOT directly modify this. Use the accessors and + * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a * particular state key are checked after the key is modified. */ StateMap _globalState; @@ -169,7 +169,7 @@ public: private: /** * Parses the stream into a Puzzle object - * Helper method for parseScrFile. + * Helper method for parseScrFile. * * @param puzzle The object to store what is parsed * @param stream Scr file stream @@ -178,7 +178,7 @@ private: /** * Parses the stream into a Criteria object - * Helper method for parsePuzzle. + * Helper method for parsePuzzle. * * @param criteria Pointer to the Criteria object to fill * @param stream Scr file stream @@ -188,7 +188,7 @@ private: /** * Parses the stream into a ResultAction objects - * Helper method for parsePuzzle. + * Helper method for parsePuzzle. * * @param stream Scr file stream * @param actionList The list where the results will be added diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index d495655a22..6f75ad6649 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -36,19 +36,25 @@ class ZVision; class SideFX { public: - enum SideFXType{ - SIDEFX_UNK = 0, - SIDEFX_TIMER = 1 + enum SideFXType { + SIDEFX_UNK = 0, + SIDEFX_TIMER = 1 }; SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {} virtual ~SideFX() {} - uint32 getKey() { return _key; } - SideFXType getType() { return _type; } + uint32 getKey() { + return _key; + } + SideFXType getType() { + return _type; + } - virtual bool process(uint32 deltaTimeInMillis) { return false; } + virtual bool process(uint32 deltaTimeInMillis) { + return false; + } /** * Serialize a SideFX for save game use. This should only be used if a SideFX needs * to save values that would be different from initialization. AKA a TimerNode needs to @@ -78,10 +84,12 @@ public: * * @return Does the SideFX need save game serialization? */ - virtual inline bool needsSerialization() { return false; } + virtual inline bool needsSerialization() { + return false; + } protected: - ZVision * _engine; + ZVision *_engine; uint32 _key; SideFXType _type; diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h index 45b5a89e95..33fe69d760 100644 --- a/engines/zvision/single_value_container.h +++ b/engines/zvision/single_value_container.h @@ -30,21 +30,21 @@ class String; namespace ZVision { /** - * A generic single value storage class. It is useful for storing different + * A generic single value storage class. It is useful for storing different * value types in a single List, Hashmap, etc. */ class SingleValueContainer { public: enum ValueType { - BOOL, - BYTE, - INT16, - UINT16, - INT32, - UINT32, - FLOAT, - DOUBLE, - STRING + BOOL, + BYTE, + INT16, + UINT16, + INT32, + UINT32, + FLOAT, + DOUBLE, + STRING }; // Constructors @@ -60,7 +60,7 @@ public: explicit SingleValueContainer(Common::String value); // Copy constructor - explicit SingleValueContainer(const SingleValueContainer& other); + explicit SingleValueContainer(const SingleValueContainer &other); // Destructor ~SingleValueContainer(); @@ -91,10 +91,10 @@ public: SingleValueContainer &operator=(const double &rhs); SingleValueContainer &operator=(const Common::String &rhs); - SingleValueContainer& operator=(const SingleValueContainer &rhs); + SingleValueContainer &operator=(const SingleValueContainer &rhs); /** - * Retrieve a bool from the container. If the container is not storing a + * Retrieve a bool from the container. If the container is not storing a * bool, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -102,7 +102,7 @@ public: */ bool getBoolValue(bool *returnValue) const; /** - * Retrieve a byte from the container. If the container is not storing a + * Retrieve a byte from the container. If the container is not storing a * byte, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -110,7 +110,7 @@ public: */ bool getByteValue(byte *returnValue) const; /** - * Retrieve an int16 from the container. If the container is not storing an + * Retrieve an int16 from the container. If the container is not storing an * int16, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -118,7 +118,7 @@ public: */ bool getInt16Value(int16 *returnValue) const; /** - * Retrieve a uint16 from the container. If the container is not storing a + * Retrieve a uint16 from the container. If the container is not storing a * uint16, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -126,7 +126,7 @@ public: */ bool getUInt16Value(uint16 *returnValue) const; /** - * Retrieve an int32 from the container. If the container is not storing an + * Retrieve an int32 from the container. If the container is not storing an * int32, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -134,7 +134,7 @@ public: */ bool getInt32Value(int32 *returnValue) const; /** - * Retrieve a uint32 from the container. If the container is not storing a + * Retrieve a uint32 from the container. If the container is not storing a * uint32, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -142,7 +142,7 @@ public: */ bool getUInt32Value(uint32 *returnValue) const; /** - * Retrieve a float from the container. If the container is not storing a + * Retrieve a float from the container. If the container is not storing a * float, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -150,7 +150,7 @@ public: */ bool getFloatValue(float *returnValue) const; /** - * Retrieve a double from the container. If the container is not storing a + * Retrieve a double from the container. If the container is not storing a * double, this will return false and display a warning(). * * @param returnValue Pointer to where you want the value stored @@ -158,9 +158,9 @@ public: */ bool getDoubleValue(double *returnValue) const; /** - * Retrieve a String from the container. If the container is not storing a + * Retrieve a String from the container. If the container is not storing a * string, this will return false and display a warning(). - * + * * Caution: Strings are internally stored as char[]. getStringValue uses * Common::String::operator=(char *) to do the assigment, which uses both * strlen() AND memmove(). diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp index ab42f3d3e0..f8a48682ac 100644 --- a/engines/zvision/string_manager.cpp +++ b/engines/zvision/string_manager.cpp @@ -36,7 +36,7 @@ namespace ZVision { -StringManager::StringManager(ZVision *engine) +StringManager::StringManager(ZVision *engine) : _engine(engine) { } @@ -218,7 +218,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { // Don't spam the user with warnings about UTF-16 support. // Just do one warning per String bool charOverflowWarning = false; - + uint16 value = stream.readUint16LE(); while (!stream.eos()) { // Check for CRLF @@ -235,7 +235,7 @@ Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { value = '?'; } char charValue = (char)value; - + asciiString += charValue; value = stream.readUint16LE(); diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h index 9cfed5261b..a6ae6d20d6 100644 --- a/engines/zvision/string_manager.h +++ b/engines/zvision/string_manager.h @@ -59,7 +59,7 @@ private: }; enum { - NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 + NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 }; private: diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index dc7dd5b38c..c7cefd6150 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -34,18 +34,18 @@ namespace ZVision { TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) : SideFX(engine, key, SIDEFX_TIMER) { - if (_engine->getGameId() == GID_NEMESIS) - _timeLeft = timeInSeconds * 1000; - else if (_engine->getGameId() == GID_GRANDINQUISITOR) - _timeLeft = timeInSeconds * 100; - _engine->getScriptManager()->setStateValue(_key, 1); + if (_engine->getGameId() == GID_NEMESIS) + _timeLeft = timeInSeconds * 1000; + else if (_engine->getGameId() == GID_GRANDINQUISITOR) + _timeLeft = timeInSeconds * 100; + _engine->getScriptManager()->setStateValue(_key, 1); } TimerNode::~TimerNode() { - if (_timeLeft <= 0) + if (_timeLeft <= 0) _engine->getScriptManager()->setStateValue(_key, 2); else - _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill + _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill } bool TimerNode::process(uint32 deltaTimeInMillis) { diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h index 2caf43ad3c..4a9c95d72b 100644 --- a/engines/zvision/timer_node.h +++ b/engines/zvision/timer_node.h @@ -44,7 +44,9 @@ public: bool process(uint32 deltaTimeInMillis); void serialize(Common::WriteStream *stream); void deserialize(Common::SeekableReadStream *stream); - inline bool needsSerialization() { return true; } + inline bool needsSerialization() { + return true; + } private: int32 _timeLeft; diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp index 289b5fbbaf..dde3b2dee5 100644 --- a/engines/zvision/truetype_font.cpp +++ b/engines/zvision/truetype_font.cpp @@ -39,12 +39,12 @@ namespace ZVision { TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) - : _engine(engine), - _fontHeight(fontHeight), - _font(0), - _lineHeight(0), - _maxCharWidth(0), - _maxCharHeight(0) { + : _engine(engine), + _fontHeight(fontHeight), + _font(0), + _lineHeight(0), + _maxCharWidth(0), + _maxCharHeight(0) { } TruetypeFont::~TruetypeFont(void) { diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h index 33f016cffd..762657a5fb 100644 --- a/engines/zvision/truetype_font.h +++ b/engines/zvision/truetype_font.h @@ -60,10 +60,10 @@ public: * * @param filename The file name of the .ttf file to load */ - bool loadFile(const Common::String &filename); + bool loadFile(const Common::String &filename); /** - * Renders the supplied text to a Surface using 0x0 as the - * background color. + * Renders the supplied text to a Surface using 0x0 as the + * background color. * * @param text The to render * @param textColor The color to render the text with diff --git a/engines/zvision/utility.cpp b/engines/zvision/utility.cpp index d973cb2f4c..1d96b33021 100644 --- a/engines/zvision/utility.cpp +++ b/engines/zvision/utility.cpp @@ -39,7 +39,7 @@ void writeFileContentsToFile(const Common::String &sourceFile, const Common::Str return; } - byte* buffer = new byte[f.size()]; + byte *buffer = new byte[f.size()]; f.read(buffer, f.size()); Common::DumpFile dumpFile; @@ -63,10 +63,10 @@ void trimCommentsAndWhiteSpace(Common::String *string) { } void tryToDumpLine(const Common::String &key, - Common::String &line, - Common::HashMap *count, - Common::HashMap *fileAlreadyUsed, - Common::DumpFile &output) { + Common::String &line, + Common::HashMap *count, + Common::HashMap *fileAlreadyUsed, + Common::DumpFile &output) { const byte numberOfExamplesPerType = 8; if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) { @@ -203,7 +203,7 @@ void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Com return; Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine); - + Common::DumpFile output; output.open(outputFile); diff --git a/engines/zvision/utility.h b/engines/zvision/utility.h index fb571f3fe8..8da88cf28c 100644 --- a/engines/zvision/utility.h +++ b/engines/zvision/utility.h @@ -72,8 +72,8 @@ void removeDuplicateEntries(Common::Array &container) { uint newLength = 1; uint j; - for(uint i = 1; i < container.size(); i++) { - for(j = 0; j < newLength; j++) { + for (uint i = 1; i < container.size(); i++) { + for (j = 0; j < newLength; j++) { if (container[i] == container[j]) { break; } @@ -93,7 +93,7 @@ void removeDuplicateEntries(Common::Array &container) { } /** - * Gets the name of the file (including extension). Forward or back slashes + * Gets the name of the file (including extension). Forward or back slashes * are interpreted as directory changes * * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp index cd11618e67..6b7299ea84 100644 --- a/engines/zvision/video.cpp +++ b/engines/zvision/video.cpp @@ -66,7 +66,7 @@ void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, const byte color2 = *srcPtr++; for (uint i = 0; i < scaleAmount; ++i) { - uint index = i *2; + uint index = i * 2; dst[index] = color; dst[index + 1] = color2; diff --git a/engines/zvision/zfs_archive.cpp b/engines/zvision/zfs_archive.cpp index 24cff27fc4..3f5ff5a0d4 100644 --- a/engines/zvision/zfs_archive.cpp +++ b/engines/zvision/zfs_archive.cpp @@ -52,7 +52,7 @@ ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStrea ZfsArchive::~ZfsArchive() { debug(1, "ZfsArchive Destructor Called"); ZfsEntryHeaderMap::iterator it = _entryHeaders.begin(); - for ( ; it != _entryHeaders.end(); ++it) { + for (; it != _entryHeaders.end(); ++it) { delete it->_value; } } @@ -79,7 +79,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { // Read in each entry header for (uint32 i = 0; i < _header.filesPerBlock; ++i) { ZfsEntryHeader entryHeader; - + entryHeader.name = readEntryName(stream); entryHeader.offset = stream->readUint32LE(); entryHeader.id = stream->readUint32LE(); @@ -138,7 +138,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common:: zfsArchive.seek(entryHeader->offset); // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory - byte* buffer = (byte *)malloc(entryHeader->size); + byte *buffer = (byte *)malloc(entryHeader->size); zfsArchive.read(buffer, entryHeader->size); // Decrypt the data in place if (_header.xorKey != 0) diff --git a/engines/zvision/zfs_archive.h b/engines/zvision/zfs_archive.h index d7b45e4b47..fc4be5aa1b 100644 --- a/engines/zvision/zfs_archive.h +++ b/engines/zvision/zfs_archive.h @@ -53,7 +53,7 @@ struct ZfsEntryHeader { uint32 unknown; }; -typedef Common::HashMap ZfsEntryHeaderMap; +typedef Common::HashMap ZfsEntryHeaderMap; class ZfsArchive : public Common::Archive { public: diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h index dc3e3327ed..7ddecce694 100644 --- a/engines/zvision/zork_avi_decoder.h +++ b/engines/zvision/zork_avi_decoder.h @@ -66,5 +66,5 @@ private: }; } // End of namespace ZVision - + #endif diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp index 029600b758..ce83add1df 100644 --- a/engines/zvision/zork_raw.cpp +++ b/engines/zvision/zork_raw.cpp @@ -191,9 +191,9 @@ bool RawZorkStream::rewind() { } Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse) { if (stereo) assert(stream->size() % 2 == 0); @@ -201,9 +201,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre } Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse) { + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse) { return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES); } @@ -221,14 +221,13 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6])) soundParams = RawZorkStream::_zNemSoundParamLookupTable[i]; } - } - else if (engine->getGameId() == GID_GRANDINQUISITOR) { + } else if (engine->getGameId() == GID_GRANDINQUISITOR) { for (int i = 0; i < 6; ++i) { if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7])) soundParams = RawZorkStream::_zgiSoundParamLookupTable[i]; } } - + if (soundParams.packed) { return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES); } else { diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h index 1f261ae139..29b555912d 100644 --- a/engines/zvision/zork_raw.h +++ b/engines/zvision/zork_raw.h @@ -106,11 +106,19 @@ private: public: int readBuffer(int16 *buffer, const int numSamples); - bool isStereo() const { return true; } - bool endOfData() const { return _endOfData; } + bool isStereo() const { + return true; + } + bool endOfData() const { + return _endOfData; + } - int getRate() const { return _rate; } - Audio::Timestamp getLength() const { return _playtime; } + int getRate() const { + return _rate; + } + Audio::Timestamp getLength() const { + return _playtime; + } bool rewind(); }; @@ -125,9 +133,9 @@ public: * @return The new SeekableAudioStream (or 0 on failure). */ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); /** * Creates an audio stream, which plays from the given stream. @@ -138,9 +146,9 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, * @return The new SeekableAudioStream (or 0 on failure). */ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stream, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); + int rate, + bool stereo, + DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 940e01ae20..8be85d39d4 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -47,28 +47,28 @@ namespace ZVision { - + ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) - : Engine(syst), - _gameDescription(gameDesc), - _workingWindow_ZGI((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), - _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT), - _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI), - _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ - _desiredFrameTime(33), /* ~30 fps */ - _clock(_system), - _scriptManager(nullptr), - _renderManager(nullptr), - _saveManager(nullptr), - _stringManager(nullptr), - _cursorManager(nullptr) { - + : Engine(syst), + _gameDescription(gameDesc), + _workingWindow_ZGI((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), + _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT), + _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI), + _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ + _desiredFrameTime(33), /* ~30 fps */ + _clock(_system), + _scriptManager(nullptr), + _renderManager(nullptr), + _saveManager(nullptr), + _stringManager(nullptr), + _cursorManager(nullptr) { + debug(1, "ZVision::ZVision"); } ZVision::~ZVision() { debug(1, "ZVision::~ZVision"); - + // Dispose of resources delete _console; delete _cursorManager; @@ -77,15 +77,15 @@ ZVision::~ZVision() { delete _renderManager; delete _scriptManager; delete _rnd; - + // Remove all of our debug levels DebugMan.clearAllDebugChannels(); } void ZVision::initialize() { const Common::FSNode gameDataDir(ConfMan.get("path")); - // TODO: There are 10 file clashes when we flatten the directories. - // From a quick look, the files are exactly the same, so it shouldn't matter. + // TODO: There are 10 file clashes when we flatten the directories. + // From a quick look, the files are exactly the same, so it shouldn't matter. // But I'm noting it here just in-case it does become a problem. SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4, true); SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4, true); @@ -143,7 +143,7 @@ Common::Error ZVision::run() { processEvents(); - // Call _renderManager->update() first so the background renders + // Call _renderManager->update() first so the background renders // before anything that puzzles/controls will render _renderManager->update(deltaTime); _scriptManager->update(deltaTime); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 89aa60fe73..10711b1605 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -51,7 +51,7 @@ class CursorManager; class StringManager; class SaveManager; class RlfAnimation; - + class ZVision : public Engine { public: ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc); @@ -68,19 +68,19 @@ public: private: enum { - WINDOW_WIDTH = 640, - WINDOW_HEIGHT = 480, + WINDOW_WIDTH = 640, + WINDOW_HEIGHT = 480, - //Zork nemesis working window sizes - ZNM_WORKING_WINDOW_WIDTH = 512, - ZNM_WORKING_WINDOW_HEIGHT = 320, + //Zork nemesis working window sizes + ZNM_WORKING_WINDOW_WIDTH = 512, + ZNM_WORKING_WINDOW_HEIGHT = 320, - //ZGI(and default) working window sizes - WORKING_WINDOW_WIDTH = 640, - WORKING_WINDOW_HEIGHT = 344, + //ZGI(and default) working window sizes + WORKING_WINDOW_WIDTH = 640, + WORKING_WINDOW_HEIGHT = 344, - ROTATION_SCREEN_EDGE_OFFSET = 60, - MAX_ROTATION_SPEED = 400 // Pixels per second + ROTATION_SCREEN_EDGE_OFFSET = 60, + MAX_ROTATION_SPEED = 400 // Pixels per second }; Console *_console; @@ -112,13 +112,27 @@ public: Common::Error run(); void pauseEngineIntern(bool pause); - ScriptManager *getScriptManager() const { return _scriptManager; } - RenderManager *getRenderManager() const { return _renderManager; } - CursorManager *getCursorManager() const { return _cursorManager; } - SaveManager *getSaveManager() const { return _saveManager; } - StringManager *getStringManager() const { return _stringManager; } - Common::RandomSource *getRandomSource() const { return _rnd; } - ZVisionGameId getGameId() const { return _gameDescription->gameId; } + ScriptManager *getScriptManager() const { + return _scriptManager; + } + RenderManager *getRenderManager() const { + return _renderManager; + } + CursorManager *getCursorManager() const { + return _cursorManager; + } + SaveManager *getSaveManager() const { + return _saveManager; + } + StringManager *getStringManager() const { + return _stringManager; + } + Common::RandomSource *getRandomSource() const { + return _rnd; + } + ZVisionGameId getGameId() const { + return _gameDescription->gameId; + } /** * Play a video until it is finished. This is a blocking call. It will call @@ -149,5 +163,5 @@ private: }; } // End of namespace ZVision - + #endif -- cgit v1.2.3 From bbe29500ccf0dd6d31ebb5bfcbbf707c74a4500a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 20 Oct 2013 18:35:11 +0000 Subject: ZVISION: Forgotten change cursos to pressed in ZGI code. --- engines/zvision/cursor_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index 015e2b014f..385e4dcc9c 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -105,6 +105,7 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) char buffer[25]; strcpy(buffer, _zgiCursorFileNames[i]); buffer[3] += 2; + changeCursor(ZorkCursor(buffer)); } return; } -- cgit v1.2.3 From dbdefe23e9861781af63608cd450cfaed86de89a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 20 Oct 2013 20:06:12 +0000 Subject: ZVISION: New render functions for rendering surface-to-surface. --- engines/zvision/render_manager.cpp | 167 +++++++++++++++++++++++++++++++++++++ engines/zvision/render_manager.h | 80 ++++++++++++++++++ 2 files changed, 247 insertions(+) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 1406fbc828..a240e766df 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -159,6 +159,173 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) { } } +void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) { + if (src.format != dst.format) + return; + + Common::Rect dstRect = _dstRect; + if (dstRect.isEmpty()) + dstRect = Common::Rect(dst.w, dst.h); + dstRect.clip(dst.w, dst.h); + + Common::Rect srcRect = _srcRect; + if (srcRect.isEmpty()) + srcRect = Common::Rect(src.w, src.h); + srcRect.clip(src.w, src.h); + + if (!srcRect.isValidRect() || !dstRect.isValidRect()) + return; + + Common::Rect rendRect = srcRect; + rendRect.clip(dstRect.width(), dstRect.height()); + + if (rendRect.isEmpty() || !rendRect.isValidRect()) + return; + + // Copy rendRect from src surface to dst surface + byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top); + byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); + + int32 w = rendRect.width(); + int32 h = rendRect.height(); + + for (int32 y = 0; y < h; y++) { + memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel); + src_buf += src.pitch; + dst_buf += dst.pitch; + } +} + +void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) { + if (src.format != dst.format) + return; + + Common::Rect dstRect = _dstRect; + if (dstRect.isEmpty()) + dstRect = Common::Rect(dst.w, dst.h); + dstRect.clip(dst.w, dst.h); + + Common::Rect srcRect = _srcRect; + if (srcRect.isEmpty()) + srcRect = Common::Rect(src.w, src.h); + srcRect.clip(src.w, src.h); + + if (!srcRect.isValidRect() || !dstRect.isValidRect()) + return; + + Common::Rect rendRect = srcRect; + rendRect.clip(dstRect.width(), dstRect.height()); + + if (rendRect.isEmpty() || !rendRect.isValidRect()) + return; + + uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1); + + // Copy rendRect from src surface to dst surface + byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top); + byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); + + int32 w = rendRect.width(); + int32 h = rendRect.height(); + + for (int32 y = 0; y < h; y++) { + switch (src.format.bytesPerPixel) { + case 1: { + uint *src_tmp = (uint *)src_buf; + uint *dst_tmp = (uint *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + case 2: { + uint16 *src_tmp = (uint16 *)src_buf; + uint16 *dst_tmp = (uint16 *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + case 4: { + uint32 *src_tmp = (uint32 *)src_buf; + uint32 *dst_tmp = (uint32 *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + default: + break; + } + src_buf += src.pitch; + dst_buf += dst.pitch; + } +} + +void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) { + if (!Common::Rect(dst.w, dst.h).contains(dstPt)) + return; + Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); + copyRectToSurface(src, dst, srcRect, dstRect); +} + +void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) { + if (!Common::Rect(dst.w, dst.h).contains(dstPt)) + return; + Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); + copyRectToSurface(src, dst, srcRect, dstRect, keycolor); +} + +void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) { + Graphics::Surface surface; + readImageToSurface(fileName, surface); + + Common::Rect srcRect(surface.w, surface.h); + Common::Point dstPt(destX, destY); + + copyRectToSurface(surface, _currentBackground, srcRect, dstPt); + moveBackground(0); +} + +void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY) { + Common::Rect srcRect(surface.w, surface.h); + Common::Point dstPt(destX, destY); + + copyRectToSurface(surface, _currentBackground, srcRect, dstPt); + moveBackground(0); +} + +void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) { + Graphics::Surface surface; + readImageToSurface(fileName, surface); + + Common::Rect srcRect(surface.w, surface.h); + Common::Point dstPt(destX, destY); + + copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor); + moveBackground(0); +} + +void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) { + Common::Rect srcRect(surface.w, surface.h); + Common::Point dstPt(destX, destY); + + copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor); + moveBackground(0); +} + void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { int16 subRectX = 0; int16 subRectY = 0; diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 9fedd1d8dd..37bfcfa20d 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -217,6 +217,86 @@ public: */ void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false); + /** + * Copies a rectangla of source surface and copy to destination rect. + * + * @param src Source surface + * @param dst Destenation surface + * @param srcRect Rect of source surface + * @param dstRect Rect for destenation surface + */ + void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect); + + /** + * Copies a rectangla of source surface and copy to destination rect. + * + * @param src Source surface + * @param dst Destenation surface + * @param srcRect Rect of source surface + * @param dstRect Rect for destenation surface + * @param colorkey Transparent color + */ + void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey); + + /** + * Copies a rectangla of source surface and copy to destination rect. + * + * @param src Source surface + * @param dst Destenation surface + * @param srcRect Rect of source surface + * @param dstPt Point for destenation surface + */ + void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt); + + /** + * Copies a rectangla of source surface and copy to destination rect. + * + * @param src Source surface + * @param dst Destenation surface + * @param srcRect Rect of source surface + * @param dstPt Point for destenation surface + * @param colorkey Transparent color + */ + void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey); + + /** + * Blits the image or a portion of the image to the background. + * + * @param fileName Name of the image file + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + */ + void renderImageToBackground(const Common::String &fileName, int16 destinationX, int16 destinationY); + + /** + * Blits the image or a portion of the image to the background. + * + * @param surface Surface to read the image data from + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + */ + void renderImageToBackground(Graphics::Surface &surface, int16 destinationX, int16 destinationY); + + /** + * Blits the image or a portion of the image to the background. + * + * @param fileName Name of the image file + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + * @param colorkey Transparent color + */ + void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey); + + /** + * Blits the image or a portion of the image to the background. + * + * @param surface Surface to read the image data from + * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! + * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + * @param colorkey Transparent color + */ + void renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey); + /** * Sets the current background image to be used by the RenderManager and immediately * blits it to the screen. (It won't show up until the end of the frame) -- cgit v1.2.3 From db3d154c63669752d0b1d75dd8f75707b671d862 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 20 Oct 2013 20:07:31 +0000 Subject: ZVISION: SetPartialScreen must update part of currentBackground image. --- engines/zvision/actions.cpp | 8 ++++---- engines/zvision/actions.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 1d4ce9c604..21c01546fd 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -321,10 +321,10 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) { bool ActionSetPartialScreen::execute(ZVision *engine) { RenderManager *renderManager = engine->getRenderManager(); - if (_backgroundColor > 0) { - renderManager->clearWorkingWindowTo555Color(_backgroundColor); - } - renderManager->renderImageToScreen(_fileName, _x, _y); + if (_backgroundColor >= 0) + renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor); + else + renderManager->renderImageToBackground(_fileName, _x, _y); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index e7a4ea302f..15923d66d1 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -300,7 +300,7 @@ private: uint _x; uint _y; Common::String _fileName; - uint16 _backgroundColor; + int32 _backgroundColor; }; class ActionSetScreen : public ResultAction { -- cgit v1.2.3 From 2e0e9dc1f64451485532bbd5b3532b6155288f6c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 21 Oct 2013 16:39:40 +0700 Subject: ZVISION: Fix changelocation sscanf format string to original format. --- engines/zvision/actions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 21c01546fd..4976bd4862 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -86,7 +86,7 @@ bool ActionAttenuate::execute(ZVision *engine) { ////////////////////////////////////////////////////////////////////////////// ActionChangeLocation::ActionChangeLocation(const Common::String &line) { - sscanf(line.c_str(), "%*[^(](%c,%c,%c%c,%u)", &_world, &_room, &_node, &_view, &_offset); + sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset); } bool ActionChangeLocation::execute(ZVision *engine) { -- cgit v1.2.3 From 9888e66603e1377ff370cbf667efba9d49d5e45d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 22 Oct 2013 08:24:30 +0000 Subject: ZVISION: Added system StateKey names enum. --- engines/zvision/script_manager.h | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index d47ee94da4..767919ef0e 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -40,6 +40,61 @@ namespace ZVision { class ZVision; +enum StateKey { + StateKey_World = 3, + StateKey_Room = 4, + StateKey_Node = 5, + StateKey_View = 6, + StateKey_ViewPos = 7, + StateKey_KeyPress = 8, + StateKey_InventoryItem = 9, + StateKey_LMouse = 10, + StateKey_Rounds = 12, + StateKey_Venus = 13, + StateKey_RMouse = 18, + StateKey_MenuState = 19, + StateKey_RestoreFlag = 20, + StateKey_Quitting = 39, + StateKey_LastWorld = 40, + StateKey_LastRoom = 41, + StateKey_LastNode = 42, + StateKey_LastView = 43, + StateKey_LastViewPos = 44, + StateKey_Menu_LastWorld = 45, + StateKey_Menu_LastRoom = 46, + StateKey_Menu_LastNode = 47, + StateKey_Menu_LastView = 48, + StateKey_Menu_LastViewPos = 49, + StateKey_KbdRotateSpeed = 50, + StateKey_Subtitles = 51, + StateKey_StreamSkipKey = 52, + StateKey_RotateSpeed = 53, + StateKey_Volume = 56, + StateKey_Qsound = 57, + StateKey_VenusEnable = 58, + StateKey_HighQuality = 59, + StateKey_VideoLineSkip = 65, + StateKey_Platform = 66, + StateKey_InstallLevel = 67, + StateKey_CountryCode = 68, + StateKey_CPU = 69, + StateKey_MovieCursor = 70, + StateKey_NoTurnAnim = 71, + StateKey_WIN958 = 72, + StateKey_ShowErrorDlg = 73, + StateKey_DebugCheats = 74, + StateKey_JapanFonts = 75, + StateKey_Brightness = 77, + StateKey_EF9_B = 91, + StateKey_EF9_G = 92, + StateKey_EF9_R = 93, + StateKey_EF9_Speed = 94, + StateKey_Inv_0_Slot = 100, + StateKey_Inv_1_Slot = 101, + StateKey_Inv_49_Slot = 149, + StateKey_Inv_TotalSlots = 150 +}; + struct Location { Location() : world('g'), room('a'), node('r'), view('y'), offset(0) {} -- cgit v1.2.3 From 3e51ed6a785ffb1871ffdbfff6aaad309959a1ee Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 22 Oct 2013 12:02:03 +0700 Subject: ZVISION: Set right reaction for mouse up/down events. --- engines/zvision/events.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index 1103dc3000..ede91273e6 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -43,17 +43,28 @@ void ZVision::processEvents() { while (_eventMan->pollEvent(_event)) { switch (_event.type) { case Common::EVENT_LBUTTONDOWN: + _cursorManager->cursorDown(true); + _scriptManager->setStateValue(StateKey_LMouse, 1); onMouseDown(_event.mouse); break; case Common::EVENT_LBUTTONUP: + _cursorManager->cursorDown(false); + _scriptManager->setStateValue(StateKey_LMouse, 0); onMouseUp(_event.mouse); break; case Common::EVENT_RBUTTONDOWN: + _cursorManager->cursorDown(true); + _scriptManager->setStateValue(StateKey_RMouse, 1); // TODO: Inventory logic break; + case Common::EVENT_RBUTTONUP: + _cursorManager->cursorDown(false); + _scriptManager->setStateValue(StateKey_RMouse, 0); + break; + case Common::EVENT_MOUSEMOVE: onMouseMove(_event.mouse); break; @@ -87,15 +98,11 @@ void ZVision::processEvents() { } void ZVision::onMouseDown(const Common::Point &pos) { - _cursorManager->cursorDown(true); - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); _scriptManager->onMouseDown(pos, imageCoord); } void ZVision::onMouseUp(const Common::Point &pos) { - _cursorManager->cursorDown(false); - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); _scriptManager->onMouseUp(pos, imageCoord); } -- cgit v1.2.3 From 803ff02136ddc102084094430aabc366192afe99 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 24 Oct 2013 22:25:34 +0000 Subject: ZVISION: New data types for script files and puzzle reference. --- engines/zvision/script_manager.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 767919ef0e..6dd2190cf1 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -119,6 +119,24 @@ public: private: ZVision *_engine; + + struct script_scope { + uint32 proc_count; + + PuzzleList *scope_queue; // For adding puzzles to queue + PuzzleList *exec_queue; // Switch to it when execute + PuzzleList _priv_queue_one; + PuzzleList _priv_queue_two; + + PuzzleList _puzzles; + ControlList _controls; + }; + + struct puzzle_ref { + Puzzle *puz; + script_scope *scope; + }; + /** * Holds the global state variable. Do NOT directly modify this. Use the accessors and * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a -- cgit v1.2.3 From d8ad0e5235b036a69bdcae68ec99020de95c47bc Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 24 Oct 2013 22:45:55 +0000 Subject: ZVISION: Added clean function for script scope and body for queue routine. --- engines/zvision/script_manager.cpp | 21 +++++++++++++++++++++ engines/zvision/script_manager.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 72e67bfa7f..515fd7a450 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -216,6 +216,24 @@ void ScriptManager::cleanStateTable() { } } +void ScriptManager::cleanScriptScope(script_scope &scope) { + scope._priv_queue_one.clear(); + scope._priv_queue_two.clear(); + scope.scope_queue = &scope._priv_queue_one; + scope.exec_queue = &scope._priv_queue_two; + for (PuzzleList::iterator iter = scope._puzzles.begin(); iter != scope._puzzles.end(); ++iter) + delete(*iter); + + scope._puzzles.clear(); + + for (ControlList::iterator iter = scope._controls.begin(); iter != scope._controls.end(); ++iter) + delete(*iter); + + scope._controls.clear(); + + scope.proc_count = 0; +} + uint ScriptManager::getStateValue(uint32 key) { if (_globalState.contains(key)) return _globalState[key]; @@ -223,6 +241,9 @@ uint ScriptManager::getStateValue(uint32 key) { return 0; } +void ScriptManager::queuePuzzles(uint32 key) { +} + void ScriptManager::setStateValue(uint32 key, uint value) { _globalState[key] = value; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 6dd2190cf1..a5324533c0 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -163,6 +163,7 @@ private: public: void initialize(); void update(uint deltaTimeMillis); + void queuePuzzles(uint32 key); uint getStateValue(uint32 key); void setStateValue(uint32 key, uint value); @@ -228,6 +229,7 @@ private: void updateNodes(uint deltaTimeMillis); void checkPuzzleCriteria(); void cleanStateTable(); + void cleanScriptScope(script_scope &scope); // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it public: -- cgit v1.2.3 From c87ca1bc9c9023b2f85b5151e790f6ebe60ea2c2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 08:13:59 +0000 Subject: ZVISION: Add flag to puzzle structure for use with new referenceTable. --- engines/zvision/puzzle.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index 2eea52f80b..1b30829462 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -74,6 +74,7 @@ struct Puzzle { // This has to be list of pointers because ResultAction is abstract Common::List resultActions; uint flags; + bool addedBySetState; }; } // End of namespace ZVision -- cgit v1.2.3 From 91cbb1ec790a604309c766ef38f6a2704922365b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 14:52:40 +0700 Subject: ZVISION: Move setState to use queuePuzzle. --- engines/zvision/script_manager.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 515fd7a450..7531182e95 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -245,13 +245,12 @@ void ScriptManager::queuePuzzles(uint32 key) { } void ScriptManager::setStateValue(uint32 key, uint value) { - _globalState[key] = value; - - if (_referenceTable.contains(key)) { - for (Common::Array::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) { - _puzzlesToCheck.push((*iter)); - } - } + if (value == 0) + _globalState.erase(key); + else + _globalState[key] = value; + debug("setStateValue %d %d\n", key , value); + queuePuzzles(key); } void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) { -- cgit v1.2.3 From 8e4070c68b9a6a5e81d80f6805a199c2872089fe Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 15:39:38 +0700 Subject: ZVISION: Added global StateFlags and set/get/unset functions. --- engines/zvision/script_manager.cpp | 24 ++++++++++++++++++++++++ engines/zvision/script_manager.h | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 7531182e95..01a6e6d09e 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -253,6 +253,30 @@ void ScriptManager::setStateValue(uint32 key, uint value) { queuePuzzles(key); } +uint ScriptManager::getStateFlag(uint32 key) { + if (_globalStateFlags.contains(key)) + return _globalStateFlags[key]; + else + return 0; +} + +void ScriptManager::setStateFlag(uint32 key, uint value) { + queuePuzzles(key); + + _globalStateFlags[key] |= value; +} + +void ScriptManager::unsetStateFlag(uint32 key, uint value) { + queuePuzzles(key); + + if (_globalStateFlags.contains(key)) { + _globalStateFlags[key] &= ~value; + + if (_globalStateFlags[key] == 0) + _globalStateFlags.erase(key); + } +} + void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) { _globalState[key] += valueToAdd; } diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index a5324533c0..71fefaf41f 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -143,6 +143,8 @@ private: * particular state key are checked after the key is modified. */ StateMap _globalState; + /** Holds execute flags */ + StateMap _globalStateFlags; /** References _globalState keys to Puzzles */ PuzzleMap _referenceTable; /** Holds the Puzzles that should be checked this frame */ @@ -169,6 +171,10 @@ public: void setStateValue(uint32 key, uint value); void addToStateValue(uint32 key, uint valueToAdd); + uint getStateFlag(uint32 key); + void setStateFlag(uint32 key, uint value); + void unsetStateFlag(uint32 key, uint value); + void addControl(Control *control); Control *getControl(uint32 key); -- cgit v1.2.3 From c0a709dc23c689b094c2dab1038447267d6fb8bd Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 17:12:08 +0700 Subject: ZVISION: Refactoring script manager, massive changes. --- engines/zvision/actions.cpp | 7 - engines/zvision/console.cpp | 1 - engines/zvision/save_manager.cpp | 5 - engines/zvision/scr_file_handling.cpp | 36 +-- engines/zvision/script_manager.cpp | 410 +++++++++++++++------------------- engines/zvision/script_manager.h | 34 +-- 6 files changed, 222 insertions(+), 271 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 4976bd4862..3c0adb4082 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -124,7 +124,6 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) { bool ActionDisableControl::execute(ZVision *engine) { debug("Disabling control %u", _key); - engine->getScriptManager()->disableControl(_key); return true; } @@ -141,7 +140,6 @@ ActionEnableControl::ActionEnableControl(const Common::String &line) { bool ActionEnableControl::execute(ZVision *engine) { debug("Enabling control %u", _key); - engine->getScriptManager()->enableControl(_key); return true; } @@ -220,8 +218,6 @@ bool ActionPreloadAnimation::execute(ZVision *engine) { // TODO: Check if the Control already exists // Create the control, but disable it until PlayPreload is called - engine->getScriptManager()->addControl(new AnimationControl(engine, _key, _fileName)); - engine->getScriptManager()->disableControl(_key); return true; } @@ -267,9 +263,6 @@ bool ActionPlayPreloadAnimation::execute(ZVision *engine) { control->setXPos(_x1); control->setYPost(_y1); - // Enable the control. ScriptManager will take care of the rest - control->enable(); - return true; } diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp index a095d3fa6a..400dcb3f39 100644 --- a/engines/zvision/console.cpp +++ b/engines/zvision/console.cpp @@ -197,7 +197,6 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) { SearchMan.listMatchingMembers(list, "*.scr"); for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - _engine->getScriptManager()->parseScrFile((*iter)->getName()); } return true; diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp index 528dd0f35b..e8947d8d16 100644 --- a/engines/zvision/save_manager.cpp +++ b/engines/zvision/save_manager.cpp @@ -128,8 +128,6 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) { // Write out the current state table values scriptManager->serializeStateTable(file); - // Write out any controls needing to save state - scriptManager->serializeControls(file); } Common::Error SaveManager::loadGame(uint slot) { @@ -160,9 +158,6 @@ Common::Error SaveManager::loadGame(uint slot) { // Load the room scriptManager->changeLocation(world, room, node, view, offset); - // Update the controls - scriptManager->deserializeControls(saveFile); - return Common::kNoError; } diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 5fed820103..4d18306ce4 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -37,7 +37,7 @@ namespace ZVision { -void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) { +void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) { Common::File file; if (!file.open(fileName)) { warning("Script file not found: %s", fileName.c_str()); @@ -58,17 +58,18 @@ void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) if (line.matchString("puzzle:*", true)) { Puzzle *puzzle = new Puzzle(); sscanf(line.c_str(), "puzzle:%u", &(puzzle->key)); - + if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST) + setStateValue(puzzle->key, 0); parsePuzzle(puzzle, file); - if (isGlobal) { - _globalPuzzles.push_back(puzzle); - } else { - _activePuzzles.push_back(puzzle); - } + scope._puzzles.push_back(puzzle); + } else if (line.matchString("control:*", true)) { - parseControl(line, file); + Control *ctrl = parseControl(line, file); + if (ctrl) + scope._controls.push_back(ctrl); } } + scope.proc_count = 0; } void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) { @@ -81,12 +82,14 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre } else if (line.matchString("results {", true)) { parseResults(stream, puzzle->resultActions); } else if (line.matchString("flags {", true)) { - puzzle->flags = parseFlags(stream); + setStateFlag(puzzle->key, parseFlags(stream)); } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); } + + puzzle->addedBySetState = 0; } bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList) const { @@ -273,7 +276,7 @@ uint ScriptManager::parseFlags(Common::SeekableReadStream &stream) const { return flags; } -void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) { +Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadStream &stream) { uint32 key; char controlTypeBuffer[20]; @@ -282,21 +285,20 @@ void ScriptManager::parseControl(Common::String &line, Common::SeekableReadStrea Common::String controlType(controlTypeBuffer); if (controlType.equalsIgnoreCase("push_toggle")) { - _activeControls.push_back(new PushToggleControl(_engine, key, stream)); - return; + return new PushToggleControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("flat")) { Control::parseFlatControl(_engine); - return; + return NULL; } else if (controlType.equalsIgnoreCase("pana")) { Control::parsePanoramaControl(_engine, stream); - return; + return NULL; } else if (controlType.equalsIgnoreCase("tilt")) { Control::parseTiltControl(_engine, stream); - return; + return NULL; } else if (controlType.equalsIgnoreCase("lever")) { - _activeControls.push_back(new LeverControl(_engine, key, stream)); - return; + return new LeverControl(_engine, key, stream); } + return NULL; } } // End of namespace ZVision diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 01a6e6d09e..74035fd41f 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -41,69 +41,86 @@ namespace ZVision { ScriptManager::ScriptManager(ZVision *engine) : _engine(engine), - _currentlyFocusedControl(0) { + _currentlyFocusedControl(0), + _activeControls(NULL) { } ScriptManager::~ScriptManager() { - for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { - delete(*iter); - } - for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) { - delete(*iter); - } - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - delete(*iter); - } + cleanScriptScope(universe); + cleanScriptScope(world); + cleanScriptScope(room); + cleanScriptScope(nodeview); } void ScriptManager::initialize() { - parseScrFile("universe.scr", true); + cleanScriptScope(universe); + cleanScriptScope(world); + cleanScriptScope(room); + cleanScriptScope(nodeview); + + _currentLocation.node = '0'; + _currentLocation.world = '0'; + _currentLocation.room = '0'; + _currentLocation.view = '0'; + + parseScrFile("universe.scr", universe); changeLocation('g', 'a', 'r', 'y', 0); } void ScriptManager::update(uint deltaTimeMillis) { + if (_currentLocation.node != _nextLocation.node || + _currentLocation.room != _nextLocation.room || + _currentLocation.view != _nextLocation.view || + _currentLocation.world != _nextLocation.world) + do_changeLocation(); + updateNodes(deltaTimeMillis); - checkPuzzleCriteria(); + execScope(nodeview); + execScope(room); + execScope(world); + execScope(universe); + updateControls(deltaTimeMillis); +} + +void ScriptManager::execScope(script_scope &scope) { + // Swap queues + PuzzleList *tmp = scope.exec_queue; + scope.exec_queue = scope.scope_queue; + scope.scope_queue = tmp; + + for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) + (*PuzzleIter)->addedBySetState = 0; + + if (scope.proc_count < 2 || getStateValue(76)) { + for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) + checkPuzzleCriteria(*PuzzleIter, scope.proc_count); + } else { + for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter) + checkPuzzleCriteria(*PuzzleIter, scope.proc_count); + } + + scope.exec_queue->clear(); + + if (scope.proc_count < 2) { + scope.proc_count++; + } } -void ScriptManager::createReferenceTable() { +void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { // Iterate through each local Puzzle - for (PuzzleList::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); ++activePuzzleIter) { - Puzzle *puzzlePtr = (*activePuzzleIter); + for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) { + Puzzle *puzzlePtr = (*PuzzleIter); - // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle - for (Common::List >::iterator criteriaIter = (*activePuzzleIter)->criteriaList.begin(); criteriaIter != (*activePuzzleIter)->criteriaList.end(); ++criteriaIter) { - for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { - _referenceTable[entryIter->key].push_back(puzzlePtr); - - // If the argument is a key, add a reference to it as well - if (entryIter->argumentIsAKey) { - _referenceTable[entryIter->argument].push_back(puzzlePtr); - } - } - } - } + puzzle_ref ref; + ref.scope = &scope; + ref.puz = puzzlePtr; - // Iterate through each global Puzzle - for (PuzzleList::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); ++globalPuzzleIter) { - Puzzle *puzzlePtr = (*globalPuzzleIter); + _referenceTable[puzzlePtr->key].push_back(ref); // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle - for (Common::List >::iterator criteriaIter = (*globalPuzzleIter)->criteriaList.begin(); criteriaIter != (*globalPuzzleIter)->criteriaList.end(); ++criteriaIter) { - for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { - _referenceTable[entryIter->key].push_back(puzzlePtr); - - // If the argument is a key, add a reference to it as well - if (entryIter->argumentIsAKey) { - _referenceTable[entryIter->argument].push_back(puzzlePtr); - } - } - } - } - - // Remove duplicate entries - for (PuzzleMap::iterator referenceTableIter = _referenceTable.begin(); referenceTableIter != _referenceTable.end(); ++referenceTableIter) { - removeDuplicateEntries(referenceTableIter->_value); + for (Common::List >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter) + for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) + _referenceTable[entryIter->key].push_back(ref); } } @@ -118,90 +135,85 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) { ++iter; } } - // If process() returns true, it means the node can be deleted - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { - if ((*iter)->process(deltaTimeMillis)) { - delete(*iter); - // Remove the node - iter = _activeControls.erase(iter); - } else { - ++iter; - } - } } -void ScriptManager::checkPuzzleCriteria() { - while (!_puzzlesToCheck.empty()) { - Puzzle *puzzle = _puzzlesToCheck.pop(); +void ScriptManager::updateControls(uint deltaTimeMillis) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) + (*iter)->process(deltaTimeMillis); +} - // Check if the puzzle is already finished - // Also check that the puzzle isn't disabled - if (getStateValue(puzzle->key) == 1 && - (puzzle->flags & Puzzle::DISABLED) == 0) { - continue; - } +void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { + // Check if the puzzle is already finished + // Also check that the puzzle isn't disabled + if (getStateValue(puzzle->key) == 1 && + (getStateFlag(puzzle->key) & Puzzle::DISABLED) == 0) { + return; + } - // Check each Criteria - - bool criteriaMet = false; - for (Common::List >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) { - criteriaMet = false; - - for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { - // Get the value to compare against - uint argumentValue; - if (entryIter->argumentIsAKey) - argumentValue = getStateValue(entryIter->argument); - else - argumentValue = entryIter->argument; - - // Do the comparison - switch (entryIter->criteriaOperator) { - case Puzzle::EQUAL_TO: - criteriaMet = getStateValue(entryIter->key) == argumentValue; - break; - case Puzzle::NOT_EQUAL_TO: - criteriaMet = getStateValue(entryIter->key) != argumentValue; - break; - case Puzzle::GREATER_THAN: - criteriaMet = getStateValue(entryIter->key) > argumentValue; - break; - case Puzzle::LESS_THAN: - criteriaMet = getStateValue(entryIter->key) < argumentValue; - break; - } - - // If one check returns false, don't keep checking - if (!criteriaMet) { - break; - } + // Check each Criteria + if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0) + return; + + bool criteriaMet = false; + for (Common::List >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) { + criteriaMet = false; + + for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { + // Get the value to compare against + uint argumentValue; + if (entryIter->argumentIsAKey) + argumentValue = getStateValue(entryIter->argument); + else + argumentValue = entryIter->argument; + + // Do the comparison + switch (entryIter->criteriaOperator) { + case Puzzle::EQUAL_TO: + criteriaMet = getStateValue(entryIter->key) == argumentValue; + break; + case Puzzle::NOT_EQUAL_TO: + criteriaMet = getStateValue(entryIter->key) != argumentValue; + break; + case Puzzle::GREATER_THAN: + criteriaMet = getStateValue(entryIter->key) > argumentValue; + break; + case Puzzle::LESS_THAN: + criteriaMet = getStateValue(entryIter->key) < argumentValue; + break; } - // If any of the Criteria are *fully* met, then execute the results - if (criteriaMet) { + // If one check returns false, don't keep checking + if (!criteriaMet) { break; } } - // criteriaList can be empty. Aka, the puzzle should be executed immediately - if (puzzle->criteriaList.empty() || criteriaMet) { - debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key); + // If any of the Criteria are *fully* met, then execute the results + if (criteriaMet) { + break; + } + } - // Set the puzzle as completed - setStateValue(puzzle->key, 1); + // criteriaList can be empty. Aka, the puzzle should be executed immediately + if (puzzle->criteriaList.empty() || criteriaMet) { + debug(1, "Puzzle %u criteria passed. Executing its ResultActions", puzzle->key); - bool shouldContinue = true; - for (Common::List::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) { - shouldContinue = shouldContinue && (*resultIter)->execute(_engine); - if (!shouldContinue) { - break; - } - } + // Set the puzzle as completed + setStateValue(puzzle->key, 1); + bool shouldContinue = true; + for (Common::List::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) { + shouldContinue = shouldContinue && (*resultIter)->execute(_engine); if (!shouldContinue) { break; } } + + if (!shouldContinue) { + return; + } } } @@ -242,6 +254,13 @@ uint ScriptManager::getStateValue(uint32 key) { } void ScriptManager::queuePuzzles(uint32 key) { + if (_referenceTable.contains(key)) { + for (Common::Array::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) + if (!iter->puz->addedBySetState) { + iter->scope->scope_queue->push_back(iter->puz); + iter->puz->addedBySetState = true; + } + } } void ScriptManager::setStateValue(uint32 key, uint value) { @@ -281,40 +300,16 @@ void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) { _globalState[key] += valueToAdd; } -void ScriptManager::addControl(Control *control) { - _activeControls.push_back(control); -} Control *ScriptManager::getControl(uint32 key) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - if ((*iter)->getKey() == key) { - return (*iter); - } - } return nullptr; } -void ScriptManager::enableControl(uint32 key) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - if ((*iter)->getKey() == key) { - (*iter)->enable(); - break; - } - } -} - -void ScriptManager::disableControl(uint32 key) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - if ((*iter)->getKey() == key) { - (*iter)->disable(); - break; - } - } -} - void ScriptManager::focusControl(uint32 key) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { uint32 controlKey = (*iter)->getKey(); if (controlKey == key) { @@ -342,20 +337,26 @@ SideFX *ScriptManager::getSideFX(uint32 key) { } void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); } } void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos); } } bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (!_activeControls) + return false; bool cursorWasChanged = false; - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos); } @@ -363,35 +364,56 @@ bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Commo } void ScriptManager::onKeyDown(Common::KeyState keyState) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { (*iter)->onKeyDown(keyState); } } void ScriptManager::onKeyUp(Common::KeyState keyState) { - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { + if (!_activeControls) + return; + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { (*iter)->onKeyUp(keyState); } } -void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 offset) { - assert(world != 0); - debug(1, "Changing location to: %c %c %c %c %u", world, room, node, view, offset); +void ScriptManager::changeLocation(char _world, char _room, char _node, char _view, uint32 offset) { + _nextLocation.world = _world; + _nextLocation.room = _room; + _nextLocation.node = _node; + _nextLocation.view = _view; + _nextLocation.offset = offset; +} + +void ScriptManager::do_changeLocation() { + assert(_nextLocation.world != 0); + debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); // Auto save - _engine->getSaveManager()->autoSave(); + //_engine->getSaveManager()->autoSave(); // Clear all the containers _referenceTable.clear(); - _puzzlesToCheck.clear(); - for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { - delete(*iter); - } - _activePuzzles.clear(); - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - delete(*iter); - } - _activeControls.clear(); + cleanScriptScope(nodeview); + cleanScriptScope(room); + cleanScriptScope(world); + + // Parse into puzzles and controls + Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); + parseScrFile(fileName, nodeview); + addPuzzlesToReferenceTable(nodeview); + + fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room); + parseScrFile(fileName, room); + addPuzzlesToReferenceTable(room); + + fileName = Common::String::format("%c.scr", _nextLocation.world); + parseScrFile(fileName, world); + addPuzzlesToReferenceTable(world); + + _activeControls = &nodeview._controls; // Revert to the idle cursor _engine->getCursorManager()->revertToIdle(); @@ -402,50 +424,14 @@ void ScriptManager::changeLocation(char world, char room, char node, char view, // Remove any alphaEntries _engine->getRenderManager()->clearAlphaEntries(); - // Clean the global state table - cleanStateTable(); - - // Parse into puzzles and controls - Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view); - parseScrFile(fileName); - // Change the background position - _engine->getRenderManager()->setBackgroundPosition(offset); + _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); - // Enable all the controls - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - (*iter)->enable(); - } - - // Add all the local puzzles to the queue to be checked - for (PuzzleList::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); ++iter) { - // Reset any Puzzles that have the flag ONCE_PER_INST - if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) { - setStateValue((*iter)->key, 0); - } - - _puzzlesToCheck.push((*iter)); - } - - // Add all the global puzzles to the queue to be checked - for (PuzzleList::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); ++iter) { - // Reset any Puzzles that have the flag ONCE_PER_INST - if (((*iter)->flags & Puzzle::ONCE_PER_INST) == Puzzle::ONCE_PER_INST) { - setStateValue((*iter)->key, 0); - } - - _puzzlesToCheck.push((*iter)); - } - - // Create the puzzle reference table - createReferenceTable(); + execScope(room); + execScope(nodeview); // Update _currentLocation - _currentLocation.world = world; - _currentLocation.room = room; - _currentLocation.node = node; - _currentLocation.view = view; - _currentLocation.offset = offset; + _currentLocation = _nextLocation; } void ScriptManager::serializeStateTable(Common::WriteStream *stream) { @@ -474,36 +460,6 @@ void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) { } } -void ScriptManager::serializeControls(Common::WriteStream *stream) { - // Count how many controls need to save their data - // Because WriteStream isn't seekable - uint32 numberOfControlsNeedingSerialization = 0; - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - if ((*iter)->needsSerialization()) { - numberOfControlsNeedingSerialization++; - } - } - stream->writeUint32LE(numberOfControlsNeedingSerialization); - - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - (*iter)->serialize(stream); - } -} - -void ScriptManager::deserializeControls(Common::SeekableReadStream *stream) { - uint32 numberOfControls = stream->readUint32LE(); - - for (uint32 i = 0; i < numberOfControls; ++i) { - uint32 key = stream->readUint32LE(); - for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { - if ((*iter)->getKey() == key) { - (*iter)->deserialize(stream); - break; - } - } - } -} - Location ScriptManager::getCurrentLocation() const { Location location = _currentLocation; location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset(); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 71fefaf41f..90df2ccee5 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -105,7 +105,6 @@ struct Location { uint32 offset; }; -typedef Common::HashMap > PuzzleMap; typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; @@ -137,6 +136,8 @@ private: script_scope *scope; }; + typedef Common::HashMap > PuzzleMap; + /** * Holds the global state variable. Do NOT directly modify this. Use the accessors and * mutators getStateValue() and setStateValue(). This ensures that Puzzles that reference a @@ -147,18 +148,19 @@ private: StateMap _globalStateFlags; /** References _globalState keys to Puzzles */ PuzzleMap _referenceTable; - /** Holds the Puzzles that should be checked this frame */ - PuzzleQueue _puzzlesToCheck; - /** Holds the currently active puzzles */ - PuzzleList _activePuzzles; - /** Holds the global puzzles */ - PuzzleList _globalPuzzles; /** Holds the currently active controls */ - ControlList _activeControls; + ControlList *_activeControls; + + script_scope universe; + script_scope world; + script_scope room; + script_scope nodeview; + /** Holds the currently active timers, musics, other */ SideFXList _activeSideFx; Location _currentLocation; + Location _nextLocation; uint32 _currentlyFocusedControl; @@ -221,21 +223,25 @@ public: */ void onKeyUp(Common::KeyState keyState); + /** Mark next location */ void changeLocation(char world, char room, char node, char view, uint32 offset); void serializeStateTable(Common::WriteStream *stream); void deserializeStateTable(Common::SeekableReadStream *stream); - void serializeControls(Common::WriteStream *stream); - void deserializeControls(Common::SeekableReadStream *stream); Location getCurrentLocation() const; private: - void createReferenceTable(); + void addPuzzlesToReferenceTable(script_scope &scope); void updateNodes(uint deltaTimeMillis); - void checkPuzzleCriteria(); + void updateControls(uint deltaTimeMillis); + void checkPuzzleCriteria(Puzzle *puzzle, uint counter); void cleanStateTable(); void cleanScriptScope(script_scope &scope); + void execScope(script_scope &scope); + + /** Perform change location */ + void do_changeLocation(); // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it public: @@ -245,7 +251,7 @@ public: * @param fileName Name of the .scr file * @param isGlobal Are the puzzles included in the file global (true). AKA, the won't be purged during location changes */ - void parseScrFile(const Common::String &fileName, bool isGlobal = false); + void parseScrFile(const Common::String &fileName, script_scope &scope); private: /** @@ -291,7 +297,7 @@ private: * @param line The line initially read * @param stream Scr file stream */ - void parseControl(Common::String &line, Common::SeekableReadStream &stream); + Control *parseControl(Common::String &line, Common::SeekableReadStream &stream); }; -- cgit v1.2.3 From 6d5e8cb10569eec6b42e41197227ed1652e57900 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 20:42:14 +0000 Subject: ZVISION: Replace disable/enable control functions by call to getStateFlag. --- engines/zvision/animation_control.cpp | 4 ---- engines/zvision/control.cpp | 18 ------------------ engines/zvision/control.h | 7 ++----- engines/zvision/lever_control.cpp | 12 ++++-------- engines/zvision/push_toggle_control.cpp | 6 ++---- 5 files changed, 8 insertions(+), 39 deletions(-) diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 66eefd7ce6..3f9a2e9cc7 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -71,9 +71,6 @@ AnimationControl::~AnimationControl() { } bool AnimationControl::process(uint32 deltaTimeInMillis) { - if (!_enabled) { - return false; - } bool finished = false; @@ -253,7 +250,6 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { // Then disable the control. DON'T delete it. It can be re-used if (finished) { _engine->getScriptManager()->setStateValue(_animationKey, 2); - disable(); _currentLoop = 0; } diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp index bcbdabc143..0346228681 100644 --- a/engines/zvision/control.cpp +++ b/engines/zvision/control.cpp @@ -33,24 +33,6 @@ namespace ZVision { -void Control::enable() { - if (!_enabled) { - _enabled = true; - return; - } - - debug("Control %u is already enabled", _key); -} - -void Control::disable() { - if (_enabled) { - _enabled = false; - return; - } - - debug("Control %u is already disabled", _key); -} - void Control::parseFlatControl(ZVision *engine) { engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT); } diff --git a/engines/zvision/control.h b/engines/zvision/control.h index ab55763a20..66fdbfee19 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -38,16 +38,14 @@ class ZVision; class Control { public: - Control() : _engine(0), _key(0), _enabled(false) {} - Control(ZVision *engine, uint32 key) : _engine(engine), _key(key), _enabled(false) {} + Control() : _engine(0), _key(0) {} + Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {} virtual ~Control() {} uint32 getKey() { return _key; } - virtual void enable(); - virtual void disable(); virtual void focus() {} virtual void unfocus() {} /** @@ -131,7 +129,6 @@ public: protected: ZVision *_engine; uint32 _key; - bool _enabled; // Static member functions public: diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index b0f9417042..bd2c186ffe 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -191,9 +191,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) { } void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return; - } if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { _mouseIsCaptured = true; @@ -202,9 +201,8 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common } void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return; - } if (_mouseIsCaptured) { _mouseIsCaptured = false; @@ -217,9 +215,8 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: } bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - } bool cursorWasChanged = false; @@ -248,9 +245,8 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common } bool LeverControl::process(uint32 deltaTimeInMillis) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - } if (_isReturning) { _accumulatedTime += deltaTimeInMillis; diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 21a1c41548..2cea5db2d2 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -73,9 +73,8 @@ PushToggleControl::~PushToggleControl() { } void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return; - } if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getScriptManager()->setStateValue(_key, 1); @@ -83,9 +82,8 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com } bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (!_enabled) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - } if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_hoverCursor); -- cgit v1.2.3 From 4d02fe42fdbddb4fb6f5d97611b31410c170082d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 20:44:40 +0000 Subject: ZVISION: Remove not needed (de)serialize functions from controls class. --- engines/zvision/control.h | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 66fdbfee19..32c59d6f27 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -93,38 +93,6 @@ public: virtual bool process(uint32 deltaTimeInMillis) { return false; } - /** - * Serialize a Control for save game use. This should only be used if a Control needs - * to save values that would be different from initialization. AKA a TimerNode needs to - * store the amount of time left on the timer. Any Controls overriding this *MUST* write - * their key as the first data outputted. The default implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override deserialize() - * and needsSerialization() - * - * @param stream Stream to write any needed data to - */ - virtual void serialize(Common::WriteStream *stream) {} - /** - * De-serialize data from a save game stream. This should only be implemented if the - * Control also implements serialize(). The calling method assumes the size of the - * data read from the stream exactly equals that written in serialize(). The default - * implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override serialize() - * and needsSerialization() - * - * @param stream Save game file stream - */ - virtual void deserialize(Common::SeekableReadStream *stream) {} - /** - * If a Control overrides serialize() and deserialize(), this should return true - * - * @return Does the Control need save game serialization? - */ - virtual inline bool needsSerialization() { - return false; - } protected: ZVision *_engine; -- cgit v1.2.3 From 6ace820da623b8579972ae58c50ec782dfcf2589 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 25 Oct 2013 20:47:36 +0000 Subject: ZVISION: Remove field "flags" from puzzle structure. --- engines/zvision/puzzle.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index 1b30829462..c02f60c8f0 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -32,7 +32,7 @@ namespace ZVision { struct Puzzle { - Puzzle() : key(0), flags(0) {} + Puzzle() : key(0) {} ~Puzzle() { for (Common::List::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) { @@ -73,7 +73,6 @@ struct Puzzle { Common::List > criteriaList; // This has to be list of pointers because ResultAction is abstract Common::List resultActions; - uint flags; bool addedBySetState; }; -- cgit v1.2.3 From 66c9d1d0fd8c9df57bcf986dd124c879eae2f35d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 29 Oct 2013 18:33:37 +0000 Subject: ZVISION: Add engine pointer to actionResult for manipulations with engine. --- engines/zvision/actions.cpp | 112 +++++++++++++++++++--------------- engines/zvision/actions.h | 101 +++++++++++++++--------------- engines/zvision/scr_file_handling.cpp | 32 +++++----- engines/zvision/script_manager.cpp | 2 +- 4 files changed, 133 insertions(+), 114 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 3c0adb4082..68c279754d 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -43,12 +43,13 @@ namespace ZVision { // ActionAdd ////////////////////////////////////////////////////////////////////////////// -ActionAdd::ActionAdd(const Common::String &line) { +ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value); } -bool ActionAdd::execute(ZVision *engine) { - engine->getScriptManager()->addToStateValue(_key, _value); +bool ActionAdd::execute() { + _engine->getScriptManager()->addToStateValue(_key, _value); return true; } @@ -57,12 +58,13 @@ bool ActionAdd::execute(ZVision *engine) { // ActionAssign ////////////////////////////////////////////////////////////////////////////// -ActionAssign::ActionAssign(const Common::String &line) { +ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value); } -bool ActionAssign::execute(ZVision *engine) { - engine->getScriptManager()->setStateValue(_key, _value); +bool ActionAssign::execute() { + _engine->getScriptManager()->setStateValue(_key, _value); return true; } @@ -71,11 +73,12 @@ bool ActionAssign::execute(ZVision *engine) { // ActionAttenuate ////////////////////////////////////////////////////////////////////////////// -ActionAttenuate::ActionAttenuate(const Common::String &line) { +ActionAttenuate::ActionAttenuate(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation); } -bool ActionAttenuate::execute(ZVision *engine) { +bool ActionAttenuate::execute() { // TODO: Implement return true; } @@ -85,13 +88,14 @@ bool ActionAttenuate::execute(ZVision *engine) { // ActionChangeLocation ////////////////////////////////////////////////////////////////////////////// -ActionChangeLocation::ActionChangeLocation(const Common::String &line) { +ActionChangeLocation::ActionChangeLocation(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset); } -bool ActionChangeLocation::execute(ZVision *engine) { +bool ActionChangeLocation::execute() { // We can't directly call ScriptManager::ChangeLocationIntern() because doing so clears all the Puzzles, and thus would corrupt the current puzzle checking - engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset); + _engine->getScriptManager()->changeLocation(_world, _room, _node, _view, _offset); // Tell the puzzle system to stop checking any more puzzles return false; } @@ -101,13 +105,14 @@ bool ActionChangeLocation::execute(ZVision *engine) { // ActionCrossfade ////////////////////////////////////////////////////////////////////////////// -ActionCrossfade::ActionCrossfade(const Common::String &line) { +ActionCrossfade::ActionCrossfade(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u %u %u %u %u %u %u)", &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); } -bool ActionCrossfade::execute(ZVision *engine) { +bool ActionCrossfade::execute() { // TODO: Implement return true; } @@ -117,11 +122,12 @@ bool ActionCrossfade::execute(ZVision *engine) { // ActionDisableControl ////////////////////////////////////////////////////////////////////////////// -ActionDisableControl::ActionDisableControl(const Common::String &line) { +ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u)", &_key); } -bool ActionDisableControl::execute(ZVision *engine) { +bool ActionDisableControl::execute() { debug("Disabling control %u", _key); @@ -133,11 +139,12 @@ bool ActionDisableControl::execute(ZVision *engine) { // ActionEnableControl ////////////////////////////////////////////////////////////////////////////// -ActionEnableControl::ActionEnableControl(const Common::String &line) { +ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^(](%u)", &_key); } -bool ActionEnableControl::execute(ZVision *engine) { +bool ActionEnableControl::execute() { debug("Enabling control %u", _key); @@ -149,7 +156,9 @@ bool ActionEnableControl::execute(ZVision *engine) { // ActionMusic ////////////////////////////////////////////////////////////////////////////// -ActionMusic::ActionMusic(const Common::String &line) : _volume(255) { +ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) : + ResultAction(engine), + _volume(255) { uint type; char fileNameBuffer[25]; uint loop; @@ -176,7 +185,7 @@ ActionMusic::ActionMusic(const Common::String &line) : _volume(255) { } } -bool ActionMusic::execute(ZVision *engine) { +bool ActionMusic::execute() { Audio::RewindableAudioStream *audioStream; if (_fileName.contains(".wav")) { @@ -185,14 +194,14 @@ bool ActionMusic::execute(ZVision *engine) { audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); } } else { - audioStream = makeRawZorkStream(_fileName, engine); + audioStream = makeRawZorkStream(_fileName, _engine); } if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume); + _engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume); } else { - engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume); + _engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume); } return true; @@ -203,7 +212,8 @@ bool ActionMusic::execute(ZVision *engine) { // ActionPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) { +ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::String &line) : + ResultAction(engine) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use @@ -212,7 +222,7 @@ ActionPreloadAnimation::ActionPreloadAnimation(const Common::String &line) { _fileName = Common::String(fileName); } -bool ActionPreloadAnimation::execute(ZVision *engine) { +bool ActionPreloadAnimation::execute() { // TODO: We ignore the mask and framerate atm. Mask refers to a key color used for binary alpha. We assume the framerate is the default framerate embedded in the videos // TODO: Check if the Control already exists @@ -226,7 +236,8 @@ bool ActionPreloadAnimation::execute(ZVision *engine) { // ActionPlayAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) { +ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &line) : + ResultAction(engine) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use @@ -237,7 +248,7 @@ ActionPlayAnimation::ActionPlayAnimation(const Common::String &line) { _fileName = Common::String(fileName); } -bool ActionPlayAnimation::execute(ZVision *engine) { +bool ActionPlayAnimation::execute() { // TODO: Implement return true; } @@ -247,15 +258,16 @@ bool ActionPlayAnimation::execute(ZVision *engine) { // ActionPlayPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(const Common::String &line) { +ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)", &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); } -bool ActionPlayPreloadAnimation::execute(ZVision *engine) { +bool ActionPlayPreloadAnimation::execute() { // Find the control - AnimationControl *control = (AnimationControl *)engine->getScriptManager()->getControl(_controlKey); + AnimationControl *control = (AnimationControl *)_engine->getScriptManager()->getControl(_controlKey); // Set the needed values within the control control->setAnimationKey(_animationKey); @@ -271,8 +283,8 @@ bool ActionPlayPreloadAnimation::execute(ZVision *engine) { // ActionQuit ////////////////////////////////////////////////////////////////////////////// -bool ActionQuit::execute(ZVision *engine) { - engine->quitGame(); +bool ActionQuit::execute() { + _engine->quitGame(); return true; } @@ -282,13 +294,14 @@ bool ActionQuit::execute(ZVision *engine) { // ActionRandom ////////////////////////////////////////////////////////////////////////////// -ActionRandom::ActionRandom(const Common::String &line) { +ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max); } -bool ActionRandom::execute(ZVision *engine) { - uint randNumber = engine->getRandomSource()->getRandomNumber(_max); - engine->getScriptManager()->setStateValue(_key, randNumber); +bool ActionRandom::execute() { + uint randNumber = _engine->getRandomSource()->getRandomNumber(_max); + _engine->getScriptManager()->setStateValue(_key, randNumber); return true; } @@ -297,7 +310,8 @@ bool ActionRandom::execute(ZVision *engine) { // ActionSetPartialScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) { +ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) : + ResultAction(engine) { char fileName[25]; uint color; @@ -311,9 +325,8 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) { _backgroundColor = color; } -bool ActionSetPartialScreen::execute(ZVision *engine) { - RenderManager *renderManager = engine->getRenderManager(); - +bool ActionSetPartialScreen::execute() { + RenderManager *renderManager = _engine->getRenderManager(); if (_backgroundColor >= 0) renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor); else @@ -327,15 +340,16 @@ bool ActionSetPartialScreen::execute(ZVision *engine) { // ActionSetScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetScreen::ActionSetScreen(const Common::String &line) { +ActionSetScreen::ActionSetScreen(ZVision *engine, const Common::String &line) : + ResultAction(engine) { char fileName[25]; sscanf(line.c_str(), "%*[^(](%25[^)])", fileName); _fileName = Common::String(fileName); } -bool ActionSetScreen::execute(ZVision *engine) { - engine->getRenderManager()->setBackgroundImage(_fileName); +bool ActionSetScreen::execute() { + _engine->getRenderManager()->setBackgroundImage(_fileName); return true; } @@ -345,7 +359,8 @@ bool ActionSetScreen::execute(ZVision *engine) { // ActionStreamVideo ////////////////////////////////////////////////////////////////////////////// -ActionStreamVideo::ActionStreamVideo(const Common::String &line) { +ActionStreamVideo::ActionStreamVideo(ZVision *engine, const Common::String &line) : + ResultAction(engine) { char fileName[25]; uint skipline; //skipline - render video with skip every second line, not skippable. @@ -355,7 +370,7 @@ ActionStreamVideo::ActionStreamVideo(const Common::String &line) { _skippable = true; } -bool ActionStreamVideo::execute(ZVision *engine) { +bool ActionStreamVideo::execute() { ZorkAVIDecoder decoder; if (!decoder.loadFile(_fileName)) { return true; @@ -366,7 +381,7 @@ bool ActionStreamVideo::execute(ZVision *engine) { destRect = Common::Rect(_x1, _y1, _x2, _y2); } - engine->playVideo(decoder, destRect, _skippable); + _engine->playVideo(decoder, destRect, _skippable); return true; } @@ -375,12 +390,13 @@ bool ActionStreamVideo::execute(ZVision *engine) { // ActionTimer ////////////////////////////////////////////////////////////////////////////// -ActionTimer::ActionTimer(const Common::String &line) { +ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : + ResultAction(engine) { sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time); } -bool ActionTimer::execute(ZVision *engine) { - engine->getScriptManager()->addSideFX(new TimerNode(engine, _key, _time)); +bool ActionTimer::execute() { + _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time)); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 15923d66d1..f779c1fa2f 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -39,6 +39,7 @@ class ZVision; */ class ResultAction { public: + ResultAction(ZVision *engine) : _engine(engine) {} virtual ~ResultAction() {} /** * This is called by the script system whenever a Puzzle's criteria are found to be true. @@ -48,7 +49,9 @@ public: * @param engine A pointer to the base engine so the ResultAction can access all the necessary methods * @return Should the script system continue to test any remaining puzzles (true) or immediately break and go on to the next frame (false) */ - virtual bool execute(ZVision *engine) = 0; + virtual bool execute() = 0; +protected: + ZVision *_engine; }; @@ -85,8 +88,8 @@ public: class ActionAdd : public ResultAction { public: - ActionAdd(const Common::String &line); - bool execute(ZVision *engine); + ActionAdd(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -95,8 +98,8 @@ private: class ActionAssign : public ResultAction { public: - ActionAssign(const Common::String &line); - bool execute(ZVision *engine); + ActionAssign(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -105,8 +108,8 @@ private: class ActionAttenuate : public ResultAction { public: - ActionAttenuate(const Common::String &line); - bool execute(ZVision *engine); + ActionAttenuate(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -115,8 +118,8 @@ private: class ActionChangeLocation : public ResultAction { public: - ActionChangeLocation(const Common::String &line); - bool execute(ZVision *engine); + ActionChangeLocation(ZVision *engine, const Common::String &line); + bool execute(); private: char _world; @@ -128,8 +131,8 @@ private: class ActionCrossfade : public ResultAction { public: - ActionCrossfade(const Common::String &line); - bool execute(ZVision *engine); + ActionCrossfade(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _keyOne; @@ -143,16 +146,16 @@ private: class ActionDebug : public ResultAction { public: - ActionDebug(const Common::String &line); - bool execute(ZVision *engine); + ActionDebug(ZVision *engine, const Common::String &line); + bool execute(); private: }; class ActionDelayRender : public ResultAction { public: - ActionDelayRender(const Common::String &line); - bool execute(ZVision *engine); + ActionDelayRender(ZVision *engine, const Common::String &line); + bool execute(); private: // TODO: Check if this should actually be frames or if it should be milliseconds/seconds @@ -161,8 +164,8 @@ private: class ActionDisableControl : public ResultAction { public: - ActionDisableControl(const Common::String &line); - bool execute(ZVision *engine); + ActionDisableControl(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -170,38 +173,38 @@ private: class ActionDisableVenus : public ResultAction { public: - ActionDisableVenus(const Common::String &line); - bool execute(ZVision *engine); + ActionDisableVenus(ZVision *engine, const Common::String &line); + bool execute(); private: }; class ActionDisplayMessage : public ResultAction { public: - ActionDisplayMessage(const Common::String &line); - bool execute(ZVision *engine); + ActionDisplayMessage(ZVision *engine, const Common::String &line); + bool execute(); private: }; class ActionDissolve : public ResultAction { public: - ActionDissolve(); - bool execute(ZVision *engine); + ActionDissolve(ZVision *engine); + bool execute(); }; class ActionDistort : public ResultAction { public: - ActionDistort(const Common::String &line); - bool execute(ZVision *engine); + ActionDistort(ZVision *engine, const Common::String &line); + bool execute(); private: }; class ActionEnableControl : public ResultAction { public: - ActionEnableControl(const Common::String &line); - bool execute(ZVision *engine); + ActionEnableControl(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -209,8 +212,8 @@ private: class ActionMusic : public ResultAction { public: - ActionMusic(const Common::String &line); - bool execute(ZVision *engine); + ActionMusic(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -222,8 +225,8 @@ private: class ActionPlayAnimation : public ResultAction { public: - ActionPlayAnimation(const Common::String &line); - bool execute(ZVision *engine); + ActionPlayAnimation(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -241,8 +244,8 @@ private: class ActionPlayPreloadAnimation : public ResultAction { public: - ActionPlayPreloadAnimation(const Common::String &line); - bool execute(ZVision *engine); + ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _animationKey; @@ -258,8 +261,8 @@ private: class ActionPreloadAnimation : public ResultAction { public: - ActionPreloadAnimation(const Common::String &line); - bool execute(ZVision *engine); + ActionPreloadAnimation(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -270,21 +273,21 @@ private: class ActionQuit : public ResultAction { public: - ActionQuit() {} - bool execute(ZVision *engine); + ActionQuit(ZVision *engine) : ResultAction(engine) {} + bool execute(); }; // TODO: See if this exists in ZGI. It doesn't in ZNem class ActionUnloadAnimation : public ResultAction { public: - ActionUnloadAnimation(const Common::String &line); - bool execute(ZVision *engine); + ActionUnloadAnimation(ZVision *engine, const Common::String &line); + bool execute(); }; class ActionRandom : public ResultAction { public: - ActionRandom(const Common::String &line); - bool execute(ZVision *engine); + ActionRandom(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; @@ -293,8 +296,8 @@ private: class ActionSetPartialScreen : public ResultAction { public: - ActionSetPartialScreen(const Common::String &line); - bool execute(ZVision *engine); + ActionSetPartialScreen(ZVision *engine, const Common::String &line); + bool execute(); private: uint _x; @@ -305,8 +308,8 @@ private: class ActionSetScreen : public ResultAction { public: - ActionSetScreen(const Common::String &line); - bool execute(ZVision *engine); + ActionSetScreen(ZVision *engine, const Common::String &line); + bool execute(); private: Common::String _fileName; @@ -314,8 +317,8 @@ private: class ActionStreamVideo : public ResultAction { public: - ActionStreamVideo(const Common::String &line); - bool execute(ZVision *engine); + ActionStreamVideo(ZVision *engine, const Common::String &line); + bool execute(); private: enum { @@ -333,8 +336,8 @@ private: class ActionTimer : public ResultAction { public: - ActionTimer(const Common::String &line); - bool execute(ZVision *engine); + ActionTimer(ZVision *engine, const Common::String &line); + bool execute(); private: uint32 _key; diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 4d18306ce4..5a96a569ec 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -163,19 +163,19 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis // Parse for the action type if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(line)); + actionList.push_back(new ActionAdd(_engine, line)); } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(line)); + actionList.push_back(new ActionPlayAnimation(_engine, line)); } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(line)); + actionList.push_back(new ActionPreloadAnimation(_engine, line)); } else if (line.matchString("*:animunload*", true)) { - //actionList.push_back(new ActionUnloadAnimation(line)); + //actionList.push_back(new ActionUnloadAnimation(_engine, line)); } else if (line.matchString("*:attenuate*", true)) { // TODO: Implement ActionAttenuate } else if (line.matchString("*:assign*", true)) { - actionList.push_back(new ActionAssign(line)); + actionList.push_back(new ActionAssign(_engine, line)); } else if (line.matchString("*:change_location*", true)) { - actionList.push_back(new ActionChangeLocation(line)); + actionList.push_back(new ActionChangeLocation(_engine, line)); } else if (line.matchString("*:crossfade*", true)) { // TODO: Implement ActionCrossfade } else if (line.matchString("*:debug*", true)) { @@ -183,7 +183,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:delay_render*", true)) { // TODO: Implement ActionDelayRender } else if (line.matchString("*:disable_control*", true)) { - actionList.push_back(new ActionDisableControl(line)); + actionList.push_back(new ActionDisableControl(_engine, line)); } else if (line.matchString("*:disable_venus*", true)) { // TODO: Implement ActionDisableVenus } else if (line.matchString("*:display_message*", true)) { @@ -193,7 +193,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:distort*", true)) { // TODO: Implement ActionDistort } else if (line.matchString("*:enable_control*", true)) { - actionList.push_back(new ActionEnableControl(line)); + actionList.push_back(new ActionEnableControl(_engine, line)); } else if (line.matchString("*:flush_mouse_events*", true)) { // TODO: Implement ActionFlushMouseEvents } else if (line.matchString("*:inventory*", true)) { @@ -203,17 +203,17 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:menu_bar_enable*", true)) { // TODO: Implement ActionMenuBarEnable } else if (line.matchString("*:music*", true)) { - actionList.push_back(new ActionMusic(line)); + actionList.push_back(new ActionMusic(_engine, line)); } else if (line.matchString("*:pan_track*", true)) { // TODO: Implement ActionPanTrack } else if (line.matchString("*:playpreload*", true)) { - actionList.push_back(new ActionPlayPreloadAnimation(line)); + actionList.push_back(new ActionPlayPreloadAnimation(_engine, line)); } else if (line.matchString("*:preferences*", true)) { // TODO: Implement ActionPreferences } else if (line.matchString("*:quit*", true)) { - actionList.push_back(new ActionQuit()); + actionList.push_back(new ActionQuit(_engine)); } else if (line.matchString("*:random*", true)) { - actionList.push_back(new ActionRandom(line)); + actionList.push_back(new ActionRandom(_engine, line)); } else if (line.matchString("*:region*", true)) { // TODO: Implement ActionRegion } else if (line.matchString("*:restore_game*", true)) { @@ -223,19 +223,19 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:save_game*", true)) { // TODO: Implement ActionSaveGame } else if (line.matchString("*:set_partial_screen*", true)) { - actionList.push_back(new ActionSetPartialScreen(line)); + actionList.push_back(new ActionSetPartialScreen(_engine, line)); } else if (line.matchString("*:set_screen*", true)) { - actionList.push_back(new ActionSetScreen(line)); + actionList.push_back(new ActionSetScreen(_engine, line)); } else if (line.matchString("*:set_venus*", true)) { // TODO: Implement ActionSetVenus } else if (line.matchString("*:stop*", true)) { // TODO: Implement ActionStop } else if (line.matchString("*:streamvideo*", true)) { - actionList.push_back(new ActionStreamVideo(line)); + actionList.push_back(new ActionStreamVideo(_engine, line)); } else if (line.matchString("*:syncsound*", true)) { // TODO: Implement ActionSyncSound } else if (line.matchString("*:timer*", true)) { - actionList.push_back(new ActionTimer(line)); + actionList.push_back(new ActionTimer(_engine, line)); } else if (line.matchString("*:ttytext*", true)) { // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 74035fd41f..3054466cd0 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -205,7 +205,7 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { bool shouldContinue = true; for (Common::List::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) { - shouldContinue = shouldContinue && (*resultIter)->execute(_engine); + shouldContinue = shouldContinue && (*resultIter)->execute(); if (!shouldContinue) { break; } -- cgit v1.2.3 From 41088f5516ba9566dcd558a103216c3798bcf9d4 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 29 Oct 2013 19:41:38 +0000 Subject: ZVISION: Make setPartialScreen use mask color correctly. --- engines/zvision/actions.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 68c279754d..8340c02428 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -313,16 +313,23 @@ bool ActionRandom::execute() { ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) : ResultAction(engine) { char fileName[25]; - uint color; + int color; - sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %u)", &_x, &_y, fileName, &color); + sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %d)", &_x, &_y, fileName, &color); _fileName = Common::String(fileName); - if (color > 0xFFFF) { + if (color >= 0) { + byte r, g, b; + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b); + _backgroundColor = _engine->_pixelFormat.RGBToColor(r, g, b); + } else { + _backgroundColor = color; + } + + if (color > 65535) { warning("Background color for ActionSetPartialScreen is bigger than a uint16"); } - _backgroundColor = color; } bool ActionSetPartialScreen::execute() { -- cgit v1.2.3 From fa74bcc4d50c746c3f06b156200a064a11369baa Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 07:51:05 +0000 Subject: ZVISION: Add to sidefx and scriptManager classes stop and kill methods --- engines/zvision/script_manager.cpp | 46 ++++++++++++++++++++++++++++++++++++++ engines/zvision/script_manager.h | 4 ++++ engines/zvision/sidefx.h | 5 +++++ 3 files changed, 55 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 3054466cd0..111865302a 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -336,6 +336,52 @@ SideFX *ScriptManager::getSideFX(uint32 key) { return nullptr; } +void ScriptManager::deleteSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + delete(*iter); + _activeSideFx.erase(iter); + break; + } + } +} + +void ScriptManager::stopSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + bool ret = (*iter)->stop(); + if (ret) { + delete(*iter); + _activeSideFx.erase(iter); + } + break; + } + } +} + +void ScriptManager::killSideFx(uint32 key) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { + if ((*iter)->getKey() == key) { + (*iter)->kill(); + delete(*iter); + _activeSideFx.erase(iter); + break; + } + } +} + +void ScriptManager::killSideFxType(SideFX::SideFXType type) { + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { + if ((*iter)->getType() & type) { + (*iter)->kill(); + delete(*iter); + _activeSideFx.erase(iter); + } else { + ++iter; + } + } +} + void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 90df2ccee5..3399484970 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -187,6 +187,10 @@ public: void addSideFX(SideFX *fx); SideFX *getSideFX(uint32 key); + void deleteSideFx(uint32 key); + void stopSideFx(uint32 key); + void killSideFx(uint32 key); + void killSideFxType(SideFX::SideFXType type); /** * Called when LeftMouse is pushed. diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 6f75ad6649..9c18371ef4 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -88,6 +88,11 @@ public: return false; } + virtual bool stop() { + return true; + } + virtual void kill() {} + protected: ZVision *_engine; uint32 _key; -- cgit v1.2.3 From b0f74feb41dfd732480a49dd233b59f33a43be88 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 07:53:47 +0000 Subject: ZVISION: Define all sidefx types. --- engines/zvision/sidefx.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 9c18371ef4..210d98effb 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -37,8 +37,15 @@ class SideFX { public: enum SideFXType { - SIDEFX_UNK = 0, - SIDEFX_TIMER = 1 + SIDEFX_ANIM = 1, + SIDEFX_AUDIO = 2, + SIDEFX_DISTORT = 4, + SIDEFX_PANTRACK = 8, + SIDEFX_REGION = 16, + SIDEFX_TIMER = 32, + SIDEFX_TTYTXT = 64, + SIDEFX_UNK = 128, + SIDEFX_ALL = 255 }; SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} -- cgit v1.2.3 From a8feff10b883d686b37a709c483129602187c155 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 07:57:39 +0000 Subject: ZVISION: Add universe scope of puzzles to reference table. --- engines/zvision/script_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 111865302a..fe8ec897b9 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -446,6 +446,8 @@ void ScriptManager::do_changeLocation() { cleanScriptScope(room); cleanScriptScope(world); + addPuzzlesToReferenceTable(universe); + // Parse into puzzles and controls Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); parseScrFile(fileName, nodeview); -- cgit v1.2.3 From e38ca6e7a952b79e1432e322905687c9e11ebb47 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 16:17:29 +0700 Subject: ZVISION: New class for handle values and values from [slots]. --- engines/zvision/script_manager.cpp | 23 +++++++++++++++++++++++ engines/zvision/script_manager.h | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index fe8ec897b9..e88c1ebca7 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -515,4 +515,27 @@ Location ScriptManager::getCurrentLocation() const { return location; } +ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val): + _sc_man(sc_man) { + value = 0; + slot = false; + const char *is_slot = strstr(slot_val, "["); + if (is_slot) { + slot = true; + value = atoi(is_slot + 1); + } else { + slot = false; + value = atoi(slot_val); + } +} +int16 ValueSlot::getValue() { + if (slot) { + if (value >= 0) + return _sc_man->getStateValue(value); + else + return 0; + } else + return value; +} + } // End of namespace ZVision diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 3399484970..dd995f4661 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -304,6 +304,16 @@ private: Control *parseControl(Common::String &line, Common::SeekableReadStream &stream); }; +class ValueSlot { +public: + ValueSlot(ScriptManager *sc_man, const char *slot_val); + int16 getValue(); +private: + int16 value; + bool slot; + ScriptManager *_sc_man; +}; + } // End of namespace ZVision -- cgit v1.2.3 From fa943f1044e78ad9b1305f2d91085c25a945aaa9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 30 Oct 2013 16:21:38 +0700 Subject: ZVISION: Move actionTimer to use ValueSlot class. --- engines/zvision/actions.cpp | 12 ++++++++++-- engines/zvision/actions.h | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 8340c02428..08e99dc501 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -399,11 +399,19 @@ bool ActionStreamVideo::execute() { ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : ResultAction(engine) { - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u)", &_key, &_time); + char time_buf[64]; + memset(time_buf, 0, 64); + sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, time_buf); + _time = new ValueSlot(_engine->getScriptManager(), time_buf); +} + +ActionTimer::~ActionTimer() { + if (_time) + delete _time; } bool ActionTimer::execute() { - _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time)); + _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time->getValue())); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index f779c1fa2f..e900167068 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -32,6 +32,7 @@ namespace ZVision { // Forward declaration of ZVision. This file is included before ZVision is declared class ZVision; +class ValueSlot; /** * The base class that represents any action that a Puzzle can take. @@ -337,11 +338,11 @@ private: class ActionTimer : public ResultAction { public: ActionTimer(ZVision *engine, const Common::String &line); + ~ActionTimer(); bool execute(); - private: uint32 _key; - uint _time; + ValueSlot *_time; }; } // End of namespace ZVision -- cgit v1.2.3 From b2aa30afebe9c799ad2513f6c22cd798c1818eb0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 31 Oct 2013 07:45:43 +0000 Subject: ZVISION: Correct timer code to match original. --- engines/zvision/actions.cpp | 1 + engines/zvision/script_manager.h | 1 + engines/zvision/timer_node.cpp | 19 ++++++++++++++----- engines/zvision/timer_node.h | 2 ++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 08e99dc501..d7921d3653 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -408,6 +408,7 @@ ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : ActionTimer::~ActionTimer() { if (_time) delete _time; + _engine->getScriptManager()->killSideFx(_key); } bool ActionTimer::execute() { diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index dd995f4661..c75296b586 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -49,6 +49,7 @@ enum StateKey { StateKey_KeyPress = 8, StateKey_InventoryItem = 9, StateKey_LMouse = 10, + StateKey_NotSet = 11, // This key doesn't set StateKey_Rounds = 12, StateKey_Venus = 13, StateKey_RMouse = 18, diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index c7cefd6150..f8da0bcf37 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -38,25 +38,34 @@ TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) _timeLeft = timeInSeconds * 1000; else if (_engine->getGameId() == GID_GRANDINQUISITOR) _timeLeft = timeInSeconds * 100; - _engine->getScriptManager()->setStateValue(_key, 1); + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); } TimerNode::~TimerNode() { - if (_timeLeft <= 0) + if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); - else - _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill + int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); + if (timeLeft > 0) + _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill } bool TimerNode::process(uint32 deltaTimeInMillis) { _timeLeft -= deltaTimeInMillis; if (_timeLeft <= 0) - return true; + return stop(); return false; } +bool TimerNode::stop() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + return true; +} + void TimerNode::serialize(Common::WriteStream *stream) { stream->writeUint32LE(_key); stream->writeUint32LE(_timeLeft); diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h index 4a9c95d72b..f6584becda 100644 --- a/engines/zvision/timer_node.h +++ b/engines/zvision/timer_node.h @@ -48,6 +48,8 @@ public: return true; } + bool stop(); + private: int32 _timeLeft; }; -- cgit v1.2.3 From 0b61b653aea21bf0329bcd5738617611d7109ee8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 31 Oct 2013 08:20:57 +0000 Subject: ZVISION: Handle go to 0000 - previous location. --- engines/zvision/script_manager.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index e88c1ebca7..c4ea8be9a2 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -431,15 +431,53 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi _nextLocation.node = _node; _nextLocation.view = _view; _nextLocation.offset = offset; + // If next location 0000 - it's indicate to go to previous location. + if (_nextLocation.world == '0' && _nextLocation.room == '0' && _nextLocation.node == '0' && _nextLocation.view == '0') { + if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { + _nextLocation.world = getStateValue(StateKey_LastWorld); + _nextLocation.room = getStateValue(StateKey_LastRoom); + _nextLocation.node = getStateValue(StateKey_LastNode); + _nextLocation.view = getStateValue(StateKey_LastView); + _nextLocation.offset = getStateValue(StateKey_LastViewPos); + } else { + _nextLocation.world = getStateValue(StateKey_Menu_LastWorld); + _nextLocation.room = getStateValue(StateKey_Menu_LastRoom); + _nextLocation.node = getStateValue(StateKey_Menu_LastNode); + _nextLocation.view = getStateValue(StateKey_Menu_LastView); + _nextLocation.offset = getStateValue(StateKey_Menu_LastViewPos); + } + } } void ScriptManager::do_changeLocation() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); + if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { + if (_nextLocation.world != 'g' || _nextLocation.room != 'j') { + setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); + setStateValue(StateKey_LastRoom, getStateValue(StateKey_Room)); + setStateValue(StateKey_LastNode, getStateValue(StateKey_Node)); + setStateValue(StateKey_LastView, getStateValue(StateKey_View)); + setStateValue(StateKey_LastViewPos, getStateValue(StateKey_ViewPos)); + } else { + setStateValue(StateKey_Menu_LastWorld, getStateValue(StateKey_World)); + setStateValue(StateKey_Menu_LastRoom, getStateValue(StateKey_Room)); + setStateValue(StateKey_Menu_LastNode, getStateValue(StateKey_Node)); + setStateValue(StateKey_Menu_LastView, getStateValue(StateKey_View)); + setStateValue(StateKey_Menu_LastViewPos, getStateValue(StateKey_ViewPos)); + } + } + // Auto save //_engine->getSaveManager()->autoSave(); + setStateValue(StateKey_World, _nextLocation.world); + setStateValue(StateKey_Room, _nextLocation.room); + setStateValue(StateKey_Node, _nextLocation.node); + setStateValue(StateKey_View, _nextLocation.view); + setStateValue(StateKey_ViewPos, _nextLocation.offset); + // Clear all the containers _referenceTable.clear(); cleanScriptScope(nodeview); -- cgit v1.2.3 From 44464ce686f26128a37ef3b8da17ed01f436b928 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 31 Oct 2013 09:53:17 +0700 Subject: ZVISION: Fix actionRandom parameter reader. --- engines/zvision/actions.cpp | 12 ++++++++++-- engines/zvision/actions.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index d7921d3653..5fbfbd6436 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -296,11 +296,19 @@ bool ActionQuit::execute() { ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) : ResultAction(engine) { - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max); + char max_buf[64]; + memset(max_buf, 0, 64); + sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf); + _max = new ValueSlot(_engine->getScriptManager(), max_buf); +} + +ActionRandom::~ActionRandom() { + if (_max) + delete _max; } bool ActionRandom::execute() { - uint randNumber = _engine->getRandomSource()->getRandomNumber(_max); + uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); _engine->getScriptManager()->setStateValue(_key, randNumber); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index e900167068..cc32cc0b43 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -288,11 +288,12 @@ public: class ActionRandom : public ResultAction { public: ActionRandom(ZVision *engine, const Common::String &line); + ~ActionRandom(); bool execute(); private: uint32 _key; - uint _max; + ValueSlot *_max; }; class ActionSetPartialScreen : public ResultAction { -- cgit v1.2.3 From 1477192e8c46918bd56d2430fc04b14495e3e8dd Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:05:15 +0700 Subject: ZVISION: Fix ZorkRaw stream decoder return true instead of real flag. --- engines/zvision/zork_raw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h index 29b555912d..5a07afad05 100644 --- a/engines/zvision/zork_raw.h +++ b/engines/zvision/zork_raw.h @@ -107,7 +107,7 @@ public: int readBuffer(int16 *buffer, const int numSamples); bool isStereo() const { - return true; + return _stereo; } bool endOfData() const { return _endOfData; -- cgit v1.2.3 From a5430c7703331e6180c17b89c95372feb73f0092 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:23:08 +0700 Subject: ZVISION: Don't use unneeded function. --- engines/zvision/actions.cpp | 2 +- engines/zvision/script_manager.cpp | 5 ----- engines/zvision/script_manager.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 5fbfbd6436..ea0d06b1d7 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -49,7 +49,7 @@ ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) : } bool ActionAdd::execute() { - _engine->getScriptManager()->addToStateValue(_key, _value); + _engine->getScriptManager()->setStateValue(_key, _engine->getScriptManager()->getStateValue(_key) + _value); return true; } diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index c4ea8be9a2..e7ec34f9e7 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -296,11 +296,6 @@ void ScriptManager::unsetStateFlag(uint32 key, uint value) { } } -void ScriptManager::addToStateValue(uint32 key, uint valueToAdd) { - _globalState[key] += valueToAdd; -} - - Control *ScriptManager::getControl(uint32 key) { return nullptr; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index c75296b586..07c09c513e 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -172,7 +172,6 @@ public: uint getStateValue(uint32 key); void setStateValue(uint32 key, uint value); - void addToStateValue(uint32 key, uint valueToAdd); uint getStateFlag(uint32 key); void setStateFlag(uint32 key, uint value); -- cgit v1.2.3 From d3ef75dac9a1ac9f091ccc75bf1bc51647a8ba02 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:43:33 +0700 Subject: ZVISION: Replace ZorkRaw audio parameters table by fully implemented with 16bit flag. --- engines/zvision/zork_raw.cpp | 73 ++++++++++++++++++++++++++++++++++++-------- engines/zvision/zork_raw.h | 5 +-- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp index ce83add1df..e7cc71a70b 100644 --- a/engines/zvision/zork_raw.cpp +++ b/engines/zvision/zork_raw.cpp @@ -140,19 +140,64 @@ int RawChunkStream::readBuffer(int16 *buffer, Common::SeekableReadStream *stream return bytesRead; } -const SoundParams RawZorkStream::_zNemSoundParamLookupTable[6] = {{'6', 0x2B11, false, false}, - {'a', 0x5622, false, true}, - {'b', 0x5622, true, true}, - {'n', 0x2B11, false, true}, - {'s', 0x5622, false, true}, - {'t', 0x5622, true, true} +const SoundParams RawZorkStream::_zNemSoundParamLookupTable[32] = {{'0', 0x1F40, false, false, false}, + {'1', 0x1F40, true, false, false}, + {'2', 0x1F40, false, false, true}, + {'3', 0x1F40, true, false, true}, + {'4', 0x2B11, false, false, false}, + {'5', 0x2B11, true, false, false}, + {'6', 0x2B11, false, false, true}, + {'7', 0x2B11, true, false, true}, + {'8', 0x5622, false, false, false}, + {'9', 0x5622, true, false, false}, + {'a', 0x5622, false, false, true}, + {'b', 0x5622, true, false, true}, + {'c', 0xAC44, false, false, false}, + {'d', 0xAC44, true, false, false}, + {'e', 0xAC44, false, false, true}, + {'f', 0xAC44, true, false, true}, + {'g', 0x1F40, false, true, false}, + {'h', 0x1F40, true, true, false}, + {'j', 0x1F40, false, true, true}, + {'k', 0x1F40, true, true, true}, + {'l', 0x2B11, false, true, false}, + {'m', 0x2B11, true, true, false}, + {'n', 0x2B11, false, true, true}, + {'p', 0x2B11, true, true, true}, + {'q', 0x5622, false, true, false}, + {'r', 0x5622, true, true, false}, + {'s', 0x5622, false, true, true}, + {'t', 0x5622, true, true, true}, + {'u', 0xAC44, false, true, false}, + {'v', 0xAC44, true, true, false}, + {'w', 0xAC44, false, true, true}, + {'x', 0xAC44, true, true, true} }; -const SoundParams RawZorkStream::_zgiSoundParamLookupTable[5] = {{'a', 0x5622, false, false}, - {'k', 0x2B11, true, true}, - {'p', 0x5622, false, true}, - {'q', 0x5622, true, true}, - {'u', 0xAC44, true, true} +const SoundParams RawZorkStream::_zgiSoundParamLookupTable[24] = {{'4', 0x2B11, false, false, false}, + {'5', 0x2B11, true, false, false}, + {'6', 0x2B11, false, false, true}, + {'7', 0x2B11, true, false, true}, + {'8', 0x5622, false, false, false}, + {'9', 0x5622, true, false, false}, + {'a', 0x5622, false, false, true}, + {'b', 0x5622, true, false, true}, + {'c', 0xAC44, false, false, false}, + {'d', 0xAC44, true, false, false}, + {'e', 0xAC44, false, false, true}, + {'f', 0xAC44, true, false, true}, + {'g', 0x2B11, false, true, false}, + {'h', 0x2B11, true, true, false}, + {'j', 0x2B11, false, true, true}, + {'k', 0x2B11, true, true, true}, + {'m', 0x5622, false, true, false}, + {'n', 0x5622, true, true, false}, + {'p', 0x5622, false, true, true}, + {'q', 0x5622, true, true, true}, + {'r', 0xAC44, false, true, false}, + {'s', 0xAC44, true, true, false}, + {'t', 0xAC44, false, true, true}, + {'u', 0xAC44, true, true, true} }; RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream) @@ -217,12 +262,12 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, SoundParams soundParams; if (engine->getGameId() == GID_NEMESIS) { - for (int i = 0; i < 6; ++i) { + for (int i = 0; i < 32; ++i) { if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6])) soundParams = RawZorkStream::_zNemSoundParamLookupTable[i]; } } else if (engine->getGameId() == GID_GRANDINQUISITOR) { - for (int i = 0; i < 6; ++i) { + for (int i = 0; i < 24; ++i) { if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7])) soundParams = RawZorkStream::_zgiSoundParamLookupTable[i]; } @@ -232,6 +277,8 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES); } else { byte flags = 0; + if (soundParams.bits16) + flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; if (soundParams.stereo) flags |= Audio::FLAG_STEREO; diff --git a/engines/zvision/zork_raw.h b/engines/zvision/zork_raw.h index 5a07afad05..a5e346dfbb 100644 --- a/engines/zvision/zork_raw.h +++ b/engines/zvision/zork_raw.h @@ -39,6 +39,7 @@ struct SoundParams { uint32 rate; bool stereo; bool packed; + bool bits16; }; @@ -91,8 +92,8 @@ public: } public: - static const SoundParams _zNemSoundParamLookupTable[6]; - static const SoundParams _zgiSoundParamLookupTable[5]; + static const SoundParams _zNemSoundParamLookupTable[32]; + static const SoundParams _zgiSoundParamLookupTable[24]; private: const int _rate; // Sample rate of stream -- cgit v1.2.3 From f46d63d35c61c9076a3c4ef9936bd88dbf8b8218 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:44:44 +0700 Subject: ZVISION: Implement engine-wide method for selecting new audio ID. --- engines/zvision/zvision.cpp | 10 +++++++++- engines/zvision/zvision.h | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 8be85d39d4..9a93259ff4 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -61,7 +61,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _renderManager(nullptr), _saveManager(nullptr), _stringManager(nullptr), - _cursorManager(nullptr) { + _cursorManager(nullptr), + _aud_id(0) { debug(1, "ZVision::ZVision"); } @@ -182,4 +183,11 @@ Common::String ZVision::generateAutoSaveFileName() { return Common::String::format("%s.auto", _targetName.c_str()); } +int ZVision::getAudioId() { + _aud_id++; + if (_aud_id < 0) + _aud_id = 0; + return _aud_id; +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 10711b1605..e7709283ae 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -101,6 +101,9 @@ private: // Clock Clock _clock; + // Audio ID + int _aud_id; + // To prevent allocation every time we process events Common::Event _event; @@ -145,6 +148,8 @@ public: */ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true); + int getAudioId(); + Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); -- cgit v1.2.3 From 7f166720372ef8e4fd95cc4622801d420a8669d6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:46:24 +0700 Subject: ZVISION: StateValue must be signed. --- engines/zvision/script_manager.cpp | 6 +++--- engines/zvision/script_manager.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index e7ec34f9e7..b58056ab29 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -162,7 +162,7 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) { // Get the value to compare against - uint argumentValue; + int argumentValue; if (entryIter->argumentIsAKey) argumentValue = getStateValue(entryIter->argument); else @@ -246,7 +246,7 @@ void ScriptManager::cleanScriptScope(script_scope &scope) { scope.proc_count = 0; } -uint ScriptManager::getStateValue(uint32 key) { +int ScriptManager::getStateValue(uint32 key) { if (_globalState.contains(key)) return _globalState[key]; else @@ -263,7 +263,7 @@ void ScriptManager::queuePuzzles(uint32 key) { } } -void ScriptManager::setStateValue(uint32 key, uint value) { +void ScriptManager::setStateValue(uint32 key, int value) { if (value == 0) _globalState.erase(key); else diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 07c09c513e..487a27cf05 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -109,7 +109,7 @@ struct Location { typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; -typedef Common::HashMap StateMap; +typedef Common::HashMap StateMap; typedef Common::List SideFXList; class ScriptManager { @@ -170,8 +170,8 @@ public: void update(uint deltaTimeMillis); void queuePuzzles(uint32 key); - uint getStateValue(uint32 key); - void setStateValue(uint32 key, uint value); + int getStateValue(uint32 key); + void setStateValue(uint32 key, int value); uint getStateFlag(uint32 key); void setStateFlag(uint32 key, uint value); -- cgit v1.2.3 From a35900142f6a316fde6463b470dbf97ce8426752 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:47:47 +0700 Subject: ZVISION: ActionAdd must handle negative vallues. --- engines/zvision/actions.cpp | 2 +- engines/zvision/actions.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index ea0d06b1d7..5af637f9be 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -45,7 +45,7 @@ namespace ZVision { ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) : ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u,%u)", &_key, &_value); + sscanf(line.c_str(), "%*[^(](%u,%d)", &_key, &_value); } bool ActionAdd::execute() { diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index cc32cc0b43..e2e57c3a74 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -94,7 +94,7 @@ public: private: uint32 _key; - uint _value; + int _value; }; class ActionAssign : public ResultAction { -- cgit v1.2.3 From e1df572ab848f64826fc5cb4a0f22ccddd135871 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:53:46 +0700 Subject: ZVISION: Implement ActionKill. --- engines/zvision/actions.cpp | 40 +++++++++++++++++++++++++++++++++++ engines/zvision/actions.h | 10 +++++++++ engines/zvision/scr_file_handling.cpp | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 5af637f9be..2a79500427 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -152,6 +152,46 @@ bool ActionEnableControl::execute() { } +////////////////////////////////////////////////////////////////////////////// +// ActionKill +////////////////////////////////////////////////////////////////////////////// + +ActionKill::ActionKill(ZVision *engine, const Common::String &line) : + ResultAction(engine) { + _key = 0; + _type = 0; + char keytype[25]; + sscanf(line.c_str(), "%*[^(](%25s)", keytype); + if (keytype[0] == '"') { + if (!scumm_stricmp(keytype, "\"ANIM\"")) + _type = SideFX::SIDEFX_ANIM; + else if (!scumm_stricmp(keytype, "\"AUDIO\"")) + _type = SideFX::SIDEFX_AUDIO; + else if (!scumm_stricmp(keytype, "\"DISTORT\"")) + _type = SideFX::SIDEFX_DISTORT; + else if (!scumm_stricmp(keytype, "\"PANTRACK\"")) + _type = SideFX::SIDEFX_PANTRACK; + else if (!scumm_stricmp(keytype, "\"REGION\"")) + _type = SideFX::SIDEFX_REGION; + else if (!scumm_stricmp(keytype, "\"TIMER\"")) + _type = SideFX::SIDEFX_TIMER; + else if (!scumm_stricmp(keytype, "\"TTYTEXT\"")) + _type = SideFX::SIDEFX_TTYTXT; + else if (!scumm_stricmp(keytype, "\"ALL\"")) + _type = SideFX::SIDEFX_ALL; + } else + _key = atoi(keytype); +} + +bool ActionKill::execute() { + if (_type) + _engine->getScriptManager()->killSideFxType((SideFX::SideFXType)_type); + else + _engine->getScriptManager()->killSideFx(_key); + return true; +} + + ////////////////////////////////////////////////////////////////////////////// // ActionMusic ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index e2e57c3a74..bcd7848c10 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -211,6 +211,16 @@ private: uint32 _key; }; +class ActionKill : public ResultAction { +public: + ActionKill(ZVision *engine, const Common::String &line); + bool execute(); + +private: + uint32 _key; + uint32 _type; +}; + class ActionMusic : public ResultAction { public: ActionMusic(ZVision *engine, const Common::String &line); diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 5a96a569ec..edb496a0eb 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -199,7 +199,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:inventory*", true)) { // TODO: Implement ActionInventory } else if (line.matchString("*:kill*", true)) { - // TODO: Implement ActionKill + actionList.push_back(new ActionKill(_engine, line)); } else if (line.matchString("*:menu_bar_enable*", true)) { // TODO: Implement ActionMenuBarEnable } else if (line.matchString("*:music*", true)) { -- cgit v1.2.3 From be93d7d67dcea18532917a6c1bd6004665973f4f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 16:55:19 +0700 Subject: ZVISION: Implement ActionStop. --- engines/zvision/actions.cpp | 15 +++++++++++++++ engines/zvision/actions.h | 9 +++++++++ engines/zvision/scr_file_handling.cpp | 2 +- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 2a79500427..06ceea2573 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -409,6 +409,21 @@ bool ActionSetScreen::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionStop +////////////////////////////////////////////////////////////////////////////// + +ActionStop::ActionStop(ZVision *engine, const Common::String &line) : + ResultAction(engine) { + _key = 0; + sscanf(line.c_str(), "%*[^(](%u)", &_key); +} + +bool ActionStop::execute() { + _engine->getScriptManager()->stopSideFx(_key); + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionStreamVideo diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index bcd7848c10..8a8412fed5 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -327,6 +327,15 @@ private: Common::String _fileName; }; +class ActionStop : public ResultAction { +public: + ActionStop(ZVision *engine, const Common::String &line); + bool execute(); + +private: + uint32 _key; +}; + class ActionStreamVideo : public ResultAction { public: ActionStreamVideo(ZVision *engine, const Common::String &line); diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index edb496a0eb..bfa1481007 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -229,7 +229,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:set_venus*", true)) { // TODO: Implement ActionSetVenus } else if (line.matchString("*:stop*", true)) { - // TODO: Implement ActionStop + actionList.push_back(new ActionStop(_engine, line)); } else if (line.matchString("*:streamvideo*", true)) { actionList.push_back(new ActionStreamVideo(_engine, line)); } else if (line.matchString("*:syncsound*", true)) { -- cgit v1.2.3 From 9dc0533f4f077a2a5edce902e8d93860c68c3fda Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 17:00:20 +0700 Subject: ZVISION: Implement MusicNode and move ActionMusic to work with it. --- engines/zvision/actions.cpp | 47 ++++++++++++------- engines/zvision/actions.h | 4 +- engines/zvision/module.mk | 3 +- engines/zvision/music_node.cpp | 86 +++++++++++++++++++++++++++++++++++ engines/zvision/music_node.h | 62 +++++++++++++++++++++++++ engines/zvision/scr_file_handling.cpp | 4 +- 6 files changed, 185 insertions(+), 21 deletions(-) create mode 100644 engines/zvision/music_node.cpp create mode 100644 engines/zvision/music_node.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 06ceea2573..3dd6382060 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -30,6 +30,7 @@ #include "zvision/zork_raw.h" #include "zvision/zork_avi_decoder.h" #include "zvision/timer_node.h" +#include "zvision/music_node.h" #include "zvision/animation_control.h" #include "common/file.h" @@ -196,9 +197,10 @@ bool ActionKill::execute() { // ActionMusic ////////////////////////////////////////////////////////////////////////////// -ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) : +ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool global) : ResultAction(engine), - _volume(255) { + _volume(255), + _universe(global) { uint type; char fileNameBuffer[25]; uint loop; @@ -225,24 +227,35 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line) : } } -bool ActionMusic::execute() { - Audio::RewindableAudioStream *audioStream; +ActionMusic::~ActionMusic() { + if (!_universe) + _engine->getScriptManager()->killSideFx(_key); +} - if (_fileName.contains(".wav")) { - Common::File *file = new Common::File(); - if (file->open(_fileName)) { - audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); +bool ActionMusic::execute() { + if (_engine->getScriptManager()->getSideFX(_key)) + return true; + Common::File *file = new Common::File(); + if (!file->exists(_fileName) && _fileName.size() >= 12) { + _fileName.setChar('r', 9); + _fileName.setChar('a', 10); + _fileName.setChar('w', 11); + if (!file->exists(_fileName)) { + _fileName.setChar('i', 9); + _fileName.setChar('f', 10); + _fileName.setChar('p', 11); + if (!file->exists(_fileName)) { + _fileName.setChar('s', 9); + _fileName.setChar('r', 10); + _fileName.setChar('c', 11); + if (!file->exists(_fileName)) + return true; + } } - } else { - audioStream = makeRawZorkStream(_fileName, _engine); - } - - if (_loop) { - Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume); - } else { - _engine->_mixer->playStream(_soundType, 0, audioStream, -1, _volume); } + if (file->exists(_fileName)) + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _key, _fileName, _loop, _volume)); + delete file; return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 8a8412fed5..7464d83b09 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -223,7 +223,8 @@ private: class ActionMusic : public ResultAction { public: - ActionMusic(ZVision *engine, const Common::String &line); + ActionMusic(ZVision *engine, const Common::String &line, bool global); + ~ActionMusic(); bool execute(); private: @@ -232,6 +233,7 @@ private: Common::String _fileName; bool _loop; byte _volume; + bool _universe; }; class ActionPlayAnimation : public ResultAction { diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index edd08c8e9f..8d37311462 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -30,7 +30,8 @@ MODULE_OBJS := \ zfs_archive.o \ zork_avi_decoder.o \ zork_raw.o \ - sidefx.o + sidefx.o \ + music_node.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp new file mode 100644 index 0000000000..6be4683178 --- /dev/null +++ b/engines/zvision/music_node.cpp @@ -0,0 +1,86 @@ +/* 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 "common/scummsys.h" + +#include "zvision/music_node.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" +#include "zvision/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + + +namespace ZVision { + +MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) + : SideFX(engine, key, SIDEFX_AUDIO) { + _loop = loop; + _volume = volume; + _crossfade = false; + _crossfade_delta = 0; + _crossfade_time = 0; + _attenuate = 0; + _pantrack = false; + _pantrack_X = 0; + + Audio::RewindableAudioStream *audioStream; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (file->open(filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + _id = _engine->getAudioId(); + + if (_loop) { + Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, loopingAudioStream, _id, _volume); + } else { + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, audioStream, _id, _volume); + } + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +MusicNode::~MusicNode() { + _engine->_mixer->stopID(_id); + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + debug(1, "MusicNode: %d destroyed\n", _key); +} + +bool MusicNode::process(uint32 deltaTimeInMillis) { + if (! _engine->_mixer->isSoundIDActive(_id)) + return stop(); + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h new file mode 100644 index 0000000000..6aed4556fa --- /dev/null +++ b/engines/zvision/music_node.h @@ -0,0 +1,62 @@ +/* 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 ZVISION_MUSIC_NODE_H +#define ZVISION_MUSIC_NODE_H + +#include "zvision/sidefx.h" + +namespace Common { +class String; +} + +namespace ZVision { +class MusicNode : public SideFX { +public: + MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); + ~MusicNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + +private: + int32 _timeLeft; + bool _pantrack; + int32 _pantrack_X; + int32 _attenuate; + int8 _volume; + int32 _id; + bool _loop; + bool _crossfade; + int32 _crossfade_delta; + int32 _crossfade_time; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index bfa1481007..0df3143a51 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -203,7 +203,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:menu_bar_enable*", true)) { // TODO: Implement ActionMenuBarEnable } else if (line.matchString("*:music*", true)) { - actionList.push_back(new ActionMusic(_engine, line)); + actionList.push_back(new ActionMusic(_engine, line, false)); } else if (line.matchString("*:pan_track*", true)) { // TODO: Implement ActionPanTrack } else if (line.matchString("*:playpreload*", true)) { @@ -239,7 +239,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:ttytext*", true)) { // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { - // TODO: Implement ActionUniverseMusic + actionList.push_back(new ActionMusic(_engine, line, true)); } else if (line.matchString("*:copy_file*", true)) { // Not used. Purposely left empty } else { -- cgit v1.2.3 From 6a135c677920184db0d055230c596fc4bd0a5960 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 1 Nov 2013 17:01:07 +0700 Subject: ZVISION: Add zgi_mx directory for files search --- engines/zvision/zvision.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 9a93259ff4..62061bfab6 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -95,6 +95,7 @@ void ZVision::initialize() { SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true); SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true); SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, true); + SearchMan.addSubDirectoryMatching(gameDataDir, "zgi_mx", 0, 1, true); SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true); // Find zfs archive files -- cgit v1.2.3 From 5da10e99b25bfd866b1ef73cadee71bf9b825c52 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 7 Nov 2013 16:43:45 +0700 Subject: ZVISION: Make source surface const type for read-only access. --- engines/zvision/render_manager.cpp | 22 +++++++++++----------- engines/zvision/render_manager.h | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index a240e766df..58df5a8d11 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -159,7 +159,7 @@ void RenderManager::clearWorkingWindowTo555Color(uint16 color) { } } -void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) { +void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) { if (src.format != dst.format) return; @@ -183,7 +183,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface return; // Copy rendRect from src surface to dst surface - byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top); + const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top); byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); int32 w = rendRect.width(); @@ -196,7 +196,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface } } -void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) { +void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) { if (src.format != dst.format) return; @@ -222,7 +222,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1); // Copy rendRect from src surface to dst surface - byte *src_buf = (byte *)src.getBasePtr(rendRect.left, rendRect.top); + const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top); byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); int32 w = rendRect.width(); @@ -231,7 +231,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface for (int32 y = 0; y < h; y++) { switch (src.format.bytesPerPixel) { case 1: { - uint *src_tmp = (uint *)src_buf; + const uint *src_tmp = (const uint *)src_buf; uint *dst_tmp = (uint *)dst_buf; for (int32 x = 0; x < w; x++) { if (*src_tmp != _keycolor) @@ -243,7 +243,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface break; case 2: { - uint16 *src_tmp = (uint16 *)src_buf; + const uint16 *src_tmp = (const uint16 *)src_buf; uint16 *dst_tmp = (uint16 *)dst_buf; for (int32 x = 0; x < w; x++) { if (*src_tmp != _keycolor) @@ -255,7 +255,7 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface break; case 4: { - uint32 *src_tmp = (uint32 *)src_buf; + const uint32 *src_tmp = (const uint32 *)src_buf; uint32 *dst_tmp = (uint32 *)dst_buf; for (int32 x = 0; x < w; x++) { if (*src_tmp != _keycolor) @@ -274,14 +274,14 @@ void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface } } -void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) { +void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) { if (!Common::Rect(dst.w, dst.h).contains(dstPt)) return; Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); copyRectToSurface(src, dst, srcRect, dstRect); } -void RenderManager::copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) { +void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) { if (!Common::Rect(dst.w, dst.h).contains(dstPt)) return; Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); @@ -299,7 +299,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1 moveBackground(0); } -void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY) { +void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY) { Common::Rect srcRect(surface.w, surface.h); Common::Point dstPt(destX, destY); @@ -318,7 +318,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1 moveBackground(0); } -void RenderManager::renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) { +void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) { Common::Rect srcRect(surface.w, surface.h); Common::Point dstPt(destX, destY); diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 37bfcfa20d..c302844117 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -225,7 +225,7 @@ public: * @param srcRect Rect of source surface * @param dstRect Rect for destenation surface */ - void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect); + void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect); /** * Copies a rectangla of source surface and copy to destination rect. @@ -236,7 +236,7 @@ public: * @param dstRect Rect for destenation surface * @param colorkey Transparent color */ - void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey); + void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey); /** * Copies a rectangla of source surface and copy to destination rect. @@ -246,7 +246,7 @@ public: * @param srcRect Rect of source surface * @param dstPt Point for destenation surface */ - void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt); + void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt); /** * Copies a rectangla of source surface and copy to destination rect. @@ -257,7 +257,7 @@ public: * @param dstPt Point for destenation surface * @param colorkey Transparent color */ - void copyRectToSurface(Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey); + void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey); /** * Blits the image or a portion of the image to the background. @@ -275,7 +275,7 @@ public: * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! */ - void renderImageToBackground(Graphics::Surface &surface, int16 destinationX, int16 destinationY); + void renderImageToBackground(const Graphics::Surface &surface, int16 destinationX, int16 destinationY); /** * Blits the image or a portion of the image to the background. @@ -295,7 +295,7 @@ public: * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! * @param colorkey Transparent color */ - void renderImageToBackground(Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey); + void renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey); /** * Sets the current background image to be used by the RenderManager and immediately -- cgit v1.2.3 From b635fab6e663b0fac154d4fa75d221db4aabb1f5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 7 Nov 2013 16:46:54 +0700 Subject: ZVISION: ActionAssign value can be another slot, ValueSlot must be used. --- engines/zvision/actions.cpp | 12 ++++++++++-- engines/zvision/actions.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 3dd6382060..4fe288d228 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -61,11 +61,19 @@ bool ActionAdd::execute() { ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) : ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u, %u)", &_key, &_value); + char buf[64]; + memset(buf, 0, 64); + sscanf(line.c_str(), "%*[^(](%u, %s)", &_key, buf); + _value = new ValueSlot(_engine->getScriptManager(), buf); +} + +ActionAssign::~ActionAssign() { + if (_value) + delete _value; } bool ActionAssign::execute() { - _engine->getScriptManager()->setStateValue(_key, _value); + _engine->getScriptManager()->setStateValue(_key, _value->getValue()); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 7464d83b09..1d7a815819 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -100,11 +100,12 @@ private: class ActionAssign : public ResultAction { public: ActionAssign(ZVision *engine, const Common::String &line); + ~ActionAssign(); bool execute(); private: uint32 _key; - uint _value; + ValueSlot *_value; }; class ActionAttenuate : public ResultAction { -- cgit v1.2.3 From 7bd57a9ad6bfa551ce2fb605b71fa78e38c5fe88 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 7 Nov 2013 17:06:25 +0700 Subject: ZVISION: Make rlf animation logic equivalent to video decoder methods. --- engines/zvision/animation_control.cpp | 2 +- engines/zvision/rlf_animation.cpp | 31 ++++++++++++++++++------------- engines/zvision/rlf_animation.h | 11 +++++------ 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 3f9a2e9cc7..5b35a4a468 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -94,7 +94,7 @@ bool AnimationControl::process(uint32 deltaTimeInMillis) { return false; } - const Graphics::Surface *frame = _animation.rlf->getNextFrame(); + const Graphics::Surface *frame = _animation.rlf->decodeNextFrame(); // Animation frames for PANORAMAs are transposed, so un-transpose them RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index 795167e572..dab32aed17 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -43,7 +43,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) _height(0), _frameTime(0), _frames(0), - _currentFrame(-1), + _currentFrame(0), _frameBufferByteSize(0) { if (!_file.open(fileName)) { warning("RLF animation file %s could not be opened", fileName.c_str()); @@ -157,8 +157,11 @@ void RlfAnimation::seekToFrame(int frameNumber) { assert(!_stream); assert(frameNumber < (int)_frameCount || frameNumber >= -1); - if (frameNumber == -1) { - _currentFrame = -1; + if (_currentFrame == frameNumber) + return; + + if (frameNumber < 0) { + _currentFrame = 0; return; } @@ -166,13 +169,15 @@ void RlfAnimation::seekToFrame(int frameNumber) { int distance = (int)frameNumber - _currentFrame; for (uint i = 0; i < _completeFrames.size(); ++i) { int newDistance = (int)frameNumber - (int)(_completeFrames[i]); - if (newDistance > 0 && (closestFrame == -1 || newDistance < distance)) { + if (newDistance < 0) + break; + if (newDistance > 0 && newDistance < distance) { closestFrame = _completeFrames[i]; distance = newDistance; } } - for (int i = closestFrame; i <= frameNumber; ++i) { + for (int i = closestFrame; i < frameNumber; ++i) { applyFrameToCurrent(i); } @@ -184,24 +189,24 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { assert(frameNumber < _frameCount); // Since this method is so expensive, first check to see if we can use - // getNextFrame() it's cheap. - if ((int)frameNumber == _currentFrame) { + // decodeNextFrame() it's cheap. + if ((int)frameNumber == _currentFrame - 1) { return &_currentFrameBuffer; - } else if (_currentFrame + 1 == (int)frameNumber) { - return getNextFrame(); + } else if (_currentFrame == (int)frameNumber) { + return decodeNextFrame(); } seekToFrame(frameNumber); - return &_currentFrameBuffer; + return decodeNextFrame(); } -const Graphics::Surface *RlfAnimation::getNextFrame() { - assert(_currentFrame + 1 < (int)_frameCount); +const Graphics::Surface *RlfAnimation::decodeNextFrame() { + assert(_currentFrame < (int)_frameCount); if (_stream) { applyFrameToCurrent(readNextFrame()); } else { - applyFrameToCurrent(_currentFrame + 1); + applyFrameToCurrent(_currentFrame); } _currentFrame++; diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index b0f7ee204e..35916de6cb 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -92,7 +92,7 @@ public: /** * Returns the pixel data of the frame specified. It will try to use - * getNextFrame() if possible. If not, it uses seekToFrame() to + * decodeNextFrame() if possible. If not, it uses seekToFrame() to * update the internal Surface and then returns a pointer to it. * This function requires _stream = false * @@ -101,19 +101,18 @@ public: */ const Graphics::Surface *getFrameData(uint frameNumber); /** - * Returns the pixel data of the next frame. It is up to the user to - * check if the next frame is valid before calling this. + * Returns the pixel data of current frame and go to next. It is up to the user to + * check if the current frame is valid before calling this. * IE. Use endOfAnimation() * * @return A pointer to the pixel data. Do NOT delete this. */ - const Graphics::Surface *getNextFrame(); - + const Graphics::Surface *decodeNextFrame(); /** * @return Is the currentFrame is the last frame in the animation? */ bool endOfAnimation() { - return _currentFrame == (int)_frameCount - 1; + return _currentFrame == (int)_frameCount; } private: -- cgit v1.2.3 From a0d73c34cf21403be85af43a5f1020ae910edde7 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 13 Nov 2013 22:38:57 +0000 Subject: ZVISION: Code for ActionDisableControl and ActionEnableControl. --- engines/zvision/actions.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 4fe288d228..ea33736b5d 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -137,9 +137,7 @@ ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String } bool ActionDisableControl::execute() { - debug("Disabling control %u", _key); - - + _engine->getScriptManager()->setStateFlag(_key, Puzzle::DISABLED); return true; } @@ -154,9 +152,7 @@ ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String & } bool ActionEnableControl::execute() { - debug("Enabling control %u", _key); - - + _engine->getScriptManager()->unsetStateFlag(_key, Puzzle::DISABLED); return true; } -- cgit v1.2.3 From 29fc5be12ee5e28e1b74402065858698f4b8eb16 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:02:18 +0000 Subject: ZVISION: Don't add puzzle to referencetable[key] twice. --- engines/zvision/script_manager.cpp | 15 +++++++++++++-- engines/zvision/script_manager.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index b58056ab29..13fb58b022 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -106,6 +106,17 @@ void ScriptManager::execScope(script_scope &scope) { } } +void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) { + if (_referenceTable.contains(key)) { + Common::Array *arr = &_referenceTable[key]; + for (uint32 i = 0; i < arr->size(); i++) + if ((*arr)[i].puz == ref.puz) + return; + } + + _referenceTable[key].push_back(ref); +} + void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { // Iterate through each local Puzzle for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) { @@ -115,12 +126,12 @@ void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { ref.scope = &scope; ref.puz = puzzlePtr; - _referenceTable[puzzlePtr->key].push_back(ref); + referenceTableAddPuzzle(puzzlePtr->key, ref); // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle for (Common::List >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter) for (Common::List::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) - _referenceTable[entryIter->key].push_back(ref); + referenceTableAddPuzzle(entryIter->key, ref); } } diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 487a27cf05..38d398248e 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -236,6 +236,7 @@ public: Location getCurrentLocation() const; private: + void referenceTableAddPuzzle(uint32 key, puzzle_ref ref); void addPuzzlesToReferenceTable(script_scope &scope); void updateNodes(uint deltaTimeMillis); void updateControls(uint deltaTimeMillis); -- cgit v1.2.3 From 9363a0d07115368f8964dfca5f48730552ef9855 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:05:11 +0000 Subject: ZVISION: Reverse queue puzzles adding to end->begin --- engines/zvision/script_manager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 13fb58b022..28850857df 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -266,10 +266,11 @@ int ScriptManager::getStateValue(uint32 key) { void ScriptManager::queuePuzzles(uint32 key) { if (_referenceTable.contains(key)) { - for (Common::Array::iterator iter = _referenceTable[key].begin(); iter != _referenceTable[key].end(); ++iter) - if (!iter->puz->addedBySetState) { - iter->scope->scope_queue->push_back(iter->puz); - iter->puz->addedBySetState = true; + Common::Array *arr = &_referenceTable[key]; + for (int32 i = arr->size() - 1; i >= 0; i--) + if (!(*arr)[i].puz->addedBySetState) { + (*arr)[i].scope->scope_queue->push_back((*arr)[i].puz); + (*arr)[i].puz->addedBySetState = true; } } } -- cgit v1.2.3 From 468c44581f4a051d435f8574fa4f689b97188ae2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:10:27 +0000 Subject: ZVISION: MouseUp and MouseDown now will return break process loop flag. --- engines/zvision/control.h | 8 ++++++-- engines/zvision/input_control.cpp | 3 ++- engines/zvision/input_control.h | 2 +- engines/zvision/lever_control.cpp | 10 ++++++---- engines/zvision/lever_control.h | 4 ++-- engines/zvision/push_toggle_control.cpp | 6 ++++-- engines/zvision/push_toggle_control.h | 2 +- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 32c59d6f27..65d76da5c4 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -54,14 +54,18 @@ public: * @param screenSpacePos The position of the mouse in screen space * @param backgroundImageSpacePos The position of the mouse in background image space */ - virtual void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {} + virtual bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + return false; + } /** * Called when LeftMouse is lifted. Default is NOP. * * @param screenSpacePos The position of the mouse in screen space * @param backgroundImageSpacePos The position of the mouse in background image space */ - virtual void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) {} + virtual bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + return false; + } /** * Called on every MouseMove. Default is NOP. * diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp index 5723a4e4a4..8d9d79ba09 100644 --- a/engines/zvision/input_control.cpp +++ b/engines/zvision/input_control.cpp @@ -93,8 +93,9 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } } -void InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { +bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { _engine->getScriptManager()->focusControl(_key); + return false; } void InputControl::onKeyDown(Common::KeyState keyState) { diff --git a/engines/zvision/input_control.h b/engines/zvision/input_control.h index 3d7db747d7..0179bd9006 100644 --- a/engines/zvision/input_control.h +++ b/engines/zvision/input_control.h @@ -54,7 +54,7 @@ public: void unfocus() { _focused = false; } - void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); void onKeyDown(Common::KeyState keyState); bool process(uint32 deltaTimeInMillis); }; diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index bd2c186ffe..6d13d60b3e 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -190,19 +190,20 @@ void LeverControl::parseLevFile(const Common::String &fileName) { } } -void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { +bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return; + return false; if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { _mouseIsCaptured = true; _lastMousePos = backgroundImageSpacePos; } + return false; } -void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { +bool LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return; + return false; if (_mouseIsCaptured) { _mouseIsCaptured = false; @@ -212,6 +213,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: _returnRoutesCurrentProgress = _frameInfo[_currentFrame].returnRoute.begin(); _returnRoutesCurrentFrame = _currentFrame; } + return false; } bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h index 94d23c1f95..19ecc7b9ac 100644 --- a/engines/zvision/lever_control.h +++ b/engines/zvision/lever_control.h @@ -88,8 +88,8 @@ private: uint32 _accumulatedTime; public: - void onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); bool process(uint32 deltaTimeInMillis); diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 2cea5db2d2..88619e8f97 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -72,13 +72,15 @@ PushToggleControl::~PushToggleControl() { _engine->getScriptManager()->setStateValue(_key, 0); } -void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { +bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return; + return false; if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getScriptManager()->setStateValue(_key, 1); + return true; } + return false; } bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h index 2a407cada9..1de279aa08 100644 --- a/engines/zvision/push_toggle_control.h +++ b/engines/zvision/push_toggle_control.h @@ -41,7 +41,7 @@ public: * @param screenSpacePos The position of the mouse in screen space * @param backgroundImageSpacePos The position of the mouse in background image space */ - void onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); /** * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. * -- cgit v1.2.3 From 677c74d59ffe43e618911f84c2dd4302cd11478f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:12:51 +0000 Subject: ZVISION: Now onMouse functions handle return results and processing control list from end to beginning --- engines/zvision/script_manager.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 28850857df..c8ef86556a 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -392,28 +392,31 @@ void ScriptManager::killSideFxType(SideFX::SideFXType type) { void ScriptManager::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos); + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseDown(screenSpacePos, backgroundImageSpacePos)) + return; } } void ScriptManager::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos); + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseUp(screenSpacePos, backgroundImageSpacePos)) + return; } } bool ScriptManager::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (!_activeControls) return false; - bool cursorWasChanged = false; - for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - cursorWasChanged = cursorWasChanged || (*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos); + + for (ControlList::iterator iter = _activeControls->reverse_begin(); iter != _activeControls->end(); iter--) { + if ((*iter)->onMouseMove(screenSpacePos, backgroundImageSpacePos)) + return true; } - return cursorWasChanged; + return false; } void ScriptManager::onKeyDown(Common::KeyState keyState) { -- cgit v1.2.3 From 5fd15be0a2810c7c18dca982685c118ee83349e7 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:14:09 +0000 Subject: ZVISION: Don't output setStateValue debug information. --- engines/zvision/script_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index c8ef86556a..861f0e47dc 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -280,7 +280,7 @@ void ScriptManager::setStateValue(uint32 key, int value) { _globalState.erase(key); else _globalState[key] = value; - debug("setStateValue %d %d\n", key , value); + queuePuzzles(key); } -- cgit v1.2.3 From e3b9f84d8179a69be011f7351fb50635f854bf73 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:15:12 +0000 Subject: ZVISION: Change _currentLocation to new location before execute first scripts. --- engines/zvision/script_manager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 861f0e47dc..b121eaa6a7 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -523,11 +523,11 @@ void ScriptManager::do_changeLocation() { // Change the background position _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); - execScope(room); - execScope(nodeview); - // Update _currentLocation _currentLocation = _nextLocation; + + execScope(room); + execScope(nodeview); } void ScriptManager::serializeStateTable(Common::WriteStream *stream) { -- cgit v1.2.3 From 30ee8ed0fd1e983f5472bd5f382c39ba7e400cb2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:34:11 +0000 Subject: ZVISION: Refactore AnimationControl to AnimationNode + changes for correct use it from actions. --- engines/zvision/actions.cpp | 58 ++++++-- engines/zvision/actions.h | 12 +- engines/zvision/animation_control.cpp | 268 ++++++++++++---------------------- engines/zvision/animation_control.h | 51 ++++--- 4 files changed, 168 insertions(+), 221 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index ea33736b5d..f83d295dde 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -274,17 +274,29 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St char fileName[25]; // The two %*u are always 0 and dont seem to have a use - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %u %u)", &_key, fileName, &_mask, &_framerate); + sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate); + + if (_mask > 0) { + byte r, g, b; + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b); + _mask = _engine->_pixelFormat.RGBToColor(r, g, b); + } _fileName = Common::String(fileName); } -bool ActionPreloadAnimation::execute() { - // TODO: We ignore the mask and framerate atm. Mask refers to a key color used for binary alpha. We assume the framerate is the default framerate embedded in the videos +ActionPreloadAnimation::~ActionPreloadAnimation() { + _engine->getScriptManager()->deleteSideFx(_key); +} - // TODO: Check if the Control already exists +bool ActionPreloadAnimation::execute() { + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); - // Create the control, but disable it until PlayPreload is called + if (!nod) { + nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false); + _engine->getScriptManager()->addSideFX(nod); + } else + nod->stop(); return true; } @@ -299,14 +311,34 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String & // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %u %*u %*u %u %u)", + "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)", &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate); + if (_mask > 0) { + byte r, g, b; + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b); + _mask = _engine->_pixelFormat.RGBToColor(r, g, b); + } + _fileName = Common::String(fileName); } +ActionPlayAnimation::~ActionPlayAnimation() { + _engine->getScriptManager()->deleteSideFx(_key); +} + bool ActionPlayAnimation::execute() { - // TODO: Implement + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + + if (!nod) { + nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate); + _engine->getScriptManager()->addSideFX(nod); + } else + nod->stop(); + + if (nod) + nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount); + return true; } @@ -323,14 +355,10 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Co } bool ActionPlayPreloadAnimation::execute() { - // Find the control - AnimationControl *control = (AnimationControl *)_engine->getScriptManager()->getControl(_controlKey); - - // Set the needed values within the control - control->setAnimationKey(_animationKey); - control->setLoopCount(_loopCount); - control->setXPos(_x1); - control->setYPost(_y1); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey); + + if (nod) + nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 1d7a815819..b75c201d99 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -240,6 +240,7 @@ private: class ActionPlayAnimation : public ResultAction { public: ActionPlayAnimation(ZVision *engine, const Common::String &line); + ~ActionPlayAnimation(); bool execute(); private: @@ -251,9 +252,9 @@ private: uint32 _height; uint32 _start; uint32 _end; - uint _mask; - uint _framerate; - uint _loopCount; + int32 _mask; + int32 _framerate; + int32 _loopCount; }; class ActionPlayPreloadAnimation : public ResultAction { @@ -276,13 +277,14 @@ private: class ActionPreloadAnimation : public ResultAction { public: ActionPreloadAnimation(ZVision *engine, const Common::String &line); + ~ActionPreloadAnimation(); bool execute(); private: uint32 _key; Common::String _fileName; - uint _mask; - uint _framerate; + int32 _mask; + int32 _framerate; }; class ActionQuit : public ResultAction { diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp index 5b35a4a468..f825bbedfc 100644 --- a/engines/zvision/animation_control.cpp +++ b/engines/zvision/animation_control.cpp @@ -37,222 +37,140 @@ namespace ZVision { -AnimationControl::AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName) - : Control(engine, controlKey), +AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) + : SideFX(engine, controlKey, SIDEFX_ANIM), _fileType(RLF), - _loopCount(1), - _currentLoop(0), - _accumulatedTime(0), - _cachedFrame(0), - _cachedFrameNeedsDeletion(false) { + _DisposeAfterUse(DisposeAfterUse), + _mask(mask) { if (fileName.hasSuffix(".rlf")) { _fileType = RLF; _animation.rlf = new RlfAnimation(fileName, false); + _frmDelay = _animation.rlf->frameTime(); } else if (fileName.hasSuffix(".avi")) { _fileType = AVI; _animation.avi = new ZorkAVIDecoder(); _animation.avi->loadFile(fileName); + _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); } else { warning("Unrecognized animation file type: %s", fileName.c_str()); } - _cachedFrame = new Graphics::Surface(); + if (frate > 0) + _frmDelay = 1000.0 / frate; } -AnimationControl::~AnimationControl() { +AnimationNode::~AnimationNode() { if (_fileType == RLF) { delete _animation.rlf; } else if (_fileType == AVI) { delete _animation.avi; } - _cachedFrame->free(); - delete _cachedFrame; -} - -bool AnimationControl::process(uint32 deltaTimeInMillis) { - - bool finished = false; + _engine->getScriptManager()->setStateValue(_key, 2); - if (_fileType == RLF) { - _accumulatedTime += deltaTimeInMillis; + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) + _engine->getScriptManager()->setStateValue((*it).slot, 2); - uint32 frameTime = _animation.rlf->frameTime(); - if (_accumulatedTime >= frameTime) { - while (_accumulatedTime >= frameTime) { - _accumulatedTime -= frameTime; + _playList.clear(); +} - // Make sure the frame is inside the working window - // If it's not, then just return +bool AnimationNode::process(uint32 deltaTimeInMillis) { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + + nod->_delay -= deltaTimeInMillis; + if (nod->_delay <= 0) { + nod->_delay += _frmDelay; + + const Graphics::Surface *frame = NULL; + + if (nod->_cur_frm == -1) { // Start of new playlist node + nod->_cur_frm = nod->start; + if (_fileType == RLF) { + _animation.rlf->seekToFrame(nod->_cur_frm); + frame = _animation.rlf->decodeNextFrame(); + } else if (_fileType == AVI) { + _animation.avi->seekToFrame(nod->_cur_frm); + frame = _animation.avi->decodeNextFrame(); + } - RenderManager *renderManager = _engine->getRenderManager(); - Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y)); - Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _animation.rlf->width(), workingWindowPoint.y + _animation.rlf->height()); + nod->_delay = _frmDelay; + if (nod->slot) + _engine->getScriptManager()->setStateValue(nod->slot, 1); + } else { + nod->_cur_frm++; - // If the clip returns false, it means the animation is outside the working window - if (!renderManager->clipRectToWorkingWindow(subRect)) { - return false; - } + if (nod->_cur_frm > nod->stop) { + nod->loop--; - const Graphics::Surface *frame = _animation.rlf->decodeNextFrame(); - - // Animation frames for PANORAMAs are transposed, so un-transpose them - RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); - if (state == RenderTable::PANORAMA) { - Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame); - - renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height()); - - // If the background can move, we need to cache the last frame so it can be rendered during background movement - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - if (_cachedFrameNeedsDeletion) { - _cachedFrame->free(); - delete _cachedFrame; - _cachedFrameNeedsDeletion = false; - } - _cachedFrame = tranposedFrame; - _cachedFrameNeedsDeletion = true; - } else { - // Cleanup - tranposedFrame->free(); - delete tranposedFrame; + if (nod->loop == 0) { + if (nod->slot >= 0) + _engine->getScriptManager()->setStateValue(nod->slot, 2); + _playList.erase(it); + return _DisposeAfterUse; } - } else { - renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, _animation.rlf->width(), subRect.width(), subRect.height()); - - // If the background can move, we need to cache the last frame so it can be rendered during background movement - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - if (_cachedFrameNeedsDeletion) { - _cachedFrame->free(); - delete _cachedFrame; - _cachedFrameNeedsDeletion = false; - } - _cachedFrame->copyFrom(*frame); - } - } - // Check if we should continue looping - if (_animation.rlf->endOfAnimation()) { - _animation.rlf->seekToFrame(-1); - if (_loopCount > 0) { - _currentLoop++; - if (_currentLoop >= _loopCount) { - finished = true; - } + nod->_cur_frm = nod->start; + if (_fileType == RLF) { + _animation.rlf->seekToFrame(nod->_cur_frm); + frame = _animation.rlf->decodeNextFrame(); + } else if (_fileType == AVI) { + _animation.avi->seekToFrame(nod->_cur_frm); + frame = _animation.avi->decodeNextFrame(); } + } else { + if (_fileType == RLF) + frame = _animation.rlf->decodeNextFrame(); + else if (_fileType == AVI) + frame = _animation.avi->decodeNextFrame(); } } - } else { - // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement - RenderManager *renderManager = _engine->getRenderManager(); - RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); - - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y)); - Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h); - - // If the clip returns false, it means the animation is outside the working window - if (!renderManager->clipRectToWorkingWindow(subRect)) { - return false; - } - - renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height()); - } - } - } else if (_fileType == AVI) { - if (!_animation.avi->isPlaying()) { - _animation.avi->start(); - } - - if (_animation.avi->needsUpdate()) { - const Graphics::Surface *frame = _animation.avi->decodeNextFrame(); if (frame) { - // Make sure the frame is inside the working window - // If it's not, then just return - - RenderManager *renderManager = _engine->getRenderManager(); - Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y)); - Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + frame->w, workingWindowPoint.y + frame->h); - - // If the clip returns false, it means the animation is outside the working window - if (!renderManager->clipRectToWorkingWindow(subRect)) { - return false; - } - - // Animation frames for PANORAMAs are transposed, so un-transpose them - RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); - if (state == RenderTable::PANORAMA) { - Graphics::Surface *tranposedFrame = RenderManager::tranposeSurface(frame); - - renderManager->copyRectToWorkingWindow((uint16 *)tranposedFrame->getBasePtr(tranposedFrame->w - subRect.width(), tranposedFrame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height()); - - // If the background can move, we need to cache the last frame so it can be rendered during background movement - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - if (_cachedFrameNeedsDeletion) { - _cachedFrame->free(); - delete _cachedFrame; - _cachedFrameNeedsDeletion = false; - } - _cachedFrame = tranposedFrame; - _cachedFrameNeedsDeletion = true; - } else { - // Cleanup - tranposedFrame->free(); - delete tranposedFrame; - } + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); + if (_mask > 0) + _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top); + delete transposed; } else { - renderManager->copyRectToWorkingWindow((const uint16 *)frame->getBasePtr(frame->w - subRect.width(), frame->h - subRect.height()), subRect.left, subRect.top, frame->w, subRect.width(), subRect.height()); - - // If the background can move, we need to cache the last frame so it can be rendered during background movement - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - if (_cachedFrameNeedsDeletion) { - _cachedFrame->free(); - delete _cachedFrame; - _cachedFrameNeedsDeletion = false; - } - _cachedFrame->copyFrom(*frame); - } + if (_mask > 0) + _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top); } - } else { - // If the background can move, we have to keep rendering animation frames, otherwise the animation flickers during background movement - RenderManager *renderManager = _engine->getRenderManager(); - RenderTable::RenderState state = renderManager->getRenderTable()->getRenderState(); + } + } + } - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - Common::Point workingWindowPoint = renderManager->imageSpaceToWorkingWindowSpace(Common::Point(_x, _y)); - Common::Rect subRect(workingWindowPoint.x, workingWindowPoint.y, workingWindowPoint.x + _cachedFrame->w, workingWindowPoint.y + _cachedFrame->h); + return false; +} - // If the clip returns false, it means the animation is outside the working window - if (!renderManager->clipRectToWorkingWindow(subRect)) { - return false; - } - renderManager->copyRectToWorkingWindow((uint16 *)_cachedFrame->getBasePtr(_cachedFrame->w - subRect.width(), _cachedFrame->h - subRect.height()), subRect.left, subRect.top, _cachedFrame->w, subRect.width(), subRect.height()); - } - } - } - // Check if we should continue looping - if (_animation.avi->endOfVideo()) { - _animation.avi->rewind(); - if (_loopCount > 0) { - _currentLoop++; - if (_currentLoop >= _loopCount) { - _animation.avi->stop(); - finished = true; - } - } - } - } +void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) { + playnode nod; + nod.loop = loops; + nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1); + nod.start = start_frame; + nod.stop = end_frame; + nod.slot = slot; + nod._cur_frm = -1; + nod._delay = 0; + _playList.push_back(nod); +} - // If we're done, set _animation key = 2 (Why 2? I don't know. It's just the value that they used) - // Then disable the control. DON'T delete it. It can be re-used - if (finished) { - _engine->getScriptManager()->setStateValue(_animationKey, 2); - _currentLoop = 0; - } +bool AnimationNode::stop() { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) + _engine->getScriptManager()->setStateValue((*it).slot, 2); + + _playList.clear(); + // We don't need to delete, it's may be reused return false; } diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h index 247fbf765d..e63824f34b 100644 --- a/engines/zvision/animation_control.h +++ b/engines/zvision/animation_control.h @@ -23,7 +23,9 @@ #ifndef ZVISION_ANIMATION_CONTROL_H #define ZVISION_ANIMATION_CONTROL_H -#include "zvision/control.h" +#include "zvision/sidefx.h" +#include "common/rect.h" +#include "common/list.h" namespace Common { @@ -43,10 +45,20 @@ namespace ZVision { class ZVision; class RlfAnimation; -class AnimationControl : public Control { +class AnimationNode : public SideFX { public: - AnimationControl(ZVision *engine, uint32 controlKey, const Common::String &fileName); - ~AnimationControl(); + AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); + ~AnimationNode(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 stop; + int32 loop; + int32 _cur_frm; + int32 _delay; + }; private: enum FileType { @@ -55,7 +67,9 @@ private: }; private: - uint32 _animationKey; + typedef Common::List PlayNodes; + + PlayNodes _playList; union { RlfAnimation *rlf; @@ -63,31 +77,16 @@ private: } _animation; FileType _fileType; - uint _loopCount; - int32 _x; - int32 _y; - - uint _accumulatedTime; - uint _currentLoop; - - Graphics::Surface *_cachedFrame; - bool _cachedFrameNeedsDeletion; + int32 _frmDelay; + int32 _mask; + bool _DisposeAfterUse; public: bool process(uint32 deltaTimeInMillis); - void setAnimationKey(uint32 animationKey) { - _animationKey = animationKey; - } - void setLoopCount(uint loopCount) { - _loopCount = loopCount; - } - void setXPos(int32 x) { - _x = x; - } - void setYPost(int32 y) { - _y = y; - } + void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1); + + bool stop(); }; } // End of namespace ZVision -- cgit v1.2.3 From 5ab767cb37da791aa0ca4a1354d405a7ac85f7e6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 15 Nov 2013 18:46:57 +0000 Subject: ZVISION: Rename animation_control files to animation_node. --- engines/zvision/actions.cpp | 2 +- engines/zvision/animation_control.cpp | 177 ---------------------------------- engines/zvision/animation_control.h | 94 ------------------ engines/zvision/animation_node.cpp | 177 ++++++++++++++++++++++++++++++++++ engines/zvision/animation_node.h | 94 ++++++++++++++++++ engines/zvision/module.mk | 2 +- 6 files changed, 273 insertions(+), 273 deletions(-) delete mode 100644 engines/zvision/animation_control.cpp delete mode 100644 engines/zvision/animation_control.h create mode 100644 engines/zvision/animation_node.cpp create mode 100644 engines/zvision/animation_node.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index f83d295dde..f540e3e34a 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -31,7 +31,7 @@ #include "zvision/zork_avi_decoder.h" #include "zvision/timer_node.h" #include "zvision/music_node.h" -#include "zvision/animation_control.h" +#include "zvision/animation_node.h" #include "common/file.h" diff --git a/engines/zvision/animation_control.cpp b/engines/zvision/animation_control.cpp deleted file mode 100644 index f825bbedfc..0000000000 --- a/engines/zvision/animation_control.cpp +++ /dev/null @@ -1,177 +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 "common/scummsys.h" - -#include "zvision/animation_control.h" - -#include "zvision/zvision.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/zork_avi_decoder.h" - -#include "video/video_decoder.h" - -#include "graphics/surface.h" - - -namespace ZVision { - -AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) - : SideFX(engine, controlKey, SIDEFX_ANIM), - _fileType(RLF), - _DisposeAfterUse(DisposeAfterUse), - _mask(mask) { - if (fileName.hasSuffix(".rlf")) { - _fileType = RLF; - _animation.rlf = new RlfAnimation(fileName, false); - _frmDelay = _animation.rlf->frameTime(); - } else if (fileName.hasSuffix(".avi")) { - _fileType = AVI; - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadFile(fileName); - _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); - } else { - warning("Unrecognized animation file type: %s", fileName.c_str()); - } - - if (frate > 0) - _frmDelay = 1000.0 / frate; -} - -AnimationNode::~AnimationNode() { - if (_fileType == RLF) { - delete _animation.rlf; - } else if (_fileType == AVI) { - delete _animation.avi; - } - - _engine->getScriptManager()->setStateValue(_key, 2); - - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) - _engine->getScriptManager()->setStateValue((*it).slot, 2); - - _playList.clear(); -} - -bool AnimationNode::process(uint32 deltaTimeInMillis) { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - playnode *nod = &(*it); - - nod->_delay -= deltaTimeInMillis; - if (nod->_delay <= 0) { - nod->_delay += _frmDelay; - - const Graphics::Surface *frame = NULL; - - if (nod->_cur_frm == -1) { // Start of new playlist node - nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } - - nod->_delay = _frmDelay; - if (nod->slot) - _engine->getScriptManager()->setStateValue(nod->slot, 1); - } else { - nod->_cur_frm++; - - if (nod->_cur_frm > nod->stop) { - nod->loop--; - - if (nod->loop == 0) { - if (nod->slot >= 0) - _engine->getScriptManager()->setStateValue(nod->slot, 2); - _playList.erase(it); - return _DisposeAfterUse; - } - - nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } - } else { - if (_fileType == RLF) - frame = _animation.rlf->decodeNextFrame(); - else if (_fileType == AVI) - frame = _animation.avi->decodeNextFrame(); - } - } - - if (frame) { - if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { - Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); - if (_mask > 0) - _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top); - delete transposed; - } else { - if (_mask > 0) - _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top); - } - } - } - } - - return false; -} - - - -void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) { - playnode nod; - nod.loop = loops; - nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1); - nod.start = start_frame; - nod.stop = end_frame; - nod.slot = slot; - nod._cur_frm = -1; - nod._delay = 0; - _playList.push_back(nod); -} - -bool AnimationNode::stop() { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) - _engine->getScriptManager()->setStateValue((*it).slot, 2); - - _playList.clear(); - - // We don't need to delete, it's may be reused - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/animation_control.h b/engines/zvision/animation_control.h deleted file mode 100644 index e63824f34b..0000000000 --- a/engines/zvision/animation_control.h +++ /dev/null @@ -1,94 +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 ZVISION_ANIMATION_CONTROL_H -#define ZVISION_ANIMATION_CONTROL_H - -#include "zvision/sidefx.h" -#include "common/rect.h" -#include "common/list.h" - - -namespace Common { -class String; -} - -namespace Video { -class VideoDecoder; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; -class RlfAnimation; - -class AnimationNode : public SideFX { -public: - AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); - ~AnimationNode(); - - struct playnode { - Common::Rect pos; - int32 slot; - int32 start; - int32 stop; - int32 loop; - int32 _cur_frm; - int32 _delay; - }; - -private: - enum FileType { - RLF = 1, - AVI = 2 - }; - -private: - typedef Common::List PlayNodes; - - PlayNodes _playList; - - union { - RlfAnimation *rlf; - Video::VideoDecoder *avi; - } _animation; - - FileType _fileType; - int32 _frmDelay; - int32 _mask; - bool _DisposeAfterUse; - -public: - bool process(uint32 deltaTimeInMillis); - - void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1); - - bool stop(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp new file mode 100644 index 0000000000..72afeabac6 --- /dev/null +++ b/engines/zvision/animation_node.cpp @@ -0,0 +1,177 @@ +/* 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 "common/scummsys.h" + +#include "zvision/animation_node.h" + +#include "zvision/zvision.h" +#include "zvision/render_manager.h" +#include "zvision/script_manager.h" +#include "zvision/rlf_animation.h" +#include "zvision/zork_avi_decoder.h" + +#include "video/video_decoder.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) + : SideFX(engine, controlKey, SIDEFX_ANIM), + _fileType(RLF), + _DisposeAfterUse(DisposeAfterUse), + _mask(mask) { + if (fileName.hasSuffix(".rlf")) { + _fileType = RLF; + _animation.rlf = new RlfAnimation(fileName, false); + _frmDelay = _animation.rlf->frameTime(); + } else if (fileName.hasSuffix(".avi")) { + _fileType = AVI; + _animation.avi = new ZorkAVIDecoder(); + _animation.avi->loadFile(fileName); + _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); + } else { + warning("Unrecognized animation file type: %s", fileName.c_str()); + } + + if (frate > 0) + _frmDelay = 1000.0 / frate; +} + +AnimationNode::~AnimationNode() { + if (_fileType == RLF) { + delete _animation.rlf; + } else if (_fileType == AVI) { + delete _animation.avi; + } + + _engine->getScriptManager()->setStateValue(_key, 2); + + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) + _engine->getScriptManager()->setStateValue((*it).slot, 2); + + _playList.clear(); +} + +bool AnimationNode::process(uint32 deltaTimeInMillis) { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + + nod->_delay -= deltaTimeInMillis; + if (nod->_delay <= 0) { + nod->_delay += _frmDelay; + + const Graphics::Surface *frame = NULL; + + if (nod->_cur_frm == -1) { // Start of new playlist node + nod->_cur_frm = nod->start; + if (_fileType == RLF) { + _animation.rlf->seekToFrame(nod->_cur_frm); + frame = _animation.rlf->decodeNextFrame(); + } else if (_fileType == AVI) { + _animation.avi->seekToFrame(nod->_cur_frm); + frame = _animation.avi->decodeNextFrame(); + } + + nod->_delay = _frmDelay; + if (nod->slot) + _engine->getScriptManager()->setStateValue(nod->slot, 1); + } else { + nod->_cur_frm++; + + if (nod->_cur_frm > nod->stop) { + nod->loop--; + + if (nod->loop == 0) { + if (nod->slot >= 0) + _engine->getScriptManager()->setStateValue(nod->slot, 2); + _playList.erase(it); + return _DisposeAfterUse; + } + + nod->_cur_frm = nod->start; + if (_fileType == RLF) { + _animation.rlf->seekToFrame(nod->_cur_frm); + frame = _animation.rlf->decodeNextFrame(); + } else if (_fileType == AVI) { + _animation.avi->seekToFrame(nod->_cur_frm); + frame = _animation.avi->decodeNextFrame(); + } + } else { + if (_fileType == RLF) + frame = _animation.rlf->decodeNextFrame(); + else if (_fileType == AVI) + frame = _animation.avi->decodeNextFrame(); + } + } + + if (frame) { + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); + if (_mask > 0) + _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top); + delete transposed; + } else { + if (_mask > 0) + _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top); + } + } + } + } + + return false; +} + + + +void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) { + playnode nod; + nod.loop = loops; + nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1); + nod.start = start_frame; + nod.stop = end_frame; + nod.slot = slot; + nod._cur_frm = -1; + nod._delay = 0; + _playList.push_back(nod); +} + +bool AnimationNode::stop() { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) + _engine->getScriptManager()->setStateValue((*it).slot, 2); + + _playList.clear(); + + // We don't need to delete, it's may be reused + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h new file mode 100644 index 0000000000..76c961ceb1 --- /dev/null +++ b/engines/zvision/animation_node.h @@ -0,0 +1,94 @@ +/* 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 ZVISION_ANIMATION_NODE_H +#define ZVISION_ANIMATION_NODE_H + +#include "zvision/sidefx.h" +#include "common/rect.h" +#include "common/list.h" + + +namespace Common { +class String; +} + +namespace Video { +class VideoDecoder; +} + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; +class RlfAnimation; + +class AnimationNode : public SideFX { +public: + AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); + ~AnimationNode(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 stop; + int32 loop; + int32 _cur_frm; + int32 _delay; + }; + +private: + enum FileType { + RLF = 1, + AVI = 2 + }; + +private: + typedef Common::List PlayNodes; + + PlayNodes _playList; + + union { + RlfAnimation *rlf; + Video::VideoDecoder *avi; + } _animation; + + FileType _fileType; + int32 _frmDelay; + int32 _mask; + bool _DisposeAfterUse; + +public: + bool process(uint32 deltaTimeInMillis); + + void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1); + + bool stop(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 8d37311462..b66f02da8e 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -2,7 +2,7 @@ MODULE := engines/zvision MODULE_OBJS := \ actions.o \ - animation_control.o \ + animation_node.o \ clock.o \ console.o \ control.o \ -- cgit v1.2.3 From ff541a0d021796d0c42d627dc4dcfe91c1335487 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 20 Nov 2013 11:44:43 +0000 Subject: ZVISION: Impliment inventory functions and ActionInventory. --- engines/zvision/actions.cpp | 49 ++++++++++++++ engines/zvision/actions.h | 9 +++ engines/zvision/inventory_manager.cpp | 123 ++++++++++++++++++++++++++++++++++ engines/zvision/inventory_manager.h | 28 -------- engines/zvision/module.mk | 3 +- engines/zvision/scr_file_handling.cpp | 2 +- engines/zvision/script_manager.h | 14 +++- 7 files changed, 196 insertions(+), 32 deletions(-) create mode 100644 engines/zvision/inventory_manager.cpp delete mode 100644 engines/zvision/inventory_manager.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index f540e3e34a..5568e39bdb 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -156,6 +156,55 @@ bool ActionEnableControl::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionInventory +////////////////////////////////////////////////////////////////////////////// + +ActionInventory::ActionInventory(ZVision *engine, const Common::String &line) : + ResultAction(engine) { + char buf[25]; + sscanf(line.c_str(), "%*[^(](%25s %d)", buf, &_key); + + if (strcmp(buf, "add") == 0) { + _type = 0; + } else if (strcmp(buf, "addi") == 0) { + _type = 1; + } else if (strcmp(buf, "drop") == 0) { + _type = 2; + } else if (strcmp(buf, "dropi") == 0) { + _type = 3; + } else if (strcmp(buf, "cycle") == 0) { + _type = 4; + } + +} + +bool ActionInventory::execute() { + switch (_type) { + case 0: // add + _engine->getScriptManager()->invertory_add(_key); + break; + case 1: // addi + _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(_key)); + break; + case 2: // drop + if (_key >= 0) + _engine->getScriptManager()->invertory_drop(_key); + else + _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem)); + break; + case 3: // dropi + _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(_key)); + break; + case 4: // cycle + _engine->getScriptManager()->invertory_cycle(); + break; + default: + break; + } + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionKill diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index b75c201d99..50224aaaf5 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -212,6 +212,15 @@ private: uint32 _key; }; +class ActionInventory : public ResultAction { +public: + ActionInventory(ZVision *engine, const Common::String &line); + bool execute(); +private: + uint8 _type; + int32 _key; +}; + class ActionKill : public ResultAction { public: ActionKill(ZVision *engine, const Common::String &line); diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp new file mode 100644 index 0000000000..3924c6b51a --- /dev/null +++ b/engines/zvision/inventory_manager.cpp @@ -0,0 +1,123 @@ +/* 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 "common/scummsys.h" + +#include "zvision/script_manager.h" + + +namespace ZVision { + +int8 ScriptManager::invertory_getCount() { + return getStateValue(StateKey_Inv_Cnt_Slot); +} + +void ScriptManager::invertory_setCount(int8 cnt) { + setStateValue(StateKey_Inv_Cnt_Slot, cnt); +} + +int16 ScriptManager::invertory_getItem(int8 id) { + if (id < 49 && id >= 0) + return getStateValue(StateKey_Inv_1_Slot + id); + return -1; +} + +void ScriptManager::invertory_setItem(int8 id, int16 item) { + if (id < 49 && id >= 0) + setStateValue(StateKey_Inv_1_Slot + id, item); +} + +void ScriptManager::invertory_add(int16 item) { + int8 cnt = invertory_getCount(); + + if (cnt < 49) { + bool not_exist = true; + + if (cnt == 0) { + invertory_setItem(0, 0); + invertory_setCount(1); // we needed empty item for cycle code + cnt = 1; + } + + for (int8 cur = 0; cur < cnt; cur++) + if (invertory_getItem(cur) == item) { + not_exist = false; + break; + } + + if (not_exist) { + for (int8 i = cnt; i > 0; i--) + invertory_setItem(i, invertory_getItem(i - 1)); + + invertory_setItem(0, item); + + setStateValue(StateKey_InventoryItem, item); + + invertory_setCount(cnt + 1); + } + } +} + +void ScriptManager::invertory_drop(int16 item) { + int8 items_cnt = invertory_getCount(); + + // if items in inventory > 0 + if (items_cnt != 0) { + int8 index = 0; + + // finding needed item + while (index < items_cnt) { + if (invertory_getItem(index) == item) + break; + + index++; + } + + // if item in the inventory + if (items_cnt != index) { + // shift all items left with rewrite founded item + for (int8 v = index; v < items_cnt - 1 ; v++) + invertory_setItem(v, invertory_getItem(v + 1)); + + // del last item + invertory_setItem(items_cnt - 1, 0); + invertory_setCount(invertory_getCount() - 1); + + setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + } + } +} +void ScriptManager::invertory_cycle() { + int8 item_cnt = invertory_getCount(); + int8 cur_item = invertory_getItem(0); + if (item_cnt > 1) { + for (int8 i = 0; i < item_cnt - 1; i++) + invertory_setItem(i, invertory_getItem(i + 1)); + + invertory_setItem(item_cnt - 1, cur_item); + + setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/inventory_manager.h b/engines/zvision/inventory_manager.h deleted file mode 100644 index ae6d116b18..0000000000 --- a/engines/zvision/inventory_manager.h +++ /dev/null @@ -1,28 +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 ZVISION_INVENTORY_MANAGER_H -#define ZVISION_INVENTORY_MANAGER_H - -// TODO: Implement InventoryManager - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index b66f02da8e..ffdef16335 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -31,7 +31,8 @@ MODULE_OBJS := \ zork_avi_decoder.o \ zork_raw.o \ sidefx.o \ - music_node.o + music_node.o \ + inventory_manager.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 0df3143a51..769c94921b 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -197,7 +197,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:flush_mouse_events*", true)) { // TODO: Implement ActionFlushMouseEvents } else if (line.matchString("*:inventory*", true)) { - // TODO: Implement ActionInventory + actionList.push_back(new ActionInventory(_engine, line)); } else if (line.matchString("*:kill*", true)) { actionList.push_back(new ActionKill(_engine, line)); } else if (line.matchString("*:menu_bar_enable*", true)) { diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 38d398248e..2f585b6291 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -90,7 +90,7 @@ enum StateKey { StateKey_EF9_G = 92, StateKey_EF9_R = 93, StateKey_EF9_Speed = 94, - StateKey_Inv_0_Slot = 100, + StateKey_Inv_Cnt_Slot = 100, StateKey_Inv_1_Slot = 101, StateKey_Inv_49_Slot = 149, StateKey_Inv_TotalSlots = 150 @@ -248,8 +248,18 @@ private: /** Perform change location */ void do_changeLocation(); -// TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it + int8 invertory_getCount(); + void invertory_setCount(int8 cnt); + int16 invertory_getItem(int8 id); + void invertory_setItem(int8 id, int16 item); + + public: + void invertory_add(int16 item); + void invertory_drop(int16 item); + void invertory_cycle(); + + // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it /** * Parses a script file into triggers and events * -- cgit v1.2.3 From f877410feef2e0030dd6c0664d615cc86118ca29 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 20 Nov 2013 11:45:52 +0000 Subject: ZVISION: Add new ChangeCursor method for load items icons. --- engines/zvision/cursor_manager.cpp | 17 +++++++++++++++++ engines/zvision/cursor_manager.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index 385e4dcc9c..de229a38d8 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -116,6 +116,23 @@ void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) warning("No cursor found for identifier %s", cursorName.c_str()); } +void CursorManager::changeCursor(int id, bool active, bool pushed) { + Common::String file; + if (_engine->getGameId() == GID_NEMESIS) { + file = Common::String::format("%2.2d%s%c.zcr", id, active ? "act" : "idle", pushed ? 'b' : 'a'); + } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { + file = Common::String::format("g0b%cc%2.2x1.zcr", active ? (pushed ? 'd' : 'c') : (pushed ? 'b' : 'a') , id); + } else + return; + + if (_currentCursor.equals(file)) + return; + + _currentCursor = file; + + changeCursor(ZorkCursor(file)); +} + void CursorManager::changeCursor(const ZorkCursor &cursor) { CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat); } diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h index 0173bf810c..ac79b259fa 100644 --- a/engines/zvision/cursor_manager.h +++ b/engines/zvision/cursor_manager.h @@ -81,6 +81,8 @@ public: * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) */ void changeCursor(const Common::String &cursorName, bool pushed); + + void changeCursor(int id, bool active, bool pushed); /** * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen. * -- cgit v1.2.3 From 4cb006f2602199a3f201f918392f3e66a385df0e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 24 Nov 2013 14:48:45 +0000 Subject: ZVISION: Animation nodes now scaleable. --- engines/zvision/actions.cpp | 4 ++-- engines/zvision/actions.h | 4 ++-- engines/zvision/animation_node.cpp | 45 ++++++++++++++++++++++++++++++++++---- engines/zvision/animation_node.h | 3 ++- engines/zvision/render_manager.cpp | 27 +++++++++++++++++++++++ engines/zvision/render_manager.h | 2 ++ 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 5568e39bdb..2fbec2945a 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -361,7 +361,7 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String & // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)", - &_key, fileName, &_x, &_y, &_width, &_height, &_start, &_end, &_loopCount, &_mask, &_framerate); + &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -386,7 +386,7 @@ bool ActionPlayAnimation::execute() { nod->stop(); if (nod) - nod->addPlayNode(_key, _x, _y, _width, _height, _start, _end, _loopCount); + nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 50224aaaf5..d9871328cb 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -257,8 +257,8 @@ private: Common::String _fileName; uint32 _x; uint32 _y; - uint32 _width; - uint32 _height; + uint32 _x2; + uint32 _y2; uint32 _start; uint32 _end; int32 _mask; diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 72afeabac6..73e419ee19 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -69,9 +69,13 @@ AnimationNode::~AnimationNode() { _engine->getScriptManager()->setStateValue(_key, 2); PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) + if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) + delete(*it)._scaled; + } + _playList.clear(); } @@ -108,6 +112,8 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->loop == 0) { if (nod->slot >= 0) _engine->getScriptManager()->setStateValue(nod->slot, 2); + if (nod->_scaled) + delete nod->_scaled; _playList.erase(it); return _DisposeAfterUse; } @@ -129,6 +135,33 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { } if (frame) { + + uint32 dstw; + uint32 dsth; + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + dstw = nod->pos.height(); + dsth = nod->pos.width(); + } else { + dstw = nod->pos.width(); + dsth = nod->pos.height(); + } + + if (frame->w != dstw || frame->h != dsth) { + if (nod->_scaled) + if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { + delete nod->_scaled; + nod->_scaled = NULL; + } + + if (!nod->_scaled) { + nod->_scaled = new Graphics::Surface; + nod->_scaled->create(dstw, dsth, frame->format); + } + + _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); + frame = nod->_scaled; + } + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); if (_mask > 0) @@ -151,22 +184,26 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { -void AnimationNode::addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops) { +void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) { playnode nod; nod.loop = loops; - nod.pos = Common::Rect(x, y, x + w - 1, y + h - 1); + nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = start_frame; nod.stop = end_frame; nod.slot = slot; nod._cur_frm = -1; nod._delay = 0; + nod._scaled = NULL; _playList.push_back(nod); } bool AnimationNode::stop() { PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) + if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) + delete(*it)._scaled; + } _playList.clear(); diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h index 76c961ceb1..843e59236b 100644 --- a/engines/zvision/animation_node.h +++ b/engines/zvision/animation_node.h @@ -58,6 +58,7 @@ public: int32 loop; int32 _cur_frm; int32 _delay; + Graphics::Surface *_scaled; }; private: @@ -84,7 +85,7 @@ private: public: bool process(uint32 deltaTimeInMillis); - void addPlayNode(int32 slot, int x, int y, int w, int h, int start_frame, int end_frame, int loops = 1); + void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); bool stop(); }; diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 58df5a8d11..fc15e18fd0 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -694,4 +694,31 @@ Graphics::Surface *RenderManager::tranposeSurface(const Graphics::Surface *surfa return tranposedSurface; } +void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight) { + assert(bytesPerPixel == 1 || bytesPerPixel == 2); + + const float xscale = (float)srcWidth / (float)dstWidth; + const float yscale = (float)srcHeight / (float)dstHeight; + + if (bytesPerPixel == 1) { + const byte *srcPtr = (const byte *)src; + byte *dstPtr = (byte *)dst; + for (uint32 y = 0; y < dstHeight; ++y) { + for (uint32 x = 0; x < dstWidth; ++x) { + *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth]; + dstPtr++; + } + } + } else if (bytesPerPixel == 2) { + const uint16 *srcPtr = (const uint16 *)src; + uint16 *dstPtr = (uint16 *)dst; + for (uint32 y = 0; y < dstHeight; ++y) { + for (uint32 x = 0; x < dstWidth; ++x) { + *dstPtr = srcPtr[(int)(x * xscale) + (int)(y * yscale) * srcWidth]; + dstPtr++; + } + } + } +} + } // End of namespace ZVision diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index c302844117..14ca704ce1 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -367,6 +367,8 @@ public: */ static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface); + void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight); + private: /** * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect -- cgit v1.2.3 From 1dbb6e807a3b70fc1cdcf7ff1a4949fc69913a05 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 25 Nov 2013 13:30:29 +0000 Subject: ZVISION: Refactor parsing actions, it must handle presence/miss of slot key in same actions. --- engines/zvision/actions.cpp | 148 ++++++++++++------------ engines/zvision/actions.h | 55 ++++----- engines/zvision/scr_file_handling.cpp | 209 ++++++++++++++++++++-------------- 3 files changed, 228 insertions(+), 184 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 2fbec2945a..9670016d74 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -44,9 +44,9 @@ namespace ZVision { // ActionAdd ////////////////////////////////////////////////////////////////////////////// -ActionAdd::ActionAdd(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u,%d)", &_key, &_value); +ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u,%d", &_key, &_value); } bool ActionAdd::execute() { @@ -59,11 +59,11 @@ bool ActionAdd::execute() { // ActionAssign ////////////////////////////////////////////////////////////////////////////// -ActionAssign::ActionAssign(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char buf[64]; memset(buf, 0, 64); - sscanf(line.c_str(), "%*[^(](%u, %s)", &_key, buf); + sscanf(line.c_str(), "%u, %s", &_key, buf); _value = new ValueSlot(_engine->getScriptManager(), buf); } @@ -82,9 +82,9 @@ bool ActionAssign::execute() { // ActionAttenuate ////////////////////////////////////////////////////////////////////////////// -ActionAttenuate::ActionAttenuate(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u, %d)", &_key, &_attenuation); +ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u, %d", &_key, &_attenuation); } bool ActionAttenuate::execute() { @@ -97,9 +97,9 @@ bool ActionAttenuate::execute() { // ActionChangeLocation ////////////////////////////////////////////////////////////////////////////// -ActionChangeLocation::ActionChangeLocation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%c, %c, %c%c, %u)", &_world, &_room, &_node, &_view, &_offset); +ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset); } bool ActionChangeLocation::execute() { @@ -114,10 +114,10 @@ bool ActionChangeLocation::execute() { // ActionCrossfade ////////////////////////////////////////////////////////////////////////////// -ActionCrossfade::ActionCrossfade(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { sscanf(line.c_str(), - "%*[^(](%u %u %u %u %u %u %u)", + "%u %u %u %u %u %u %u", &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); } @@ -131,9 +131,9 @@ bool ActionCrossfade::execute() { // ActionDisableControl ////////////////////////////////////////////////////////////////////////////// -ActionDisableControl::ActionDisableControl(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u)", &_key); +ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u", &_key); } bool ActionDisableControl::execute() { @@ -146,9 +146,9 @@ bool ActionDisableControl::execute() { // ActionEnableControl ////////////////////////////////////////////////////////////////////////////// -ActionEnableControl::ActionEnableControl(ZVision *engine, const Common::String &line) : - ResultAction(engine) { - sscanf(line.c_str(), "%*[^(](%u)", &_key); +ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u", &_key); } bool ActionEnableControl::execute() { @@ -160,10 +160,10 @@ bool ActionEnableControl::execute() { // ActionInventory ////////////////////////////////////////////////////////////////////////////// -ActionInventory::ActionInventory(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char buf[25]; - sscanf(line.c_str(), "%*[^(](%25s %d)", buf, &_key); + sscanf(line.c_str(), "%25s %d", buf, &_key); if (strcmp(buf, "add") == 0) { _type = 0; @@ -210,12 +210,12 @@ bool ActionInventory::execute() { // ActionKill ////////////////////////////////////////////////////////////////////////////// -ActionKill::ActionKill(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { _key = 0; _type = 0; char keytype[25]; - sscanf(line.c_str(), "%*[^(](%25s)", keytype); + sscanf(line.c_str(), "%25s", keytype); if (keytype[0] == '"') { if (!scumm_stricmp(keytype, "\"ANIM\"")) _type = SideFX::SIDEFX_ANIM; @@ -250,8 +250,8 @@ bool ActionKill::execute() { // ActionMusic ////////////////////////////////////////////////////////////////////////////// -ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool global) : - ResultAction(engine), +ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) : + ResultAction(engine, slotkey), _volume(255), _universe(global) { uint type; @@ -259,7 +259,7 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa uint loop; uint volume = 255; - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%u %25s %u %u)", &_key, &type, fileNameBuffer, &loop, &volume); + sscanf(line.c_str(), "%u %25s %u %u", &type, fileNameBuffer, &loop, &volume); // type 4 are midi sound effect files if (type == 4) { @@ -282,11 +282,11 @@ ActionMusic::ActionMusic(ZVision *engine, const Common::String &line, bool globa ActionMusic::~ActionMusic() { if (!_universe) - _engine->getScriptManager()->killSideFx(_key); + _engine->getScriptManager()->killSideFx(_slotkey); } bool ActionMusic::execute() { - if (_engine->getScriptManager()->getSideFX(_key)) + if (_engine->getScriptManager()->getSideFX(_slotkey)) return true; Common::File *file = new Common::File(); if (!file->exists(_fileName) && _fileName.size() >= 12) { @@ -307,7 +307,7 @@ bool ActionMusic::execute() { } } if (file->exists(_fileName)) - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _key, _fileName, _loop, _volume)); + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); delete file; return true; @@ -318,12 +318,12 @@ bool ActionMusic::execute() { // ActionPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%25s %*u %*u %d %d)", &_key, fileName, &_mask, &_framerate); + sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -335,14 +335,14 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, const Common::St } ActionPreloadAnimation::~ActionPreloadAnimation() { - _engine->getScriptManager()->deleteSideFx(_key); + _engine->getScriptManager()->deleteSideFx(_slotkey); } bool ActionPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); if (!nod) { - nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate, false); + nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); @@ -354,14 +354,14 @@ bool ActionPreloadAnimation::execute() { // ActionPlayAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%25s %u %u %u %u %u %u %d %*u %*u %d %d)", - &_key, fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); + "%25s %u %u %u %u %u %u %d %*u %*u %d %d", + fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -373,20 +373,20 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, const Common::String & } ActionPlayAnimation::~ActionPlayAnimation() { - _engine->getScriptManager()->deleteSideFx(_key); + _engine->getScriptManager()->deleteSideFx(_slotkey); } bool ActionPlayAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); if (!nod) { - nod = new AnimationNode(_engine, _key, _fileName, _mask, _framerate); + nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); if (nod) - nod->addPlayNode(_key, _x, _y, _x2, _y2, _start, _end, _loopCount); + nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount); return true; } @@ -396,18 +396,18 @@ bool ActionPlayAnimation::execute() { // ActionPlayPreloadAnimation ////////////////////////////////////////////////////////////////////////////// -ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { sscanf(line.c_str(), - "%*[^:]:%*[^:]:%u(%u %u %u %u %u %u %u %u)", - &_animationKey, &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); + "%u %u %u %u %u %u %u %u", + &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); } bool ActionPlayPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_animationKey); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey); if (nod) - nod->addPlayNode(_controlKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); + nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); return true; } @@ -428,11 +428,11 @@ bool ActionQuit::execute() { // ActionRandom ////////////////////////////////////////////////////////////////////////////// -ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char max_buf[64]; memset(max_buf, 0, 64); - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf); + sscanf(line.c_str(), "%s", max_buf); _max = new ValueSlot(_engine->getScriptManager(), max_buf); } @@ -443,7 +443,7 @@ ActionRandom::~ActionRandom() { bool ActionRandom::execute() { uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); - _engine->getScriptManager()->setStateValue(_key, randNumber); + _engine->getScriptManager()->setStateValue(_slotkey, randNumber); return true; } @@ -452,12 +452,12 @@ bool ActionRandom::execute() { // ActionSetPartialScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; int color; - sscanf(line.c_str(), "%*[^(](%u %u %25s %*u %d)", &_x, &_y, fileName, &color); + sscanf(line.c_str(), "%u %u %25s %*u %d", &_x, &_y, fileName, &color); _fileName = Common::String(fileName); @@ -489,10 +489,10 @@ bool ActionSetPartialScreen::execute() { // ActionSetScreen ////////////////////////////////////////////////////////////////////////////// -ActionSetScreen::ActionSetScreen(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; - sscanf(line.c_str(), "%*[^(](%25[^)])", fileName); + sscanf(line.c_str(), "%25s", fileName); _fileName = Common::String(fileName); } @@ -507,10 +507,10 @@ bool ActionSetScreen::execute() { // ActionStop ////////////////////////////////////////////////////////////////////////////// -ActionStop::ActionStop(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionStop::ActionStop(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { _key = 0; - sscanf(line.c_str(), "%*[^(](%u)", &_key); + sscanf(line.c_str(), "%u", &_key); } bool ActionStop::execute() { @@ -523,12 +523,12 @@ bool ActionStop::execute() { // ActionStreamVideo ////////////////////////////////////////////////////////////////////////////// -ActionStreamVideo::ActionStreamVideo(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char fileName[25]; uint skipline; //skipline - render video with skip every second line, not skippable. - sscanf(line.c_str(), "%*[^(](%25s %u %u %u %u %u %u)", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); + sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); _fileName = Common::String(fileName); _skippable = true; @@ -554,22 +554,22 @@ bool ActionStreamVideo::execute() { // ActionTimer ////////////////////////////////////////////////////////////////////////////// -ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : - ResultAction(engine) { +ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { char time_buf[64]; memset(time_buf, 0, 64); - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, time_buf); + sscanf(line.c_str(), "%s", time_buf); _time = new ValueSlot(_engine->getScriptManager(), time_buf); } ActionTimer::~ActionTimer() { if (_time) delete _time; - _engine->getScriptManager()->killSideFx(_key); + _engine->getScriptManager()->killSideFx(_slotkey); } bool ActionTimer::execute() { - _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _key, _time->getValue())); + _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue())); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index d9871328cb..aadb97fc9b 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -40,7 +40,7 @@ class ValueSlot; */ class ResultAction { public: - ResultAction(ZVision *engine) : _engine(engine) {} + ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {} virtual ~ResultAction() {} /** * This is called by the script system whenever a Puzzle's criteria are found to be true. @@ -53,6 +53,7 @@ public: virtual bool execute() = 0; protected: ZVision *_engine; + int32 _slotkey; }; @@ -89,7 +90,7 @@ protected: class ActionAdd : public ResultAction { public: - ActionAdd(ZVision *engine, const Common::String &line); + ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -99,7 +100,7 @@ private: class ActionAssign : public ResultAction { public: - ActionAssign(ZVision *engine, const Common::String &line); + ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionAssign(); bool execute(); @@ -110,7 +111,7 @@ private: class ActionAttenuate : public ResultAction { public: - ActionAttenuate(ZVision *engine, const Common::String &line); + ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -120,7 +121,7 @@ private: class ActionChangeLocation : public ResultAction { public: - ActionChangeLocation(ZVision *engine, const Common::String &line); + ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -133,7 +134,7 @@ private: class ActionCrossfade : public ResultAction { public: - ActionCrossfade(ZVision *engine, const Common::String &line); + ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -148,7 +149,7 @@ private: class ActionDebug : public ResultAction { public: - ActionDebug(ZVision *engine, const Common::String &line); + ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -156,7 +157,7 @@ private: class ActionDelayRender : public ResultAction { public: - ActionDelayRender(ZVision *engine, const Common::String &line); + ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -166,7 +167,7 @@ private: class ActionDisableControl : public ResultAction { public: - ActionDisableControl(ZVision *engine, const Common::String &line); + ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -175,7 +176,7 @@ private: class ActionDisableVenus : public ResultAction { public: - ActionDisableVenus(ZVision *engine, const Common::String &line); + ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -183,7 +184,7 @@ private: class ActionDisplayMessage : public ResultAction { public: - ActionDisplayMessage(ZVision *engine, const Common::String &line); + ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -197,7 +198,7 @@ public: class ActionDistort : public ResultAction { public: - ActionDistort(ZVision *engine, const Common::String &line); + ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -205,7 +206,7 @@ private: class ActionEnableControl : public ResultAction { public: - ActionEnableControl(ZVision *engine, const Common::String &line); + ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -214,7 +215,7 @@ private: class ActionInventory : public ResultAction { public: - ActionInventory(ZVision *engine, const Common::String &line); + ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: uint8 _type; @@ -223,7 +224,7 @@ private: class ActionKill : public ResultAction { public: - ActionKill(ZVision *engine, const Common::String &line); + ActionKill(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -233,7 +234,7 @@ private: class ActionMusic : public ResultAction { public: - ActionMusic(ZVision *engine, const Common::String &line, bool global); + ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global); ~ActionMusic(); bool execute(); @@ -248,7 +249,7 @@ private: class ActionPlayAnimation : public ResultAction { public: - ActionPlayAnimation(ZVision *engine, const Common::String &line); + ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionPlayAnimation(); bool execute(); @@ -268,7 +269,7 @@ private: class ActionPlayPreloadAnimation : public ResultAction { public: - ActionPlayPreloadAnimation(ZVision *engine, const Common::String &line); + ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -285,7 +286,7 @@ private: class ActionPreloadAnimation : public ResultAction { public: - ActionPreloadAnimation(ZVision *engine, const Common::String &line); + ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionPreloadAnimation(); bool execute(); @@ -298,20 +299,20 @@ private: class ActionQuit : public ResultAction { public: - ActionQuit(ZVision *engine) : ResultAction(engine) {} + ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {} bool execute(); }; // TODO: See if this exists in ZGI. It doesn't in ZNem class ActionUnloadAnimation : public ResultAction { public: - ActionUnloadAnimation(ZVision *engine, const Common::String &line); + ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); }; class ActionRandom : public ResultAction { public: - ActionRandom(ZVision *engine, const Common::String &line); + ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionRandom(); bool execute(); @@ -322,7 +323,7 @@ private: class ActionSetPartialScreen : public ResultAction { public: - ActionSetPartialScreen(ZVision *engine, const Common::String &line); + ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -334,7 +335,7 @@ private: class ActionSetScreen : public ResultAction { public: - ActionSetScreen(ZVision *engine, const Common::String &line); + ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -343,7 +344,7 @@ private: class ActionStop : public ResultAction { public: - ActionStop(ZVision *engine, const Common::String &line); + ActionStop(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -352,7 +353,7 @@ private: class ActionStreamVideo : public ResultAction { public: - ActionStreamVideo(ZVision *engine, const Common::String &line); + ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: @@ -371,7 +372,7 @@ private: class ActionTimer : public ResultAction { public: - ActionTimer(ZVision *engine, const Common::String &line); + ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line); ~ActionTimer(); bool execute(); private: diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 769c94921b..0149347c4e 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -161,89 +161,132 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis continue; } - // Parse for the action type - if (line.matchString("*:add*", true)) { - actionList.push_back(new ActionAdd(_engine, line)); - } else if (line.matchString("*:animplay*", true)) { - actionList.push_back(new ActionPlayAnimation(_engine, line)); - } else if (line.matchString("*:animpreload*", true)) { - actionList.push_back(new ActionPreloadAnimation(_engine, line)); - } else if (line.matchString("*:animunload*", true)) { - //actionList.push_back(new ActionUnloadAnimation(_engine, line)); - } else if (line.matchString("*:attenuate*", true)) { - // TODO: Implement ActionAttenuate - } else if (line.matchString("*:assign*", true)) { - actionList.push_back(new ActionAssign(_engine, line)); - } else if (line.matchString("*:change_location*", true)) { - actionList.push_back(new ActionChangeLocation(_engine, line)); - } else if (line.matchString("*:crossfade*", true)) { - // TODO: Implement ActionCrossfade - } else if (line.matchString("*:debug*", true)) { - // TODO: Implement ActionDebug - } else if (line.matchString("*:delay_render*", true)) { - // TODO: Implement ActionDelayRender - } else if (line.matchString("*:disable_control*", true)) { - actionList.push_back(new ActionDisableControl(_engine, line)); - } else if (line.matchString("*:disable_venus*", true)) { - // TODO: Implement ActionDisableVenus - } else if (line.matchString("*:display_message*", true)) { - // TODO: Implement ActionDisplayMessage - } else if (line.matchString("*:dissolve*", true)) { - // TODO: Implement ActionDissolve - } else if (line.matchString("*:distort*", true)) { - // TODO: Implement ActionDistort - } else if (line.matchString("*:enable_control*", true)) { - actionList.push_back(new ActionEnableControl(_engine, line)); - } else if (line.matchString("*:flush_mouse_events*", true)) { - // TODO: Implement ActionFlushMouseEvents - } else if (line.matchString("*:inventory*", true)) { - actionList.push_back(new ActionInventory(_engine, line)); - } else if (line.matchString("*:kill*", true)) { - actionList.push_back(new ActionKill(_engine, line)); - } else if (line.matchString("*:menu_bar_enable*", true)) { - // TODO: Implement ActionMenuBarEnable - } else if (line.matchString("*:music*", true)) { - actionList.push_back(new ActionMusic(_engine, line, false)); - } else if (line.matchString("*:pan_track*", true)) { - // TODO: Implement ActionPanTrack - } else if (line.matchString("*:playpreload*", true)) { - actionList.push_back(new ActionPlayPreloadAnimation(_engine, line)); - } else if (line.matchString("*:preferences*", true)) { - // TODO: Implement ActionPreferences - } else if (line.matchString("*:quit*", true)) { - actionList.push_back(new ActionQuit(_engine)); - } else if (line.matchString("*:random*", true)) { - actionList.push_back(new ActionRandom(_engine, line)); - } else if (line.matchString("*:region*", true)) { - // TODO: Implement ActionRegion - } else if (line.matchString("*:restore_game*", true)) { - // TODO: Implement ActionRestoreGame - } else if (line.matchString("*:rotate_to*", true)) { - // TODO: Implement ActionRotateTo - } else if (line.matchString("*:save_game*", true)) { - // TODO: Implement ActionSaveGame - } else if (line.matchString("*:set_partial_screen*", true)) { - actionList.push_back(new ActionSetPartialScreen(_engine, line)); - } else if (line.matchString("*:set_screen*", true)) { - actionList.push_back(new ActionSetScreen(_engine, line)); - } else if (line.matchString("*:set_venus*", true)) { - // TODO: Implement ActionSetVenus - } else if (line.matchString("*:stop*", true)) { - actionList.push_back(new ActionStop(_engine, line)); - } else if (line.matchString("*:streamvideo*", true)) { - actionList.push_back(new ActionStreamVideo(_engine, line)); - } else if (line.matchString("*:syncsound*", true)) { - // TODO: Implement ActionSyncSound - } else if (line.matchString("*:timer*", true)) { - actionList.push_back(new ActionTimer(_engine, line)); - } else if (line.matchString("*:ttytext*", true)) { - // TODO: Implement ActionTTYText - } else if (line.matchString("*:universe_music*", true)) { - actionList.push_back(new ActionMusic(_engine, line, true)); - } else if (line.matchString("*:copy_file*", true)) { - // Not used. Purposely left empty - } else { - warning("Unhandled result action type: %s", line.c_str()); + const char *chrs = line.c_str(); + uint pos; + for (pos = 0; pos < line.size(); pos++) + if (chrs[pos] == ':') + break; + + if (pos < line.size()) { + + uint startpos = pos + 1; + + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == ':' || chrs[pos] == '(') + break; + + if (pos < line.size()) { + int32 slot = 11; + Common::String args = ""; + Common::String act(chrs + startpos, chrs + pos); + + startpos = pos + 1; + + if (chrs[pos] == ':') { + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == '(') + break; + Common::String s_slot(chrs + startpos, chrs + pos); + slot = atoi(s_slot.c_str()); + + startpos = pos + 1; + } + + if (pos < line.size()) { + for (pos = startpos; pos < line.size(); pos++) + if (chrs[pos] == ')') + break; + + args = Common::String(chrs + startpos, chrs + pos); + } + + + + // Parse for the action type + if (act.matchString("add", true)) { + actionList.push_back(new ActionAdd(_engine, slot, args)); + } else if (act.matchString("animplay", true)) { + actionList.push_back(new ActionPlayAnimation(_engine, slot, args)); + } else if (act.matchString("animpreload", true)) { + actionList.push_back(new ActionPreloadAnimation(_engine, slot, args)); + } else if (act.matchString("animunload", true)) { + //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); + } else if (act.matchString("attenuate", true)) { + // TODO: Implement ActionAttenuate + } else if (act.matchString("assign", true)) { + actionList.push_back(new ActionAssign(_engine, slot, args)); + } else if (act.matchString("change_location", true)) { + actionList.push_back(new ActionChangeLocation(_engine, slot, args)); + } else if (act.matchString("crossfade", true)) { + // TODO: Implement ActionCrossfade + } else if (act.matchString("debug", true)) { + // TODO: Implement ActionDebug + } else if (act.matchString("delay_render", true)) { + // TODO: Implement ActionDelayRender + } else if (act.matchString("disable_control", true)) { + actionList.push_back(new ActionDisableControl(_engine, slot, args)); + } else if (act.matchString("disable_venus", true)) { + // TODO: Implement ActionDisableVenus + } else if (act.matchString("display_message", true)) { + // TODO: Implement ActionDisplayMessage + } else if (act.matchString("dissolve", true)) { + // TODO: Implement ActionDissolve + } else if (act.matchString("distort", true)) { + // TODO: Implement ActionDistort + } else if (act.matchString("enable_control", true)) { + actionList.push_back(new ActionEnableControl(_engine, slot, args)); + } else if (act.matchString("flush_mouse_events", true)) { + // TODO: Implement ActionFlushMouseEvents + } else if (act.matchString("inventory", true)) { + actionList.push_back(new ActionInventory(_engine, slot, args)); + } else if (act.matchString("kill", true)) { + actionList.push_back(new ActionKill(_engine, slot, args)); + } else if (act.matchString("menu_bar_enable", true)) { + // TODO: Implement ActionMenuBarEnable + } else if (act.matchString("music", true)) { + actionList.push_back(new ActionMusic(_engine, slot, args, false)); + } else if (act.matchString("pan_track", true)) { + // TODO: Implement ActionPanTrack + } else if (act.matchString("playpreload", true)) { + actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args)); + } else if (act.matchString("preferences", true)) { + // TODO: Implement ActionPreferences + } else if (act.matchString("quit", true)) { + actionList.push_back(new ActionQuit(_engine, slot)); + } else if (act.matchString("random", true)) { + actionList.push_back(new ActionRandom(_engine, slot, args)); + } else if (act.matchString("region", true)) { + // TODO: Implement ActionRegion + } else if (act.matchString("restore_game", true)) { + // TODO: Implement ActionRestoreGame + } else if (act.matchString("rotate_to", true)) { + // TODO: Implement ActionRotateTo + } else if (act.matchString("save_game", true)) { + // TODO: Implement ActionSaveGame + } else if (act.matchString("set_partial_screen", true)) { + actionList.push_back(new ActionSetPartialScreen(_engine, slot, args)); + } else if (act.matchString("set_screen", true)) { + actionList.push_back(new ActionSetScreen(_engine, slot, args)); + } else if (act.matchString("set_venus", true)) { + // TODO: Implement ActionSetVenus + } else if (act.matchString("stop", true)) { + actionList.push_back(new ActionStop(_engine, slot, args)); + } else if (act.matchString("streamvideo", true)) { + actionList.push_back(new ActionStreamVideo(_engine, slot, args)); + } else if (act.matchString("syncsound", true)) { + // TODO: Implement ActionSyncSound + } else if (act.matchString("timer", true)) { + actionList.push_back(new ActionTimer(_engine, slot, args)); + } else if (act.matchString("ttytext", true)) { + // TODO: Implement ActionTTYText + } else if (act.matchString("universe_music", true)) { + actionList.push_back(new ActionMusic(_engine, slot, args, true)); + } else if (act.matchString("copy_file", true)) { + // Not used. Purposely left empty + } else { + warning("Unhandled result action type: %s", line.c_str()); + } + } } line = stream.readLine(); -- cgit v1.2.3 From 9f39b1e819a94d56c2dd6ecbca1488f7e0cd553a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 25 Nov 2013 13:34:44 +0000 Subject: ZVISION: PreloadAnimation must indicate that the animation is loaded. --- engines/zvision/actions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 9670016d74..ccae6fd47c 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -346,6 +346,7 @@ bool ActionPreloadAnimation::execute() { _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); + _engine->getScriptManager()->setStateValue(_slotkey, 2); return true; } -- cgit v1.2.3 From feabdc60179452973cc329520b3539f5dc22841a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 25 Nov 2013 13:41:37 +0000 Subject: ZVISION: Change clear queued list firstly, not exec list. --- engines/zvision/script_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index b121eaa6a7..f62cbd86c3 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -87,6 +87,7 @@ void ScriptManager::execScope(script_scope &scope) { PuzzleList *tmp = scope.exec_queue; scope.exec_queue = scope.scope_queue; scope.scope_queue = tmp; + scope.scope_queue->clear(); for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) (*PuzzleIter)->addedBySetState = 0; @@ -99,8 +100,6 @@ void ScriptManager::execScope(script_scope &scope) { checkPuzzleCriteria(*PuzzleIter, scope.proc_count); } - scope.exec_queue->clear(); - if (scope.proc_count < 2) { scope.proc_count++; } -- cgit v1.2.3 From f3e2857cde044019dc322eba46bbdcc854fd4839 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 26 Nov 2013 15:02:38 +0000 Subject: ZVISION: Some scripts action arguments can be uppercased, make all lowercase. --- engines/zvision/scr_file_handling.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 0149347c4e..f80700cc0d 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -151,13 +151,14 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + line.toLowercase(); // TODO: Re-order the if-then statements in order of highest occurrence while (!stream.eos() && !line.contains('}')) { if (line.empty()) { line = stream.readLine(); trimCommentsAndWhiteSpace(&line); - + line.toLowercase(); continue; } @@ -291,6 +292,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + line.toLowercase(); } return; -- cgit v1.2.3 From 066cc74d9690222cb6af8cfc08b840eaffd57764 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 4 Dec 2013 14:00:48 +0000 Subject: ZVISION: Refactoring cursor manager into simple and full-functionally. --- engines/zvision/cursor_manager.cpp | 163 ++++++++++++++------------------ engines/zvision/cursor_manager.h | 73 ++++++++------ engines/zvision/events.cpp | 10 +- engines/zvision/lever_control.cpp | 2 +- engines/zvision/push_toggle_control.cpp | 2 +- engines/zvision/script_manager.cpp | 2 +- engines/zvision/zvision.cpp | 2 + 7 files changed, 129 insertions(+), 125 deletions(-) diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index de229a38d8..aaf3bb8ee4 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -50,87 +50,59 @@ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), - _cursorIsPushed(false) { - // WARNING: The index IDLE_CURSOR_INDEX is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly - if (_engine->getGameId() == GID_NEMESIS) { - Common::String name(Common::String::format("%sa.zcr", _zNemCursorFileNames[IDLE_CURSOR_INDEX])); - _idleCursor = ZorkCursor(name); - } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - _idleCursor = ZorkCursor(_zgiCursorFileNames[IDLE_CURSOR_INDEX]); + _cursorIsPushed(false), + _item(0), + _lastitem(0) { + for (int i = 0; i < NUM_CURSORS; i++) { + if (_engine->getGameId() == GID_NEMESIS) { + Common::String name; + name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); + _cursors[i][0] = ZorkCursor(name); // Up cursor + name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); + _cursors[i][1] = ZorkCursor(name); // Down cursor + } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { + _cursors[i][0] = ZorkCursor(_zgiCursorFileNames[i]); // Up cursor + char buffer[25]; + strcpy(buffer, _zgiCursorFileNames[i]); + buffer[3] += 2; + _cursors[i][1] = ZorkCursor(buffer); // Down cursor + } } } -void CursorManager::initialize() { - revertToIdle(); - CursorMan.showMouse(true); -} - -void CursorManager::changeCursor(const Common::String &cursorName) { - changeCursor(cursorName, _cursorIsPushed); -} - -void CursorManager::changeCursor(const Common::String &cursorName, bool pushed) { - if (_currentCursor.equals(cursorName) && _cursorIsPushed == pushed) - return; - - if (_cursorIsPushed != pushed) - _cursorIsPushed = pushed; - - if (cursorName == "idle" && !pushed) { - CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat); - return; - } - - for (int i = 0; i < NUM_CURSORS; ++i) { - if (_engine->getGameId() == GID_NEMESIS) { - if (cursorName.equals(_cursorNames[i])) { - _currentCursor = cursorName; - - // ZNem uses a/b at the end of the file to signify not pushed/pushed respectively - Common::String pushedFlag = pushed ? "b" : "a"; - Common::String name = Common::String::format("%s%s.zcr", _zNemCursorFileNames[i], pushedFlag.c_str()); - - changeCursor(ZorkCursor(name)); - return; - } - } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - if (cursorName.equals(_cursorNames[i])) { - _currentCursor = cursorName; - - if (!pushed) { - changeCursor(ZorkCursor(_zgiCursorFileNames[i])); - } else { - // ZGI flips not pushed/pushed between a/c and b/d - // It flips the 4th character of the name - char buffer[25]; - strcpy(buffer, _zgiCursorFileNames[i]); - buffer[3] += 2; - changeCursor(ZorkCursor(buffer)); - } +void CursorManager::setItemID(int id) { + if (id != _item) { + if (id) { + Common::String file; + if (_engine->getGameId() == GID_NEMESIS) { + file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a'); + _cursors[NUM_CURSORS][0] = ZorkCursor(file); + file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b'); + _cursors[NUM_CURSORS][1] = ZorkCursor(file); + file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a'); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b'); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { + file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id); + _cursors[NUM_CURSORS][0] = ZorkCursor(file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id); + _cursors[NUM_CURSORS][1] = ZorkCursor(file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id); + _cursors[NUM_CURSORS + 1][1] = ZorkCursor(file); + } else return; - } } + _item = id; + changeCursor(CursorIndex_Idle); } - - // If we get here, something went wrong - warning("No cursor found for identifier %s", cursorName.c_str()); } -void CursorManager::changeCursor(int id, bool active, bool pushed) { - Common::String file; - if (_engine->getGameId() == GID_NEMESIS) { - file = Common::String::format("%2.2d%s%c.zcr", id, active ? "act" : "idle", pushed ? 'b' : 'a'); - } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - file = Common::String::format("g0b%cc%2.2x1.zcr", active ? (pushed ? 'd' : 'c') : (pushed ? 'b' : 'a') , id); - } else - return; - - if (_currentCursor.equals(file)) - return; - - _currentCursor = file; - - changeCursor(ZorkCursor(file)); +void CursorManager::initialize() { + changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]); + showMouse(true); } void CursorManager::changeCursor(const ZorkCursor &cursor) { @@ -141,31 +113,42 @@ void CursorManager::cursorDown(bool pushed) { if (_cursorIsPushed == pushed) return; - changeCursor(_currentCursor, pushed); -} + _cursorIsPushed = pushed; -void CursorManager::setLeftCursor() { - changeCursor("leftarrow"); + changeCursor(_cursors[_currentCursor][_cursorIsPushed]); } -void CursorManager::setRightCursor() { - changeCursor("rightarrow"); -} +void CursorManager::changeCursor(int id) { + int _id = id; -void CursorManager::setUpCursor() { - changeCursor("zuparrow"); + if (_item && + (_id == CursorIndex_Active || + _id == CursorIndex_Idle || + _id == CursorIndex_HandPu)) { + + if (_id == CursorIndex_Idle) + _id = CursorIndex_ItemIdle; + else + _id = CursorIndex_ItemAct; + } + + if (_currentCursor != _id || + ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) { + _currentCursor = _id; + _lastitem = _item; + changeCursor(_cursors[_currentCursor][_cursorIsPushed]); + } } -void CursorManager::setDownCursor() { - changeCursor("downarrow"); +int CursorManager::getCursorId(Common::String &name) { + for (int i = 0; i < NUM_CURSORS; i++) + if (name.equals(_cursorNames[i])) + return i; + return CursorIndex_Idle; } -void CursorManager::revertToIdle() { - _currentCursor = "idle"; - if (!_cursorIsPushed) - CursorMan.replaceCursor(_idleCursor.getSurface(), _idleCursor.getWidth(), _idleCursor.getHeight(), _idleCursor.getHotspotX(), _idleCursor.getHotspotY(), _idleCursor.getKeyColor(), false, _pixelFormat); - else - changeCursor(_currentCursor, _cursorIsPushed); +void CursorManager::showMouse(bool vis) { + CursorMan.showMouse(vis); } } // End of namespace ZVision diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h index ac79b259fa..7bd1c4240f 100644 --- a/engines/zvision/cursor_manager.h +++ b/engines/zvision/cursor_manager.h @@ -36,6 +36,21 @@ namespace ZVision { class ZVision; +/** + * Mostly usable cursors + */ +enum CursorIndex { + CursorIndex_Active = 0, + CursorIndex_DownArr = 3, + CursorIndex_HandPu = 6, + CursorIndex_Idle = 11, + CursorIndex_Left = 12, + CursorIndex_Right = 13, + CursorIndex_UpArr = 17, + CursorIndex_ItemIdle = 18, + CursorIndex_ItemAct = 19 +}; + /** * Class to manage cursor changes. The actual changes have to be done * through CursorMan. Otherwise the cursor will disappear after GMM @@ -47,17 +62,17 @@ public: CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat); private: - enum { - NUM_CURSORS = 18, - // WARNING: The index 11 is hardcoded. If you change the order of _cursorNames/_zgiCursorFileNames/_zNemCursorFileNames, you HAVE to change the index accordingly - IDLE_CURSOR_INDEX = 11 - }; + static const int NUM_CURSORS = 18; + + // 18 default cursors in up/down states, +2 for items idle/act cursors + ZorkCursor _cursors[NUM_CURSORS + 2][2]; ZVision *_engine; const Graphics::PixelFormat *_pixelFormat; - ZorkCursor _idleCursor; - Common::String _currentCursor; bool _cursorIsPushed; + int _item; + int _lastitem; + int _currentCursor; static const char *_cursorNames[]; static const char *_zgiCursorFileNames[]; @@ -68,21 +83,30 @@ public: void initialize(); /** - * Parses a cursor name into a cursor file then creates and shows that cursor. - * It will use the current _isCursorPushed state to choose the correct cursor + * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item. + * + * @param id Wanted cursor id. + */ + + void changeCursor(int id); + + /** + * Return founded id for string contains cursor name * - * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[] + * @param name Cursor name + * @return Id of cursor or idle cursor id if not found */ - void changeCursor(const Common::String &cursorName); + + int getCursorId(Common::String &name); + /** - * Parses a cursor name into a cursor file then creates and shows that cursor. + * Load cursor for item by id, and try to change cursor to item cursor if it's not 0 * - * @param cursorName The name of a cursor. This *HAS* to correspond to one of the entries in _cursorNames[] - * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) + * @param id Item id or 0 for no item cursor */ - void changeCursor(const Common::String &cursorName, bool pushed); - void changeCursor(int id, bool active, bool pushed); + void setItemID(int id); + /** * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen. * @@ -90,17 +114,12 @@ public: */ void cursorDown(bool pushed); - /** Set the cursor to 'Left Arrow'. It will retain the current _isCursorPushed state */ - void setLeftCursor(); - /** Set the cursor to 'Right Arrow'. It will retain the current _isCursorPushed state */ - void setRightCursor(); - /** Set the cursor to 'Up Arrow'. It will retain the current _isCursorPushed state */ - void setUpCursor(); - /** Set the cursor to 'Down Arrow'. It will retain the current _isCursorPushed state */ - void setDownCursor(); - - /** Set the cursor to 'Idle'. It will retain the current _isCursorPushed state */ - void revertToIdle(); + /** + * Show or hide mouse cursor. + * + * @param vis Should the cursor be showed (true) or hide (false) + */ + void showMouse(bool vis); private: /** diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index ede91273e6..69f5ffec24 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -150,14 +150,14 @@ void ZVision::onMouseMove(const Common::Point &pos) { // We use fixed point math to get better accuracy Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED; _renderManager->setBackgroundVelocity(velocity.toInt()); - _cursorManager->setLeftCursor(); + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to the right edge (y = mx) // We use fixed point math to get better accuracy Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET); _renderManager->setBackgroundVelocity(velocity.toInt()); - _cursorManager->setRightCursor(); + _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; } else { _renderManager->setBackgroundVelocity(0); @@ -168,14 +168,14 @@ void ZVision::onMouseMove(const Common::Point &pos) { // We use fixed point math to get better accuracy Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED; _renderManager->setBackgroundVelocity(velocity.toInt()); - _cursorManager->setUpCursor(); + _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to the bottom edge (y = mx) // We use fixed point math to get better accuracy Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET); _renderManager->setBackgroundVelocity(velocity.toInt()); - _cursorManager->setDownCursor(); + _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; } else { _renderManager->setBackgroundVelocity(0); @@ -186,7 +186,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { } if (!cursorWasChanged) { - _cursorManager->revertToIdle(); + _cursorManager->changeCursor(CursorIndex_Idle); } } diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index 6d13d60b3e..fa8475f457 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -239,7 +239,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common } } } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_cursorName); + _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_cursorName)); cursorWasChanged = true; } diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 88619e8f97..86f499739c 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -88,7 +88,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C return false; if (_hotspot.contains(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_hoverCursor); + _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor)); return true; } diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index f62cbd86c3..e2397abc59 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -511,7 +511,7 @@ void ScriptManager::do_changeLocation() { _activeControls = &nodeview._controls; // Revert to the idle cursor - _engine->getCursorManager()->revertToIdle(); + _engine->getCursorManager()->changeCursor(CursorIndex_Idle); // Reset the background velocity _engine->getRenderManager()->setBackgroundVelocity(0); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 62061bfab6..39d61d9a89 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -143,6 +143,8 @@ Common::Error ZVision::run() { uint32 currentTime = _clock.getLastMeasuredTime(); uint32 deltaTime = _clock.getDeltaTime(); + _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); + processEvents(); // Call _renderManager->update() first so the background renders -- cgit v1.2.3 From 570630ee3df60e1dd22fbab1595a4d9dfaa38774 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 24 Dec 2013 14:38:11 +0700 Subject: ZVISION: Make update screen delayed for updates. --- engines/zvision/script_manager.cpp | 2 ++ engines/zvision/zvision.cpp | 16 ++++++++++++++-- engines/zvision/zvision.h | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index e2397abc59..e30861aa98 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -462,6 +462,8 @@ void ScriptManager::do_changeLocation() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); + _engine->setRenderDelay(2); + if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { if (_nextLocation.world != 'g' || _nextLocation.room != 'j') { setStateValue(StateKey_LastWorld, getStateValue(StateKey_World)); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 39d61d9a89..65064d8a66 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -62,7 +62,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _saveManager(nullptr), _stringManager(nullptr), _cursorManager(nullptr), - _aud_id(0) { + _aud_id(0), + _rendDelay(2) { debug(1, "ZVision::ZVision"); } @@ -156,7 +157,10 @@ Common::Error ZVision::run() { _renderManager->renderBackbufferToScreen(); // Update the screen - _system->updateScreen(); + if (_rendDelay <= 0) + _system->updateScreen(); + else + _rendDelay--; // Calculate the frame delay based off a desired frame time int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); @@ -193,4 +197,12 @@ int ZVision::getAudioId() { return _aud_id; } +void ZVision::setRenderDelay(uint delay) { + _rendDelay = delay; +} + +bool ZVision::canRender() { + return _rendDelay <= 0; +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index e7709283ae..05c5fcd3a4 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -109,6 +109,8 @@ private: const Common::Rect _workingWindow_ZGI; const Common::Rect _workingWindow_ZNM; + + int _rendDelay; public: uint32 getFeatures() const; Common::Language getLanguage() const; @@ -153,6 +155,9 @@ public: Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); + void setRenderDelay(uint); + bool canRender(); + private: void initialize(); void initFonts(); -- cgit v1.2.3 From 621818836e6a1100bbed2dbc1520a1005f1ad9ed Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 24 Dec 2013 14:43:42 +0700 Subject: ZVISION: New easy-to-use render functions for next rendermanager generation. --- engines/zvision/render_manager.cpp | 56 ++++++++++++++++++++++++++++++++++++++ engines/zvision/render_manager.h | 10 +++++++ 2 files changed, 66 insertions(+) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index fc15e18fd0..6578c850f6 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -721,4 +721,60 @@ void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uin } } +void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { + Common::Rect pos(x, y, x + src.w, y + src.h); + pos.clip(dst.w, dst.h); + copyRectToSurface(src, dst, Common::Rect(), pos); +} + +void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) { + Common::Rect pos(x, y, x + src.w, y + src.h); + pos.clip(dst.w, dst.h); + copyRectToSurface(src, dst, Common::Rect(), pos, colorkey); +} + +void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y) { + blitSurfaceToSurface(src, _currentBackground, x, y); + moveBackground(0); // Temporary workaround +} + +void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) { + blitSurfaceToSurface(src, _currentBackground, x, y, colorkey); + moveBackground(0); // Temporary workaround +} + +void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y) { + blitSurfaceToSurface(src, _workingWindowBuffer, x, y); +} + +void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) { + blitSurfaceToSurface(src, _workingWindowBuffer, x, y, colorkey); +} + +Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) { + Common::Rect dst = rect; + dst.clip(_currentBackground.w, _currentBackground.h); + + if (dst.isEmpty() || !dst.isValidRect()) + return NULL; + + Graphics::Surface *srf = new Graphics::Surface; + srf->create(dst.width(), dst.height(), _currentBackground.format); + + srf->copyRectToSurface(_currentBackground, 0, 0, Common::Rect(dst)); + + return srf; +} + +Graphics::Surface *RenderManager::loadImage(Common::String &file) { + Graphics::Surface *tmp = new Graphics::Surface; + readImageToSurface(file, *tmp); + return tmp; +} + +Graphics::Surface *RenderManager::loadImage(const char *file) { + Common::String str = Common::String(file); + return loadImage(str); +} + } // End of namespace ZVision diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 14ca704ce1..e16d3562dc 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -369,6 +369,16 @@ public: void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight); + void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y); + void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); + void blitSurfaceToBkg(Graphics::Surface &src, int x, int y); + void blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey); + void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y); + void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey); + Graphics::Surface *getBkgRect(Common::Rect &rect); + Graphics::Surface *loadImage(const char *file); + Graphics::Surface *loadImage(Common::String &file); + private: /** * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect -- cgit v1.2.3 From fd325d49f9103408f7d2fc10cc99dae7fab9a0a1 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 24 Dec 2013 15:05:23 +0700 Subject: ZVISION: Add splitter function into controls class. --- engines/zvision/control.cpp | 24 ++++++++++++++++++++++++ engines/zvision/control.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/engines/zvision/control.cpp b/engines/zvision/control.cpp index 0346228681..ef2e90f8ce 100644 --- a/engines/zvision/control.cpp +++ b/engines/zvision/control.cpp @@ -103,4 +103,28 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre renderTable->generateRenderTable(); } +void Control::getParams(Common::String &input_str, Common::String ¶meter, Common::String &values) { + const char *chrs = input_str.c_str(); + uint lbr; + + for (lbr = 0; lbr < input_str.size(); lbr++) + if (chrs[lbr] == '(') + break; + + if (lbr >= input_str.size()) + return; + + uint rbr; + + for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + if (chrs[rbr] == ')') + break; + + if (rbr >= input_str.size()) + return; + + parameter = Common::String(chrs, chrs + lbr); + values = Common::String(chrs + lbr + 1, chrs + rbr); +} + } // End of namespace ZVision diff --git a/engines/zvision/control.h b/engines/zvision/control.h index 65d76da5c4..93ad5f5df1 100644 --- a/engines/zvision/control.h +++ b/engines/zvision/control.h @@ -24,6 +24,7 @@ #define ZVISION_CONTROL_H #include "common/keyboard.h" +#include "common/str.h" namespace Common { @@ -102,6 +103,7 @@ protected: ZVision *_engine; uint32 _key; + void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values); // Static member functions public: static void parseFlatControl(ZVision *engine); -- cgit v1.2.3 From 0c7d1d2d3691f93701e33f40cb665d87004e5499 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 24 Dec 2013 15:11:39 +0700 Subject: ZVISION: Slot control code. --- engines/zvision/module.mk | 3 +- engines/zvision/scr_file_handling.cpp | 3 + engines/zvision/slot_control.cpp | 215 ++++++++++++++++++++++++++++++++++ engines/zvision/slot_control.h | 86 ++++++++++++++ 4 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/slot_control.cpp create mode 100644 engines/zvision/slot_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index ffdef16335..b5512636c3 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -32,7 +32,8 @@ MODULE_OBJS := \ zork_raw.o \ sidefx.o \ music_node.o \ - inventory_manager.o + inventory_manager.o \ + slot_control.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index f80700cc0d..4f1c3631bd 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -29,6 +29,7 @@ #include "zvision/actions.h" #include "zvision/push_toggle_control.h" #include "zvision/lever_control.h" +#include "zvision/slot_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -342,6 +343,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return NULL; } else if (controlType.equalsIgnoreCase("lever")) { return new LeverControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("slot")) { + return new SlotControl(_engine, key, stream); } return NULL; } diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp new file mode 100644 index 0000000000..418aa8fad2 --- /dev/null +++ b/engines/zvision/slot_control.cpp @@ -0,0 +1,215 @@ +/* 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 "common/scummsys.h" + +#include "zvision/slot_control.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" +#include "zvision/cursor_manager.h" +#include "zvision/render_manager.h" +#include "zvision/utility.h" + +#include "common/stream.h" + + +namespace ZVision { + +SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key) { + + _rendered_item = 0; + _bkg = NULL; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("hotspot", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _hotspot = Common::Rect(x, y, width, height); + } else if (param.matchString("rectangle", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _rectangle = Common::Rect(x, y, width, height); + } else if (param.matchString("cursor", true)) { + _cursor = _engine->getCursorManager()->getCursorId(values); + } else if (param.matchString("distance_id", true)) { + sscanf(values.c_str(), "%c", &_distance_id); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } else if (param.matchString("eligible_objects", true)) { + char buf[256]; + memset(buf, 0, 256); + strcpy(buf, values.c_str()); + + char *curpos = buf; + char *strend = buf + strlen(buf); + while (true) { + char *st = curpos; + + if (st >= strend) + break; + + while (*curpos != ' ' && curpos < strend) + curpos++; + + *curpos = 0; + curpos++; + + int obj = atoi(st); + + _eligible_objects.push_back(obj); + } + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } + + if (_hotspot.isEmpty() || _rectangle.isEmpty()) { + warning("Slot %u was parsed incorrectly", key); + } +} + +SlotControl::~SlotControl() { + // Clear the state value back to 0 + //_engine->getScriptManager()->setStateValue(_key, 0); + + if (_bkg) + delete _bkg; +} + +bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_hotspot.contains(backgroundImageSpacePos)) { + //ctrl_setvenus(ct); + + int item = _engine->getScriptManager()->getStateValue(_key); + int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (item != 0) { + if (mouse_item != 0) { + if (eligeblity(mouse_item)) { + _engine->getScriptManager()->invertory_drop(mouse_item); + _engine->getScriptManager()->invertory_add(item); + _engine->getScriptManager()->setStateValue(_key, mouse_item); + } + } else { + _engine->getScriptManager()->invertory_add(item); + _engine->getScriptManager()->setStateValue(_key, 0); + } + } else if (mouse_item == 0) { + if (eligeblity(0)) { + _engine->getScriptManager()->invertory_drop(0); + _engine->getScriptManager()->setStateValue(_key, 0); + } + } else if (eligeblity(mouse_item)) { + _engine->getScriptManager()->setStateValue(_key, mouse_item); + _engine->getScriptManager()->invertory_drop(mouse_item); + } + } + return false; +} + +bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_hotspot.contains(backgroundImageSpacePos)) { + _engine->getCursorManager()->changeCursor(_cursor); + return true; + } + + return false; +} + +bool SlotControl::process(uint32 deltaTimeInMillis) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_engine->canRender()) { + int cur_item = _engine->getScriptManager()->getStateValue(_key); + if (cur_item != _rendered_item) { + if (_rendered_item == 0) { + if (_bkg) + delete _bkg; + + _bkg = _engine->getRenderManager()->getBkgRect(_rectangle); + + char buf[16]; + if (_engine->getGameId() == GID_NEMESIS) + sprintf(buf, "%d%cobj.tga", cur_item, _distance_id); + else + sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item); + + Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf); + + int16 drawx = _rectangle.left; + int16 drawy = _rectangle.top; + + if (_rectangle.width() > srf->w) + drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2; + + if (_rectangle.height() > srf->h) + drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2; + + _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0); + + delete srf; + + _rendered_item = cur_item; + } else { + _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); + _rendered_item = cur_item; + } + } + } + return false; +} + +bool SlotControl::eligeblity(int item_id) { + for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) + if (*it == item_id) + return true; + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h new file mode 100644 index 0000000000..eec2d04518 --- /dev/null +++ b/engines/zvision/slot_control.h @@ -0,0 +1,86 @@ +/* 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 ZVISION_SLOT_CONTROL_H +#define ZVISION_SLOT_CONTROL_H + +#include "zvision/control.h" + +#include "graphics/surface.h" + +#include "common/rect.h" +#include "common/list.h" + + +namespace ZVision { + +class SlotControl : public Control { +public: + SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~SlotControl(); + + /** + * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + /** + * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. + * + * @param engine The base engine + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + * @return Was the cursor changed? + */ + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + + bool process(uint32 deltaTimeInMillis); + +private: + /** + * The area that will trigger the event + * This is in image space coordinates, NOT screen space + */ + Common::Rect _rectangle; + Common::Rect _hotspot; + + int _cursor; + char _distance_id; + int _venus_id; + + int _rendered_item; + + Common::List _eligible_objects; + + bool eligeblity(int item_id); + + Graphics::Surface *_bkg; + + /** The cursor to use when hovering over _hotspot */ + Common::String _hoverCursor; +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 48156debaf148b50acd3eb6e3de7020498016a5f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 24 Dec 2013 15:37:11 +0700 Subject: ZVISION: Fix animation_node upper frame. --- engines/zvision/animation_node.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 73e419ee19..967dee2c4a 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -190,6 +190,13 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = start_frame; nod.stop = end_frame; + if (_fileType == RLF) { + if (nod.stop >= (int)_animation.rlf->frameCount()) + nod.stop = _animation.rlf->frameCount() - 1; + } else if (_fileType == AVI) { + if (nod.stop > (int)_animation.avi->getFrameCount()) + nod.stop = _animation.avi->getFrameCount(); + } nod.slot = slot; nod._cur_frm = -1; nod._delay = 0; -- cgit v1.2.3 From 1428cb8950e5bdcfad9d15d0fb2e32ff1dbc0bae Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 7 Jan 2014 18:39:16 +0700 Subject: ZVISION: Refactoring of renderManager. --- engines/zvision/animation_node.cpp | 8 +- engines/zvision/console.cpp | 16 +- engines/zvision/events.cpp | 48 ++- engines/zvision/input_control.cpp | 4 +- engines/zvision/lever_control.cpp | 14 +- engines/zvision/render_manager.cpp | 863 ++++++++++++++++--------------------- engines/zvision/render_manager.h | 320 ++++---------- engines/zvision/render_table.cpp | 22 + engines/zvision/render_table.h | 2 + engines/zvision/script_manager.cpp | 4 +- engines/zvision/zvision.cpp | 50 ++- engines/zvision/zvision.h | 2 + 12 files changed, 577 insertions(+), 776 deletions(-) diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 967dee2c4a..74b532b2ef 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -165,15 +165,15 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); if (_mask > 0) - _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top, _mask); + _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); else - _engine->getRenderManager()->renderImageToBackground(*transposed, nod->pos.left, nod->pos.top); + _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); delete transposed; } else { if (_mask > 0) - _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top, _mask); + _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); else - _engine->getRenderManager()->renderImageToBackground(*frame, nod->pos.left, nod->pos.top); + _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top); } } } diff --git a/engines/zvision/console.cpp b/engines/zvision/console.cpp index 400dcb3f39..252a4b75ef 100644 --- a/engines/zvision/console.cpp +++ b/engines/zvision/console.cpp @@ -60,12 +60,12 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { } bool Console::cmdLoadImage(int argc, const char **argv) { - if (argc == 4) - _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3])); - else { - DebugPrintf("Use loadimage to load an image to the screen\n"); - return true; - } +// if (argc == 4) +// _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3])); +// else { +// DebugPrintf("Use loadimage to load an image to the screen\n"); +// return true; +// } return true; } @@ -208,8 +208,8 @@ bool Console::cmdRenderText(int argc, const char **argv) { return true; } - StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2])); - _engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true); + //StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2])); + //_engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true); return true; } diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index 69f5ffec24..d8828867b0 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -146,43 +146,53 @@ void ZVision::onMouseMove(const Common::Point &pos) { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { - // Linear function of distance to the left edge (y = -mx + b) - // We use fixed point math to get better accuracy - Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED; - _renderManager->setBackgroundVelocity(velocity.toInt()); + + int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; + if (mspeed <= 0) + mspeed = 400 >> 4; + _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { - // Linear function of distance to the right edge (y = mx) - // We use fixed point math to get better accuracy - Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET); - _renderManager->setBackgroundVelocity(velocity.toInt()); + + int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; + if (mspeed <= 0) + mspeed = 400 >> 4; + _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; } else { - _renderManager->setBackgroundVelocity(0); + _velocity = 0; } } else if (renderState == RenderTable::TILT) { if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { - // Linear function of distance to top edge - // We use fixed point math to get better accuracy - Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED; - _renderManager->setBackgroundVelocity(velocity.toInt()); + + int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; + if (mspeed <= 0) + mspeed = 400 >> 4; + _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { - // Linear function of distance to the bottom edge (y = mx) - // We use fixed point math to get better accuracy - Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET); - _renderManager->setBackgroundVelocity(velocity.toInt()); + + int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; + if (mspeed <= 0) + mspeed = 400 >> 4; + _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; } else { - _renderManager->setBackgroundVelocity(0); + _velocity = 0; } + } else { + _velocity = 0; } } else { - _renderManager->setBackgroundVelocity(0); + _velocity = 0; } if (!cursorWasChanged) { diff --git a/engines/zvision/input_control.cpp b/engines/zvision/input_control.cpp index 8d9d79ba09..a366e06923 100644 --- a/engines/zvision/input_control.cpp +++ b/engines/zvision/input_control.cpp @@ -129,9 +129,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) { // First see if we need to render the text if (_textChanged) { // Blit the text using the RenderManager - Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width()); + //Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width()); - _cursorOffset = destRect.left - _textRectangle.left; + //_cursorOffset = destRect.left - _textRectangle.left; } // Render the next frame of the animation diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index fa8475f457..9cd36cf653 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -375,26 +375,20 @@ void LeverControl::renderFrame(uint frameNumber) { _lastRenderedFrame = frameNumber; } - const uint16 *frameData; + const Graphics::Surface *frameData; int x = _animationCoords.left; int y = _animationCoords.top; - int width; - int height; if (_fileType == RLF) { // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can - frameData = (const uint16 *)_animation.rlf->getFrameData(frameNumber)->getPixels(); - width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width() - height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height() + frameData = _animation.rlf->getFrameData(frameNumber); } else if (_fileType == AVI) { _animation.avi->seekToFrame(frameNumber); const Graphics::Surface *surface = _animation.avi->decodeNextFrame(); - frameData = (const uint16 *)surface->getPixels(); - width = surface->w; - height = surface->h; + frameData = surface; } - _engine->getRenderManager()->copyRectToWorkingWindow(frameData, x, y, width, width, height); + _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); } } // End of namespace ZVision diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 6578c850f6..bc4d169569 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -39,356 +39,75 @@ namespace ZVision { RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) : _system(system), - _workingWidth(workingWindow.width()), - _workingHeight(workingWindow.height()), - _screenCenterX(_workingWidth / 2), - _screenCenterY(_workingHeight / 2), + _wrkWidth(workingWindow.width()), + _wrkHeight(workingWindow.height()), + _screenCenterX(_wrkWidth / 2), + _screenCenterY(_wrkHeight / 2), _workingWindow(workingWindow), _pixelFormat(pixelFormat), - _backgroundWidth(0), - _backgroundHeight(0), - _backgroundInverseVelocity(0), - _backgroundOffset(0, 0), - _accumulatedVelocityMilliseconds(0), - _renderTable(_workingWidth, _workingHeight) { + _bkgWidth(0), + _bkgHeight(0), + _bkgOff(0), + _renderTable(_wrkWidth, _wrkHeight) { - _workingWindowBuffer.create(_workingWidth, _workingHeight, _pixelFormat); - _backBuffer.create(windowWidth, windowHeight, pixelFormat); -} + _wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); + _outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); + _menuWnd.create(windowWidth, workingWindow.top, _pixelFormat); + _subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); -RenderManager::~RenderManager() { - _workingWindowBuffer.free(); - _currentBackground.free(); - _backBuffer.free(); + _menuWndRect = Common::Rect(0, 0, windowWidth, workingWindow.top); + _subWndRect = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight); - for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) { - iter->_value.data->free(); - delete iter->_value.data; - } + _subid = 0; } -void RenderManager::update(uint deltaTimeInMillis) { - // An inverse velocity of 0 would be infinitely fast, so we'll let 0 mean no velocity. - if (_backgroundInverseVelocity != 0) { - _accumulatedVelocityMilliseconds += deltaTimeInMillis; - - uint absVelocity = uint(abs(_backgroundInverseVelocity)); - - int numberOfSteps = 0; - while (_accumulatedVelocityMilliseconds >= absVelocity) { - _accumulatedVelocityMilliseconds -= absVelocity; - numberOfSteps++; - } - - // Choose the direction of movement using the sign of the velocity - moveBackground(_backgroundInverseVelocity < 0 ? -numberOfSteps : numberOfSteps); - } +RenderManager::~RenderManager() { + _curBkg.free(); + _wrkWnd.free(); + _outWnd.free(); } void RenderManager::renderBackbufferToScreen() { - if (!_workingWindowDirtyRect.isEmpty()) { - RenderTable::RenderState state = _renderTable.getRenderState(); - if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - _renderTable.mutateImage((uint16 *)_workingWindowBuffer.getPixels(), (uint16 *)_backBuffer.getBasePtr(_workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top), _backBuffer.w, _workingWindowDirtyRect); - } else { - _backBuffer.copyRectToSurface(_workingWindowBuffer.getBasePtr(_workingWindowDirtyRect.left, _workingWindowDirtyRect.top), _workingWindowBuffer.pitch, _workingWindow.left + _workingWindowDirtyRect.left, _workingWindow.top + _workingWindowDirtyRect.top, _workingWindowDirtyRect.width(), _workingWindowDirtyRect.height()); - } - - // Translate the working window dirty rect to screen coords - _workingWindowDirtyRect.translate(_workingWindow.left, _workingWindow.top); - // Then extend the backbuffer dirty rect to contain it - if (_backBufferDirtyRect.isEmpty()) { - _backBufferDirtyRect = _workingWindowDirtyRect; - } else { - _backBufferDirtyRect.extend(_workingWindowDirtyRect); - } - - // Clear the dirty rect - _workingWindowDirtyRect = Common::Rect(); - } - - // TODO: Add menu rendering - - // Render alpha entries - processAlphaEntries(); - - if (!_backBufferDirtyRect.isEmpty()) { - _system->copyRectToScreen(_backBuffer.getBasePtr(_backBufferDirtyRect.left, _backBufferDirtyRect.top), _backBuffer.pitch, _backBufferDirtyRect.left, _backBufferDirtyRect.top, _backBufferDirtyRect.width(), _backBufferDirtyRect.height()); - _backBufferDirtyRect = Common::Rect(); - } -} - -void RenderManager::processAlphaEntries() { - // TODO: Add dirty rectangling support. AKA only draw an entry if the _backbufferDirtyRect intersects/contains the entry Rect + Graphics::Surface *out = &_outWnd; - for (AlphaEntryMap::iterator iter = _alphaDataEntries.begin(); iter != _alphaDataEntries.end(); ++iter) { - uint32 destOffset = 0; - uint32 sourceOffset = 0; - uint16 *backbufferPtr = (uint16 *)_backBuffer.getBasePtr(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top); - uint16 *entryPtr = (uint16 *)iter->_value.data->getPixels(); - - for (int32 y = 0; y < iter->_value.height; ++y) { - for (int32 x = 0; x < iter->_value.width; ++x) { - uint16 color = entryPtr[sourceOffset + x]; - if (color != iter->_value.alphaColor) { - backbufferPtr[destOffset + x] = color; - } - } - - destOffset += _backBuffer.w; - sourceOffset += iter->_value.width; - } - - if (_backBufferDirtyRect.isEmpty()) { - _backBufferDirtyRect = Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height); - } else { - _backBufferDirtyRect.extend(Common::Rect(iter->_value.destX + _workingWindow.left, iter->_value.destY + _workingWindow.top, iter->_value.destX + _workingWindow.left + iter->_value.width, iter->_value.destY + _workingWindow.top + iter->_value.height)); + RenderTable::RenderState state = _renderTable.getRenderState(); + if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { + if (!_wrkWndDirtyRect.isEmpty()) { + _renderTable.mutateImage(&_outWnd, &_wrkWnd); + out = &_outWnd; + _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight); } + } else { + out = &_wrkWnd; + _outWndDirtyRect = _wrkWndDirtyRect; } -} - -void RenderManager::clearWorkingWindowTo555Color(uint16 color) { - uint32 workingWindowSize = _workingWidth * _workingHeight; - byte r, g, b; - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b); - uint16 colorIn565 = _pixelFormat.RGBToColor(r, g, b); - uint16 *bufferPtr = (uint16 *)_workingWindowBuffer.getPixels(); - - for (uint32 i = 0; i < workingWindowSize; ++i) { - bufferPtr[i] = colorIn565; - } -} - -void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect) { - if (src.format != dst.format) - return; - - Common::Rect dstRect = _dstRect; - if (dstRect.isEmpty()) - dstRect = Common::Rect(dst.w, dst.h); - dstRect.clip(dst.w, dst.h); - - Common::Rect srcRect = _srcRect; - if (srcRect.isEmpty()) - srcRect = Common::Rect(src.w, src.h); - srcRect.clip(src.w, src.h); - - if (!srcRect.isValidRect() || !dstRect.isValidRect()) - return; - - Common::Rect rendRect = srcRect; - rendRect.clip(dstRect.width(), dstRect.height()); - - if (rendRect.isEmpty() || !rendRect.isValidRect()) - return; - // Copy rendRect from src surface to dst surface - const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top); - byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); - int32 w = rendRect.width(); - int32 h = rendRect.height(); + if (!_outWndDirtyRect.isEmpty()) { + _system->copyRectToScreen(out->getBasePtr(_outWndDirtyRect.left, _outWndDirtyRect.top), out->pitch, + _outWndDirtyRect.left + _workingWindow.left, + _outWndDirtyRect.top + _workingWindow.top, + _outWndDirtyRect.width(), + _outWndDirtyRect.height()); - for (int32 y = 0; y < h; y++) { - memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel); - src_buf += src.pitch; - dst_buf += dst.pitch; + _outWndDirtyRect = Common::Rect(); } } -void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &_srcRect, const Common::Rect &_dstRect, uint32 keycolor) { - if (src.format != dst.format) - return; - - Common::Rect dstRect = _dstRect; - if (dstRect.isEmpty()) - dstRect = Common::Rect(dst.w, dst.h); - dstRect.clip(dst.w, dst.h); - - Common::Rect srcRect = _srcRect; - if (srcRect.isEmpty()) - srcRect = Common::Rect(src.w, src.h); - srcRect.clip(src.w, src.h); - - if (!srcRect.isValidRect() || !dstRect.isValidRect()) - return; - - Common::Rect rendRect = srcRect; - rendRect.clip(dstRect.width(), dstRect.height()); - - if (rendRect.isEmpty() || !rendRect.isValidRect()) - return; - - uint32 _keycolor = keycolor & ((1 << (src.format.bytesPerPixel << 3)) - 1); - - // Copy rendRect from src surface to dst surface - const byte *src_buf = (const byte *)src.getBasePtr(rendRect.left, rendRect.top); - byte *dst_buf = (byte *)dst.getBasePtr(dstRect.left, dstRect.top); - - int32 w = rendRect.width(); - int32 h = rendRect.height(); - - for (int32 y = 0; y < h; y++) { - switch (src.format.bytesPerPixel) { - case 1: { - const uint *src_tmp = (const uint *)src_buf; - uint *dst_tmp = (uint *)dst_buf; - for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; - } - } - break; - - case 2: { - const uint16 *src_tmp = (const uint16 *)src_buf; - uint16 *dst_tmp = (uint16 *)dst_buf; - for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; - } - } - break; - - case 4: { - const uint32 *src_tmp = (const uint32 *)src_buf; - uint32 *dst_tmp = (uint32 *)dst_buf; - for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; - } - } - break; - - default: - break; - } - src_buf += src.pitch; - dst_buf += dst.pitch; - } -} - -void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt) { - if (!Common::Rect(dst.w, dst.h).contains(dstPt)) - return; - Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); - copyRectToSurface(src, dst, srcRect, dstRect); -} - -void RenderManager::copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 keycolor) { - if (!Common::Rect(dst.w, dst.h).contains(dstPt)) - return; - Common::Rect dstRect(dstPt.x, dstPt.y, dst.w, dst.h); - copyRectToSurface(src, dst, srcRect, dstRect, keycolor); -} - void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) { Graphics::Surface surface; readImageToSurface(fileName, surface); - Common::Rect srcRect(surface.w, surface.h); - Common::Point dstPt(destX, destY); - - copyRectToSurface(surface, _currentBackground, srcRect, dstPt); - moveBackground(0); -} - -void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY) { - Common::Rect srcRect(surface.w, surface.h); - Common::Point dstPt(destX, destY); - - copyRectToSurface(surface, _currentBackground, srcRect, dstPt); - moveBackground(0); + blitSurfaceToBkg(surface, destX, destY); + surface.free(); } void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 keycolor) { Graphics::Surface surface; readImageToSurface(fileName, surface); - Common::Rect srcRect(surface.w, surface.h); - Common::Point dstPt(destX, destY); - - copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor); - moveBackground(0); -} - -void RenderManager::renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 keycolor) { - Common::Rect srcRect(surface.w, surface.h); - Common::Point dstPt(destX, destY); - - copyRectToSurface(surface, _currentBackground, srcRect, dstPt, keycolor); - moveBackground(0); -} - -void RenderManager::renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { - int16 subRectX = 0; - int16 subRectY = 0; - - // Take care of negative destinations - if (destinationX < 0) { - subRectX = -destinationX; - destinationX = 0; - } else if (destinationX >= surface.w) { - // Take care of extreme positive destinations - destinationX -= surface.w; - } - - // Take care of negative destinations - if (destinationY < 0) { - subRectY = -destinationY; - destinationY = 0; - } else if (destinationY >= surface.h) { - // Take care of extreme positive destinations - destinationY -= surface.h; - } - - if (wrap) { - _backgroundWidth = surface.w; - _backgroundHeight = surface.h; - - if (destinationX > 0) { - // Move destinationX to 0 - subRectX = surface.w - destinationX; - destinationX = 0; - } - - if (destinationY > 0) { - // Move destinationY to 0 - subRectY = surface.h - destinationY; - destinationY = 0; - } - } - - // Clip subRect to working window bounds - Common::Rect subRect(subRectX, subRectY, subRectX + _workingWidth, subRectY + _workingHeight); - - if (!wrap) { - // Clip to image bounds - subRect.clip(surface.w, surface.h); - } - - // Check destRect for validity - if (!subRect.isValidRect() || subRect.isEmpty()) - return; - - copyRectToWorkingWindow((const uint16 *)surface.getBasePtr(subRect.left, subRect.top), destinationX, destinationY, surface.w, subRect.width(), subRect.height()); -} - -void RenderManager::renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap) { - Graphics::Surface surface; - readImageToSurface(fileName, surface); - - renderSubRectToScreen(surface, destinationX, destinationY, wrap); -} - -void RenderManager::renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap) { - renderSubRectToScreen(surface, destinationX, destinationY, wrap); + blitSurfaceToBkg(surface, destX, destY, keycolor); + surface.free(); } void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) { @@ -485,72 +204,6 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: destination.convertToInPlace(_pixelFormat); } -void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height) { - uint32 destOffset = 0; - uint32 sourceOffset = 0; - uint16 *workingWindowBufferPtr = (uint16 *)_workingWindowBuffer.getBasePtr(destX, destY); - - for (int32 y = 0; y < height; ++y) { - for (int32 x = 0; x < width; ++x) { - workingWindowBufferPtr[destOffset + x] = buffer[sourceOffset + x]; - } - - destOffset += _workingWidth; - sourceOffset += imageWidth; - } - - if (_workingWindowDirtyRect.isEmpty()) { - _workingWindowDirtyRect = Common::Rect(destX, destY, destX + width, destY + height); - } else { - _workingWindowDirtyRect.extend(Common::Rect(destX, destY, destX + width, destY + height)); - } - - // TODO: Remove this from release. It's here to make sure code that uses this function clips their destinations correctly - assert(_workingWindowDirtyRect.width() <= _workingWidth && _workingWindowDirtyRect.height() <= _workingHeight); -} - -void RenderManager::copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber) { - AlphaDataEntry entry; - entry.alphaColor = alphaColor; - entry.data = new Graphics::Surface(); - entry.data->create(width, height, _pixelFormat); - entry.destX = destX; - entry.destY = destY; - entry.width = width; - entry.height = height; - - uint32 sourceOffset = 0; - uint32 destOffset = 0; - uint16 *surfacePtr = (uint16 *)entry.data->getPixels(); - - for (int32 y = 0; y < height; ++y) { - for (int32 x = 0; x < width; ++x) { - surfacePtr[destOffset + x] = buffer[sourceOffset + x]; - } - - destOffset += width; - sourceOffset += imageWidth; - } - - _alphaDataEntries[idNumber] = entry; -} - -Common::Rect RenderManager::renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) { - AlphaDataEntry entry; - entry.alphaColor = 0; - entry.destX = destX; - entry.destY = destY; - - // Draw the text to the working window - entry.data = font->drawTextToSurface(text, textColor, maxWidth, maxHeight, align, wrap); - entry.width = entry.data->w; - entry.height = entry.data->h; - - _alphaDataEntries[idNumber] = entry; - - return Common::Rect(destX, destY, destX + entry.width, destY + entry.height); -} - const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) { if (_workingWindow.contains(point)) { // Convert from screen space to working window space @@ -562,19 +215,20 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point & } if (state == RenderTable::PANORAMA) { - newPoint -= (Common::Point(_screenCenterX, 0) - _backgroundOffset); + newPoint += (Common::Point(_bkgOff - _screenCenterX, 0)); } else if (state == RenderTable::TILT) { - newPoint -= (Common::Point(0, _screenCenterY) - _backgroundOffset); + newPoint += (Common::Point(0, _bkgOff - _screenCenterY)); } + if (_bkgWidth) + newPoint.x %= _bkgWidth; + if (_bkgHeight) + newPoint.y %= _bkgHeight; + if (newPoint.x < 0) - newPoint.x += _backgroundWidth; - else if (newPoint.x >= _backgroundWidth) - newPoint.x -= _backgroundWidth; + newPoint.x += _bkgWidth; if (newPoint.y < 0) - newPoint.y += _backgroundHeight; - else if (newPoint.y >= _backgroundHeight) - newPoint.y -= _backgroundHeight; + newPoint.y += _bkgHeight; return newPoint; } else { @@ -582,95 +236,32 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point & } } -const Common::Point RenderManager::imageSpaceToWorkingWindowSpace(const Common::Point &point) { - Common::Point newPoint(point); - - RenderTable::RenderState state = _renderTable.getRenderState(); - if (state == RenderTable::PANORAMA) { - newPoint += (Common::Point(_screenCenterX, 0) - _backgroundOffset); - } else if (state == RenderTable::TILT) { - newPoint += (Common::Point(0, _screenCenterY) - _backgroundOffset); - } - - return newPoint; -} - -bool RenderManager::clipRectToWorkingWindow(Common::Rect &rect) { - if (!_workingWindow.contains(rect)) { - return false; - } - - // We can't clip against the actual working window rect because it's in screen space - // But rect is in working window space - rect.clip(_workingWidth, _workingHeight); - return true; -} - RenderTable *RenderManager::getRenderTable() { return &_renderTable; } void RenderManager::setBackgroundImage(const Common::String &fileName) { - readImageToSurface(fileName, _currentBackground); - - moveBackground(0); + readImageToSurface(fileName, _curBkg); + _bkgWidth = _curBkg.w; + _bkgHeight = _curBkg.h; + _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); } void RenderManager::setBackgroundPosition(int offset) { RenderTable::RenderState state = _renderTable.getRenderState(); - if (state == RenderTable::TILT) { - _backgroundOffset.x = 0; - _backgroundOffset.y = offset; - } else if (state == RenderTable::PANORAMA) { - _backgroundOffset.x = offset; - _backgroundOffset.y = 0; - } else { - _backgroundOffset.x = 0; - _backgroundOffset.y = 0; - } -} - -void RenderManager::setBackgroundVelocity(int velocity) { - // setBackgroundVelocity(0) will be called quite often, so make sure - // _backgroundInverseVelocity isn't already 0 to prevent an extraneous assignment - if (velocity == 0) { - if (_backgroundInverseVelocity != 0) { - _backgroundInverseVelocity = 0; - } - } else { - _backgroundInverseVelocity = 1000 / velocity; - } -} - -void RenderManager::moveBackground(int offset) { - RenderTable::RenderState state = _renderTable.getRenderState(); - if (state == RenderTable::TILT) { - _backgroundOffset += Common::Point(0, offset); - - _backgroundOffset.y = CLIP(_backgroundOffset.y, _screenCenterY, (int16)_backgroundHeight - _screenCenterY); - - renderImageToScreen(_currentBackground, 0, _screenCenterY - _backgroundOffset.y, true); - } else if (state == RenderTable::PANORAMA) { - _backgroundOffset += Common::Point(offset, 0); - - if (_backgroundOffset.x <= -_backgroundWidth) - _backgroundOffset.x += _backgroundWidth; - else if (_backgroundOffset.x >= _backgroundWidth) - _backgroundOffset.x -= _backgroundWidth; - - renderImageToScreen(_currentBackground, _screenCenterX - _backgroundOffset.x, 0, true); - } else { - renderImageToScreen(_currentBackground, 0, 0); - } + if (state == RenderTable::TILT || state == RenderTable::PANORAMA) + if (_bkgOff != offset) + _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); + _bkgOff = offset; } uint32 RenderManager::getCurrentBackgroundOffset() { RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA) { - return _backgroundOffset.x; + return _bkgOff; } else if (state == RenderTable::TILT) { - return _backgroundOffset.y; + return _bkgOff; } else { return 0; } @@ -721,47 +312,196 @@ void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uin } } -void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { - Common::Rect pos(x, y, x + src.w, y + src.h); - pos.clip(dst.w, dst.h); - copyRectToSurface(src, dst, Common::Rect(), pos); +void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) { + + if (src.format != dst.format) + return; + + Common::Rect srcRect = _srcRect; + if (srcRect.isEmpty()) + srcRect = Common::Rect(src.w, src.h); + srcRect.clip(src.w, src.h); + Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h); + srcRect.clip(dstRect); + + if (srcRect.isEmpty() || !srcRect.isValidRect()) + return; + + // Copy srcRect from src surface to dst surface + const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + + int xx = _x; + int yy = _y; + + if (xx < 0) + xx = 0; + if (yy < 0) + yy = 0; + + if (_x >= dst.w || _y >= dst.h) + return; + + byte *dst_buf = (byte *)dst.getBasePtr(xx, yy); + + int32 w = srcRect.width(); + int32 h = srcRect.height(); + + for (int32 y = 0; y < h; y++) { + memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel); + src_buf += src.pitch; + dst_buf += dst.pitch; + } } -void RenderManager::blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) { - Common::Rect pos(x, y, x + src.w, y + src.h); - pos.clip(dst.w, dst.h); - copyRectToSurface(src, dst, Common::Rect(), pos, colorkey); +void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey) { + + if (src.format != dst.format) + return; + + Common::Rect srcRect = _srcRect; + if (srcRect.isEmpty()) + srcRect = Common::Rect(src.w, src.h); + srcRect.clip(src.w, src.h); + Common::Rect dstRect = Common::Rect(-_x + srcRect.left , -_y + srcRect.top, -_x + srcRect.left + dst.w, -_y + srcRect.top + dst.h); + srcRect.clip(dstRect); + + if (srcRect.isEmpty() || !srcRect.isValidRect()) + return; + + + + uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1); + + // Copy srcRect from src surface to dst surface + const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + + int xx = _x; + int yy = _y; + + if (xx < 0) + xx = 0; + if (yy < 0) + yy = 0; + + if (_x >= dst.w || _y >= dst.h) + return; + + byte *dst_buf = (byte *)dst.getBasePtr(xx, yy); + + int32 w = srcRect.width(); + int32 h = srcRect.height(); + + for (int32 y = 0; y < h; y++) { + switch (src.format.bytesPerPixel) { + case 1: { + const uint *src_tmp = (const uint *)src_buf; + uint *dst_tmp = (uint *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + case 2: { + const uint16 *src_tmp = (const uint16 *)src_buf; + uint16 *dst_tmp = (uint16 *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + case 4: { + const uint32 *src_tmp = (const uint32 *)src_buf; + uint32 *dst_tmp = (uint32 *)dst_buf; + for (int32 x = 0; x < w; x++) { + if (*src_tmp != _keycolor) + *dst_tmp = *src_tmp; + src_tmp++; + dst_tmp++; + } + } + break; + + default: + break; + } + src_buf += src.pitch; + dst_buf += dst.pitch; + } +} + +void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, dst, x, y); +} + +void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, dst, x, y, colorkey); } -void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y) { - blitSurfaceToSurface(src, _currentBackground, x, y); - moveBackground(0); // Temporary workaround +void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, _curBkg, x, y); + Common::Rect dirty(src.w, src.h); + dirty.translate(x, y); + if (_bkgDirtyRect.isEmpty()) + _bkgDirtyRect = dirty; + else + _bkgDirtyRect.extend(dirty); } -void RenderManager::blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) { - blitSurfaceToSurface(src, _currentBackground, x, y, colorkey); - moveBackground(0); // Temporary workaround +void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, _curBkg, x, y, colorkey); + Common::Rect dirty(src.w, src.h); + dirty.translate(x, y); + if (_bkgDirtyRect.isEmpty()) + _bkgDirtyRect = dirty; + else + _bkgDirtyRect.extend(dirty); } -void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y) { - blitSurfaceToSurface(src, _workingWindowBuffer, x, y); +void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, _menuWnd, x, y); + Common::Rect dirty(src.w, src.h); + dirty.translate(x, y); + if (_menuWndDirtyRect.isEmpty()) + _menuWndDirtyRect = dirty; + else + _menuWndDirtyRect.extend(dirty); } -void RenderManager::blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey) { - blitSurfaceToSurface(src, _workingWindowBuffer, x, y, colorkey); +void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) { + Common::Rect empt; + blitSurfaceToSurface(src, empt, _menuWnd, x, y, colorkey); + Common::Rect dirty(src.w, src.h); + dirty.translate(x, y); + if (_menuWndDirtyRect.isEmpty()) + _menuWndDirtyRect = dirty; + else + _menuWndDirtyRect.extend(dirty); } Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) { Common::Rect dst = rect; - dst.clip(_currentBackground.w, _currentBackground.h); + dst.clip(_bkgWidth, _bkgHeight); if (dst.isEmpty() || !dst.isValidRect()) return NULL; Graphics::Surface *srf = new Graphics::Surface; - srf->create(dst.width(), dst.height(), _currentBackground.format); + srf->create(dst.width(), dst.height(), _curBkg.format); - srf->copyRectToSurface(_currentBackground, 0, 0, Common::Rect(dst)); + srf->copyRectToSurface(_curBkg, 0, 0, Common::Rect(dst)); return srf; } @@ -777,4 +517,149 @@ Graphics::Surface *RenderManager::loadImage(const char *file) { return loadImage(str); } +void RenderManager::prepareBkg() { + _bkgDirtyRect.clip(_bkgWidth, _bkgHeight); + RenderTable::RenderState state = _renderTable.getRenderState(); + + if (state == RenderTable::PANORAMA) { + Common::Rect viewPort(_wrkWidth, _wrkHeight); + viewPort.translate(-(_screenCenterX - _bkgOff), 0); + Common::Rect drawRect = _bkgDirtyRect; + drawRect.clip(viewPort); + + if (!drawRect.isEmpty()) + blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - _bkgOff + drawRect.left, drawRect.top); + + _wrkWndDirtyRect = _bkgDirtyRect; + _wrkWndDirtyRect.translate(_screenCenterX - _bkgOff, 0); + + if (_bkgOff < _screenCenterX) { + viewPort.moveTo(-(_screenCenterX - (_bkgOff + _bkgWidth)), 0); + drawRect = _bkgDirtyRect; + drawRect.clip(viewPort); + + if (!drawRect.isEmpty()) + blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - (_bkgOff + _bkgWidth) + drawRect.left, drawRect.top); + + Common::Rect tmp = _bkgDirtyRect; + tmp.translate(_screenCenterX - (_bkgOff + _bkgWidth), 0); + if (!tmp.isEmpty()) + _wrkWndDirtyRect.extend(tmp); + + } else if (_bkgWidth - _bkgOff < _screenCenterX) { + viewPort.moveTo(-(_screenCenterX + _bkgWidth - _bkgOff), 0); + drawRect = _bkgDirtyRect; + drawRect.clip(viewPort); + + if (!drawRect.isEmpty()) + blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX + _bkgWidth - _bkgOff + drawRect.left, drawRect.top); + + Common::Rect tmp = _bkgDirtyRect; + tmp.translate(_screenCenterX + _bkgWidth - _bkgOff, 0); + if (!tmp.isEmpty()) + _wrkWndDirtyRect.extend(tmp); + + } + } else if (state == RenderTable::TILT) { + Common::Rect viewPort(_wrkWidth, _wrkHeight); + viewPort.translate(0, -(_screenCenterY - _bkgOff)); + Common::Rect drawRect = _bkgDirtyRect; + drawRect.clip(viewPort); + if (!drawRect.isEmpty()) + blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, drawRect.left, _screenCenterY - _bkgOff + drawRect.top); + + _wrkWndDirtyRect = _bkgDirtyRect; + _wrkWndDirtyRect.translate(0, _screenCenterY - _bkgOff); + + } else { + if (!_bkgDirtyRect.isEmpty()) + blitSurfaceToSurface(_curBkg, _bkgDirtyRect, _wrkWnd, _bkgDirtyRect.left, _bkgDirtyRect.top); + _wrkWndDirtyRect = _bkgDirtyRect; + } + + _bkgDirtyRect = Common::Rect(); + + _wrkWndDirtyRect.clip(_wrkWidth, _wrkHeight); +} + +void RenderManager::clearMenuSurface() { + _menuWndDirtyRect = Common::Rect(0, 0, _menuWnd.w, _menuWnd.h); + _menuWnd.fillRect(_menuWndDirtyRect, 0); +} + +void RenderManager::renderMenuToScreen() { + if (!_menuWndDirtyRect.isEmpty()) { + _menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h)); + + _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch, + _menuWndDirtyRect.left + _menuWndRect.left, + _menuWndDirtyRect.top + _menuWndRect.top, + _menuWndDirtyRect.width(), + _menuWndDirtyRect.height()); + _menuWndDirtyRect = Common::Rect(); + } +} + +uint16 RenderManager::createSubArea(const Common::Rect &area) { + _subid++; + + oneSub sub; + sub.redraw = false; + sub.timer = -1; + sub.todelete = false; + sub._r = area; + + _subsList[_subid] = sub; + + return _subid; +} + +void RenderManager::deleteSubArea(uint16 id) { + if (_subsList.contains(id)) + _subsList[id].todelete = true; +} + +void RenderManager::deleteSubArea(uint16 id, int16 delay) { + if (_subsList.contains(id)) + _subsList[id].timer = delay; +} + +void RenderManager::updateSubArea(uint16 id, const Common::String &txt) { + if (_subsList.contains(id)) { + oneSub *sub = &_subsList[id]; + sub->_txt = txt; + sub->redraw = true; + } +} + +void RenderManager::renderSubsToScreen() { + bool redraw = false; + for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { + if (it->_value.todelete) { + _subsList.erase(it); + redraw = true; + } else if (it->_value.redraw) { + redraw = true; + } + } + + if (redraw) { + _subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0); + + for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { + //draw subs + } + + _system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch, + _subWndRect.left, + _subWndRect.top, + _subWnd.w, + _subWnd.h); + } +} + +Common::Point RenderManager::getBkgSize() { + return Common::Point(_bkgWidth, _bkgHeight); +} + } // End of namespace ZVision diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index e16d3562dc..de53481be0 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -51,39 +51,66 @@ public: ~RenderManager(); private: - struct AlphaDataEntry { - Graphics::Surface *data; - uint16 alphaColor; - uint16 destX; - uint16 destY; - uint16 width; - uint16 height; + struct oneSub { + Common::Rect _r; + Common::String _txt; + int16 timer; + bool todelete; + bool redraw; }; - - typedef Common::HashMap AlphaEntryMap; +// struct AlphaDataEntry { +// Graphics::Surface *data; +// uint16 alphaColor; +// uint16 destX; +// uint16 destY; +// uint16 width; +// uint16 height; +// }; +// + typedef Common::HashMap subMap; private: OSystem *_system; const Graphics::PixelFormat _pixelFormat; + // A buffer for blitting background image to working window + Graphics::Surface _wrkWnd; + + Common::Rect _wrkWndDirtyRect; + + Graphics::Surface _outWnd; + + Common::Rect _outWndDirtyRect; + + Common::Rect _bkgDirtyRect; + + Graphics::Surface _subWnd; + + Common::Rect _subWndDirtyRect; + + Graphics::Surface _menuWnd; + + Common::Rect _menuWndDirtyRect; + + // A buffer the exact same size as the workingWindow // This buffer stores everything un-warped, then does a warp at the end of the frame - Graphics::Surface _workingWindowBuffer; + //Graphics::Surface _workingWindowBuffer; // A buffer representing the entire screen. Any graphical updates are first done with this buffer // before actually being blitted to the screen - Graphics::Surface _backBuffer; + //Graphics::Surface _backBuffer; // A list of Alpha Entries that need to be blitted to the backbuffer - AlphaEntryMap _alphaDataEntries; + //AlphaEntryMap _alphaDataEntries; // A rectangle representing the portion of the working window where the pixels have been changed since last frame - Common::Rect _workingWindowDirtyRect; + //Common::Rect _workingWindowDirtyRect; // A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame - Common::Rect _backBufferDirtyRect; + //Common::Rect _backBufferDirtyRect; /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */ - const int _workingWidth; + const int _wrkWidth; /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */ - const int _workingHeight; + const int _wrkHeight; /** Center of the screen in the x direction */ const int _screenCenterX; /** Center of the screen in the y direction */ @@ -95,170 +122,42 @@ private: * edges of this Rectangle */ const Common::Rect _workingWindow; + + Common::Rect _subWndRect; + + Common::Rect _menuWndRect; + /** Used to warp the background image */ RenderTable _renderTable; - Graphics::Surface _currentBackground; + Graphics::Surface _curBkg; /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */ - Common::Point _backgroundOffset; + int16 _bkgOff; /** The width of the current background image */ - uint16 _backgroundWidth; + uint16 _bkgWidth; /** The height of the current background image */ - uint16 _backgroundHeight; + uint16 _bkgHeight; + + uint16 _subid; + + subMap _subsList; /** * The "velocity" at which the background image is panning. We actually store the inverse of velocity (ms/pixel instead of pixels/ms) * because it allows you to accumulate whole pixels 'steps' instead of rounding pixels every frame */ - int _backgroundInverseVelocity; + //int _backgroundInverseVelocity; /** Holds any 'leftover' milliseconds between frames */ - uint _accumulatedVelocityMilliseconds; + //uint _accumulatedVelocityMilliseconds; public: void initialize(); - /** - * Rotates the background image in accordance to the current _backgroundInverseVelocity - * - * @param deltaTimeInMillis The amount of time that has passed since the last frame - */ - void update(uint deltaTimeInMillis); /** * Renders the current state of the backbuffer to the screen */ void renderBackbufferToScreen(); - /** - * Renders all AlphaEntries to the backbuffer - */ - void processAlphaEntries(); - /** - * Clears the AlphaEntry list - */ - void clearAlphaEntries() { - _alphaDataEntries.clear(); - } - /** - * Removes a specific AlphaEntry from the list - * - * @param idNumber The id number identifing the AlphaEntry - */ - void removeAlphaEntry(uint32 idNumber) { - _alphaDataEntries.erase(idNumber); - } - - /** - * Copies a sub-rectangle of a buffer to the working window - * - * @param buffer The pixel data to copy to the working window - * @param destX The X destination in the working window where the subRect of data should be put - * @param destY The Y destination in the working window where the subRect of data should be put - * @param imageWidth The width of the source image - * @param width The width of the sub rectangle - * @param height The height of the sub rectangle - */ - void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height); - /** - * Copies a sub-rectangle of a buffer to the working window with binary alpha support. - * - * @param buffer The pixel data to copy to the working window - * @param destX The X destination in the working window where the subRect of data should be put - * @param destY The Y destination in the working window where the subRect of data should be put - * @param imageWidth The width of the source image - * @param width The width of the sub rectangle - * @param height The height of the sub rectangle - * @param alphaColor The color to interpret as meaning 'transparent' - * @param idNumber A unique identifier for the data being copied over. - */ - void copyRectToWorkingWindow(const uint16 *buffer, int32 destX, int32 destY, int32 imageWidth, int32 width, int32 height, int16 alphaColor, uint32 idNumber); - - /** - * Renders the supplied text to the working window - * - * @param idNumber A unique identifier for the text - * @param text The text to be rendered - * @param font The font to use to render the text - * @param destX The X destination in the working window where the text should be rendered - * @param destY The Y destination in the working window where the text should be rendered - * @param textColor The color to render the text with (in RBG 565) - * @param maxWidth The max width the text should take up. - * @param maxHeight The max height the text should take up. - * @param align The alignment of the text within the bounds of maxWidth - * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit - * @return A rectangle representing where the text was drawn in the working window - */ - Common::Rect renderTextToWorkingWindow(uint32 idNumber, const Common::String &text, TruetypeFont *font, int destX, int destY, uint16 textColor, int maxWidth, int maxHeight = -1, Graphics::TextAlign align = Graphics::kTextAlignLeft, bool wrap = true); - - /** - * Fills the entire workingWindow with the specified color. Internally, the color - * will be converted to RGB 565 and then blitted. - * - * @param color The color to fill the working window with. (In RGB 555) - */ - void clearWorkingWindowTo555Color(uint16 color); - - /** - * Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame. - * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space! - * - * @param fileName Name of the image file - * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! - * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! - */ - void renderImageToScreen(const Common::String &fileName, int16 destinationX, int16 destinationY, bool wrap = false); - - /** - * Blits the image or a portion of the image to the backbuffer. Actual screen updates won't happen until the end of the frame. - * The image will be clipped to fit inside the working window. Coords are in working window space, not screen space! - * - * @param stream Surface to read the image data from - * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! - * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! - */ - void renderImageToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap = false); - - /** - * Copies a rectangla of source surface and copy to destination rect. - * - * @param src Source surface - * @param dst Destenation surface - * @param srcRect Rect of source surface - * @param dstRect Rect for destenation surface - */ - void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect); - - /** - * Copies a rectangla of source surface and copy to destination rect. - * - * @param src Source surface - * @param dst Destenation surface - * @param srcRect Rect of source surface - * @param dstRect Rect for destenation surface - * @param colorkey Transparent color - */ - void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Rect &dstRect, uint32 colorkey); - - /** - * Copies a rectangla of source surface and copy to destination rect. - * - * @param src Source surface - * @param dst Destenation surface - * @param srcRect Rect of source surface - * @param dstPt Point for destenation surface - */ - void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt); - - /** - * Copies a rectangla of source surface and copy to destination rect. - * - * @param src Source surface - * @param dst Destenation surface - * @param srcRect Rect of source surface - * @param dstPt Point for destenation surface - * @param colorkey Transparent color - */ - void copyRectToSurface(const Graphics::Surface &src, Graphics::Surface &dst, const Common::Rect &srcRect, const Common::Point &dstPt, uint32 colorkey); - /** * Blits the image or a portion of the image to the background. * @@ -268,15 +167,6 @@ public: */ void renderImageToBackground(const Common::String &fileName, int16 destinationX, int16 destinationY); - /** - * Blits the image or a portion of the image to the background. - * - * @param surface Surface to read the image data from - * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! - * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! - */ - void renderImageToBackground(const Graphics::Surface &surface, int16 destinationX, int16 destinationY); - /** * Blits the image or a portion of the image to the background. * @@ -287,16 +177,6 @@ public: */ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey); - /** - * Blits the image or a portion of the image to the background. - * - * @param surface Surface to read the image data from - * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! - * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! - * @param colorkey Transparent color - */ - void renderImageToBackground(const Graphics::Surface &surface, int16 destX, int16 destY, uint32 colorkey); - /** * Sets the current background image to be used by the RenderManager and immediately * blits it to the screen. (It won't show up until the end of the frame) @@ -317,14 +197,6 @@ public: */ void setBackgroundPosition(int offset); - /** - * Set the background scroll velocity. Negative velocities correspond to left / up scrolling and - * positive velocities correspond to right / down scrolling - * - * @param velocity Velocity - */ - void setBackgroundVelocity(int velocity); - /** * Converts a point in screen coordinate space to image coordinate space * @@ -332,29 +204,9 @@ public: * @return Point in image coordinate space */ const Common::Point screenSpaceToImageSpace(const Common::Point &point); - /** - * Converts a point in image coordinate space to ***PRE-WARP*** - * working window coordinate space - * - * @param point Point in image coordinate space - * @return Point in PRE-WARP working window coordinate space - */ - const Common::Point imageSpaceToWorkingWindowSpace(const Common::Point &point); - - /** - * Clip a rectangle to the working window. If it returns false, the original rect - * is not inside the working window. - * - * @param rect The rectangle to clip against the working window - * @return Is rect at least partially inside the working window (true) or completely outside (false) - */ - bool clipRectToWorkingWindow(Common::Rect &rect); RenderTable *getRenderTable(); uint32 getCurrentBackgroundOffset(); - const Graphics::Surface *getBackBuffer() { - return &_backBuffer; - } /** * Creates a copy of surface and transposes the data. @@ -369,31 +221,32 @@ public: void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight); - void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y); - void blitSurfaceToSurface(Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); - void blitSurfaceToBkg(Graphics::Surface &src, int x, int y); - void blitSurfaceToBkg(Graphics::Surface &src, int x, int y, uint32 colorkey); - void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y); - void blitSurfaceUpBkg(Graphics::Surface &src, int x, int y, uint32 colorkey); + + void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y); + void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey); + void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y); + void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); + void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y); + void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey); + void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y); + void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); + + uint16 createSubArea(const Common::Rect &area); + void deleteSubArea(uint16 id); + void deleteSubArea(uint16 id, int16 delay); + void updateSubArea(uint16 id, const Common::String &txt); + void renderSubsToScreen(); + + Common::Point getBkgSize(); + Graphics::Surface *getBkgRect(Common::Rect &rect); Graphics::Surface *loadImage(const char *file); Graphics::Surface *loadImage(Common::String &file); -private: - /** - * Renders a subRectangle of an image to the backbuffer. The destinationRect and SubRect - * will be clipped to image bound and to working window bounds - * - * @param buffer Pointer to (0, 0) of the image data - * @param imageWidth The width of the original image (not of the subRectangle) - * @param imageHeight The width of the original image (not of the subRectangle) - * @param horizontalPitch The horizontal pitch of the original image - * @param destinationX The x coordinate (in working window space) of where to put the final image - * @param destinationY The y coordinate (in working window space) of where to put the final image - * @param subRectangle A rectangle representing the part of the image that should be rendered - * @param wrap Should the image wrap (tile) if it doesn't completely fill the screen? - */ - void renderSubRectToScreen(Graphics::Surface &surface, int16 destinationX, int16 destinationY, bool wrap); + void clearMenuSurface(); + void renderMenuToScreen(); + + void prepareBkg(); /** * Reads an image file pixel data into a Surface buffer. In the process @@ -406,19 +259,6 @@ private: * @param destination A reference to the Surface to store the pixel data in */ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination); - - /** - * Move the background image by an offset. If we are currently in Panorama mode, - * the offset will correspond to a horizontal motion. If we are currently in Tilt mode, - * the offset will correspond to a vertical motion. This function should not be called - * if we are in Flat mode. - * - * The RenderManager will take care of wrapping the image. - * Ex: If the image has width 1400px, it is legal to offset 1500px. - * - * @param offset The amount to move the background - */ - void moveBackground(int offset); }; } // End of namespace ZVision diff --git a/engines/zvision/render_table.cpp b/engines/zvision/render_table.cpp index 5a0bae7c22..210c4fc1fb 100644 --- a/engines/zvision/render_table.cpp +++ b/engines/zvision/render_table.cpp @@ -123,6 +123,28 @@ void RenderTable::mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 d } } +void RenderTable::mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf) { + uint32 destOffset = 0; + + uint16 *sourceBuffer = (uint16 *)srcBuf->getPixels(); + uint16 *destBuffer = (uint16 *)dstBuf->getPixels(); + + for (int16 y = 0; y < srcBuf->h; ++y) { + uint32 sourceOffset = y * _numColumns; + + for (int16 x = 0; x < srcBuf->w; ++x) { + uint32 index = sourceOffset + x; + + // RenderTable only stores offsets from the original coordinates + uint32 sourceYIndex = y + _internalBuffer[index].y; + uint32 sourceXIndex = x + _internalBuffer[index].x; + + destBuffer[destOffset] = sourceBuffer[sourceYIndex * _numColumns + sourceXIndex]; + destOffset++; + } + } +} + void RenderTable::generateRenderTable() { switch (_renderState) { case ZVision::RenderTable::PANORAMA: diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h index 401e627747..db9ab08f7c 100644 --- a/engines/zvision/render_table.h +++ b/engines/zvision/render_table.h @@ -24,6 +24,7 @@ #define ZVISION_RENDER_TABLE_H #include "common/rect.h" +#include "graphics/surface.h" namespace ZVision { @@ -67,6 +68,7 @@ public: const Common::Point convertWarpedCoordToFlatCoord(const Common::Point &point); void mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect); + void mutateImage(Graphics::Surface *dstBuf, Graphics::Surface *srcBuf); void generateRenderTable(); void setPanoramaFoV(float fov); diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index e30861aa98..ddb57c80da 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -516,10 +516,10 @@ void ScriptManager::do_changeLocation() { _engine->getCursorManager()->changeCursor(CursorIndex_Idle); // Reset the background velocity - _engine->getRenderManager()->setBackgroundVelocity(0); + //_engine->getRenderManager()->setBackgroundVelocity(0); // Remove any alphaEntries - _engine->getRenderManager()->clearAlphaEntries(); + //_engine->getRenderManager()->clearAlphaEntries(); // Change the background position _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 65064d8a66..787b3ee3da 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -63,7 +63,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _stringManager(nullptr), _cursorManager(nullptr), _aud_id(0), - _rendDelay(2) { + _rendDelay(2), + _velocity(0) { debug(1, "ZVision::ZVision"); } @@ -147,13 +148,16 @@ Common::Error ZVision::run() { _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); processEvents(); + updateRotation(); // Call _renderManager->update() first so the background renders // before anything that puzzles/controls will render - _renderManager->update(deltaTime); _scriptManager->update(deltaTime); // Render the backBuffer to the screen + _renderManager->prepareBkg(); + _renderManager->renderMenuToScreen(); + _renderManager->renderSubsToScreen(); _renderManager->renderBackbufferToScreen(); // Update the screen @@ -205,4 +209,46 @@ bool ZVision::canRender() { return _rendDelay <= 0; } +void ZVision::updateRotation() { + if (_velocity) { + RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); + if (renderState == RenderTable::PANORAMA) { + int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + + int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + + int16 zero_point = 0; + if (st_pos >= zero_point && new_pos < zero_point) + _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1); + if (st_pos <= zero_point && new_pos > zero_point) + _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1); + + int16 scr_width = _renderManager->getBkgSize().x; + if (scr_width) + new_pos %= scr_width; + + if (new_pos < 0) + new_pos += scr_width; + + _scriptManager->setStateValue(StateKey_ViewPos, new_pos); + _renderManager->setBackgroundPosition(new_pos); + } else if (renderState == RenderTable::TILT) { + int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + + int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + + int16 scr_height = _renderManager->getBkgSize().y; + int16 tilt_gap = _workingWindow.height() / 2; + + if (new_pos >= (scr_height - tilt_gap)) + new_pos = scr_height - tilt_gap; + if (new_pos <= tilt_gap) + new_pos = tilt_gap; + + _scriptManager->setStateValue(StateKey_ViewPos, new_pos); + _renderManager->setBackgroundPosition(new_pos); + } + } +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 05c5fcd3a4..974384c7ff 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -111,6 +111,7 @@ private: const Common::Rect _workingWindow_ZNM; int _rendDelay; + int16 _velocity; public: uint32 getFeatures() const; Common::Language getLanguage() const; @@ -170,6 +171,7 @@ private: void onMouseDown(const Common::Point &pos); void onMouseUp(const Common::Point &pos); void onMouseMove(const Common::Point &pos); + void updateRotation(); }; } // End of namespace ZVision -- cgit v1.2.3 From e2dc6d31d27760bae85b1e00eba32011a07da178 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 12 Jan 2014 19:19:11 +0700 Subject: ZVISION: Correct RenderManager methods for support menu. --- engines/zvision/render_manager.cpp | 124 +++++++++++++++++++++++++++++++++++-- engines/zvision/render_manager.h | 4 ++ 2 files changed, 122 insertions(+), 6 deletions(-) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index bc4d169569..f5d6847cf3 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -204,6 +204,99 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: destination.convertToInPlace(_pixelFormat); } +void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) { + Common::File file; + + if (!file.open(fileName)) { + warning("Could not open file %s", fileName.c_str()); + return; + } + + // Read the magic number + // Some files are true TGA, while others are TGZ + uint32 fileType = file.readUint32BE(); + + uint32 imageWidth; + uint32 imageHeight; + Graphics::TGADecoder tga; + uint16 *buffer; + // All ZVision images are in RGB 555 + Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + destination.format = pixelFormat555; + + bool isTGZ; + + // Check for TGZ files + if (fileType == MKTAG('T', 'G', 'Z', '\0')) { + isTGZ = true; + + // TGZ files have a header and then Bitmap data that is compressed with LZSS + uint32 decompressedSize = file.readSint32LE(); + imageWidth = file.readSint32LE(); + imageHeight = file.readSint32LE(); + + LzssReadStream lzssStream(&file); + buffer = (uint16 *)(new uint16[decompressedSize]); + lzssStream.read(buffer, decompressedSize); + } else { + isTGZ = false; + + // Reset the cursor + file.seek(0); + + // Decode + if (!tga.loadStream(file)) { + warning("Error while reading TGA image"); + return; + } + + Graphics::Surface tgaSurface = *(tga.getSurface()); + imageWidth = tgaSurface.w; + imageHeight = tgaSurface.h; + + buffer = (uint16 *)tgaSurface.getPixels(); + } + + // Flip the width and height if transposed + if (transposed) { + uint16 temp = imageHeight; + imageHeight = imageWidth; + imageWidth = temp; + } + + // If the destination internal buffer is the same size as what we're copying into it, + // there is no need to free() and re-create + if (imageWidth != destination.w || imageHeight != destination.h) { + destination.create(imageWidth, imageHeight, pixelFormat555); + } + + // If transposed, 'un-transpose' the data while copying it to the destination + // Otherwise, just do a simple copy + if (transposed) { + uint16 *dest = (uint16 *)destination.getPixels(); + + for (uint32 y = 0; y < imageHeight; ++y) { + uint32 columnIndex = y * imageWidth; + + for (uint32 x = 0; x < imageWidth; ++x) { + dest[columnIndex + x] = buffer[x * imageHeight + y]; + } + } + } else { + memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel); + } + + // Cleanup + if (isTGZ) { + delete[] buffer; + } else { + tga.destroy(); + } + + // Convert in place to RGB 565 from RGB 555 + destination.convertToInPlace(_pixelFormat); +} + const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) { if (_workingWindow.contains(point)) { // Convert from screen space to working window space @@ -517,6 +610,17 @@ Graphics::Surface *RenderManager::loadImage(const char *file) { return loadImage(str); } +Graphics::Surface *RenderManager::loadImage(Common::String &file, bool transposed) { + Graphics::Surface *tmp = new Graphics::Surface; + readImageToSurface(file, *tmp, transposed); + return tmp; +} + +Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) { + Common::String str = Common::String(file); + return loadImage(str, transposed); +} + void RenderManager::prepareBkg() { _bkgDirtyRect.clip(_bkgWidth, _bkgHeight); RenderTable::RenderState state = _renderTable.getRenderState(); @@ -587,15 +691,23 @@ void RenderManager::clearMenuSurface() { _menuWnd.fillRect(_menuWndDirtyRect, 0); } +void RenderManager::clearMenuSurface(const Common::Rect &r) { + if (_menuWndDirtyRect.isEmpty()) + _menuWndDirtyRect = r; + else + _menuWndDirtyRect.extend(r); + _menuWnd.fillRect(r, 0); +} + void RenderManager::renderMenuToScreen() { if (!_menuWndDirtyRect.isEmpty()) { _menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h)); - - _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch, - _menuWndDirtyRect.left + _menuWndRect.left, - _menuWndDirtyRect.top + _menuWndRect.top, - _menuWndDirtyRect.width(), - _menuWndDirtyRect.height()); + if (!_menuWndDirtyRect.isEmpty()) + _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch, + _menuWndDirtyRect.left + _menuWndRect.left, + _menuWndDirtyRect.top + _menuWndRect.top, + _menuWndDirtyRect.width(), + _menuWndDirtyRect.height()); _menuWndDirtyRect = Common::Rect(); } } diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index de53481be0..901385b453 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -242,8 +242,11 @@ public: Graphics::Surface *getBkgRect(Common::Rect &rect); Graphics::Surface *loadImage(const char *file); Graphics::Surface *loadImage(Common::String &file); + Graphics::Surface *loadImage(const char *file, bool transposed); + Graphics::Surface *loadImage(Common::String &file, bool transposed); void clearMenuSurface(); + void clearMenuSurface(const Common::Rect &r); void renderMenuToScreen(); void prepareBkg(); @@ -259,6 +262,7 @@ public: * @param destination A reference to the Surface to store the pixel data in */ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination); + void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed); }; } // End of namespace ZVision -- cgit v1.2.3 From 52bcd6224813410aab3935a3f02de07b60abefe5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 12 Jan 2014 19:20:49 +0700 Subject: ZVISION: Fix onMouseMove rectangle for scriptManager. --- engines/zvision/events.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index d8828867b0..34b72e81d0 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -110,7 +110,7 @@ void ZVision::onMouseUp(const Common::Point &pos) { void ZVision::onMouseMove(const Common::Point &pos) { Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); - bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord); + bool cursorWasChanged = false; // Graph of the function governing rotation velocity: // @@ -143,6 +143,8 @@ void ZVision::onMouseMove(const Common::Point &pos) { // ^ if (_workingWindow.contains(pos)) { + cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord); + RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { -- cgit v1.2.3 From aef9c68f3c99908ae6027c059652b46ee758ca7b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 12 Jan 2014 19:27:11 +0700 Subject: ZVISION: Implement menus. --- engines/zvision/events.cpp | 6 + engines/zvision/menu.cpp | 774 ++++++++++++++++++++++++++++++++++++++++++++ engines/zvision/menu.h | 94 +++++- engines/zvision/module.mk | 3 +- engines/zvision/zvision.cpp | 7 + engines/zvision/zvision.h | 2 + 6 files changed, 884 insertions(+), 2 deletions(-) create mode 100644 engines/zvision/menu.cpp diff --git a/engines/zvision/events.cpp b/engines/zvision/events.cpp index 34b72e81d0..189bf007c1 100644 --- a/engines/zvision/events.cpp +++ b/engines/zvision/events.cpp @@ -29,6 +29,7 @@ #include "zvision/render_manager.h" #include "zvision/script_manager.h" #include "zvision/rlf_animation.h" +#include "zvision/menu.h" #include "common/events.h" #include "common/system.h" @@ -98,16 +99,21 @@ void ZVision::processEvents() { } void ZVision::onMouseDown(const Common::Point &pos) { + _menu->onMouseDown(pos); + Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); _scriptManager->onMouseDown(pos, imageCoord); } void ZVision::onMouseUp(const Common::Point &pos) { + _menu->onMouseUp(pos); + Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); _scriptManager->onMouseUp(pos, imageCoord); } void ZVision::onMouseMove(const Common::Point &pos) { + _menu->onMouseMove(pos); Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); bool cursorWasChanged = false; diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp new file mode 100644 index 0000000000..4c84271c47 --- /dev/null +++ b/engines/zvision/menu.cpp @@ -0,0 +1,774 @@ +/* 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 "common/scummsys.h" + +#include "zvision/menu.h" + +#include "zvision/render_manager.h" + + +namespace ZVision { + +enum { + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 +}; + +enum { + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 +}; + +menuHandler::menuHandler(ZVision *engine) { + _engine = engine; + menu_bar_flag = 0xFFFF; +} + +menuZgi::menuZgi(ZVision *engine) : + menuHandler(engine) { + menu_mousefocus = -1; + inmenu = false; + scrolled[0] = false; + scrolled[1] = false; + scrolled[2] = false; + scrollPos[0] = 0.0; + scrollPos[1] = 0.0; + scrollPos[2] = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 1; i < 4; i++) { + sprintf(buf, "gmzau%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); + sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); + } + for (int i = 0; i < 4; i++) { + sprintf(buf, "gmzmu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); + sprintf(buf, "gmznu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); + } + + for (int i = 0; i < 50; i++) { + items[i][0] = NULL; + items[i][1] = NULL; + item_id[i] = 0; + } + + for (int i = 0; i < 12; i++) { + magic[i][0] = NULL; + magic[i][1] = NULL; + magic_id[i] = 0; + } +} + +menuZgi::~menuZgi() { + for (int i = 0; i < 3; i++) { + menuback[i][0].free(); + menuback[i][1].free(); + } + for (int i = 0; i < 4; i++) { + menubar[i][0].free(); + menubar[i][1].free(); + } + for (int i = 0; i < 50; i++) { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + } + } + for (int i = 0; i < 12; i++) { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + } + } +} + +void menuZgi::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouse_item >= 0 && mouse_item < 0xE0) { + _engine->getScriptManager()->invertory_drop(mouse_item); + _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); + + redraw = true; + } + } + } + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + for (int i = 0; i < 12; i++) { + + uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (itemnum != 0) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + itemnum = 0xEE + i; + else + itemnum = 0xE0 + i; + } + if (itemnum) + if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) + _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); + } + + } + break; + + case menu_MAIN: + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + // ifquit(); + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + } + break; + } + } +} + +void menuZgi::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + if (!inmenu) + redraw = true; + inmenu = true; + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + int last_item = mouse_on_item; + + mouse_on_item = -1; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) + redraw = true; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + int last_item = mouse_on_item; + mouse_on_item = -1; + for (int i = 0; i < 12; i++) { + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) + redraw = true; + + } + break; + + case menu_MAIN: + { + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) + redraw = true; + } + break; + + default: + int cur_menu = menu_mousefocus; + if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main + menu_mousefocus = menu_MAIN; + scrolled[menu_MAIN] = false; + scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + } + + if (menu_bar_flag & menuBar_Magic) + if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic + menu_mousefocus = menu_MAGIC; + scrolled[menu_MAGIC] = false; + scrollPos[menu_MAGIC] = 28; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); + } + + if (menu_bar_flag & menuBar_Items) + if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items + menu_mousefocus = menu_ITEM; + scrolled[menu_ITEM] = false; + scrollPos[menu_ITEM] = 28 - 600; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); + } + + if (cur_menu != menu_mousefocus) + clean = true; + + break; + } + } else { + if (inmenu) + clean = true; + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + menu_mousefocus = -1; + } +} + +void menuZgi::process(uint32 deltatime) { + if (clean) { + _engine->getRenderManager()->clearMenuSurface(); + clean = false; + } + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) + if (!scrolled[menu_ITEM]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_ITEM] += scrl; + + if (scrollPos[menu_ITEM] >= 0) { + scrolled[menu_ITEM] = true; + scrollPos [menu_ITEM] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); + + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + items[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + items[i][1] = _engine->getRenderManager()->loadImage(buf, false); + item_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + + } else { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + items[i][0] = NULL; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + items[i][1] = NULL; + } + item_id[i] = 0; + } + } + + redraw = false; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) + if (!scrolled[menu_MAGIC]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAGIC] += scrl; + + if (scrollPos[menu_MAGIC] >= 600) { + scrolled[menu_MAGIC] = true; + scrollPos [menu_MAGIC] = 600; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); + + for (int i = 0; i < 12; i++) { + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (cur_item_id) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + cur_item_id = 0xEE + i; + else + cur_item_id = 0xE0 + i; + } + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); + magic_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + + } else { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + magic[i][0] = NULL; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + magic[i][1] = NULL; + } + magic_id[i] = 0; + } + } + redraw = false; + } + break; + + case menu_MAIN: + if (!scrolled[menu_MAIN]) { + redraw = true; + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAIN] += scrl; + + if (scrollPos[menu_MAIN] >= 0) { + scrolled[menu_MAIN] = true; + scrollPos [menu_MAIN] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); + + if (menu_bar_flag & menuBar_Exit) + { + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Settings) + { + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Restore) + { + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Save) + { + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); + } + redraw = false; + } + break; + default: + if (redraw) { + if (inmenu) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); + + if (menu_bar_flag & menuBar_Items) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); + + if (menu_bar_flag & menuBar_Magic) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); + } + redraw = false; + } + break; + } +} + + +menuNem::menuNem(ZVision *engine) : + menuHandler(engine) { + inmenu = false; + scrolled = false; + scrollPos = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) { + sprintf(buf, "butfrm%d%d.tga", i + 1, j); + _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); + } + + _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); + + frm = 0; +} + +menuNem::~menuNem() { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) + but[i][j].free(); + + menubar.free(); +} + +static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; + +void menuNem::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + // ifquit(); + frm = 5; + redraw = true; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + frm = 5; + redraw = true; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + frm = 5; + redraw = true; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + frm = 5; + redraw = true; + } + } +} + +void menuNem::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + inmenu = true; + + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) { + redraw = true; + frm = 0; + delay = 200; + } + } else { + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + mouse_on_item = -1; + } +} + +void menuNem::process(uint32 deltatime) { + if (inmenu) { + if (!scrolled) + { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos += scrl; + redraw = true; + } + + if (scrollPos >= 0) + { + scrolled = true; + scrollPos = 0; + } + + if (mouse_on_item != -1) { + delay -= deltatime; + if (delay <= 0 && frm < 4) { + delay = 200; + frm++; + redraw = true; + } + } + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + + if (menu_bar_flag & menuBar_Exit) + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); + + if (menu_bar_flag & menuBar_Settings) + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); + + if (menu_bar_flag & menuBar_Restore) + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); + + if (menu_bar_flag & menuBar_Save) + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); + + redraw = false; + } + } else { + scrolled = false; + if (scrollPos > -32) + { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); + _engine->getRenderManager()->clearMenuSurface(cl); + + scrollPos -= scrl; + redraw = true; + } + else + scrollPos = -32; + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + redraw = false; + } + } +} + + +} // End of namespace ZVision diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h index affc69abd5..c5938cdc3d 100644 --- a/engines/zvision/menu.h +++ b/engines/zvision/menu.h @@ -23,6 +23,98 @@ #ifndef ZVISION_MENU_H #define ZVISION_MENU_H -// TODO: Implement MenuHandler +#include "graphics/surface.h" +#include "common/rect.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" + +namespace ZVision { + +enum menuBar { + menuBar_Exit = 0x1, + menuBar_Settings = 0x2, + menuBar_Restore = 0x4, + menuBar_Save = 0x8, + menuBar_Items = 0x100, + menuBar_Magic = 0x200 +}; + +class menuHandler { +public: + menuHandler(ZVision *engine); + virtual ~menuHandler() {}; + virtual void onMouseMove(const Common::Point &Pos) {}; + virtual void onMouseDown(const Common::Point &Pos) {}; + virtual void onMouseUp(const Common::Point &Pos) {}; + virtual void process(uint32 deltaTimeInMillis) {}; +protected: + uint16 menu_bar_flag; + ZVision *_engine; +}; + +class menuZgi: public menuHandler { +public: + menuZgi(ZVision *engine); + ~menuZgi(); + void onMouseMove(const Common::Point &Pos); + void onMouseUp(const Common::Point &Pos); + void process(uint32 deltaTimeInMillis); +private: + Graphics::Surface menuback[3][2]; + Graphics::Surface menubar[4][2]; + + + Graphics::Surface *items[50][2]; + uint item_id[50]; + + Graphics::Surface *magic[12][2]; + uint magic_id[12]; + + int menu_mousefocus; + bool inmenu; + + int mouse_on_item; + + bool scrolled[3]; + float scrollPos[3]; + + enum { + menu_ITEM = 0, + menu_MAGIC = 1, + menu_MAIN = 2 + }; + + bool clean; + bool redraw; + +}; + +class menuNem: public menuHandler { +public: + menuNem(ZVision *engine); + ~menuNem(); + void onMouseMove(const Common::Point &Pos); + void onMouseUp(const Common::Point &Pos); + void process(uint32 deltaTimeInMillis); +private: + Graphics::Surface but[4][6]; + Graphics::Surface menubar; + + bool inmenu; + + int mouse_on_item; + + bool scrolled; + float scrollPos; + + bool redraw; + + int frm; + int16 delay; + +}; + +} #endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index b5512636c3..af90923f9a 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -33,7 +33,8 @@ MODULE_OBJS := \ sidefx.o \ music_node.o \ inventory_manager.o \ - slot_control.o + slot_control.o \ + menu.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 787b3ee3da..05923ce079 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -32,6 +32,7 @@ #include "zvision/string_manager.h" #include "zvision/zfs_archive.h" #include "zvision/detection.h" +#include "zvision/menu.h" #include "common/config-manager.h" #include "common/debug.h" @@ -127,6 +128,11 @@ void ZVision::initialize() { _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, &_pixelFormat); + if (_gameDescription->gameId == GID_GRANDINQUISITOR) + _menu = new menuZgi(this); + else + _menu = new menuNem(this); + // Initialize the managers _cursorManager->initialize(); _scriptManager->initialize(); @@ -153,6 +159,7 @@ Common::Error ZVision::run() { // Call _renderManager->update() first so the background renders // before anything that puzzles/controls will render _scriptManager->update(deltaTime); + _menu->process(deltaTime); // Render the backBuffer to the screen _renderManager->prepareBkg(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 974384c7ff..23c5f60a4a 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -51,6 +51,7 @@ class CursorManager; class StringManager; class SaveManager; class RlfAnimation; +class menuHandler; class ZVision : public Engine { public: @@ -97,6 +98,7 @@ private: CursorManager *_cursorManager; SaveManager *_saveManager; StringManager *_stringManager; + menuHandler *_menu; // Clock Clock _clock; -- cgit v1.2.3 From 4ced9c07e0ce55fd77c7a31261a3179b5abb7a8c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 13 Jan 2014 07:53:36 +0700 Subject: ZVISION: Fix killSideFxType iterator. --- engines/zvision/script_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index ddb57c80da..a1003197ef 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -381,7 +381,7 @@ void ScriptManager::killSideFxType(SideFX::SideFXType type) { if ((*iter)->getType() & type) { (*iter)->kill(); delete(*iter); - _activeSideFx.erase(iter); + iter = _activeSideFx.erase(iter); } else { ++iter; } -- cgit v1.2.3 From 9803f7e6c045d625ee41e5b2769b1b2de3ab8ee3 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 13 Jan 2014 09:07:44 +0700 Subject: ZVISION: Fix code style with astyle. --- engines/zvision/animation_node.cpp | 8 +-- engines/zvision/menu.cpp | 16 +++--- engines/zvision/menu.h | 18 +++---- engines/zvision/script_manager.h | 106 ++++++++++++++++++------------------- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 74b532b2ef..27ee873f98 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -191,11 +191,11 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.start = start_frame; nod.stop = end_frame; if (_fileType == RLF) { - if (nod.stop >= (int)_animation.rlf->frameCount()) - nod.stop = _animation.rlf->frameCount() - 1; + if (nod.stop >= (int)_animation.rlf->frameCount()) + nod.stop = _animation.rlf->frameCount() - 1; } else if (_fileType == AVI) { - if (nod.stop > (int)_animation.avi->getFrameCount()) - nod.stop = _animation.avi->getFrameCount(); + if (nod.stop > (int)_animation.avi->getFrameCount()) + nod.stop = _animation.avi->getFrameCount(); } nod.slot = slot; nod._cur_frm = -1; diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp index 4c84271c47..8e1dea183b 100644 --- a/engines/zvision/menu.cpp +++ b/engines/zvision/menu.cpp @@ -30,17 +30,17 @@ namespace ZVision { enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 }; enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 }; menuHandler::menuHandler(ZVision *engine) { diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h index c5938cdc3d..35e7347a3b 100644 --- a/engines/zvision/menu.h +++ b/engines/zvision/menu.h @@ -32,12 +32,12 @@ namespace ZVision { enum menuBar { - menuBar_Exit = 0x1, - menuBar_Settings = 0x2, - menuBar_Restore = 0x4, - menuBar_Save = 0x8, - menuBar_Items = 0x100, - menuBar_Magic = 0x200 + menuBar_Exit = 0x1, + menuBar_Settings = 0x2, + menuBar_Restore = 0x4, + menuBar_Save = 0x8, + menuBar_Items = 0x100, + menuBar_Magic = 0x200 }; class menuHandler { @@ -80,9 +80,9 @@ private: float scrollPos[3]; enum { - menu_ITEM = 0, - menu_MAGIC = 1, - menu_MAIN = 2 + menu_ITEM = 0, + menu_MAGIC = 1, + menu_MAIN = 2 }; bool clean; diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 2f585b6291..3e671aa3db 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -41,59 +41,59 @@ namespace ZVision { class ZVision; enum StateKey { - StateKey_World = 3, - StateKey_Room = 4, - StateKey_Node = 5, - StateKey_View = 6, - StateKey_ViewPos = 7, - StateKey_KeyPress = 8, - StateKey_InventoryItem = 9, - StateKey_LMouse = 10, - StateKey_NotSet = 11, // This key doesn't set - StateKey_Rounds = 12, - StateKey_Venus = 13, - StateKey_RMouse = 18, - StateKey_MenuState = 19, - StateKey_RestoreFlag = 20, - StateKey_Quitting = 39, - StateKey_LastWorld = 40, - StateKey_LastRoom = 41, - StateKey_LastNode = 42, - StateKey_LastView = 43, - StateKey_LastViewPos = 44, - StateKey_Menu_LastWorld = 45, - StateKey_Menu_LastRoom = 46, - StateKey_Menu_LastNode = 47, - StateKey_Menu_LastView = 48, - StateKey_Menu_LastViewPos = 49, - StateKey_KbdRotateSpeed = 50, - StateKey_Subtitles = 51, - StateKey_StreamSkipKey = 52, - StateKey_RotateSpeed = 53, - StateKey_Volume = 56, - StateKey_Qsound = 57, - StateKey_VenusEnable = 58, - StateKey_HighQuality = 59, - StateKey_VideoLineSkip = 65, - StateKey_Platform = 66, - StateKey_InstallLevel = 67, - StateKey_CountryCode = 68, - StateKey_CPU = 69, - StateKey_MovieCursor = 70, - StateKey_NoTurnAnim = 71, - StateKey_WIN958 = 72, - StateKey_ShowErrorDlg = 73, - StateKey_DebugCheats = 74, - StateKey_JapanFonts = 75, - StateKey_Brightness = 77, - StateKey_EF9_B = 91, - StateKey_EF9_G = 92, - StateKey_EF9_R = 93, - StateKey_EF9_Speed = 94, - StateKey_Inv_Cnt_Slot = 100, - StateKey_Inv_1_Slot = 101, - StateKey_Inv_49_Slot = 149, - StateKey_Inv_TotalSlots = 150 + StateKey_World = 3, + StateKey_Room = 4, + StateKey_Node = 5, + StateKey_View = 6, + StateKey_ViewPos = 7, + StateKey_KeyPress = 8, + StateKey_InventoryItem = 9, + StateKey_LMouse = 10, + StateKey_NotSet = 11, // This key doesn't set + StateKey_Rounds = 12, + StateKey_Venus = 13, + StateKey_RMouse = 18, + StateKey_MenuState = 19, + StateKey_RestoreFlag = 20, + StateKey_Quitting = 39, + StateKey_LastWorld = 40, + StateKey_LastRoom = 41, + StateKey_LastNode = 42, + StateKey_LastView = 43, + StateKey_LastViewPos = 44, + StateKey_Menu_LastWorld = 45, + StateKey_Menu_LastRoom = 46, + StateKey_Menu_LastNode = 47, + StateKey_Menu_LastView = 48, + StateKey_Menu_LastViewPos = 49, + StateKey_KbdRotateSpeed = 50, + StateKey_Subtitles = 51, + StateKey_StreamSkipKey = 52, + StateKey_RotateSpeed = 53, + StateKey_Volume = 56, + StateKey_Qsound = 57, + StateKey_VenusEnable = 58, + StateKey_HighQuality = 59, + StateKey_VideoLineSkip = 65, + StateKey_Platform = 66, + StateKey_InstallLevel = 67, + StateKey_CountryCode = 68, + StateKey_CPU = 69, + StateKey_MovieCursor = 70, + StateKey_NoTurnAnim = 71, + StateKey_WIN958 = 72, + StateKey_ShowErrorDlg = 73, + StateKey_DebugCheats = 74, + StateKey_JapanFonts = 75, + StateKey_Brightness = 77, + StateKey_EF9_B = 91, + StateKey_EF9_G = 92, + StateKey_EF9_R = 93, + StateKey_EF9_Speed = 94, + StateKey_Inv_Cnt_Slot = 100, + StateKey_Inv_1_Slot = 101, + StateKey_Inv_49_Slot = 149, + StateKey_Inv_TotalSlots = 150 }; struct Location { -- cgit v1.2.3 From 61224e7225061551765c07b691e8d8c5da3434df Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 09:32:06 +0700 Subject: ZVISION: Move MusicNode to use Audio::SoundHandle. --- engines/zvision/music_node.cpp | 9 ++++----- engines/zvision/music_node.h | 2 ++ engines/zvision/zvision.cpp | 7 ------- engines/zvision/zvision.h | 2 -- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 6be4683178..709b554823 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -57,13 +57,12 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool audioStream = makeRawZorkStream(filename, _engine); } - _id = _engine->getAudioId(); if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, loopingAudioStream, _id, _volume); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); } else { - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, 0, audioStream, _id, _volume); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); } if (_key != StateKey_NotSet) @@ -71,14 +70,14 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool } MusicNode::~MusicNode() { - _engine->_mixer->stopID(_id); + _engine->_mixer->stopHandle(_handle); if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); debug(1, "MusicNode: %d destroyed\n", _key); } bool MusicNode::process(uint32 deltaTimeInMillis) { - if (! _engine->_mixer->isSoundIDActive(_id)) + if (! _engine->_mixer->isSoundHandleActive(_handle)) return stop(); return false; } diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h index 6aed4556fa..973feaf175 100644 --- a/engines/zvision/music_node.h +++ b/engines/zvision/music_node.h @@ -23,6 +23,7 @@ #ifndef ZVISION_MUSIC_NODE_H #define ZVISION_MUSIC_NODE_H +#include "audio/mixer.h" #include "zvision/sidefx.h" namespace Common { @@ -55,6 +56,7 @@ private: bool _crossfade; int32 _crossfade_delta; int32 _crossfade_time; + Audio::SoundHandle _handle; }; } // End of namespace ZVision diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 05923ce079..f21498c315 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -201,13 +201,6 @@ Common::String ZVision::generateAutoSaveFileName() { return Common::String::format("%s.auto", _targetName.c_str()); } -int ZVision::getAudioId() { - _aud_id++; - if (_aud_id < 0) - _aud_id = 0; - return _aud_id; -} - void ZVision::setRenderDelay(uint delay) { _rendDelay = delay; } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 23c5f60a4a..26d7644eb0 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -153,8 +153,6 @@ public: */ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true); - int getAudioId(); - Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); -- cgit v1.2.3 From 41415002b223e5ae0e53fb351ee41d8a99fbc920 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 10:57:29 +0700 Subject: ZVISION: Implement PanTrack. --- engines/zvision/actions.cpp | 24 +++++++++++ engines/zvision/actions.h | 11 +++++ engines/zvision/music_node.cpp | 75 ++++++++++++++++++++++++++++++++++- engines/zvision/music_node.h | 19 +++++++-- engines/zvision/scr_file_handling.cpp | 2 +- 5 files changed, 126 insertions(+), 5 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index ccae6fd47c..3eec70d1ba 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -313,6 +313,30 @@ bool ActionMusic::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionPanTrack +////////////////////////////////////////////////////////////////////////////// + +ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey), + _pos(0), + _mus_slot(0) { + + sscanf(line.c_str(), "%u %d", &_mus_slot, &_pos); +} + +ActionPanTrack::~ActionPanTrack() { + _engine->getScriptManager()->killSideFx(_slotkey); +} + +bool ActionPanTrack::execute() { + if (_engine->getScriptManager()->getSideFX(_slotkey)) + return true; + + _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotkey, _mus_slot, _pos)); + + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionPreloadAnimation diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index aadb97fc9b..417c1ada1a 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -247,6 +247,17 @@ private: bool _universe; }; +class ActionPanTrack : public ResultAction { +public: + ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line); + ~ActionPanTrack(); + bool execute(); + +private: + int32 _pos; + uint32 _mus_slot; +}; + class ActionPlayAnimation : public ResultAction { public: ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 709b554823..081c9dbcca 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -26,6 +26,7 @@ #include "zvision/zvision.h" #include "zvision/script_manager.h" +#include "zvision/render_manager.h" #include "zvision/zork_raw.h" #include "common/stream.h" @@ -40,7 +41,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool _loop = loop; _volume = volume; _crossfade = false; - _crossfade_delta = 0; + _crossfade_target = 0; _crossfade_time = 0; _attenuate = 0; _pantrack = false; @@ -57,6 +58,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool audioStream = makeRawZorkStream(filename, _engine); } + _stereo = audioStream->isStereo(); if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); @@ -76,10 +78,81 @@ MusicNode::~MusicNode() { debug(1, "MusicNode: %d destroyed\n", _key); } +void MusicNode::setPanTrack(int16 pos) { + if (!_stereo) { + _pantrack = true; + _pantrack_X = pos; + setVolume(_volume); + } +} + +void MusicNode::unsetPanTrack() { + _pantrack = false; + setVolume(_volume); +} + bool MusicNode::process(uint32 deltaTimeInMillis) { if (! _engine->_mixer->isSoundHandleActive(_handle)) return stop(); + else { + uint8 _newvol = _volume; + + if (_pantrack || _volume != _newvol) + setVolume(_newvol); + } return false; } +void MusicNode::setVolume(uint8 new_volume) { + if (_pantrack) { + int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + cur_x -= _pantrack_X; + int32 _width = _engine->getRenderManager()->getBkgSize().x; + if (cur_x < (-_width) / 2) + cur_x += _width; + else if (cur_x >= _width / 2) + cur_x -= _width; + + float norm = (float)cur_x / ((float)_width / 2.0); + float lvl = fabs(norm); + if (lvl > 0.5) + lvl = (lvl - 0.5) * 1.7; + else + lvl = 1.0; + + float bal = sin(-norm * 3.1415926) * 127.0; + + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, bal); + _engine->_mixer->setChannelVolume(_handle, new_volume * lvl); + } + } else { + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, 0); + _engine->_mixer->setChannelVolume(_handle, new_volume); + } + } + + _volume = new_volume; +} + +PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) + : SideFX(engine, key, SIDEFX_PANTRACK) { + _slot = slot; + + SideFX *fx = _engine->getScriptManager()->getSideFX(slot); + if (fx && fx->getType() == SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + mus->setPanTrack(pos); + } +} + +PanTrackNode::~PanTrackNode() { + SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); + if (fx && fx->getType() == SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + mus->unsetPanTrack(); + } +} + } // End of namespace ZVision diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h index 973feaf175..9ccf9ab657 100644 --- a/engines/zvision/music_node.h +++ b/engines/zvision/music_node.h @@ -45,20 +45,33 @@ public: */ bool process(uint32 deltaTimeInMillis); + void setVolume(uint8 volume); + + void setPanTrack(int16 pos); + void unsetPanTrack(); private: int32 _timeLeft; bool _pantrack; int32 _pantrack_X; int32 _attenuate; - int8 _volume; - int32 _id; + uint8 _volume; bool _loop; bool _crossfade; - int32 _crossfade_delta; + uint8 _crossfade_target; int32 _crossfade_time; + bool _stereo; Audio::SoundHandle _handle; }; +class PanTrackNode : public SideFX { +public: + PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); + ~PanTrackNode(); + +private: + uint32 _slot; +}; + } // End of namespace ZVision #endif diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 4f1c3631bd..83f25a8954 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -248,7 +248,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("music", true)) { actionList.push_back(new ActionMusic(_engine, slot, args, false)); } else if (act.matchString("pan_track", true)) { - // TODO: Implement ActionPanTrack + actionList.push_back(new ActionPanTrack(_engine, slot, args)); } else if (act.matchString("playpreload", true)) { actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args)); } else if (act.matchString("preferences", true)) { -- cgit v1.2.3 From d973b1fb1bde603b3b2436a58afcf043b178c407 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 11:07:58 +0700 Subject: ZVISION: Implement attenuate code. --- engines/zvision/actions.cpp | 6 +++++- engines/zvision/actions.h | 2 +- engines/zvision/scr_file_handling.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 3eec70d1ba..92d6f6c389 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -88,7 +88,11 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S } bool ActionAttenuate::execute() { - // TODO: Implement + SideFX *fx = _engine->getScriptManager()->getSideFX(_key); + if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + mus->setVolume(255 - (abs(_attenuation) >> 7)); + } return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 417c1ada1a..b204fbeb28 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -116,7 +116,7 @@ public: private: uint32 _key; - int _attenuation; + int32 _attenuation; }; class ActionChangeLocation : public ResultAction { diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 83f25a8954..002871af0b 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -214,7 +214,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("animunload", true)) { //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); } else if (act.matchString("attenuate", true)) { - // TODO: Implement ActionAttenuate + actionList.push_back(new ActionAttenuate(_engine, slot, args)); } else if (act.matchString("assign", true)) { actionList.push_back(new ActionAssign(_engine, slot, args)); } else if (act.matchString("change_location", true)) { -- cgit v1.2.3 From 7b7ae43f7fe30782201fba691beee1bad18db60a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 11:10:17 +0700 Subject: ZVISION: Implement crossfade. --- engines/zvision/actions.cpp | 24 ++++++++++++++++++++++-- engines/zvision/actions.h | 10 +++++----- engines/zvision/music_node.cpp | 19 +++++++++++++++++++ engines/zvision/music_node.h | 3 +++ engines/zvision/scr_file_handling.cpp | 2 +- 5 files changed, 50 insertions(+), 8 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 92d6f6c389..5d1dc9a608 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -121,12 +121,32 @@ bool ActionChangeLocation::execute() { ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { sscanf(line.c_str(), - "%u %u %u %u %u %u %u", + "%u %u %d %d %d %d %d", &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); } bool ActionCrossfade::execute() { - // TODO: Implement + if (_keyOne) { + SideFX *fx = _engine->getScriptManager()->getSideFX(_keyOne); + if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + if (_oneStartVolume >= 0) + mus->setVolume((_oneStartVolume * 255) / 100); + + mus->setFade(_timeInMillis, (_oneEndVolume * 255) / 100); + } + } + + if (_keyTwo) { + SideFX *fx = _engine->getScriptManager()->getSideFX(_keyTwo); + if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + if (_twoStartVolume >= 0) + mus->setVolume((_twoStartVolume * 255) / 100); + + mus->setFade(_timeInMillis, (_twoEndVolume * 255) / 100); + } + } return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index b204fbeb28..5c6cf6c35f 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -140,11 +140,11 @@ public: private: uint32 _keyOne; uint32 _keyTwo; - uint _oneStartVolume; - uint _twoStartVolume; - uint _oneEndVolume; - uint _twoEndVolume; - uint _timeInMillis; + int32 _oneStartVolume; + int32 _twoStartVolume; + int32 _oneEndVolume; + int32 _twoEndVolume; + int32 _timeInMillis; }; class ActionDebug : public ResultAction { diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 081c9dbcca..30271480c1 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -91,12 +91,31 @@ void MusicNode::unsetPanTrack() { setVolume(_volume); } +void MusicNode::setFade(int32 time, uint8 target) { + _crossfade_target = target; + _crossfade_time = time; + _crossfade = true; +} + bool MusicNode::process(uint32 deltaTimeInMillis) { if (! _engine->_mixer->isSoundHandleActive(_handle)) return stop(); else { uint8 _newvol = _volume; + if (_crossfade) { + if (_crossfade_time > 0) { + if ((int32)deltaTimeInMillis > _crossfade_time) + deltaTimeInMillis = _crossfade_time; + _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; + _crossfade_time -= deltaTimeInMillis; + } + else { + _crossfade = false; + _newvol = _crossfade_target; + } + } + if (_pantrack || _volume != _newvol) setVolume(_newvol); } diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h index 9ccf9ab657..6e3033f6b0 100644 --- a/engines/zvision/music_node.h +++ b/engines/zvision/music_node.h @@ -49,6 +49,9 @@ public: void setPanTrack(int16 pos); void unsetPanTrack(); + + void setFade(int32 time, uint8 target); + private: int32 _timeLeft; bool _pantrack; diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 002871af0b..833db11ad1 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("change_location", true)) { actionList.push_back(new ActionChangeLocation(_engine, slot, args)); } else if (act.matchString("crossfade", true)) { - // TODO: Implement ActionCrossfade + actionList.push_back(new ActionCrossfade(_engine, slot, args)); } else if (act.matchString("debug", true)) { // TODO: Implement ActionDebug } else if (act.matchString("delay_render", true)) { -- cgit v1.2.3 From 3a1fda6d5760b25acb3bb561b567f6402685bcc6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 16:52:26 +0700 Subject: ZVISION: New class for handle rlf and avi animations. --- engines/zvision/meta_animation.cpp | 129 +++++++++++++++++++++++++++++++++++++ engines/zvision/meta_animation.h | 98 ++++++++++++++++++++++++++++ engines/zvision/module.mk | 3 +- 3 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/meta_animation.cpp create mode 100644 engines/zvision/meta_animation.h diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp new file mode 100644 index 0000000000..430b1436cb --- /dev/null +++ b/engines/zvision/meta_animation.cpp @@ -0,0 +1,129 @@ +/* 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 "common/scummsys.h" + +#include "zvision/meta_animation.h" + +#include "zvision/zvision.h" +#include "zvision/render_manager.h" +#include "zvision/script_manager.h" +#include "zvision/rlf_animation.h" +#include "zvision/zork_avi_decoder.h" + +#include "video/video_decoder.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +MetaAnimation::MetaAnimation(const Common::String &fileName) + : _fileType(RLF), + _cur_frame(NULL) { + if (fileName.hasSuffix(".rlf")) { + _fileType = RLF; + _animation.rlf = new RlfAnimation(fileName, false); + _frmDelay = _animation.rlf->frameTime(); + } else if (fileName.hasSuffix(".avi")) { + _fileType = AVI; + _animation.avi = new ZorkAVIDecoder(); + _animation.avi->loadFile(fileName); + _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); + } else { + warning("Unrecognized animation file type: %s", fileName.c_str()); + } +} + +MetaAnimation::~MetaAnimation() { + if (_fileType == RLF) { + delete _animation.rlf; + } else if (_fileType == AVI) { + delete _animation.avi; + } +} + +uint MetaAnimation::frameCount() { + if (_fileType == RLF) { + return _animation.rlf->frameCount(); + } else + return _animation.avi->getFrameCount(); + +} + +uint MetaAnimation::width() { + if (_fileType == RLF) { + return _animation.rlf->width(); + } else + return _animation.avi->getWidth(); +} +uint MetaAnimation::height() { + if (_fileType == RLF) { + return _animation.rlf->height(); + } else + return _animation.avi->getHeight(); +} +uint32 MetaAnimation::frameTime() { + return _frmDelay; +} + +void MetaAnimation::seekToFrame(int frameNumber) { + if (frameNumber >= (int)frameCount()) + frameNumber = frameCount() - 1; + + if (_fileType == RLF) { + _animation.rlf->seekToFrame(frameNumber); + } else + _animation.avi->seekToFrame(frameNumber); +} + +const Graphics::Surface *MetaAnimation::decodeNextFrame() { + if (_fileType == RLF) + _cur_frame = _animation.rlf->decodeNextFrame(); + else + _cur_frame = _animation.avi->decodeNextFrame(); + + return _cur_frame; +} + +const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { + if (frameNumber >= frameCount()) + frameNumber = frameCount() - 1; + + if (_fileType == RLF) { + _cur_frame = _animation.rlf->getFrameData(frameNumber); + return _cur_frame; + } else { + _animation.avi->seekToFrame(frameNumber); + _cur_frame = _animation.avi->decodeNextFrame(); + return _cur_frame; + } +} + +bool MetaAnimation::endOfAnimation() { + if (_fileType == RLF) { + return _animation.rlf->endOfAnimation(); + } else + return _animation.avi->endOfVideo(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h new file mode 100644 index 0000000000..fea7a6a6c1 --- /dev/null +++ b/engines/zvision/meta_animation.h @@ -0,0 +1,98 @@ +/* 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 ZVISION_METAANIM_NODE_H +#define ZVISION_METAANIM_NODE_H + +#include "zvision/sidefx.h" +#include "common/rect.h" +#include "common/list.h" + + +namespace Common { +class String; +} + +namespace Video { +class VideoDecoder; +} + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; +class RlfAnimation; + +class MetaAnimation { +public: + MetaAnimation(const Common::String &fileName); + ~MetaAnimation(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 stop; + int32 loop; + int32 _cur_frm; + int32 _delay; + Graphics::Surface *_scaled; + }; + +private: + enum FileType { + RLF = 1, + AVI = 2 + }; + +private: + union { + RlfAnimation *rlf; + Video::VideoDecoder *avi; + } _animation; + + FileType _fileType; + int32 _frmDelay; + + const Graphics::Surface *_cur_frame; + +public: + + uint frameCount(); + uint width(); + uint height(); + uint32 frameTime(); + + void seekToFrame(int frameNumber); + + const Graphics::Surface *decodeNextFrame(); + const Graphics::Surface *getFrameData(uint frameNumber); + + bool endOfAnimation(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index af90923f9a..62a1293663 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -34,7 +34,8 @@ MODULE_OBJS := \ music_node.o \ inventory_manager.o \ slot_control.o \ - menu.o + menu.o \ + meta_animation.o MODULE_DIRS += \ engines/zvision -- cgit v1.2.3 From ff2a20889cfead5075c252dd5cdcdba658a40844 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 16:54:59 +0700 Subject: ZVISION: Move code of animation_node to use meta_animation. --- engines/zvision/animation_node.cpp | 65 +++++++++++--------------------------- engines/zvision/animation_node.h | 22 +++---------- 2 files changed, 23 insertions(+), 64 deletions(-) diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 27ee873f98..11275b5c7d 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -27,10 +27,7 @@ #include "zvision/zvision.h" #include "zvision/render_manager.h" #include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/zork_avi_decoder.h" - -#include "video/video_decoder.h" +#include "zvision/meta_animation.h" #include "graphics/surface.h" @@ -39,18 +36,13 @@ namespace ZVision { AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) : SideFX(engine, controlKey, SIDEFX_ANIM), - _fileType(RLF), _DisposeAfterUse(DisposeAfterUse), - _mask(mask) { - if (fileName.hasSuffix(".rlf")) { - _fileType = RLF; - _animation.rlf = new RlfAnimation(fileName, false); - _frmDelay = _animation.rlf->frameTime(); - } else if (fileName.hasSuffix(".avi")) { - _fileType = AVI; - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadFile(fileName); - _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); + _mask(mask), + _animation(NULL) { + + if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { + _animation = new MetaAnimation(fileName); + _frmDelay = _animation->frameTime(); } else { warning("Unrecognized animation file type: %s", fileName.c_str()); } @@ -60,11 +52,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S } AnimationNode::~AnimationNode() { - if (_fileType == RLF) { - delete _animation.rlf; - } else if (_fileType == AVI) { - delete _animation.avi; - } + if (_animation) + delete _animation; _engine->getScriptManager()->setStateValue(_key, 2); @@ -92,13 +81,9 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->_cur_frm == -1) { // Start of new playlist node nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } + + _animation->seekToFrame(nod->_cur_frm); + frame = _animation->decodeNextFrame(); nod->_delay = _frmDelay; if (nod->slot) @@ -119,19 +104,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { } nod->_cur_frm = nod->start; - if (_fileType == RLF) { - _animation.rlf->seekToFrame(nod->_cur_frm); - frame = _animation.rlf->decodeNextFrame(); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(nod->_cur_frm); - frame = _animation.avi->decodeNextFrame(); - } - } else { - if (_fileType == RLF) - frame = _animation.rlf->decodeNextFrame(); - else if (_fileType == AVI) - frame = _animation.avi->decodeNextFrame(); + _animation->seekToFrame(nod->_cur_frm); } + + frame = _animation->decodeNextFrame(); } if (frame) { @@ -190,13 +166,10 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = start_frame; nod.stop = end_frame; - if (_fileType == RLF) { - if (nod.stop >= (int)_animation.rlf->frameCount()) - nod.stop = _animation.rlf->frameCount() - 1; - } else if (_fileType == AVI) { - if (nod.stop > (int)_animation.avi->getFrameCount()) - nod.stop = _animation.avi->getFrameCount(); - } + + if (nod.stop >= (int)_animation->frameCount()) + nod.stop = _animation->frameCount() - 1; + nod.slot = slot; nod._cur_frm = -1; nod._delay = 0; diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h index 843e59236b..556ab8a51f 100644 --- a/engines/zvision/animation_node.h +++ b/engines/zvision/animation_node.h @@ -32,10 +32,6 @@ namespace Common { class String; } -namespace Video { -class VideoDecoder; -} - namespace Graphics { struct Surface; } @@ -43,7 +39,7 @@ struct Surface; namespace ZVision { class ZVision; -class RlfAnimation; +class MetaAnimation; class AnimationNode : public SideFX { public: @@ -61,27 +57,17 @@ public: Graphics::Surface *_scaled; }; -private: - enum FileType { - RLF = 1, - AVI = 2 - }; - private: typedef Common::List PlayNodes; PlayNodes _playList; - union { - RlfAnimation *rlf; - Video::VideoDecoder *avi; - } _animation; - - FileType _fileType; - int32 _frmDelay; int32 _mask; bool _DisposeAfterUse; + MetaAnimation *_animation; + int32 _frmDelay; + public: bool process(uint32 deltaTimeInMillis); -- cgit v1.2.3 From 9c9f59d57060617d1acec71bd0d4066504f17c7a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 17 Jan 2014 16:56:49 +0700 Subject: ZVISION: Move lever code to use MetaAnimation. --- engines/zvision/lever_control.cpp | 34 +++++++++------------------------- engines/zvision/lever_control.h | 12 ++---------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index 9cd36cf653..e96c873033 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -28,8 +28,7 @@ #include "zvision/script_manager.h" #include "zvision/render_manager.h" #include "zvision/cursor_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/zork_avi_decoder.h" +#include "zvision/meta_animation.h" #include "zvision/utility.h" #include "common/stream.h" @@ -79,11 +78,8 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre } LeverControl::~LeverControl() { - if (_fileType == AVI) { - delete _animation.avi; - } else if (_fileType == RLF) { - delete _animation.rlf; - } + if (_animation) + delete _animation; delete[] _frameInfo; } @@ -106,14 +102,9 @@ void LeverControl::parseLevFile(const Common::String &fileName) { Common::String animationFileName(fileNameBuffer); - if (animationFileName.hasSuffix(".avi")) { - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadFile(animationFileName); - _fileType = AVI; - } else if (animationFileName.hasSuffix(".rlf")) { - _animation.rlf = new RlfAnimation(animationFileName, false); - _fileType = RLF; - } + if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf")) + _animation = new MetaAnimation(animationFileName); + } else if (line.matchString("*skipcolor*", true)) { // Not used } else if (line.matchString("*anim_coords*", true)) { @@ -379,16 +370,9 @@ void LeverControl::renderFrame(uint frameNumber) { int x = _animationCoords.left; int y = _animationCoords.top; - if (_fileType == RLF) { - // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can - frameData = _animation.rlf->getFrameData(frameNumber); - } else if (_fileType == AVI) { - _animation.avi->seekToFrame(frameNumber); - const Graphics::Surface *surface = _animation.avi->decodeNextFrame(); - frameData = surface; - } - - _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); + frameData = _animation->getFrameData(frameNumber); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); } } // End of namespace ZVision diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h index 19ecc7b9ac..591d64e949 100644 --- a/engines/zvision/lever_control.h +++ b/engines/zvision/lever_control.h @@ -32,7 +32,7 @@ namespace ZVision { class ZorkAVIDecoder; -class RlfAnimation; +class MetaAnimation; class LeverControl : public Control { public: @@ -40,10 +40,6 @@ public: ~LeverControl(); private: - enum FileType { - RLF = 1, - AVI = 2 - }; struct Direction { Direction(uint a, uint t) : angle(a), toFrame(t) {} @@ -64,11 +60,7 @@ private: }; private: - union { - RlfAnimation *rlf; - ZorkAVIDecoder *avi; - } _animation; - FileType _fileType; + MetaAnimation *_animation; Common::String _cursorName; Common::Rect _animationCoords; -- cgit v1.2.3 From 4a454ed763c24f94062be5dd57f43e0a84c1b0a2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 4 Feb 2014 08:32:02 +0700 Subject: ZVISION: New search manager for handle right handle for ZIX-files. --- engines/zvision/actions.cpp | 45 +++--- engines/zvision/animation_node.cpp | 2 +- engines/zvision/cursor.cpp | 29 ++++ engines/zvision/cursor.h | 2 + engines/zvision/cursor_manager.cpp | 24 +-- engines/zvision/lever_control.cpp | 4 +- engines/zvision/meta_animation.cpp | 8 +- engines/zvision/meta_animation.h | 3 +- engines/zvision/module.mk | 3 +- engines/zvision/music_node.cpp | 2 +- engines/zvision/render_manager.cpp | 10 +- engines/zvision/render_manager.h | 3 +- engines/zvision/rlf_animation.cpp | 116 +++++++++----- engines/zvision/rlf_animation.h | 3 +- engines/zvision/scr_file_handling.cpp | 3 +- engines/zvision/search_manager.cpp | 274 ++++++++++++++++++++++++++++++++++ engines/zvision/search_manager.h | 51 +++++++ engines/zvision/zork_raw.cpp | 2 +- engines/zvision/zvision.cpp | 27 +++- engines/zvision/zvision.h | 5 + 20 files changed, 518 insertions(+), 98 deletions(-) create mode 100644 engines/zvision/search_manager.cpp create mode 100644 engines/zvision/search_manager.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 5d1dc9a608..7b9050f47a 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -312,27 +312,11 @@ ActionMusic::~ActionMusic() { bool ActionMusic::execute() { if (_engine->getScriptManager()->getSideFX(_slotkey)) return true; - Common::File *file = new Common::File(); - if (!file->exists(_fileName) && _fileName.size() >= 12) { - _fileName.setChar('r', 9); - _fileName.setChar('a', 10); - _fileName.setChar('w', 11); - if (!file->exists(_fileName)) { - _fileName.setChar('i', 9); - _fileName.setChar('f', 10); - _fileName.setChar('p', 11); - if (!file->exists(_fileName)) { - _fileName.setChar('s', 9); - _fileName.setChar('r', 10); - _fileName.setChar('c', 11); - if (!file->exists(_fileName)) - return true; - } - } - } - if (file->exists(_fileName)) - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); - delete file; + + if (!_engine->getSearchManager()->hasFile(_fileName)) + return true; + + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); return true; } @@ -585,16 +569,21 @@ ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Commo bool ActionStreamVideo::execute() { ZorkAVIDecoder decoder; - if (!decoder.loadFile(_fileName)) { - return true; - } + Common::File *_file = _engine->getSearchManager()->openFile(_fileName); + + if (_file) { + if (!decoder.loadStream(_file)) { + return true; + } + + Common::Rect destRect; + if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) { + destRect = Common::Rect(_x1, _y1, _x2, _y2); + } - Common::Rect destRect; - if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) { - destRect = Common::Rect(_x1, _y1, _x2, _y2); + _engine->playVideo(decoder, destRect, _skippable); } - _engine->playVideo(decoder, destRect, _skippable); return true; } diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 11275b5c7d..89d0f5e451 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -41,7 +41,7 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _animation(NULL) { if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { - _animation = new MetaAnimation(fileName); + _animation = new MetaAnimation(fileName, engine); _frmDelay = _animation->frameTime(); } else { warning("Unrecognized animation file type: %s", fileName.c_str()); diff --git a/engines/zvision/cursor.cpp b/engines/zvision/cursor.cpp index 5386c8ead6..e2e3d7ee72 100644 --- a/engines/zvision/cursor.cpp +++ b/engines/zvision/cursor.cpp @@ -66,6 +66,35 @@ ZorkCursor::ZorkCursor(const Common::String &fileName) _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); } +ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) + : _width(0), + _height(0), + _hotspotX(0), + _hotspotY(0) { + Common::File file; + if (!engine->getSearchManager()->openFile(file, fileName)) + return; + + uint32 magic = file.readUint32BE(); + if (magic != MKTAG('Z', 'C', 'R', '1')) { + warning("%s is not a Zork Cursor file", fileName.c_str()); + return; + } + + _hotspotX = file.readUint16LE(); + _hotspotY = file.readUint16LE(); + _width = file.readUint16LE(); + _height = file.readUint16LE(); + + uint dataSize = _width * _height * sizeof(uint16); + _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + uint32 bytesRead = file.read(_surface.getPixels(), dataSize); + assert(bytesRead == dataSize); + + // Convert to RGB 565 + _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); +} + ZorkCursor::ZorkCursor(const ZorkCursor &other) { _width = other._width; _height = other._height; diff --git a/engines/zvision/cursor.h b/engines/zvision/cursor.h index 8f119c8982..2304bf4c82 100644 --- a/engines/zvision/cursor.h +++ b/engines/zvision/cursor.h @@ -24,6 +24,7 @@ #define ZVISION_CURSOR_H #include "graphics/surface.h" +#include "zvision/zvision.h" namespace Common { @@ -40,6 +41,7 @@ class ZorkCursor { public: ZorkCursor(); ZorkCursor(const Common::String &fileName); + ZorkCursor(ZVision *engine, const Common::String &fileName); ZorkCursor(const ZorkCursor &other); ~ZorkCursor(); diff --git a/engines/zvision/cursor_manager.cpp b/engines/zvision/cursor_manager.cpp index aaf3bb8ee4..c66fa650a8 100644 --- a/engines/zvision/cursor_manager.cpp +++ b/engines/zvision/cursor_manager.cpp @@ -57,15 +57,15 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel if (_engine->getGameId() == GID_NEMESIS) { Common::String name; name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); - _cursors[i][0] = ZorkCursor(name); // Up cursor + _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); - _cursors[i][1] = ZorkCursor(name); // Down cursor + _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - _cursors[i][0] = ZorkCursor(_zgiCursorFileNames[i]); // Up cursor + _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor char buffer[25]; strcpy(buffer, _zgiCursorFileNames[i]); buffer[3] += 2; - _cursors[i][1] = ZorkCursor(buffer); // Down cursor + _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor } } } @@ -76,22 +76,22 @@ void CursorManager::setItemID(int id) { Common::String file; if (_engine->getGameId() == GID_NEMESIS) { file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a'); - _cursors[NUM_CURSORS][0] = ZorkCursor(file); + _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b'); - _cursors[NUM_CURSORS][1] = ZorkCursor(file); + _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a'); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b'); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id); - _cursors[NUM_CURSORS][0] = ZorkCursor(file); + _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id); - _cursors[NUM_CURSORS][1] = ZorkCursor(file); + _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(file); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id); - _cursors[NUM_CURSORS + 1][1] = ZorkCursor(file); + _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file); } else return; } diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index e96c873033..33aa2be592 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -86,7 +86,7 @@ LeverControl::~LeverControl() { void LeverControl::parseLevFile(const Common::String &fileName) { Common::File file; - if (!file.open(fileName)) { + if (!_engine->getSearchManager()->openFile(file, fileName)) { warning("LEV file %s could could be opened", fileName.c_str()); return; } @@ -103,7 +103,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { Common::String animationFileName(fileNameBuffer); if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf")) - _animation = new MetaAnimation(animationFileName); + _animation = new MetaAnimation(animationFileName, _engine); } else if (line.matchString("*skipcolor*", true)) { // Not used diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp index 430b1436cb..33ae92a523 100644 --- a/engines/zvision/meta_animation.cpp +++ b/engines/zvision/meta_animation.cpp @@ -37,17 +37,19 @@ namespace ZVision { -MetaAnimation::MetaAnimation(const Common::String &fileName) +MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) : _fileType(RLF), _cur_frame(NULL) { if (fileName.hasSuffix(".rlf")) { _fileType = RLF; - _animation.rlf = new RlfAnimation(fileName, false); + Common::File *_file = engine->getSearchManager()->openFile(fileName); + _animation.rlf = new RlfAnimation(_file, false); _frmDelay = _animation.rlf->frameTime(); } else if (fileName.hasSuffix(".avi")) { _fileType = AVI; + Common::File *_file = engine->getSearchManager()->openFile(fileName); _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadFile(fileName); + _animation.avi->loadStream(_file); _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); } else { warning("Unrecognized animation file type: %s", fileName.c_str()); diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h index fea7a6a6c1..e259955891 100644 --- a/engines/zvision/meta_animation.h +++ b/engines/zvision/meta_animation.h @@ -24,6 +24,7 @@ #define ZVISION_METAANIM_NODE_H #include "zvision/sidefx.h" +#include "zvision/zvision.h" #include "common/rect.h" #include "common/list.h" @@ -47,7 +48,7 @@ class RlfAnimation; class MetaAnimation { public: - MetaAnimation(const Common::String &fileName); + MetaAnimation(const Common::String &fileName, ZVision *engine); ~MetaAnimation(); struct playnode { diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 62a1293663..b8dca9e63a 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -35,7 +35,8 @@ MODULE_OBJS := \ inventory_manager.o \ slot_control.o \ menu.o \ - meta_animation.o + meta_animation.o \ + search_manager.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 30271480c1..d47a796382 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -51,7 +51,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool if (filename.contains(".wav")) { Common::File *file = new Common::File(); - if (file->open(filename)) { + if (_engine->getSearchManager()->openFile(*file, filename)) { audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); } } else { diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index f5d6847cf3..6cfc0509c7 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" +#include "zvision/zvision.h" #include "zvision/render_manager.h" #include "zvision/lzss_read_stream.h" @@ -37,8 +38,9 @@ namespace ZVision { -RenderManager::RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) - : _system(system), +RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) + : _engine(engine), + _system(engine->_system), _wrkWidth(workingWindow.width()), _wrkHeight(workingWindow.height()), _screenCenterX(_wrkWidth / 2), @@ -113,7 +115,7 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1 void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) { Common::File file; - if (!file.open(fileName)) { + if (!_engine->getSearchManager()->openFile(file, fileName)) { warning("Could not open file %s", fileName.c_str()); return; } @@ -207,7 +209,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) { Common::File file; - if (!file.open(fileName)) { + if (!_engine->getSearchManager()->openFile(file, fileName)) { warning("Could not open file %s", fileName.c_str()); return; } diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 901385b453..3c03331d0f 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -47,7 +47,7 @@ namespace ZVision { class RenderManager { public: - RenderManager(OSystem *system, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat); + RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat); ~RenderManager(); private: @@ -70,6 +70,7 @@ private: typedef Common::HashMap subMap; private: + ZVision *_engine; OSystem *_system; const Graphics::PixelFormat _pixelFormat; diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index dab32aed17..f23f569d98 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -37,6 +37,7 @@ namespace ZVision { RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) : _stream(stream), + _readStream(NULL), _lastFrameRead(0), _frameCount(0), _width(0), @@ -45,11 +46,15 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) _frames(0), _currentFrame(0), _frameBufferByteSize(0) { - if (!_file.open(fileName)) { + + Common::File *_file = new Common::File; + if (!_file->open(fileName)) { warning("RLF animation file %s could not be opened", fileName.c_str()); return; } + _readStream = _file; + if (!readHeader()) { warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str()); return; @@ -68,59 +73,90 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) } } +RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream) + : _stream(stream), + _readStream(rstream), + _lastFrameRead(0), + _frameCount(0), + _width(0), + _height(0), + _frameTime(0), + _frames(0), + _currentFrame(0), + _frameBufferByteSize(0) { + + if (!readHeader()) { + warning("Stream is not a RLF animation. Wrong magic number"); + return; + } + + _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); + _frameBufferByteSize = _width * _height * sizeof(uint16); + + if (!stream) { + _frames = new Frame[_frameCount]; + + // Read in each frame + for (uint i = 0; i < _frameCount; ++i) { + _frames[i] = readNextFrame(); + } + } +} + RlfAnimation::~RlfAnimation() { for (uint i = 0; i < _frameCount; ++i) { delete[] _frames[i].encodedData; } delete[] _frames; + delete _readStream; _currentFrameBuffer.free(); } bool RlfAnimation::readHeader() { - if (_file.readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { + if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { return false; } // Read the header - _file.readUint32LE(); // Size1 - _file.readUint32LE(); // Unknown1 - _file.readUint32LE(); // Unknown2 - _frameCount = _file.readUint32LE(); // Frame count + _readStream->readUint32LE(); // Size1 + _readStream->readUint32LE(); // Unknown1 + _readStream->readUint32LE(); // Unknown2 + _frameCount = _readStream->readUint32LE(); // Frame count // Since we don't need any of the data, we can just seek right to the // entries we need rather than read in all the individual entries. - _file.seek(136, SEEK_CUR); + _readStream->seek(136, SEEK_CUR); //// Read CIN header - //_file.readUint32BE(); // Magic number FNIC - //_file.readUint32LE(); // Size2 - //_file.readUint32LE(); // Unknown3 - //_file.readUint32LE(); // Unknown4 - //_file.readUint32LE(); // Unknown5 - //_file.seek(0x18, SEEK_CUR); // VRLE - //_file.readUint32LE(); // LRVD - //_file.readUint32LE(); // Unknown6 - //_file.seek(0x18, SEEK_CUR); // HRLE - //_file.readUint32LE(); // ELHD - //_file.readUint32LE(); // Unknown7 - //_file.seek(0x18, SEEK_CUR); // HKEY - //_file.readUint32LE(); // ELRH + //_readStream->readUint32BE(); // Magic number FNIC + //_readStream->readUint32LE(); // Size2 + //_readStream->readUint32LE(); // Unknown3 + //_readStream->readUint32LE(); // Unknown4 + //_readStream->readUint32LE(); // Unknown5 + //_readStream->seek(0x18, SEEK_CUR); // VRLE + //_readStream->readUint32LE(); // LRVD + //_readStream->readUint32LE(); // Unknown6 + //_readStream->seek(0x18, SEEK_CUR); // HRLE + //_readStream->readUint32LE(); // ELHD + //_readStream->readUint32LE(); // Unknown7 + //_readStream->seek(0x18, SEEK_CUR); // HKEY + //_readStream->readUint32LE(); // ELRH //// Read MIN info header - //_file.readUint32BE(); // Magic number FNIM - //_file.readUint32LE(); // Size3 - //_file.readUint32LE(); // OEDV - //_file.readUint32LE(); // Unknown8 - //_file.readUint32LE(); // Unknown9 - //_file.readUint32LE(); // Unknown10 - _width = _file.readUint32LE(); // Width - _height = _file.readUint32LE(); // Height + //_readStream->readUint32BE(); // Magic number FNIM + //_readStream->readUint32LE(); // Size3 + //_readStream->readUint32LE(); // OEDV + //_readStream->readUint32LE(); // Unknown8 + //_readStream->readUint32LE(); // Unknown9 + //_readStream->readUint32LE(); // Unknown10 + _width = _readStream->readUint32LE(); // Width + _height = _readStream->readUint32LE(); // Height // Read time header - _file.readUint32BE(); // Magic number EMIT - _file.readUint32LE(); // Size4 - _file.readUint32LE(); // Unknown11 - _frameTime = _file.readUint32LE() / 10; // Frame time in microseconds + _readStream->readUint32BE(); // Magic number EMIT + _readStream->readUint32LE(); // Size4 + _readStream->readUint32LE(); // Unknown11 + _frameTime = _readStream->readUint32LE() / 10; // Frame time in microseconds return true; } @@ -128,17 +164,17 @@ bool RlfAnimation::readHeader() { RlfAnimation::Frame RlfAnimation::readNextFrame() { RlfAnimation::Frame frame; - _file.readUint32BE(); // Magic number MARF - uint32 size = _file.readUint32LE(); // Size - _file.readUint32LE(); // Unknown1 - _file.readUint32LE(); // Unknown2 - uint32 type = _file.readUint32BE(); // Either ELHD or ELRH - uint32 headerSize = _file.readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28 - _file.readUint32LE(); // Unknown3 + _readStream->readUint32BE(); // Magic number MARF + uint32 size = _readStream->readUint32LE(); // Size + _readStream->readUint32LE(); // Unknown1 + _readStream->readUint32LE(); // Unknown2 + uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH + uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28 + _readStream->readUint32LE(); // Unknown3 frame.encodedSize = size - headerSize; frame.encodedData = new int8[frame.encodedSize]; - _file.read(frame.encodedData, frame.encodedSize); + _readStream->read(frame.encodedData, frame.encodedSize); if (type == MKTAG('E', 'L', 'H', 'D')) { frame.type = Masked; diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index 35916de6cb..3764465786 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -37,6 +37,7 @@ namespace ZVision { class RlfAnimation { public: RlfAnimation(const Common::String &fileName, bool stream = true); + RlfAnimation(Common::SeekableReadStream *rstream, bool stream); ~RlfAnimation(); private: @@ -52,7 +53,7 @@ private: }; private: - Common::File _file; + Common::SeekableReadStream *_readStream; bool _stream; uint _lastFrameRead; diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 833db11ad1..db4e8fa9b1 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" +#include "zvision/zvision.h" #include "zvision/script_manager.h" #include "zvision/utility.h" @@ -40,7 +41,7 @@ namespace ZVision { void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) { Common::File file; - if (!file.open(fileName)) { + if (!_engine->getSearchManager()->openFile(file, fileName)) { warning("Script file not found: %s", fileName.c_str()); return; } diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp new file mode 100644 index 0000000000..5c94ff0a26 --- /dev/null +++ b/engines/zvision/search_manager.cpp @@ -0,0 +1,274 @@ +/* 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 "common/debug.h" + +#include "zvision/search_manager.h" +#include "zvision/zfs_archive.h" +#include "common/fs.h" +#include "common/stream.h" + + +namespace ZVision { + +sManager::sManager(const Common::String &root_path, int depth) { + _root = root_path; + if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') + _root.deleteLastChar(); + + Common::FSNode fs_node(_root); + + list_dir_recursive(dir_list, fs_node, depth); + + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) + if (it->size() == _root.size()) + it = dir_list.erase(it); + else if (it->size() > _root.size()) { + *it = Common::String(it->c_str() + _root.size() + 1); + it++; + } else + it++; +} + +sManager::~sManager() { + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + delete *it; + it++; + } + + archList.clear(); +} + +void sManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lw_name = dst; + lw_name.toLowercase(); + + sManager::MatchList::iterator it = files.find(lw_name); + + if (it != files.end()) { + lw_name = src; + lw_name.toLowercase(); + files[lw_name] = it->_value; + } +} + +void sManager::addFile(const Common::String &name, Common::Archive *arch) { + bool addArch = true; + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + if (*it == arch) { + addArch = false; + break; + } + it++; + } + if (addArch) + archList.push_back(arch); + + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::Node nod; + nod.name = lw_name; + nod.arch = arch; + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit == files.end()) { + files[lw_name] = nod; + } else { + Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); + if (stream) { + if (stream->size() < 10) + fit->_value.arch = arch; + delete stream; + } else { + files[lw_name] = nod; + } + } +} + +Common::File *sManager::openFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) { + Common::File *tmp = new Common::File(); + tmp->open(fit->_value.name, *fit->_value.arch); + return tmp; + } + return NULL; +} + +bool sManager::openFile(Common::File &file, const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return file.open(fit->_value.name, *fit->_value.arch); + return false; +} + +bool sManager::hasFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return true; + return false; +} + +void sManager::loadZix(const Common::String &name) { + Common::File file; + file.open(name); + + Common::String line; + + while (!file.eos()) { + line = file.readLine(); + if (line.matchString("----------*", true)) + break; + } + + if (file.eos()) + return; + + Common::Array archives; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + if (line.matchString("----------*", true)) + break; + else if (line.matchString("DIR:*", true)) { + Common::String path(line.c_str() + 5); + Common::Archive *arc; + char n_path[128]; + strcpy(n_path, path.c_str()); + for (uint i = 0; i < path.size(); i++) + if (n_path[i] == '\\') + n_path[i] = '/'; + + path = Common::String(n_path); + if (path.size() && path[0] == '.') + path.deleteChar(0); + if (path.size() && path[0] == '/') + path.deleteChar(0); + + if (path.matchString("*.zfs", true)) + arc = new ZfsArchive(path); + else { + if (path.size()) { + if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') + path.deleteLastChar(); + if (path.size()) + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + arc = new Common::FSDirectory(path); + } + archives.push_back(arc); + } + } + + if (file.eos()) + return; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + uint dr = 0; + char buf[32]; + if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { + if (dr < archives.size() && dr > 0) { + addFile(Common::String(buf), archives[dr - 1]); + } + } + } +} + +void sManager::addDir(const Common::String &name) { + Common::String path; + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (name.equalsIgnoreCase(*it)) { + path = *it; + break; + } + + if (path.size() == 0) + return; + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + Common::FSDirectory *dir = new Common::FSDirectory(path); + + Common::ArchiveMemberList list; + dir->listMatchingMembers(list, "*.zfs"); + + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + + ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); + + Common::ArchiveMemberList zfslist; + zfs->listMembers(zfslist); + + for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { + Common::String z_name = (*ziter)->getName(); + addFile(z_name, zfs); + } + } + + list.clear(); + dir->listMembers(list); + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + addFile(flname, dir); + } +} + +void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { + Common::FSList fs_list; + fs_node.getChildren(fs_list); + + _list.push_back(fs_node.getPath()); + + if (depth > 1) + for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) + list_dir_recursive(_list, *it, depth - 1); +} + +} // End of namespace ZVision diff --git a/engines/zvision/search_manager.h b/engines/zvision/search_manager.h new file mode 100644 index 0000000000..c768cb8b00 --- /dev/null +++ b/engines/zvision/search_manager.h @@ -0,0 +1,51 @@ +#ifndef SEARCH_MANAGER_H_INCLUDED +#define SEARCH_MANAGER_H_INCLUDED + +#include "common/str.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/archive.h" +#include "common/file.h" +#include "common/list.h" + +namespace ZVision { + +class sManager { +public: + sManager(const Common::String &root_path, int depth); + ~sManager(); + + void addFile(const Common::String &name, Common::Archive *arch); + void addDir(const Common::String &name); + void addPatch(const Common::String &src, const Common::String &dst); + + Common::File *openFile(const Common::String &name); + bool openFile(Common::File &file, const Common::String &name); + bool hasFile(const Common::String &name); + + void loadZix(const Common::String &name); + +private: + + void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); + + struct Node { + Common::String name; + Common::Archive *arch; + }; + + Common::List dir_list; + + typedef Common::HashMap MatchList; + + Common::List archList; + MatchList files; + + Common::String _root; + +private: +}; + +} + +#endif // SEARCH_MANAGER_H_INCLUDED diff --git a/engines/zvision/zork_raw.cpp b/engines/zvision/zork_raw.cpp index e7cc71a70b..a4d091f3c0 100644 --- a/engines/zvision/zork_raw.cpp +++ b/engines/zvision/zork_raw.cpp @@ -254,7 +254,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) { Common::File *file = new Common::File(); - assert(file->open(filePath)); + assert(engine->getSearchManager()->openFile(*file, filePath)); Common::String fileName = getFileName(filePath); fileName.toLowercase(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index f21498c315..bf945f859a 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -33,8 +33,10 @@ #include "zvision/zfs_archive.h" #include "zvision/detection.h" #include "zvision/menu.h" +#include "zvision/search_manager.h" #include "common/config-manager.h" +#include "common/str.h" #include "common/debug.h" #include "common/debug-channels.h" #include "common/textconsole.h" @@ -88,6 +90,29 @@ ZVision::~ZVision() { void ZVision::initialize() { const Common::FSNode gameDataDir(ConfMan.get("path")); + + _searchManager = new sManager(ConfMan.get("path"), 6); + + _searchManager->addDir("addon"); + + if (_gameDescription->gameId == GID_GRANDINQUISITOR) { + _searchManager->loadZix("INQUIS.ZIX"); + _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC"); + _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC"); + _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC"); + _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC"); + _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC"); + _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC"); + _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC"); + _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC"); + _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC"); + _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC"); + _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC"); + _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC"); + _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC"); + _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); + } else if (_gameDescription->gameId == GID_NEMESIS) + _searchManager->loadZix("NEMESIS.ZIX"); // TODO: There are 10 file clashes when we flatten the directories. // From a quick look, the files are exactly the same, so it shouldn't matter. // But I'm noting it here just in-case it does become a problem. @@ -123,7 +148,7 @@ void ZVision::initialize() { // Create managers _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(_system, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat); _saveManager = new SaveManager(this); _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, &_pixelFormat); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 26d7644eb0..c9e14e8651 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -26,6 +26,7 @@ #include "zvision/detection.h" #include "zvision/clock.h" +#include "zvision/search_manager.h" #include "common/random.h" #include "common/events.h" @@ -99,6 +100,7 @@ private: SaveManager *_saveManager; StringManager *_stringManager; menuHandler *_menu; + sManager *_searchManager; // Clock Clock _clock; @@ -135,6 +137,9 @@ public: StringManager *getStringManager() const { return _stringManager; } + sManager *getSearchManager() const { + return _searchManager; + } Common::RandomSource *getRandomSource() const { return _rnd; } -- cgit v1.2.3 From 00337400010efc1012e95ec0c14a77423bb3a0ee Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Feb 2014 16:07:52 +0700 Subject: ZVISION: Fix lever code; --- engines/zvision/lever_control.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/engines/zvision/lever_control.cpp b/engines/zvision/lever_control.cpp index 33aa2be592..f68f256229 100644 --- a/engines/zvision/lever_control.cpp +++ b/engines/zvision/lever_control.cpp @@ -91,9 +91,11 @@ void LeverControl::parseLevFile(const Common::String &fileName) { return; } - Common::String line = file.readLine(); + Common::String line; while (!file.eos()) { + line = file.readLine(); + if (line.matchString("*animation_id*", true)) { // Not used } else if (line.matchString("*filename*", true)) { @@ -142,6 +144,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) { uint frameNumber; uint x, y; + line.toLowercase(); + if (sscanf(line.c_str(), "%u:%u %u", &frameNumber, &x, &y) == 3) { _frameInfo[frameNumber].hotspot.left = x; _frameInfo[frameNumber].hotspot.top = y; @@ -149,13 +153,13 @@ void LeverControl::parseLevFile(const Common::String &fileName) { _frameInfo[frameNumber].hotspot.bottom = y + _hotspotDelta.y; } - Common::StringTokenizer tokenizer(line, " ^=()"); + Common::StringTokenizer tokenizer(line, " ^=()~"); tokenizer.nextToken(); tokenizer.nextToken(); Common::String token = tokenizer.nextToken(); while (!tokenizer.empty()) { - if (token == "D") { + if (token == "d") { token = tokenizer.nextToken(); uint angle; @@ -163,7 +167,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { sscanf(token.c_str(), "%u,%u", &toFrame, &angle); _frameInfo[frameNumber].directions.push_back(Direction(angle, toFrame)); - } else if (token.hasPrefix("P")) { + } else if (token.hasPrefix("p")) { // Format: P( to ) tokenizer.nextToken(); tokenizer.nextToken(); @@ -177,7 +181,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { } } - line = file.readLine(); + // Don't read lines in this place because last will not be parsed. } } @@ -290,7 +294,7 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm // Calculate the angle using arctan // Then convert to degrees. (180 / 3.14159 = 57.2958) - int angle = int(atan((float)yDist / (float)xDist) * 57); + int angle = int(atan((float)yDist / (float)abs(xDist)) * 57); // Calculate what quadrant pointTwo is in uint quadrant = ((yDist > 0 ? 1 : 0) << 1) | (xDist < 0 ? 1 : 0); @@ -339,16 +343,16 @@ int LeverControl::calculateVectorAngle(const Common::Point &pointOne, const Comm // Convert the local angles to unit circle angles switch (quadrant) { case 0: - angle = 180 + angle; + angle = -angle; break; case 1: - // Do nothing + angle = angle + 180; break; case 2: - angle = 180 + angle; + angle = 360 - angle; break; case 3: - angle = 360 + angle; + angle = 180 + angle; break; } -- cgit v1.2.3 From cb2503aa9dd5d76a12aaf0522ddea810907a97a5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Feb 2014 23:03:02 +0700 Subject: ZVISION: Refactor of pushtoggle code, now full functional implementation. --- engines/zvision/push_toggle_control.cpp | 51 ++++++++++++++++++++++++++++++--- engines/zvision/push_toggle_control.h | 12 ++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/engines/zvision/push_toggle_control.cpp b/engines/zvision/push_toggle_control.cpp index 86f499739c..0ba6dd7d25 100644 --- a/engines/zvision/push_toggle_control.cpp +++ b/engines/zvision/push_toggle_control.cpp @@ -35,10 +35,13 @@ namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key) { + : Control(engine, key), + _countTo(2), + _event(Common::EVENT_LBUTTONUP) { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + line.toLowercase(); while (!stream.eos() && !line.contains('}')) { if (line.matchString("*_hotspot*", true)) { @@ -56,6 +59,27 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer); _hoverCursor = Common::String(nameBuffer); + } else if (line.matchString("animation*", true)) { + // Not used + } else if (line.matchString("sound*", true)) { + // Not used + } else if (line.matchString("count_to*", true)) { + sscanf(line.c_str(), "%*[^(](%u)", &_countTo); + } else if (line.matchString("mouse_event*", true)) { + char nameBuffer[25]; + + sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer); + + Common::String evntStr(nameBuffer); + if (evntStr.equalsIgnoreCase("up")) { + _event = Common::EVENT_LBUTTONUP; + } else if (evntStr.equalsIgnoreCase("down")) { + _event = Common::EVENT_LBUTTONDOWN; + } else if (evntStr.equalsIgnoreCase("double")) { + // Not used + } + } else if (line.matchString("venus_id*", true)) { + // Not used } line = stream.readLine(); @@ -68,16 +92,35 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab } PushToggleControl::~PushToggleControl() { - // Clear the state value back to 0 - _engine->getScriptManager()->setStateValue(_key, 0); } bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; + if (_event != Common::EVENT_LBUTTONUP) + return false; + + if (_hotspot.contains(backgroundImageSpacePos)) { + int32 val = _engine->getScriptManager()->getStateValue(_key); + val = (val + 1) % _countTo; + _engine->getScriptManager()->setStateValue(_key, val); + return true; + } + return false; +} + +bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_event != Common::EVENT_LBUTTONDOWN) + return false; + if (_hotspot.contains(backgroundImageSpacePos)) { - _engine->getScriptManager()->setStateValue(_key, 1); + int32 val = _engine->getScriptManager()->getStateValue(_key); + val = (val + 1) % _countTo; + _engine->getScriptManager()->setStateValue(_key, val); return true; } return false; diff --git a/engines/zvision/push_toggle_control.h b/engines/zvision/push_toggle_control.h index 1de279aa08..17ff850e32 100644 --- a/engines/zvision/push_toggle_control.h +++ b/engines/zvision/push_toggle_control.h @@ -26,6 +26,7 @@ #include "zvision/control.h" #include "common/rect.h" +#include "common/events.h" namespace ZVision { @@ -35,6 +36,13 @@ public: PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); ~PushToggleControl(); + /** + * Called when LeftMouse is pushed. Default is NOP. + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); /** * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); * @@ -60,6 +68,10 @@ private: Common::Rect _hotspot; /** The cursor to use when hovering over _hotspot */ Common::String _hoverCursor; + /** Button maximal values count */ + uint _countTo; + + Common::EventType _event; }; } // End of namespace ZVision -- cgit v1.2.3 From 6210ead126ea81727e6a68398366c4cbe8da9e79 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 20:37:58 +0700 Subject: ZVISION: Fix wrong style. --- engines/zvision/actions.h | 2 +- engines/zvision/cursor_manager.h | 18 +++--- engines/zvision/detection.h | 6 +- engines/zvision/lever_control.h | 4 +- engines/zvision/lzss_read_stream.h | 2 +- engines/zvision/menu.cpp | 43 +++++-------- engines/zvision/menu.h | 18 +++--- engines/zvision/meta_animation.h | 4 +- engines/zvision/music_node.cpp | 3 +- engines/zvision/puzzle.h | 14 ++-- engines/zvision/render_table.h | 6 +- engines/zvision/rlf_animation.h | 4 +- engines/zvision/save_manager.h | 2 +- engines/zvision/script_manager.h | 106 +++++++++++++++---------------- engines/zvision/sidefx.h | 18 +++--- engines/zvision/single_value_container.h | 18 +++--- engines/zvision/string_manager.h | 2 +- engines/zvision/zork_avi_decoder.h | 2 +- engines/zvision/zvision.h | 20 +++--- 19 files changed, 141 insertions(+), 151 deletions(-) diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index 5c6cf6c35f..f4a2c0f387 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -369,7 +369,7 @@ public: private: enum { - DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions + DIFFERENT_DIMENSIONS = 0x1 // 0x1 flags that the destRect dimensions are different from the original video dimensions }; Common::String _fileName; diff --git a/engines/zvision/cursor_manager.h b/engines/zvision/cursor_manager.h index 7bd1c4240f..0521a17337 100644 --- a/engines/zvision/cursor_manager.h +++ b/engines/zvision/cursor_manager.h @@ -40,15 +40,15 @@ class ZVision; * Mostly usable cursors */ enum CursorIndex { - CursorIndex_Active = 0, - CursorIndex_DownArr = 3, - CursorIndex_HandPu = 6, - CursorIndex_Idle = 11, - CursorIndex_Left = 12, - CursorIndex_Right = 13, - CursorIndex_UpArr = 17, - CursorIndex_ItemIdle = 18, - CursorIndex_ItemAct = 19 + CursorIndex_Active = 0, + CursorIndex_DownArr = 3, + CursorIndex_HandPu = 6, + CursorIndex_Idle = 11, + CursorIndex_Left = 12, + CursorIndex_Right = 13, + CursorIndex_UpArr = 17, + CursorIndex_ItemIdle = 18, + CursorIndex_ItemAct = 19 }; /** diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h index 1f430dac1c..34417601e8 100644 --- a/engines/zvision/detection.h +++ b/engines/zvision/detection.h @@ -29,9 +29,9 @@ namespace ZVision { enum ZVisionGameId { - GID_NONE = 0, - GID_NEMESIS = 1, - GID_GRANDINQUISITOR = 2 + GID_NONE = 0, + GID_NEMESIS = 1, + GID_GRANDINQUISITOR = 2 }; struct ZVisionGameDescription { diff --git a/engines/zvision/lever_control.h b/engines/zvision/lever_control.h index 591d64e949..ac7ee8b5c7 100644 --- a/engines/zvision/lever_control.h +++ b/engines/zvision/lever_control.h @@ -55,8 +55,8 @@ private: }; enum { - ANGLE_DELTA = 30, // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA) - ANIMATION_FRAME_TIME = 30 // In millis + ANGLE_DELTA = 30, // How far off a mouse angle can be and still be considered valid. This is in both directions, so the total buffer zone is (2 * ANGLE_DELTA) + ANIMATION_FRAME_TIME = 30 // In millis }; private: diff --git a/engines/zvision/lzss_read_stream.h b/engines/zvision/lzss_read_stream.h index 1f7df9d4e0..73e848b9f6 100644 --- a/engines/zvision/lzss_read_stream.h +++ b/engines/zvision/lzss_read_stream.h @@ -45,7 +45,7 @@ public: private: enum { - BLOCK_SIZE = 0x1000 + BLOCK_SIZE = 0x1000 }; private: diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp index 8e1dea183b..bf422b300f 100644 --- a/engines/zvision/menu.cpp +++ b/engines/zvision/menu.cpp @@ -30,17 +30,17 @@ namespace ZVision { enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 }; enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 }; menuHandler::menuHandler(ZVision *engine) { @@ -264,8 +264,7 @@ void menuZgi::onMouseMove(const Common::Point &Pos) { } break; - case menu_MAIN: - { + case menu_MAIN: { int last_item = mouse_on_item; mouse_on_item = -1; @@ -510,29 +509,25 @@ void menuZgi::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - if (menu_bar_flag & menuBar_Exit) - { + if (menu_bar_flag & menuBar_Exit) { if (mouse_on_item == menu_MAIN_EXIT) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Settings) - { + if (menu_bar_flag & menuBar_Settings) { if (mouse_on_item == menu_MAIN_PREF) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Restore) - { + if (menu_bar_flag & menuBar_Restore) { if (mouse_on_item == menu_MAIN_REST) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Save) - { + if (menu_bar_flag & menuBar_Save) { if (mouse_on_item == menu_MAIN_SAVE) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); else @@ -698,8 +693,7 @@ void menuNem::onMouseMove(const Common::Point &Pos) { void menuNem::process(uint32 deltatime) { if (inmenu) { - if (!scrolled) - { + if (!scrolled) { float scrl = 32.0 * 2.0 * (deltatime / 1000.0); if (scrl == 0) @@ -709,8 +703,7 @@ void menuNem::process(uint32 deltatime) { redraw = true; } - if (scrollPos >= 0) - { + if (scrollPos >= 0) { scrolled = true; scrollPos = 0; } @@ -747,8 +740,7 @@ void menuNem::process(uint32 deltatime) { } } else { scrolled = false; - if (scrollPos > -32) - { + if (scrollPos > -32) { float scrl = 32.0 * 2.0 * (deltatime / 1000.0); if (scrl == 0) @@ -759,8 +751,7 @@ void menuNem::process(uint32 deltatime) { scrollPos -= scrl; redraw = true; - } - else + } else scrollPos = -32; if (redraw) { diff --git a/engines/zvision/menu.h b/engines/zvision/menu.h index 35e7347a3b..c5938cdc3d 100644 --- a/engines/zvision/menu.h +++ b/engines/zvision/menu.h @@ -32,12 +32,12 @@ namespace ZVision { enum menuBar { - menuBar_Exit = 0x1, - menuBar_Settings = 0x2, - menuBar_Restore = 0x4, - menuBar_Save = 0x8, - menuBar_Items = 0x100, - menuBar_Magic = 0x200 + menuBar_Exit = 0x1, + menuBar_Settings = 0x2, + menuBar_Restore = 0x4, + menuBar_Save = 0x8, + menuBar_Items = 0x100, + menuBar_Magic = 0x200 }; class menuHandler { @@ -80,9 +80,9 @@ private: float scrollPos[3]; enum { - menu_ITEM = 0, - menu_MAGIC = 1, - menu_MAIN = 2 + menu_ITEM = 0, + menu_MAGIC = 1, + menu_MAIN = 2 }; bool clean; diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h index e259955891..3754aae058 100644 --- a/engines/zvision/meta_animation.h +++ b/engines/zvision/meta_animation.h @@ -64,8 +64,8 @@ public: private: enum FileType { - RLF = 1, - AVI = 2 + RLF = 1, + AVI = 2 }; private: diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index d47a796382..31d222aead 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -109,8 +109,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { deltaTimeInMillis = _crossfade_time; _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; _crossfade_time -= deltaTimeInMillis; - } - else { + } else { _crossfade = false; _newvol = _crossfade_target; } diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index c02f60c8f0..e06b087aca 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -42,10 +42,10 @@ struct Puzzle { /** How criteria should be decided */ enum CriteriaOperator { - EQUAL_TO, - NOT_EQUAL_TO, - GREATER_THAN, - LESS_THAN + EQUAL_TO, + NOT_EQUAL_TO, + GREATER_THAN, + LESS_THAN }; /** Criteria for a Puzzle result to be fired */ @@ -64,9 +64,9 @@ struct Puzzle { }; enum StateFlags { - ONCE_PER_INST = 0x01, - DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria - DISABLED = 0x04 + ONCE_PER_INST = 0x01, + DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria + DISABLED = 0x04 }; uint32 key; diff --git a/engines/zvision/render_table.h b/engines/zvision/render_table.h index db9ab08f7c..86afd1fff9 100644 --- a/engines/zvision/render_table.h +++ b/engines/zvision/render_table.h @@ -36,9 +36,9 @@ public: public: enum RenderState { - PANORAMA, - TILT, - FLAT + PANORAMA, + TILT, + FLAT }; private: diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h index 3764465786..bc5fdc5d90 100644 --- a/engines/zvision/rlf_animation.h +++ b/engines/zvision/rlf_animation.h @@ -42,8 +42,8 @@ public: private: enum EncodingType { - Masked, - Simple + Masked, + Simple }; struct Frame { diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h index 9de1c51900..ec80b37e20 100644 --- a/engines/zvision/save_manager.h +++ b/engines/zvision/save_manager.h @@ -54,7 +54,7 @@ private: static const uint32 SAVEGAME_ID; enum { - SAVE_VERSION = 1 + SAVE_VERSION = 1 }; public: diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 3e671aa3db..2f585b6291 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -41,59 +41,59 @@ namespace ZVision { class ZVision; enum StateKey { - StateKey_World = 3, - StateKey_Room = 4, - StateKey_Node = 5, - StateKey_View = 6, - StateKey_ViewPos = 7, - StateKey_KeyPress = 8, - StateKey_InventoryItem = 9, - StateKey_LMouse = 10, - StateKey_NotSet = 11, // This key doesn't set - StateKey_Rounds = 12, - StateKey_Venus = 13, - StateKey_RMouse = 18, - StateKey_MenuState = 19, - StateKey_RestoreFlag = 20, - StateKey_Quitting = 39, - StateKey_LastWorld = 40, - StateKey_LastRoom = 41, - StateKey_LastNode = 42, - StateKey_LastView = 43, - StateKey_LastViewPos = 44, - StateKey_Menu_LastWorld = 45, - StateKey_Menu_LastRoom = 46, - StateKey_Menu_LastNode = 47, - StateKey_Menu_LastView = 48, - StateKey_Menu_LastViewPos = 49, - StateKey_KbdRotateSpeed = 50, - StateKey_Subtitles = 51, - StateKey_StreamSkipKey = 52, - StateKey_RotateSpeed = 53, - StateKey_Volume = 56, - StateKey_Qsound = 57, - StateKey_VenusEnable = 58, - StateKey_HighQuality = 59, - StateKey_VideoLineSkip = 65, - StateKey_Platform = 66, - StateKey_InstallLevel = 67, - StateKey_CountryCode = 68, - StateKey_CPU = 69, - StateKey_MovieCursor = 70, - StateKey_NoTurnAnim = 71, - StateKey_WIN958 = 72, - StateKey_ShowErrorDlg = 73, - StateKey_DebugCheats = 74, - StateKey_JapanFonts = 75, - StateKey_Brightness = 77, - StateKey_EF9_B = 91, - StateKey_EF9_G = 92, - StateKey_EF9_R = 93, - StateKey_EF9_Speed = 94, - StateKey_Inv_Cnt_Slot = 100, - StateKey_Inv_1_Slot = 101, - StateKey_Inv_49_Slot = 149, - StateKey_Inv_TotalSlots = 150 + StateKey_World = 3, + StateKey_Room = 4, + StateKey_Node = 5, + StateKey_View = 6, + StateKey_ViewPos = 7, + StateKey_KeyPress = 8, + StateKey_InventoryItem = 9, + StateKey_LMouse = 10, + StateKey_NotSet = 11, // This key doesn't set + StateKey_Rounds = 12, + StateKey_Venus = 13, + StateKey_RMouse = 18, + StateKey_MenuState = 19, + StateKey_RestoreFlag = 20, + StateKey_Quitting = 39, + StateKey_LastWorld = 40, + StateKey_LastRoom = 41, + StateKey_LastNode = 42, + StateKey_LastView = 43, + StateKey_LastViewPos = 44, + StateKey_Menu_LastWorld = 45, + StateKey_Menu_LastRoom = 46, + StateKey_Menu_LastNode = 47, + StateKey_Menu_LastView = 48, + StateKey_Menu_LastViewPos = 49, + StateKey_KbdRotateSpeed = 50, + StateKey_Subtitles = 51, + StateKey_StreamSkipKey = 52, + StateKey_RotateSpeed = 53, + StateKey_Volume = 56, + StateKey_Qsound = 57, + StateKey_VenusEnable = 58, + StateKey_HighQuality = 59, + StateKey_VideoLineSkip = 65, + StateKey_Platform = 66, + StateKey_InstallLevel = 67, + StateKey_CountryCode = 68, + StateKey_CPU = 69, + StateKey_MovieCursor = 70, + StateKey_NoTurnAnim = 71, + StateKey_WIN958 = 72, + StateKey_ShowErrorDlg = 73, + StateKey_DebugCheats = 74, + StateKey_JapanFonts = 75, + StateKey_Brightness = 77, + StateKey_EF9_B = 91, + StateKey_EF9_G = 92, + StateKey_EF9_R = 93, + StateKey_EF9_Speed = 94, + StateKey_Inv_Cnt_Slot = 100, + StateKey_Inv_1_Slot = 101, + StateKey_Inv_49_Slot = 149, + StateKey_Inv_TotalSlots = 150 }; struct Location { diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h index 210d98effb..2c53467559 100644 --- a/engines/zvision/sidefx.h +++ b/engines/zvision/sidefx.h @@ -37,15 +37,15 @@ class SideFX { public: enum SideFXType { - SIDEFX_ANIM = 1, - SIDEFX_AUDIO = 2, - SIDEFX_DISTORT = 4, - SIDEFX_PANTRACK = 8, - SIDEFX_REGION = 16, - SIDEFX_TIMER = 32, - SIDEFX_TTYTXT = 64, - SIDEFX_UNK = 128, - SIDEFX_ALL = 255 + SIDEFX_ANIM = 1, + SIDEFX_AUDIO = 2, + SIDEFX_DISTORT = 4, + SIDEFX_PANTRACK = 8, + SIDEFX_REGION = 16, + SIDEFX_TIMER = 32, + SIDEFX_TTYTXT = 64, + SIDEFX_UNK = 128, + SIDEFX_ALL = 255 }; SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} diff --git a/engines/zvision/single_value_container.h b/engines/zvision/single_value_container.h index 33fe69d760..32b4d6c6dc 100644 --- a/engines/zvision/single_value_container.h +++ b/engines/zvision/single_value_container.h @@ -36,15 +36,15 @@ namespace ZVision { class SingleValueContainer { public: enum ValueType { - BOOL, - BYTE, - INT16, - UINT16, - INT32, - UINT32, - FLOAT, - DOUBLE, - STRING + BOOL, + BYTE, + INT16, + UINT16, + INT32, + UINT32, + FLOAT, + DOUBLE, + STRING }; // Constructors diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h index a6ae6d20d6..9cfed5261b 100644 --- a/engines/zvision/string_manager.h +++ b/engines/zvision/string_manager.h @@ -59,7 +59,7 @@ private: }; enum { - NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 + NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 }; private: diff --git a/engines/zvision/zork_avi_decoder.h b/engines/zvision/zork_avi_decoder.h index 7ddecce694..d8937ac057 100644 --- a/engines/zvision/zork_avi_decoder.h +++ b/engines/zvision/zork_avi_decoder.h @@ -61,7 +61,7 @@ private: private: // Audio Codecs enum { - kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM) + kWaveFormatZorkPCM = 17 // special Zork PCM audio format (clashes with MS IMA ADPCM) }; }; diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index c9e14e8651..983d5a56eb 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -70,19 +70,19 @@ public: private: enum { - WINDOW_WIDTH = 640, - WINDOW_HEIGHT = 480, + WINDOW_WIDTH = 640, + WINDOW_HEIGHT = 480, - //Zork nemesis working window sizes - ZNM_WORKING_WINDOW_WIDTH = 512, - ZNM_WORKING_WINDOW_HEIGHT = 320, + //Zork nemesis working window sizes + ZNM_WORKING_WINDOW_WIDTH = 512, + ZNM_WORKING_WINDOW_HEIGHT = 320, - //ZGI(and default) working window sizes - WORKING_WINDOW_WIDTH = 640, - WORKING_WINDOW_HEIGHT = 344, + //ZGI(and default) working window sizes + WORKING_WINDOW_WIDTH = 640, + WORKING_WINDOW_HEIGHT = 344, - ROTATION_SCREEN_EDGE_OFFSET = 60, - MAX_ROTATION_SPEED = 400 // Pixels per second + ROTATION_SCREEN_EDGE_OFFSET = 60, + MAX_ROTATION_SPEED = 400 // Pixels per second }; Console *_console; -- cgit v1.2.3 From 226ccb0de7ed702d4b41625c8a2211fac9cc0787 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 20:40:20 +0700 Subject: ZVISION: Don't add new timer if sidefx with same key exist --- engines/zvision/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 7b9050f47a..c3f85fe247 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -607,6 +607,8 @@ ActionTimer::~ActionTimer() { } bool ActionTimer::execute() { + if (_engine->getScriptManager()->getSideFX(_slotkey)) + return true; _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue())); return true; } -- cgit v1.2.3 From dcfe35c8ac1cd2c9139f5d7a59f0f554e3c5082b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 20:44:22 +0700 Subject: ZVISION: Implement sTTFont class for handle ttf with styles. --- engines/zvision/truetype_font.cpp | 226 ++++++++++++++++++++++++++++++++++++++ engines/zvision/truetype_font.h | 42 +++++++ 2 files changed, 268 insertions(+) diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp index dde3b2dee5..5e1bc7a81d 100644 --- a/engines/zvision/truetype_font.cpp +++ b/engines/zvision/truetype_font.cpp @@ -27,9 +27,11 @@ #include "zvision/zvision.h" #include "zvision/render_manager.h" +#include "common/config-manager.h" #include "common/debug.h" #include "common/file.h" #include "common/system.h" +#include "common/unzip.h" #include "graphics/font.h" #include "graphics/fonts/ttf.h" @@ -113,4 +115,228 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, u return surface; } +sTTFont::sTTFont(ZVision *engine) { + _engine = engine; + _style = 0; + _font = NULL; + _lineHeight = 0; +} + +sTTFont::~sTTFont() { + if (_font) + delete _font; +} + +bool sTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { + _style = style; + return loadFont(fontName, point); +} + +bool sTTFont::loadFont(const Common::String &fontName, int32 point) { + Common::String newFontName; + if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "timesbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "timesbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "timesi.ttf"; + else + newFontName = "times.ttf"; + + } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "courbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "courbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "couri.ttf"; + else + newFontName = "cour.ttf"; + + } else if (fontName.matchString("*century schoolbook*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "censcbkbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "censcbkbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "censcbki.ttf"; + else + newFontName = "censcbk.ttf"; + + } else if (fontName.matchString("*garamond*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "garabi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "garabd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "garai.ttf"; + else + newFontName = "gara.ttf"; + + } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "arialbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "arialbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "ariali.ttf"; + else + newFontName = "arial.ttf"; + + } else { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + newFontName = "arial.ttf"; + } + + Common::File *file = _engine->getSearchManager()->openFile(newFontName); + + if (!file) { + Common::SeekableReadStream *themeFile = nullptr; + if (ConfMan.hasKey("themepath")) { + Common::FSNode themePath(ConfMan.get("themepath")); + if (themePath.exists()) { + Common::FSNode scummModern = themePath.getChild("scummmodern.zip"); + if (scummModern.exists()) { + themeFile = scummModern.createReadStream(); + } + } + } + if (!themeFile) { // Fallback 2.5: Search for ScummModern.zip in SearchMan. + themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); + } + if (themeFile) { + Common::Archive *themeArchive = Common::makeZipArchive(themeFile); + if (themeArchive->hasFile("FreeSans.ttf")) { + Common::SeekableReadStream *stream = nullptr; + stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); + Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + if (stream) + delete stream; + } + delete themeArchive; + themeArchive = nullptr; + } + } else { + Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + delete file; + } + + _fntName = fontName; + _lineHeight = point; + + if (_font) + return true; + return false; +} + +void sTTFont::setStyle(uint newStyle) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) != (newStyle & (STTF_BOLD | STTF_ITALIC))) { + _style = newStyle; + loadFont(_fntName, _lineHeight); + } else { + _style = newStyle; + } +} + +int sTTFont::getFontHeight() { + if (_font) + return _font->getFontHeight(); + return 0; +} + +int sTTFont::getMaxCharWidth() { + if (_font) + return _font->getMaxCharWidth(); + return 0; +} + +int sTTFont::getCharWidth(byte chr) { + if (_font) + return _font->getCharWidth(chr); + return 0; +} + +int sTTFont::getKerningOffset(byte left, byte right) { + if (_font) + return _font->getKerningOffset(left, right); + return 0; +} + +void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { + if (_font) { + _font->drawChar(dst, chr, x, y, color); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + } +} + +void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { + if (_font) { + _font->drawString(dst, str, x, y, w, color, align); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + } +} + +int sTTFont::getStringWidth(const Common::String &str) { + if (_font) + return _font->getStringWidth(str); + return 0; +} + +Graphics::Surface *sTTFont::renderSolidText(const Common::String &str, uint32 color) { + Graphics::Surface *tmp = new Graphics::Surface; + if (_font) { + int16 w = _font->getStringWidth(str); + if (w && w < 1024) { + tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); + drawString(tmp, str, 0, 0, w, color); + } + } + return tmp; +} + } // End of namespace ZVision diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h index 762657a5fb..0462f35aff 100644 --- a/engines/zvision/truetype_font.h +++ b/engines/zvision/truetype_font.h @@ -76,6 +76,48 @@ public: Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap); }; +// Styled TTF +class sTTFont { +public: + sTTFont(ZVision *engine); + ~sTTFont(); + + enum { + STTF_BOLD = 1, + STTF_ITALIC = 2, + STTF_UNDERLINE = 4, + STTF_STRIKEOUT = 8 + }; + +private: + ZVision *_engine; + Graphics::Font *_font; + int _lineHeight; + uint _style; + Common::String _fntName; + +public: + bool loadFont(const Common::String &fontName, int32 point); + bool loadFont(const Common::String &fontName, int32 point, uint style); + void setStyle(uint newStyle); + + int getFontHeight(); + int getMaxCharWidth(); + int getCharWidth(byte chr); + int getKerningOffset(byte left, byte right); + + void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); + + void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); + int getStringWidth(const Common::String &str); + + Graphics::Surface *renderSolidText(const Common::String &str, uint32 color); + + bool isLoaded() { + return _font != NULL; + }; +}; + } // End of namespace ZVision #endif -- cgit v1.2.3 From cf08849147905ffd12cd9571b617033ded5a95fb Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 22:31:06 +0700 Subject: ZVISION: Implement textRender with tags parser. --- engines/zvision/module.mk | 3 +- engines/zvision/text.cpp | 512 ++++++++++++++++++++++++++++++++++++++++++++ engines/zvision/text.h | 97 +++++++++ engines/zvision/zvision.cpp | 3 + engines/zvision/zvision.h | 5 + 5 files changed, 619 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/text.cpp create mode 100644 engines/zvision/text.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index b8dca9e63a..ea70b4b831 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -36,7 +36,8 @@ MODULE_OBJS := \ slot_control.o \ menu.o \ meta_animation.o \ - search_manager.o + search_manager.o \ + text.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp new file mode 100644 index 0000000000..575ca03d10 --- /dev/null +++ b/engines/zvision/text.cpp @@ -0,0 +1,512 @@ +/* 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 "common/scummsys.h" + +#include "zvision/text.h" + +#include "zvision/truetype_font.h" + +#include "common/file.h" +#include "common/tokenizer.h" +#include "common/debug.h" +#include "common/rect.h" + +#include "graphics/fontman.h" +#include "graphics/colormasks.h" +#include "graphics/surface.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" + +#include "zvision/render_manager.h" +#include "zvision/script_manager.h" + + +namespace ZVision { + +cTxtStyle::cTxtStyle() { + fontname = "Arial"; + blue = 255; + green = 255; + red = 255; + bold = false; + escapement = 0; + italic = false; + justify = TXT_JUSTIFY_LEFT; + newline = false; + size = 12; + skipcolor = false; + strikeout = false; + underline = false; + statebox = 0; +} + +txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { + Common::String buf = Common::String(strin.c_str(), ln); + + int8 retval = TXT_RET_NOTHING; + + Common::StringTokenizer tokenizer(buf, " "); + Common::String token; + + while (!tokenizer.empty()) { + token = tokenizer.nextToken(); + + if (token.matchString("font", true)) { + token = tokenizer.nextToken(); + if (token[0] == '"') { + Common::String _tmp = Common::String(token.c_str() + 1); + + while (token.lastChar() != '"' && !tokenizer.empty()) { + token = tokenizer.nextToken(); + _tmp += " " + token; + } + + if (_tmp.lastChar() == '"') + _tmp.deleteLastChar(); + + fontname = _tmp; + } else { + if (!tokenizer.empty()) + fontname = token; + } + retval |= TXT_RET_FNTCHG; + + } else if (token.matchString("blue", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (blue != tmp) { + blue = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("red", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (red != tmp) { + red = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("green", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (green != tmp) { + green = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("newline", true)) { + if ((retval & TXT_RET_NEWLN) == 0) + newline = 0; + + newline++; + retval |= TXT_RET_NEWLN; + } else if (token.matchString("point", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (size != tmp) { + size = tmp; + retval |= TXT_RET_FNTCHG; + } + } + } else if (token.matchString("escapement", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + escapement = tmp; + } + } else if (token.matchString("italic", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (italic != true) { + italic = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (italic != false) { + italic = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("underline", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (underline != true) { + underline = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (underline != false) { + underline = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("strikeout", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (strikeout != true) { + strikeout = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (strikeout != false) { + strikeout = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("bold", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (bold != true) { + bold = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (bold != false) { + bold = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("skipcolor", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + skipcolor = true; + } else if (token.matchString("off", true)) { + skipcolor = false; + } + } + } else if (token.matchString("image", true)) { + // Not used + } else if (token.matchString("statebox", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + statebox = atoi(token.c_str()); + retval |= TXT_RET_HASSTBOX; + } + } else if (token.matchString("justify", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("center", true)) + justify = TXT_JUSTIFY_CENTER; + else if (token.matchString("left", true)) + justify = TXT_JUSTIFY_LEFT; + else if (token.matchString("right", true)) + justify = TXT_JUSTIFY_RIGHT; + } + } + } + return (txtReturn)retval; +} + +void cTxtStyle::readAllStyle(const Common::String &txt) { + int16 strt = -1; + int16 endt = -1; + + for (uint16 i = 0; i < txt.size(); i++) { + if (txt[i] == '<') + strt = i; + else if (txt[i] == '>') { + endt = i; + if (strt != -1) + if ((endt - strt - 1) > 0) + parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1); + } + + } +} + +void cTxtStyle::setFontStyle(sTTFont &font) { + uint temp_stl = 0; + + if (bold) + temp_stl |= sTTFont::STTF_BOLD; + + if (italic) + temp_stl |= sTTFont::STTF_ITALIC; + + if (underline) + temp_stl |= sTTFont::STTF_UNDERLINE; + + if (strikeout) + temp_stl |= sTTFont::STTF_STRIKEOUT; + + font.setStyle(temp_stl); +} + +void cTxtStyle::setFont(sTTFont &font) { + uint temp_stl = 0; + + if (bold) + temp_stl |= sTTFont::STTF_BOLD; + + if (italic) + temp_stl |= sTTFont::STTF_ITALIC; + + if (underline) + temp_stl |= sTTFont::STTF_UNDERLINE; + + if (strikeout) + temp_stl |= sTTFont::STTF_STRIKEOUT; + + font.loadFont(fontname, size, temp_stl); +} + +Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) { + style.setFontStyle(fnt); + uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue); + return fnt.renderSolidText(txt, clr); +} + +void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { + if (justify == TXT_JUSTIFY_LEFT) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft); + else if (justify == TXT_JUSTIFY_CENTER) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter); + else if (justify == TXT_JUSTIFY_RIGHT) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight); +} + +int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) { + sTTFont font(_engine); + fnt_stl.setFont(font); + + dst.fillRect(Common::Rect(dst.w, dst.h), 0); + + uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue); + + int16 w; + + w = font.getStringWidth(txt); + + drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify); + + return w; +} + +void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { + const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it + const int TXT_CFG_TEXTURES_PER_LINE = 6; + cTxtStyle style, style2; + int16 strt = -1; + int16 endt = -1; + int16 i = 0; + int16 dx = 0, dy = 0; + int16 txt_w; + int16 txtpos = 0; + Common::String buf; + Common::String buf2; + + Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE]; + int16 currentline = 0, currentlineitm = 0; + + int TxtJustify[TXT_CFG_TEXTURES_LINES]; + int TxtPoint[TXT_CFG_TEXTURES_LINES]; + + for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) { + TxtPoint[k] = 0; + for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) + TxtSurfaces[k][j] = NULL; + } + + int16 stringlen = text.size(); + + sTTFont font(_engine); + + style.setFont(font); + + int16 prevbufspace = 0, prevtxtspace = 0; + + while (i < stringlen) { + TxtJustify[currentline] = style.justify; + if (text[i] == '<') { + int16 ret = 0; + + strt = i; + while (i < stringlen && text[i] != '>') + i++; + endt = i; + if (strt != -1) + if ((endt - strt - 1) > 0) { + style2 = style; + ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1); + } + + if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { + if (buf.size() > 0) { + txt_w = font.getStringWidth(buf); + + TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + + currentlineitm++; + + buf.clear(); + prevbufspace = 0; + txtpos = 0; + dx += txt_w; + + } + if (ret & TXT_RET_FNTCHG) { + style.setFont(font); + } + if (ret & TXT_RET_FNTSTL) + style.setFontStyle(font); + + if (ret & TXT_RET_NEWLN) { + currentline++; + currentlineitm = 0; + dx = 0; + } + } + + if (ret & TXT_RET_HASSTBOX) { + Common::String buf3; + buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); + buf += buf3; + txtpos += buf3.size(); + } + + } else { + + buf += text[i]; + txtpos++; + + if (text[i] == ' ') { + prevbufspace = txtpos - 1; + prevtxtspace = i; + } + + if (font.isLoaded()) { + txt_w = font.getStringWidth(buf); + if (txt_w + dx > dst.w) { + if (prevbufspace == 0) { + prevtxtspace = i; + prevbufspace = txtpos - 1; + } + buf2 = Common::String(buf.c_str(), prevbufspace + 1); + + if (buf2.size() > 0) { + TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + } + + buf.clear(); + i = prevtxtspace; + prevbufspace = 0; + txtpos = 0; + currentline++; + currentlineitm = 0; + dx = 0; + } + } + } + i++; + } + + if (buf.size() > 0) { + TxtSurfaces[currentline][currentlineitm] = render(font, buf, style); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + } + + dy = 0; + for (i = 0; i <= currentline; i++) { + int16 j = 0; + int16 width = 0; + while (TxtSurfaces[i][j] != NULL) { + width += TxtSurfaces[i][j]->w; + j++; + } + dx = 0; + for (int32_t jj = 0; jj < j; jj++) { + if (TxtJustify[i] == TXT_JUSTIFY_LEFT) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + dx += TxtSurfaces[i][jj]->w; + } + + dy += TxtPoint[i]; + } + + for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++) + for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) + if (TxtSurfaces[i][j] != NULL) { + TxtSurfaces[i][j]->free(); + delete TxtSurfaces[i][j]; + } +} + +Common::String readWideLine(Common::SeekableReadStream &stream) { + Common::String asciiString; + + while (!stream.eos()) { + uint32 value = stream.readUint16LE(); + // Check for CRLF + if (value == 0x0A0D) { + // Read in the extra NULL char + stream.readByte(); // \0 + // End of the line. Break + break; + } + + // Crush each octet pair to a single octet with a simple cast + if (value < 0x80) { + asciiString += (char)(value & 0x7F); + } else if (value >= 0x80 && value < 0x800) { + asciiString += (char)(0xC0 | ((value >> 6) & 0x1F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } else if (value >= 0x800 && value < 0x10000) { + asciiString += (char)(0xE0 | ((value >> 12) & 0xF)); + asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } else if (value >= 0x10000 && value < 0x200000) { + asciiString += (char)(0xF0); + asciiString += (char)(0x80 | ((value >> 12) & 0x3F)); + asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } + } + + return asciiString; +} + + +} // End of namespace ZVision diff --git a/engines/zvision/text.h b/engines/zvision/text.h new file mode 100644 index 0000000000..40244f7f0c --- /dev/null +++ b/engines/zvision/text.h @@ -0,0 +1,97 @@ +/* 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 ZVISION_TEXT_H +#define ZVISION_TEXT_H + +#include "zvision/detection.h" +#include "zvision/truetype_font.h" +#include "zvision/zvision.h" + + +namespace Graphics { +class FontManager; +} + +namespace ZVision { + +class ZVision; + +enum txtJustify { + TXT_JUSTIFY_CENTER = 0, + TXT_JUSTIFY_LEFT = 1, + TXT_JUSTIFY_RIGHT = 2 +}; + +enum txtReturn { + TXT_RET_NOTHING = 0x0, + TXT_RET_FNTCHG = 0x1, + TXT_RET_FNTSTL = 0x2, + TXT_RET_NEWLN = 0x4, + TXT_RET_HASSTBOX = 0x8 +}; + +class cTxtStyle { +public: + cTxtStyle(); + txtReturn parseStyle(const Common::String &strin, int16 len); + void readAllStyle(const Common::String &txt); + void setFontStyle(sTTFont &font); + void setFont(sTTFont &font); + +public: + Common::String fontname; + txtJustify justify; // 0 - center, 1-left, 2-right + int16 size; + uint8 red; // 0-255 + uint8 green; // 0-255 + uint8 blue; // 0-255 + int8 newline; + int8 escapement; + bool italic; + bool bold; + bool underline; + bool strikeout; + bool skipcolor; + int32 statebox; + // char image ?? +}; + +class textRenderer { +public: + textRenderer(ZVision *engine): _engine(engine) {}; + + void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); + int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst); + Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style); + void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst); + +private: + ZVision *_engine; +}; + +Common::String readWideLine(Common::SeekableReadStream &stream); + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index bf945f859a..178c7978ae 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -34,6 +34,7 @@ #include "zvision/detection.h" #include "zvision/menu.h" #include "zvision/search_manager.h" +#include "zvision/text.h" #include "common/config-manager.h" #include "common/str.h" @@ -93,6 +94,7 @@ void ZVision::initialize() { _searchManager = new sManager(ConfMan.get("path"), 6); + _searchManager->addDir("FONTS"); _searchManager->addDir("addon"); if (_gameDescription->gameId == GID_GRANDINQUISITOR) { @@ -152,6 +154,7 @@ void ZVision::initialize() { _saveManager = new SaveManager(this); _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, &_pixelFormat); + _textRenderer = new textRenderer(this); if (_gameDescription->gameId == GID_GRANDINQUISITOR) _menu = new menuZgi(this); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 983d5a56eb..bbcaf3c952 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -53,6 +53,7 @@ class StringManager; class SaveManager; class RlfAnimation; class menuHandler; +class textRenderer; class ZVision : public Engine { public: @@ -101,6 +102,7 @@ private: StringManager *_stringManager; menuHandler *_menu; sManager *_searchManager; + textRenderer *_textRenderer; // Clock Clock _clock; @@ -140,6 +142,9 @@ public: sManager *getSearchManager() const { return _searchManager; } + textRenderer *getTextRenderer() const { + return _textRenderer; + } Common::RandomSource *getRandomSource() const { return _rnd; } -- cgit v1.2.3 From ac9b74dd16fb5950cdaa6c540b1e0d2e968ed129 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 22:43:09 +0700 Subject: ZVISION: Implement subtitle handle class --- engines/zvision/module.mk | 3 +- engines/zvision/subtitles.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++ engines/zvision/subtitles.h | 26 +++++++++- 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 engines/zvision/subtitles.cpp diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index ea70b4b831..c8f629de1f 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -37,7 +37,8 @@ MODULE_OBJS := \ menu.o \ meta_animation.o \ search_manager.o \ - text.o + text.o \ + subtitles.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp new file mode 100644 index 0000000000..1942e3c979 --- /dev/null +++ b/engines/zvision/subtitles.cpp @@ -0,0 +1,108 @@ +/* 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 "zvision/subtitles.h" +#include "zvision/render_manager.h" +#include "zvision/search_manager.h" +#include "zvision/text.h" + +namespace ZVision { + +Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : + _engine(engine), + _areaId(-1), + _subId(-1) { + Common::File file; + if (_engine->getSearchManager()->openFile(file, subname)) { + while (!file.eos()) { + Common::String str = file.readLine(); + if (str.lastChar() == '~') + str.deleteLastChar(); + + if (str.matchString("*Initialization*", true)) { + // Not used + } else if (str.matchString("*Rectangle*", true)) { + int32 x1, y1, x2, y2; + sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); + Common::Rect rct = Common::Rect(x1, y1, x2, y2); + _areaId = _engine->getRenderManager()->createSubArea(rct); + } else if (str.matchString("*TextFile*", true)) { + char filename[64]; + sscanf(str.c_str(), "%*[^:]:%s", filename); + Common::File txt; + if (_engine->getSearchManager()->openFile(txt, filename)) { + while (!txt.eos()) { + Common::String txtline = readWideLine(txt); + sub cur_sub; + cur_sub.start = -1; + cur_sub.stop = -1; + cur_sub.sub = txtline; + + _subs.push_back(cur_sub); + } + txt.close(); + } + } else { + int32 st; + int32 en; + int32 sb; + if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { + if (sb <= (int32)_subs.size()) { + _subs[sb].start = st; + _subs[sb].stop = en; + } + } + } + } + } +} + +Subtitle::~Subtitle() { + if (_areaId != -1) + _engine->getRenderManager()->deleteSubArea(_areaId); + + _subs.clear(); +} + +void Subtitle::process(int32 time) { + int16 j = -1; + for (uint16 i = 0; i < _subs.size(); i++) + if (time >= _subs[i].start && time <= _subs[i].stop) { + j = i; + break; + } + + if (j == -1 && _subId != -1) { + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, ""); + _subId = -1; + } + + if (j != -1 && j != _subId) { + if (_subs[j].sub.size()) + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub); + _subId = j; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h index 13426e03e4..d14cb6f052 100644 --- a/engines/zvision/subtitles.h +++ b/engines/zvision/subtitles.h @@ -24,6 +24,30 @@ #ifndef ZVISION_SUBTITLES_H #define ZVISION_SUBTITLES_H -// TODO: Implement Subtitles +#include "zvision/zvision.h" + +namespace ZVision { + +class Subtitle { +public: + Subtitle(ZVision *engine, const Common::String &subname); + ~Subtitle(); + + void process(int32 time); +private: + ZVision *_engine; + int32 _areaId; + int16 _subId; + + struct sub { + int start; + int stop; + Common::String sub; + }; + + Common::Array _subs; +}; + +} #endif -- cgit v1.2.3 From 8e02e06db153a68e86239c09b79565b0372cd789 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 22:46:00 +0700 Subject: ZVISION: Change rendermanager code for correct subtitles handle. --- engines/zvision/render_manager.cpp | 19 +++++++++++++++++-- engines/zvision/render_manager.h | 2 +- engines/zvision/zvision.cpp | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 6cfc0509c7..071affffab 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -24,6 +24,7 @@ #include "zvision/zvision.h" #include "zvision/render_manager.h" +#include "zvision/text.h" #include "zvision/lzss_read_stream.h" @@ -746,9 +747,14 @@ void RenderManager::updateSubArea(uint16 id, const Common::String &txt) { } } -void RenderManager::renderSubsToScreen() { +void RenderManager::processSubs(uint16 deltatime) { bool redraw = false; for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { + if (it->_value.timer != -1) { + it->_value.timer -= deltatime; + if (it->_value.timer <= 0) + it->_value.todelete = true; + } if (it->_value.todelete) { _subsList.erase(it); redraw = true; @@ -761,7 +767,16 @@ void RenderManager::renderSubsToScreen() { _subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0); for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { - //draw subs + oneSub *sub = &it->_value; + if (sub->_txt.size()) { + Graphics::Surface *rndr = new Graphics::Surface(); + rndr->create(sub->_r.width(), sub->_r.height(), _pixelFormat); + _engine->getTextRenderer()->drawTxtInOneLine(sub->_txt, *rndr); + blitSurfaceToSurface(*rndr, _subWnd, sub->_r.left - _subWndRect.left + _workingWindow.left, sub->_r.top - _subWndRect.top + _workingWindow.top); + rndr->free(); + delete rndr; + } + sub->redraw = false; } _system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch, diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 3c03331d0f..668c8acc41 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -236,7 +236,7 @@ public: void deleteSubArea(uint16 id); void deleteSubArea(uint16 id, int16 delay); void updateSubArea(uint16 id, const Common::String &txt); - void renderSubsToScreen(); + void processSubs(uint16 deltatime); Common::Point getBkgSize(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 178c7978ae..4c5164cd6e 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -192,7 +192,7 @@ Common::Error ZVision::run() { // Render the backBuffer to the screen _renderManager->prepareBkg(); _renderManager->renderMenuToScreen(); - _renderManager->renderSubsToScreen(); + _renderManager->processSubs(deltaTime); _renderManager->renderBackbufferToScreen(); // Update the screen -- cgit v1.2.3 From 1af6f404f441a7a2d77bb0f23d1dbb1c838cf56c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 22:47:28 +0700 Subject: ZVISION: Add subtitles support for MusicNode. --- engines/zvision/music_node.cpp | 14 ++++++++++++++ engines/zvision/music_node.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index 31d222aead..b716b3ead1 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -46,6 +46,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool _attenuate = 0; _pantrack = false; _pantrack_X = 0; + _sub = NULL; Audio::RewindableAudioStream *audioStream; @@ -69,12 +70,22 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 1); + + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); } MusicNode::~MusicNode() { _engine->_mixer->stopHandle(_handle); if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); + if (_sub) + delete _sub; debug(1, "MusicNode: %d destroyed\n", _key); } @@ -117,6 +128,9 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { if (_pantrack || _volume != _newvol) setVolume(_newvol); + + if (_sub) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); } return false; } diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h index 6e3033f6b0..d24496fc02 100644 --- a/engines/zvision/music_node.h +++ b/engines/zvision/music_node.h @@ -25,6 +25,7 @@ #include "audio/mixer.h" #include "zvision/sidefx.h" +#include "zvision/subtitles.h" namespace Common { class String; @@ -64,6 +65,7 @@ private: int32 _crossfade_time; bool _stereo; Audio::SoundHandle _handle; + Subtitle *_sub; }; class PanTrackNode : public SideFX { -- cgit v1.2.3 From 3608a0f6c6be65cc86aac7b75dbed5505859f267 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 24 Feb 2014 22:49:44 +0700 Subject: ZVISION: Change changelocation code for identical work to original. --- engines/zvision/script_manager.cpp | 89 +++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 30 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index a1003197ef..54d126f8cb 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -58,10 +58,10 @@ void ScriptManager::initialize() { cleanScriptScope(room); cleanScriptScope(nodeview); - _currentLocation.node = '0'; - _currentLocation.world = '0'; - _currentLocation.room = '0'; - _currentLocation.view = '0'; + _currentLocation.node = 0; + _currentLocation.world = 0; + _currentLocation.room = 0; + _currentLocation.view = 0; parseScrFile("universe.scr", universe); changeLocation('g', 'a', 'r', 'y', 0); @@ -489,46 +489,75 @@ void ScriptManager::do_changeLocation() { setStateValue(StateKey_View, _nextLocation.view); setStateValue(StateKey_ViewPos, _nextLocation.offset); - // Clear all the containers _referenceTable.clear(); - cleanScriptScope(nodeview); - cleanScriptScope(room); - cleanScriptScope(world); - addPuzzlesToReferenceTable(universe); - // Parse into puzzles and controls - Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); - parseScrFile(fileName, nodeview); - addPuzzlesToReferenceTable(nodeview); + if (_nextLocation.world != _currentLocation.world) { + cleanScriptScope(nodeview); + cleanScriptScope(room); + cleanScriptScope(world); + + Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); + parseScrFile(fileName, nodeview); + addPuzzlesToReferenceTable(nodeview); + + fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room); + parseScrFile(fileName, room); + addPuzzlesToReferenceTable(room); + + fileName = Common::String::format("%c.scr", _nextLocation.world); + parseScrFile(fileName, world); + addPuzzlesToReferenceTable(world); + } else if (_nextLocation.room != _currentLocation.room) { + cleanScriptScope(nodeview); + cleanScriptScope(room); + + addPuzzlesToReferenceTable(world); + + Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); + parseScrFile(fileName, nodeview); + addPuzzlesToReferenceTable(nodeview); - fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room); - parseScrFile(fileName, room); - addPuzzlesToReferenceTable(room); + fileName = Common::String::format("%c%c.scr", _nextLocation.world, _nextLocation.room); + parseScrFile(fileName, room); + addPuzzlesToReferenceTable(room); - fileName = Common::String::format("%c.scr", _nextLocation.world); - parseScrFile(fileName, world); - addPuzzlesToReferenceTable(world); + } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) { + cleanScriptScope(nodeview); + + addPuzzlesToReferenceTable(room); + addPuzzlesToReferenceTable(world); + + Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view); + parseScrFile(fileName, nodeview); + addPuzzlesToReferenceTable(nodeview); + } _activeControls = &nodeview._controls; // Revert to the idle cursor _engine->getCursorManager()->changeCursor(CursorIndex_Idle); - // Reset the background velocity - //_engine->getRenderManager()->setBackgroundVelocity(0); - - // Remove any alphaEntries - //_engine->getRenderManager()->clearAlphaEntries(); - // Change the background position _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); - // Update _currentLocation - _currentLocation = _nextLocation; - - execScope(room); - execScope(nodeview); + if (_currentLocation.world == 0 && _currentLocation.room == 0 && _currentLocation.node == 0 && _currentLocation.view == 0) { + _currentLocation = _nextLocation; + execScope(world); + execScope(room); + execScope(nodeview); + } else if (_nextLocation.world != _currentLocation.world) { + _currentLocation = _nextLocation; + execScope(room); + execScope(nodeview); + } else if (_nextLocation.room != _currentLocation.room) { + _currentLocation = _nextLocation; + execScope(room); + execScope(nodeview); + } else if (_nextLocation.node != _currentLocation.node || _nextLocation.view != _currentLocation.view) { + _currentLocation = _nextLocation; + execScope(nodeview); + } } void ScriptManager::serializeStateTable(Common::WriteStream *stream) { -- cgit v1.2.3 From 665014033d2163f5029a3284c3dd3cbad8d7bf1d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 1 Mar 2014 20:39:24 +0700 Subject: ZVISION: Add functions for framedelay controlling in animation_node --- engines/zvision/animation_node.cpp | 17 +++++++++++++++++ engines/zvision/animation_node.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 89d0f5e451..365ff747f4 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -191,4 +191,21 @@ bool AnimationNode::stop() { return false; } +void AnimationNode::setNewFrameDelay(int32 newDelay) { + if (newDelay > 0) { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + float percent = (float)nod->_delay / (float)_frmDelay; + nod->_delay = percent * newDelay; // Scale to new max + } + + _frmDelay = newDelay; + } +} + +int32 AnimationNode::getFrameDelay() { + return _frmDelay; +} + } // End of namespace ZVision diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h index 556ab8a51f..ff7636a31f 100644 --- a/engines/zvision/animation_node.h +++ b/engines/zvision/animation_node.h @@ -74,6 +74,9 @@ public: void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); bool stop(); + + void setNewFrameDelay(int32 newDelay); + int32 getFrameDelay(); }; } // End of namespace ZVision -- cgit v1.2.3 From d90b325a3b0ec5ab455f8b8ae90bef9a528600df Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 1 Mar 2014 20:41:13 +0700 Subject: ZVISION: Implement syncsound sidefx class and action class. --- engines/zvision/actions.cpp | 30 ++++++++++++ engines/zvision/actions.h | 10 ++++ engines/zvision/module.mk | 3 +- engines/zvision/scr_file_handling.cpp | 2 +- engines/zvision/syncsound_node.cpp | 86 +++++++++++++++++++++++++++++++++++ engines/zvision/syncsound_node.h | 56 +++++++++++++++++++++++ 6 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 engines/zvision/syncsound_node.cpp create mode 100644 engines/zvision/syncsound_node.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index c3f85fe247..bab1a5e1a1 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -31,6 +31,7 @@ #include "zvision/zork_avi_decoder.h" #include "zvision/timer_node.h" #include "zvision/music_node.h" +#include "zvision/syncsound_node.h" #include "zvision/animation_node.h" #include "common/file.h" @@ -587,6 +588,35 @@ bool ActionStreamVideo::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionSyncSound +////////////////////////////////////////////////////////////////////////////// + +ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + char fileName[25]; + int not_used; + + sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬_used, fileName); + + _fileName = Common::String(fileName); +} + +bool ActionSyncSound::execute() { + SideFX *fx = _engine->getScriptManager()->getSideFX(_syncto); + if (!fx) + return true; + + if (!(fx->getType() & SideFX::SIDEFX_ANIM)) + return true; + + AnimationNode *animnode = (AnimationNode *)fx; + if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload + animnode->setNewFrameDelay(66); // ~15fps + + _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotkey, _fileName, _syncto)); + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionTimer diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index f4a2c0f387..bc88a6d67f 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -381,6 +381,16 @@ private: bool _skippable; }; +class ActionSyncSound : public ResultAction { +public: + ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + int _syncto; + Common::String _fileName; +}; + class ActionTimer : public ResultAction { public: ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index c8f629de1f..90a297591c 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -38,7 +38,8 @@ MODULE_OBJS := \ meta_animation.o \ search_manager.o \ text.o \ - subtitles.o + subtitles.o \ + syncsound_node.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index db4e8fa9b1..347c3a6712 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -277,7 +277,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("streamvideo", true)) { actionList.push_back(new ActionStreamVideo(_engine, slot, args)); } else if (act.matchString("syncsound", true)) { - // TODO: Implement ActionSyncSound + actionList.push_back(new ActionSyncSound(_engine, slot, args)); } else if (act.matchString("timer", true)) { actionList.push_back(new ActionTimer(_engine, slot, args)); } else if (act.matchString("ttytext", true)) { diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp new file mode 100644 index 0000000000..5d04c1fb70 --- /dev/null +++ b/engines/zvision/syncsound_node.cpp @@ -0,0 +1,86 @@ +/* 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 "common/scummsys.h" + +#include "zvision/syncsound_node.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" +#include "zvision/render_manager.h" +#include "zvision/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + + +namespace ZVision { + +SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) + : SideFX(engine, key, SIDEFX_AUDIO) { + _syncto = syncto; + _sub = NULL; + + Audio::RewindableAudioStream *audioStream; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (_engine->getSearchManager()->openFile(*file, filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream); + + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); +} + +SyncSoundNode::~SyncSoundNode() { + _engine->_mixer->stopHandle(_handle); + if (_sub) + delete _sub; +} + +bool SyncSoundNode::process(uint32 deltaTimeInMillis) { + if (! _engine->_mixer->isSoundHandleActive(_handle)) + return stop(); + else { + + if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) + return stop(); + + if (_sub) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); + } + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h new file mode 100644 index 0000000000..7d875f2797 --- /dev/null +++ b/engines/zvision/syncsound_node.h @@ -0,0 +1,56 @@ +/* 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 ZVISION_SYNCSOUND_NODE_H +#define ZVISION_SYNCSOUND_NODE_H + +#include "audio/mixer.h" +#include "zvision/sidefx.h" +#include "zvision/subtitles.h" + +namespace Common { +class String; +} + +namespace ZVision { +class SyncSoundNode : public SideFX { +public: + SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto); + ~SyncSoundNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + int32 _syncto; + Audio::SoundHandle _handle; + Subtitle *_sub; +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From eb9061e580ce7c055c4f7cafe9bd81823367f39d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 2 Mar 2014 00:03:25 +0700 Subject: ZVISION: Refactor video-play and correct streamvideo for use subtitles and correct scale. --- engines/zvision/actions.cpp | 20 ++++++-- engines/zvision/subtitles.h | 2 + engines/zvision/video.cpp | 116 ++++++++++++-------------------------------- engines/zvision/zvision.cpp | 1 + engines/zvision/zvision.h | 3 +- 5 files changed, 51 insertions(+), 91 deletions(-) diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index bab1a5e1a1..99fa6a646d 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -577,12 +577,22 @@ bool ActionStreamVideo::execute() { return true; } - Common::Rect destRect; - if ((_flags & DIFFERENT_DIMENSIONS) == DIFFERENT_DIMENSIONS) { - destRect = Common::Rect(_x1, _y1, _x2, _y2); - } + Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1); + + Common::String subname = _fileName; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + Subtitle *sub = NULL; + + if (_engine->getSearchManager()->hasFile(subname)) + sub = new Subtitle(_engine, subname); + + _engine->playVideo(decoder, destRect, _skippable, sub); - _engine->playVideo(decoder, destRect, _skippable); + if (sub) + delete sub; } return true; diff --git a/engines/zvision/subtitles.h b/engines/zvision/subtitles.h index d14cb6f052..698561b655 100644 --- a/engines/zvision/subtitles.h +++ b/engines/zvision/subtitles.h @@ -28,6 +28,8 @@ namespace ZVision { +class ZVision; + class Subtitle { public: Subtitle(ZVision *engine, const Common::String &subname); diff --git a/engines/zvision/video.cpp b/engines/zvision/video.cpp index 6b7299ea84..0ad9000fcb 100644 --- a/engines/zvision/video.cpp +++ b/engines/zvision/video.cpp @@ -26,6 +26,7 @@ #include "zvision/clock.h" #include "zvision/render_manager.h" +#include "zvision/subtitles.h" #include "common/system.h" @@ -38,90 +39,32 @@ namespace ZVision { -// Taken/modified from SCI -void scaleBuffer(const byte *src, byte *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint scaleAmount) { - assert(bytesPerPixel == 1 || bytesPerPixel == 2); - - const uint32 newWidth = srcWidth * scaleAmount; - const uint32 pitch = newWidth * bytesPerPixel; - const byte *srcPtr = src; - - if (bytesPerPixel == 1) { - for (uint32 y = 0; y < srcHeight; ++y) { - for (uint32 x = 0; x < srcWidth; ++x) { - const byte color = *srcPtr++; - - for (uint i = 0; i < scaleAmount; ++i) { - dst[i] = color; - dst[pitch + i] = color; - } - dst += scaleAmount; - } - dst += pitch; - } - } else if (bytesPerPixel == 2) { - for (uint32 y = 0; y < srcHeight; ++y) { - for (uint32 x = 0; x < srcWidth; ++x) { - const byte color = *srcPtr++; - const byte color2 = *srcPtr++; - - for (uint i = 0; i < scaleAmount; ++i) { - uint index = i * 2; - - dst[index] = color; - dst[index + 1] = color2; - dst[pitch + index] = color; - dst[pitch + index + 1] = color2; - } - dst += 2 * scaleAmount; - } - dst += pitch; - } - } -} - -void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) { - byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel; - - uint16 origWidth = videoDecoder.getWidth(); - uint16 origHeight = videoDecoder.getHeight(); - - uint scale = 1; +void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) { + Common::Rect dst = destRect; // If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway - if (destRect.isEmpty()) { - // Most videos are very small. Therefore we do a simple 2x scale - if (origWidth * 2 <= 640 && origHeight * 2 <= 480) { - scale = 2; - } - } else { - // Assume bilinear scaling. AKA calculate the scale from just the width. - // Also assume that the scaling is in integral intervals. AKA no 1.5x scaling - // TODO: Test ^these^ assumptions - scale = destRect.width() / origWidth; + if (dst.isEmpty()) + dst = Common::Rect(vid.getWidth(), vid.getHeight()); - // TODO: Test if we need to support downscale. - } - - uint16 pitch = origWidth * bytesPerPixel; + Graphics::Surface *scaled = NULL; - uint16 finalWidth = origWidth * scale; - uint16 finalHeight = origHeight * scale; - - byte *scaledVideoFrameBuffer; - if (scale != 1) { - scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel]; + if (vid.getWidth() != dst.width() || vid.getHeight() != dst.height()) { + scaled = new Graphics::Surface; + scaled->create(dst.width(), dst.height(), vid.getPixelFormat()); } - uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left; - uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top; + + uint16 x = _workingWindow.left + dst.left; + uint16 y = _workingWindow.top + dst.top; + uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width(); + uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height(); _clock.stop(); - videoDecoder.start(); + vid.start(); // Only continue while the video is still playing - while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) { + while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) { // Check for engine quit and video stop key presses - while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) { + while (_eventMan->pollEvent(_event)) { switch (_event.type) { case Common::EVENT_KEYDOWN: switch (_event.kbd.keycode) { @@ -131,7 +74,7 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d break; case Common::KEYCODE_SPACE: if (skippable) { - videoDecoder.stop(); + vid.stop(); } break; default: @@ -142,29 +85,32 @@ void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &d } } - if (videoDecoder.needsUpdate()) { - const Graphics::Surface *frame = videoDecoder.decodeNextFrame(); + if (vid.needsUpdate()) { + const Graphics::Surface *frame = vid.decodeNextFrame(); + if (sub) + sub->process(vid.getCurFrame()); if (frame) { - if (scale != 1) { - scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale); - _system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight); - } else { - _system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight); + if (scaled) { + _renderManager->scaleBuffer(frame->getPixels(), scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, scaled->w, scaled->h); + frame = scaled; } + _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, finalWidth, finalHeight); + _renderManager->processSubs(0); } } // Always update the screen so the mouse continues to render _system->updateScreen(); - _system->delayMillis(videoDecoder.getTimeToNextFrame()); + _system->delayMillis(vid.getTimeToNextFrame() / 2); } _clock.start(); - if (scale != 1) { - delete[] scaledVideoFrameBuffer; + if (scaled) { + scaled->free(); + delete scaled; } } diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 4c5164cd6e..b1615aa7b4 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -35,6 +35,7 @@ #include "zvision/menu.h" #include "zvision/search_manager.h" #include "zvision/text.h" +#include "zvision/truetype_font.h" #include "common/config-manager.h" #include "common/str.h" diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index bbcaf3c952..982d3fd98b 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -54,6 +54,7 @@ class SaveManager; class RlfAnimation; class menuHandler; class textRenderer; +class Subtitle; class ZVision : public Engine { public: @@ -161,7 +162,7 @@ public: * @param destRect Where to put the video. (In working window coords) * @param skippable If true, the video can be skipped at any time using [Spacebar] */ - void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true); + void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL); Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); -- cgit v1.2.3 From 2a4e9a63588bc462c2a71195bb7597fe81ab0617 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 5 Mar 2014 16:21:03 +0700 Subject: ZVISION: Refactor of save functions --- engines/zvision/save_manager.cpp | 157 ++++++++++++++++++++++--------------- engines/zvision/save_manager.h | 9 ++- engines/zvision/script_manager.cpp | 131 +++++++++++++++++++++++++++---- engines/zvision/script_manager.h | 6 +- engines/zvision/timer_node.cpp | 4 +- 5 files changed, 224 insertions(+), 83 deletions(-) diff --git a/engines/zvision/save_manager.cpp b/engines/zvision/save_manager.cpp index e8947d8d16..15b7424de7 100644 --- a/engines/zvision/save_manager.cpp +++ b/engines/zvision/save_manager.cpp @@ -42,44 +42,27 @@ const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); void SaveManager::saveGame(uint slot, const Common::String &saveName) { // The games only support 20 slots - assert(slot <= 1 && slot <= 20); + //assert(slot <= 1 && slot <= 20); Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - // Write out the savegame header - file->writeUint32BE(SAVEGAME_ID); - - // Write version - file->writeByte(SAVE_VERSION); + writeSaveGameHeader(file, saveName); - // Write savegame name - file->writeString(saveName); - file->writeByte(0); + _engine->getScriptManager()->serialize(file); - // We can't call writeGameSaveData because the save menu is actually - // a room, so writeGameSaveData would save us in the save menu. - // However, an auto save is performed before each room change, so we - // can copy the data from there. We can guarantee that an auto save file will - // exist before this is called because the save menu can only be accessed - // after the first room (the main menu) has loaded. - Common::InSaveFile *autoSaveFile = saveFileManager->openForLoading(_engine->generateAutoSaveFileName()); + file->finalize(); + delete file; +} - // Skip over the header info - autoSaveFile->readSint32BE(); // SAVEGAME_ID - autoSaveFile->readByte(); // Version - autoSaveFile->seek(5, SEEK_CUR); // The string "auto" with terminating NULL +void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { + Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); + Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - // Read the rest to a buffer - uint32 size = autoSaveFile->size() - autoSaveFile->pos(); - byte *buffer = new byte[size]; - autoSaveFile->read(buffer, size); + writeSaveGameHeader(file, saveName); - // Then write the buffer to the new file - file->write(buffer, size); + file->write(stream->getData(), stream->size()); - // Cleanup - delete[] buffer; file->finalize(); delete file; } @@ -87,23 +70,26 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) { void SaveManager::autoSave() { Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); - // Write out the savegame header - file->writeUint32BE(SAVEGAME_ID); - - // Version - file->writeByte(SAVE_VERSION); + writeSaveGameHeader(file, "auto"); - file->writeString("auto"); - file->writeByte(0); - - writeSaveGameData(file); + _engine->getScriptManager()->serialize(file); // Cleanup file->finalize(); delete file; } -void SaveManager::writeSaveGameData(Common::OutSaveFile *file) { +void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { + + file->writeUint32BE(SAVEGAME_ID); + + // Write version + file->writeByte(SAVE_VERSION); + + // Write savegame name + file->writeString(saveName); + file->writeByte(0); + // Create a thumbnail and save it Graphics::saveThumbnail(*file); @@ -115,26 +101,13 @@ void SaveManager::writeSaveGameData(Common::OutSaveFile *file) { file->writeSint16LE(td.tm_mday); file->writeSint16LE(td.tm_hour); file->writeSint16LE(td.tm_min); - - ScriptManager *scriptManager = _engine->getScriptManager(); - // Write out the current location - Location currentLocation = scriptManager->getCurrentLocation(); - file->writeByte(currentLocation.world); - file->writeByte(currentLocation.room); - file->writeByte(currentLocation.node); - file->writeByte(currentLocation.view); - file->writeUint32LE(currentLocation.offset); - - // Write out the current state table values - scriptManager->serializeStateTable(file); - } Common::Error SaveManager::loadGame(uint slot) { // The games only support 20 slots - assert(slot <= 1 && slot <= 20); + //assert(slot <= 1 && slot <= 20); - Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); + Common::SeekableReadStream *saveFile = getSlotFile(slot); if (saveFile == 0) { return Common::kPathDoesNotExist; } @@ -145,24 +118,59 @@ Common::Error SaveManager::loadGame(uint slot) { return Common::kUnknownError; } - char world = (char)saveFile->readByte(); - char room = (char)saveFile->readByte(); - char node = (char)saveFile->readByte(); - char view = (char)saveFile->readByte(); - uint32 offset = (char)saveFile->readUint32LE(); + ScriptManager *scriptManager = _engine->getScriptManager(); + // Update the state table values + scriptManager->deserialize(saveFile); + + delete saveFile; + if (header.thumbnail) + delete header.thumbnail; + + return Common::kNoError; +} + +Common::Error SaveManager::loadGame(const Common::String &saveName) { + Common::File *saveFile = _engine->getSearchManager()->openFile(saveName); + if (saveFile == NULL) { + saveFile = new Common::File; + if (!saveFile->open(saveName)) { + delete saveFile; + return Common::kPathDoesNotExist; + } + } + + // Read the header + SaveGameHeader header; + if (!readSaveGameHeader(saveFile, header)) { + return Common::kUnknownError; + } ScriptManager *scriptManager = _engine->getScriptManager(); // Update the state table values - scriptManager->deserializeStateTable(saveFile); + scriptManager->deserialize(saveFile); - // Load the room - scriptManager->changeLocation(world, room, node, view, offset); + delete saveFile; + if (header.thumbnail) + delete header.thumbnail; return Common::kNoError; } bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { - if (in->readUint32BE() != SAVEGAME_ID) { + uint32 tag = in->readUint32BE(); + if (tag == MKTAG('Z', 'N', 'S', 'G')) { + header.saveYear = 0; + header.saveMonth = 0; + header.saveDay = 0; + header.saveHour = 0; + header.saveMinutes = 0; + header.saveName = "Original Save"; + header.thumbnail = NULL; + header.version = SAVE_ORIGINAL; + in->seek(-4, SEEK_CUR); + return true; + } + if (tag != SAVEGAME_ID) { warning("File is not a ZVision save file. Aborting load"); return false; } @@ -198,4 +206,29 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea return true; } +Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { + Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); + if (saveFile == NULL) { + // Try to load standart save file + Common::String filename; + if (_engine->getGameId() == GID_GRANDINQUISITOR) + filename.format("inqsav%u.sav", slot); + else if (_engine->getGameId() == GID_NEMESIS) + filename.format("nemsav%u.sav", slot); + + saveFile = _engine->getSearchManager()->openFile(filename); + if (saveFile == NULL) { + Common::File *tmpFile = new Common::File; + if (!tmpFile->open(filename)) { + delete tmpFile; + } else { + saveFile = tmpFile; + } + } + + } + + return saveFile; +} + } // End of namespace ZVision diff --git a/engines/zvision/save_manager.h b/engines/zvision/save_manager.h index ec80b37e20..84afc8cb13 100644 --- a/engines/zvision/save_manager.h +++ b/engines/zvision/save_manager.h @@ -24,6 +24,7 @@ #define ZVISION_SAVE_MANAGER_H #include "common/savefile.h" +#include "common/memstream.h" namespace Common { class String; @@ -54,6 +55,7 @@ private: static const uint32 SAVEGAME_ID; enum { + SAVE_ORIGINAL = 0, SAVE_VERSION = 1 }; @@ -73,6 +75,7 @@ public: * @param saveName The internal name for this save. This is NOT the name of the actual save file. */ void saveGame(uint slot, const Common::String &saveName); + void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); /** * Loads the state data from the save file that slot references. Uses * ZVision::generateSaveFileName(slot) to get the save file name. @@ -80,10 +83,12 @@ public: * @param slot The save slot to load. Must be [1, 20] */ Common::Error loadGame(uint slot); + Common::Error loadGame(const Common::String &saveName); + Common::SeekableReadStream *getSlotFile(uint slot); + bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); private: - void writeSaveGameData(Common::OutSaveFile *file); - bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header); + void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; } // End of namespace ZVision diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 54d126f8cb..5e101cb58f 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -30,6 +30,7 @@ #include "zvision/save_manager.h" #include "zvision/actions.h" #include "zvision/utility.h" +#include "zvision/timer_node.h" #include "common/algorithm.h" #include "common/hashmap.h" @@ -283,6 +284,13 @@ void ScriptManager::setStateValue(uint32 key, int value) { queuePuzzles(key); } +void ScriptManager::setStateValueSilent(uint32 key, int value) { + if (value == 0) + _globalState.erase(key); + else + _globalState[key] = value; +} + uint ScriptManager::getStateFlag(uint32 key) { if (_globalStateFlags.contains(key)) return _globalStateFlags[key]; @@ -296,6 +304,13 @@ void ScriptManager::setStateFlag(uint32 key, uint value) { _globalStateFlags[key] |= value; } +void ScriptManager::setStateFlagSilent(uint32 key, uint value) { + if (value == 0) + _globalStateFlags.erase(key); + else + _globalStateFlags[key] = value; +} + void ScriptManager::unsetStateFlag(uint32 key, uint value) { queuePuzzles(key); @@ -560,30 +575,114 @@ void ScriptManager::do_changeLocation() { } } -void ScriptManager::serializeStateTable(Common::WriteStream *stream) { - // Write the number of state value entries - stream->writeUint32LE(_globalState.size()); +void ScriptManager::serialize(Common::WriteStream *stream) { + stream->writeUint32BE(MKTAG('Z', 'N', 'S', 'G')); + stream->writeUint32LE(4); + stream->writeUint32LE(0); + stream->writeUint32BE(MKTAG('L', 'O', 'C', ' ')); + stream->writeUint32LE(8); + stream->writeByte(getStateValue(StateKey_World)); + stream->writeByte(getStateValue(StateKey_Room)); + stream->writeByte(getStateValue(StateKey_Node)); + stream->writeByte(getStateValue(StateKey_View)); + stream->writeUint32LE(getStateValue(StateKey_ViewPos)); - for (StateMap::iterator iter = _globalState.begin(); iter != _globalState.end(); ++iter) { - // Write out the key/value pair - stream->writeUint32LE(iter->_key); - stream->writeUint32LE(iter->_value); - } + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) + (*iter)->serialize(stream); + + stream->writeUint32BE(MKTAG('F', 'L', 'A', 'G')); + + int32 slots = 20000; + if (_engine->getGameId() == GID_NEMESIS) + slots = 30000; + + stream->writeUint32LE(slots * 2); + + for (int32 i = 0; i < slots; i++) + stream->writeUint16LE(getStateFlag(i)); + + stream->writeUint32BE(MKTAG('P', 'U', 'Z', 'Z')); + + stream->writeUint32LE(slots * 2); + + for (int32 i = 0; i < slots; i++) + stream->writeSint16LE(getStateValue(i)); } -void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) { +void ScriptManager::deserialize(Common::SeekableReadStream *stream) { // Clear out the current table values _globalState.clear(); + _globalStateFlags.clear(); - // Read the number of key/value pairs - uint32 numberOfPairs = stream->readUint32LE(); + cleanScriptScope(nodeview); + cleanScriptScope(room); + cleanScriptScope(world); - for (uint32 i = 0; i < numberOfPairs; ++i) { - uint32 key = stream->readUint32LE(); - uint32 value = stream->readUint32LE(); - // Directly access the state table so we don't trigger Puzzle checks - _globalState[key] = value; + _currentLocation.node = 0; + _currentLocation.world = 0; + _currentLocation.room = 0; + _currentLocation.view = 0; + + for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); iter++) + delete(*iter); + + _activeSideFx.clear(); + + _referenceTable.clear(); + + if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) { + changeLocation('g', 'a', 'r', 'y', 0); + debug("ZNSG"); + return; } + + stream->seek(4, SEEK_CUR); + + if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) { + changeLocation('g', 'a', 'r', 'y', 0); + debug("LOC"); + return; + } + + Location next_loc; + + next_loc.world = stream->readByte(); + next_loc.room = stream->readByte(); + next_loc.node = stream->readByte(); + next_loc.view = stream->readByte(); + next_loc.offset = stream->readUint32LE() & 0x0000FFFF; + + // What the fck, eos is not 'return pos >= size' + // while (!stream->eos()) {*/ + while (stream->pos() < stream->size()) { + uint32 tag = stream->readUint32BE(); + uint32 tag_size = stream->readUint32LE(); + switch (tag) { + case MKTAG('T', 'I', 'M', 'R'): { + uint32 key = stream->readUint32LE(); + uint32 time = stream->readUint32LE(); + addSideFX(new TimerNode(_engine, key, time)); + } + break; + case MKTAG('F', 'L', 'A', 'G'): + for (uint32 i = 0; i < tag_size / 2; i++) + setStateFlagSilent(i, stream->readUint16LE()); + break; + case MKTAG('P', 'U', 'Z', 'Z'): + for (uint32 i = 0; i < tag_size / 2; i++) + setStateValueSilent(i, stream->readUint16LE()); + break; + default: + stream->seek(tag_size, SEEK_CUR); + } + } + + _nextLocation = next_loc; + + do_changeLocation(); + // Place for read prefs + _engine->setRenderDelay(10); + setStateValue(StateKey_RestoreFlag, 1); } Location ScriptManager::getCurrentLocation() const { diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 2f585b6291..6adade5745 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -230,8 +230,8 @@ public: /** Mark next location */ void changeLocation(char world, char room, char node, char view, uint32 offset); - void serializeStateTable(Common::WriteStream *stream); - void deserializeStateTable(Common::SeekableReadStream *stream); + void serialize(Common::WriteStream *stream); + void deserialize(Common::SeekableReadStream *stream); Location getCurrentLocation() const; @@ -253,6 +253,8 @@ private: int16 invertory_getItem(int8 id); void invertory_setItem(int8 id, int16 item); + void setStateFlagSilent(uint32 key, uint value); + void setStateValueSilent(uint32 key, int value); public: void invertory_add(int16 item); diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index f8da0bcf37..0d7f9b1114 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -67,8 +67,10 @@ bool TimerNode::stop() { } void TimerNode::serialize(Common::WriteStream *stream) { + stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); + stream->writeUint32LE(8); // size stream->writeUint32LE(_key); - stream->writeUint32LE(_timeLeft); + stream->writeUint32LE(_timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100)); } void TimerNode::deserialize(Common::SeekableReadStream *stream) { -- cgit v1.2.3 From 5eb6462d60a27ef158afbfc23b578b6f57f8f789 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 5 Mar 2014 18:29:55 +0700 Subject: ZVISION: Remove forgotten debug prints --- engines/zvision/script_manager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 5e101cb58f..2178887469 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -632,7 +632,6 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) { changeLocation('g', 'a', 'r', 'y', 0); - debug("ZNSG"); return; } @@ -640,7 +639,6 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { if (stream->readUint32BE() != MKTAG('L', 'O', 'C', ' ') || stream->readUint32LE() != 8) { changeLocation('g', 'a', 'r', 'y', 0); - debug("LOC"); return; } -- cgit v1.2.3 From 5f92871a9c76d5f8bda74c10ef304c3ec1a328f5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 5 Mar 2014 18:44:23 +0700 Subject: ZVISION: Fix timer values for savegame --- engines/zvision/script_manager.cpp | 4 ++++ engines/zvision/timer_node.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 2178887469..1a567397a8 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -659,6 +659,10 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { case MKTAG('T', 'I', 'M', 'R'): { uint32 key = stream->readUint32LE(); uint32 time = stream->readUint32LE(); + if (_engine->getGameId() == GID_GRANDINQUISITOR) + time /= 100; + else if (_engine->getGameId() == GID_NEMESIS) + time /= 1000; addSideFX(new TimerNode(_engine, key, time)); } break; diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index 0d7f9b1114..a94f6db19b 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -70,7 +70,7 @@ void TimerNode::serialize(Common::WriteStream *stream) { stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); stream->writeUint32LE(8); // size stream->writeUint32LE(_key); - stream->writeUint32LE(_timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100)); + stream->writeUint32LE(_timeLeft); } void TimerNode::deserialize(Common::SeekableReadStream *stream) { -- cgit v1.2.3 From 26d923e354d22a3d8aeb007f4d6f1e5dc669efb4 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 5 Mar 2014 18:47:52 +0700 Subject: ZVISION: Fix incompatibility of puzzle flugs with original saves. --- engines/zvision/puzzle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index e06b087aca..4d50756b87 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -65,8 +65,8 @@ struct Puzzle { enum StateFlags { ONCE_PER_INST = 0x01, - DO_ME_NOW = 0x02, // Somewhat useless flag since anything that needs to be done immediately has no criteria - DISABLED = 0x04 + DISABLED = 0x02, + DO_ME_NOW = 0x04 }; uint32 key; -- cgit v1.2.3 From 7d1c4ec27cb197ea729ab468ecd7f4cbd4594202 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 6 Mar 2014 15:22:05 +0700 Subject: ZVISION: Fix rlf incorrect ABS -128 issue --- engines/zvision/rlf_animation.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp index f23f569d98..5784df0dac 100644 --- a/engines/zvision/rlf_animation.cpp +++ b/engines/zvision/rlf_animation.cpp @@ -268,6 +268,7 @@ void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) { void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; + int16 numberOfCopy = 0; while (sourceOffset < sourceSize) { int8 numberOfSamples = source[sourceOffset]; @@ -276,9 +277,9 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3 // If numberOfSamples is negative, the next abs(numberOfSamples) samples should // be copied directly from source to dest if (numberOfSamples < 0) { - numberOfSamples = ABS(numberOfSamples); + numberOfCopy = -numberOfSamples; - while (numberOfSamples > 0) { + while (numberOfCopy > 0) { if (sourceOffset + 1 >= sourceSize) { return; } else if (destOffset + 1 >= destSize) { @@ -293,7 +294,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3 sourceOffset += 2; destOffset += 2; - numberOfSamples--; + numberOfCopy--; } // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2) @@ -314,6 +315,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3 void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; + int16 numberOfCopy = 0; while (sourceOffset < sourceSize) { int8 numberOfSamples = source[sourceOffset]; @@ -322,9 +324,9 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3 // If numberOfSamples is negative, the next abs(numberOfSamples) samples should // be copied directly from source to dest if (numberOfSamples < 0) { - numberOfSamples = ABS(numberOfSamples); + numberOfCopy = -numberOfSamples; - while (numberOfSamples > 0) { + while (numberOfCopy > 0) { if (sourceOffset + 1 >= sourceSize) { return; } else if (destOffset + 1 >= destSize) { @@ -339,7 +341,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3 sourceOffset += 2; destOffset += 2; - numberOfSamples--; + numberOfCopy--; } // If numberOfSamples is >= 0, copy one sample from source to the @@ -354,8 +356,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3 uint16 sampleColor = Graphics::RGBToColor >(r, g, b); sourceOffset += 2; - numberOfSamples += 2; - while (numberOfSamples > 0) { + numberOfCopy = numberOfSamples + 2; + while (numberOfCopy > 0) { if (destOffset + 1 >= destSize) { debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); return; @@ -363,7 +365,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3 WRITE_UINT16(dest + destOffset, sampleColor); destOffset += 2; - numberOfSamples--; + numberOfCopy--; } } } -- cgit v1.2.3 From 84681a2439047b9c6a5fd0c89f9be383bd51ad7e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 6 Mar 2014 15:24:18 +0700 Subject: ZVISION: SearchManager dir index in ZIX-file started from 1 not 0, include up border --- engines/zvision/search_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp index 5c94ff0a26..124a49912d 100644 --- a/engines/zvision/search_manager.cpp +++ b/engines/zvision/search_manager.cpp @@ -211,7 +211,7 @@ void sManager::loadZix(const Common::String &name) { uint dr = 0; char buf[32]; if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { - if (dr < archives.size() && dr > 0) { + if (dr <= archives.size() && dr > 0) { addFile(Common::String(buf), archives[dr - 1]); } } -- cgit v1.2.3 From 74fe47748e11cc58aee46e986d6670636c027e32 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Mar 2014 08:16:17 +0700 Subject: ZVISION: Fix slot rendering for item-to-item click --- engines/zvision/slot_control.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp index 418aa8fad2..111a7c63e8 100644 --- a/engines/zvision/slot_control.cpp +++ b/engines/zvision/slot_control.cpp @@ -168,11 +168,18 @@ bool SlotControl::process(uint32 deltaTimeInMillis) { if (_engine->canRender()) { int cur_item = _engine->getScriptManager()->getStateValue(_key); if (cur_item != _rendered_item) { - if (_rendered_item == 0) { - if (_bkg) - delete _bkg; + if (_rendered_item != 0 && cur_item == 0) { + _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); + _rendered_item = cur_item; + } else { + if (_rendered_item == 0) { + if (_bkg) + delete _bkg; - _bkg = _engine->getRenderManager()->getBkgRect(_rectangle); + _bkg = _engine->getRenderManager()->getBkgRect(_rectangle); + } else { + _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); + } char buf[16]; if (_engine->getGameId() == GID_NEMESIS) @@ -195,9 +202,6 @@ bool SlotControl::process(uint32 deltaTimeInMillis) { delete srf; - _rendered_item = cur_item; - } else { - _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); _rendered_item = cur_item; } } -- cgit v1.2.3 From ea6e151047641563f588b6578aea80141f51bbd0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 9 Mar 2014 23:18:05 +0700 Subject: ZVISION: Add support for sharp(monochrome) font loading --- engines/zvision/text.cpp | 7 +++++++ engines/zvision/text.h | 1 + engines/zvision/truetype_font.cpp | 8 +++++--- engines/zvision/truetype_font.h | 3 ++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp index 575ca03d10..e96bf4b32c 100644 --- a/engines/zvision/text.cpp +++ b/engines/zvision/text.cpp @@ -58,6 +58,7 @@ cTxtStyle::cTxtStyle() { strikeout = false; underline = false; statebox = 0; + sharp = false; } txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { @@ -263,6 +264,9 @@ void cTxtStyle::setFontStyle(sTTFont &font) { if (strikeout) temp_stl |= sTTFont::STTF_STRIKEOUT; + if (sharp) + temp_stl |= sTTFont::STTF_SHARP; + font.setStyle(temp_stl); } @@ -281,6 +285,9 @@ void cTxtStyle::setFont(sTTFont &font) { if (strikeout) temp_stl |= sTTFont::STTF_STRIKEOUT; + if (sharp) + temp_stl |= sTTFont::STTF_SHARP; + font.loadFont(fontname, size, temp_stl); } diff --git a/engines/zvision/text.h b/engines/zvision/text.h index 40244f7f0c..6937832335 100644 --- a/engines/zvision/text.h +++ b/engines/zvision/text.h @@ -74,6 +74,7 @@ public: bool strikeout; bool skipcolor; int32 statebox; + bool sharp; // char image ?? }; diff --git a/engines/zvision/truetype_font.cpp b/engines/zvision/truetype_font.cpp index 5e1bc7a81d..e3eea403b6 100644 --- a/engines/zvision/truetype_font.cpp +++ b/engines/zvision/truetype_font.cpp @@ -189,6 +189,8 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { newFontName = "arial.ttf"; } + bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + Common::File *file = _engine->getSearchManager()->openFile(newFontName); if (!file) { @@ -210,7 +212,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { if (themeArchive->hasFile("FreeSans.ttf")) { Common::SeekableReadStream *stream = nullptr; stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); - Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60); // 66 dpi for 640 x 480 on 14" display + Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display if (_newFont) { if (!_font) delete _font; @@ -223,7 +225,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { themeArchive = nullptr; } } else { - Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60); // 66 dpi for 640 x 480 on 14" display + Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display if (_newFont) { if (!_font) delete _font; @@ -241,7 +243,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { } void sTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) != (newStyle & (STTF_BOLD | STTF_ITALIC))) { + if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { _style = newStyle; loadFont(_fntName, _lineHeight); } else { diff --git a/engines/zvision/truetype_font.h b/engines/zvision/truetype_font.h index 0462f35aff..497ac763c1 100644 --- a/engines/zvision/truetype_font.h +++ b/engines/zvision/truetype_font.h @@ -86,7 +86,8 @@ public: STTF_BOLD = 1, STTF_ITALIC = 2, STTF_UNDERLINE = 4, - STTF_STRIKEOUT = 8 + STTF_STRIKEOUT = 8, + STTF_SHARP = 16 }; private: -- cgit v1.2.3 From 6ca301c3205cf04e4aa37c16e21224223233ea9b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 9 Mar 2014 23:19:17 +0700 Subject: ZVISION: Add utf8 char length and utf8->uint16 functions --- engines/zvision/text.cpp | 30 ++++++++++++++++++++++++++++++ engines/zvision/text.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp index e96bf4b32c..2fdfafcdf6 100644 --- a/engines/zvision/text.cpp +++ b/engines/zvision/text.cpp @@ -515,5 +515,35 @@ Common::String readWideLine(Common::SeekableReadStream &stream) { return asciiString; } +int8 getUtf8CharSize(char chr) { + if ((chr & 0x80) == 0) + return 1; + else if ((chr & 0xE0) == 0xC0) + return 2; + else if ((chr & 0xF0) == 0xE0) + return 3; + else if ((chr & 0xF8) == 0xF0) + return 4; + else if ((chr & 0xFC) == 0xF8) + return 5; + else if ((chr & 0xFE) == 0xFC) + return 6; + + return 1; +} + +uint16 readUtf8Char(const char *chr) { + uint16 result = 0; + if ((chr[0] & 0x80) == 0) + result = chr[0]; + else if ((chr[0] & 0xE0) == 0xC0) + result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F); + else if ((chr[0] & 0xF0) == 0xE0) + result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F); + else + result = chr[0]; + + return result; +} } // End of namespace ZVision diff --git a/engines/zvision/text.h b/engines/zvision/text.h index 6937832335..c1dc0c167c 100644 --- a/engines/zvision/text.h +++ b/engines/zvision/text.h @@ -92,6 +92,8 @@ private: }; Common::String readWideLine(Common::SeekableReadStream &stream); +int8 getUtf8CharSize(char chr); +uint16 readUtf8Char(const char *chr); } // End of namespace ZVision -- cgit v1.2.3 From 48360645dcd5f8fddb135b6e31ae5cae4be8d77f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sun, 9 Mar 2014 23:20:27 +0700 Subject: ZVISION: Implement ttyText action --- engines/zvision/actions.cpp | 25 +++++ engines/zvision/actions.h | 12 +++ engines/zvision/module.mk | 3 +- engines/zvision/scr_file_handling.cpp | 2 +- engines/zvision/ttytext_node.cpp | 175 ++++++++++++++++++++++++++++++++++ engines/zvision/ttytext_node.h | 76 +++++++++++++++ 6 files changed, 291 insertions(+), 2 deletions(-) create mode 100644 engines/zvision/ttytext_node.cpp create mode 100644 engines/zvision/ttytext_node.h diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 99fa6a646d..f60a69744a 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -33,6 +33,7 @@ #include "zvision/music_node.h" #include "zvision/syncsound_node.h" #include "zvision/animation_node.h" +#include "zvision/ttytext_node.h" #include "common/file.h" @@ -653,4 +654,28 @@ bool ActionTimer::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionTtyText +////////////////////////////////////////////////////////////////////////////// + +ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + char filename[64]; + int32 x1, y1, x2, y2; + sscanf(line.c_str(), "%d %d %d %d %s %u", &x1, &y1, &x2, &y2, filename, &_delay); + _r = Common::Rect(x1, y1, x2, y2); + _filename = Common::String(filename); +} + +ActionTtyText::~ActionTtyText() { + _engine->getScriptManager()->killSideFx(_slotkey); +} + +bool ActionTtyText::execute() { + if (_engine->getScriptManager()->getSideFX(_slotkey)) + return true; + _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotkey, _filename, _r, _delay)); + return true; +} + } // End of namespace ZVision diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index bc88a6d67f..82532cef99 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -24,6 +24,7 @@ #define ZVISION_ACTIONS_H #include "common/str.h" +#include "common/rect.h" #include "audio/mixer.h" @@ -401,6 +402,17 @@ private: ValueSlot *_time; }; +class ActionTtyText : public ResultAction { +public: + ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line); + ~ActionTtyText(); + bool execute(); + +private: + Common::String _filename; + uint32 _delay; + Common::Rect _r; +}; } // End of namespace ZVision #endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 90a297591c..d6d0dd7b5a 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -39,7 +39,8 @@ MODULE_OBJS := \ search_manager.o \ text.o \ subtitles.o \ - syncsound_node.o + syncsound_node.o \ + ttytext_node.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp index 347c3a6712..9d1d0bf856 100644 --- a/engines/zvision/scr_file_handling.cpp +++ b/engines/zvision/scr_file_handling.cpp @@ -281,7 +281,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("timer", true)) { actionList.push_back(new ActionTimer(_engine, slot, args)); } else if (act.matchString("ttytext", true)) { - // TODO: Implement ActionTTYText + actionList.push_back(new ActionTtyText(_engine, slot, args)); } else if (act.matchString("universe_music", true)) { actionList.push_back(new ActionMusic(_engine, slot, args, true)); } else if (act.matchString("copy_file", true)) { diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp new file mode 100644 index 0000000000..4f64800cd7 --- /dev/null +++ b/engines/zvision/ttytext_node.cpp @@ -0,0 +1,175 @@ +/* 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 "common/scummsys.h" + +#include "zvision/ttytext_node.h" + +#include "zvision/zvision.h" +#include "zvision/script_manager.h" +#include "zvision/render_manager.h" +#include "zvision/text.h" + +#include "common/stream.h" +#include "common/file.h" + + +namespace ZVision { + +ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : + SideFX(engine, key, SIDEFX_TTYTXT), + _fnt(engine) { + _delay = delay; + _r = r; + _txtpos = 0; + _nexttime = 0; + _dx = 0; + _dy = 0; + + Common::File *infile = _engine->getSearchManager()->openFile(file); + if (infile) { + while (!infile->eos()) { + Common::String asciiLine = readWideLine(*infile); + if (asciiLine.empty()) { + continue; + } + _txtbuf += asciiLine; + } + + delete infile; + } + _img.create(_r.width(), _r.height(), _engine->_pixelFormat); + _style.sharp = true; + _style.readAllStyle(_txtbuf); + _style.setFont(_fnt); + _engine->getScriptManager()->setStateValue(_key, 1); +} + +ttyTextNode::~ttyTextNode() { + _engine->getScriptManager()->setStateValue(_key, 2); + _img.free(); +} + +bool ttyTextNode::process(uint32 deltaTimeInMillis) { + _nexttime -= deltaTimeInMillis; + + if (_nexttime < 0) { + if (_txtpos < _txtbuf.size()) { + if (_txtbuf[_txtpos] == '<') { + int32 strt = _txtpos; + int32 endt = 0; + int16 ret = 0; + while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) + _txtpos++; + endt = _txtpos; + if (strt != -1) + if ((endt - strt - 1) > 0) + ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); + + if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { + if (ret & TXT_RET_FNTCHG) + _style.setFont(_fnt); + if (ret & TXT_RET_FNTSTL) + _style.setFontStyle(_fnt); + + if (ret & TXT_RET_NEWLN) + newline(); + } + + if (ret & TXT_RET_HASSTBOX) { + Common::String buf; + buf.format("%d", _style.statebox); + + for (uint8 j = 0; j < buf.size(); j++) + outchar(buf[j]); + } + + _txtpos++; + } else { + int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]); + + uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + if (chr == ' ') { + uint32 i = _txtpos + charsz; + uint16 width = _fnt.getCharWidth(chr); + + while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') { + + int8 chsz = getUtf8CharSize(_txtbuf[i]); + uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + width += _fnt.getCharWidth(uchr); + + i += chsz; + } + + if (_dx + width > _r.width()) + newline(); + else + outchar(chr); + } else + outchar(chr); + + _txtpos += charsz; + } + _nexttime = _delay; + _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top); + } else + return stop(); + } + + return false; +} + +void ttyTextNode::scroll() { + int32 scrl = 0; + while (_dy - scrl > _r.height() - _fnt.getFontHeight()) + scrl += _fnt.getFontHeight(); + int8 *pixels = (int8 *)_img.getPixels(); + for (uint16 h = scrl; h < _img.h; h++) + memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch); + + _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0); + _dy -= scrl; +} + +void ttyTextNode::newline() { + _dy += _fnt.getFontHeight(); + _dx = 0; +} + +void ttyTextNode::outchar(uint16 chr) { + uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue); + + if (_dx + _fnt.getCharWidth(chr) > _r.width()) + newline(); + + if (_dy + _fnt.getFontHeight() >= _r.height()) + scroll(); + + _fnt.drawChar(&_img, chr, _dx, _dy, clr); + + _dx += _fnt.getCharWidth(chr); +} + +} // End of namespace ZVision diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h new file mode 100644 index 0000000000..6c3e6f46af --- /dev/null +++ b/engines/zvision/ttytext_node.h @@ -0,0 +1,76 @@ +/* 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 ZVISION_TTYTEXT_NODE_H +#define ZVISION_TTYTEXT_NODE_H + +#include "common/rect.h" +#include "graphics/surface.h" + +#include "zvision/sidefx.h" +#include "zvision/text.h" +#include "zvision/truetype_font.h" + +namespace Common { +class String; +} + +namespace ZVision { +class ttyTextNode : public SideFX { +public: + ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay); + ~ttyTextNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + Common::Rect _r; + //int16 x; + //int16 y; + //uint16 w; + //uint16 h; + cTxtStyle _style; + sTTFont _fnt; + Common::String _txtbuf; + uint32 _txtpos; + //int32 txtsize; + int32 _delay; + int32 _nexttime; + Graphics::Surface _img; + int16 _dx; + int16 _dy; +private: + + void newline(); + void scroll(); + void outchar(uint16 chr); +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From ace0e5e88f63f34dad94962c95f57f3ec42258ae Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 14 Jun 2014 15:18:24 +0700 Subject: ZVISION: Fix compilation errors with latest scummvm --- engines/zvision/animation/rlf_animation.cpp | 2 +- engines/zvision/animation_node.cpp | 4 +- engines/zvision/core/console.cpp | 62 +++++++++++----------- engines/zvision/core/events.cpp | 12 ++--- engines/zvision/core/menu.h | 2 +- engines/zvision/cursors/cursor.cpp | 2 +- engines/zvision/cursors/cursor_manager.cpp | 2 +- engines/zvision/cursors/cursor_manager.h | 2 +- engines/zvision/fonts/truetype_font.cpp | 8 +-- engines/zvision/fonts/truetype_font.h | 6 +-- engines/zvision/graphics/render_manager.cpp | 10 ++-- engines/zvision/graphics/render_manager.h | 4 +- engines/zvision/inventory_manager.cpp | 2 +- engines/zvision/menu.cpp | 4 +- engines/zvision/meta_animation.cpp | 8 +-- engines/zvision/module.mk | 52 +++++++++--------- engines/zvision/music_node.cpp | 6 +-- engines/zvision/music_node.h | 2 +- engines/zvision/scripting/actions.cpp | 12 ++--- .../zvision/scripting/controls/input_control.cpp | 10 ++-- .../zvision/scripting/controls/lever_control.cpp | 10 ++-- engines/zvision/scripting/controls/timer_node.cpp | 4 +- engines/zvision/scripting/puzzle.h | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 12 ++--- engines/zvision/scripting/script_manager.cpp | 14 ++--- engines/zvision/scripting/script_manager.h | 4 +- engines/zvision/search_manager.cpp | 2 +- engines/zvision/sidefx.cpp | 4 +- engines/zvision/slot_control.cpp | 8 +-- engines/zvision/slot_control.h | 2 +- engines/zvision/sound/zork_raw.cpp | 4 +- engines/zvision/subtitles.cpp | 4 +- engines/zvision/syncsound_node.cpp | 6 +-- engines/zvision/syncsound_node.h | 2 +- engines/zvision/text.cpp | 6 +-- engines/zvision/text.h | 2 +- engines/zvision/ttytext_node.cpp | 4 +- engines/zvision/ttytext_node.h | 2 +- engines/zvision/video/video.cpp | 6 +-- engines/zvision/video/zork_avi_decoder.h | 2 +- engines/zvision/zvision.cpp | 18 +++---- engines/zvision/zvision.h | 2 +- 42 files changed, 166 insertions(+), 166 deletions(-) diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp index 5784df0dac..2bb0271966 100644 --- a/engines/zvision/animation/rlf_animation.cpp +++ b/engines/zvision/animation/rlf_animation.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#include "zvision/rlf_animation.h" +#include "zvision/animation/rlf_animation.h" #include "common/str.h" #include "common/file.h" diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp index 365ff747f4..49ef22bb51 100644 --- a/engines/zvision/animation_node.cpp +++ b/engines/zvision/animation_node.cpp @@ -25,8 +25,8 @@ #include "zvision/animation_node.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" #include "zvision/meta_animation.h" #include "graphics/surface.h" diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 252a4b75ef..ef088f7553 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -22,16 +22,16 @@ #include "common/scummsys.h" -#include "zvision/console.h" +#include "zvision/core/console.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/string_manager.h" -#include "zvision/zork_avi_decoder.h" -#include "zvision/zork_raw.h" -#include "zvision/utility.h" -#include "zvision/cursor.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/strings/string_manager.h" +#include "zvision/video/zork_avi_decoder.h" +#include "zvision/sound/zork_raw.h" +#include "zvision/utility/utility.h" +#include "zvision/cursors/cursor.h" #include "common/system.h" #include "common/file.h" @@ -45,18 +45,18 @@ namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { - DCmd_Register("loadimage", WRAP_METHOD(Console, cmdLoadImage)); - DCmd_Register("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); - DCmd_Register("loadsound", WRAP_METHOD(Console, cmdLoadSound)); - DCmd_Register("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); - DCmd_Register("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState)); - DCmd_Register("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); - DCmd_Register("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); - DCmd_Register("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); - DCmd_Register("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); - DCmd_Register("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - DCmd_Register("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); - DCmd_Register("rendertext", WRAP_METHOD(Console, cmdRenderText)); + registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage)); + registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); + registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound)); + registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); + registerCmd("setrenderstate", WRAP_METHOD(Console, cmdSetRenderState)); + registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); + registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); + registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); + registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); + registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); + registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText)); } bool Console::cmdLoadImage(int argc, const char **argv) { @@ -72,7 +72,7 @@ bool Console::cmdLoadImage(int argc, const char **argv) { bool Console::cmdLoadVideo(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use loadvideo to load a video to the screen\n"); + debugPrintf("Use loadvideo to load a video to the screen\n"); return true; } @@ -86,7 +86,7 @@ bool Console::cmdLoadVideo(int argc, const char **argv) { bool Console::cmdLoadSound(int argc, const char **argv) { if (!Common::File::exists(argv[1])) { - DebugPrintf("File does not exist\n"); + debugPrintf("File does not exist\n"); return true; } @@ -105,7 +105,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); } else { - DebugPrintf("Use loadsound [ ] to load a sound\n"); + debugPrintf("Use loadsound [ ] to load a sound\n"); return true; } @@ -114,7 +114,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { bool Console::cmdRawToWav(int argc, const char **argv) { if (argc != 3) { - DebugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); + debugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); return true; } @@ -124,7 +124,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) { bool Console::cmdSetRenderState(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use setrenderstate to change the current render state\n"); return true; } @@ -137,7 +137,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) { else if (renderState.matchString("flat", true)) _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT); else - DebugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use setrenderstate to change the current render state\n"); return true; } @@ -150,7 +150,7 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) { bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setpanoramafov to change the current panorama field of view\n"); + debugPrintf("Use setpanoramafov to change the current panorama field of view\n"); return true; } @@ -161,7 +161,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { bool Console::cmdSetPanoramaScale(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use setpanoramascale to change the current panorama scale\n"); + debugPrintf("Use setpanoramascale to change the current panorama scale\n"); return true; } @@ -172,7 +172,7 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) { bool Console::cmdChangeLocation(int argc, const char **argv) { if (argc != 6) { - DebugPrintf("Use changelocation to change your location\n"); + debugPrintf("Use changelocation to change your location\n"); return true; } @@ -183,7 +183,7 @@ bool Console::cmdChangeLocation(int argc, const char **argv) { bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { - DebugPrintf("Use dumpfile to dump a file\n"); + debugPrintf("Use dumpfile to dump a file\n"); return true; } @@ -204,7 +204,7 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) { bool Console::cmdRenderText(int argc, const char **argv) { if (argc != 7) { - DebugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); + debugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); return true; } diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 189bf007c1..943f8ff279 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -24,12 +24,12 @@ #include "zvision/zvision.h" -#include "zvision/console.h" -#include "zvision/cursor_manager.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/menu.h" +#include "zvision/core/console.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/animation/rlf_animation.h" +#include "zvision/core/menu.h" #include "common/events.h" #include "common/system.h" diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7be03f62ef..cc802ee5f5 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -27,7 +27,7 @@ #include "common/rect.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" namespace ZVision { diff --git a/engines/zvision/cursors/cursor.cpp b/engines/zvision/cursors/cursor.cpp index e2e3d7ee72..8c6027a1bb 100644 --- a/engines/zvision/cursors/cursor.cpp +++ b/engines/zvision/cursors/cursor.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#include "zvision/cursor.h" +#include "zvision/cursors/cursor.h" #include "common/str.h" #include "common/file.h" diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp index c66fa650a8..cfb4baf636 100644 --- a/engines/zvision/cursors/cursor_manager.cpp +++ b/engines/zvision/cursors/cursor_manager.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#include "zvision/cursor_manager.h" +#include "zvision/cursors/cursor_manager.h" #include "zvision/zvision.h" diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h index 0521a17337..5392fd5e03 100644 --- a/engines/zvision/cursors/cursor_manager.h +++ b/engines/zvision/cursors/cursor_manager.h @@ -23,7 +23,7 @@ #ifndef ZVISION_CURSOR_MANAGER_H #define ZVISION_CURSOR_MANAGER_H -#include "zvision/cursor.h" +#include "zvision/cursors/cursor.h" #include "common/str.h" diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp index e3eea403b6..224603c469 100644 --- a/engines/zvision/fonts/truetype_font.cpp +++ b/engines/zvision/fonts/truetype_font.cpp @@ -22,10 +22,10 @@ #include "common/scummsys.h" -#include "zvision/truetype_font.h" +#include "zvision/fonts/truetype_font.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" +#include "zvision/graphics/render_manager.h" #include "common/config-manager.h" #include "common/debug.h" @@ -212,7 +212,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { if (themeArchive->hasFile("FreeSans.ttf")) { Common::SeekableReadStream *stream = nullptr; stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); - Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display + Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display if (_newFont) { if (!_font) delete _font; @@ -225,7 +225,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { themeArchive = nullptr; } } else { - Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display + Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display if (_newFont) { if (!_font) delete _font; diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h index bed1d5513e..0fed3ccbc4 100644 --- a/engines/zvision/fonts/truetype_font.h +++ b/engines/zvision/fonts/truetype_font.h @@ -43,12 +43,12 @@ public: ~TruetypeFont(); private: -// ZVision *_engine; + ZVision *_engine; Graphics::Font *_font; int _lineHeight; -// size_t _maxCharWidth; -// size_t _maxCharHeight; + size_t _maxCharWidth; + size_t _maxCharHeight; public: int32 _fontHeight; diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 071affffab..c9dc5d37b2 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -23,10 +23,10 @@ #include "common/scummsys.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" +#include "zvision/graphics/render_manager.h" #include "zvision/text.h" -#include "zvision/lzss_read_stream.h" +#include "zvision/utility/lzss_read_stream.h" #include "common/file.h" #include "common/system.h" @@ -34,7 +34,7 @@ #include "engines/util.h" -#include "graphics/decoders/tga.h" +#include "image/tga.h" namespace ZVision { @@ -127,7 +127,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: uint32 imageWidth; uint32 imageHeight; - Graphics::TGADecoder tga; + Image::TGADecoder tga; uint16 *buffer; bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA; // All ZVision images are in RGB 555 @@ -221,7 +221,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: uint32 imageWidth; uint32 imageHeight; - Graphics::TGADecoder tga; + Image::TGADecoder tga; uint16 *buffer; // All ZVision images are in RGB 555 Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 668c8acc41..ca2e715e8a 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -23,8 +23,8 @@ #ifndef ZVISION_RENDER_MANAGER_H #define ZVISION_RENDER_MANAGER_H -#include "zvision/render_table.h" -#include "zvision/truetype_font.h" +#include "zvision/graphics/render_table.h" +#include "zvision/fonts/truetype_font.h" #include "common/rect.h" #include "common/hashmap.h" diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp index 3924c6b51a..f8b22970c4 100644 --- a/engines/zvision/inventory_manager.cpp +++ b/engines/zvision/inventory_manager.cpp @@ -22,7 +22,7 @@ #include "common/scummsys.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" namespace ZVision { diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp index bf422b300f..bf311c4577 100644 --- a/engines/zvision/menu.cpp +++ b/engines/zvision/menu.cpp @@ -22,9 +22,9 @@ #include "common/scummsys.h" -#include "zvision/menu.h" +#include "zvision/core/menu.h" -#include "zvision/render_manager.h" +#include "zvision/graphics/render_manager.h" namespace ZVision { diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp index 33ae92a523..dddc238379 100644 --- a/engines/zvision/meta_animation.cpp +++ b/engines/zvision/meta_animation.cpp @@ -25,10 +25,10 @@ #include "zvision/meta_animation.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" -#include "zvision/rlf_animation.h" -#include "zvision/zork_avi_decoder.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/animation/rlf_animation.h" +#include "zvision/video/zork_avi_decoder.h" #include "video/video_decoder.h" diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index d6d0dd7b5a..a386f6fac6 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -1,35 +1,35 @@ MODULE := engines/zvision MODULE_OBJS := \ - actions.o \ + scripting/actions.o \ animation_node.o \ - clock.o \ - console.o \ - control.o \ - cursor.o \ - cursor_manager.o \ + utility/clock.o \ + core/console.o \ + scripting/control.o \ + cursors/cursor.o \ + cursors/cursor_manager.o \ detection.o \ - events.o \ - input_control.o \ - lever_control.o \ - lzss_read_stream.o \ - push_toggle_control.o \ - render_manager.o \ - render_table.o \ - rlf_animation.o \ - save_manager.o \ - scr_file_handling.o \ - script_manager.o \ - single_value_container.o \ - string_manager.o \ - timer_node.o \ - truetype_font.o \ - utility.o \ - video.o \ + core/events.o \ + scripting/controls/input_control.o \ + scripting/controls/lever_control.o \ + utility/lzss_read_stream.o \ + scripting/controls/push_toggle_control.o \ + graphics/render_manager.o \ + graphics/render_table.o \ + animation/rlf_animation.o \ + core/save_manager.o \ + scripting/scr_file_handling.o \ + scripting/script_manager.o \ + utility/single_value_container.o \ + strings/string_manager.o \ + scripting/controls/timer_node.o \ + fonts/truetype_font.o \ + utility/utility.o \ + video/video.o \ zvision.o \ - zfs_archive.o \ - zork_avi_decoder.o \ - zork_raw.o \ + archives/zfs_archive.o \ + video/zork_avi_decoder.o \ + sound/zork_raw.o \ sidefx.o \ music_node.o \ inventory_manager.o \ diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp index b716b3ead1..f8fd08b285 100644 --- a/engines/zvision/music_node.cpp +++ b/engines/zvision/music_node.cpp @@ -25,9 +25,9 @@ #include "zvision/music_node.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/zork_raw.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h index d24496fc02..0dad22614b 100644 --- a/engines/zvision/music_node.h +++ b/engines/zvision/music_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/sidefx.h" -#include "zvision/subtitles.h" +#include "zvision/subtitles/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index f60a69744a..3c341fbc80 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -22,14 +22,14 @@ #include "common/scummsys.h" -#include "zvision/actions.h" +#include "zvision/scripting/actions.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/zork_raw.h" -#include "zvision/zork_avi_decoder.h" -#include "zvision/timer_node.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" +#include "zvision/video/zork_avi_decoder.h" +#include "zvision/scripting/controls/timer_node.h" #include "zvision/music_node.h" #include "zvision/syncsound_node.h" #include "zvision/animation_node.h" diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index a366e06923..ca707b5ab0 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -22,13 +22,13 @@ #include "common/scummsys.h" -#include "zvision/input_control.h" +#include "zvision/scripting/controls/input_control.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/string_manager.h" -#include "zvision/render_manager.h" -#include "zvision/utility.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/strings/string_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" #include "common/str.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index f68f256229..121fab97e1 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -22,14 +22,14 @@ #include "common/scummsys.h" -#include "zvision/lever_control.h" +#include "zvision/scripting/controls/lever_control.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/cursor_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" #include "zvision/meta_animation.h" -#include "zvision/utility.h" +#include "zvision/utility/utility.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/controls/timer_node.cpp index a94f6db19b..e68610f537 100644 --- a/engines/zvision/scripting/controls/timer_node.cpp +++ b/engines/zvision/scripting/controls/timer_node.cpp @@ -22,10 +22,10 @@ #include "common/scummsys.h" -#include "zvision/timer_node.h" +#include "zvision/scripting/controls/timer_node.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/puzzle.h b/engines/zvision/scripting/puzzle.h index 4d50756b87..ab38c5fc5d 100644 --- a/engines/zvision/scripting/puzzle.h +++ b/engines/zvision/scripting/puzzle.h @@ -23,7 +23,7 @@ #ifndef ZVISION_PUZZLE_H #define ZVISION_PUZZLE_H -#include "zvision/actions.h" +#include "zvision/scripting/actions.h" #include "common/list.h" #include "common/ptr.h" diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 9d1d0bf856..fff187d369 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -23,13 +23,13 @@ #include "common/scummsys.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" -#include "zvision/utility.h" -#include "zvision/puzzle.h" -#include "zvision/actions.h" -#include "zvision/push_toggle_control.h" -#include "zvision/lever_control.h" +#include "zvision/utility/utility.h" +#include "zvision/scripting/puzzle.h" +#include "zvision/scripting/actions.h" +#include "zvision/scripting/controls/push_toggle_control.h" +#include "zvision/scripting/controls/lever_control.h" #include "zvision/slot_control.h" #include "common/textconsole.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 1a567397a8..9713a34733 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -22,15 +22,15 @@ #include "common/scummsys.h" -#include "zvision/script_manager.h" +#include "zvision/scripting/script_manager.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" -#include "zvision/cursor_manager.h" -#include "zvision/save_manager.h" -#include "zvision/actions.h" -#include "zvision/utility.h" -#include "zvision/timer_node.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/core/save_manager.h" +#include "zvision/scripting/actions.h" +#include "zvision/utility/utility.h" +#include "zvision/scripting/controls/timer_node.h" #include "common/algorithm.h" #include "common/hashmap.h" diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 6adade5745..a835c13951 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -23,8 +23,8 @@ #ifndef ZVISION_SCRIPT_MANAGER_H #define ZVISION_SCRIPT_MANAGER_H -#include "zvision/puzzle.h" -#include "zvision/control.h" +#include "zvision/scripting/puzzle.h" +#include "zvision/scripting/control.h" #include "zvision/sidefx.h" #include "common/hashmap.h" diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp index 124a49912d..db120f2a4b 100644 --- a/engines/zvision/search_manager.cpp +++ b/engines/zvision/search_manager.cpp @@ -22,7 +22,7 @@ #include "common/debug.h" #include "zvision/search_manager.h" -#include "zvision/zfs_archive.h" +#include "zvision/archives/zfs_archive.h" #include "common/fs.h" #include "common/stream.h" diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp index 3874c86485..7ba1959db7 100644 --- a/engines/zvision/sidefx.cpp +++ b/engines/zvision/sidefx.cpp @@ -25,8 +25,8 @@ #include "zvision/sidefx.h" #include "zvision/zvision.h" -#include "zvision/render_manager.h" -#include "zvision/utility.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp index 111a7c63e8..d3d9c2ec4b 100644 --- a/engines/zvision/slot_control.cpp +++ b/engines/zvision/slot_control.cpp @@ -25,10 +25,10 @@ #include "zvision/slot_control.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/cursor_manager.h" -#include "zvision/render_manager.h" -#include "zvision/utility.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h index eec2d04518..0ac8ec9ce0 100644 --- a/engines/zvision/slot_control.h +++ b/engines/zvision/slot_control.h @@ -23,7 +23,7 @@ #ifndef ZVISION_SLOT_CONTROL_H #define ZVISION_SLOT_CONTROL_H -#include "zvision/control.h" +#include "zvision/scripting/control.h" #include "graphics/surface.h" diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index a4d091f3c0..a0f660f65f 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -22,11 +22,11 @@ #include "common/scummsys.h" -#include "zvision/zork_raw.h" +#include "zvision/sound/zork_raw.h" #include "zvision/zvision.h" #include "zvision/detection.h" -#include "zvision/utility.h" +#include "zvision/utility/utility.h" #include "common/file.h" #include "common/str.h" diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp index 1942e3c979..da9b0fc1c9 100644 --- a/engines/zvision/subtitles.cpp +++ b/engines/zvision/subtitles.cpp @@ -20,8 +20,8 @@ * */ -#include "zvision/subtitles.h" -#include "zvision/render_manager.h" +#include "zvision/subtitles/subtitles.h" +#include "zvision/graphics/render_manager.h" #include "zvision/search_manager.h" #include "zvision/text.h" diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp index 5d04c1fb70..7bd520d475 100644 --- a/engines/zvision/syncsound_node.cpp +++ b/engines/zvision/syncsound_node.cpp @@ -25,9 +25,9 @@ #include "zvision/syncsound_node.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/zork_raw.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h index 7d875f2797..1f63ec48dd 100644 --- a/engines/zvision/syncsound_node.h +++ b/engines/zvision/syncsound_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/sidefx.h" -#include "zvision/subtitles.h" +#include "zvision/subtitles/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp index 2fdfafcdf6..6b0ff0712b 100644 --- a/engines/zvision/text.cpp +++ b/engines/zvision/text.cpp @@ -24,7 +24,7 @@ #include "zvision/text.h" -#include "zvision/truetype_font.h" +#include "zvision/fonts/truetype_font.h" #include "common/file.h" #include "common/tokenizer.h" @@ -37,8 +37,8 @@ #include "graphics/font.h" #include "graphics/fonts/ttf.h" -#include "zvision/render_manager.h" -#include "zvision/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" namespace ZVision { diff --git a/engines/zvision/text.h b/engines/zvision/text.h index c1dc0c167c..4b318fdef0 100644 --- a/engines/zvision/text.h +++ b/engines/zvision/text.h @@ -25,7 +25,7 @@ #define ZVISION_TEXT_H #include "zvision/detection.h" -#include "zvision/truetype_font.h" +#include "zvision/fonts/truetype_font.h" #include "zvision/zvision.h" diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp index 4f64800cd7..6741d28a56 100644 --- a/engines/zvision/ttytext_node.cpp +++ b/engines/zvision/ttytext_node.cpp @@ -25,8 +25,8 @@ #include "zvision/ttytext_node.h" #include "zvision/zvision.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" #include "zvision/text.h" #include "common/stream.h" diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h index 6c3e6f46af..e25fdb0c07 100644 --- a/engines/zvision/ttytext_node.h +++ b/engines/zvision/ttytext_node.h @@ -28,7 +28,7 @@ #include "zvision/sidefx.h" #include "zvision/text.h" -#include "zvision/truetype_font.h" +#include "zvision/fonts/truetype_font.h" namespace Common { class String; diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 0ad9000fcb..7a120df76b 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -24,9 +24,9 @@ #include "zvision/zvision.h" -#include "zvision/clock.h" -#include "zvision/render_manager.h" -#include "zvision/subtitles.h" +#include "zvision/utility/clock.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/subtitles/subtitles.h" #include "common/system.h" diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index d8937ac057..db1ad312c7 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -25,7 +25,7 @@ #define ZORK_AVI_DECODER_H #include "video/avi_decoder.h" -#include "zork_raw.h" +#include "zvision/sound/zork_raw.h" namespace ZVision { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b1615aa7b4..580f8c4367 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -24,18 +24,18 @@ #include "zvision/zvision.h" -#include "zvision/console.h" -#include "zvision/script_manager.h" -#include "zvision/render_manager.h" -#include "zvision/cursor_manager.h" -#include "zvision/save_manager.h" -#include "zvision/string_manager.h" -#include "zvision/zfs_archive.h" +#include "zvision/core/console.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/core/save_manager.h" +#include "zvision/strings/string_manager.h" +#include "zvision/archives/zfs_archive.h" #include "zvision/detection.h" -#include "zvision/menu.h" +#include "zvision/core/menu.h" #include "zvision/search_manager.h" #include "zvision/text.h" -#include "zvision/truetype_font.h" +#include "zvision/fonts/truetype_font.h" #include "common/config-manager.h" #include "common/str.h" diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 982d3fd98b..2674df27e0 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -25,7 +25,7 @@ #define ZVISION_ZVISION_H #include "zvision/detection.h" -#include "zvision/clock.h" +#include "zvision/utility/clock.h" #include "zvision/search_manager.h" #include "common/random.h" -- cgit v1.2.3 From 84fb3e816d3c66105a0291834c8ab8bed352b4af Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 17 Jun 2014 09:34:15 +0200 Subject: TONY: Switch to 565 screen format. The old (555) screen format is not supported by some backends. This leaves the savegame thumbnails as 555 (for compatibility). --- engines/tony/game.cpp | 4 +- engines/tony/gfxcore.cpp | 119 ++++++++++++++++++++++++++--------------------- engines/tony/window.cpp | 12 ++--- 3 files changed, 73 insertions(+), 62 deletions(-) diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c102242dfd..0a2c62330b 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1557,14 +1557,14 @@ void RMPointer::updateCursor() { for (int i = 0; i < 64; i++) { uint16 *lineP = src; for (int j = 0; j < 64; j++) { - lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; + lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j]]; } src += 64; } } // Get the raw pixel data and set the cursor to it - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9254d59df6..b8350eb8d7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -422,11 +422,11 @@ uint16 *RMGfxTargetBuffer::_precalcTable = NULL; * called if the user selects the black & white option. */ void RMGfxTargetBuffer::createBWPrecalcTable() { - _precalcTable = new uint16[0x8000]; + _precalcTable = new uint16[0x10000]; - for (int i = 0; i < 0x8000; i++) { - int r = (i >> 10) & 0x1F; - int g = (i >> 5) & 0x1F; + for (int i = 0; i < 0x10000; i++) { + int r = (i >> 11) & 0x1F; + int g = (i >> 6) & 0x1F; int b = i & 0x1F; int min = MIN(r, MIN(g, b)); @@ -434,11 +434,11 @@ void RMGfxTargetBuffer::createBWPrecalcTable() { min = (min + max) / 2; - r = CLIP(min + 8 - 8, 0, 31); - g = CLIP(min + 5 - 8, 0, 31); - b = CLIP(min + 0 - 8, 0, 31); + r = CLIP(min + 8 - 8, 0, 0x1f); + g = CLIP(min + 5 - 8, 0, 0x1f); + b = CLIP(min + 0 - 8, 0, 0x1f); - _precalcTable[i] = (r << 10) | (g << 5) | b; + _precalcTable[i] = (r << 11) | (g << 6) | b; } } @@ -512,8 +512,9 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { void RMGfxSourceBufferPal::preparePalette() { for (int i = 0; i < 256; i++) { - _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 10) | - (((int)_pal[i * 3 + 1] >> 3) << 5) | + // we convert 555 to 565 here. + _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 11) | + (((int)_pal[i * 3 + 1] >> 3) << 6) | (((int)_pal[i * 3 + 2] >> 3) << 0); } } @@ -665,8 +666,8 @@ void RMGfxSourceBuffer8::create(int dimx, int dimy) { RMGfxBuffer::create(dimx, dimy, 8); } -#define GETRED(x) (((x) >> 10) & 0x1F) -#define GETGREEN(x) (((x) >> 5) & 0x1F) +#define GETRED(x) (((x) >> 11) & 0x1F) +#define GETGREEN(x) (((x) >> 5) & 0x3F) #define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ @@ -684,13 +685,13 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { if (r > 0x1F) r = 0x1F; - if (g > 0x1F) - g = 0x1F; + if (g > 0x3F) + g = 0x3F; if (b > 0x1F) b = 0x1F; - return (r << 10) | (g << 5) | b; + return (r << 11) | (g << 5) | b; } void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -802,8 +803,8 @@ void RMGfxSourceBuffer8RLE::preparePalette() { // Handle RGB alpha blending if (_alphaBlendColor != -1) { - _alphaR = (_palFinal[_alphaBlendColor] >> 10) & 0x1F; - _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x1F; + _alphaR = (_palFinal[_alphaBlendColor] >> 11) & 0x1F; + _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x3F; _alphaB = (_palFinal[_alphaBlendColor]) & 0x1F; } } @@ -1054,15 +1055,15 @@ RLEByteDoAlpha2: if (n > nLength) n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst ++ = (r << 10) | (g << 5) | b; + *dst ++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1158,15 +1159,15 @@ RLEByteFlippedDoAlpha2: if (n > nLength) n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst-- = (r << 10) | (g << 5) | b; + *dst-- = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1302,15 +1303,15 @@ RLEWordDoAlpha2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst++ = (r << 10) | (g << 5) | b; + *dst++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1416,15 +1417,15 @@ RLEWordFlippedDoAlpha2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst-- = (r << 10) | (g << 5) | b; + *dst-- = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1543,15 +1544,15 @@ RLEWordDoAlpha2: // @@@ SHOULD NOT BE THERE !!!!! for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst++ = (r << 10) | (g << 5) | b; + *dst++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1570,19 +1571,19 @@ RLEWordDoCopy2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; - int r2 = (_palFinal[*src] >> 10) & 0x1F; - int g2 = (_palFinal[*src] >> 5) & 0x1F; + int r2 = (_palFinal[*src] >> 11) & 0x1F; + int g2 = (_palFinal[*src] >> 5) & 0x3F; int b2 = _palFinal[*src] & 0x1F; r = (r >> 1) + (r2 >> 1); g = (g >> 1) + (g2 >> 1); b = (b >> 1) + (b2 >> 1); - *dst ++ = (r << 10) | (g << 5) | b; + *dst ++ = (r << 11) | (g << 5) | b; src++; } @@ -1732,14 +1733,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri g /= 5; b /= 5; - if (r > 31) - r = 31; - if (g > 31) - g = 31; - if (b > 31) - b = 31; + if (r > 0x1f) + r = 0x1f; + if (g > 0x3f) + g = 0x3f; + if (b > 0x1f) + b = 0x1f; - mybuf[0] = (r << 10) | (g << 5) | b; + mybuf[0] = (r << 11) | (g << 5) | b; } } @@ -1773,14 +1774,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri g /= 6; b /= 6; - if (r > 31) - r = 31; - if (g > 31) - g = 31; - if (b > 31) - b = 31; + if (r > 0x1f) + r = 0x1f; + if (g > 0x3f) + g = 0x3f; + if (b > 0x1f) + b = 0x1f; - mybuf[0] = (r << 10) | (g << 5) | b; + mybuf[0] = (r << 11) | (g << 5) | b; } } @@ -1948,8 +1949,17 @@ void RMGfxSourceBuffer16::prepareImage() { // Color space conversion if necessary! uint16 *buf = (uint16 *)_buf; - for (int i = 0; i < _dimx * _dimy; i++) - buf[i] = FROM_LE_16(buf[i]) & 0x7FFF; + // convert 555 to 565 + for (int i = 0; i < _dimx * _dimy; i++) { + uint16 pixel = FROM_LE_16(buf[i]); + int r = (pixel >> 10) & 0x1F; + int g = (pixel >> 5) & 0x1F; + int b = pixel & 0x1F; + + pixel = (r << 11) | (g << 6) | b; + + WRITE_LE_UINT16(&buf[i], pixel); + } } RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy) @@ -1983,7 +1993,8 @@ void RMGfxBox::setColor(byte r, byte g, byte b) { r >>= 3; g >>= 3; b >>= 3; - _wFillColor = (r << 10) | (g << 5) | b; + // These are hard-coded colors, so we convert 555 to 565. + _wFillColor = (r << 11) | (g << 6) | b; } void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5c50a50a57..c62f483a35 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -53,7 +53,7 @@ RMWindow::~RMWindow() { * Initializes the graphics window */ void RMWindow::init() { - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); reset(); @@ -83,7 +83,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, for (int i = 0; i < h; i++) { uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); for (int j = 0; j < w; j++) { - dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF]; + dst[j] = RMGfxTargetBuffer::_precalcTable[src[j]]; } src += (pitch / 2); } @@ -291,8 +291,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { cursrc = &src[RM_SKIPX + x]; *curOut++ = ((*cursrc) & 0x1F) << 3; - *curOut++ = (((*cursrc) >> 5) & 0x1F) << 3; - *curOut++ = (((*cursrc) >> 10) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 5) & 0x3F) << 3; + *curOut++ = (((*cursrc) >> 11) & 0x1F) << 3; if (lpDestBuf) *lpDestBuf++ = *cursrc; @@ -319,8 +319,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { curv = v; sommab += cursrc[curv * RM_BBX + u] & 0x1F; - sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; - sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; + sommag += (cursrc[curv * RM_BBX + u] >> 6) & 0x1F; + sommar += (cursrc[curv * RM_BBX + u] >> 11) & 0x1F; } } _rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); -- cgit v1.2.3 From 23c1b508611d5fa4e7dfc47f8f5ec10a7de177e3 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 2 Jul 2014 19:50:55 +0000 Subject: ZVISION: Reorgonize source files into directories. --- engines/zvision/animation/meta_animation.cpp | 131 ++++ engines/zvision/animation/meta_animation.h | 99 +++ engines/zvision/animation_node.cpp | 211 ------ engines/zvision/animation_node.h | 84 --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/menu.cpp | 765 +++++++++++++++++++++ engines/zvision/core/search_manager.cpp | 274 ++++++++ engines/zvision/core/search_manager.h | 51 ++ engines/zvision/graphics/render_manager.cpp | 2 +- engines/zvision/inventory_manager.cpp | 123 ---- engines/zvision/menu.cpp | 765 --------------------- engines/zvision/meta_animation.cpp | 131 ---- engines/zvision/meta_animation.h | 99 --- engines/zvision/module.mk | 56 +- engines/zvision/music_node.cpp | 190 ----- engines/zvision/music_node.h | 82 --- engines/zvision/scripting/actions.cpp | 10 +- .../zvision/scripting/controls/input_control.cpp | 2 +- engines/zvision/scripting/controls/input_control.h | 2 +- .../zvision/scripting/controls/lever_control.cpp | 2 +- .../zvision/scripting/controls/slot_control.cpp | 219 ++++++ engines/zvision/scripting/controls/slot_control.h | 86 +++ engines/zvision/scripting/controls/timer_node.cpp | 80 --- engines/zvision/scripting/controls/timer_node.h | 59 -- engines/zvision/scripting/inventory.cpp | 123 ++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- engines/zvision/scripting/script_manager.h | 2 +- engines/zvision/scripting/sidefx.cpp | 36 + engines/zvision/scripting/sidefx.h | 124 ++++ .../zvision/scripting/sidefx/animation_node.cpp | 211 ++++++ engines/zvision/scripting/sidefx/animation_node.h | 84 +++ engines/zvision/scripting/sidefx/music_node.cpp | 190 +++++ engines/zvision/scripting/sidefx/music_node.h | 82 +++ .../zvision/scripting/sidefx/syncsound_node.cpp | 86 +++ engines/zvision/scripting/sidefx/syncsound_node.h | 56 ++ engines/zvision/scripting/sidefx/timer_node.cpp | 80 +++ engines/zvision/scripting/sidefx/timer_node.h | 59 ++ engines/zvision/scripting/sidefx/ttytext_node.cpp | 175 +++++ engines/zvision/scripting/sidefx/ttytext_node.h | 76 ++ engines/zvision/search_manager.cpp | 274 -------- engines/zvision/search_manager.h | 51 -- engines/zvision/sidefx.cpp | 36 - engines/zvision/sidefx.h | 124 ---- engines/zvision/slot_control.cpp | 219 ------ engines/zvision/slot_control.h | 86 --- engines/zvision/strings/string_manager.cpp | 255 ------- engines/zvision/strings/string_manager.h | 84 --- engines/zvision/subtitles.cpp | 108 --- engines/zvision/subtitles/subtitles.cpp | 108 +++ engines/zvision/syncsound_node.cpp | 86 --- engines/zvision/syncsound_node.h | 56 -- engines/zvision/text.cpp | 549 --------------- engines/zvision/text.h | 100 --- engines/zvision/text/string_manager.cpp | 255 +++++++ engines/zvision/text/string_manager.h | 84 +++ engines/zvision/text/text.cpp | 549 +++++++++++++++ engines/zvision/text/text.h | 100 +++ engines/zvision/ttytext_node.cpp | 175 ----- engines/zvision/ttytext_node.h | 76 -- engines/zvision/zvision.cpp | 6 +- engines/zvision/zvision.h | 2 +- 62 files changed, 4148 insertions(+), 4148 deletions(-) create mode 100644 engines/zvision/animation/meta_animation.cpp create mode 100644 engines/zvision/animation/meta_animation.h delete mode 100644 engines/zvision/animation_node.cpp delete mode 100644 engines/zvision/animation_node.h create mode 100644 engines/zvision/core/menu.cpp create mode 100644 engines/zvision/core/search_manager.cpp create mode 100644 engines/zvision/core/search_manager.h delete mode 100644 engines/zvision/inventory_manager.cpp delete mode 100644 engines/zvision/menu.cpp delete mode 100644 engines/zvision/meta_animation.cpp delete mode 100644 engines/zvision/meta_animation.h delete mode 100644 engines/zvision/music_node.cpp delete mode 100644 engines/zvision/music_node.h create mode 100644 engines/zvision/scripting/controls/slot_control.cpp create mode 100644 engines/zvision/scripting/controls/slot_control.h delete mode 100644 engines/zvision/scripting/controls/timer_node.cpp delete mode 100644 engines/zvision/scripting/controls/timer_node.h create mode 100644 engines/zvision/scripting/inventory.cpp create mode 100644 engines/zvision/scripting/sidefx.cpp create mode 100644 engines/zvision/scripting/sidefx.h create mode 100644 engines/zvision/scripting/sidefx/animation_node.cpp create mode 100644 engines/zvision/scripting/sidefx/animation_node.h create mode 100644 engines/zvision/scripting/sidefx/music_node.cpp create mode 100644 engines/zvision/scripting/sidefx/music_node.h create mode 100644 engines/zvision/scripting/sidefx/syncsound_node.cpp create mode 100644 engines/zvision/scripting/sidefx/syncsound_node.h create mode 100644 engines/zvision/scripting/sidefx/timer_node.cpp create mode 100644 engines/zvision/scripting/sidefx/timer_node.h create mode 100644 engines/zvision/scripting/sidefx/ttytext_node.cpp create mode 100644 engines/zvision/scripting/sidefx/ttytext_node.h delete mode 100644 engines/zvision/search_manager.cpp delete mode 100644 engines/zvision/search_manager.h delete mode 100644 engines/zvision/sidefx.cpp delete mode 100644 engines/zvision/sidefx.h delete mode 100644 engines/zvision/slot_control.cpp delete mode 100644 engines/zvision/slot_control.h delete mode 100644 engines/zvision/strings/string_manager.cpp delete mode 100644 engines/zvision/strings/string_manager.h delete mode 100644 engines/zvision/subtitles.cpp create mode 100644 engines/zvision/subtitles/subtitles.cpp delete mode 100644 engines/zvision/syncsound_node.cpp delete mode 100644 engines/zvision/syncsound_node.h delete mode 100644 engines/zvision/text.cpp delete mode 100644 engines/zvision/text.h create mode 100644 engines/zvision/text/string_manager.cpp create mode 100644 engines/zvision/text/string_manager.h create mode 100644 engines/zvision/text/text.cpp create mode 100644 engines/zvision/text/text.h delete mode 100644 engines/zvision/ttytext_node.cpp delete mode 100644 engines/zvision/ttytext_node.h diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp new file mode 100644 index 0000000000..38f56699bb --- /dev/null +++ b/engines/zvision/animation/meta_animation.cpp @@ -0,0 +1,131 @@ +/* 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 "common/scummsys.h" + +#include "zvision/animation/meta_animation.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/animation/rlf_animation.h" +#include "zvision/video/zork_avi_decoder.h" + +#include "video/video_decoder.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) + : _fileType(RLF), + _cur_frame(NULL) { + if (fileName.hasSuffix(".rlf")) { + _fileType = RLF; + Common::File *_file = engine->getSearchManager()->openFile(fileName); + _animation.rlf = new RlfAnimation(_file, false); + _frmDelay = _animation.rlf->frameTime(); + } else if (fileName.hasSuffix(".avi")) { + _fileType = AVI; + Common::File *_file = engine->getSearchManager()->openFile(fileName); + _animation.avi = new ZorkAVIDecoder(); + _animation.avi->loadStream(_file); + _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); + } else { + warning("Unrecognized animation file type: %s", fileName.c_str()); + } +} + +MetaAnimation::~MetaAnimation() { + if (_fileType == RLF) { + delete _animation.rlf; + } else if (_fileType == AVI) { + delete _animation.avi; + } +} + +uint MetaAnimation::frameCount() { + if (_fileType == RLF) { + return _animation.rlf->frameCount(); + } else + return _animation.avi->getFrameCount(); + +} + +uint MetaAnimation::width() { + if (_fileType == RLF) { + return _animation.rlf->width(); + } else + return _animation.avi->getWidth(); +} +uint MetaAnimation::height() { + if (_fileType == RLF) { + return _animation.rlf->height(); + } else + return _animation.avi->getHeight(); +} +uint32 MetaAnimation::frameTime() { + return _frmDelay; +} + +void MetaAnimation::seekToFrame(int frameNumber) { + if (frameNumber >= (int)frameCount()) + frameNumber = frameCount() - 1; + + if (_fileType == RLF) { + _animation.rlf->seekToFrame(frameNumber); + } else + _animation.avi->seekToFrame(frameNumber); +} + +const Graphics::Surface *MetaAnimation::decodeNextFrame() { + if (_fileType == RLF) + _cur_frame = _animation.rlf->decodeNextFrame(); + else + _cur_frame = _animation.avi->decodeNextFrame(); + + return _cur_frame; +} + +const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { + if (frameNumber >= frameCount()) + frameNumber = frameCount() - 1; + + if (_fileType == RLF) { + _cur_frame = _animation.rlf->getFrameData(frameNumber); + return _cur_frame; + } else { + _animation.avi->seekToFrame(frameNumber); + _cur_frame = _animation.avi->decodeNextFrame(); + return _cur_frame; + } +} + +bool MetaAnimation::endOfAnimation() { + if (_fileType == RLF) { + return _animation.rlf->endOfAnimation(); + } else + return _animation.avi->endOfVideo(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h new file mode 100644 index 0000000000..2ea00310f9 --- /dev/null +++ b/engines/zvision/animation/meta_animation.h @@ -0,0 +1,99 @@ +/* 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 ZVISION_METAANIM_NODE_H +#define ZVISION_METAANIM_NODE_H + +#include "zvision/scripting/sidefx.h" +#include "zvision/zvision.h" +#include "common/rect.h" +#include "common/list.h" + + +namespace Common { +class String; +} + +namespace Video { +class VideoDecoder; +} + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; +class RlfAnimation; + +class MetaAnimation { +public: + MetaAnimation(const Common::String &fileName, ZVision *engine); + ~MetaAnimation(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 stop; + int32 loop; + int32 _cur_frm; + int32 _delay; + Graphics::Surface *_scaled; + }; + +private: + enum FileType { + RLF = 1, + AVI = 2 + }; + +private: + union { + RlfAnimation *rlf; + Video::VideoDecoder *avi; + } _animation; + + FileType _fileType; + int32 _frmDelay; + + const Graphics::Surface *_cur_frame; + +public: + + uint frameCount(); + uint width(); + uint height(); + uint32 frameTime(); + + void seekToFrame(int frameNumber); + + const Graphics::Surface *decodeNextFrame(); + const Graphics::Surface *getFrameData(uint frameNumber); + + bool endOfAnimation(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/animation_node.cpp b/engines/zvision/animation_node.cpp deleted file mode 100644 index 49ef22bb51..0000000000 --- a/engines/zvision/animation_node.cpp +++ /dev/null @@ -1,211 +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 "common/scummsys.h" - -#include "zvision/animation_node.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/meta_animation.h" - -#include "graphics/surface.h" - - -namespace ZVision { - -AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) - : SideFX(engine, controlKey, SIDEFX_ANIM), - _DisposeAfterUse(DisposeAfterUse), - _mask(mask), - _animation(NULL) { - - if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { - _animation = new MetaAnimation(fileName, engine); - _frmDelay = _animation->frameTime(); - } else { - warning("Unrecognized animation file type: %s", fileName.c_str()); - } - - if (frate > 0) - _frmDelay = 1000.0 / frate; -} - -AnimationNode::~AnimationNode() { - if (_animation) - delete _animation; - - _engine->getScriptManager()->setStateValue(_key, 2); - - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - _engine->getScriptManager()->setStateValue((*it).slot, 2); - - if ((*it)._scaled) - delete(*it)._scaled; - } - - _playList.clear(); -} - -bool AnimationNode::process(uint32 deltaTimeInMillis) { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - playnode *nod = &(*it); - - nod->_delay -= deltaTimeInMillis; - if (nod->_delay <= 0) { - nod->_delay += _frmDelay; - - const Graphics::Surface *frame = NULL; - - if (nod->_cur_frm == -1) { // Start of new playlist node - nod->_cur_frm = nod->start; - - _animation->seekToFrame(nod->_cur_frm); - frame = _animation->decodeNextFrame(); - - nod->_delay = _frmDelay; - if (nod->slot) - _engine->getScriptManager()->setStateValue(nod->slot, 1); - } else { - nod->_cur_frm++; - - if (nod->_cur_frm > nod->stop) { - nod->loop--; - - if (nod->loop == 0) { - if (nod->slot >= 0) - _engine->getScriptManager()->setStateValue(nod->slot, 2); - if (nod->_scaled) - delete nod->_scaled; - _playList.erase(it); - return _DisposeAfterUse; - } - - nod->_cur_frm = nod->start; - _animation->seekToFrame(nod->_cur_frm); - } - - frame = _animation->decodeNextFrame(); - } - - if (frame) { - - uint32 dstw; - uint32 dsth; - if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { - dstw = nod->pos.height(); - dsth = nod->pos.width(); - } else { - dstw = nod->pos.width(); - dsth = nod->pos.height(); - } - - if (frame->w != dstw || frame->h != dsth) { - if (nod->_scaled) - if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { - delete nod->_scaled; - nod->_scaled = NULL; - } - - if (!nod->_scaled) { - nod->_scaled = new Graphics::Surface; - nod->_scaled->create(dstw, dsth, frame->format); - } - - _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); - frame = nod->_scaled; - } - - if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { - Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); - if (_mask > 0) - _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); - delete transposed; - } else { - if (_mask > 0) - _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top); - } - } - } - } - - return false; -} - - - -void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) { - playnode nod; - nod.loop = loops; - nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); - nod.start = start_frame; - nod.stop = end_frame; - - if (nod.stop >= (int)_animation->frameCount()) - nod.stop = _animation->frameCount() - 1; - - nod.slot = slot; - nod._cur_frm = -1; - nod._delay = 0; - nod._scaled = NULL; - _playList.push_back(nod); -} - -bool AnimationNode::stop() { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - _engine->getScriptManager()->setStateValue((*it).slot, 2); - if ((*it)._scaled) - delete(*it)._scaled; - } - - _playList.clear(); - - // We don't need to delete, it's may be reused - return false; -} - -void AnimationNode::setNewFrameDelay(int32 newDelay) { - if (newDelay > 0) { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - playnode *nod = &(*it); - float percent = (float)nod->_delay / (float)_frmDelay; - nod->_delay = percent * newDelay; // Scale to new max - } - - _frmDelay = newDelay; - } -} - -int32 AnimationNode::getFrameDelay() { - return _frmDelay; -} - -} // End of namespace ZVision diff --git a/engines/zvision/animation_node.h b/engines/zvision/animation_node.h deleted file mode 100644 index ff7636a31f..0000000000 --- a/engines/zvision/animation_node.h +++ /dev/null @@ -1,84 +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 ZVISION_ANIMATION_NODE_H -#define ZVISION_ANIMATION_NODE_H - -#include "zvision/sidefx.h" -#include "common/rect.h" -#include "common/list.h" - - -namespace Common { -class String; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; -class MetaAnimation; - -class AnimationNode : public SideFX { -public: - AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); - ~AnimationNode(); - - struct playnode { - Common::Rect pos; - int32 slot; - int32 start; - int32 stop; - int32 loop; - int32 _cur_frm; - int32 _delay; - Graphics::Surface *_scaled; - }; - -private: - typedef Common::List PlayNodes; - - PlayNodes _playList; - - int32 _mask; - bool _DisposeAfterUse; - - MetaAnimation *_animation; - int32 _frmDelay; - -public: - bool process(uint32 deltaTimeInMillis); - - void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); - - bool stop(); - - void setNewFrameDelay(int32 newDelay); - int32 getFrameDelay(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index ef088f7553..aac4e7b2bc 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/strings/string_manager.h" +#include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp new file mode 100644 index 0000000000..bf311c4577 --- /dev/null +++ b/engines/zvision/core/menu.cpp @@ -0,0 +1,765 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/menu.h" + +#include "zvision/graphics/render_manager.h" + + +namespace ZVision { + +enum { + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 +}; + +enum { + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 +}; + +menuHandler::menuHandler(ZVision *engine) { + _engine = engine; + menu_bar_flag = 0xFFFF; +} + +menuZgi::menuZgi(ZVision *engine) : + menuHandler(engine) { + menu_mousefocus = -1; + inmenu = false; + scrolled[0] = false; + scrolled[1] = false; + scrolled[2] = false; + scrollPos[0] = 0.0; + scrollPos[1] = 0.0; + scrollPos[2] = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 1; i < 4; i++) { + sprintf(buf, "gmzau%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); + sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); + } + for (int i = 0; i < 4; i++) { + sprintf(buf, "gmzmu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); + sprintf(buf, "gmznu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); + } + + for (int i = 0; i < 50; i++) { + items[i][0] = NULL; + items[i][1] = NULL; + item_id[i] = 0; + } + + for (int i = 0; i < 12; i++) { + magic[i][0] = NULL; + magic[i][1] = NULL; + magic_id[i] = 0; + } +} + +menuZgi::~menuZgi() { + for (int i = 0; i < 3; i++) { + menuback[i][0].free(); + menuback[i][1].free(); + } + for (int i = 0; i < 4; i++) { + menubar[i][0].free(); + menubar[i][1].free(); + } + for (int i = 0; i < 50; i++) { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + } + } + for (int i = 0; i < 12; i++) { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + } + } +} + +void menuZgi::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouse_item >= 0 && mouse_item < 0xE0) { + _engine->getScriptManager()->invertory_drop(mouse_item); + _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); + + redraw = true; + } + } + } + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + for (int i = 0; i < 12; i++) { + + uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (itemnum != 0) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + itemnum = 0xEE + i; + else + itemnum = 0xE0 + i; + } + if (itemnum) + if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) + _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); + } + + } + break; + + case menu_MAIN: + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + // ifquit(); + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + } + break; + } + } +} + +void menuZgi::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + if (!inmenu) + redraw = true; + inmenu = true; + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) { + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + int last_item = mouse_on_item; + + mouse_on_item = -1; + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) + redraw = true; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) { + int last_item = mouse_on_item; + mouse_on_item = -1; + for (int i = 0; i < 12; i++) { + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { + mouse_on_item = i; + break; + } + } + + if (last_item != mouse_on_item) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) + redraw = true; + + } + break; + + case menu_MAIN: { + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) + redraw = true; + } + break; + + default: + int cur_menu = menu_mousefocus; + if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main + menu_mousefocus = menu_MAIN; + scrolled[menu_MAIN] = false; + scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + } + + if (menu_bar_flag & menuBar_Magic) + if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic + menu_mousefocus = menu_MAGIC; + scrolled[menu_MAGIC] = false; + scrollPos[menu_MAGIC] = 28; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); + } + + if (menu_bar_flag & menuBar_Items) + if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items + menu_mousefocus = menu_ITEM; + scrolled[menu_ITEM] = false; + scrollPos[menu_ITEM] = 28 - 600; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); + } + + if (cur_menu != menu_mousefocus) + clean = true; + + break; + } + } else { + if (inmenu) + clean = true; + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + menu_mousefocus = -1; + } +} + +void menuZgi::process(uint32 deltatime) { + if (clean) { + _engine->getRenderManager()->clearMenuSurface(); + clean = false; + } + switch (menu_mousefocus) { + case menu_ITEM: + if (menu_bar_flag & menuBar_Items) + if (!scrolled[menu_ITEM]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_ITEM] += scrl; + + if (scrollPos[menu_ITEM] >= 0) { + scrolled[menu_ITEM] = true; + scrollPos [menu_ITEM] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); + + int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (item_count == 0) + item_count = 20; + else if (item_count > 50) + item_count = 50; + + + for (int i = 0; i < item_count; i++) { + int itemspace = (600 - 28) / item_count; + + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + items[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + items[i][1] = _engine->getRenderManager()->loadImage(buf, false); + item_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + + } else { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + items[i][0] = NULL; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + items[i][1] = NULL; + } + item_id[i] = 0; + } + } + + redraw = false; + } + break; + + case menu_MAGIC: + if (menu_bar_flag & menuBar_Magic) + if (!scrolled[menu_MAGIC]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAGIC] += scrl; + + if (scrollPos[menu_MAGIC] >= 600) { + scrolled[menu_MAGIC] = true; + scrollPos [menu_MAGIC] = 600; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); + + for (int i = 0; i < 12; i++) { + bool inrect = false; + + if (mouse_on_item == i) + inrect = true; + + uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (cur_item_id) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + cur_item_id = 0xEE + i; + else + cur_item_id = 0xE0 + i; + } + + if (cur_item_id != 0) { + if (item_id[i] != cur_item_id) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); + magic_id[i] = cur_item_id; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + + } else { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + magic[i][0] = NULL; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + magic[i][1] = NULL; + } + magic_id[i] = 0; + } + } + redraw = false; + } + break; + + case menu_MAIN: + if (!scrolled[menu_MAIN]) { + redraw = true; + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAIN] += scrl; + + if (scrollPos[menu_MAIN] >= 0) { + scrolled[menu_MAIN] = true; + scrollPos [menu_MAIN] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); + + if (menu_bar_flag & menuBar_Exit) { + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Settings) { + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Restore) { + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); + } + if (menu_bar_flag & menuBar_Save) { + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); + } + redraw = false; + } + break; + default: + if (redraw) { + if (inmenu) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); + + if (menu_bar_flag & menuBar_Items) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); + + if (menu_bar_flag & menuBar_Magic) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); + } + redraw = false; + } + break; + } +} + + +menuNem::menuNem(ZVision *engine) : + menuHandler(engine) { + inmenu = false; + scrolled = false; + scrollPos = 0.0; + mouse_on_item = -1; + + char buf[24]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) { + sprintf(buf, "butfrm%d%d.tga", i + 1, j); + _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); + } + + _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); + + frm = 0; +} + +menuNem::~menuNem() { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) + but[i][j].free(); + + menubar.free(); +} + +static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; + +void menuNem::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + // ifquit(); + frm = 5; + redraw = true; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + frm = 5; + redraw = true; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + frm = 5; + redraw = true; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + frm = 5; + redraw = true; + } + } +} + +void menuNem::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + inmenu = true; + + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + + int last_item = mouse_on_item; + mouse_on_item = -1; + + // Exit + if (menu_bar_flag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_EXIT; + } + + // Settings + if (menu_bar_flag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_PREF; + } + + // Load + if (menu_bar_flag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_REST; + } + + // Save + if (menu_bar_flag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + mouse_on_item = menu_MAIN_SAVE; + } + + if (last_item != mouse_on_item) { + redraw = true; + frm = 0; + delay = 200; + } + } else { + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + mouse_on_item = -1; + } +} + +void menuNem::process(uint32 deltatime) { + if (inmenu) { + if (!scrolled) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos += scrl; + redraw = true; + } + + if (scrollPos >= 0) { + scrolled = true; + scrollPos = 0; + } + + if (mouse_on_item != -1) { + delay -= deltatime; + if (delay <= 0 && frm < 4) { + delay = 200; + frm++; + redraw = true; + } + } + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + + if (menu_bar_flag & menuBar_Exit) + if (mouse_on_item == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); + + if (menu_bar_flag & menuBar_Settings) + if (mouse_on_item == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); + + if (menu_bar_flag & menuBar_Restore) + if (mouse_on_item == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); + + if (menu_bar_flag & menuBar_Save) + if (mouse_on_item == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); + + redraw = false; + } + } else { + scrolled = false; + if (scrollPos > -32) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); + _engine->getRenderManager()->clearMenuSurface(cl); + + scrollPos -= scrl; + redraw = true; + } else + scrollPos = -32; + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + redraw = false; + } + } +} + + +} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp new file mode 100644 index 0000000000..fe99772b9b --- /dev/null +++ b/engines/zvision/core/search_manager.cpp @@ -0,0 +1,274 @@ +/* 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 "common/debug.h" + +#include "zvision/core/search_manager.h" +#include "zvision/archives/zfs_archive.h" +#include "common/fs.h" +#include "common/stream.h" + + +namespace ZVision { + +sManager::sManager(const Common::String &root_path, int depth) { + _root = root_path; + if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') + _root.deleteLastChar(); + + Common::FSNode fs_node(_root); + + list_dir_recursive(dir_list, fs_node, depth); + + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) + if (it->size() == _root.size()) + it = dir_list.erase(it); + else if (it->size() > _root.size()) { + *it = Common::String(it->c_str() + _root.size() + 1); + it++; + } else + it++; +} + +sManager::~sManager() { + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + delete *it; + it++; + } + + archList.clear(); +} + +void sManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lw_name = dst; + lw_name.toLowercase(); + + sManager::MatchList::iterator it = files.find(lw_name); + + if (it != files.end()) { + lw_name = src; + lw_name.toLowercase(); + files[lw_name] = it->_value; + } +} + +void sManager::addFile(const Common::String &name, Common::Archive *arch) { + bool addArch = true; + Common::List::iterator it = archList.begin(); + while (it != archList.end()) { + if (*it == arch) { + addArch = false; + break; + } + it++; + } + if (addArch) + archList.push_back(arch); + + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::Node nod; + nod.name = lw_name; + nod.arch = arch; + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit == files.end()) { + files[lw_name] = nod; + } else { + Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); + if (stream) { + if (stream->size() < 10) + fit->_value.arch = arch; + delete stream; + } else { + files[lw_name] = nod; + } + } +} + +Common::File *sManager::openFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) { + Common::File *tmp = new Common::File(); + tmp->open(fit->_value.name, *fit->_value.arch); + return tmp; + } + return NULL; +} + +bool sManager::openFile(Common::File &file, const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return file.open(fit->_value.name, *fit->_value.arch); + return false; +} + +bool sManager::hasFile(const Common::String &name) { + Common::String lw_name = name; + lw_name.toLowercase(); + + sManager::MatchList::iterator fit = files.find(lw_name); + + if (fit != files.end()) + return true; + return false; +} + +void sManager::loadZix(const Common::String &name) { + Common::File file; + file.open(name); + + Common::String line; + + while (!file.eos()) { + line = file.readLine(); + if (line.matchString("----------*", true)) + break; + } + + if (file.eos()) + return; + + Common::Array archives; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + if (line.matchString("----------*", true)) + break; + else if (line.matchString("DIR:*", true)) { + Common::String path(line.c_str() + 5); + Common::Archive *arc; + char n_path[128]; + strcpy(n_path, path.c_str()); + for (uint i = 0; i < path.size(); i++) + if (n_path[i] == '\\') + n_path[i] = '/'; + + path = Common::String(n_path); + if (path.size() && path[0] == '.') + path.deleteChar(0); + if (path.size() && path[0] == '/') + path.deleteChar(0); + + if (path.matchString("*.zfs", true)) + arc = new ZfsArchive(path); + else { + if (path.size()) { + if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') + path.deleteLastChar(); + if (path.size()) + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + arc = new Common::FSDirectory(path); + } + archives.push_back(arc); + } + } + + if (file.eos()) + return; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + uint dr = 0; + char buf[32]; + if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { + if (dr <= archives.size() && dr > 0) { + addFile(Common::String(buf), archives[dr - 1]); + } + } + } +} + +void sManager::addDir(const Common::String &name) { + Common::String path; + for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + if (name.equalsIgnoreCase(*it)) { + path = *it; + break; + } + + if (path.size() == 0) + return; + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + Common::FSDirectory *dir = new Common::FSDirectory(path); + + Common::ArchiveMemberList list; + dir->listMatchingMembers(list, "*.zfs"); + + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + + ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); + + Common::ArchiveMemberList zfslist; + zfs->listMembers(zfslist); + + for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { + Common::String z_name = (*ziter)->getName(); + addFile(z_name, zfs); + } + } + + list.clear(); + dir->listMembers(list); + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + addFile(flname, dir); + } +} + +void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { + Common::FSList fs_list; + fs_node.getChildren(fs_list); + + _list.push_back(fs_node.getPath()); + + if (depth > 1) + for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) + list_dir_recursive(_list, *it, depth - 1); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h new file mode 100644 index 0000000000..c768cb8b00 --- /dev/null +++ b/engines/zvision/core/search_manager.h @@ -0,0 +1,51 @@ +#ifndef SEARCH_MANAGER_H_INCLUDED +#define SEARCH_MANAGER_H_INCLUDED + +#include "common/str.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/archive.h" +#include "common/file.h" +#include "common/list.h" + +namespace ZVision { + +class sManager { +public: + sManager(const Common::String &root_path, int depth); + ~sManager(); + + void addFile(const Common::String &name, Common::Archive *arch); + void addDir(const Common::String &name); + void addPatch(const Common::String &src, const Common::String &dst); + + Common::File *openFile(const Common::String &name); + bool openFile(Common::File &file, const Common::String &name); + bool hasFile(const Common::String &name); + + void loadZix(const Common::String &name); + +private: + + void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); + + struct Node { + Common::String name; + Common::Archive *arch; + }; + + Common::List dir_list; + + typedef Common::HashMap MatchList; + + Common::List archList; + MatchList files; + + Common::String _root; + +private: +}; + +} + +#endif // SEARCH_MANAGER_H_INCLUDED diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index c9dc5d37b2..f3b01b7e30 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -24,7 +24,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" -#include "zvision/text.h" +#include "zvision/text/text.h" #include "zvision/utility/lzss_read_stream.h" diff --git a/engines/zvision/inventory_manager.cpp b/engines/zvision/inventory_manager.cpp deleted file mode 100644 index f8b22970c4..0000000000 --- a/engines/zvision/inventory_manager.cpp +++ /dev/null @@ -1,123 +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 "common/scummsys.h" - -#include "zvision/scripting/script_manager.h" - - -namespace ZVision { - -int8 ScriptManager::invertory_getCount() { - return getStateValue(StateKey_Inv_Cnt_Slot); -} - -void ScriptManager::invertory_setCount(int8 cnt) { - setStateValue(StateKey_Inv_Cnt_Slot, cnt); -} - -int16 ScriptManager::invertory_getItem(int8 id) { - if (id < 49 && id >= 0) - return getStateValue(StateKey_Inv_1_Slot + id); - return -1; -} - -void ScriptManager::invertory_setItem(int8 id, int16 item) { - if (id < 49 && id >= 0) - setStateValue(StateKey_Inv_1_Slot + id, item); -} - -void ScriptManager::invertory_add(int16 item) { - int8 cnt = invertory_getCount(); - - if (cnt < 49) { - bool not_exist = true; - - if (cnt == 0) { - invertory_setItem(0, 0); - invertory_setCount(1); // we needed empty item for cycle code - cnt = 1; - } - - for (int8 cur = 0; cur < cnt; cur++) - if (invertory_getItem(cur) == item) { - not_exist = false; - break; - } - - if (not_exist) { - for (int8 i = cnt; i > 0; i--) - invertory_setItem(i, invertory_getItem(i - 1)); - - invertory_setItem(0, item); - - setStateValue(StateKey_InventoryItem, item); - - invertory_setCount(cnt + 1); - } - } -} - -void ScriptManager::invertory_drop(int16 item) { - int8 items_cnt = invertory_getCount(); - - // if items in inventory > 0 - if (items_cnt != 0) { - int8 index = 0; - - // finding needed item - while (index < items_cnt) { - if (invertory_getItem(index) == item) - break; - - index++; - } - - // if item in the inventory - if (items_cnt != index) { - // shift all items left with rewrite founded item - for (int8 v = index; v < items_cnt - 1 ; v++) - invertory_setItem(v, invertory_getItem(v + 1)); - - // del last item - invertory_setItem(items_cnt - 1, 0); - invertory_setCount(invertory_getCount() - 1); - - setStateValue(StateKey_InventoryItem, invertory_getItem(0)); - } - } -} -void ScriptManager::invertory_cycle() { - int8 item_cnt = invertory_getCount(); - int8 cur_item = invertory_getItem(0); - if (item_cnt > 1) { - for (int8 i = 0; i < item_cnt - 1; i++) - invertory_setItem(i, invertory_getItem(i + 1)); - - invertory_setItem(item_cnt - 1, cur_item); - - setStateValue(StateKey_InventoryItem, invertory_getItem(0)); - - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/menu.cpp b/engines/zvision/menu.cpp deleted file mode 100644 index bf311c4577..0000000000 --- a/engines/zvision/menu.cpp +++ /dev/null @@ -1,765 +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 "common/scummsys.h" - -#include "zvision/core/menu.h" - -#include "zvision/graphics/render_manager.h" - - -namespace ZVision { - -enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 -}; - -enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 -}; - -menuHandler::menuHandler(ZVision *engine) { - _engine = engine; - menu_bar_flag = 0xFFFF; -} - -menuZgi::menuZgi(ZVision *engine) : - menuHandler(engine) { - menu_mousefocus = -1; - inmenu = false; - scrolled[0] = false; - scrolled[1] = false; - scrolled[2] = false; - scrollPos[0] = 0.0; - scrollPos[1] = 0.0; - scrollPos[2] = 0.0; - mouse_on_item = -1; - - char buf[24]; - for (int i = 1; i < 4; i++) { - sprintf(buf, "gmzau%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); - sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); - } - for (int i = 0; i < 4; i++) { - sprintf(buf, "gmzmu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); - sprintf(buf, "gmznu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); - } - - for (int i = 0; i < 50; i++) { - items[i][0] = NULL; - items[i][1] = NULL; - item_id[i] = 0; - } - - for (int i = 0; i < 12; i++) { - magic[i][0] = NULL; - magic[i][1] = NULL; - magic_id[i] = 0; - } -} - -menuZgi::~menuZgi() { - for (int i = 0; i < 3; i++) { - menuback[i][0].free(); - menuback[i][1].free(); - } - for (int i = 0; i < 4; i++) { - menubar[i][0].free(); - menubar[i][1].free(); - } - for (int i = 0; i < 50; i++) { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - } - } - for (int i = 0; i < 12; i++) { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - } - } -} - -void menuZgi::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - switch (menu_mousefocus) { - case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (mouse_item >= 0 && mouse_item < 0xE0) { - _engine->getScriptManager()->invertory_drop(mouse_item); - _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); - - redraw = true; - } - } - } - } - break; - - case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { - for (int i = 0; i < 12; i++) { - - uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (itemnum != 0) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - itemnum = 0xEE + i; - else - itemnum = 0xE0 + i; - } - if (itemnum) - if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) - _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); - } - - } - break; - - case menu_MAIN: - - // Exit - if (menu_bar_flag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - // ifquit(); - } - - // Settings - if (menu_bar_flag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - } - - // Load - if (menu_bar_flag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - } - - // Save - if (menu_bar_flag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - } - break; - } - } -} - -void menuZgi::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - if (!inmenu) - redraw = true; - inmenu = true; - switch (menu_mousefocus) { - case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; - - int last_item = mouse_on_item; - - mouse_on_item = -1; - - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - mouse_on_item = i; - break; - } - } - - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) - redraw = true; - } - break; - - case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { - int last_item = mouse_on_item; - mouse_on_item = -1; - for (int i = 0; i < 12; i++) { - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { - mouse_on_item = i; - break; - } - } - - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) - redraw = true; - - } - break; - - case menu_MAIN: { - int last_item = mouse_on_item; - mouse_on_item = -1; - - // Exit - if (menu_bar_flag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; - } - - // Settings - if (menu_bar_flag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; - } - - // Load - if (menu_bar_flag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; - } - - // Save - if (menu_bar_flag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; - } - - if (last_item != mouse_on_item) - redraw = true; - } - break; - - default: - int cur_menu = menu_mousefocus; - if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menu_mousefocus = menu_MAIN; - scrolled[menu_MAIN] = false; - scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - } - - if (menu_bar_flag & menuBar_Magic) - if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menu_mousefocus = menu_MAGIC; - scrolled[menu_MAGIC] = false; - scrollPos[menu_MAGIC] = 28; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); - } - - if (menu_bar_flag & menuBar_Items) - if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menu_mousefocus = menu_ITEM; - scrolled[menu_ITEM] = false; - scrollPos[menu_ITEM] = 28 - 600; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); - } - - if (cur_menu != menu_mousefocus) - clean = true; - - break; - } - } else { - if (inmenu) - clean = true; - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - menu_mousefocus = -1; - } -} - -void menuZgi::process(uint32 deltatime) { - if (clean) { - _engine->getRenderManager()->clearMenuSurface(); - clean = false; - } - switch (menu_mousefocus) { - case menu_ITEM: - if (menu_bar_flag & menuBar_Items) - if (!scrolled[menu_ITEM]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_ITEM] += scrl; - - if (scrollPos[menu_ITEM] >= 0) { - scrolled[menu_ITEM] = true; - scrollPos [menu_ITEM] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); - - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; - - - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; - - bool inrect = false; - - if (mouse_on_item == i) - inrect = true; - - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); - - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); - items[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); - items[i][1] = _engine->getRenderManager()->loadImage(buf, false); - item_id[i] = cur_item_id; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - - } else { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - items[i][0] = NULL; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - items[i][1] = NULL; - } - item_id[i] = 0; - } - } - - redraw = false; - } - break; - - case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) - if (!scrolled[menu_MAGIC]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAGIC] += scrl; - - if (scrollPos[menu_MAGIC] >= 600) { - scrolled[menu_MAGIC] = true; - scrollPos [menu_MAGIC] = 600; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); - - for (int i = 0; i < 12; i++) { - bool inrect = false; - - if (mouse_on_item == i) - inrect = true; - - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (cur_item_id) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - cur_item_id = 0xEE + i; - else - cur_item_id = 0xE0 + i; - } - - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); - magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); - magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); - magic_id[i] = cur_item_id; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - - } else { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - magic[i][0] = NULL; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - magic[i][1] = NULL; - } - magic_id[i] = 0; - } - } - redraw = false; - } - break; - - case menu_MAIN: - if (!scrolled[menu_MAIN]) { - redraw = true; - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAIN] += scrl; - - if (scrollPos[menu_MAIN] >= 0) { - scrolled[menu_MAIN] = true; - scrollPos [menu_MAIN] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - - if (menu_bar_flag & menuBar_Exit) { - if (mouse_on_item == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); - } - if (menu_bar_flag & menuBar_Settings) { - if (mouse_on_item == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); - } - if (menu_bar_flag & menuBar_Restore) { - if (mouse_on_item == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); - } - if (menu_bar_flag & menuBar_Save) { - if (mouse_on_item == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); - } - redraw = false; - } - break; - default: - if (redraw) { - if (inmenu) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); - - if (menu_bar_flag & menuBar_Items) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); - - if (menu_bar_flag & menuBar_Magic) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); - } - redraw = false; - } - break; - } -} - - -menuNem::menuNem(ZVision *engine) : - menuHandler(engine) { - inmenu = false; - scrolled = false; - scrollPos = 0.0; - mouse_on_item = -1; - - char buf[24]; - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) { - sprintf(buf, "butfrm%d%d.tga", i + 1, j); - _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); - } - - _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); - - frm = 0; -} - -menuNem::~menuNem() { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) - but[i][j].free(); - - menubar.free(); -} - -static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; - -void menuNem::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - // Exit - if (menu_bar_flag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - // ifquit(); - frm = 5; - redraw = true; - } - - // Settings - if (menu_bar_flag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - frm = 5; - redraw = true; - } - - // Load - if (menu_bar_flag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - frm = 5; - redraw = true; - } - - // Save - if (menu_bar_flag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - frm = 5; - redraw = true; - } - } -} - -void menuNem::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - inmenu = true; - - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - - int last_item = mouse_on_item; - mouse_on_item = -1; - - // Exit - if (menu_bar_flag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; - } - - // Settings - if (menu_bar_flag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; - } - - // Load - if (menu_bar_flag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; - } - - // Save - if (menu_bar_flag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; - } - - if (last_item != mouse_on_item) { - redraw = true; - frm = 0; - delay = 200; - } - } else { - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - mouse_on_item = -1; - } -} - -void menuNem::process(uint32 deltatime) { - if (inmenu) { - if (!scrolled) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos += scrl; - redraw = true; - } - - if (scrollPos >= 0) { - scrolled = true; - scrollPos = 0; - } - - if (mouse_on_item != -1) { - delay -= deltatime; - if (delay <= 0 && frm < 4) { - delay = 200; - frm++; - redraw = true; - } - } - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - - if (menu_bar_flag & menuBar_Exit) - if (mouse_on_item == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - - if (menu_bar_flag & menuBar_Settings) - if (mouse_on_item == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - - if (menu_bar_flag & menuBar_Restore) - if (mouse_on_item == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - - if (menu_bar_flag & menuBar_Save) - if (mouse_on_item == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); - - redraw = false; - } - } else { - scrolled = false; - if (scrollPos > -32) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); - _engine->getRenderManager()->clearMenuSurface(cl); - - scrollPos -= scrl; - redraw = true; - } else - scrollPos = -32; - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - redraw = false; - } - } -} - - -} // End of namespace ZVision diff --git a/engines/zvision/meta_animation.cpp b/engines/zvision/meta_animation.cpp deleted file mode 100644 index dddc238379..0000000000 --- a/engines/zvision/meta_animation.cpp +++ /dev/null @@ -1,131 +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 "common/scummsys.h" - -#include "zvision/meta_animation.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/animation/rlf_animation.h" -#include "zvision/video/zork_avi_decoder.h" - -#include "video/video_decoder.h" - -#include "graphics/surface.h" - - -namespace ZVision { - -MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) - : _fileType(RLF), - _cur_frame(NULL) { - if (fileName.hasSuffix(".rlf")) { - _fileType = RLF; - Common::File *_file = engine->getSearchManager()->openFile(fileName); - _animation.rlf = new RlfAnimation(_file, false); - _frmDelay = _animation.rlf->frameTime(); - } else if (fileName.hasSuffix(".avi")) { - _fileType = AVI; - Common::File *_file = engine->getSearchManager()->openFile(fileName); - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadStream(_file); - _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); - } else { - warning("Unrecognized animation file type: %s", fileName.c_str()); - } -} - -MetaAnimation::~MetaAnimation() { - if (_fileType == RLF) { - delete _animation.rlf; - } else if (_fileType == AVI) { - delete _animation.avi; - } -} - -uint MetaAnimation::frameCount() { - if (_fileType == RLF) { - return _animation.rlf->frameCount(); - } else - return _animation.avi->getFrameCount(); - -} - -uint MetaAnimation::width() { - if (_fileType == RLF) { - return _animation.rlf->width(); - } else - return _animation.avi->getWidth(); -} -uint MetaAnimation::height() { - if (_fileType == RLF) { - return _animation.rlf->height(); - } else - return _animation.avi->getHeight(); -} -uint32 MetaAnimation::frameTime() { - return _frmDelay; -} - -void MetaAnimation::seekToFrame(int frameNumber) { - if (frameNumber >= (int)frameCount()) - frameNumber = frameCount() - 1; - - if (_fileType == RLF) { - _animation.rlf->seekToFrame(frameNumber); - } else - _animation.avi->seekToFrame(frameNumber); -} - -const Graphics::Surface *MetaAnimation::decodeNextFrame() { - if (_fileType == RLF) - _cur_frame = _animation.rlf->decodeNextFrame(); - else - _cur_frame = _animation.avi->decodeNextFrame(); - - return _cur_frame; -} - -const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { - if (frameNumber >= frameCount()) - frameNumber = frameCount() - 1; - - if (_fileType == RLF) { - _cur_frame = _animation.rlf->getFrameData(frameNumber); - return _cur_frame; - } else { - _animation.avi->seekToFrame(frameNumber); - _cur_frame = _animation.avi->decodeNextFrame(); - return _cur_frame; - } -} - -bool MetaAnimation::endOfAnimation() { - if (_fileType == RLF) { - return _animation.rlf->endOfAnimation(); - } else - return _animation.avi->endOfVideo(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/meta_animation.h b/engines/zvision/meta_animation.h deleted file mode 100644 index 3754aae058..0000000000 --- a/engines/zvision/meta_animation.h +++ /dev/null @@ -1,99 +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 ZVISION_METAANIM_NODE_H -#define ZVISION_METAANIM_NODE_H - -#include "zvision/sidefx.h" -#include "zvision/zvision.h" -#include "common/rect.h" -#include "common/list.h" - - -namespace Common { -class String; -} - -namespace Video { -class VideoDecoder; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; -class RlfAnimation; - -class MetaAnimation { -public: - MetaAnimation(const Common::String &fileName, ZVision *engine); - ~MetaAnimation(); - - struct playnode { - Common::Rect pos; - int32 slot; - int32 start; - int32 stop; - int32 loop; - int32 _cur_frm; - int32 _delay; - Graphics::Surface *_scaled; - }; - -private: - enum FileType { - RLF = 1, - AVI = 2 - }; - -private: - union { - RlfAnimation *rlf; - Video::VideoDecoder *avi; - } _animation; - - FileType _fileType; - int32 _frmDelay; - - const Graphics::Surface *_cur_frame; - -public: - - uint frameCount(); - uint width(); - uint height(); - uint32 frameTime(); - - void seekToFrame(int frameNumber); - - const Graphics::Surface *decodeNextFrame(); - const Graphics::Surface *getFrameData(uint frameNumber); - - bool endOfAnimation(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index a386f6fac6..9d5072a64d 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -1,46 +1,46 @@ MODULE := engines/zvision MODULE_OBJS := \ - scripting/actions.o \ - animation_node.o \ - utility/clock.o \ + animation/meta_animation.o \ + animation/rlf_animation.o \ + archives/zfs_archive.o \ core/console.o \ - scripting/control.o \ - cursors/cursor.o \ + core/events.o \ + core/menu.o \ + core/save_manager.o \ + core/search_manager.o \ cursors/cursor_manager.o \ + cursors/cursor.o \ detection.o \ - core/events.o \ + fonts/truetype_font.o \ + graphics/render_manager.o \ + graphics/render_table.o \ + scripting/actions.o \ + scripting/control.o \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ - utility/lzss_read_stream.o \ scripting/controls/push_toggle_control.o \ - graphics/render_manager.o \ - graphics/render_table.o \ - animation/rlf_animation.o \ - core/save_manager.o \ + scripting/controls/slot_control.o \ + scripting/inventory.o \ scripting/scr_file_handling.o \ scripting/script_manager.o \ + scripting/sidefx.o \ + scripting/sidefx/animation_node.o \ + scripting/sidefx/music_node.o \ + scripting/sidefx/syncsound_node.o \ + scripting/sidefx/timer_node.o \ + scripting/sidefx/ttytext_node.o \ + sound/zork_raw.o \ + subtitles/subtitles.o \ + text/string_manager.o \ + text/text.o \ + utility/clock.o \ + utility/lzss_read_stream.o \ utility/single_value_container.o \ - strings/string_manager.o \ - scripting/controls/timer_node.o \ - fonts/truetype_font.o \ utility/utility.o \ video/video.o \ - zvision.o \ - archives/zfs_archive.o \ video/zork_avi_decoder.o \ - sound/zork_raw.o \ - sidefx.o \ - music_node.o \ - inventory_manager.o \ - slot_control.o \ - menu.o \ - meta_animation.o \ - search_manager.o \ - text.o \ - subtitles.o \ - syncsound_node.o \ - ttytext_node.o + zvision.o MODULE_DIRS += \ engines/zvision diff --git a/engines/zvision/music_node.cpp b/engines/zvision/music_node.cpp deleted file mode 100644 index f8fd08b285..0000000000 --- a/engines/zvision/music_node.cpp +++ /dev/null @@ -1,190 +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 "common/scummsys.h" - -#include "zvision/music_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/sound/zork_raw.h" - -#include "common/stream.h" -#include "common/file.h" -#include "audio/decoders/wave.h" - - -namespace ZVision { - -MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) - : SideFX(engine, key, SIDEFX_AUDIO) { - _loop = loop; - _volume = volume; - _crossfade = false; - _crossfade_target = 0; - _crossfade_time = 0; - _attenuate = 0; - _pantrack = false; - _pantrack_X = 0; - _sub = NULL; - - Audio::RewindableAudioStream *audioStream; - - if (filename.contains(".wav")) { - Common::File *file = new Common::File(); - if (_engine->getSearchManager()->openFile(*file, filename)) { - audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); - } - } else { - audioStream = makeRawZorkStream(filename, _engine); - } - - _stereo = audioStream->isStereo(); - - if (_loop) { - Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); - } else { - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); - } - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); - - Common::String subname = filename; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); - - if (_engine->getSearchManager()->hasFile(subname)) - _sub = new Subtitle(_engine, subname); -} - -MusicNode::~MusicNode() { - _engine->_mixer->stopHandle(_handle); - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - if (_sub) - delete _sub; - debug(1, "MusicNode: %d destroyed\n", _key); -} - -void MusicNode::setPanTrack(int16 pos) { - if (!_stereo) { - _pantrack = true; - _pantrack_X = pos; - setVolume(_volume); - } -} - -void MusicNode::unsetPanTrack() { - _pantrack = false; - setVolume(_volume); -} - -void MusicNode::setFade(int32 time, uint8 target) { - _crossfade_target = target; - _crossfade_time = time; - _crossfade = true; -} - -bool MusicNode::process(uint32 deltaTimeInMillis) { - if (! _engine->_mixer->isSoundHandleActive(_handle)) - return stop(); - else { - uint8 _newvol = _volume; - - if (_crossfade) { - if (_crossfade_time > 0) { - if ((int32)deltaTimeInMillis > _crossfade_time) - deltaTimeInMillis = _crossfade_time; - _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; - _crossfade_time -= deltaTimeInMillis; - } else { - _crossfade = false; - _newvol = _crossfade_target; - } - } - - if (_pantrack || _volume != _newvol) - setVolume(_newvol); - - if (_sub) - _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); - } - return false; -} - -void MusicNode::setVolume(uint8 new_volume) { - if (_pantrack) { - int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); - cur_x -= _pantrack_X; - int32 _width = _engine->getRenderManager()->getBkgSize().x; - if (cur_x < (-_width) / 2) - cur_x += _width; - else if (cur_x >= _width / 2) - cur_x -= _width; - - float norm = (float)cur_x / ((float)_width / 2.0); - float lvl = fabs(norm); - if (lvl > 0.5) - lvl = (lvl - 0.5) * 1.7; - else - lvl = 1.0; - - float bal = sin(-norm * 3.1415926) * 127.0; - - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, bal); - _engine->_mixer->setChannelVolume(_handle, new_volume * lvl); - } - } else { - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, 0); - _engine->_mixer->setChannelVolume(_handle, new_volume); - } - } - - _volume = new_volume; -} - -PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) - : SideFX(engine, key, SIDEFX_PANTRACK) { - _slot = slot; - - SideFX *fx = _engine->getScriptManager()->getSideFX(slot); - if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode *mus = (MusicNode *)fx; - mus->setPanTrack(pos); - } -} - -PanTrackNode::~PanTrackNode() { - SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); - if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode *mus = (MusicNode *)fx; - mus->unsetPanTrack(); - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/music_node.h b/engines/zvision/music_node.h deleted file mode 100644 index 0dad22614b..0000000000 --- a/engines/zvision/music_node.h +++ /dev/null @@ -1,82 +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 ZVISION_MUSIC_NODE_H -#define ZVISION_MUSIC_NODE_H - -#include "audio/mixer.h" -#include "zvision/sidefx.h" -#include "zvision/subtitles/subtitles.h" - -namespace Common { -class String; -} - -namespace ZVision { -class MusicNode : public SideFX { -public: - MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); - ~MusicNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - - void setVolume(uint8 volume); - - void setPanTrack(int16 pos); - void unsetPanTrack(); - - void setFade(int32 time, uint8 target); - -private: - int32 _timeLeft; - bool _pantrack; - int32 _pantrack_X; - int32 _attenuate; - uint8 _volume; - bool _loop; - bool _crossfade; - uint8 _crossfade_target; - int32 _crossfade_time; - bool _stereo; - Audio::SoundHandle _handle; - Subtitle *_sub; -}; - -class PanTrackNode : public SideFX { -public: - PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); - ~PanTrackNode(); - -private: - uint32 _slot; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 3c341fbc80..22fbd4ff16 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -29,11 +29,11 @@ #include "zvision/graphics/render_manager.h" #include "zvision/sound/zork_raw.h" #include "zvision/video/zork_avi_decoder.h" -#include "zvision/scripting/controls/timer_node.h" -#include "zvision/music_node.h" -#include "zvision/syncsound_node.h" -#include "zvision/animation_node.h" -#include "zvision/ttytext_node.h" +#include "zvision/scripting/sidefx/timer_node.h" +#include "zvision/scripting/sidefx/music_node.h" +#include "zvision/scripting/sidefx/syncsound_node.h" +#include "zvision/scripting/sidefx/animation_node.h" +#include "zvision/scripting/sidefx/ttytext_node.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index ca707b5ab0..ba1b634d42 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/strings/string_manager.h" +#include "zvision/text/string_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 4a63f228a0..6fcdb2ca54 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -24,7 +24,7 @@ #define ZVISION_INPUT_CONTROL_H #include "zvision/scripting/control.h" -#include "zvision/strings/string_manager.h" +#include "zvision/text/string_manager.h" #include "common/rect.h" diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 121fab97e1..7e3ee775fb 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" -#include "zvision/meta_animation.h" +#include "zvision/animation/meta_animation.h" #include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp new file mode 100644 index 0000000000..c85b02b3cd --- /dev/null +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -0,0 +1,219 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/slot_control.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" + + +namespace ZVision { + +SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key) { + + _rendered_item = 0; + _bkg = NULL; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("hotspot", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _hotspot = Common::Rect(x, y, width, height); + } else if (param.matchString("rectangle", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _rectangle = Common::Rect(x, y, width, height); + } else if (param.matchString("cursor", true)) { + _cursor = _engine->getCursorManager()->getCursorId(values); + } else if (param.matchString("distance_id", true)) { + sscanf(values.c_str(), "%c", &_distance_id); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } else if (param.matchString("eligible_objects", true)) { + char buf[256]; + memset(buf, 0, 256); + strcpy(buf, values.c_str()); + + char *curpos = buf; + char *strend = buf + strlen(buf); + while (true) { + char *st = curpos; + + if (st >= strend) + break; + + while (*curpos != ' ' && curpos < strend) + curpos++; + + *curpos = 0; + curpos++; + + int obj = atoi(st); + + _eligible_objects.push_back(obj); + } + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } + + if (_hotspot.isEmpty() || _rectangle.isEmpty()) { + warning("Slot %u was parsed incorrectly", key); + } +} + +SlotControl::~SlotControl() { + // Clear the state value back to 0 + //_engine->getScriptManager()->setStateValue(_key, 0); + + if (_bkg) + delete _bkg; +} + +bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_hotspot.contains(backgroundImageSpacePos)) { + //ctrl_setvenus(ct); + + int item = _engine->getScriptManager()->getStateValue(_key); + int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (item != 0) { + if (mouse_item != 0) { + if (eligeblity(mouse_item)) { + _engine->getScriptManager()->invertory_drop(mouse_item); + _engine->getScriptManager()->invertory_add(item); + _engine->getScriptManager()->setStateValue(_key, mouse_item); + } + } else { + _engine->getScriptManager()->invertory_add(item); + _engine->getScriptManager()->setStateValue(_key, 0); + } + } else if (mouse_item == 0) { + if (eligeblity(0)) { + _engine->getScriptManager()->invertory_drop(0); + _engine->getScriptManager()->setStateValue(_key, 0); + } + } else if (eligeblity(mouse_item)) { + _engine->getScriptManager()->setStateValue(_key, mouse_item); + _engine->getScriptManager()->invertory_drop(mouse_item); + } + } + return false; +} + +bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_hotspot.contains(backgroundImageSpacePos)) { + _engine->getCursorManager()->changeCursor(_cursor); + return true; + } + + return false; +} + +bool SlotControl::process(uint32 deltaTimeInMillis) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_engine->canRender()) { + int cur_item = _engine->getScriptManager()->getStateValue(_key); + if (cur_item != _rendered_item) { + if (_rendered_item != 0 && cur_item == 0) { + _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); + _rendered_item = cur_item; + } else { + if (_rendered_item == 0) { + if (_bkg) + delete _bkg; + + _bkg = _engine->getRenderManager()->getBkgRect(_rectangle); + } else { + _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); + } + + char buf[16]; + if (_engine->getGameId() == GID_NEMESIS) + sprintf(buf, "%d%cobj.tga", cur_item, _distance_id); + else + sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item); + + Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf); + + int16 drawx = _rectangle.left; + int16 drawy = _rectangle.top; + + if (_rectangle.width() > srf->w) + drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2; + + if (_rectangle.height() > srf->h) + drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2; + + _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0); + + delete srf; + + _rendered_item = cur_item; + } + } + } + return false; +} + +bool SlotControl::eligeblity(int item_id) { + for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) + if (*it == item_id) + return true; + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h new file mode 100644 index 0000000000..0ac8ec9ce0 --- /dev/null +++ b/engines/zvision/scripting/controls/slot_control.h @@ -0,0 +1,86 @@ +/* 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 ZVISION_SLOT_CONTROL_H +#define ZVISION_SLOT_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "graphics/surface.h" + +#include "common/rect.h" +#include "common/list.h" + + +namespace ZVision { + +class SlotControl : public Control { +public: + SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~SlotControl(); + + /** + * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); + * + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + /** + * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. + * + * @param engine The base engine + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + * @return Was the cursor changed? + */ + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + + bool process(uint32 deltaTimeInMillis); + +private: + /** + * The area that will trigger the event + * This is in image space coordinates, NOT screen space + */ + Common::Rect _rectangle; + Common::Rect _hotspot; + + int _cursor; + char _distance_id; + int _venus_id; + + int _rendered_item; + + Common::List _eligible_objects; + + bool eligeblity(int item_id); + + Graphics::Surface *_bkg; + + /** The cursor to use when hovering over _hotspot */ + Common::String _hoverCursor; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/controls/timer_node.cpp deleted file mode 100644 index e68610f537..0000000000 --- a/engines/zvision/scripting/controls/timer_node.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 "common/scummsys.h" - -#include "zvision/scripting/controls/timer_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" - -#include "common/stream.h" - - -namespace ZVision { - -TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) - : SideFX(engine, key, SIDEFX_TIMER) { - if (_engine->getGameId() == GID_NEMESIS) - _timeLeft = timeInSeconds * 1000; - else if (_engine->getGameId() == GID_GRANDINQUISITOR) - _timeLeft = timeInSeconds * 100; - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); -} - -TimerNode::~TimerNode() { - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); - if (timeLeft > 0) - _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill -} - -bool TimerNode::process(uint32 deltaTimeInMillis) { - _timeLeft -= deltaTimeInMillis; - - if (_timeLeft <= 0) - return stop(); - - return false; -} - -bool TimerNode::stop() { - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - return true; -} - -void TimerNode::serialize(Common::WriteStream *stream) { - stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); - stream->writeUint32LE(8); // size - stream->writeUint32LE(_key); - stream->writeUint32LE(_timeLeft); -} - -void TimerNode::deserialize(Common::SeekableReadStream *stream) { - _timeLeft = stream->readUint32LE(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/timer_node.h b/engines/zvision/scripting/controls/timer_node.h deleted file mode 100644 index f6584becda..0000000000 --- a/engines/zvision/scripting/controls/timer_node.h +++ /dev/null @@ -1,59 +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 ZVISION_TIMER_NODE_H -#define ZVISION_TIMER_NODE_H - -#include "zvision/sidefx.h" - -namespace ZVision { - -class ZVision; - -class TimerNode : public SideFX { -public: - TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); - ~TimerNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - void serialize(Common::WriteStream *stream); - void deserialize(Common::SeekableReadStream *stream); - inline bool needsSerialization() { - return true; - } - - bool stop(); - -private: - int32 _timeLeft; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp new file mode 100644 index 0000000000..f8b22970c4 --- /dev/null +++ b/engines/zvision/scripting/inventory.cpp @@ -0,0 +1,123 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/script_manager.h" + + +namespace ZVision { + +int8 ScriptManager::invertory_getCount() { + return getStateValue(StateKey_Inv_Cnt_Slot); +} + +void ScriptManager::invertory_setCount(int8 cnt) { + setStateValue(StateKey_Inv_Cnt_Slot, cnt); +} + +int16 ScriptManager::invertory_getItem(int8 id) { + if (id < 49 && id >= 0) + return getStateValue(StateKey_Inv_1_Slot + id); + return -1; +} + +void ScriptManager::invertory_setItem(int8 id, int16 item) { + if (id < 49 && id >= 0) + setStateValue(StateKey_Inv_1_Slot + id, item); +} + +void ScriptManager::invertory_add(int16 item) { + int8 cnt = invertory_getCount(); + + if (cnt < 49) { + bool not_exist = true; + + if (cnt == 0) { + invertory_setItem(0, 0); + invertory_setCount(1); // we needed empty item for cycle code + cnt = 1; + } + + for (int8 cur = 0; cur < cnt; cur++) + if (invertory_getItem(cur) == item) { + not_exist = false; + break; + } + + if (not_exist) { + for (int8 i = cnt; i > 0; i--) + invertory_setItem(i, invertory_getItem(i - 1)); + + invertory_setItem(0, item); + + setStateValue(StateKey_InventoryItem, item); + + invertory_setCount(cnt + 1); + } + } +} + +void ScriptManager::invertory_drop(int16 item) { + int8 items_cnt = invertory_getCount(); + + // if items in inventory > 0 + if (items_cnt != 0) { + int8 index = 0; + + // finding needed item + while (index < items_cnt) { + if (invertory_getItem(index) == item) + break; + + index++; + } + + // if item in the inventory + if (items_cnt != index) { + // shift all items left with rewrite founded item + for (int8 v = index; v < items_cnt - 1 ; v++) + invertory_setItem(v, invertory_getItem(v + 1)); + + // del last item + invertory_setItem(items_cnt - 1, 0); + invertory_setCount(invertory_getCount() - 1); + + setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + } + } +} +void ScriptManager::invertory_cycle() { + int8 item_cnt = invertory_getCount(); + int8 cur_item = invertory_getItem(0); + if (item_cnt > 1) { + for (int8 i = 0; i < item_cnt - 1; i++) + invertory_setItem(i, invertory_getItem(i + 1)); + + invertory_setItem(item_cnt - 1, cur_item); + + setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index fff187d369..5d697bd841 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -30,7 +30,7 @@ #include "zvision/scripting/actions.h" #include "zvision/scripting/controls/push_toggle_control.h" #include "zvision/scripting/controls/lever_control.h" -#include "zvision/slot_control.h" +#include "zvision/scripting/controls/slot_control.h" #include "common/textconsole.h" #include "common/file.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 9713a34733..a27ae4dbf0 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -30,7 +30,7 @@ #include "zvision/core/save_manager.h" #include "zvision/scripting/actions.h" #include "zvision/utility/utility.h" -#include "zvision/scripting/controls/timer_node.h" +#include "zvision/scripting/sidefx/timer_node.h" #include "common/algorithm.h" #include "common/hashmap.h" diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index a835c13951..8ec364b35f 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -25,7 +25,7 @@ #include "zvision/scripting/puzzle.h" #include "zvision/scripting/control.h" -#include "zvision/sidefx.h" +#include "zvision/scripting/sidefx.h" #include "common/hashmap.h" #include "common/queue.h" diff --git a/engines/zvision/scripting/sidefx.cpp b/engines/zvision/scripting/sidefx.cpp new file mode 100644 index 0000000000..c0b8a4d12f --- /dev/null +++ b/engines/zvision/scripting/sidefx.cpp @@ -0,0 +1,36 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" + +namespace ZVision { + + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h new file mode 100644 index 0000000000..2c53467559 --- /dev/null +++ b/engines/zvision/scripting/sidefx.h @@ -0,0 +1,124 @@ +/* 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 SIDEFX_H_INCLUDED +#define SIDEFX_H_INCLUDED + +namespace Common { +class SeekableReadStream; +struct Point; +class WriteStream; +} + +namespace ZVision { + +class ZVision; + +class SideFX { +public: + + enum SideFXType { + SIDEFX_ANIM = 1, + SIDEFX_AUDIO = 2, + SIDEFX_DISTORT = 4, + SIDEFX_PANTRACK = 8, + SIDEFX_REGION = 16, + SIDEFX_TIMER = 32, + SIDEFX_TTYTXT = 64, + SIDEFX_UNK = 128, + SIDEFX_ALL = 255 + }; + + SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} + SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {} + virtual ~SideFX() {} + + uint32 getKey() { + return _key; + } + SideFXType getType() { + return _type; + } + + virtual bool process(uint32 deltaTimeInMillis) { + return false; + } + /** + * Serialize a SideFX for save game use. This should only be used if a SideFX needs + * to save values that would be different from initialization. AKA a TimerNode needs to + * store the amount of time left on the timer. Any Controls overriding this *MUST* write + * their key as the first data outputted. The default implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override deserialize() + * and needsSerialization() + * + * @param stream Stream to write any needed data to + */ + virtual void serialize(Common::WriteStream *stream) {} + /** + * De-serialize data from a save game stream. This should only be implemented if the + * SideFX also implements serialize(). The calling method assumes the size of the + * data read from the stream exactly equals that written in serialize(). The default + * implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override serialize() + * and needsSerialization() + * + * @param stream Save game file stream + */ + virtual void deserialize(Common::SeekableReadStream *stream) {} + /** + * If a SideFX overrides serialize() and deserialize(), this should return true + * + * @return Does the SideFX need save game serialization? + */ + virtual inline bool needsSerialization() { + return false; + } + + virtual bool stop() { + return true; + } + virtual void kill() {} + +protected: + ZVision *_engine; + uint32 _key; + SideFXType _type; + +// Static member functions +public: + +}; + +// TODO: Implement InputControl +// TODO: Implement SaveControl +// TODO: Implement SlotControl +// TODO: Implement SafeControl +// TODO: Implement FistControl +// TODO: Implement HotMovieControl +// TODO: Implement PaintControl +// TODO: Implement TilterControl + +} // End of namespace ZVision + +#endif // SIDEFX_H_INCLUDED diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp new file mode 100644 index 0000000000..4a606adc9e --- /dev/null +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -0,0 +1,211 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/animation_node.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/animation/meta_animation.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) + : SideFX(engine, controlKey, SIDEFX_ANIM), + _DisposeAfterUse(DisposeAfterUse), + _mask(mask), + _animation(NULL) { + + if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { + _animation = new MetaAnimation(fileName, engine); + _frmDelay = _animation->frameTime(); + } else { + warning("Unrecognized animation file type: %s", fileName.c_str()); + } + + if (frate > 0) + _frmDelay = 1000.0 / frate; +} + +AnimationNode::~AnimationNode() { + if (_animation) + delete _animation; + + _engine->getScriptManager()->setStateValue(_key, 2); + + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + _engine->getScriptManager()->setStateValue((*it).slot, 2); + + if ((*it)._scaled) + delete(*it)._scaled; + } + + _playList.clear(); +} + +bool AnimationNode::process(uint32 deltaTimeInMillis) { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + + nod->_delay -= deltaTimeInMillis; + if (nod->_delay <= 0) { + nod->_delay += _frmDelay; + + const Graphics::Surface *frame = NULL; + + if (nod->_cur_frm == -1) { // Start of new playlist node + nod->_cur_frm = nod->start; + + _animation->seekToFrame(nod->_cur_frm); + frame = _animation->decodeNextFrame(); + + nod->_delay = _frmDelay; + if (nod->slot) + _engine->getScriptManager()->setStateValue(nod->slot, 1); + } else { + nod->_cur_frm++; + + if (nod->_cur_frm > nod->stop) { + nod->loop--; + + if (nod->loop == 0) { + if (nod->slot >= 0) + _engine->getScriptManager()->setStateValue(nod->slot, 2); + if (nod->_scaled) + delete nod->_scaled; + _playList.erase(it); + return _DisposeAfterUse; + } + + nod->_cur_frm = nod->start; + _animation->seekToFrame(nod->_cur_frm); + } + + frame = _animation->decodeNextFrame(); + } + + if (frame) { + + uint32 dstw; + uint32 dsth; + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + dstw = nod->pos.height(); + dsth = nod->pos.width(); + } else { + dstw = nod->pos.width(); + dsth = nod->pos.height(); + } + + if (frame->w != dstw || frame->h != dsth) { + if (nod->_scaled) + if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { + delete nod->_scaled; + nod->_scaled = NULL; + } + + if (!nod->_scaled) { + nod->_scaled = new Graphics::Surface; + nod->_scaled->create(dstw, dsth, frame->format); + } + + _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); + frame = nod->_scaled; + } + + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); + if (_mask > 0) + _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); + delete transposed; + } else { + if (_mask > 0) + _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); + else + _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top); + } + } + } + } + + return false; +} + + + +void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) { + playnode nod; + nod.loop = loops; + nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); + nod.start = start_frame; + nod.stop = end_frame; + + if (nod.stop >= (int)_animation->frameCount()) + nod.stop = _animation->frameCount() - 1; + + nod.slot = slot; + nod._cur_frm = -1; + nod._delay = 0; + nod._scaled = NULL; + _playList.push_back(nod); +} + +bool AnimationNode::stop() { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) + delete(*it)._scaled; + } + + _playList.clear(); + + // We don't need to delete, it's may be reused + return false; +} + +void AnimationNode::setNewFrameDelay(int32 newDelay) { + if (newDelay > 0) { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + float percent = (float)nod->_delay / (float)_frmDelay; + nod->_delay = percent * newDelay; // Scale to new max + } + + _frmDelay = newDelay; + } +} + +int32 AnimationNode::getFrameDelay() { + return _frmDelay; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h new file mode 100644 index 0000000000..4d1c74bccf --- /dev/null +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -0,0 +1,84 @@ +/* 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 ZVISION_ANIMATION_NODE_H +#define ZVISION_ANIMATION_NODE_H + +#include "zvision/scripting/sidefx.h" +#include "common/rect.h" +#include "common/list.h" + + +namespace Common { +class String; +} + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; +class MetaAnimation; + +class AnimationNode : public SideFX { +public: + AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); + ~AnimationNode(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 stop; + int32 loop; + int32 _cur_frm; + int32 _delay; + Graphics::Surface *_scaled; + }; + +private: + typedef Common::List PlayNodes; + + PlayNodes _playList; + + int32 _mask; + bool _DisposeAfterUse; + + MetaAnimation *_animation; + int32 _frmDelay; + +public: + bool process(uint32 deltaTimeInMillis); + + void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); + + bool stop(); + + void setNewFrameDelay(int32 newDelay); + int32 getFrameDelay(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp new file mode 100644 index 0000000000..0351867dd9 --- /dev/null +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -0,0 +1,190 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/music_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + + +namespace ZVision { + +MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) + : SideFX(engine, key, SIDEFX_AUDIO) { + _loop = loop; + _volume = volume; + _crossfade = false; + _crossfade_target = 0; + _crossfade_time = 0; + _attenuate = 0; + _pantrack = false; + _pantrack_X = 0; + _sub = NULL; + + Audio::RewindableAudioStream *audioStream; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (_engine->getSearchManager()->openFile(*file, filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + _stereo = audioStream->isStereo(); + + if (_loop) { + Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); + } else { + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); + } + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); + + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); +} + +MusicNode::~MusicNode() { + _engine->_mixer->stopHandle(_handle); + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + if (_sub) + delete _sub; + debug(1, "MusicNode: %d destroyed\n", _key); +} + +void MusicNode::setPanTrack(int16 pos) { + if (!_stereo) { + _pantrack = true; + _pantrack_X = pos; + setVolume(_volume); + } +} + +void MusicNode::unsetPanTrack() { + _pantrack = false; + setVolume(_volume); +} + +void MusicNode::setFade(int32 time, uint8 target) { + _crossfade_target = target; + _crossfade_time = time; + _crossfade = true; +} + +bool MusicNode::process(uint32 deltaTimeInMillis) { + if (! _engine->_mixer->isSoundHandleActive(_handle)) + return stop(); + else { + uint8 _newvol = _volume; + + if (_crossfade) { + if (_crossfade_time > 0) { + if ((int32)deltaTimeInMillis > _crossfade_time) + deltaTimeInMillis = _crossfade_time; + _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; + _crossfade_time -= deltaTimeInMillis; + } else { + _crossfade = false; + _newvol = _crossfade_target; + } + } + + if (_pantrack || _volume != _newvol) + setVolume(_newvol); + + if (_sub) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); + } + return false; +} + +void MusicNode::setVolume(uint8 new_volume) { + if (_pantrack) { + int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + cur_x -= _pantrack_X; + int32 _width = _engine->getRenderManager()->getBkgSize().x; + if (cur_x < (-_width) / 2) + cur_x += _width; + else if (cur_x >= _width / 2) + cur_x -= _width; + + float norm = (float)cur_x / ((float)_width / 2.0); + float lvl = fabs(norm); + if (lvl > 0.5) + lvl = (lvl - 0.5) * 1.7; + else + lvl = 1.0; + + float bal = sin(-norm * 3.1415926) * 127.0; + + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, bal); + _engine->_mixer->setChannelVolume(_handle, new_volume * lvl); + } + } else { + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, 0); + _engine->_mixer->setChannelVolume(_handle, new_volume); + } + } + + _volume = new_volume; +} + +PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) + : SideFX(engine, key, SIDEFX_PANTRACK) { + _slot = slot; + + SideFX *fx = _engine->getScriptManager()->getSideFX(slot); + if (fx && fx->getType() == SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + mus->setPanTrack(pos); + } +} + +PanTrackNode::~PanTrackNode() { + SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); + if (fx && fx->getType() == SIDEFX_AUDIO) { + MusicNode *mus = (MusicNode *)fx; + mus->unsetPanTrack(); + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h new file mode 100644 index 0000000000..066b8f80f4 --- /dev/null +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -0,0 +1,82 @@ +/* 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 ZVISION_MUSIC_NODE_H +#define ZVISION_MUSIC_NODE_H + +#include "audio/mixer.h" +#include "zvision/scripting/sidefx.h" +#include "zvision/subtitles/subtitles.h" + +namespace Common { +class String; +} + +namespace ZVision { +class MusicNode : public SideFX { +public: + MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); + ~MusicNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + + void setVolume(uint8 volume); + + void setPanTrack(int16 pos); + void unsetPanTrack(); + + void setFade(int32 time, uint8 target); + +private: + int32 _timeLeft; + bool _pantrack; + int32 _pantrack_X; + int32 _attenuate; + uint8 _volume; + bool _loop; + bool _crossfade; + uint8 _crossfade_target; + int32 _crossfade_time; + bool _stereo; + Audio::SoundHandle _handle; + Subtitle *_sub; +}; + +class PanTrackNode : public SideFX { +public: + PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); + ~PanTrackNode(); + +private: + uint32 _slot; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp new file mode 100644 index 0000000000..2bfdc349d1 --- /dev/null +++ b/engines/zvision/scripting/sidefx/syncsound_node.cpp @@ -0,0 +1,86 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/syncsound_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + + +namespace ZVision { + +SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) + : SideFX(engine, key, SIDEFX_AUDIO) { + _syncto = syncto; + _sub = NULL; + + Audio::RewindableAudioStream *audioStream; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (_engine->getSearchManager()->openFile(*file, filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream); + + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); +} + +SyncSoundNode::~SyncSoundNode() { + _engine->_mixer->stopHandle(_handle); + if (_sub) + delete _sub; +} + +bool SyncSoundNode::process(uint32 deltaTimeInMillis) { + if (! _engine->_mixer->isSoundHandleActive(_handle)) + return stop(); + else { + + if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) + return stop(); + + if (_sub) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); + } + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h new file mode 100644 index 0000000000..c16ffebe7f --- /dev/null +++ b/engines/zvision/scripting/sidefx/syncsound_node.h @@ -0,0 +1,56 @@ +/* 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 ZVISION_SYNCSOUND_NODE_H +#define ZVISION_SYNCSOUND_NODE_H + +#include "audio/mixer.h" +#include "zvision/scripting/sidefx.h" +#include "zvision/subtitles/subtitles.h" + +namespace Common { +class String; +} + +namespace ZVision { +class SyncSoundNode : public SideFX { +public: + SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto); + ~SyncSoundNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + int32 _syncto; + Audio::SoundHandle _handle; + Subtitle *_sub; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp new file mode 100644 index 0000000000..6e71101acd --- /dev/null +++ b/engines/zvision/scripting/sidefx/timer_node.cpp @@ -0,0 +1,80 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/timer_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" + +#include "common/stream.h" + + +namespace ZVision { + +TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) + : SideFX(engine, key, SIDEFX_TIMER) { + if (_engine->getGameId() == GID_NEMESIS) + _timeLeft = timeInSeconds * 1000; + else if (_engine->getGameId() == GID_GRANDINQUISITOR) + _timeLeft = timeInSeconds * 100; + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +TimerNode::~TimerNode() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); + if (timeLeft > 0) + _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill +} + +bool TimerNode::process(uint32 deltaTimeInMillis) { + _timeLeft -= deltaTimeInMillis; + + if (_timeLeft <= 0) + return stop(); + + return false; +} + +bool TimerNode::stop() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + return true; +} + +void TimerNode::serialize(Common::WriteStream *stream) { + stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); + stream->writeUint32LE(8); // size + stream->writeUint32LE(_key); + stream->writeUint32LE(_timeLeft); +} + +void TimerNode::deserialize(Common::SeekableReadStream *stream) { + _timeLeft = stream->readUint32LE(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/timer_node.h b/engines/zvision/scripting/sidefx/timer_node.h new file mode 100644 index 0000000000..7a26aff251 --- /dev/null +++ b/engines/zvision/scripting/sidefx/timer_node.h @@ -0,0 +1,59 @@ +/* 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 ZVISION_TIMER_NODE_H +#define ZVISION_TIMER_NODE_H + +#include "zvision/scripting/sidefx.h" + +namespace ZVision { + +class ZVision; + +class TimerNode : public SideFX { +public: + TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); + ~TimerNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + void serialize(Common::WriteStream *stream); + void deserialize(Common::SeekableReadStream *stream); + inline bool needsSerialization() { + return true; + } + + bool stop(); + +private: + int32 _timeLeft; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp new file mode 100644 index 0000000000..68636eb422 --- /dev/null +++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp @@ -0,0 +1,175 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/ttytext_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/text/text.h" + +#include "common/stream.h" +#include "common/file.h" + + +namespace ZVision { + +ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : + SideFX(engine, key, SIDEFX_TTYTXT), + _fnt(engine) { + _delay = delay; + _r = r; + _txtpos = 0; + _nexttime = 0; + _dx = 0; + _dy = 0; + + Common::File *infile = _engine->getSearchManager()->openFile(file); + if (infile) { + while (!infile->eos()) { + Common::String asciiLine = readWideLine(*infile); + if (asciiLine.empty()) { + continue; + } + _txtbuf += asciiLine; + } + + delete infile; + } + _img.create(_r.width(), _r.height(), _engine->_pixelFormat); + _style.sharp = true; + _style.readAllStyle(_txtbuf); + _style.setFont(_fnt); + _engine->getScriptManager()->setStateValue(_key, 1); +} + +ttyTextNode::~ttyTextNode() { + _engine->getScriptManager()->setStateValue(_key, 2); + _img.free(); +} + +bool ttyTextNode::process(uint32 deltaTimeInMillis) { + _nexttime -= deltaTimeInMillis; + + if (_nexttime < 0) { + if (_txtpos < _txtbuf.size()) { + if (_txtbuf[_txtpos] == '<') { + int32 strt = _txtpos; + int32 endt = 0; + int16 ret = 0; + while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) + _txtpos++; + endt = _txtpos; + if (strt != -1) + if ((endt - strt - 1) > 0) + ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); + + if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { + if (ret & TXT_RET_FNTCHG) + _style.setFont(_fnt); + if (ret & TXT_RET_FNTSTL) + _style.setFontStyle(_fnt); + + if (ret & TXT_RET_NEWLN) + newline(); + } + + if (ret & TXT_RET_HASSTBOX) { + Common::String buf; + buf.format("%d", _style.statebox); + + for (uint8 j = 0; j < buf.size(); j++) + outchar(buf[j]); + } + + _txtpos++; + } else { + int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]); + + uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + if (chr == ' ') { + uint32 i = _txtpos + charsz; + uint16 width = _fnt.getCharWidth(chr); + + while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') { + + int8 chsz = getUtf8CharSize(_txtbuf[i]); + uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + width += _fnt.getCharWidth(uchr); + + i += chsz; + } + + if (_dx + width > _r.width()) + newline(); + else + outchar(chr); + } else + outchar(chr); + + _txtpos += charsz; + } + _nexttime = _delay; + _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top); + } else + return stop(); + } + + return false; +} + +void ttyTextNode::scroll() { + int32 scrl = 0; + while (_dy - scrl > _r.height() - _fnt.getFontHeight()) + scrl += _fnt.getFontHeight(); + int8 *pixels = (int8 *)_img.getPixels(); + for (uint16 h = scrl; h < _img.h; h++) + memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch); + + _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0); + _dy -= scrl; +} + +void ttyTextNode::newline() { + _dy += _fnt.getFontHeight(); + _dx = 0; +} + +void ttyTextNode::outchar(uint16 chr) { + uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue); + + if (_dx + _fnt.getCharWidth(chr) > _r.width()) + newline(); + + if (_dy + _fnt.getFontHeight() >= _r.height()) + scroll(); + + _fnt.drawChar(&_img, chr, _dx, _dy, clr); + + _dx += _fnt.getCharWidth(chr); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h new file mode 100644 index 0000000000..a6326c733b --- /dev/null +++ b/engines/zvision/scripting/sidefx/ttytext_node.h @@ -0,0 +1,76 @@ +/* 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 ZVISION_TTYTEXT_NODE_H +#define ZVISION_TTYTEXT_NODE_H + +#include "common/rect.h" +#include "graphics/surface.h" + +#include "zvision/scripting/sidefx.h" +#include "zvision/text/text.h" +#include "zvision/fonts/truetype_font.h" + +namespace Common { +class String; +} + +namespace ZVision { +class ttyTextNode : public SideFX { +public: + ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay); + ~ttyTextNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + Common::Rect _r; + //int16 x; + //int16 y; + //uint16 w; + //uint16 h; + cTxtStyle _style; + sTTFont _fnt; + Common::String _txtbuf; + uint32 _txtpos; + //int32 txtsize; + int32 _delay; + int32 _nexttime; + Graphics::Surface _img; + int16 _dx; + int16 _dy; +private: + + void newline(); + void scroll(); + void outchar(uint16 chr); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/search_manager.cpp b/engines/zvision/search_manager.cpp deleted file mode 100644 index db120f2a4b..0000000000 --- a/engines/zvision/search_manager.cpp +++ /dev/null @@ -1,274 +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 "common/debug.h" - -#include "zvision/search_manager.h" -#include "zvision/archives/zfs_archive.h" -#include "common/fs.h" -#include "common/stream.h" - - -namespace ZVision { - -sManager::sManager(const Common::String &root_path, int depth) { - _root = root_path; - if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') - _root.deleteLastChar(); - - Common::FSNode fs_node(_root); - - list_dir_recursive(dir_list, fs_node, depth); - - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) - if (it->size() == _root.size()) - it = dir_list.erase(it); - else if (it->size() > _root.size()) { - *it = Common::String(it->c_str() + _root.size() + 1); - it++; - } else - it++; -} - -sManager::~sManager() { - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { - delete *it; - it++; - } - - archList.clear(); -} - -void sManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lw_name = dst; - lw_name.toLowercase(); - - sManager::MatchList::iterator it = files.find(lw_name); - - if (it != files.end()) { - lw_name = src; - lw_name.toLowercase(); - files[lw_name] = it->_value; - } -} - -void sManager::addFile(const Common::String &name, Common::Archive *arch) { - bool addArch = true; - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { - if (*it == arch) { - addArch = false; - break; - } - it++; - } - if (addArch) - archList.push_back(arch); - - Common::String lw_name = name; - lw_name.toLowercase(); - - sManager::Node nod; - nod.name = lw_name; - nod.arch = arch; - - sManager::MatchList::iterator fit = files.find(lw_name); - - if (fit == files.end()) { - files[lw_name] = nod; - } else { - Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); - if (stream) { - if (stream->size() < 10) - fit->_value.arch = arch; - delete stream; - } else { - files[lw_name] = nod; - } - } -} - -Common::File *sManager::openFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); - - sManager::MatchList::iterator fit = files.find(lw_name); - - if (fit != files.end()) { - Common::File *tmp = new Common::File(); - tmp->open(fit->_value.name, *fit->_value.arch); - return tmp; - } - return NULL; -} - -bool sManager::openFile(Common::File &file, const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); - - sManager::MatchList::iterator fit = files.find(lw_name); - - if (fit != files.end()) - return file.open(fit->_value.name, *fit->_value.arch); - return false; -} - -bool sManager::hasFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); - - sManager::MatchList::iterator fit = files.find(lw_name); - - if (fit != files.end()) - return true; - return false; -} - -void sManager::loadZix(const Common::String &name) { - Common::File file; - file.open(name); - - Common::String line; - - while (!file.eos()) { - line = file.readLine(); - if (line.matchString("----------*", true)) - break; - } - - if (file.eos()) - return; - - Common::Array archives; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - if (line.matchString("----------*", true)) - break; - else if (line.matchString("DIR:*", true)) { - Common::String path(line.c_str() + 5); - Common::Archive *arc; - char n_path[128]; - strcpy(n_path, path.c_str()); - for (uint i = 0; i < path.size(); i++) - if (n_path[i] == '\\') - n_path[i] = '/'; - - path = Common::String(n_path); - if (path.size() && path[0] == '.') - path.deleteChar(0); - if (path.size() && path[0] == '/') - path.deleteChar(0); - - if (path.matchString("*.zfs", true)) - arc = new ZfsArchive(path); - else { - if (path.size()) { - if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') - path.deleteLastChar(); - if (path.size()) - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) - if (path.equalsIgnoreCase(*it)) { - path = *it; - break; - } - } - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - arc = new Common::FSDirectory(path); - } - archives.push_back(arc); - } - } - - if (file.eos()) - return; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - uint dr = 0; - char buf[32]; - if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { - if (dr <= archives.size() && dr > 0) { - addFile(Common::String(buf), archives[dr - 1]); - } - } - } -} - -void sManager::addDir(const Common::String &name) { - Common::String path; - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) - if (name.equalsIgnoreCase(*it)) { - path = *it; - break; - } - - if (path.size() == 0) - return; - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - Common::FSDirectory *dir = new Common::FSDirectory(path); - - Common::ArchiveMemberList list; - dir->listMatchingMembers(list, "*.zfs"); - - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - - ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); - - Common::ArchiveMemberList zfslist; - zfs->listMembers(zfslist); - - for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { - Common::String z_name = (*ziter)->getName(); - addFile(z_name, zfs); - } - } - - list.clear(); - dir->listMembers(list); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - addFile(flname, dir); - } -} - -void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { - Common::FSList fs_list; - fs_node.getChildren(fs_list); - - _list.push_back(fs_node.getPath()); - - if (depth > 1) - for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) - list_dir_recursive(_list, *it, depth - 1); -} - -} // End of namespace ZVision diff --git a/engines/zvision/search_manager.h b/engines/zvision/search_manager.h deleted file mode 100644 index c768cb8b00..0000000000 --- a/engines/zvision/search_manager.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SEARCH_MANAGER_H_INCLUDED -#define SEARCH_MANAGER_H_INCLUDED - -#include "common/str.h" -#include "common/hash-str.h" -#include "common/hashmap.h" -#include "common/archive.h" -#include "common/file.h" -#include "common/list.h" - -namespace ZVision { - -class sManager { -public: - sManager(const Common::String &root_path, int depth); - ~sManager(); - - void addFile(const Common::String &name, Common::Archive *arch); - void addDir(const Common::String &name); - void addPatch(const Common::String &src, const Common::String &dst); - - Common::File *openFile(const Common::String &name); - bool openFile(Common::File &file, const Common::String &name); - bool hasFile(const Common::String &name); - - void loadZix(const Common::String &name); - -private: - - void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); - - struct Node { - Common::String name; - Common::Archive *arch; - }; - - Common::List dir_list; - - typedef Common::HashMap MatchList; - - Common::List archList; - MatchList files; - - Common::String _root; - -private: -}; - -} - -#endif // SEARCH_MANAGER_H_INCLUDED diff --git a/engines/zvision/sidefx.cpp b/engines/zvision/sidefx.cpp deleted file mode 100644 index 7ba1959db7..0000000000 --- a/engines/zvision/sidefx.cpp +++ /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. - * - */ - -#include "common/scummsys.h" - -#include "zvision/sidefx.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" - -#include "common/stream.h" - -namespace ZVision { - - -} // End of namespace ZVision diff --git a/engines/zvision/sidefx.h b/engines/zvision/sidefx.h deleted file mode 100644 index 2c53467559..0000000000 --- a/engines/zvision/sidefx.h +++ /dev/null @@ -1,124 +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 SIDEFX_H_INCLUDED -#define SIDEFX_H_INCLUDED - -namespace Common { -class SeekableReadStream; -struct Point; -class WriteStream; -} - -namespace ZVision { - -class ZVision; - -class SideFX { -public: - - enum SideFXType { - SIDEFX_ANIM = 1, - SIDEFX_AUDIO = 2, - SIDEFX_DISTORT = 4, - SIDEFX_PANTRACK = 8, - SIDEFX_REGION = 16, - SIDEFX_TIMER = 32, - SIDEFX_TTYTXT = 64, - SIDEFX_UNK = 128, - SIDEFX_ALL = 255 - }; - - SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} - SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {} - virtual ~SideFX() {} - - uint32 getKey() { - return _key; - } - SideFXType getType() { - return _type; - } - - virtual bool process(uint32 deltaTimeInMillis) { - return false; - } - /** - * Serialize a SideFX for save game use. This should only be used if a SideFX needs - * to save values that would be different from initialization. AKA a TimerNode needs to - * store the amount of time left on the timer. Any Controls overriding this *MUST* write - * their key as the first data outputted. The default implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override deserialize() - * and needsSerialization() - * - * @param stream Stream to write any needed data to - */ - virtual void serialize(Common::WriteStream *stream) {} - /** - * De-serialize data from a save game stream. This should only be implemented if the - * SideFX also implements serialize(). The calling method assumes the size of the - * data read from the stream exactly equals that written in serialize(). The default - * implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override serialize() - * and needsSerialization() - * - * @param stream Save game file stream - */ - virtual void deserialize(Common::SeekableReadStream *stream) {} - /** - * If a SideFX overrides serialize() and deserialize(), this should return true - * - * @return Does the SideFX need save game serialization? - */ - virtual inline bool needsSerialization() { - return false; - } - - virtual bool stop() { - return true; - } - virtual void kill() {} - -protected: - ZVision *_engine; - uint32 _key; - SideFXType _type; - -// Static member functions -public: - -}; - -// TODO: Implement InputControl -// TODO: Implement SaveControl -// TODO: Implement SlotControl -// TODO: Implement SafeControl -// TODO: Implement FistControl -// TODO: Implement HotMovieControl -// TODO: Implement PaintControl -// TODO: Implement TilterControl - -} // End of namespace ZVision - -#endif // SIDEFX_H_INCLUDED diff --git a/engines/zvision/slot_control.cpp b/engines/zvision/slot_control.cpp deleted file mode 100644 index d3d9c2ec4b..0000000000 --- a/engines/zvision/slot_control.cpp +++ /dev/null @@ -1,219 +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 "common/scummsys.h" - -#include "zvision/slot_control.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/cursors/cursor_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" - -#include "common/stream.h" - - -namespace ZVision { - -SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key) { - - _rendered_item = 0; - _bkg = NULL; - - // Loop until we find the closing brace - Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); - Common::String param; - Common::String values; - getParams(line, param, values); - - while (!stream.eos() && !line.contains('}')) { - if (param.matchString("hotspot", true)) { - int x; - int y; - int width; - int height; - - sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); - - _hotspot = Common::Rect(x, y, width, height); - } else if (param.matchString("rectangle", true)) { - int x; - int y; - int width; - int height; - - sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); - - _rectangle = Common::Rect(x, y, width, height); - } else if (param.matchString("cursor", true)) { - _cursor = _engine->getCursorManager()->getCursorId(values); - } else if (param.matchString("distance_id", true)) { - sscanf(values.c_str(), "%c", &_distance_id); - } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); - } else if (param.matchString("eligible_objects", true)) { - char buf[256]; - memset(buf, 0, 256); - strcpy(buf, values.c_str()); - - char *curpos = buf; - char *strend = buf + strlen(buf); - while (true) { - char *st = curpos; - - if (st >= strend) - break; - - while (*curpos != ' ' && curpos < strend) - curpos++; - - *curpos = 0; - curpos++; - - int obj = atoi(st); - - _eligible_objects.push_back(obj); - } - } - - line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); - getParams(line, param, values); - } - - if (_hotspot.isEmpty() || _rectangle.isEmpty()) { - warning("Slot %u was parsed incorrectly", key); - } -} - -SlotControl::~SlotControl() { - // Clear the state value back to 0 - //_engine->getScriptManager()->setStateValue(_key, 0); - - if (_bkg) - delete _bkg; -} - -bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return false; - - if (_hotspot.contains(backgroundImageSpacePos)) { - //ctrl_setvenus(ct); - - int item = _engine->getScriptManager()->getStateValue(_key); - int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (item != 0) { - if (mouse_item != 0) { - if (eligeblity(mouse_item)) { - _engine->getScriptManager()->invertory_drop(mouse_item); - _engine->getScriptManager()->invertory_add(item); - _engine->getScriptManager()->setStateValue(_key, mouse_item); - } - } else { - _engine->getScriptManager()->invertory_add(item); - _engine->getScriptManager()->setStateValue(_key, 0); - } - } else if (mouse_item == 0) { - if (eligeblity(0)) { - _engine->getScriptManager()->invertory_drop(0); - _engine->getScriptManager()->setStateValue(_key, 0); - } - } else if (eligeblity(mouse_item)) { - _engine->getScriptManager()->setStateValue(_key, mouse_item); - _engine->getScriptManager()->invertory_drop(mouse_item); - } - } - return false; -} - -bool SlotControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return false; - - if (_hotspot.contains(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_cursor); - return true; - } - - return false; -} - -bool SlotControl::process(uint32 deltaTimeInMillis) { - if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) - return false; - - if (_engine->canRender()) { - int cur_item = _engine->getScriptManager()->getStateValue(_key); - if (cur_item != _rendered_item) { - if (_rendered_item != 0 && cur_item == 0) { - _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); - _rendered_item = cur_item; - } else { - if (_rendered_item == 0) { - if (_bkg) - delete _bkg; - - _bkg = _engine->getRenderManager()->getBkgRect(_rectangle); - } else { - _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); - } - - char buf[16]; - if (_engine->getGameId() == GID_NEMESIS) - sprintf(buf, "%d%cobj.tga", cur_item, _distance_id); - else - sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item); - - Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf); - - int16 drawx = _rectangle.left; - int16 drawy = _rectangle.top; - - if (_rectangle.width() > srf->w) - drawx = _rectangle.left + (_rectangle.width() - srf->w) / 2; - - if (_rectangle.height() > srf->h) - drawy = _rectangle.top + (_rectangle.height() - srf->h) / 2; - - _engine->getRenderManager()->blitSurfaceToBkg(*srf, drawx, drawy, 0); - - delete srf; - - _rendered_item = cur_item; - } - } - } - return false; -} - -bool SlotControl::eligeblity(int item_id) { - for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) - if (*it == item_id) - return true; - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/slot_control.h b/engines/zvision/slot_control.h deleted file mode 100644 index 0ac8ec9ce0..0000000000 --- a/engines/zvision/slot_control.h +++ /dev/null @@ -1,86 +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 ZVISION_SLOT_CONTROL_H -#define ZVISION_SLOT_CONTROL_H - -#include "zvision/scripting/control.h" - -#include "graphics/surface.h" - -#include "common/rect.h" -#include "common/list.h" - - -namespace ZVision { - -class SlotControl : public Control { -public: - SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); - ~SlotControl(); - - /** - * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); - * - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - */ - bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - /** - * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. - * - * @param engine The base engine - * @param screenSpacePos The position of the mouse in screen space - * @param backgroundImageSpacePos The position of the mouse in background image space - * @return Was the cursor changed? - */ - bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - - bool process(uint32 deltaTimeInMillis); - -private: - /** - * The area that will trigger the event - * This is in image space coordinates, NOT screen space - */ - Common::Rect _rectangle; - Common::Rect _hotspot; - - int _cursor; - char _distance_id; - int _venus_id; - - int _rendered_item; - - Common::List _eligible_objects; - - bool eligeblity(int item_id); - - Graphics::Surface *_bkg; - - /** The cursor to use when hovering over _hotspot */ - Common::String _hoverCursor; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/strings/string_manager.cpp b/engines/zvision/strings/string_manager.cpp deleted file mode 100644 index 22331d8a24..0000000000 --- a/engines/zvision/strings/string_manager.cpp +++ /dev/null @@ -1,255 +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 "common/scummsys.h" - -#include "zvision/strings/string_manager.h" - -#include "zvision/fonts/truetype_font.h" - -#include "common/file.h" -#include "common/tokenizer.h" -#include "common/debug.h" - -#include "graphics/fontman.h" -#include "graphics/colormasks.h" - - -namespace ZVision { - -StringManager::StringManager(ZVision *engine) - : _engine(engine) { -} - -StringManager::~StringManager() { - for (Common::HashMap::iterator iter = _fonts.begin(); iter != _fonts.end(); ++iter) { - delete iter->_value; - } -} - -void StringManager::initialize(ZVisionGameId gameId) { - if (gameId == GID_NEMESIS) { - // TODO: Check this hardcoded filename against all versions of Nemesis - parseStrFile("nemesis.str"); - } else if (gameId == GID_GRANDINQUISITOR) { - // TODO: Check this hardcoded filename against all versions of Grand Inquisitor - parseStrFile("inquis.str"); - } -} - -void StringManager::parseStrFile(const Common::String &fileName) { - Common::File file; - if (!file.open(fileName)) { - warning("%s does not exist. String parsing failed", fileName.c_str()); - return; - } - - uint lineNumber = 0; - while (!file.eos()) { - _lastStyle.align = Graphics::kTextAlignLeft; - _lastStyle.color = 0; - _lastStyle.font = nullptr; - - Common::String asciiLine = readWideLine(file); - if (asciiLine.empty()) { - continue; - } - - char tagString[150]; - uint tagStringCursor = 0; - char textString[150]; - uint textStringCursor = 0; - bool inTag = false; - - for (uint i = 0; i < asciiLine.size(); ++i) { - switch (asciiLine[i]) { - case '<': - inTag = true; - if (!_inGameText[lineNumber].fragments.empty()) { - _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); - textStringCursor = 0; - } - break; - case '>': - inTag = false; - parseTag(Common::String(tagString, tagStringCursor), lineNumber); - tagStringCursor = 0; - break; - default: - if (inTag) { - tagString[tagStringCursor] = asciiLine[i]; - tagStringCursor++; - } else { - textString[textStringCursor] = asciiLine[i]; - textStringCursor++; - } - break; - } - } - - if (textStringCursor > 0) { - _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); - } - - lineNumber++; - assert(lineNumber <= NUM_TEXT_LINES); - } -} - -void StringManager::parseTag(const Common::String &tagString, uint lineNumber) { - Common::StringTokenizer tokenizer(tagString); - - Common::String token = tokenizer.nextToken(); - - Common::String fontName; - bool bold = false; - Graphics::TextAlign align = _lastStyle.align; - int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12; - int red = 0; - int green = 0; - int blue = 0; - - while (!token.empty()) { - if (token.matchString("font", true)) { - fontName = tokenizer.nextToken(); - } else if (token.matchString("bold", true)) { - token = tokenizer.nextToken(); - if (token.matchString("on", false)) { - bold = true; - } - } else if (token.matchString("justify", true)) { - token = tokenizer.nextToken(); - if (token.matchString("center", false)) { - align = Graphics::kTextAlignCenter; - } else if (token.matchString("right", false)) { - align = Graphics::kTextAlignRight; - } - } else if (token.matchString("point", true)) { - point = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("red", true)) { - red = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("green", true)) { - green = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("blue", true)) { - blue = atoi(tokenizer.nextToken().c_str()); - } - - token = tokenizer.nextToken(); - } - - TextFragment fragment; - - if (fontName.empty()) { - fragment.style.font = _lastStyle.font; - } else { - Common::String newFontName; - if (fontName.matchString("*times new roman*", true)) { - if (bold) { - newFontName = "timesbd.ttf"; - } else { - newFontName = "times.ttf"; - } - } else if (fontName.matchString("*courier new*", true)) { - if (bold) { - newFontName = "courbd.ttf"; - } else { - newFontName = "cour.ttf"; - } - } else if (fontName.matchString("*century schoolbook*", true)) { - if (bold) { - newFontName = "censcbkbd.ttf"; - } else { - newFontName = "censcbk.ttf"; - } - } else if (fontName.matchString("*garamond*", true)) { - if (bold) { - newFontName = "garabd.ttf"; - } else { - newFontName = "gara.ttf"; - } - } else { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - if (bold) { - newFontName = "zorknorm.ttf"; - } else { - newFontName = "arial.ttf"; - } - } - - Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point); - if (_fonts.contains(fontKey)) { - fragment.style.font = _fonts[fontKey]; - } else { - fragment.style.font = new TruetypeFont(_engine, point); - fragment.style.font->loadFile(newFontName); - _fonts[fontKey] = fragment.style.font; - } - } - - fragment.style.align = align; - fragment.style.color = Graphics::ARGBToColor >(0, red, green, blue); - _inGameText[lineNumber].fragments.push_back(fragment); - - _lastStyle = fragment.style; -} - -Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { - Common::String asciiString; - - // Don't spam the user with warnings about UTF-16 support. - // Just do one warning per String - bool charOverflowWarning = false; - - uint16 value = stream.readUint16LE(); - while (!stream.eos()) { - // Check for CRLF - if (value == 0x0A0D) { - // Read in the extra NULL char - stream.readByte(); // \0 - // End of the line. Break - break; - } - - // Crush each octet pair to a single octet with a simple cast - if (value > 255) { - charOverflowWarning = true; - value = '?'; - } - char charValue = (char)value; - - asciiString += charValue; - - value = stream.readUint16LE(); - } - - if (charOverflowWarning) { - warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'"); - } - - return asciiString; -} - -StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) { - return _inGameText[stringNumber].fragments.front().style; -} - -} // End of namespace ZVision diff --git a/engines/zvision/strings/string_manager.h b/engines/zvision/strings/string_manager.h deleted file mode 100644 index af8324b890..0000000000 --- a/engines/zvision/strings/string_manager.h +++ /dev/null @@ -1,84 +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 ZVISION_STRING_MANAGER_H -#define ZVISION_STRING_MANAGER_H - -#include "zvision/detection.h" -#include "zvision/fonts/truetype_font.h" - - -namespace Graphics { -class FontManager; -} - -namespace ZVision { - -class ZVision; - -class StringManager { -public: - StringManager(ZVision *engine); - ~StringManager(); - -public: - struct TextStyle { - TruetypeFont *font; - uint16 color; // In RBG 565 - Graphics::TextAlign align; - }; - - struct TextFragment { - TextStyle style; - Common::String text; - }; - -private: - struct InGameText { - Common::List fragments; - }; - - enum { - NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 - }; - -private: - ZVision *_engine; - InGameText _inGameText[NUM_TEXT_LINES]; - Common::HashMap _fonts; - - TextStyle _lastStyle; - -public: - void initialize(ZVisionGameId gameId); - StringManager::TextStyle getTextStyle(uint stringNumber); - -private: - void parseStrFile(const Common::String &fileName); - void parseTag(const Common::String &tagString, uint lineNumber); - - static Common::String readWideLine(Common::SeekableReadStream &stream); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/subtitles.cpp b/engines/zvision/subtitles.cpp deleted file mode 100644 index da9b0fc1c9..0000000000 --- a/engines/zvision/subtitles.cpp +++ /dev/null @@ -1,108 +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 "zvision/subtitles/subtitles.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/search_manager.h" -#include "zvision/text.h" - -namespace ZVision { - -Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : - _engine(engine), - _areaId(-1), - _subId(-1) { - Common::File file; - if (_engine->getSearchManager()->openFile(file, subname)) { - while (!file.eos()) { - Common::String str = file.readLine(); - if (str.lastChar() == '~') - str.deleteLastChar(); - - if (str.matchString("*Initialization*", true)) { - // Not used - } else if (str.matchString("*Rectangle*", true)) { - int32 x1, y1, x2, y2; - sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); - Common::Rect rct = Common::Rect(x1, y1, x2, y2); - _areaId = _engine->getRenderManager()->createSubArea(rct); - } else if (str.matchString("*TextFile*", true)) { - char filename[64]; - sscanf(str.c_str(), "%*[^:]:%s", filename); - Common::File txt; - if (_engine->getSearchManager()->openFile(txt, filename)) { - while (!txt.eos()) { - Common::String txtline = readWideLine(txt); - sub cur_sub; - cur_sub.start = -1; - cur_sub.stop = -1; - cur_sub.sub = txtline; - - _subs.push_back(cur_sub); - } - txt.close(); - } - } else { - int32 st; - int32 en; - int32 sb; - if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { - if (sb <= (int32)_subs.size()) { - _subs[sb].start = st; - _subs[sb].stop = en; - } - } - } - } - } -} - -Subtitle::~Subtitle() { - if (_areaId != -1) - _engine->getRenderManager()->deleteSubArea(_areaId); - - _subs.clear(); -} - -void Subtitle::process(int32 time) { - int16 j = -1; - for (uint16 i = 0; i < _subs.size(); i++) - if (time >= _subs[i].start && time <= _subs[i].stop) { - j = i; - break; - } - - if (j == -1 && _subId != -1) { - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, ""); - _subId = -1; - } - - if (j != -1 && j != _subId) { - if (_subs[j].sub.size()) - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub); - _subId = j; - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp new file mode 100644 index 0000000000..4ca48f7b42 --- /dev/null +++ b/engines/zvision/subtitles/subtitles.cpp @@ -0,0 +1,108 @@ +/* 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 "zvision/subtitles/subtitles.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/core/search_manager.h" +#include "zvision/text/text.h" + +namespace ZVision { + +Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : + _engine(engine), + _areaId(-1), + _subId(-1) { + Common::File file; + if (_engine->getSearchManager()->openFile(file, subname)) { + while (!file.eos()) { + Common::String str = file.readLine(); + if (str.lastChar() == '~') + str.deleteLastChar(); + + if (str.matchString("*Initialization*", true)) { + // Not used + } else if (str.matchString("*Rectangle*", true)) { + int32 x1, y1, x2, y2; + sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); + Common::Rect rct = Common::Rect(x1, y1, x2, y2); + _areaId = _engine->getRenderManager()->createSubArea(rct); + } else if (str.matchString("*TextFile*", true)) { + char filename[64]; + sscanf(str.c_str(), "%*[^:]:%s", filename); + Common::File txt; + if (_engine->getSearchManager()->openFile(txt, filename)) { + while (!txt.eos()) { + Common::String txtline = readWideLine(txt); + sub cur_sub; + cur_sub.start = -1; + cur_sub.stop = -1; + cur_sub.sub = txtline; + + _subs.push_back(cur_sub); + } + txt.close(); + } + } else { + int32 st; + int32 en; + int32 sb; + if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { + if (sb <= (int32)_subs.size()) { + _subs[sb].start = st; + _subs[sb].stop = en; + } + } + } + } + } +} + +Subtitle::~Subtitle() { + if (_areaId != -1) + _engine->getRenderManager()->deleteSubArea(_areaId); + + _subs.clear(); +} + +void Subtitle::process(int32 time) { + int16 j = -1; + for (uint16 i = 0; i < _subs.size(); i++) + if (time >= _subs[i].start && time <= _subs[i].stop) { + j = i; + break; + } + + if (j == -1 && _subId != -1) { + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, ""); + _subId = -1; + } + + if (j != -1 && j != _subId) { + if (_subs[j].sub.size()) + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub); + _subId = j; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/syncsound_node.cpp b/engines/zvision/syncsound_node.cpp deleted file mode 100644 index 7bd520d475..0000000000 --- a/engines/zvision/syncsound_node.cpp +++ /dev/null @@ -1,86 +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 "common/scummsys.h" - -#include "zvision/syncsound_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/sound/zork_raw.h" - -#include "common/stream.h" -#include "common/file.h" -#include "audio/decoders/wave.h" - - -namespace ZVision { - -SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) - : SideFX(engine, key, SIDEFX_AUDIO) { - _syncto = syncto; - _sub = NULL; - - Audio::RewindableAudioStream *audioStream; - - if (filename.contains(".wav")) { - Common::File *file = new Common::File(); - if (_engine->getSearchManager()->openFile(*file, filename)) { - audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); - } - } else { - audioStream = makeRawZorkStream(filename, _engine); - } - - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream); - - Common::String subname = filename; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); - - if (_engine->getSearchManager()->hasFile(subname)) - _sub = new Subtitle(_engine, subname); -} - -SyncSoundNode::~SyncSoundNode() { - _engine->_mixer->stopHandle(_handle); - if (_sub) - delete _sub; -} - -bool SyncSoundNode::process(uint32 deltaTimeInMillis) { - if (! _engine->_mixer->isSoundHandleActive(_handle)) - return stop(); - else { - - if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) - return stop(); - - if (_sub) - _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); - } - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/syncsound_node.h b/engines/zvision/syncsound_node.h deleted file mode 100644 index 1f63ec48dd..0000000000 --- a/engines/zvision/syncsound_node.h +++ /dev/null @@ -1,56 +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 ZVISION_SYNCSOUND_NODE_H -#define ZVISION_SYNCSOUND_NODE_H - -#include "audio/mixer.h" -#include "zvision/sidefx.h" -#include "zvision/subtitles/subtitles.h" - -namespace Common { -class String; -} - -namespace ZVision { -class SyncSoundNode : public SideFX { -public: - SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto); - ~SyncSoundNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); -private: - int32 _syncto; - Audio::SoundHandle _handle; - Subtitle *_sub; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/text.cpp b/engines/zvision/text.cpp deleted file mode 100644 index 6b0ff0712b..0000000000 --- a/engines/zvision/text.cpp +++ /dev/null @@ -1,549 +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 "common/scummsys.h" - -#include "zvision/text.h" - -#include "zvision/fonts/truetype_font.h" - -#include "common/file.h" -#include "common/tokenizer.h" -#include "common/debug.h" -#include "common/rect.h" - -#include "graphics/fontman.h" -#include "graphics/colormasks.h" -#include "graphics/surface.h" -#include "graphics/font.h" -#include "graphics/fonts/ttf.h" - -#include "zvision/graphics/render_manager.h" -#include "zvision/scripting/script_manager.h" - - -namespace ZVision { - -cTxtStyle::cTxtStyle() { - fontname = "Arial"; - blue = 255; - green = 255; - red = 255; - bold = false; - escapement = 0; - italic = false; - justify = TXT_JUSTIFY_LEFT; - newline = false; - size = 12; - skipcolor = false; - strikeout = false; - underline = false; - statebox = 0; - sharp = false; -} - -txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { - Common::String buf = Common::String(strin.c_str(), ln); - - int8 retval = TXT_RET_NOTHING; - - Common::StringTokenizer tokenizer(buf, " "); - Common::String token; - - while (!tokenizer.empty()) { - token = tokenizer.nextToken(); - - if (token.matchString("font", true)) { - token = tokenizer.nextToken(); - if (token[0] == '"') { - Common::String _tmp = Common::String(token.c_str() + 1); - - while (token.lastChar() != '"' && !tokenizer.empty()) { - token = tokenizer.nextToken(); - _tmp += " " + token; - } - - if (_tmp.lastChar() == '"') - _tmp.deleteLastChar(); - - fontname = _tmp; - } else { - if (!tokenizer.empty()) - fontname = token; - } - retval |= TXT_RET_FNTCHG; - - } else if (token.matchString("blue", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - int32 tmp = atoi(token.c_str()); - if (blue != tmp) { - blue = tmp; - retval |= TXT_RET_FNTSTL; - } - } - } else if (token.matchString("red", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - int32 tmp = atoi(token.c_str()); - if (red != tmp) { - red = tmp; - retval |= TXT_RET_FNTSTL; - } - } - } else if (token.matchString("green", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - int32 tmp = atoi(token.c_str()); - if (green != tmp) { - green = tmp; - retval |= TXT_RET_FNTSTL; - } - } - } else if (token.matchString("newline", true)) { - if ((retval & TXT_RET_NEWLN) == 0) - newline = 0; - - newline++; - retval |= TXT_RET_NEWLN; - } else if (token.matchString("point", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - int32 tmp = atoi(token.c_str()); - if (size != tmp) { - size = tmp; - retval |= TXT_RET_FNTCHG; - } - } - } else if (token.matchString("escapement", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - int32 tmp = atoi(token.c_str()); - escapement = tmp; - } - } else if (token.matchString("italic", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("on", true)) { - if (italic != true) { - italic = true; - retval |= TXT_RET_FNTSTL; - } - } else if (token.matchString("off", true)) { - if (italic != false) { - italic = false; - retval |= TXT_RET_FNTSTL; - } - } - } - } else if (token.matchString("underline", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("on", true)) { - if (underline != true) { - underline = true; - retval |= TXT_RET_FNTSTL; - } - } else if (token.matchString("off", true)) { - if (underline != false) { - underline = false; - retval |= TXT_RET_FNTSTL; - } - } - } - } else if (token.matchString("strikeout", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("on", true)) { - if (strikeout != true) { - strikeout = true; - retval |= TXT_RET_FNTSTL; - } - } else if (token.matchString("off", true)) { - if (strikeout != false) { - strikeout = false; - retval |= TXT_RET_FNTSTL; - } - } - } - } else if (token.matchString("bold", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("on", true)) { - if (bold != true) { - bold = true; - retval |= TXT_RET_FNTSTL; - } - } else if (token.matchString("off", true)) { - if (bold != false) { - bold = false; - retval |= TXT_RET_FNTSTL; - } - } - } - } else if (token.matchString("skipcolor", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("on", true)) { - skipcolor = true; - } else if (token.matchString("off", true)) { - skipcolor = false; - } - } - } else if (token.matchString("image", true)) { - // Not used - } else if (token.matchString("statebox", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - statebox = atoi(token.c_str()); - retval |= TXT_RET_HASSTBOX; - } - } else if (token.matchString("justify", true)) { - if (!tokenizer.empty()) { - token = tokenizer.nextToken(); - if (token.matchString("center", true)) - justify = TXT_JUSTIFY_CENTER; - else if (token.matchString("left", true)) - justify = TXT_JUSTIFY_LEFT; - else if (token.matchString("right", true)) - justify = TXT_JUSTIFY_RIGHT; - } - } - } - return (txtReturn)retval; -} - -void cTxtStyle::readAllStyle(const Common::String &txt) { - int16 strt = -1; - int16 endt = -1; - - for (uint16 i = 0; i < txt.size(); i++) { - if (txt[i] == '<') - strt = i; - else if (txt[i] == '>') { - endt = i; - if (strt != -1) - if ((endt - strt - 1) > 0) - parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1); - } - - } -} - -void cTxtStyle::setFontStyle(sTTFont &font) { - uint temp_stl = 0; - - if (bold) - temp_stl |= sTTFont::STTF_BOLD; - - if (italic) - temp_stl |= sTTFont::STTF_ITALIC; - - if (underline) - temp_stl |= sTTFont::STTF_UNDERLINE; - - if (strikeout) - temp_stl |= sTTFont::STTF_STRIKEOUT; - - if (sharp) - temp_stl |= sTTFont::STTF_SHARP; - - font.setStyle(temp_stl); -} - -void cTxtStyle::setFont(sTTFont &font) { - uint temp_stl = 0; - - if (bold) - temp_stl |= sTTFont::STTF_BOLD; - - if (italic) - temp_stl |= sTTFont::STTF_ITALIC; - - if (underline) - temp_stl |= sTTFont::STTF_UNDERLINE; - - if (strikeout) - temp_stl |= sTTFont::STTF_STRIKEOUT; - - if (sharp) - temp_stl |= sTTFont::STTF_SHARP; - - font.loadFont(fontname, size, temp_stl); -} - -Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) { - style.setFontStyle(fnt); - uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue); - return fnt.renderSolidText(txt, clr); -} - -void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { - if (justify == TXT_JUSTIFY_LEFT) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft); - else if (justify == TXT_JUSTIFY_CENTER) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter); - else if (justify == TXT_JUSTIFY_RIGHT) - fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight); -} - -int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) { - sTTFont font(_engine); - fnt_stl.setFont(font); - - dst.fillRect(Common::Rect(dst.w, dst.h), 0); - - uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue); - - int16 w; - - w = font.getStringWidth(txt); - - drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify); - - return w; -} - -void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { - const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it - const int TXT_CFG_TEXTURES_PER_LINE = 6; - cTxtStyle style, style2; - int16 strt = -1; - int16 endt = -1; - int16 i = 0; - int16 dx = 0, dy = 0; - int16 txt_w; - int16 txtpos = 0; - Common::String buf; - Common::String buf2; - - Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE]; - int16 currentline = 0, currentlineitm = 0; - - int TxtJustify[TXT_CFG_TEXTURES_LINES]; - int TxtPoint[TXT_CFG_TEXTURES_LINES]; - - for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) { - TxtPoint[k] = 0; - for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) - TxtSurfaces[k][j] = NULL; - } - - int16 stringlen = text.size(); - - sTTFont font(_engine); - - style.setFont(font); - - int16 prevbufspace = 0, prevtxtspace = 0; - - while (i < stringlen) { - TxtJustify[currentline] = style.justify; - if (text[i] == '<') { - int16 ret = 0; - - strt = i; - while (i < stringlen && text[i] != '>') - i++; - endt = i; - if (strt != -1) - if ((endt - strt - 1) > 0) { - style2 = style; - ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1); - } - - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (buf.size() > 0) { - txt_w = font.getStringWidth(buf); - - TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); - - currentlineitm++; - - buf.clear(); - prevbufspace = 0; - txtpos = 0; - dx += txt_w; - - } - if (ret & TXT_RET_FNTCHG) { - style.setFont(font); - } - if (ret & TXT_RET_FNTSTL) - style.setFontStyle(font); - - if (ret & TXT_RET_NEWLN) { - currentline++; - currentlineitm = 0; - dx = 0; - } - } - - if (ret & TXT_RET_HASSTBOX) { - Common::String buf3; - buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); - buf += buf3; - txtpos += buf3.size(); - } - - } else { - - buf += text[i]; - txtpos++; - - if (text[i] == ' ') { - prevbufspace = txtpos - 1; - prevtxtspace = i; - } - - if (font.isLoaded()) { - txt_w = font.getStringWidth(buf); - if (txt_w + dx > dst.w) { - if (prevbufspace == 0) { - prevtxtspace = i; - prevbufspace = txtpos - 1; - } - buf2 = Common::String(buf.c_str(), prevbufspace + 1); - - if (buf2.size() > 0) { - TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); - } - - buf.clear(); - i = prevtxtspace; - prevbufspace = 0; - txtpos = 0; - currentline++; - currentlineitm = 0; - dx = 0; - } - } - } - i++; - } - - if (buf.size() > 0) { - TxtSurfaces[currentline][currentlineitm] = render(font, buf, style); - TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); - } - - dy = 0; - for (i = 0; i <= currentline; i++) { - int16 j = 0; - int16 width = 0; - while (TxtSurfaces[i][j] != NULL) { - width += TxtSurfaces[i][j]->w; - j++; - } - dx = 0; - for (int32_t jj = 0; jj < j; jj++) { - if (TxtJustify[i] == TXT_JUSTIFY_LEFT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); - - else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); - - else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); - - dx += TxtSurfaces[i][jj]->w; - } - - dy += TxtPoint[i]; - } - - for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++) - for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) - if (TxtSurfaces[i][j] != NULL) { - TxtSurfaces[i][j]->free(); - delete TxtSurfaces[i][j]; - } -} - -Common::String readWideLine(Common::SeekableReadStream &stream) { - Common::String asciiString; - - while (!stream.eos()) { - uint32 value = stream.readUint16LE(); - // Check for CRLF - if (value == 0x0A0D) { - // Read in the extra NULL char - stream.readByte(); // \0 - // End of the line. Break - break; - } - - // Crush each octet pair to a single octet with a simple cast - if (value < 0x80) { - asciiString += (char)(value & 0x7F); - } else if (value >= 0x80 && value < 0x800) { - asciiString += (char)(0xC0 | ((value >> 6) & 0x1F)); - asciiString += (char)(0x80 | (value & 0x3F)); - } else if (value >= 0x800 && value < 0x10000) { - asciiString += (char)(0xE0 | ((value >> 12) & 0xF)); - asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); - asciiString += (char)(0x80 | (value & 0x3F)); - } else if (value >= 0x10000 && value < 0x200000) { - asciiString += (char)(0xF0); - asciiString += (char)(0x80 | ((value >> 12) & 0x3F)); - asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); - asciiString += (char)(0x80 | (value & 0x3F)); - } - } - - return asciiString; -} - -int8 getUtf8CharSize(char chr) { - if ((chr & 0x80) == 0) - return 1; - else if ((chr & 0xE0) == 0xC0) - return 2; - else if ((chr & 0xF0) == 0xE0) - return 3; - else if ((chr & 0xF8) == 0xF0) - return 4; - else if ((chr & 0xFC) == 0xF8) - return 5; - else if ((chr & 0xFE) == 0xFC) - return 6; - - return 1; -} - -uint16 readUtf8Char(const char *chr) { - uint16 result = 0; - if ((chr[0] & 0x80) == 0) - result = chr[0]; - else if ((chr[0] & 0xE0) == 0xC0) - result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F); - else if ((chr[0] & 0xF0) == 0xE0) - result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F); - else - result = chr[0]; - - return result; -} - -} // End of namespace ZVision diff --git a/engines/zvision/text.h b/engines/zvision/text.h deleted file mode 100644 index 4b318fdef0..0000000000 --- a/engines/zvision/text.h +++ /dev/null @@ -1,100 +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 ZVISION_TEXT_H -#define ZVISION_TEXT_H - -#include "zvision/detection.h" -#include "zvision/fonts/truetype_font.h" -#include "zvision/zvision.h" - - -namespace Graphics { -class FontManager; -} - -namespace ZVision { - -class ZVision; - -enum txtJustify { - TXT_JUSTIFY_CENTER = 0, - TXT_JUSTIFY_LEFT = 1, - TXT_JUSTIFY_RIGHT = 2 -}; - -enum txtReturn { - TXT_RET_NOTHING = 0x0, - TXT_RET_FNTCHG = 0x1, - TXT_RET_FNTSTL = 0x2, - TXT_RET_NEWLN = 0x4, - TXT_RET_HASSTBOX = 0x8 -}; - -class cTxtStyle { -public: - cTxtStyle(); - txtReturn parseStyle(const Common::String &strin, int16 len); - void readAllStyle(const Common::String &txt); - void setFontStyle(sTTFont &font); - void setFont(sTTFont &font); - -public: - Common::String fontname; - txtJustify justify; // 0 - center, 1-left, 2-right - int16 size; - uint8 red; // 0-255 - uint8 green; // 0-255 - uint8 blue; // 0-255 - int8 newline; - int8 escapement; - bool italic; - bool bold; - bool underline; - bool strikeout; - bool skipcolor; - int32 statebox; - bool sharp; - // char image ?? -}; - -class textRenderer { -public: - textRenderer(ZVision *engine): _engine(engine) {}; - - void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); - int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst); - Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style); - void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst); - -private: - ZVision *_engine; -}; - -Common::String readWideLine(Common::SeekableReadStream &stream); -int8 getUtf8CharSize(char chr); -uint16 readUtf8Char(const char *chr); - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp new file mode 100644 index 0000000000..cadfbf1f49 --- /dev/null +++ b/engines/zvision/text/string_manager.cpp @@ -0,0 +1,255 @@ +/* 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 "common/scummsys.h" + +#include "zvision/text/string_manager.h" + +#include "zvision/fonts/truetype_font.h" + +#include "common/file.h" +#include "common/tokenizer.h" +#include "common/debug.h" + +#include "graphics/fontman.h" +#include "graphics/colormasks.h" + + +namespace ZVision { + +StringManager::StringManager(ZVision *engine) + : _engine(engine) { +} + +StringManager::~StringManager() { + for (Common::HashMap::iterator iter = _fonts.begin(); iter != _fonts.end(); ++iter) { + delete iter->_value; + } +} + +void StringManager::initialize(ZVisionGameId gameId) { + if (gameId == GID_NEMESIS) { + // TODO: Check this hardcoded filename against all versions of Nemesis + parseStrFile("nemesis.str"); + } else if (gameId == GID_GRANDINQUISITOR) { + // TODO: Check this hardcoded filename against all versions of Grand Inquisitor + parseStrFile("inquis.str"); + } +} + +void StringManager::parseStrFile(const Common::String &fileName) { + Common::File file; + if (!file.open(fileName)) { + warning("%s does not exist. String parsing failed", fileName.c_str()); + return; + } + + uint lineNumber = 0; + while (!file.eos()) { + _lastStyle.align = Graphics::kTextAlignLeft; + _lastStyle.color = 0; + _lastStyle.font = nullptr; + + Common::String asciiLine = readWideLine(file); + if (asciiLine.empty()) { + continue; + } + + char tagString[150]; + uint tagStringCursor = 0; + char textString[150]; + uint textStringCursor = 0; + bool inTag = false; + + for (uint i = 0; i < asciiLine.size(); ++i) { + switch (asciiLine[i]) { + case '<': + inTag = true; + if (!_inGameText[lineNumber].fragments.empty()) { + _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); + textStringCursor = 0; + } + break; + case '>': + inTag = false; + parseTag(Common::String(tagString, tagStringCursor), lineNumber); + tagStringCursor = 0; + break; + default: + if (inTag) { + tagString[tagStringCursor] = asciiLine[i]; + tagStringCursor++; + } else { + textString[textStringCursor] = asciiLine[i]; + textStringCursor++; + } + break; + } + } + + if (textStringCursor > 0) { + _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); + } + + lineNumber++; + assert(lineNumber <= NUM_TEXT_LINES); + } +} + +void StringManager::parseTag(const Common::String &tagString, uint lineNumber) { + Common::StringTokenizer tokenizer(tagString); + + Common::String token = tokenizer.nextToken(); + + Common::String fontName; + bool bold = false; + Graphics::TextAlign align = _lastStyle.align; + int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12; + int red = 0; + int green = 0; + int blue = 0; + + while (!token.empty()) { + if (token.matchString("font", true)) { + fontName = tokenizer.nextToken(); + } else if (token.matchString("bold", true)) { + token = tokenizer.nextToken(); + if (token.matchString("on", false)) { + bold = true; + } + } else if (token.matchString("justify", true)) { + token = tokenizer.nextToken(); + if (token.matchString("center", false)) { + align = Graphics::kTextAlignCenter; + } else if (token.matchString("right", false)) { + align = Graphics::kTextAlignRight; + } + } else if (token.matchString("point", true)) { + point = atoi(tokenizer.nextToken().c_str()); + } else if (token.matchString("red", true)) { + red = atoi(tokenizer.nextToken().c_str()); + } else if (token.matchString("green", true)) { + green = atoi(tokenizer.nextToken().c_str()); + } else if (token.matchString("blue", true)) { + blue = atoi(tokenizer.nextToken().c_str()); + } + + token = tokenizer.nextToken(); + } + + TextFragment fragment; + + if (fontName.empty()) { + fragment.style.font = _lastStyle.font; + } else { + Common::String newFontName; + if (fontName.matchString("*times new roman*", true)) { + if (bold) { + newFontName = "timesbd.ttf"; + } else { + newFontName = "times.ttf"; + } + } else if (fontName.matchString("*courier new*", true)) { + if (bold) { + newFontName = "courbd.ttf"; + } else { + newFontName = "cour.ttf"; + } + } else if (fontName.matchString("*century schoolbook*", true)) { + if (bold) { + newFontName = "censcbkbd.ttf"; + } else { + newFontName = "censcbk.ttf"; + } + } else if (fontName.matchString("*garamond*", true)) { + if (bold) { + newFontName = "garabd.ttf"; + } else { + newFontName = "gara.ttf"; + } + } else { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + if (bold) { + newFontName = "zorknorm.ttf"; + } else { + newFontName = "arial.ttf"; + } + } + + Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point); + if (_fonts.contains(fontKey)) { + fragment.style.font = _fonts[fontKey]; + } else { + fragment.style.font = new TruetypeFont(_engine, point); + fragment.style.font->loadFile(newFontName); + _fonts[fontKey] = fragment.style.font; + } + } + + fragment.style.align = align; + fragment.style.color = Graphics::ARGBToColor >(0, red, green, blue); + _inGameText[lineNumber].fragments.push_back(fragment); + + _lastStyle = fragment.style; +} + +Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { + Common::String asciiString; + + // Don't spam the user with warnings about UTF-16 support. + // Just do one warning per String + bool charOverflowWarning = false; + + uint16 value = stream.readUint16LE(); + while (!stream.eos()) { + // Check for CRLF + if (value == 0x0A0D) { + // Read in the extra NULL char + stream.readByte(); // \0 + // End of the line. Break + break; + } + + // Crush each octet pair to a single octet with a simple cast + if (value > 255) { + charOverflowWarning = true; + value = '?'; + } + char charValue = (char)value; + + asciiString += charValue; + + value = stream.readUint16LE(); + } + + if (charOverflowWarning) { + warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'"); + } + + return asciiString; +} + +StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) { + return _inGameText[stringNumber].fragments.front().style; +} + +} // End of namespace ZVision diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h new file mode 100644 index 0000000000..af8324b890 --- /dev/null +++ b/engines/zvision/text/string_manager.h @@ -0,0 +1,84 @@ +/* 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 ZVISION_STRING_MANAGER_H +#define ZVISION_STRING_MANAGER_H + +#include "zvision/detection.h" +#include "zvision/fonts/truetype_font.h" + + +namespace Graphics { +class FontManager; +} + +namespace ZVision { + +class ZVision; + +class StringManager { +public: + StringManager(ZVision *engine); + ~StringManager(); + +public: + struct TextStyle { + TruetypeFont *font; + uint16 color; // In RBG 565 + Graphics::TextAlign align; + }; + + struct TextFragment { + TextStyle style; + Common::String text; + }; + +private: + struct InGameText { + Common::List fragments; + }; + + enum { + NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 + }; + +private: + ZVision *_engine; + InGameText _inGameText[NUM_TEXT_LINES]; + Common::HashMap _fonts; + + TextStyle _lastStyle; + +public: + void initialize(ZVisionGameId gameId); + StringManager::TextStyle getTextStyle(uint stringNumber); + +private: + void parseStrFile(const Common::String &fileName); + void parseTag(const Common::String &tagString, uint lineNumber); + + static Common::String readWideLine(Common::SeekableReadStream &stream); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp new file mode 100644 index 0000000000..cad2723d13 --- /dev/null +++ b/engines/zvision/text/text.cpp @@ -0,0 +1,549 @@ +/* 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 "common/scummsys.h" + +#include "zvision/text/text.h" + +#include "zvision/fonts/truetype_font.h" + +#include "common/file.h" +#include "common/tokenizer.h" +#include "common/debug.h" +#include "common/rect.h" + +#include "graphics/fontman.h" +#include "graphics/colormasks.h" +#include "graphics/surface.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" + +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" + + +namespace ZVision { + +cTxtStyle::cTxtStyle() { + fontname = "Arial"; + blue = 255; + green = 255; + red = 255; + bold = false; + escapement = 0; + italic = false; + justify = TXT_JUSTIFY_LEFT; + newline = false; + size = 12; + skipcolor = false; + strikeout = false; + underline = false; + statebox = 0; + sharp = false; +} + +txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { + Common::String buf = Common::String(strin.c_str(), ln); + + int8 retval = TXT_RET_NOTHING; + + Common::StringTokenizer tokenizer(buf, " "); + Common::String token; + + while (!tokenizer.empty()) { + token = tokenizer.nextToken(); + + if (token.matchString("font", true)) { + token = tokenizer.nextToken(); + if (token[0] == '"') { + Common::String _tmp = Common::String(token.c_str() + 1); + + while (token.lastChar() != '"' && !tokenizer.empty()) { + token = tokenizer.nextToken(); + _tmp += " " + token; + } + + if (_tmp.lastChar() == '"') + _tmp.deleteLastChar(); + + fontname = _tmp; + } else { + if (!tokenizer.empty()) + fontname = token; + } + retval |= TXT_RET_FNTCHG; + + } else if (token.matchString("blue", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (blue != tmp) { + blue = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("red", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (red != tmp) { + red = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("green", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (green != tmp) { + green = tmp; + retval |= TXT_RET_FNTSTL; + } + } + } else if (token.matchString("newline", true)) { + if ((retval & TXT_RET_NEWLN) == 0) + newline = 0; + + newline++; + retval |= TXT_RET_NEWLN; + } else if (token.matchString("point", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + if (size != tmp) { + size = tmp; + retval |= TXT_RET_FNTCHG; + } + } + } else if (token.matchString("escapement", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + int32 tmp = atoi(token.c_str()); + escapement = tmp; + } + } else if (token.matchString("italic", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (italic != true) { + italic = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (italic != false) { + italic = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("underline", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (underline != true) { + underline = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (underline != false) { + underline = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("strikeout", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (strikeout != true) { + strikeout = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (strikeout != false) { + strikeout = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("bold", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + if (bold != true) { + bold = true; + retval |= TXT_RET_FNTSTL; + } + } else if (token.matchString("off", true)) { + if (bold != false) { + bold = false; + retval |= TXT_RET_FNTSTL; + } + } + } + } else if (token.matchString("skipcolor", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("on", true)) { + skipcolor = true; + } else if (token.matchString("off", true)) { + skipcolor = false; + } + } + } else if (token.matchString("image", true)) { + // Not used + } else if (token.matchString("statebox", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + statebox = atoi(token.c_str()); + retval |= TXT_RET_HASSTBOX; + } + } else if (token.matchString("justify", true)) { + if (!tokenizer.empty()) { + token = tokenizer.nextToken(); + if (token.matchString("center", true)) + justify = TXT_JUSTIFY_CENTER; + else if (token.matchString("left", true)) + justify = TXT_JUSTIFY_LEFT; + else if (token.matchString("right", true)) + justify = TXT_JUSTIFY_RIGHT; + } + } + } + return (txtReturn)retval; +} + +void cTxtStyle::readAllStyle(const Common::String &txt) { + int16 strt = -1; + int16 endt = -1; + + for (uint16 i = 0; i < txt.size(); i++) { + if (txt[i] == '<') + strt = i; + else if (txt[i] == '>') { + endt = i; + if (strt != -1) + if ((endt - strt - 1) > 0) + parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1); + } + + } +} + +void cTxtStyle::setFontStyle(sTTFont &font) { + uint temp_stl = 0; + + if (bold) + temp_stl |= sTTFont::STTF_BOLD; + + if (italic) + temp_stl |= sTTFont::STTF_ITALIC; + + if (underline) + temp_stl |= sTTFont::STTF_UNDERLINE; + + if (strikeout) + temp_stl |= sTTFont::STTF_STRIKEOUT; + + if (sharp) + temp_stl |= sTTFont::STTF_SHARP; + + font.setStyle(temp_stl); +} + +void cTxtStyle::setFont(sTTFont &font) { + uint temp_stl = 0; + + if (bold) + temp_stl |= sTTFont::STTF_BOLD; + + if (italic) + temp_stl |= sTTFont::STTF_ITALIC; + + if (underline) + temp_stl |= sTTFont::STTF_UNDERLINE; + + if (strikeout) + temp_stl |= sTTFont::STTF_STRIKEOUT; + + if (sharp) + temp_stl |= sTTFont::STTF_SHARP; + + font.loadFont(fontname, size, temp_stl); +} + +Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) { + style.setFontStyle(fnt); + uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue); + return fnt.renderSolidText(txt, clr); +} + +void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { + if (justify == TXT_JUSTIFY_LEFT) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft); + else if (justify == TXT_JUSTIFY_CENTER) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignCenter); + else if (justify == TXT_JUSTIFY_RIGHT) + fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight); +} + +int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) { + sTTFont font(_engine); + fnt_stl.setFont(font); + + dst.fillRect(Common::Rect(dst.w, dst.h), 0); + + uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue); + + int16 w; + + w = font.getStringWidth(txt); + + drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify); + + return w; +} + +void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { + const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it + const int TXT_CFG_TEXTURES_PER_LINE = 6; + cTxtStyle style, style2; + int16 strt = -1; + int16 endt = -1; + int16 i = 0; + int16 dx = 0, dy = 0; + int16 txt_w; + int16 txtpos = 0; + Common::String buf; + Common::String buf2; + + Graphics::Surface *TxtSurfaces[TXT_CFG_TEXTURES_LINES][TXT_CFG_TEXTURES_PER_LINE]; + int16 currentline = 0, currentlineitm = 0; + + int TxtJustify[TXT_CFG_TEXTURES_LINES]; + int TxtPoint[TXT_CFG_TEXTURES_LINES]; + + for (int16 k = 0; k < TXT_CFG_TEXTURES_LINES; k++) { + TxtPoint[k] = 0; + for (int j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) + TxtSurfaces[k][j] = NULL; + } + + int16 stringlen = text.size(); + + sTTFont font(_engine); + + style.setFont(font); + + int16 prevbufspace = 0, prevtxtspace = 0; + + while (i < stringlen) { + TxtJustify[currentline] = style.justify; + if (text[i] == '<') { + int16 ret = 0; + + strt = i; + while (i < stringlen && text[i] != '>') + i++; + endt = i; + if (strt != -1) + if ((endt - strt - 1) > 0) { + style2 = style; + ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1); + } + + if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { + if (buf.size() > 0) { + txt_w = font.getStringWidth(buf); + + TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + + currentlineitm++; + + buf.clear(); + prevbufspace = 0; + txtpos = 0; + dx += txt_w; + + } + if (ret & TXT_RET_FNTCHG) { + style.setFont(font); + } + if (ret & TXT_RET_FNTSTL) + style.setFontStyle(font); + + if (ret & TXT_RET_NEWLN) { + currentline++; + currentlineitm = 0; + dx = 0; + } + } + + if (ret & TXT_RET_HASSTBOX) { + Common::String buf3; + buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); + buf += buf3; + txtpos += buf3.size(); + } + + } else { + + buf += text[i]; + txtpos++; + + if (text[i] == ' ') { + prevbufspace = txtpos - 1; + prevtxtspace = i; + } + + if (font.isLoaded()) { + txt_w = font.getStringWidth(buf); + if (txt_w + dx > dst.w) { + if (prevbufspace == 0) { + prevtxtspace = i; + prevbufspace = txtpos - 1; + } + buf2 = Common::String(buf.c_str(), prevbufspace + 1); + + if (buf2.size() > 0) { + TxtSurfaces[currentline][currentlineitm] = render(font, buf2, style); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + } + + buf.clear(); + i = prevtxtspace; + prevbufspace = 0; + txtpos = 0; + currentline++; + currentlineitm = 0; + dx = 0; + } + } + } + i++; + } + + if (buf.size() > 0) { + TxtSurfaces[currentline][currentlineitm] = render(font, buf, style); + TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); + } + + dy = 0; + for (i = 0; i <= currentline; i++) { + int16 j = 0; + int16 width = 0; + while (TxtSurfaces[i][j] != NULL) { + width += TxtSurfaces[i][j]->w; + j++; + } + dx = 0; + for (int32_t jj = 0; jj < j; jj++) { + if (TxtJustify[i] == TXT_JUSTIFY_LEFT) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + + dx += TxtSurfaces[i][jj]->w; + } + + dy += TxtPoint[i]; + } + + for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++) + for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) + if (TxtSurfaces[i][j] != NULL) { + TxtSurfaces[i][j]->free(); + delete TxtSurfaces[i][j]; + } +} + +Common::String readWideLine(Common::SeekableReadStream &stream) { + Common::String asciiString; + + while (!stream.eos()) { + uint32 value = stream.readUint16LE(); + // Check for CRLF + if (value == 0x0A0D) { + // Read in the extra NULL char + stream.readByte(); // \0 + // End of the line. Break + break; + } + + // Crush each octet pair to a single octet with a simple cast + if (value < 0x80) { + asciiString += (char)(value & 0x7F); + } else if (value >= 0x80 && value < 0x800) { + asciiString += (char)(0xC0 | ((value >> 6) & 0x1F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } else if (value >= 0x800 && value < 0x10000) { + asciiString += (char)(0xE0 | ((value >> 12) & 0xF)); + asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } else if (value >= 0x10000 && value < 0x200000) { + asciiString += (char)(0xF0); + asciiString += (char)(0x80 | ((value >> 12) & 0x3F)); + asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); + asciiString += (char)(0x80 | (value & 0x3F)); + } + } + + return asciiString; +} + +int8 getUtf8CharSize(char chr) { + if ((chr & 0x80) == 0) + return 1; + else if ((chr & 0xE0) == 0xC0) + return 2; + else if ((chr & 0xF0) == 0xE0) + return 3; + else if ((chr & 0xF8) == 0xF0) + return 4; + else if ((chr & 0xFC) == 0xF8) + return 5; + else if ((chr & 0xFE) == 0xFC) + return 6; + + return 1; +} + +uint16 readUtf8Char(const char *chr) { + uint16 result = 0; + if ((chr[0] & 0x80) == 0) + result = chr[0]; + else if ((chr[0] & 0xE0) == 0xC0) + result = ((chr[0] & 0x1F) << 6) | (chr[1] & 0x3F); + else if ((chr[0] & 0xF0) == 0xE0) + result = ((chr[0] & 0x0F) << 12) | ((chr[1] & 0x3F) << 6) | (chr[2] & 0x3F); + else + result = chr[0]; + + return result; +} + +} // End of namespace ZVision diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h new file mode 100644 index 0000000000..4b318fdef0 --- /dev/null +++ b/engines/zvision/text/text.h @@ -0,0 +1,100 @@ +/* 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 ZVISION_TEXT_H +#define ZVISION_TEXT_H + +#include "zvision/detection.h" +#include "zvision/fonts/truetype_font.h" +#include "zvision/zvision.h" + + +namespace Graphics { +class FontManager; +} + +namespace ZVision { + +class ZVision; + +enum txtJustify { + TXT_JUSTIFY_CENTER = 0, + TXT_JUSTIFY_LEFT = 1, + TXT_JUSTIFY_RIGHT = 2 +}; + +enum txtReturn { + TXT_RET_NOTHING = 0x0, + TXT_RET_FNTCHG = 0x1, + TXT_RET_FNTSTL = 0x2, + TXT_RET_NEWLN = 0x4, + TXT_RET_HASSTBOX = 0x8 +}; + +class cTxtStyle { +public: + cTxtStyle(); + txtReturn parseStyle(const Common::String &strin, int16 len); + void readAllStyle(const Common::String &txt); + void setFontStyle(sTTFont &font); + void setFont(sTTFont &font); + +public: + Common::String fontname; + txtJustify justify; // 0 - center, 1-left, 2-right + int16 size; + uint8 red; // 0-255 + uint8 green; // 0-255 + uint8 blue; // 0-255 + int8 newline; + int8 escapement; + bool italic; + bool bold; + bool underline; + bool strikeout; + bool skipcolor; + int32 statebox; + bool sharp; + // char image ?? +}; + +class textRenderer { +public: + textRenderer(ZVision *engine): _engine(engine) {}; + + void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); + int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst); + Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style); + void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst); + +private: + ZVision *_engine; +}; + +Common::String readWideLine(Common::SeekableReadStream &stream); +int8 getUtf8CharSize(char chr); +uint16 readUtf8Char(const char *chr); + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/ttytext_node.cpp b/engines/zvision/ttytext_node.cpp deleted file mode 100644 index 6741d28a56..0000000000 --- a/engines/zvision/ttytext_node.cpp +++ /dev/null @@ -1,175 +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 "common/scummsys.h" - -#include "zvision/ttytext_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/text.h" - -#include "common/stream.h" -#include "common/file.h" - - -namespace ZVision { - -ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : - SideFX(engine, key, SIDEFX_TTYTXT), - _fnt(engine) { - _delay = delay; - _r = r; - _txtpos = 0; - _nexttime = 0; - _dx = 0; - _dy = 0; - - Common::File *infile = _engine->getSearchManager()->openFile(file); - if (infile) { - while (!infile->eos()) { - Common::String asciiLine = readWideLine(*infile); - if (asciiLine.empty()) { - continue; - } - _txtbuf += asciiLine; - } - - delete infile; - } - _img.create(_r.width(), _r.height(), _engine->_pixelFormat); - _style.sharp = true; - _style.readAllStyle(_txtbuf); - _style.setFont(_fnt); - _engine->getScriptManager()->setStateValue(_key, 1); -} - -ttyTextNode::~ttyTextNode() { - _engine->getScriptManager()->setStateValue(_key, 2); - _img.free(); -} - -bool ttyTextNode::process(uint32 deltaTimeInMillis) { - _nexttime -= deltaTimeInMillis; - - if (_nexttime < 0) { - if (_txtpos < _txtbuf.size()) { - if (_txtbuf[_txtpos] == '<') { - int32 strt = _txtpos; - int32 endt = 0; - int16 ret = 0; - while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) - _txtpos++; - endt = _txtpos; - if (strt != -1) - if ((endt - strt - 1) > 0) - ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); - - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (ret & TXT_RET_FNTCHG) - _style.setFont(_fnt); - if (ret & TXT_RET_FNTSTL) - _style.setFontStyle(_fnt); - - if (ret & TXT_RET_NEWLN) - newline(); - } - - if (ret & TXT_RET_HASSTBOX) { - Common::String buf; - buf.format("%d", _style.statebox); - - for (uint8 j = 0; j < buf.size(); j++) - outchar(buf[j]); - } - - _txtpos++; - } else { - int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]); - - uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos); - - if (chr == ' ') { - uint32 i = _txtpos + charsz; - uint16 width = _fnt.getCharWidth(chr); - - while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') { - - int8 chsz = getUtf8CharSize(_txtbuf[i]); - uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos); - - width += _fnt.getCharWidth(uchr); - - i += chsz; - } - - if (_dx + width > _r.width()) - newline(); - else - outchar(chr); - } else - outchar(chr); - - _txtpos += charsz; - } - _nexttime = _delay; - _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top); - } else - return stop(); - } - - return false; -} - -void ttyTextNode::scroll() { - int32 scrl = 0; - while (_dy - scrl > _r.height() - _fnt.getFontHeight()) - scrl += _fnt.getFontHeight(); - int8 *pixels = (int8 *)_img.getPixels(); - for (uint16 h = scrl; h < _img.h; h++) - memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch); - - _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0); - _dy -= scrl; -} - -void ttyTextNode::newline() { - _dy += _fnt.getFontHeight(); - _dx = 0; -} - -void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue); - - if (_dx + _fnt.getCharWidth(chr) > _r.width()) - newline(); - - if (_dy + _fnt.getFontHeight() >= _r.height()) - scroll(); - - _fnt.drawChar(&_img, chr, _dx, _dy, clr); - - _dx += _fnt.getCharWidth(chr); -} - -} // End of namespace ZVision diff --git a/engines/zvision/ttytext_node.h b/engines/zvision/ttytext_node.h deleted file mode 100644 index e25fdb0c07..0000000000 --- a/engines/zvision/ttytext_node.h +++ /dev/null @@ -1,76 +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 ZVISION_TTYTEXT_NODE_H -#define ZVISION_TTYTEXT_NODE_H - -#include "common/rect.h" -#include "graphics/surface.h" - -#include "zvision/sidefx.h" -#include "zvision/text.h" -#include "zvision/fonts/truetype_font.h" - -namespace Common { -class String; -} - -namespace ZVision { -class ttyTextNode : public SideFX { -public: - ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay); - ~ttyTextNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); -private: - Common::Rect _r; - //int16 x; - //int16 y; - //uint16 w; - //uint16 h; - cTxtStyle _style; - sTTFont _fnt; - Common::String _txtbuf; - uint32 _txtpos; - //int32 txtsize; - int32 _delay; - int32 _nexttime; - Graphics::Surface _img; - int16 _dx; - int16 _dy; -private: - - void newline(); - void scroll(); - void outchar(uint16 chr); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 580f8c4367..0eb14257f2 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -29,12 +29,12 @@ #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" -#include "zvision/strings/string_manager.h" +#include "zvision/text/string_manager.h" #include "zvision/archives/zfs_archive.h" #include "zvision/detection.h" #include "zvision/core/menu.h" -#include "zvision/search_manager.h" -#include "zvision/text.h" +#include "zvision/core/search_manager.h" +#include "zvision/text/text.h" #include "zvision/fonts/truetype_font.h" #include "common/config-manager.h" diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 2674df27e0..db2c646fda 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -26,7 +26,7 @@ #include "zvision/detection.h" #include "zvision/utility/clock.h" -#include "zvision/search_manager.h" +#include "zvision/core/search_manager.h" #include "common/random.h" #include "common/events.h" -- cgit v1.2.3 From 628d6cb4ee92aa15dbdf5029b8675cb09d18f3e9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 5 Jul 2014 17:15:04 +0000 Subject: ZVISION: Fix puzzle disable condition check --- engines/zvision/scripting/script_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index a27ae4dbf0..fc765f0bfb 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -158,8 +158,7 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { // Check if the puzzle is already finished // Also check that the puzzle isn't disabled - if (getStateValue(puzzle->key) == 1 && - (getStateFlag(puzzle->key) & Puzzle::DISABLED) == 0) { + if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) { return; } -- cgit v1.2.3 From bbaebdf680179dca103b0ed635e791aa602d610d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 5 Jul 2014 17:27:08 +0000 Subject: ZVISION: Process events for controls similar to original engine, fix some errors. --- engines/zvision/core/events.cpp | 24 +++++--------------- engines/zvision/scripting/script_manager.cpp | 33 ++++++++++++++++++++++++++++ engines/zvision/scripting/script_manager.h | 6 +++++ engines/zvision/zvision.h | 2 -- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 943f8ff279..c977125f55 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -46,13 +46,15 @@ void ZVision::processEvents() { case Common::EVENT_LBUTTONDOWN: _cursorManager->cursorDown(true); _scriptManager->setStateValue(StateKey_LMouse, 1); - onMouseDown(_event.mouse); + _menu->onMouseDown(_event.mouse); + _scriptManager->addEvent(_event); break; case Common::EVENT_LBUTTONUP: _cursorManager->cursorDown(false); _scriptManager->setStateValue(StateKey_LMouse, 0); - onMouseUp(_event.mouse); + _menu->onMouseUp(_event.mouse); + _scriptManager->addEvent(_event); break; case Common::EVENT_RBUTTONDOWN: @@ -87,10 +89,10 @@ void ZVision::processEvents() { break; } - _scriptManager->onKeyDown(_event.kbd); + _scriptManager->addEvent(_event); break; case Common::EVENT_KEYUP: - _scriptManager->onKeyUp(_event.kbd); + _scriptManager->addEvent(_event); break; default: break; @@ -98,20 +100,6 @@ void ZVision::processEvents() { } } -void ZVision::onMouseDown(const Common::Point &pos) { - _menu->onMouseDown(pos); - - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); - _scriptManager->onMouseDown(pos, imageCoord); -} - -void ZVision::onMouseUp(const Common::Point &pos) { - _menu->onMouseUp(pos); - - Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); - _scriptManager->onMouseUp(pos, imageCoord); -} - void ZVision::onMouseMove(const Common::Point &pos) { _menu->onMouseMove(pos); Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index fc765f0bfb..7c124b6eca 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -51,6 +51,7 @@ ScriptManager::~ScriptManager() { cleanScriptScope(world); cleanScriptScope(room); cleanScriptScope(nodeview); + _controlEvents.clear(); } void ScriptManager::initialize() { @@ -66,6 +67,8 @@ void ScriptManager::initialize() { parseScrFile("universe.scr", universe); changeLocation('g', 'a', 'r', 'y', 0); + + _controlEvents.clear(); } void ScriptManager::update(uint deltaTimeMillis) { @@ -151,6 +154,32 @@ void ScriptManager::updateNodes(uint deltaTimeMillis) { void ScriptManager::updateControls(uint deltaTimeMillis) { if (!_activeControls) return; + + // Process only one event + if (!_controlEvents.empty()) { + Common::Event _event = _controlEvents.front(); + Common::Point imageCoord; + switch (_event.type) { + case Common::EVENT_LBUTTONDOWN: + imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); + onMouseDown(_event.mouse, imageCoord); + break; + case Common::EVENT_LBUTTONUP: + imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); + onMouseUp(_event.mouse, imageCoord); + break; + case Common::EVENT_KEYDOWN: + onKeyDown(_event.kbd); + break; + case Common::EVENT_KEYUP: + onKeyUp(_event.kbd); + break; + default: + break; + } + _controlEvents.pop_front(); + } + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) (*iter)->process(deltaTimeMillis); } @@ -693,6 +722,10 @@ Location ScriptManager::getCurrentLocation() const { return location; } +void ScriptManager::addEvent(Common::Event event) { + _controlEvents.push_back(event); +} + ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val): _sc_man(sc_man) { value = 0; diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 8ec364b35f..316b50ab26 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -29,6 +29,7 @@ #include "common/hashmap.h" #include "common/queue.h" +#include "common/events.h" namespace Common { @@ -111,6 +112,7 @@ typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; typedef Common::HashMap StateMap; typedef Common::List SideFXList; +typedef Common::List EventList; class ScriptManager { public: @@ -152,6 +154,8 @@ private: /** Holds the currently active controls */ ControlList *_activeControls; + EventList _controlEvents; + script_scope universe; script_scope world; script_scope room; @@ -192,6 +196,8 @@ public: void killSideFx(uint32 key); void killSideFxType(SideFX::SideFXType type); + void addEvent(Common::Event); + /** * Called when LeftMouse is pushed. * diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index db2c646fda..57e7339da6 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -179,8 +179,6 @@ private: /** Called every frame from ZVision::run() to process any events from EventMan */ void processEvents(); - void onMouseDown(const Common::Point &pos); - void onMouseUp(const Common::Point &pos); void onMouseMove(const Common::Point &pos); void updateRotation(); }; -- cgit v1.2.3 From b9103b8d19a5da396d217e8d9bcc5c1502b89837 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 19:09:08 +0000 Subject: ZVISION: Implement functions for system messaging. --- engines/zvision/graphics/render_manager.cpp | 15 +++++++ engines/zvision/graphics/render_manager.h | 1 + engines/zvision/zvision.cpp | 65 +++++++++++++++++++++++++++++ engines/zvision/zvision.h | 4 ++ 4 files changed, 85 insertions(+) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index f3b01b7e30..c89444df13 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -729,6 +729,21 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { return _subid; } +uint16 RenderManager::createSubArea() { + _subid++; + + oneSub sub; + sub.redraw = false; + sub.timer = -1; + sub.todelete = false; + sub._r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom); + sub._r.translate(-_workingWindow.left, -_workingWindow.top); + + _subsList[_subid] = sub; + + return _subid; +} + void RenderManager::deleteSubArea(uint16 id) { if (_subsList.contains(id)) _subsList[id].todelete = true; diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index ca2e715e8a..b4c6c76a6e 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -233,6 +233,7 @@ public: void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); uint16 createSubArea(const Common::Rect &area); + uint16 createSubArea(); void deleteSubArea(uint16 id); void deleteSubArea(uint16 id, int16 delay); void updateSubArea(uint16 id, const Common::String &txt); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 0eb14257f2..24e15e0c86 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -212,6 +212,71 @@ Common::Error ZVision::run() { return Common::kNoError; } +bool ZVision::askQuestion(const Common::String &str) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _clock.stop(); + + int result = 0; + + while (result == 0) { + Common::Event evnt; + while (_eventMan->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN) { + switch (evnt.kbd.keycode) { + case Common::KEYCODE_y: + result = 2; + break; + case Common::KEYCODE_n: + result = 1; + break; + default: + break; + } + } + } + _system->updateScreen(); + _system->delayMillis(66); + } + _renderManager->deleteSubArea(msgid); + _clock.start(); + return result == 2; +} + +void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _clock.stop(); + + uint32 stop_time = _system->getMillis() + milsecs; + while (_system->getMillis() < stop_time) { + Common::Event evnt; + while (_eventMan->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN && + (evnt.kbd.keycode == Common::KEYCODE_SPACE || + evnt.kbd.keycode == Common::KEYCODE_RETURN || + evnt.kbd.keycode == Common::KEYCODE_ESCAPE)) + break; + } + _system->updateScreen(); + _system->delayMillis(66); + } + _renderManager->deleteSubArea(msgid); + _clock.start(); +} + +void ZVision::timedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, str); + _renderManager->processSubs(0); + _renderManager->renderBackbufferToScreen(); + _renderManager->deleteSubArea(msgid, milsecs); +} + void ZVision::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 57e7339da6..e5d32bf678 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -167,6 +167,10 @@ public: Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); + bool askQuestion(const Common::String &str); + void delayedMessage(const Common::String &str, uint16 milsecs); + void timedMessage(const Common::String &str, uint16 milsecs); + void setRenderDelay(uint); bool canRender(); -- cgit v1.2.3 From 57857a1d768fc9b226326efe2294f73e847c816e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:35:50 +0000 Subject: ZVISION: Controls now can return type of control. --- engines/zvision/scripting/control.h | 23 +++++++++++++++++++++- .../zvision/scripting/controls/input_control.cpp | 2 +- .../zvision/scripting/controls/lever_control.cpp | 2 +- .../scripting/controls/push_toggle_control.cpp | 2 +- .../zvision/scripting/controls/slot_control.cpp | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 93ad5f5df1..6ec47c6455 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -39,14 +39,33 @@ class ZVision; class Control { public: + + enum ControlType { + CONTROL_UNKNOW, + CONTROL_INPUT, + CONTROL_PUSHTGL, + CONTROL_SLOT, + CONTROL_LEVER, + CONTROL_SAVE, + CONTROL_SAFE, + CONTROL_FIST, + CONTROL_TITLER, + CONTROL_HOTMOV, + CONTROL_PAINT + }; + Control() : _engine(0), _key(0) {} - Control(ZVision *engine, uint32 key) : _engine(engine), _key(key) {} + Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type) {} virtual ~Control() {} uint32 getKey() { return _key; } + ControlType getType() { + return _type; + } + virtual void focus() {} virtual void unfocus() {} /** @@ -109,6 +128,8 @@ public: static void parseFlatControl(ZVision *engine); static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream); static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream); +private: + ControlType _type; }; // TODO: Implement InputControl diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index ba1b634d42..0bca01bf47 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -38,7 +38,7 @@ namespace ZVision { InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key), + : Control(engine, key, CONTROL_INPUT), _nextTabstop(0), _focused(false), _textChanged(false), diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 7e3ee775fb..87fbb433dd 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -42,7 +42,7 @@ namespace ZVision { LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key), + : Control(engine, key, CONTROL_LEVER), _frameInfo(0), _frameCount(0), _startFrame(0), diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 16cd971ad5..2f4af0d843 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -35,7 +35,7 @@ namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key), + : Control(engine, key, CONTROL_PUSHTGL), _countTo(2), _event(Common::EVENT_LBUTTONUP) { // Loop until we find the closing brace diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index c85b02b3cd..f78061ac13 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -36,7 +36,7 @@ namespace ZVision { SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key) { + : Control(engine, key, CONTROL_SLOT) { _rendered_item = 0; _bkg = NULL; -- cgit v1.2.3 From 9dd9bfce808cacb90bdea1ee7cc371e698c1eca9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:38:11 +0000 Subject: ZVISION: String manager only load text lines without parsing text styles. --- engines/zvision/text/string_manager.cpp | 25 +++++++++++++++++++++++-- engines/zvision/text/string_manager.h | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index cadfbf1f49..114f298505 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -22,6 +22,8 @@ #include "common/scummsys.h" +#include "zvision/zvision.h" +#include "zvision/core/search_manager.h" #include "zvision/text/string_manager.h" #include "zvision/fonts/truetype_font.h" @@ -49,10 +51,25 @@ StringManager::~StringManager() { void StringManager::initialize(ZVisionGameId gameId) { if (gameId == GID_NEMESIS) { // TODO: Check this hardcoded filename against all versions of Nemesis - parseStrFile("nemesis.str"); + loadStrFile("nemesis.str"); } else if (gameId == GID_GRANDINQUISITOR) { // TODO: Check this hardcoded filename against all versions of Grand Inquisitor - parseStrFile("inquis.str"); + loadStrFile("inquis.str"); + } +} + +void StringManager::loadStrFile(const Common::String &fileName) { + Common::File file; + if (!_engine->getSearchManager()->openFile(file, fileName)) { + warning("%s does not exist. String parsing failed", fileName.c_str()); + return; + } + uint lineNumber = 0; + while (!file.eos()) { + _lines[lineNumber] = readWideLine(file); + + lineNumber++; + assert(lineNumber <= NUM_TEXT_LINES); } } @@ -252,4 +269,8 @@ StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) { return _inGameText[stringNumber].fragments.front().style; } +const Common::String StringManager::getTextLine(uint stringNumber) { + return _lines[stringNumber]; +} + } // End of namespace ZVision diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index af8324b890..e226fbeae8 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -63,6 +63,8 @@ private: private: ZVision *_engine; + Common::String _lines[NUM_TEXT_LINES]; + InGameText _inGameText[NUM_TEXT_LINES]; Common::HashMap _fonts; @@ -71,8 +73,10 @@ private: public: void initialize(ZVisionGameId gameId); StringManager::TextStyle getTextStyle(uint stringNumber); + const Common::String getTextLine(uint stringNumber); private: + void loadStrFile(const Common::String &fileName); void parseStrFile(const Common::String &fileName); void parseTag(const Common::String &tagString, uint lineNumber); -- cgit v1.2.3 From bc4b0b5bf6145be02071410e044c9f27040c856b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:39:02 +0000 Subject: ZVISION: Implement code for getControl --- engines/zvision/scripting/script_manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 7c124b6eca..25fa13866a 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -351,7 +351,9 @@ void ScriptManager::unsetStateFlag(uint32 key, uint value) { } Control *ScriptManager::getControl(uint32 key) { - + for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) + if ((*iter)->getKey() == key) + return *iter; return nullptr; } -- cgit v1.2.3 From ce248644b813d7a722f2c6250f723331fd119e55 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:41:49 +0000 Subject: ZVISION: Fix drawTxt y-position. --- engines/zvision/text/text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index cad2723d13..efb0fb42f9 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -318,7 +318,7 @@ int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graph w = font.getStringWidth(txt); - drawTxtWithJustify(txt, font, clr, dst, fnt_stl.size, fnt_stl.justify); + drawTxtWithJustify(txt, font, clr, dst, 0, fnt_stl.justify); return w; } -- cgit v1.2.3 From 7f2d4d9a6c72b4f0e88c86d5fe04eb059ec107a8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:44:10 +0000 Subject: ZVISION: Implement fuctionality for change focus without of calling focus/unfocus --- engines/zvision/scripting/script_manager.cpp | 4 ++++ engines/zvision/scripting/script_manager.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 25fa13866a..ada06a5b51 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -373,6 +373,10 @@ void ScriptManager::focusControl(uint32 key) { _currentlyFocusedControl = key; } +void ScriptManager::setFocusControlKey(uint32 key) { + _currentlyFocusedControl = key; +} + void ScriptManager::addSideFX(SideFX *fx) { _activeSideFx.push_back(fx); } diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 316b50ab26..6cc957874b 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -188,6 +188,8 @@ public: void disableControl(uint32 key); void focusControl(uint32 key); + // Only change focus control without call focus/unfocus. + void setFocusControlKey(uint32 key); void addSideFX(SideFX *fx); SideFX *getSideFX(uint32 key); -- cgit v1.2.3 From 5a870100bd62ce3913bb4a3adb6bd12ce97f1675 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 12 Jul 2014 21:52:56 +0000 Subject: ZVISION: Bool results for keyUp and keyDown events for controls. --- engines/zvision/scripting/control.h | 4 ++-- engines/zvision/scripting/controls/input_control.cpp | 5 +++-- engines/zvision/scripting/controls/input_control.h | 2 +- engines/zvision/scripting/script_manager.cpp | 6 ++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 6ec47c6455..ac245054ee 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -101,13 +101,13 @@ public: * * @param keycode The key that was pressed */ - virtual void onKeyDown(Common::KeyState keyState) {} + virtual bool onKeyDown(Common::KeyState keyState) {return false;} /** * Called when a key is released. Default is NOP. * * @param keycode The key that was pressed */ - virtual void onKeyUp(Common::KeyState keyState) {} + virtual bool onKeyUp(Common::KeyState keyState) {return false;} /** * Processes the node given the deltaTime since last frame. Default is NOP. * diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 0bca01bf47..bebf3fae11 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -98,9 +98,9 @@ bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: return false; } -void InputControl::onKeyDown(Common::KeyState keyState) { +bool InputControl::onKeyDown(Common::KeyState keyState) { if (!_focused) { - return; + return false; } if (keyState.keycode == Common::KEYCODE_BACKSPACE) { @@ -119,6 +119,7 @@ void InputControl::onKeyDown(Common::KeyState keyState) { _textChanged = true; } } + return false; } bool InputControl::process(uint32 deltaTimeInMillis) { diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 6fcdb2ca54..91fcd364cd 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -55,7 +55,7 @@ public: _focused = false; } bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - void onKeyDown(Common::KeyState keyState); + bool onKeyDown(Common::KeyState keyState); bool process(uint32 deltaTimeInMillis); }; diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index ada06a5b51..53fa5832d9 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -471,7 +471,8 @@ void ScriptManager::onKeyDown(Common::KeyState keyState) { if (!_activeControls) return; for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onKeyDown(keyState); + if ((*iter)->onKeyDown(keyState)) + return; } } @@ -479,7 +480,8 @@ void ScriptManager::onKeyUp(Common::KeyState keyState) { if (!_activeControls) return; for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { - (*iter)->onKeyUp(keyState); + if ((*iter)->onKeyUp(keyState)) + return; } } -- cgit v1.2.3 From 563d83701313fcd71ac7090deb61e7f3910e6070 Mon Sep 17 00:00:00 2001 From: Joel Teichroeb Date: Wed, 22 Jan 2014 14:23:30 -0800 Subject: ANDROID: Modernize build system Written originally by @Botje for ResidualVM --- backends/platform/android/android.mk | 193 +++++++++-------------------------- dists/android/custom_rules.xml | 31 ++++++ dists/android/jni/Android.mk | 9 ++ dists/android/project.properties | 11 ++ dists/android/res/layout/main.xml | 4 - 5 files changed, 102 insertions(+), 146 deletions(-) create mode 100644 dists/android/custom_rules.xml create mode 100644 dists/android/jni/Android.mk create mode 100644 dists/android/project.properties diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 69aa9d8303..f9a2bc9813 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -2,183 +2,92 @@ # These must be incremented for each market upload ANDROID_VERSIONCODE = 6 -ANDROID_PLUGIN_VERSIONCODE = 6 -JAVA_FILES = \ - ScummVM.java \ - ScummVMEvents.java \ - ScummVMEventsHoneycomb.java \ - ScummVMApplication.java \ - ScummVMActivity.java \ - EditableSurfaceView.java \ - MouseHelper.java \ - Unpacker.java +ANDROID_TARGET_VERSION = 14 -JAVA_FILES_PLUGIN = \ - PluginProvider.java - -JAVA_FILES_GEN = \ - Manifest.java \ - R.java +NDK_BUILD = $(ANDROID_NDK)/ndk-build +SDK_ANDROID = $(ANDROID_SDK)/tools/android PATH_DIST = $(srcdir)/dists/android PATH_RESOURCES = $(PATH_DIST)/res PORT_DISTFILES = $(PATH_DIST)/README.Android +DIST_JAVA_SRC_DIR = $(srcdir)/backends/platform/android/org RESOURCES = \ - $(PATH_RESOURCES)/values/strings.xml \ - $(PATH_RESOURCES)/values/margins.xml \ - $(PATH_RESOURCES)/values-television/margins.xml \ - $(PATH_RESOURCES)/layout/main.xml \ - $(PATH_RESOURCES)/layout/splash.xml \ - $(PATH_RESOURCES)/drawable/gradient.xml \ - $(PATH_RESOURCES)/drawable/scummvm.png \ - $(PATH_RESOURCES)/drawable/scummvm_big.png \ - $(PATH_RESOURCES)/drawable-xhdpi/ouya_icon.png - -PLUGIN_RESOURCES = \ - $(PATH_RESOURCES)/values/strings.xml \ - $(PATH_RESOURCES)/drawable/scummvm.png - -# FIXME: find/mark plugin entry points and add all this back again: -#LDFLAGS += -Wl,--gc-sections -#CXXFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden - -AAPT = $(ANDROID_SDK)/$(ANDROID_BTOOLS)/aapt -ADB = $(ANDROID_SDK)/platform-tools/adb -DX = $(ANDROID_SDK)/$(ANDROID_BTOOLS)/dx -APKBUILDER = java -Xmx128M -classpath $(ANDROID_SDK)/tools/lib/sdklib.jar com.android.sdklib.build.ApkBuilderMain -JAVAC ?= javac -JAVACFLAGS = -source 1.5 -target 1.5 - -ANDROID_JAR = $(ANDROID_SDK)/platforms/android-14/android.jar + $(PATH_BUILD_RES)/values/strings.xml \ + $(PATH_BUILD_RES)/values-television/margins.xml \ + $(PATH_BUILD_RES)/layout/main.xml \ + $(PATH_BUILD_RES)/layout/splash.xml \ + $(PATH_BUILD_RES)/drawable/gradient.xml \ + $(PATH_BUILD_RES)/drawable/scummvm.png \ + $(PATH_BUILD_RES)/drawable/scummvm_big.png \ + $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png + +DIST_ANDROID_MK = $(PATH_DIST)/jni/Android.mk +DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml PATH_BUILD = ./build.tmp PATH_BUILD_ASSETS = $(PATH_BUILD)/assets -PATH_BUILD_CLASSES_MAIN_TOP = $(PATH_BUILD)/classes.main -PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin - -PATH_STAGE_PREFIX = build.stage -PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main - -PATH_REL = org/scummvm/scummvm -PATH_SRC_TOP = $(srcdir)/backends/platform/android -PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL) - -PATH_GEN_TOP = $(PATH_BUILD)/java -PATH_GEN = $(PATH_GEN_TOP)/$(PATH_REL) -PATH_CLASSES_MAIN = $(PATH_BUILD_CLASSES_MAIN_TOP)/$(PATH_REL) -PATH_CLASSES_PLUGIN = $(PATH_BUILD_CLASSES_PLUGIN_TOP)/$(PATH_REL) +PATH_BUILD_RES = $(PATH_BUILD)/res +PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/mylib/armeabi/libscummvm.so FILE_MANIFEST_SRC = $(srcdir)/dists/android/AndroidManifest.xml FILE_MANIFEST = $(PATH_BUILD)/AndroidManifest.xml -FILE_DEX = $(PATH_BUILD)/classes.dex -FILE_DEX_PLUGIN = $(PATH_BUILD)/plugins/classes.dex -FILE_RESOURCES = resources.ap_ -FILE_RESOURCES_MAIN = $(PATH_BUILD)/$(FILE_RESOURCES) - -SRC_GEN = $(addprefix $(PATH_GEN)/, $(JAVA_FILES_GEN)) - -CLASSES_MAIN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES:%.java=%.class)) -CLASSES_GEN = $(addprefix $(PATH_CLASSES_MAIN)/, $(JAVA_FILES_GEN:%.java=%.class)) -CLASSES_PLUGIN = $(addprefix $(PATH_CLASSES_PLUGIN)/, $(JAVA_FILES_PLUGIN:%.java=%.class)) -APK_MAIN = scummvm.apk +APK_MAIN = ScummVM-debug.apk +APK_MAIN_RELEASE = ScummVM-release-unsigned.apk APK_PLUGINS = $(patsubst plugins/lib%.so, scummvm-engine-%.apk, $(PLUGINS)) -$(FILE_MANIFEST): $(FILE_MANIFEST_SRC) +$(FILE_MANIFEST): $(FILE_MANIFEST_SRC) | $(PATH_BUILD) @$(MKDIR) -p $(@D) sed "s/@ANDROID_VERSIONCODE@/$(ANDROID_VERSIONCODE)/" < $< > $@ -$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR) - @$(MKDIR) -p $(PATH_GEN_TOP) - $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR) - -$(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN) +$(PATH_BUILD)/res/%: $(PATH_DIST)/res/% | $(PATH_BUILD) @$(MKDIR) -p $(@D) - $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $< + $(CP) $< $@ -$(PATH_CLASSES_MAIN)/%.class: $(PATH_SRC)/%.java $(SRC_GEN) +$(PATH_BUILD)/libs/%: $(PATH_DIST)/libs/% | $(PATH_BUILD) @$(MKDIR) -p $(@D) - $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP):$(PATH_GEN_TOP) -d $(PATH_BUILD_CLASSES_MAIN_TOP) -bootclasspath $(ANDROID_JAR) $< + $(CP) $< $@ -$(PATH_CLASSES_PLUGIN)/%.class: $(PATH_SRC)/%.java - @$(MKDIR) -p $(@D) - $(JAVAC) $(JAVACFLAGS) -cp $(PATH_SRC_TOP) -d $(PATH_BUILD_CLASSES_PLUGIN_TOP) -bootclasspath $(ANDROID_JAR) $< +$(PATH_BUILD_ASSETS): $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(DIST_FILES_SHADERS) $(DIST_BUILD_XML) | $(PATH_BUILD) + $(INSTALL) -d $(PATH_BUILD_ASSETS) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/ + $(INSTALL) -d $(PATH_BUILD)/jni + $(INSTALL) -c -m 644 $(DIST_ANDROID_MK) $(PATH_BUILD)/jni + $(INSTALL) -c -m 644 $(DIST_BUILD_XML) $(PATH_BUILD) -$(FILE_DEX): $(CLASSES_MAIN) $(CLASSES_GEN) - $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_MAIN_TOP) +$(PATH_BUILD): $(DIST_ANDROID_MK) + $(MKDIR) -p $(PATH_BUILD) $(PATH_BUILD)/res + $(MKDIR) -p $(PATH_BUILD)/libs -$(FILE_DEX_PLUGIN): $(CLASSES_PLUGIN) - @$(MKDIR) -p $(@D) - $(DX) --dex --output=$@ $(PATH_BUILD_CLASSES_PLUGIN_TOP) +$(PATH_BUILD_LIBSCUMMVM): libscummvm.so | $(PATH_BUILD) + $(INSTALL) -c -m 644 libscummvm.so $(PATH_BUILD) + $(STRIP) $(PATH_BUILD)/libscummvm.so + cd $(PATH_BUILD); $(NDK_BUILD) -$(PATH_BUILD)/%/AndroidManifest.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml - @$(MKDIR) -p $(@D) - $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-manifest.xml $(ANDROID_PLUGIN_VERSIONCODE) $@ +$(PATH_BUILD_RES): $(RESOURCES) | $(PATH_BUILD) -$(PATH_STAGE_PREFIX).%/res/values/strings.xml: $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $(PATH_DIST)/plugin-manifest.xml - @$(MKDIR) -p $(@D) - $(PATH_DIST)/mkplugin.sh $(srcdir)/configure $* $(PATH_DIST)/plugin-strings.xml $(ANDROID_PLUGIN_VERSIONCODE) $@ +setupapk: $(FILE_MANIFEST) $(PATH_BUILD_RES) $(PATH_BUILD_ASSETS) $(PATH_BUILD_LIBSCUMMVM) | $(PATH_BUILD) + $(SDK_ANDROID) update project -p $(PATH_BUILD) -t android-$(ANDROID_TARGET_VERSION) -n ScummVM -$(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scummvm.png - @$(MKDIR) -p $(@D) - $(CP) $< $@ +$(APK_MAIN): setupapk | $(PATH_BUILD) + (cd $(PATH_BUILD); ant debug -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))") + $(CP) $(PATH_BUILD)/bin/ScummVM-debug.apk $@ -$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) - $(INSTALL) -d $(PATH_BUILD_ASSETS) - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/ - work_dir=`pwd`; \ - for i in $(PATH_BUILD_ASSETS)/*.zip; do \ - echo "recompress $$i"; \ - cd "$$work_dir"; \ - $(RM) -rf $(PATH_BUILD_ASSETS)/tmp; \ - $(MKDIR) $(PATH_BUILD_ASSETS)/tmp; \ - unzip -q $$i -d $(PATH_BUILD_ASSETS)/tmp; \ - cd $(PATH_BUILD_ASSETS)/tmp; \ - zip -r ../`basename $$i` *; \ - done - @$(RM) -rf $(PATH_BUILD_ASSETS)/tmp - $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR) -F $@ - -$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR) - $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR) -F $@ - -# Package installer won't delete old libscummvm.so on upgrade so -# replace it with a zero size file -$(APK_MAIN): $(EXECUTABLE) $(FILE_RESOURCES_MAIN) $(FILE_DEX) - $(INSTALL) -d $(PATH_STAGE_MAIN)/common/lib/armeabi - touch $(PATH_STAGE_MAIN)/common/lib/armeabi/libscummvm.so - $(INSTALL) -d $(PATH_STAGE_MAIN)/common/mylib/armeabi - $(INSTALL) -c -m 644 libscummvm.so $(PATH_STAGE_MAIN)/common/mylib/armeabi/ - $(STRIP) $(PATH_STAGE_MAIN)/common/mylib/armeabi/libscummvm.so - $(APKBUILDER) $@ -z $(FILE_RESOURCES_MAIN) -f $(FILE_DEX) -rf $(PATH_STAGE_MAIN)/common || { $(RM) $@; exit 1; } - -scummvm-engine-%.apk: plugins/lib%.so $(PATH_BUILD)/%/$(FILE_RESOURCES) $(FILE_DEX_PLUGIN) - $(INSTALL) -d $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/ - $(INSTALL) -c -m 644 plugins/lib$*.so $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/ - $(STRIP) $(PATH_STAGE_PREFIX).$*/apk/mylib/armeabi/lib$*.so - $(APKBUILDER) $@ -z $(PATH_BUILD)/$*/$(FILE_RESOURCES) -f $(FILE_DEX_PLUGIN) -rf $(PATH_STAGE_PREFIX).$*/apk || { $(RM) $@; exit 1; } - -all: $(APK_MAIN) $(APK_PLUGINS) +$(APK_MAIN_RELEASE): setupapk | $(PATH_BUILD) + (cd $(PATH_BUILD); ant release -Dsource.dir="$(realpath $(DIST_JAVA_SRC_DIR))") + $(CP) $(PATH_BUILD)/bin/ScummVM-release-unsigned.apk $@ + +all: $(APK_MAIN) clean: androidclean androidclean: - @$(RM) -rf $(PATH_BUILD) $(PATH_STAGE_PREFIX).* *.apk release - -# remove debugging signature -release/%.apk: %.apk - @$(MKDIR) -p $(@D) - @$(RM) $@ - $(CP) $< $@.tmp - zip -d $@.tmp META-INF/\* - jarsigner $(JARSIGNER_FLAGS) $@.tmp release - zipalign 4 $@.tmp $@ - $(RM) $@.tmp + @$(RM) -rf $(PATH_BUILD) *.apk release -androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS)) +androidrelease: $(APK_MAIN_RELEASE) androidtestmain: $(APK_MAIN) $(ADB) install -r $(APK_MAIN) @@ -198,4 +107,4 @@ androiddistdebug: all sed 's/$$/\r/' < $$i > debug/`basename $$i`.txt; \ done -.PHONY: androidrelease androidtest +.PHONY: androidrelease androidtest $(PATH_BUILD_SRC) diff --git a/dists/android/custom_rules.xml b/dists/android/custom_rules.xml new file mode 100644 index 0000000000..5ed81b7273 --- /dev/null +++ b/dists/android/custom_rules.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/dists/android/jni/Android.mk b/dists/android/jni/Android.mk new file mode 100644 index 0000000000..d5b398412f --- /dev/null +++ b/dists/android/jni/Android.mk @@ -0,0 +1,9 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +APP_ABI := armeabi +LOCAL_MODULE := scummvm +LOCAL_SRC_FILES := ../libscummvm.so + +include $(PREBUILT_SHARED_LIBRARY) diff --git a/dists/android/project.properties b/dists/android/project.properties new file mode 100644 index 0000000000..730e911f2f --- /dev/null +++ b/dists/android/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-14 diff --git a/dists/android/res/layout/main.xml b/dists/android/res/layout/main.xml index 31aa345cc7..8b0d515d62 100644 --- a/dists/android/res/layout/main.xml +++ b/dists/android/res/layout/main.xml @@ -9,8 +9,4 @@ android:keepScreenOn="true" android:focusable="true" android:focusableInTouchMode="true" - android:layout_marginTop="@dimen/verticalMargin" - android:layout_marginLeft="@dimen/horizontalMargin" - android:layout_marginBottom="@dimen/verticalMargin" - android:layout_marginRight="@dimen/horizontalMargin" /> -- cgit v1.2.3 From 8480f53d6005b5873964ca1015644ae6925e6ede Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 Jul 2014 21:02:28 -0400 Subject: ACCESS: Initial engine skeleton --- engines/access/access.cpp | 61 ++++++++++++++++ engines/access/access.h | 94 ++++++++++++++++++++++++ engines/access/configure.engine | 3 + engines/access/debugger.cpp | 33 +++++++++ engines/access/debugger.h | 45 ++++++++++++ engines/access/detection.cpp | 146 ++++++++++++++++++++++++++++++++++++++ engines/access/detection_tables.h | 47 ++++++++++++ engines/access/module.mk | 14 ++++ 8 files changed, 443 insertions(+) create mode 100644 engines/access/access.cpp create mode 100644 engines/access/access.h create mode 100644 engines/access/configure.engine create mode 100644 engines/access/debugger.cpp create mode 100644 engines/access/debugger.h create mode 100644 engines/access/detection.cpp create mode 100644 engines/access/detection_tables.h create mode 100644 engines/access/module.mk diff --git a/engines/access/access.cpp b/engines/access/access.cpp new file mode 100644 index 0000000000..f3615e10da --- /dev/null +++ b/engines/access/access.cpp @@ -0,0 +1,61 @@ +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "common/debug-channels.h" +#include "common/events.h" +#include "engines/util.h" +#include "access/access.h" + +namespace Access { + +AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : + _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { + _debugger = nullptr; +} + +AccessEngine::~AccessEngine() { + delete _debugger; +} + +void AccessEngine::initialize() { + // Set up debug channels + DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level"); + DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts"); + DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling"); + + _debugger = new Debugger(this); +} + +Common::Error AccessEngine::run() { + initGraphics(320, 200, false); + initialize(); + + return Common::kNoError; +} + +int AccessEngine::getRandomNumber(int maxNumber) { + return _randomSource.getRandomNumber(maxNumber); +} + +} // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h new file mode 100644 index 0000000000..f46cf0094c --- /dev/null +++ b/engines/access/access.h @@ -0,0 +1,94 @@ +/* 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 ACCESS_ACCESS_H +#define ACCESS_ACCESS_H + +#include "common/scummsys.h" +#include "common/system.h" +#include "common/error.h" +#include "common/random.h" +#include "common/util.h" +#include "engines/engine.h" +#include "graphics/surface.h" +#include "access/debugger.h" + +/** + * This is the namespace of the Access engine. + * + * Status of this engine: In Development + * + * Games using this engine: + * - Amazon: Guardians of Eden + */ +namespace Access { + +#define DEBUG_BASIC 1 +#define DEBUG_INTERMEDIATE 2 +#define DEBUG_DETAILED 3 + +enum AccessDebugChannels { + kDebugPath = 1 << 0, + kDebugScripts = 1 << 1, + kDebugGraphics = 1 << 2 +}; + +enum { + GType_Amazon = 0, + GType_MeanStreets = 1 +}; + +struct AccessGameDescription; + + +class AccessEngine : public Engine { +private: + const AccessGameDescription *_gameDescription; + Common::RandomSource _randomSource; + + /** + * Handles basic initialisation + */ + void initialize(); +protected: + // Engine APIs + virtual Common::Error run(); + virtual bool hasFeature(EngineFeature f) const; +public: + Debugger *_debugger; +public: + AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); + virtual ~AccessEngine(); + + uint32 getFeatures() const; + Common::Language getLanguage() const; + Common::Platform getPlatform() const; + uint16 getVersion() const; + uint32 getGameID() const; + uint32 getGameFeatures() const; + + int getRandomNumber(int maxNumber); +}; + +} // End of namespace Access + +#endif /* ACCESS_ACCESS_H */ diff --git a/engines/access/configure.engine b/engines/access/configure.engine new file mode 100644 index 0000000000..b1defce946 --- /dev/null +++ b/engines/access/configure.engine @@ -0,0 +1,3 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine access "Access" no diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp new file mode 100644 index 0000000000..e92e3402ac --- /dev/null +++ b/engines/access/debugger.cpp @@ -0,0 +1,33 @@ +/* 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 "common/file.h" +#include "access/access.h" +#include "access/debugger.h" + +namespace Access { + +Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); +} + +} // End of namespace Access diff --git a/engines/access/debugger.h b/engines/access/debugger.h new file mode 100644 index 0000000000..dcf49c4ecd --- /dev/null +++ b/engines/access/debugger.h @@ -0,0 +1,45 @@ +/* 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 ACCESS_DEBUGGER_H +#define ACCESS_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" + +namespace Access { + +class AccessEngine; + +class Debugger : public GUI::Debugger { +private: + AccessEngine *_vm; +protected: +public: +public: + Debugger(AccessEngine *vm); + virtual ~Debugger() {} +}; + +} // End of namespace Access + +#endif /* ACCESS_DEBUGGER_H */ diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp new file mode 100644 index 0000000000..aca594d60d --- /dev/null +++ b/engines/access/detection.cpp @@ -0,0 +1,146 @@ +/* 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 "access/access.h" + +#include "base/plugins.h" +#include "common/savefile.h" +#include "common/str-array.h" +#include "common/memstream.h" +#include "engines/advancedDetector.h" +#include "common/system.h" +#include "graphics/colormasks.h" +#include "graphics/surface.h" + +#define MAX_SAVES 99 + +namespace Access { + +struct AccessGameDescription { + ADGameDescription desc; + + int gameID; + uint32 features; +}; + +uint32 AccessEngine::getGameID() const { + return _gameDescription->gameID; +} + +uint32 AccessEngine::getGameFeatures() const { + return _gameDescription->features; +} + +uint32 AccessEngine::getFeatures() const { + return _gameDescription->desc.flags; +} + +Common::Language AccessEngine::getLanguage() const { + return _gameDescription->desc.language; +} + +Common::Platform AccessEngine::getPlatform() const { + return _gameDescription->desc.platform; +} + +} // End of namespace Access + +static const PlainGameDescriptor AccessGames[] = { + {"Access", "Access"}, + {"amazon", "Amazon: Guardians of Eden"}, + {0, 0} +}; + +#include "access/detection_tables.h" + +class AccessMetaEngine : public AdvancedMetaEngine { +public: + AccessMetaEngine() : AdvancedMetaEngine(Access::gameDescriptions, sizeof(Access::AccessGameDescription), AccessGames) { + _maxScanDepth = 3; + } + + virtual const char *getName() const { + return "Access Engine"; + } + + virtual const char *getOriginalCopyright() const { + return "Access (c)"; + } + + virtual bool hasFeature(MetaEngineFeature f) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; + virtual int getMaximumSaveSlot() const; + virtual void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; +}; + +bool AccessMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); +} + +bool Access::AccessEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); +} + +bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + const Access::AccessGameDescription *gd = (const Access::AccessGameDescription *)desc; + if (gd) { + *engine = new Access::AccessEngine(syst, gd); + } + return gd != 0; +} + +SaveStateList AccessMetaEngine::listSaves(const char *target) const { + SaveStateList saveList; + + return saveList; +} + +int AccessMetaEngine::getMaximumSaveSlot() const { + return MAX_SAVES; +} + +void AccessMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String filename = Common::String::format("%s.%03d", target, slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +SaveStateDescriptor AccessMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + return SaveStateDescriptor(); +} + + +#if PLUGIN_ENABLED_DYNAMIC(ACCESS) + REGISTER_PLUGIN_DYNAMIC(ACCESS, PLUGIN_TYPE_ENGINE, AccessMetaEngine); +#else + REGISTER_PLUGIN_STATIC(ACCESS, PLUGIN_TYPE_ENGINE, AccessMetaEngine); +#endif diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h new file mode 100644 index 0000000000..9100e52e30 --- /dev/null +++ b/engines/access/detection_tables.h @@ -0,0 +1,47 @@ +/* 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. + * + */ + +namespace Access { + +static const AccessGameDescription gameDescriptions[] = { + { + // Amazon Guadians of Eden + { + "amazon", + 0, + { + {"amazon", 0, "00000000000000000000000000000000", 1}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + GType_Amazon, + 0 + }, + + { AD_TABLE_END_MARKER, 0, 0 } +}; + +} // End of namespace Access diff --git a/engines/access/module.mk b/engines/access/module.mk new file mode 100644 index 0000000000..c61ab50fae --- /dev/null +++ b/engines/access/module.mk @@ -0,0 +1,14 @@ +MODULE := engines/access + +MODULE_OBJS := \ + access.o \ + debugger.o \ + detection.o + +# This module can be built as a plugin +ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk -- cgit v1.2.3 From 83f55f737b3eab7be2236de1bf31035024400e43 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 29 Jul 2014 22:49:45 -0400 Subject: ACCESS: Main engine skeleton and events manager --- engines/access/access.cpp | 3 ++ engines/access/access.h | 7 +++ engines/access/events.cpp | 106 ++++++++++++++++++++++++++++++++++++++++++++++ engines/access/events.h | 86 +++++++++++++++++++++++++++++++++++++ engines/access/module.mk | 3 +- 5 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 engines/access/events.cpp create mode 100644 engines/access/events.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f3615e10da..23b8fb9f45 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -32,10 +32,12 @@ namespace Access { AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { _debugger = nullptr; + _events = nullptr; } AccessEngine::~AccessEngine() { delete _debugger; + delete _events; } void AccessEngine::initialize() { @@ -45,6 +47,7 @@ void AccessEngine::initialize() { DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling"); _debugger = new Debugger(this); + _events = new EventsManager(this); } Common::Error AccessEngine::run() { diff --git a/engines/access/access.h b/engines/access/access.h index f46cf0094c..ef9960e007 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -31,6 +31,7 @@ #include "engines/engine.h" #include "graphics/surface.h" #include "access/debugger.h" +#include "access/events.h" /** * This is the namespace of the Access engine. @@ -64,6 +65,11 @@ class AccessEngine : public Engine { private: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; + + Graphics::Surface _buffer1; + Graphics::Surface _buffer2; + Graphics::Surface _vidbuf; + Graphics::Surface _plotBuf; /** * Handles basic initialisation @@ -75,6 +81,7 @@ protected: virtual bool hasFeature(EngineFeature f) const; public: Debugger *_debugger; + EventsManager *_events; public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/events.cpp b/engines/access/events.cpp new file mode 100644 index 0000000000..47908ff1cb --- /dev/null +++ b/engines/access/events.cpp @@ -0,0 +1,106 @@ +/* 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 "common/scummsys.h" +#include "graphics/cursorman.h" +#include "common/events.h" +#include "engines/util.h" +#include "access/access.h" +#include "access/events.h" + +namespace Access { + +EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { + _cursorId = CURSOR_NONE; + _frameCounter = 10; + _priorFrameTime = 0; + _leftButton = false; +} + +EventsManager::~EventsManager() { +} + +void EventsManager::setCursor(CursorType cursorId) { + _cursorId = cursorId; +} + +void EventsManager::showCursor() { + CursorMan.showMouse(true); +} + +void EventsManager::hideCursor() { + CursorMan.showMouse(false); +} + +bool EventsManager::isCursorVisible() { + return CursorMan.isVisible(); +} + +void EventsManager::pollEvents() { + checkForNextFrameCounter(); + + Common::Event event; + while (g_system->getEventManager()->pollEvent(event)) { + // Handle keypress + switch (event.type) { + case Common::EVENT_QUIT: + case Common::EVENT_RTL: + return; + + case Common::EVENT_KEYDOWN: + // Check for debugger + if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger->attach(); + _vm->_debugger->onFrame(); + } + return; + case Common::EVENT_KEYUP: + return; + case Common::EVENT_LBUTTONDOWN: + _leftButton = true; + break; + case Common::EVENT_LBUTTONUP: + _leftButton = false; + break; + default: + break; + } + } +} + +void EventsManager::checkForNextFrameCounter() { + // Check for next game frame + uint32 milli = g_system->getMillis(); + if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { + ++_frameCounter; + _priorFrameTime = milli; + + // Give time to the debugger + _vm->_debugger->onFrame(); + + // Signal the ScummVM debugger + _vm->_debugger->onFrame(); + } +} + +} // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h new file mode 100644 index 0000000000..b30670cdbc --- /dev/null +++ b/engines/access/events.h @@ -0,0 +1,86 @@ +/* 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 ACCESS_EVENTS_H +#define ACCESS_EVENTS_H + +#include "common/scummsys.h" +#include "common/events.h" +#include "common/stack.h" + +namespace Access { + +enum CursorType { CURSOR_NONE = 0 }; + +#define GAME_FRAME_RATE 50 +#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) + +class AccessEngine; + +class EventsManager { +private: + AccessEngine *_vm; + uint32 _frameCounter; + uint32 _priorFrameTime; + Common::Point _mousePos; + + void checkForNextFrameCounter(); +public: + CursorType _cursorId; + bool _leftButton; +public: + /** + * Constructor + */ + EventsManager(AccessEngine *vm); + + /** + * Destructor + */ + ~EventsManager(); + + /** + * Sets the cursor + */ + void setCursor(CursorType cursorId); + + /** + * Show the mouse cursor + */ + void showCursor(); + + /** + * Hide the mouse cursor + */ + void hideCursor(); + + /** + * Returns if the mouse cursor is visible + */ + bool isCursorVisible(); + + void pollEvents(); +}; + +} // End of namespace Access + +#endif /* ACCESS_EVENTS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index c61ab50fae..a6f352f1a5 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -3,7 +3,8 @@ MODULE := engines/access MODULE_OBJS := \ access.o \ debugger.o \ - detection.o + detection.o \ + events.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) -- cgit v1.2.3 From c2451b57bccc2a425a6e1376c2a116df48b1fcc6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Aug 2014 15:21:21 -0400 Subject: ACCESS: Added resources for cursors --- engines/access/module.mk | 3 +- engines/access/resources.cpp | 156 +++++++++++++++++++++++++++++++++++++++++++ engines/access/resources.h | 49 ++++++++++++++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 engines/access/resources.cpp create mode 100644 engines/access/resources.h diff --git a/engines/access/module.mk b/engines/access/module.mk index a6f352f1a5..11630335d1 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -4,7 +4,8 @@ MODULE_OBJS := \ access.o \ debugger.o \ detection.o \ - events.o + events.o \ + resources.o \ # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp new file mode 100644 index 0000000000..4ab3dd9513 --- /dev/null +++ b/engines/access/resources.cpp @@ -0,0 +1,156 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software + * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * + */ + +#include "access/resources.h" + +namespace Access { + +namespace Amazon { + +const byte *CURSORS[10] = { + MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP +}; + +const byte MOUSE0[] = { + 0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, + 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, + 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, + 6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, + 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3, + 3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1 +}; +const byte MOUSE1[] = { + 0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, + 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, + 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00, + 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, + 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, + 0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte MOUSE2[] = { + 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, + 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; +const byte MOUSE3[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00, + 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, + 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSEYE[] = { + 0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, + 0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, + 0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, + 0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, + 0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01, + 0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSHAND[] = { + 0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, + 0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01, + 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02, + 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B, + 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12, + 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, + 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, + 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, + 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, + 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, + 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, + 0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08, + 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, + 0x0D +}; +const byte CURSGET[] = { + 0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07, + 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E, + 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E, + 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D, + 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E, + 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, + 0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07 +}; +const byte CURSCLIMB[] = { + 0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01, + 0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, + 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, + 0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, + 0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D, + 0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03, + 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20, + 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 +}; +const byte CURSTALK[] = { + 0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08, + 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06, + 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F, + 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01, + 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02, + 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08, + 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06, + 0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSHELP[] = { + 0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, + 0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, + 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, + 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, + 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07, + 0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00, + 0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22, + 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 +}; + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h new file mode 100644 index 0000000000..cabaac96a1 --- /dev/null +++ b/engines/access/resources.h @@ -0,0 +1,49 @@ +/* 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 ACCESS_RESOURCES_H +#define ACCESS_RESOURCES_H + +#include "common/scummsys.h" + +namespace Access { + +namespace Amazon { + +extern const byte MOUSE0[]; +extern const byte MOUSE1[]; +extern const byte MOUSE2[]; +extern const byte MOUSE3[]; +extern const byte CURSEYE[]; +extern const byte CURSHAND[]; +extern const byte CURSGET[]; +extern const byte CURSCLIMB[]; +extern const byte CURSTALK[]; +extern const byte CURSHELP[]; + +extern const byte *CURSORS[10]; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_EVENTS_H */ -- cgit v1.2.3 From 4d24209eae5e776fe150775771e7cd70579a518e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Aug 2014 16:20:24 -0400 Subject: ACCESS: Add Amazon floppy detection and skeleton for Amazon engine --- engines/access/access.cpp | 6 ++++- engines/access/access.h | 7 ++---- engines/access/amazon/amazon_game.cpp | 35 ++++++++++++++++++++++++++++ engines/access/amazon/amazon_game.h | 43 +++++++++++++++++++++++++++++++++++ engines/access/detection.cpp | 9 +++++++- engines/access/detection_tables.h | 9 ++++++-- engines/access/module.mk | 1 + 7 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 engines/access/amazon/amazon_game.cpp create mode 100644 engines/access/amazon/amazon_game.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 23b8fb9f45..e4b4159f9b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -51,7 +51,6 @@ void AccessEngine::initialize() { } Common::Error AccessEngine::run() { - initGraphics(320, 200, false); initialize(); return Common::kNoError; @@ -61,4 +60,9 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +void AccessEngine::SETVGA() { + initGraphics(320, 200, false); +} + + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index ef9960e007..5c9207db22 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -53,11 +53,6 @@ enum AccessDebugChannels { kDebugGraphics = 1 << 2 }; -enum { - GType_Amazon = 0, - GType_MeanStreets = 1 -}; - struct AccessGameDescription; @@ -75,6 +70,8 @@ private: * Handles basic initialisation */ void initialize(); + + void SETVGA(); protected: // Engine APIs virtual Common::Error run(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp new file mode 100644 index 0000000000..2b4196a406 --- /dev/null +++ b/engines/access/amazon/amazon_game.cpp @@ -0,0 +1,35 @@ +/* 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 "access/amazon/amazon_game.h" + +namespace Access { + +namespace Amazon { + +AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : + AccessEngine(syst, gameDesc) { +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h new file mode 100644 index 0000000000..1bccd1cedc --- /dev/null +++ b/engines/access/amazon/amazon_game.h @@ -0,0 +1,43 @@ +/* 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 ACCESS_AMAZON_GAME_H +#define ACCESS_AMAZON_GAME_H + +#include "access/access.h" + +namespace Access { + +namespace Amazon { + +class AmazonEngine : public AccessEngine { +public: + AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); + + virtual ~AmazonEngine() {} +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_ACCESS_H */ diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index aca594d60d..ca04a64b0d 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -22,6 +22,7 @@ */ #include "access/access.h" +#include "access/amazon/amazon_game.h" #include "base/plugins.h" #include "common/savefile.h" @@ -114,7 +115,13 @@ bool Access::AccessEngine::hasFeature(EngineFeature f) const { bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { const Access::AccessGameDescription *gd = (const Access::AccessGameDescription *)desc; if (gd) { - *engine = new Access::AccessEngine(syst, gd); + switch (gd->gameID) { + case Access::GType_Amazon: + *engine = new Access::Amazon::AmazonEngine(syst, gd); + break; + default: + error("Unknown game"); + } } return gd != 0; } diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index 9100e52e30..90304290f1 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -22,14 +22,19 @@ namespace Access { +enum { + GType_Amazon = 1, + GType_MeanStreets = 2 +}; + static const AccessGameDescription gameDescriptions[] = { { - // Amazon Guadians of Eden + // Amazon Guadians of Eden - Floppy English { "amazon", 0, { - {"amazon", 0, "00000000000000000000000000000000", 1}, + { "c00.ap", 0, "dcabf69d5a0d911168cb73511ebaead0", 331481 }, AD_LISTEND }, Common::EN_ANY, diff --git a/engines/access/module.mk b/engines/access/module.mk index 11630335d1..f04e51630e 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -6,6 +6,7 @@ MODULE_OBJS := \ detection.o \ events.o \ resources.o \ + amazon\amazon_game.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) -- cgit v1.2.3 From 857f94423fcf4464df44e5b46241f68e33f800a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 1 Aug 2014 21:32:05 -0400 Subject: ACCESS: Implement decoding of game cursors --- engines/access/access.cpp | 27 +++++++++++++++++++++- engines/access/access.h | 20 ++++++++-------- engines/access/events.cpp | 54 +++++++++++++++++++++++++++++++++++++++++--- engines/access/events.h | 11 ++++++++- engines/access/graphics.cpp | 46 +++++++++++++++++++++++++++++++++++++ engines/access/graphics.h | 51 +++++++++++++++++++++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/resources.cpp | 24 +++++++++++++++++++- engines/access/resources.h | 2 ++ 9 files changed, 221 insertions(+), 15 deletions(-) create mode 100644 engines/access/graphics.cpp create mode 100644 engines/access/graphics.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index e4b4159f9b..8aabac2b0b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -33,11 +33,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { _debugger = nullptr; _events = nullptr; + _graphics = nullptr; } AccessEngine::~AccessEngine() { delete _debugger; delete _events; + delete _graphics; } void AccessEngine::initialize() { @@ -48,19 +50,42 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); + _graphics = new GraphicsManager(this); } Common::Error AccessEngine::run() { initialize(); + setVGA(); + _graphics->setPalettte(); + _graphics->setPanel(0); + _events->setCursor(CURSOR_0); + _events->showCursor(); + + dummyLoop(); return Common::kNoError; } +void AccessEngine::dummyLoop() { + // Dummy game loop + while (!shouldQuit()) { + _events->pollEvents(); + g_system->delayMillis(50); + g_system->updateScreen(); + + if (_events->_leftButton) { + CursorType cursorId = _events->getCursor(); + _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_0 : (CursorType)(cursorId + 1)); + } + } + +} + int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::SETVGA() { +void AccessEngine::setVGA() { initGraphics(320, 200, false); } diff --git a/engines/access/access.h b/engines/access/access.h index 5c9207db22..16487ea64f 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -32,6 +32,7 @@ #include "graphics/surface.h" #include "access/debugger.h" #include "access/events.h" +#include "access/graphics.h" /** * This is the namespace of the Access engine. @@ -58,27 +59,28 @@ struct AccessGameDescription; class AccessEngine : public Engine { private: - const AccessGameDescription *_gameDescription; - Common::RandomSource _randomSource; - - Graphics::Surface _buffer1; - Graphics::Surface _buffer2; - Graphics::Surface _vidbuf; - Graphics::Surface _plotBuf; - /** * Handles basic initialisation */ void initialize(); - void SETVGA(); + /** + * Set VGA mode + */ + void setVGA(); + + void dummyLoop(); protected: + const AccessGameDescription *_gameDescription; + Common::RandomSource _randomSource; + // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; public: Debugger *_debugger; EventsManager *_events; + GraphicsManager *_graphics; public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 47908ff1cb..29f6270387 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -23,9 +23,14 @@ #include "common/scummsys.h" #include "graphics/cursorman.h" #include "common/events.h" +#include "common/endian.h" #include "engines/util.h" #include "access/access.h" #include "access/events.h" +#include "access/resources.h" + +#define CURSOR_WIDTH 16 +#define CURSOR_HEIGHT 16 namespace Access { @@ -40,7 +45,49 @@ EventsManager::~EventsManager() { } void EventsManager::setCursor(CursorType cursorId) { + if (cursorId == _cursorId) + return; _cursorId = cursorId; + + // Get a pointer to the mouse data to use, and get the cursor hotspot + const byte *srcP = Amazon::CURSORS[cursorId]; + int hotspotX = (int16)READ_LE_UINT16(srcP); + int hotspotY = (int16)READ_LE_UINT16(srcP + 2); + srcP += 4; + + // Create a surface to build up the cursor on + Graphics::Surface cursorSurface; + cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8()); + byte *destP = (byte *)cursorSurface.getPixels(); + Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0); + + // Loop to build up the cursor + for (int y = 0; y < CURSOR_HEIGHT; ++y) { + destP = (byte *)cursorSurface.getBasePtr(0, y); + int width = CURSOR_WIDTH; + int skip = *srcP++; + int plot = *srcP++; + if (skip >= width) + break; + + // Skip over pixels + destP += skip; + width -= skip; + + // Write out the pixels to plot + while (plot > 0 && width > 0) { + *destP++ = *srcP++; + --plot; + --width; + } + } + + // Set the cursor + CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT, + hotspotX, hotspotY, 0); + + // Free the cursor surface + cursorSurface.free(); } void EventsManager::showCursor() { @@ -58,6 +105,8 @@ bool EventsManager::isCursorVisible() { void EventsManager::pollEvents() { checkForNextFrameCounter(); + _leftButton = false; + Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { // Handle keypress @@ -78,10 +127,9 @@ void EventsManager::pollEvents() { return; case Common::EVENT_LBUTTONDOWN: _leftButton = true; - break; + return; case Common::EVENT_LBUTTONUP: - _leftButton = false; - break; + return; default: break; } diff --git a/engines/access/events.h b/engines/access/events.h index b30670cdbc..3cf610ece6 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -29,7 +29,11 @@ namespace Access { -enum CursorType { CURSOR_NONE = 0 }; +enum CursorType { + CURSOR_NONE = -1, + CURSOR_0 = 0, CURSOR_1, CURSOR_2, CURSOR_3, CURSOR_EYE, CURSOR_HAND, + CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP +}; #define GAME_FRAME_RATE 50 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) @@ -63,6 +67,11 @@ public: */ void setCursor(CursorType cursorId); + /** + * Return the current cursor Id + */ + CursorType getCursor() const { return _cursorId; } + /** * Show the mouse cursor */ diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp new file mode 100644 index 0000000000..8f0e22f2b1 --- /dev/null +++ b/engines/access/graphics.cpp @@ -0,0 +1,46 @@ +/* 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 "graphics/palette.h" +#include "access/access.h" +#include "access/graphics.h" +#include "access/resources.h" + +namespace Access { + +GraphicsManager::GraphicsManager(AccessEngine *vm) : _vm(vm) { + _vesaCurrentWin = 0; + _currentPanel = 0; + _hideFlag = true; +} + +void GraphicsManager::setPanel(int num) { + assert(num < 4); + _currentPanel = num; + _msVirtualOffset = _virtualOffsetsTable[num]; +} + +void GraphicsManager::setPalettte() { + g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); +} + +} // End of namespace Access diff --git a/engines/access/graphics.h b/engines/access/graphics.h new file mode 100644 index 0000000000..c7d2acd54e --- /dev/null +++ b/engines/access/graphics.h @@ -0,0 +1,51 @@ +/* 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 ACCESS_GRAPHICS_H +#define ACCESS_GRAPHICS_H + +#include "common/rect.h" +#include "graphics/surface.h" + +namespace Access { + +class AccessEngine; + +class GraphicsManager { +private: + AccessEngine *_vm; +public: + int _vesaCurrentWin; + int _currentPanel; + Common::Point _msVirtualOffset; + Common::Point _virtualOffsetsTable[4]; + bool _hideFlag; +public: + GraphicsManager(AccessEngine *vm); + + void setPanel(int num); + void setPalettte(); +}; + +} // End of namespace Access + +#endif /* ACCESS_GRAPHICS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index f04e51630e..d8867bc593 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ debugger.o \ detection.o \ events.o \ + graphics.o \ resources.o \ amazon\amazon_game.o diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 4ab3dd9513..cf8b491900 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -24,6 +24,27 @@ namespace Access { +const byte INITIAL_PALETTE[18 * 3] = { + 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, + 0xf0, 0xf0, 0xf0, + 0xe0, 0xe0, 0xe0, + 0xd0, 0xd0, 0xd0, + 0xc0, 0xc0, 0xc0, + 0xb0, 0xb0, 0xb0, + 0xa0, 0xa0, 0xa0, + 0x90, 0x90, 0x90, + 0x80, 0x80, 0x80, + 0x70, 0x70, 0x70, + 0x60, 0x60, 0x60, + 0x50, 0x50, 0x50, + 0x40, 0x40, 0x40, + 0x30, 0x30, 0x30, + 0x20, 0x20, 0x20, + 0x10, 0x10, 0x10, + 0x00, 0x00, 0x00 +}; + namespace Amazon { const byte *CURSORS[10] = { @@ -31,7 +52,8 @@ const byte *CURSORS[10] = { }; const byte MOUSE0[] = { - 0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, + 0, 0, 0, 0, + 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, diff --git a/engines/access/resources.h b/engines/access/resources.h index cabaac96a1..7bd2354c06 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -27,6 +27,8 @@ namespace Access { +extern const byte INITIAL_PALETTE[18 * 3]; + namespace Amazon { extern const byte MOUSE0[]; -- cgit v1.2.3 From a94bf197ef512eb7bf4dcb96ffcd459959c0d57c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Aug 2014 10:07:54 -0400 Subject: ACCESS: Implement fading routines --- engines/access/access.cpp | 8 ++- engines/access/access.h | 7 +++ engines/access/amazon/amazon_game.cpp | 7 +++ engines/access/amazon/amazon_game.h | 2 + engines/access/graphics.cpp | 4 -- engines/access/graphics.h | 1 - engines/access/module.mk | 1 + engines/access/screen.cpp | 100 ++++++++++++++++++++++++++++++++++ engines/access/screen.h | 72 ++++++++++++++++++++++++ 9 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 engines/access/screen.cpp create mode 100644 engines/access/screen.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 8aabac2b0b..3acd4c530a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,12 +34,14 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _graphics = nullptr; + _screen = nullptr; } AccessEngine::~AccessEngine() { delete _debugger; delete _events; delete _graphics; + delete _screen; } void AccessEngine::initialize() { @@ -51,16 +53,18 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _graphics = new GraphicsManager(this); + _screen = new Screen(this); } Common::Error AccessEngine::run() { initialize(); setVGA(); - _graphics->setPalettte(); - _graphics->setPanel(0); + _screen->setInitialPalettte(); _events->setCursor(CURSOR_0); _events->showCursor(); + _graphics->setPanel(0); + doTitle(); dummyLoop(); return Common::kNoError; diff --git a/engines/access/access.h b/engines/access/access.h index 16487ea64f..4676d73d1d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -33,6 +33,7 @@ #include "access/debugger.h" #include "access/events.h" #include "access/graphics.h" +#include "access/screen.h" /** * This is the namespace of the Access engine. @@ -77,10 +78,16 @@ protected: // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; +protected: + /** + * Show game title + */ + virtual void doTitle() = 0; public: Debugger *_debugger; EventsManager *_events; GraphicsManager *_graphics; + Screen *_screen; public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 2b4196a406..37441411d6 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -30,6 +30,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine(syst, gameDesc) { } +void AmazonEngine::doTitle() { + _screen->setDisplayScan(); + _screen->forceFadeOut(); + _events->hideCursor(); + +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 1bccd1cedc..30ec2c6519 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -30,6 +30,8 @@ namespace Access { namespace Amazon { class AmazonEngine : public AccessEngine { +protected: + virtual void doTitle(); public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp index 8f0e22f2b1..c1187f2eb3 100644 --- a/engines/access/graphics.cpp +++ b/engines/access/graphics.cpp @@ -39,8 +39,4 @@ void GraphicsManager::setPanel(int num) { _msVirtualOffset = _virtualOffsetsTable[num]; } -void GraphicsManager::setPalettte() { - g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); -} - } // End of namespace Access diff --git a/engines/access/graphics.h b/engines/access/graphics.h index c7d2acd54e..df626176fa 100644 --- a/engines/access/graphics.h +++ b/engines/access/graphics.h @@ -43,7 +43,6 @@ public: GraphicsManager(AccessEngine *vm); void setPanel(int num); - void setPalettte(); }; } // End of namespace Access diff --git a/engines/access/module.mk b/engines/access/module.mk index d8867bc593..a4fb8646ba 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ events.o \ graphics.o \ resources.o \ + screen.o \ amazon\amazon_game.o # This module can be built as a plugin diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp new file mode 100644 index 0000000000..3f8dc4ecda --- /dev/null +++ b/engines/access/screen.cpp @@ -0,0 +1,100 @@ +/* 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 "common/algorithm.h" +#include "common/textconsole.h" +#include "common/system.h" +#include "graphics/palette.h" +#include "access/screen.h" +#include "access/resources.h" + +namespace Access { + +Screen::Screen(AccessEngine *vm) : _vm(vm) { + create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); +} + +void Screen::setDisplayScan() { + warning("TODO: setDisplayScan"); +} + +void Screen::updateScreen() { + g_system->updateScreen(); +} + +void Screen::setInitialPalettte() { + Common::copy(&INITIAL_PALETTE[0], &INITIAL_PALETTE[18 * 3], _rawPalette); + Common::fill(&_rawPalette[18 * 3], &_rawPalette[PALETTE_SIZE], 0); + + g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); +} + +void Screen::updatePalette() { + g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT); + updateScreen(); +} + +void Screen::forceFadeOut() { + const int FADE_AMOUNT = 2; + bool repeatFlag; + byte *srcP; + int count; + + do { + repeatFlag = false; + for (srcP = &_tempPalette[0], count = 0; count < PALETTE_COUNT; ++count, ++srcP) { + int v = *srcP; + if (v) { + repeatFlag = true; + *srcP = MAX(*srcP - FADE_AMOUNT, 0); + } + } + + updatePalette(); + g_system->delayMillis(10); + } while (repeatFlag); +} + +void Screen::forceFadeIn() { + Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + + const int FADE_AMOUNT = 2; + bool repeatFlag; + do { + repeatFlag = false; + const byte *srcP = &_rawPalette[0]; + byte *destP = &_tempPalette[0]; + + for (int idx = 0; idx < PALETTE_SIZE; ++idx, ++srcP, ++destP) { + if (*destP != *srcP) { + repeatFlag = true; + *destP = MAX((int)*destP + FADE_AMOUNT, (int)*srcP); + } + } + + updatePalette(); + g_system->delayMillis(10); + } while (repeatFlag); +} + +} // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h new file mode 100644 index 0000000000..f8e0dab1b1 --- /dev/null +++ b/engines/access/screen.h @@ -0,0 +1,72 @@ +/* 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 ACCESS_SCREEN_H +#define ACCESS_SCREEN_H + +#include "common/scummsys.h" +#include "common/rect.h" +#include "graphics/surface.h" + +namespace Access { + +class AccessEngine; + +#define PALETTE_COUNT 256 +#define PALETTE_SIZE (256 * 3) + +class Screen: public Graphics::Surface { +private: + AccessEngine *_vm; + byte _tempPalette[PALETTE_SIZE]; + byte _rawPalette[PALETTE_SIZE]; + + void updatePalette(); +public: + Screen(AccessEngine *vm); + + void setDisplayScan(); + + /** + * Update the underlying screen + */ + void updateScreen(); + + /** + * Fade out screen + */ + void forceFadeOut(); + + /** + * Fade in screen + */ + void forceFadeIn(); + + /** + * Set the initial palette + */ + void setInitialPalettte(); +}; + +} // End of namespace Access + +#endif /* ACCESS_SCREEN_H */ -- cgit v1.2.3 From a35ba4caf96ab29a184787a859aea2918a74975c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Aug 2014 15:14:42 -0400 Subject: ACCESS: Adding file loading --- engines/access/access.cpp | 6 ++ engines/access/access.h | 9 +++ engines/access/amazon/amazon_game.cpp | 2 + engines/access/detection_tables.h | 5 -- engines/access/files.cpp | 111 ++++++++++++++++++++++++++++++++++ engines/access/files.h | 76 +++++++++++++++++++++++ engines/access/module.mk | 2 + engines/access/resources.cpp | 25 ++++++++ engines/access/resources.h | 2 + engines/access/sound.cpp | 29 +++++++++ engines/access/sound.h | 43 +++++++++++++ 11 files changed, 305 insertions(+), 5 deletions(-) create mode 100644 engines/access/files.cpp create mode 100644 engines/access/files.h create mode 100644 engines/access/sound.cpp create mode 100644 engines/access/sound.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 3acd4c530a..25d9fcc99e 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -33,15 +33,19 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { _debugger = nullptr; _events = nullptr; + _files = nullptr; _graphics = nullptr; _screen = nullptr; + _sound = nullptr; } AccessEngine::~AccessEngine() { delete _debugger; delete _events; + delete _files; delete _graphics; delete _screen; + delete _sound; } void AccessEngine::initialize() { @@ -52,8 +56,10 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); + _files = new FileManager(this); _graphics = new GraphicsManager(this); _screen = new Screen(this); + _sound = new SoundManager(this); } Common::Error AccessEngine::run() { diff --git a/engines/access/access.h b/engines/access/access.h index 4676d73d1d..3386cd9e11 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -32,8 +32,10 @@ #include "graphics/surface.h" #include "access/debugger.h" #include "access/events.h" +#include "access/files.h" #include "access/graphics.h" #include "access/screen.h" +#include "access/sound.h" /** * This is the namespace of the Access engine. @@ -49,6 +51,11 @@ namespace Access { #define DEBUG_INTERMEDIATE 2 #define DEBUG_DETAILED 3 +enum { + GType_Amazon = 1, + GType_MeanStreets = 2 +}; + enum AccessDebugChannels { kDebugPath = 1 << 0, kDebugScripts = 1 << 1, @@ -86,8 +93,10 @@ protected: public: Debugger *_debugger; EventsManager *_events; + FileManager *_files; GraphicsManager *_graphics; Screen *_screen; + SoundManager *_sound; public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 37441411d6..53ddde9f68 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -35,6 +35,8 @@ void AmazonEngine::doTitle() { _screen->forceFadeOut(); _events->hideCursor(); + _sound->loadSound(98, 30); + } } // End of namespace Amazon diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index 90304290f1..cbef1d3b63 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -22,11 +22,6 @@ namespace Access { -enum { - GType_Amazon = 1, - GType_MeanStreets = 2 -}; - static const AccessGameDescription gameDescriptions[] = { { // Amazon Guadians of Eden - Floppy English diff --git a/engines/access/files.cpp b/engines/access/files.cpp new file mode 100644 index 0000000000..7da7574df2 --- /dev/null +++ b/engines/access/files.cpp @@ -0,0 +1,111 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software + * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * + */ + +#include "access/files.h" +#include "access/resources.h" +#include "access/access.h" + +namespace Access { + +FileManager::FileManager(AccessEngine *vm): _vm(vm) { + switch (vm->getGameID()) { + case GType_Amazon: + _filenames = &Amazon::FILENAMES[0]; + break; + default: + error("Unknown game"); + } + + _fileNumber = -1; + _stream = nullptr; +} + +FileManager::~FileManager() { + delete _stream; + _file.close(); +} + +void FileManager::loadFile(int fileNum, int subfile) { + setAppended(fileNum); + gotoAppended(subfile); + + handleFile(); +} + +void FileManager::loadFile(const Common::String &filename) { + // Open up the file + _fileNumber = -1; + _file.close(); + if (_file.open(filename)) + error("Could not open file - %s", filename.c_str()); + + // Get a stream for the entire file + delete _stream; + _stream = _file.readStream(_file.size()); + + handleFile(); +} + +void FileManager::handleFile() { + char header[3]; + _stream->read(&header[0], 3); + + if (!strncmp(header, "BDE", 3)) + // Decompress the resource + decompressFile(); + else + // Not compressed, so move back to start of data + _stream->seek(0); +} + +void FileManager::decompressFile() { + // TODO +} + +void FileManager::setAppended(int fileNum) { + if (_fileNumber != fileNum) { + _fileNumber = fileNum; + + _file.close(); + if (!_file.open(_filenames[fileNum])) + error("Could not open file %s", _filenames[fileNum]); + + // Read in the file index + _fileIndex.resize(50); + for (int i = 0; i < 50; ++i) { + _fileIndex[i]._offset = _file.readUint32LE(); + _fileIndex[i]._nextOffset = _file.readUint32LE(); + } + } +} + +void FileManager::gotoAppended(int subfile) { + uint32 offset = _fileIndex[subfile]._offset; + uint32 size = _fileIndex[subfile]._nextOffset - offset; + + _file.seek(offset); + delete _stream; + _stream = _file.readStream(size); +} + + +} // End of namespace Access diff --git a/engines/access/files.h b/engines/access/files.h new file mode 100644 index 0000000000..fcd24808a3 --- /dev/null +++ b/engines/access/files.h @@ -0,0 +1,76 @@ +/* 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 ACCESS_FILES_H +#define ACCESS_FILES_H + +#include "common/scummsys.h" +#include "common/file.h" + +namespace Access { + +class AccessEngine; + +struct FileEntry { + uint32 _offset; + uint32 _nextOffset; +}; + +class FileManager { +private: + AccessEngine *_vm; + const char * const *_filenames; + + void handleFile(); + + void decompressFile(); + +public: + int _fileNumber; + Common::File _file; + Common::SeekableReadStream *_stream; + Common::Array _fileIndex; + uint32 _entryOffset; + uint32 _nextOffset; +public: + FileManager(AccessEngine *vm); + ~FileManager(); + + void loadFile(int fileNum, int subfile); + + void loadFile(const Common::String &filename); + + /** + * Open up a sub-file container file + */ + void setAppended(int fileNum); + + + /** + * Open up a sub-file resource within an alrady opened container file. + */ + void gotoAppended(int subfile); +}; + +} // End of namespace Access + +#endif /* ACCESS_FILES_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index a4fb8646ba..7e23ede512 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -5,9 +5,11 @@ MODULE_OBJS := \ debugger.o \ detection.o \ events.o \ + files.o \ graphics.o \ resources.o \ screen.o \ + sound.o \ amazon\amazon_game.o # This module can be built as a plugin diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index cf8b491900..a47abf2b06 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -21,6 +21,7 @@ */ #include "access/resources.h" +#include "access/access.h" namespace Access { @@ -47,6 +48,30 @@ const byte INITIAL_PALETTE[18 * 3] = { namespace Amazon { +const char *const FILENAMES[] = { + "S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP", + "S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP", + "S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP", + "S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP", + "S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP", + "S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP", + "S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP", + "S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP", + "C36.AP", nullptr, "S50.AP", nullptr, nullptr, "S53.AP", + "S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr, + nullptr, "S61.AP", nullptr, nullptr, "S64.AP", "C00.AP", + "C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP", + "C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP", + "C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP", + "C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP", + "C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP", + "EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP", + "NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP", + "NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP", + "NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP", + "NARATE13.AP", "NARATE14.AP" +}; + const byte *CURSORS[10] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP }; diff --git a/engines/access/resources.h b/engines/access/resources.h index 7bd2354c06..ba335cd0ec 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -31,6 +31,8 @@ extern const byte INITIAL_PALETTE[18 * 3]; namespace Amazon { +extern const char *const FILENAMES[]; + extern const byte MOUSE0[]; extern const byte MOUSE1[]; extern const byte MOUSE2[]; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp new file mode 100644 index 0000000000..d04d915cc9 --- /dev/null +++ b/engines/access/sound.cpp @@ -0,0 +1,29 @@ +/* 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 "access/sound.h" + +namespace Access { + +SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {} + +} // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h new file mode 100644 index 0000000000..e35e64795d --- /dev/null +++ b/engines/access/sound.h @@ -0,0 +1,43 @@ +/* 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 ACCESS_SOUND_H +#define ACCESS_SOUND_H + +namespace Access { + +class AccessEngine; + +class SoundManager { +private: + AccessEngine *_vm; +public: + int _soundPriority; +public: + SoundManager(AccessEngine *vm); + + void loadSound(int fileNum, int subfile) {} +}; + +} // End of namespace Access + +#endif /* ACCESS_SOUND_H*/ -- cgit v1.2.3 From 7a63e12edb98f47d9a262601d9d26d9444975314 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 2 Aug 2014 17:09:28 -0400 Subject: ACCESS: Added screen loading and file index load fixes --- engines/access/amazon/amazon_game.cpp | 10 ++++- engines/access/files.cpp | 71 +++++++++++++++++++++++++---------- engines/access/files.h | 35 +++++++++++------ engines/access/screen.cpp | 17 +++++++++ engines/access/screen.h | 12 ++++++ engines/access/sound.cpp | 17 ++++++++- engines/access/sound.h | 10 ++++- 7 files changed, 136 insertions(+), 36 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 53ddde9f68..3f8ae73faa 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -35,8 +35,14 @@ void AmazonEngine::doTitle() { _screen->forceFadeOut(); _events->hideCursor(); - _sound->loadSound(98, 30); - + _sound->_soundTable[0] = _sound->loadSound(98, 30); + _sound->_soundPriority[0] = 1; + _sound->_soundTable[1] = _sound->loadSound(98, 8); + _sound->_soundPriority[1] = 2; + + _screen->_loadPalFlag = false; + byte *scr = _files->loadScreen(0, 3); + _screen->copyBuffer(scr); } } // End of namespace Amazon diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 7da7574df2..549429b154 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -44,41 +44,72 @@ FileManager::~FileManager() { _file.close(); } -void FileManager::loadFile(int fileNum, int subfile) { +byte *FileManager::loadFile(int fileNum, int subfile) { setAppended(fileNum); gotoAppended(subfile); - handleFile(); + return handleFile(); } -void FileManager::loadFile(const Common::String &filename) { +byte *FileManager::loadFile(const Common::String &filename) { + // Open the file + openFile(filename); + + // Get a stream for the entire file + delete _stream; + _stream = _file.readStream(_file.size()); + + return handleFile(); +} + +void FileManager::openFile(const Common::String &filename) { // Open up the file _fileNumber = -1; _file.close(); if (_file.open(filename)) error("Could not open file - %s", filename.c_str()); +} - // Get a stream for the entire file +byte *FileManager::loadScreen(int fileNum, int subfile) { + setAppended(fileNum); + gotoAppended(subfile); + _vm->_screen->loadPalette(_stream); + + return handleFile(); +} + +byte *FileManager::loadScreen(const Common::String &filename) { + // Open the file + openFile(filename); + + // Get the palette + _vm->_screen->loadPalette(_stream); + + // Get a stream for the remainder of the file delete _stream; _stream = _file.readStream(_file.size()); - handleFile(); + return handleFile(); } -void FileManager::handleFile() { +byte *FileManager::handleFile() { char header[3]; _stream->read(&header[0], 3); - if (!strncmp(header, "BDE", 3)) + if (!strncmp(header, "DBE", 3)) // Decompress the resource - decompressFile(); - else - // Not compressed, so move back to start of data - _stream->seek(0); + return decompressFile(); + + // Not compressed, so pass out all of the file + _stream->seek(0); + byte *data = new byte[_stream->size()]; + _stream->read(data, _stream->size()); + + return data; } -void FileManager::decompressFile() { - // TODO +byte *FileManager::decompressFile() { + error("TODO: decompression"); } void FileManager::setAppended(int fileNum) { @@ -90,17 +121,17 @@ void FileManager::setAppended(int fileNum) { error("Could not open file %s", _filenames[fileNum]); // Read in the file index - _fileIndex.resize(50); - for (int i = 0; i < 50; ++i) { - _fileIndex[i]._offset = _file.readUint32LE(); - _fileIndex[i]._nextOffset = _file.readUint32LE(); - } + int count = _file.readUint16LE(); + assert(count <= 100); + _fileIndex.resize(count); + for (int i = 0; i < count; ++i) + _fileIndex[i] = _file.readUint32LE(); } } void FileManager::gotoAppended(int subfile) { - uint32 offset = _fileIndex[subfile]._offset; - uint32 size = _fileIndex[subfile]._nextOffset - offset; + uint32 offset = _fileIndex[subfile]; + uint32 size = _fileIndex[subfile + 1] - offset; _file.seek(offset); delete _stream; diff --git a/engines/access/files.h b/engines/access/files.h index fcd24808a3..42b439ce45 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -24,47 +24,60 @@ #define ACCESS_FILES_H #include "common/scummsys.h" +#include "common/array.h" #include "common/file.h" namespace Access { class AccessEngine; -struct FileEntry { - uint32 _offset; - uint32 _nextOffset; -}; - class FileManager { private: AccessEngine *_vm; const char * const *_filenames; - void handleFile(); + void openFile(const Common::String &filename); + + byte *handleFile(); - void decompressFile(); + byte *decompressFile(); public: int _fileNumber; Common::File _file; Common::SeekableReadStream *_stream; - Common::Array _fileIndex; + Common::Array _fileIndex; uint32 _entryOffset; uint32 _nextOffset; public: FileManager(AccessEngine *vm); ~FileManager(); - void loadFile(int fileNum, int subfile); + /** + * Load a given subfile from a container file + */ + byte *loadFile(int fileNum, int subfile); + + /** + * Load a given file by name + */ + byte *loadFile(const Common::String &filename); - void loadFile(const Common::String &filename); + /** + * Load a given scren from a container file + */ + byte *loadScreen(int fileNum, int subfile); + + /** + * Load a given screen by name + */ + byte *loadScreen(const Common::String &filename); /** * Open up a sub-file container file */ void setAppended(int fileNum); - /** * Open up a sub-file resource within an alrady opened container file. */ diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3f8dc4ecda..4059cab070 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -32,6 +32,7 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + _loadPalFlag = false; } void Screen::setDisplayScan() { @@ -49,6 +50,16 @@ void Screen::setInitialPalettte() { g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); } +void Screen::loadPalette(Common::SeekableReadStream *stream) { + stream->read(&_rawPalette[0], PALETTE_SIZE); + setPalette(); + _loadPalFlag = true; +} + +void Screen::setPalette() { + g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT); +} + void Screen::updatePalette() { g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT); updateScreen(); @@ -97,4 +108,10 @@ void Screen::forceFadeIn() { } while (repeatFlag); } +void Screen::copyBuffer(const byte *data) { + byte *destP = (byte *)getPixels(); + Common::copy(data, data + (h * w), destP); + g_system->copyRectToScreen(destP, w, 0, 0, w, h); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index f8e0dab1b1..d16333c46e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/stream.h" #include "graphics/surface.h" namespace Access { @@ -40,7 +41,11 @@ private: byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + void setPalette(); + void updatePalette(); +public: + bool _loadPalFlag; public: Screen(AccessEngine *vm); @@ -65,6 +70,13 @@ public: * Set the initial palette */ void setInitialPalettte(); + + void loadPalette(Common::SeekableReadStream *stream); + + /** + * Copy a buffer to the screen + */ + void copyBuffer(const byte *data); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index d04d915cc9..baad6352b8 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -20,10 +20,25 @@ * */ +#include "common/algorithm.h" +#include "access/access.h" #include "access/sound.h" namespace Access { -SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) {} +SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) { + Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr); + Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); +} + +SoundManager::~SoundManager() { + for (int i = 0; i < MAX_SOUNDS; ++i) + delete _soundTable[i]; +} + +byte *SoundManager::loadSound(int fileNum, int subfile) { + return _vm->_files->loadFile(fileNum, subfile); +} + } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index e35e64795d..5d173e2e2b 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -23,6 +23,10 @@ #ifndef ACCESS_SOUND_H #define ACCESS_SOUND_H +#include "common/scummsys.h" + +#define MAX_SOUNDS 20 + namespace Access { class AccessEngine; @@ -31,11 +35,13 @@ class SoundManager { private: AccessEngine *_vm; public: - int _soundPriority; + byte *_soundTable[MAX_SOUNDS]; + int _soundPriority[MAX_SOUNDS]; public: SoundManager(AccessEngine *vm); + ~SoundManager(); - void loadSound(int fileNum, int subfile) {} + byte *loadSound(int fileNum, int subfile); }; } // End of namespace Access -- cgit v1.2.3 From d41c5cd7407a99fde350f2c9fbe9b4d6e73d1ba6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Aug 2014 16:59:22 -0400 Subject: ACCESS: Added decompression code --- engines/access/decompress.cpp | 127 ++++++++++++++++++++++++++++++++++++++++++ engines/access/decompress.h | 48 ++++++++++++++++ engines/access/files.cpp | 33 ++++++----- engines/access/files.h | 7 +-- engines/access/module.mk | 1 + 5 files changed, 196 insertions(+), 20 deletions(-) create mode 100644 engines/access/decompress.cpp create mode 100644 engines/access/decompress.h diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp new file mode 100644 index 0000000000..45ae07d712 --- /dev/null +++ b/engines/access/decompress.cpp @@ -0,0 +1,127 @@ +/* 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 "common/debug.h" +#include "common/endian.h" +#include "common/util.h" + +#include "access/decompress.h" + +namespace Access { + +void LzwDecompressor::decompress(byte *source, byte *dest) { + + _source = source; + + byte litByte; + uint16 copyLength, maxCodeValue, code, nextCode, lastCode, oldCode; + + byte *copyBuf = new byte[8192]; + + struct { uint16 code; byte value; } codeTable[8192]; + memset(codeTable, 0, sizeof(codeTable)); + + _codeLength = 9; + nextCode = 258; + maxCodeValue = 512; + + copyLength = 0; + _bitPos = 0; + + while (1) { + + code = getCode(); + + if (code == 257) + break; + + if (code == 256) { + _codeLength = 9; + nextCode = 258; + maxCodeValue = 512; + lastCode = getCode(); + oldCode = lastCode; + litByte = lastCode; + *dest++ = litByte; + } else { + lastCode = code; + if (code >= nextCode) { + lastCode = oldCode; + copyBuf[copyLength++] = litByte; + } + while (lastCode > 255) { + copyBuf[copyLength++] = codeTable[lastCode].value; + lastCode = codeTable[lastCode].code; + } + litByte = lastCode; + copyBuf[copyLength++] = lastCode; + while (copyLength > 0) + *dest++ = copyBuf[--copyLength]; + codeTable[nextCode].value = lastCode; + codeTable[nextCode].code = oldCode; + nextCode++; + oldCode = code; + if (nextCode >= maxCodeValue && _codeLength <= 12) { + _codeLength++; + maxCodeValue <<= 1; + } + } + + } + + delete[] copyBuf; + +} + +uint16 LzwDecompressor::getCode() { + const byte bitMasks[9] = { + 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0x0FF + }; + uint16 bits, loCode, hiCode; + loCode = (READ_LE_UINT16(_source) >> _bitPos) & 0xFF; + _source++; + bits = _codeLength - 8; + hiCode = (READ_LE_UINT16(_source) >> _bitPos) & bitMasks[bits]; + _bitPos += bits; + if (_bitPos > 8) { + _source++; + _bitPos -= 8; + } + return (hiCode << 8) | loCode; +} + +uint32 decompressDBE(byte *source, byte **dest) { + + uint32 destSize = READ_LE_UINT32(source + 4); + *dest = new byte[destSize]; + + debug(1, "decompressDBE() destSize = %d", destSize); + + LzwDecompressor dec; + dec.decompress(source + 16, *dest); + + debug(1, "decompressDBE() ok"); + + return destSize; +} + +} // End of namespace Access diff --git a/engines/access/decompress.h b/engines/access/decompress.h new file mode 100644 index 0000000000..522bfb2acf --- /dev/null +++ b/engines/access/decompress.h @@ -0,0 +1,48 @@ +/* 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. +/* 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 ACCESS_DECOMPRESS_H +#define ACCESS_DECOMPRESS_H + +#include "common/scummsys.h" + +namespace Access { + +class LzwDecompressor { +public: + void decompress(byte *source, byte *dest); +private: + byte *_source; + byte _codeLength, _bitPos; + uint16 getCode(); +}; + +uint32 decompressDBE(byte *source, byte **dest); + +} // End of namespace Access + +#endif diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 549429b154..7b4a23d0e8 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -68,6 +68,8 @@ void FileManager::openFile(const Common::String &filename) { _file.close(); if (_file.open(filename)) error("Could not open file - %s", filename.c_str()); + + _filesize = _file.size(); } byte *FileManager::loadScreen(int fileNum, int subfile) { @@ -83,11 +85,11 @@ byte *FileManager::loadScreen(const Common::String &filename) { openFile(filename); // Get the palette - _vm->_screen->loadPalette(_stream); + _vm->_screen->loadPalette(&_file); // Get a stream for the remainder of the file delete _stream; - _stream = _file.readStream(_file.size()); + _stream = _file.readStream(_file.size() - _file.pos()); return handleFile(); } @@ -95,21 +97,23 @@ byte *FileManager::loadScreen(const Common::String &filename) { byte *FileManager::handleFile() { char header[3]; _stream->read(&header[0], 3); + _stream->seek(-3, SEEK_CUR); - if (!strncmp(header, "DBE", 3)) - // Decompress the resource - return decompressFile(); - - // Not compressed, so pass out all of the file - _stream->seek(0); - byte *data = new byte[_stream->size()]; - _stream->read(data, _stream->size()); + bool isCompressed = !strncmp(header, "DBE", 3); - return data; -} + // Get the data from the file or resource + _filesize = _stream->size() - _stream->pos(); + byte *data = new byte[_filesize]; + _stream->read(data, _filesize); -byte *FileManager::decompressFile() { - error("TODO: decompression"); + // If the data is compressed, uncompress it + if (isCompressed) { + byte *src = data; + _filesize = decompressDBE(src, &data); + delete[] src; + } + + return data; } void FileManager::setAppended(int fileNum) { @@ -138,5 +142,4 @@ void FileManager::gotoAppended(int subfile) { _stream = _file.readStream(size); } - } // End of namespace Access diff --git a/engines/access/files.h b/engines/access/files.h index 42b439ce45..9224b29429 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/file.h" +#include "access/decompress.h" namespace Access { @@ -39,16 +40,12 @@ private: void openFile(const Common::String &filename); byte *handleFile(); - - byte *decompressFile(); - public: int _fileNumber; Common::File _file; Common::SeekableReadStream *_stream; Common::Array _fileIndex; - uint32 _entryOffset; - uint32 _nextOffset; + uint32 _filesize; public: FileManager(AccessEngine *vm); ~FileManager(); diff --git a/engines/access/module.mk b/engines/access/module.mk index 7e23ede512..c9d593de22 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -3,6 +3,7 @@ MODULE := engines/access MODULE_OBJS := \ access.o \ debugger.o \ + decompress.o \ detection.o \ events.o \ files.o \ -- cgit v1.2.3 From fb62b9477b5a9d887eb3484d82a7ef67efb6bfa5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:29:58 +0700 Subject: ZVISION: Make controls processing breakeable. --- engines/zvision/scripting/script_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 53fa5832d9..4dd51816a0 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -181,7 +181,8 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { } for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) - (*iter)->process(deltaTimeMillis); + if ( (*iter)->process(deltaTimeMillis) ) + break; } void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { -- cgit v1.2.3 From d7d058cd60aae2c898f285b183416d1393c4a7ad Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:32:48 +0700 Subject: ZVISION: New scriptManager location methods --- engines/zvision/scripting/script_manager.cpp | 26 ++++++++++++++++++++++++++ engines/zvision/scripting/script_manager.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 4dd51816a0..6a9398d356 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -486,6 +486,10 @@ void ScriptManager::onKeyUp(Common::KeyState keyState) { } } +void ScriptManager::changeLocation(const Location &_newLocation) { + changeLocation(_newLocation.world, _newLocation.room, _newLocation.node, _newLocation.view, _newLocation.offset); +} + void ScriptManager::changeLocation(char _world, char _room, char _node, char _view, uint32 offset) { _nextLocation.world = _world; _nextLocation.room = _room; @@ -731,6 +735,28 @@ Location ScriptManager::getCurrentLocation() const { return location; } +Location ScriptManager::getLastLocation() { + Location location; + location.world = getStateValue(StateKey_LastWorld); + location.room = getStateValue(StateKey_LastRoom); + location.node = getStateValue(StateKey_LastNode); + location.view = getStateValue(StateKey_LastView); + location.offset = getStateValue(StateKey_LastViewPos); + + return location; +} + +Location ScriptManager::getLastMenuLocation() { + Location location; + location.world = getStateValue(StateKey_Menu_LastWorld); + location.room = getStateValue(StateKey_Menu_LastRoom); + location.node = getStateValue(StateKey_Menu_LastNode); + location.view = getStateValue(StateKey_Menu_LastView); + location.offset = getStateValue(StateKey_Menu_LastViewPos); + + return location; +} + void ScriptManager::addEvent(Common::Event event) { _controlEvents.push_back(event); } diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 6cc957874b..4d82f36aea 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -237,11 +237,14 @@ public: /** Mark next location */ void changeLocation(char world, char room, char node, char view, uint32 offset); + void changeLocation(const Location &_newLocation); void serialize(Common::WriteStream *stream); void deserialize(Common::SeekableReadStream *stream); Location getCurrentLocation() const; + Location getLastLocation(); + Location getLastMenuLocation(); private: void referenceTableAddPuzzle(uint32 key, puzzle_ref ref); -- cgit v1.2.3 From 73d26bc2337e8afd03bfd73e6ccc0c0fb44a5950 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:33:36 +0700 Subject: ZVISION: Don't focus on already focused control --- engines/zvision/scripting/script_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 6a9398d356..380141490a 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -361,6 +361,8 @@ Control *ScriptManager::getControl(uint32 key) { void ScriptManager::focusControl(uint32 key) { if (!_activeControls) return; + if (_currentlyFocusedControl == key) + return; for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); ++iter) { uint32 controlKey = (*iter)->getKey(); -- cgit v1.2.3 From 550c4dbc359ece732684e0733e1925283f31c257 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:35:54 +0700 Subject: ZVISION: Implement full code for input control --- .../zvision/scripting/controls/input_control.cpp | 149 +++++++++++++++++---- engines/zvision/scripting/controls/input_control.h | 20 ++- engines/zvision/scripting/scr_file_handling.cpp | 3 + 3 files changed, 147 insertions(+), 25 deletions(-) diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index bebf3fae11..e35b300cb9 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "zvision/scripting/controls/input_control.h" +#include "zvision/cursors/cursor_manager.h" #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" @@ -42,7 +43,11 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _nextTabstop(0), _focused(false), _textChanged(false), - _cursorOffset(0) { + _cursorOffset(0), + _enterPressed(false), + _readOnly(false), + _txtWidth(0), + _animation(NULL) { // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); @@ -71,21 +76,30 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber); - _textStyle = _engine->getStringManager()->getTextStyle(fontFormatNumber); + _string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + } else if (line.matchString("*chooser_init_string*", true)) { + uint fontFormatNumber; + + sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber); + + _string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (line.matchString("*next_tabstop*", true)) { sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop); + } else if (line.matchString("*cursor_dimensions*", true)) { + // Ignore, use the dimensions in the animation file + } else if (line.matchString("*cursor_animation_frames*", true)) { + // Ignore, use the frame count in the animation file } else if (line.matchString("*cursor_animation*", true)) { char fileName[25]; sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName); - _cursorAnimationFileName = Common::String(fileName); - } else if (line.matchString("*cursor_dimensions*", true)) { - // Ignore, use the dimensions in the animation file - } else if (line.matchString("*cursor_animation_frames*", true)) { - // Ignore, use the frame count in the animation file + _animation = new MetaAnimation(fileName, _engine); + _frame = -1; + _frameDelay = 0; } else if (line.matchString("*focus*", true)) { _focused = true; + _engine->getScriptManager()->setFocusControlKey(_key); } line = stream.readLine(); @@ -94,51 +108,140 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { - _engine->getScriptManager()->focusControl(_key); + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_textRectangle.contains(backgroundImageSpacePos)) { + if (!_readOnly) { + // Save + _engine->getScriptManager()->focusControl(_key); + } else { + // Restore + if (_currentInputText.size()) + _enterPressed = true; + } + } + return false; +} + +bool InputControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_textRectangle.contains(backgroundImageSpacePos)) { + if (!_readOnly) { + // Save + _engine->getCursorManager()->changeCursor(CursorIndex_Active); + return true; + } else { + // Restore + if (_currentInputText.size()) { + _engine->getCursorManager()->changeCursor(CursorIndex_Active); + _engine->getScriptManager()->focusControl(_key); + return true; + } + } + } return false; } bool InputControl::onKeyDown(Common::KeyState keyState) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + if (!_focused) { return false; } if (keyState.keycode == Common::KEYCODE_BACKSPACE) { - _currentInputText.deleteLastChar(); + if (!_readOnly) { + _currentInputText.deleteLastChar(); + _textChanged = true; + } + } else if (keyState.keycode == Common::KEYCODE_RETURN) { + _enterPressed = true; } else if (keyState.keycode == Common::KEYCODE_TAB) { - _focused = false; + unfocus(); // Focus the next input control _engine->getScriptManager()->focusControl(_nextTabstop); + // Don't process this event for other controls + return true; } else { - // Otherwise, append the new character to the end of the current text - - uint16 asciiValue = keyState.ascii; - // We only care about text values - if (asciiValue >= 32 && asciiValue <= 126) { - _currentInputText += (char)asciiValue; - _textChanged = true; + if (!_readOnly) { + // Otherwise, append the new character to the end of the current text + uint16 asciiValue = keyState.ascii; + // We only care about text values + if (asciiValue >= 32 && asciiValue <= 126) { + _currentInputText += (char)asciiValue; + _textChanged = true; + } } } return false; } bool InputControl::process(uint32 deltaTimeInMillis) { - if (!_focused) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - } // First see if we need to render the text if (_textChanged) { // Blit the text using the RenderManager - //Common::Rect destRect = _engine->getRenderManager()->renderTextToWorkingWindow(_key, _currentInputText, _textStyle.font, _textRectangle.left, _textRectangle.top, _textStyle.color, _textRectangle.width()); - //_cursorOffset = destRect.left - _textRectangle.left; + Graphics::Surface txt; + txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat); + + if (!_readOnly || !_focused) + _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_init, txt); + else + _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_chooser_init, txt); + + _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); + + txt.free(); + } + + if (_animation && !_readOnly && _focused) { + bool need_draw = true;// = _textChanged; + _frameDelay -= deltaTimeInMillis; + if (_frameDelay <= 0) { + _frame = (_frame + 1) % _animation->frameCount(); + _frameDelay = _animation->frameTime(); + need_draw = true; + } + + if (need_draw) { + const Graphics::Surface *srf = _animation->getFrameData(_frame); + uint32 xx = _textRectangle.left + _txtWidth; + if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width())) + xx = _textRectangle.left + _textRectangle.width() - _animation->width(); + _engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top); + } } - // Render the next frame of the animation - // TODO: Implement animation handling + _textChanged = false; + return false; +} +bool InputControl::enterPress() { + if (_enterPressed) { + _enterPressed = false; + return true; + } return false; } +void InputControl::setText(const Common::String &_str) { + _currentInputText = _str; + _textChanged = true; +} + +const Common::String InputControl::getText() { + return _currentInputText; +} + +void InputControl::setReadOnly(bool readonly) { + _readOnly = readonly; +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 91fcd364cd..5e2190f369 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -24,6 +24,8 @@ #define ZVISION_INPUT_CONTROL_H #include "zvision/scripting/control.h" +#include "zvision/animation/meta_animation.h" +#include "zvision/text/text.h" #include "zvision/text/string_manager.h" #include "common/rect.h" @@ -38,25 +40,39 @@ public: private: Common::Rect _textRectangle; Common::Rect _headerRectangle; - StringManager::TextStyle _textStyle; + cTxtStyle _string_init; + cTxtStyle _string_chooser_init; uint32 _nextTabstop; - Common::String _cursorAnimationFileName; bool _focused; Common::String _currentInputText; bool _textChanged; uint _cursorOffset; + bool _enterPressed; + bool _readOnly; + + int16 _txtWidth; + MetaAnimation *_animation; + int32 _frameDelay; + int16 _frame; public: void focus() { _focused = true; + _textChanged = true; } void unfocus() { _focused = false; + _textChanged = true; } bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); bool onKeyDown(Common::KeyState keyState); bool process(uint32 deltaTimeInMillis); + void setText(const Common::String &_str); + const Common::String getText(); + bool enterPress(); + void setReadOnly(bool); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 5d697bd841..d1d6e2862d 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -31,6 +31,7 @@ #include "zvision/scripting/controls/push_toggle_control.h" #include "zvision/scripting/controls/lever_control.h" #include "zvision/scripting/controls/slot_control.h" +#include "zvision/scripting/controls/input_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -346,6 +347,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new LeverControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("slot")) { return new SlotControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("input")) { + return new InputControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 5a5a32c84a67ce4c8466b069b6bb1c844d014577 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:39:14 +0700 Subject: ZVISION: New SaveManager methods for pre-buffering save data --- engines/zvision/core/save_manager.cpp | 23 +++++++++++++++++++++++ engines/zvision/core/save_manager.h | 9 ++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 8ec4f4d628..6e8b6b5ff3 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -67,6 +67,13 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me delete file; } +void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { + if (_tempSave) { + saveGame(slot, saveName, _tempSave); + flushSaveBuffer(); + } +} + void SaveManager::autoSave() { Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); @@ -231,4 +238,20 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { return saveFile; } +void SaveManager::prepareSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = new Common::MemoryWriteStreamDynamic; + + _engine->getScriptManager()->serialize(_tempSave); +} + +void SaveManager::flushSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = NULL; +} + } // End of namespace ZVision diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 8ed64a3fdc..c7c1297062 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -48,7 +48,8 @@ struct SaveGameHeader { class SaveManager { public: - SaveManager(ZVision *engine) : _engine(engine) {} + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + ~SaveManager() { flushSaveBuffer(); } private: ZVision *_engine; @@ -59,6 +60,8 @@ private: SAVE_VERSION = 1 }; + Common::MemoryWriteStreamDynamic *_tempSave; + public: /** * Called every room change. Saves the state of the room just before @@ -76,6 +79,7 @@ public: */ void saveGame(uint slot, const Common::String &saveName); void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); + void saveGameBuffered(uint slot, const Common::String &saveName); /** * Loads the state data from the save file that slot references. Uses * ZVision::generateSaveFileName(slot) to get the save file name. @@ -87,6 +91,9 @@ public: Common::SeekableReadStream *getSlotFile(uint slot); bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); + + void prepareSaveBuffer(); + void flushSaveBuffer(); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; -- cgit v1.2.3 From 49fc9eb5e665ad77512c3ea466ec34330022b776 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:41:08 +0700 Subject: ZVISION: Define ID's for system strings --- engines/zvision/text/string_manager.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index e226fbeae8..5420e1f3ee 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -52,6 +52,13 @@ public: Common::String text; }; + enum { + ZVISION_STR_SAVEEXIST = 23, + ZVISION_STR_SAVED = 4, + ZVISION_STR_SAVEEMPTY = 21, + ZVISION_STR_EXITPROMT = 6 + }; + private: struct InGameText { Common::List fragments; -- cgit v1.2.3 From e9676f5d7aa0a77b649ee99f4222f571894f96c2 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:42:16 +0700 Subject: ZVISION: Implementation of save control --- engines/zvision/module.mk | 1 + .../zvision/scripting/controls/save_control.cpp | 122 +++++++++++++++++++++ engines/zvision/scripting/controls/save_control.h | 56 ++++++++++ engines/zvision/scripting/scr_file_handling.cpp | 3 + 4 files changed, 182 insertions(+) create mode 100644 engines/zvision/scripting/controls/save_control.cpp create mode 100644 engines/zvision/scripting/controls/save_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 9d5072a64d..ee4a2331a0 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -20,6 +20,7 @@ MODULE_OBJS := \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ scripting/controls/push_toggle_control.o \ + scripting/controls/save_control.o \ scripting/controls/slot_control.o \ scripting/inventory.o \ scripting/scr_file_handling.o \ diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp new file mode 100644 index 0000000000..fda8a70114 --- /dev/null +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -0,0 +1,122 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/input_control.h" +#include "zvision/scripting/controls/save_control.h" +#include "zvision/utility/utility.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/text/string_manager.h" + +#include "zvision/core/save_manager.h" + +#include "common/str.h" +#include "common/stream.h" + + +namespace ZVision { + +SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_SAVE), + _saveControl(false) { + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + + while (!stream.eos() && !line.contains('}')) { + if (line.matchString("*savebox*", true)) { + int save_id; + int input_id; + + sscanf(line.c_str(), "%*[^(](%d %d)", &save_id, &input_id); + save_elmnt elmnt; + elmnt.input_key = input_id; + elmnt.save_id = save_id; + elmnt.exist = false; + _inputs.push_back(elmnt); + } else if (line.matchString("*control_type*", true)) { + char buf[32]; + + sscanf(line.c_str(), "%*[^(](%s)", buf); + if (Common::String(buf).contains("save")) + _saveControl = true; + else + _saveControl = false; + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + } + + for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) { + Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key); + if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) { + InputControl *inp = (InputControl *)ctrl; + inp->setReadOnly(!_saveControl); + Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->save_id); + if (save) { + SaveGameHeader header; + _engine->getSaveManager()->readSaveGameHeader(save, header); + delete save; + inp->setText(header.saveName); + iter->exist = true; + } + } + } +} + +bool SaveControl::process(uint32 deltaTimeInMillis) { + for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) { + Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key); + if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) { + InputControl *inp = (InputControl *)ctrl; + if (inp->enterPress()) { + if (_saveControl) { + if (inp->getText().size() > 0) { + bool toSave = true; + if (iter->exist) + if (!_engine->askQuestion(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEXIST))) + toSave = false; + + if (toSave) { + _engine->getSaveManager()->saveGameBuffered(iter->save_id, inp->getText()); + _engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000); + _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation()); + } + } else { + _engine->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000); + } + } else { + _engine->getSaveManager()->loadGame(iter->save_id); + return true; + } + break; + } + } + } + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h new file mode 100644 index 0000000000..942b9c9269 --- /dev/null +++ b/engines/zvision/scripting/controls/save_control.h @@ -0,0 +1,56 @@ +/* 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 ZVISION_SAVE_CONTROL_H +#define ZVISION_SAVE_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "common/list.h" + + +namespace ZVision { + +class SaveControl : public Control { +public: + SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + +private: + struct save_elmnt { + int save_id; + int input_key; + bool exist; + }; + typedef Common::List saveElmntList; + saveElmntList _inputs; + + bool _saveControl; + +public: + + bool process(uint32 deltaTimeInMillis); + +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index d1d6e2862d..cacde9b3ca 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -31,6 +31,7 @@ #include "zvision/scripting/controls/push_toggle_control.h" #include "zvision/scripting/controls/lever_control.h" #include "zvision/scripting/controls/slot_control.h" +#include "zvision/scripting/controls/save_control.h" #include "zvision/scripting/controls/input_control.h" #include "common/textconsole.h" @@ -349,6 +350,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new SlotControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("input")) { return new InputControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("save")) { + return new SaveControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 1696e0dd9675f087608fdfabb7b5c93d7d2820df Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 4 Aug 2014 16:43:15 +0700 Subject: ZVISION: Prepare save data while changing location --- engines/zvision/scripting/script_manager.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 380141490a..7a2854d230 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -538,8 +538,18 @@ void ScriptManager::do_changeLocation() { } } - // Auto save - //_engine->getSaveManager()->autoSave(); + if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { + if (_nextLocation.node == 's' && _nextLocation.view == 'e' && + _currentLocation.world != 'g' && _currentLocation.room != 'j') + _engine->getSaveManager()->prepareSaveBuffer(); + } else { + if (_currentLocation.world == 'g' && _currentLocation.room == 'j') + _engine->getSaveManager()->flushSaveBuffer(); + else { + // Auto save + //_engine->getSaveManager()->autoSave(); + } + } setStateValue(StateKey_World, _nextLocation.world); setStateValue(StateKey_Room, _nextLocation.room); -- cgit v1.2.3 From 04d42638cde9022523910b9ec75130bd85ec1fa5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 4 Aug 2014 09:21:39 -0400 Subject: ACCESS: Fleshed out beginning of title sequence, added Screen::clip --- engines/access/access.cpp | 23 +++++++++----- engines/access/access.h | 7 +++++ engines/access/amazon/amazon_game.cpp | 37 +++++++++++++++++++--- engines/access/amazon/amazon_game.h | 2 +- engines/access/files.cpp | 14 ++++++--- engines/access/files.h | 4 +-- engines/access/screen.cpp | 59 +++++++++++++++++++++++++++++++++++ engines/access/screen.h | 8 +++++ engines/access/sound.cpp | 29 +++++++++++++++-- engines/access/sound.h | 19 +++++++++-- 10 files changed, 177 insertions(+), 25 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 25d9fcc99e..1470842e1b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -37,6 +37,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _graphics = nullptr; _screen = nullptr; _sound = nullptr; + + _destIn = nullptr; + _objectsTable = nullptr; } AccessEngine::~AccessEngine() { @@ -46,6 +49,14 @@ AccessEngine::~AccessEngine() { delete _graphics; delete _screen; delete _sound; + + _buffer1.free(); + _buffer2.free(); + delete[] _objectsTable; +} + +void AccessEngine::setVGA() { + initGraphics(320, 200, false); } void AccessEngine::initialize() { @@ -59,13 +70,16 @@ void AccessEngine::initialize() { _files = new FileManager(this); _graphics = new GraphicsManager(this); _screen = new Screen(this); - _sound = new SoundManager(this); + _sound = new SoundManager(this, _mixer); + + _buffer1.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); } Common::Error AccessEngine::run() { + setVGA(); initialize(); - setVGA(); _screen->setInitialPalettte(); _events->setCursor(CURSOR_0); _events->showCursor(); @@ -95,9 +109,4 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::setVGA() { - initGraphics(320, 200, false); -} - - } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 3386cd9e11..05ef545e38 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -97,6 +97,13 @@ public: GraphicsManager *_graphics; Screen *_screen; SoundManager *_sound; + + byte *_destIn; + Graphics::Surface _buffer1; + Graphics::Surface _buffer2; + byte *_objectsTable; + int _pCount; + public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 3f8ae73faa..30733087dd 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -30,19 +30,46 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine(syst, gameDesc) { } +AmazonEngine::~AmazonEngine() { +} + + void AmazonEngine::doTitle() { _screen->setDisplayScan(); + _destIn = (byte *)_buffer2.getPixels(); + _screen->forceFadeOut(); _events->hideCursor(); - _sound->_soundTable[0] = _sound->loadSound(98, 30); + _sound->queueSound(0, 98, 30); _sound->_soundPriority[0] = 1; - _sound->_soundTable[1] = _sound->loadSound(98, 8); - _sound->_soundPriority[1] = 2; _screen->_loadPalFlag = false; - byte *scr = _files->loadScreen(0, 3); - _screen->copyBuffer(scr); + _files->loadScreen(0, 3); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _screen->forceFadeIn(); + _sound->playSound(1); + + _objectsTable = _files->loadFile(0, 2); + _sound->playSound(1); + + _screen->_loadPalFlag = false; + _files->loadScreen(0, 4); + _sound->playSound(1); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _sound->playSound(1); + + const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; + for (int _pCount = 0; _pCount < 3; ++_pCount) { + _buffer2.copyFrom(_buffer1); + int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); + int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); + _screen->plotImage(_objectsTable, id, Common::Point(xp, 71)); + } } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 30ec2c6519..33d7833670 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -35,7 +35,7 @@ protected: public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); - virtual ~AmazonEngine() {} + virtual ~AmazonEngine(); }; } // End of namespace Amazon diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 7b4a23d0e8..37b2578cea 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -72,15 +72,18 @@ void FileManager::openFile(const Common::String &filename) { _filesize = _file.size(); } -byte *FileManager::loadScreen(int fileNum, int subfile) { +void FileManager::loadScreen(int fileNum, int subfile) { setAppended(fileNum); gotoAppended(subfile); _vm->_screen->loadPalette(_stream); - return handleFile(); + // Get the data for the screen, and copy it over + byte *pSrc = handleFile(); + Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); + delete[] pSrc; } -byte *FileManager::loadScreen(const Common::String &filename) { +void FileManager::loadScreen(const Common::String &filename) { // Open the file openFile(filename); @@ -91,7 +94,10 @@ byte *FileManager::loadScreen(const Common::String &filename) { delete _stream; _stream = _file.readStream(_file.size() - _file.pos()); - return handleFile(); + // Get the data for the screen, and copy it over + byte *pSrc = handleFile(); + Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); + delete[] pSrc; } byte *FileManager::handleFile() { diff --git a/engines/access/files.h b/engines/access/files.h index 9224b29429..848ee0d2ca 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -63,12 +63,12 @@ public: /** * Load a given scren from a container file */ - byte *loadScreen(int fileNum, int subfile); + void loadScreen(int fileNum, int subfile); /** * Load a given screen by name */ - byte *loadScreen(const Common::String &filename); + void loadScreen(const Common::String &filename); /** * Open up a sub-file container file diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 4059cab070..cb0154d56e 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -21,6 +21,8 @@ */ #include "common/algorithm.h" +#include "common/endian.h" +#include "common/rect.h" #include "common/textconsole.h" #include "common/system.h" #include "graphics/palette.h" @@ -33,6 +35,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); _loadPalFlag = false; + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + _clipWidth = _clipHeight = 0; } void Screen::setDisplayScan() { @@ -114,4 +119,58 @@ void Screen::copyBuffer(const byte *data) { g_system->copyRectToScreen(destP, w, 0, 0, w, h); } +void Screen::plotImage(const byte *pData, int idx, const Common::Point &pt) { + const byte *sizeP = pData + READ_LE_UINT16(pData + idx * 4); + int w = READ_LE_UINT16(sizeP); + int h = READ_LE_UINT16(sizeP + 2); + Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + h); + + if (!clip(r)) { + _lastBounds = r; + //plotf(); + } +} + +bool Screen::clip(Common::Rect &r) { + int skip; + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + + if (r.left > _clipWidth) { + skip = -r.left; + r.setWidth(r.width() - skip); + _leftSkip = skip; + r.moveTo(0, r.top); + } else if (r.left >= 0) + return true; + + int right = r.right - 1; + if (right < 0) + return true; + else if (right > _clipWidth) { + skip = right - _clipWidth; + r.setWidth(r.width() - skip); + _rightSkip = skip; + } + + if (r.top > _clipHeight) { + skip = -r.top; + r.setHeight(r.height() - skip); + _topSkip = skip; + r.moveTo(r.left, 0); + } else if (r.top >= 0) + return true; + + int bottom = r.bottom - 1; + if (bottom < 0) + return true; + else if (bottom > _clipHeight) { + skip = bottom - _clipHeight; + _bottomSkip = skip; + r.setHeight(r.height() - skip); + } + + return false; +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index d16333c46e..0d68c1bc7e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -40,10 +40,16 @@ private: AccessEngine *_vm; byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + Common::Rect _lastBounds; + int _leftSkip, _rightSkip; + int _topSkip, _bottomSkip; + int _clipWidth, _clipHeight; void setPalette(); void updatePalette(); + + bool clip(Common::Rect &r); public: bool _loadPalFlag; public: @@ -77,6 +83,8 @@ public: * Copy a buffer to the screen */ void copyBuffer(const byte *data); + + void plotImage(const byte *pData, int idx, const Common::Point &pt); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index baad6352b8..5375485695 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -21,24 +21,47 @@ */ #include "common/algorithm.h" +#include "audio/audiostream.h" #include "access/access.h" #include "access/sound.h" namespace Access { -SoundManager::SoundManager(AccessEngine *vm) : _vm(vm) { - Common::fill(&_soundTable[0], &_soundTable[MAX_SOUNDS], (byte *)nullptr); +SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : + _vm(vm), _mixer(mixer) { Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); + for (int i = 0; i < MAX_SOUNDS; ++i) + _soundTable[i]._data = nullptr; } SoundManager::~SoundManager() { for (int i = 0; i < MAX_SOUNDS; ++i) - delete _soundTable[i]; + delete _soundTable[i]._data; +} + +void SoundManager::queueSound(int idx, int fileNum, int subfile) { + /* + _soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._size = _vm->_files->_filesize; + */ } byte *SoundManager::loadSound(int fileNum, int subfile) { return _vm->_files->loadFile(fileNum, subfile); } +void SoundManager::playSound(int soundIndex) { + int idx = _soundPriority[soundIndex - 1] - 1; + playSound(_soundTable[idx]._data, _soundTable[idx]._size); +} + +void SoundManager::playSound(byte *data, uint32 size) { + /* + Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); + audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); + _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, + Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false); + */ +} } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 5d173e2e2b..d3d5052c0e 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -24,6 +24,7 @@ #define ACCESS_SOUND_H #include "common/scummsys.h" +#include "audio/mixer.h" #define MAX_SOUNDS 20 @@ -32,16 +33,28 @@ namespace Access { class AccessEngine; class SoundManager { + struct SoundEntry { + byte *_data; + uint32 _size; + }; private: AccessEngine *_vm; + Audio::Mixer *_mixer; + Audio::SoundHandle _soundHandle; + + byte *loadSound(int fileNum, int subfile); + + void playSound(byte *data, uint32 size); public: - byte *_soundTable[MAX_SOUNDS]; + SoundEntry _soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; public: - SoundManager(AccessEngine *vm); + SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); - byte *loadSound(int fileNum, int subfile); + void queueSound(int idx, int fileNum, int subfile); + + void playSound(int soundIndex); }; } // End of namespace Access -- cgit v1.2.3 From bb48a153a6479e08fe37c3547e14622226efeeb2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 4 Aug 2014 21:35:49 -0400 Subject: ACCESS: Remove graphics manager, and added more skeleton for Amazon intro --- engines/access/access.cpp | 9 +------ engines/access/access.h | 6 ++--- engines/access/amazon/amazon_game.cpp | 39 +++++++++++++++++++++++++++ engines/access/amazon/amazon_game.h | 22 ++++++++++++++- engines/access/asurface.cpp | 33 +++++++++++++++++++++++ engines/access/asurface.h | 38 ++++++++++++++++++++++++++ engines/access/graphics.cpp | 42 ----------------------------- engines/access/graphics.h | 50 ----------------------------------- engines/access/module.mk | 2 +- engines/access/screen.cpp | 9 +++++++ engines/access/screen.h | 13 +++++++-- 11 files changed, 155 insertions(+), 108 deletions(-) create mode 100644 engines/access/asurface.cpp create mode 100644 engines/access/asurface.h delete mode 100644 engines/access/graphics.cpp delete mode 100644 engines/access/graphics.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 1470842e1b..af64612e01 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,7 +34,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; - _graphics = nullptr; _screen = nullptr; _sound = nullptr; @@ -46,7 +45,6 @@ AccessEngine::~AccessEngine() { delete _debugger; delete _events; delete _files; - delete _graphics; delete _screen; delete _sound; @@ -68,7 +66,6 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); - _graphics = new GraphicsManager(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); @@ -80,11 +77,7 @@ Common::Error AccessEngine::run() { setVGA(); initialize(); - _screen->setInitialPalettte(); - _events->setCursor(CURSOR_0); - _events->showCursor(); - _graphics->setPanel(0); - doTitle(); + playGame(); dummyLoop(); return Common::kNoError; diff --git a/engines/access/access.h b/engines/access/access.h index 05ef545e38..f6d51cc744 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -33,7 +33,6 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" -#include "access/graphics.h" #include "access/screen.h" #include "access/sound.h" @@ -87,14 +86,13 @@ protected: virtual bool hasFeature(EngineFeature f) const; protected: /** - * Show game title + * Play the game */ - virtual void doTitle() = 0; + virtual void playGame() = 0; public: Debugger *_debugger; EventsManager *_events; FileManager *_files; - GraphicsManager *_graphics; Screen *_screen; SoundManager *_sound; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 30733087dd..681819f602 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -28,11 +28,41 @@ namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc) { + _skipStart = false; } AmazonEngine::~AmazonEngine() { } +void AmazonEngine::playGame() { + _screen->setInitialPalettte(); + _events->setCursor(CURSOR_0); + _events->showCursor(); + _screen->setPanel(0); + + doTitle(); + if (shouldQuit()) + return; + + if (!_skipStart) { + _screen->setPanel(3); + doOpening(); + if (shouldQuit()) + return; + + if (!_skipStart) { + doTent(); + if (shouldQuit()) + return; + } + } + + doTitle(); + if (shouldQuit()) + return; + + _screen->clearScreen(); +} void AmazonEngine::doTitle() { _screen->setDisplayScan(); @@ -70,6 +100,15 @@ void AmazonEngine::doTitle() { int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); _screen->plotImage(_objectsTable, id, Common::Point(xp, 71)); } + // TODO: More to do +} + +void AmazonEngine::doOpening() { + // TODO +} + +void AmazonEngine::doTent() { + // TODO } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 33d7833670..79a74b329f 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -30,8 +30,28 @@ namespace Access { namespace Amazon { class AmazonEngine : public AccessEngine { +private: + bool _skipStart; + + /** + * Do title sequence + */ + void doTitle(); + + /** + * Do opening sequence + */ + void doOpening(); + + /** + * Do tent scene of introduction + */ + void doTent(); protected: - virtual void doTitle(); + /** + * Play the game + */ + virtual void playGame(); public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp new file mode 100644 index 0000000000..a0a790dbdc --- /dev/null +++ b/engines/access/asurface.cpp @@ -0,0 +1,33 @@ +/* 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 "common/algorithm.h" +#include "access/asurface.h" + +namespace Access { + +void ASurface::clearBuffer() { + byte *pSrc = (byte *)getPixels(); + Common::fill(pSrc, pSrc + w * h, 0); +} + +} // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h new file mode 100644 index 0000000000..ecd04b9682 --- /dev/null +++ b/engines/access/asurface.h @@ -0,0 +1,38 @@ +/* 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 ACCESS_ASURFACE_H +#define ACCESS_ASURFACE_H + +#include "common/rect.h" +#include "graphics/surface.h" + +namespace Access { + +class ASurface : public Graphics::Surface { +public: + void clearBuffer(); +}; + +} // End of namespace Access + +#endif /* ACCESS_ASURFACE_H */ diff --git a/engines/access/graphics.cpp b/engines/access/graphics.cpp deleted file mode 100644 index c1187f2eb3..0000000000 --- a/engines/access/graphics.cpp +++ /dev/null @@ -1,42 +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 "graphics/palette.h" -#include "access/access.h" -#include "access/graphics.h" -#include "access/resources.h" - -namespace Access { - -GraphicsManager::GraphicsManager(AccessEngine *vm) : _vm(vm) { - _vesaCurrentWin = 0; - _currentPanel = 0; - _hideFlag = true; -} - -void GraphicsManager::setPanel(int num) { - assert(num < 4); - _currentPanel = num; - _msVirtualOffset = _virtualOffsetsTable[num]; -} - -} // End of namespace Access diff --git a/engines/access/graphics.h b/engines/access/graphics.h deleted file mode 100644 index df626176fa..0000000000 --- a/engines/access/graphics.h +++ /dev/null @@ -1,50 +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 ACCESS_GRAPHICS_H -#define ACCESS_GRAPHICS_H - -#include "common/rect.h" -#include "graphics/surface.h" - -namespace Access { - -class AccessEngine; - -class GraphicsManager { -private: - AccessEngine *_vm; -public: - int _vesaCurrentWin; - int _currentPanel; - Common::Point _msVirtualOffset; - Common::Point _virtualOffsetsTable[4]; - bool _hideFlag; -public: - GraphicsManager(AccessEngine *vm); - - void setPanel(int num); -}; - -} // End of namespace Access - -#endif /* ACCESS_GRAPHICS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index c9d593de22..ff4cedbdc6 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -1,13 +1,13 @@ MODULE := engines/access MODULE_OBJS := \ + asurface.o \ access.o \ debugger.o \ decompress.o \ detection.o \ events.o \ files.o \ - graphics.o \ resources.o \ screen.o \ sound.o \ diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index cb0154d56e..591bb67a7f 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -34,6 +34,9 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + _vesaCurrentWin = 0; + _currentPanel = 0; + _hideFlag = true; _loadPalFlag = false; _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; @@ -44,6 +47,12 @@ void Screen::setDisplayScan() { warning("TODO: setDisplayScan"); } +void Screen::setPanel(int num) { + assert(num < 4); + _currentPanel = num; + _msVirtualOffset = _virtualOffsetsTable[num]; +} + void Screen::updateScreen() { g_system->updateScreen(); } diff --git a/engines/access/screen.h b/engines/access/screen.h index 0d68c1bc7e..295372770a 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -26,7 +26,7 @@ #include "common/scummsys.h" #include "common/rect.h" #include "common/stream.h" -#include "graphics/surface.h" +#include "access/asurface.h" namespace Access { @@ -35,11 +35,16 @@ class AccessEngine; #define PALETTE_COUNT 256 #define PALETTE_SIZE (256 * 3) -class Screen: public Graphics::Surface { +class Screen: public ASurface { private: AccessEngine *_vm; byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + int _vesaCurrentWin; + int _currentPanel; + Common::Point _msVirtualOffset; + Common::Point _virtualOffsetsTable[4]; + bool _hideFlag; Common::Rect _lastBounds; int _leftSkip, _rightSkip; int _topSkip, _bottomSkip; @@ -57,6 +62,8 @@ public: void setDisplayScan(); + void setPanel(int num); + /** * Update the underlying screen */ @@ -72,6 +79,8 @@ public: */ void forceFadeIn(); + void clearScreen() { clearBuffer(); } + /** * Set the initial palette */ -- cgit v1.2.3 From e6b1d148ce184a53598fbf9cefa28689678b47a9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 4 Aug 2014 22:38:50 -0400 Subject: ACCESS: Added Globals classes --- engines/access/access.cpp | 19 ++++++++ engines/access/access.h | 19 ++++++++ engines/access/amazon/amazon_game.cpp | 8 +++ engines/access/amazon/amazon_game.h | 6 +++ engines/access/amazon/amazon_globals.cpp | 48 ++++++++++++++++++ engines/access/amazon/amazon_globals.h | 58 ++++++++++++++++++++++ engines/access/globals.cpp | 75 ++++++++++++++++++++++++++++ engines/access/globals.h | 84 ++++++++++++++++++++++++++++++++ engines/access/module.mk | 4 +- 9 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 engines/access/amazon/amazon_globals.cpp create mode 100644 engines/access/amazon/amazon_globals.h create mode 100644 engines/access/globals.cpp create mode 100644 engines/access/globals.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index af64612e01..3639115455 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,11 +34,30 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; + _globals = nullptr; _screen = nullptr; _sound = nullptr; _destIn = nullptr; _objectsTable = nullptr; + _pCount = 0; + _currentMan = 0; + _currentManOld = -1; + _man1 = nullptr; + _manPal1 = nullptr; + _music = nullptr; + _playField = nullptr; + _script = nullptr; + _anim = nullptr; + _title = nullptr; + _converseMode = 0; + _startInvItem = 0; + _startAboutItem = 0; + _startTravelItem = 0; + _startInvBox = 0; + _startAboutBox = 0; + _startTravelBox = 0; + } AccessEngine::~AccessEngine() { diff --git a/engines/access/access.h b/engines/access/access.h index f6d51cc744..34287116ba 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -33,6 +33,7 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" +#include "access/globals.h" #include "access/screen.h" #include "access/sound.h" @@ -93,6 +94,7 @@ public: Debugger *_debugger; EventsManager *_events; FileManager *_files; + Globals *_globals; Screen *_screen; SoundManager *_sound; @@ -102,6 +104,23 @@ public: byte *_objectsTable; int _pCount; + int _currentMan; + int _currentManOld; + byte *_man1; + byte *_manPal1; + byte *_music; + byte *_playField; + byte *_script; + byte *_anim; + byte *_title; + int _converseMode; + int _startInvItem; + int _startAboutItem; + int _startTravelItem; + int _startInvBox; + int _startAboutBox; + int _startTravelBox; + public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 681819f602..af7b77e743 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -21,6 +21,7 @@ */ #include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_globals.h" namespace Access { @@ -28,10 +29,12 @@ namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc) { + _globals = new AmazonGlobals(); _skipStart = false; } AmazonEngine::~AmazonEngine() { + delete _globals; } void AmazonEngine::playGame() { @@ -62,6 +65,10 @@ void AmazonEngine::playGame() { return; _screen->clearScreen(); + _screen->setPanel(0); + _screen->forceFadeOut(); + + } void AmazonEngine::doTitle() { @@ -111,6 +118,7 @@ void AmazonEngine::doTent() { // TODO } + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 79a74b329f..42fc31d724 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -24,6 +24,7 @@ #define ACCESS_AMAZON_GAME_H #include "access/access.h" +#include "access/amazon/amazon_globals.h" namespace Access { @@ -47,6 +48,11 @@ private: * Do tent scene of introduction */ void doTent(); + + /** + * Get globals reference + */ + AmazonGlobals &globals() { return *(AmazonGlobals *)_globals; } protected: /** * Play the game diff --git a/engines/access/amazon/amazon_globals.cpp b/engines/access/amazon/amazon_globals.cpp new file mode 100644 index 0000000000..7982233730 --- /dev/null +++ b/engines/access/amazon/amazon_globals.cpp @@ -0,0 +1,48 @@ +/* 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 = 0; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "access/amazon/amazon_globals.h" + +namespace Access { + +namespace Amazon { + +AmazonGlobals::AmazonGlobals() : Globals() { + _canoeLane = 0; + _canoeYPos = 0; + _hitCount = 0; + _saveRiver = 0; + _hitSafe = 0; + _chapter = 0; + _topList = 0; + _botList = 0; + _riverIndex = 0; + _rawInactiveX = 0; + _rawInactiveY = 0; + _inactiveYOff = 0; + Common::fill(&_esTabTable[0], &_esTabTable[100], 0); +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_globals.h b/engines/access/amazon/amazon_globals.h new file mode 100644 index 0000000000..d9631f7450 --- /dev/null +++ b/engines/access/amazon/amazon_globals.h @@ -0,0 +1,58 @@ +/* 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 ACCESS_AMAZON_GLOBALS_H +#define ACCESS_AMAZON_GLOBALS_H + +#include "common/scummsys.h" +#include "access/globals.h" + +namespace Access { + +namespace Amazon { + +class AmazonGlobals: public Globals { +public: + int _canoeLane; + int _canoeYPos; + int _hitCount; + int _saveRiver; + int _hitSafe; + int _chapter; + int _topList; + int _botList; + int _riverIndex; + int _rawInactiveX; + int _rawInactiveY; + int _inactiveYOff; + int _esTabTable[100]; +public: + AmazonGlobals(); + + virtual ~AmazonGlobals() {} +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_GLOBALS_H */ diff --git a/engines/access/globals.cpp b/engines/access/globals.cpp new file mode 100644 index 0000000000..ab0c37b168 --- /dev/null +++ b/engines/access/globals.cpp @@ -0,0 +1,75 @@ +/* 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 = 0; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "access/globals.h" + +namespace Access { + +Globals::Globals() { + _startData = 0; + _rawPlayerXLow = 0; + _rawPlayerX = 0; + _rawPlayerYLow = 0; + _rawPlayerY = 0; + _conversation = 0; + _currentMan = 0; + _newTime = 0; + _newDate = 0; + _intTim[3] = 0; + _timer[3] = 0; + _timerFlag = false; + Common::fill(&_flags[0], &_flags[99], 0); + Common::fill(&_useItem[0], &_useItem[23], 0); + _guardLoc = 0; + _guardFind = 0; + _helpLevel = 0; + _jasMayaFlag = 0; + _moreHelp = 0; + _startup = 0; + _flashbackFlag = false; + _manScaleOff = 0; + _riverFlag = false; + _antOutFlag = false; + _badEnd = 0; + _noHints = false; + _antFlag = false; + _allenFlag = false; + _noSound = false; + Common::fill(&inv[0], &inv[85], 0); + Common::fill(&_help1[0], &_help1[366], 0); + Common::fill(&_help2[0], &_help2[366], 0); + Common::fill(&_help1[0], &_help3[366], 0); + _travel = 0; + _ask = 0; + _rScrollRow = 0; + _rScrollCol = 0; + _rSrcollX = 0; + _rScrollY = 0; + _rOldRectCount = 0; + _rNewRectCount = 0; + _rKeyFlag = 0; + _mapOffset = 0; + _screenVirtX = 0; +} + +} // End of namespace Access diff --git a/engines/access/globals.h b/engines/access/globals.h new file mode 100644 index 0000000000..30dbd46ad8 --- /dev/null +++ b/engines/access/globals.h @@ -0,0 +1,84 @@ +/* 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 ACCESS_GLOBALS_H +#define ACCESS_GLOBALS_H + +#include "common/scummsys.h" + +namespace Access { + +class Globals { +public: + int _startData; + int _rawPlayerXLow; + int _rawPlayerX; + int _rawPlayerYLow; + int _rawPlayerY; + int _conversation; + int _currentMan; + uint32 _newTime; + uint32 _newDate; + int _intTim[3]; + int _timer[3]; + bool _timerFlag; + byte _flags[99]; + byte _useItem[23]; + int _guardLoc; + int _guardFind; + int _helpLevel; + int _jasMayaFlag; + int _moreHelp; + int _startup; + bool _flashbackFlag; + int _manScaleOff; + bool _riverFlag; + bool _antOutFlag; + int _badEnd; + bool _noHints; + bool _antFlag; + bool _allenFlag; + bool _noSound; + int inv[85]; + byte _help1[366]; + byte _help2[366]; + byte _help3[366]; + int _travel; + int _ask; + int _rScrollRow; + int _rScrollCol; + int _rSrcollX; + int _rScrollY; + int _rOldRectCount; + int _rNewRectCount; + int _rKeyFlag; + int _mapOffset; + int _screenVirtX; +public: + Globals(); + + virtual ~Globals() {} +}; + +} // End of namespace Access + +#endif /* ACCESS_GLOBALS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index ff4cedbdc6..e49a11be41 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -8,10 +8,12 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ + globals.o \ resources.o \ screen.o \ sound.o \ - amazon\amazon_game.o + amazon\amazon_game.o \ + amazon\amazon_globals.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) -- cgit v1.2.3 From c4fb766811d523a28630c98ca535cb9c6000acf5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 20:04:41 -0400 Subject: ACCESS: Moved globals into the main engine classes --- engines/access/access.cpp | 45 ++++++++++++++++- engines/access/access.h | 48 ++++++++++++++++-- engines/access/amazon/amazon_game.cpp | 17 +++++-- engines/access/amazon/amazon_game.h | 22 ++++++--- engines/access/amazon/amazon_globals.cpp | 48 ------------------ engines/access/amazon/amazon_globals.h | 58 ---------------------- engines/access/globals.cpp | 75 ---------------------------- engines/access/globals.h | 84 -------------------------------- engines/access/module.mk | 4 +- 9 files changed, 120 insertions(+), 281 deletions(-) delete mode 100644 engines/access/amazon/amazon_globals.cpp delete mode 100644 engines/access/amazon/amazon_globals.h delete mode 100644 engines/access/globals.cpp delete mode 100644 engines/access/globals.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 3639115455..fdf6cd03b0 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,7 +34,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; - _globals = nullptr; _screen = nullptr; _sound = nullptr; @@ -58,6 +57,50 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startAboutBox = 0; _startTravelBox = 0; + _startData = 0; + _rawPlayerXLow = 0; + _rawPlayerX = 0; + _rawPlayerYLow = 0; + _rawPlayerY = 0; + _conversation = 0; + _currentMan = 0; + _newTime = 0; + _newDate = 0; + _intTim[3] = 0; + _timer[3] = 0; + _timerFlag = false; + Common::fill(&_flags[0], &_flags[99], 0); + Common::fill(&_useItem[0], &_useItem[23], 0); + _guardLoc = 0; + _guardFind = 0; + _helpLevel = 0; + _jasMayaFlag = 0; + _moreHelp = 0; + _startup = 0; + _flashbackFlag = false; + _manScaleOff = 0; + _riverFlag = false; + _antOutFlag = false; + _badEnd = 0; + _noHints = false; + _antFlag = false; + _allenFlag = false; + _noSound = false; + Common::fill(&inv[0], &inv[85], 0); + Common::fill(&_help1[0], &_help1[366], 0); + Common::fill(&_help2[0], &_help2[366], 0); + Common::fill(&_help1[0], &_help3[366], 0); + _travel = 0; + _ask = 0; + _rScrollRow = 0; + _rScrollCol = 0; + _rSrcollX = 0; + _rScrollY = 0; + _rOldRectCount = 0; + _rNewRectCount = 0; + _rKeyFlag = 0; + _mapOffset = 0; + _screenVirtX = 0; } AccessEngine::~AccessEngine() { diff --git a/engines/access/access.h b/engines/access/access.h index 34287116ba..fd95c912bc 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -33,7 +33,6 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" -#include "access/globals.h" #include "access/screen.h" #include "access/sound.h" @@ -94,7 +93,6 @@ public: Debugger *_debugger; EventsManager *_events; FileManager *_files; - Globals *_globals; Screen *_screen; SoundManager *_sound; @@ -104,7 +102,6 @@ public: byte *_objectsTable; int _pCount; - int _currentMan; int _currentManOld; byte *_man1; byte *_manPal1; @@ -121,6 +118,51 @@ public: int _startAboutBox; int _startTravelBox; + // Fields that are included in savegames + int _startData; + int _rawPlayerXLow; + int _rawPlayerX; + int _rawPlayerYLow; + int _rawPlayerY; + int _conversation; + int _currentMan; + uint32 _newTime; + uint32 _newDate; + int _intTim[3]; + int _timer[3]; + bool _timerFlag; + byte _flags[99]; + byte _useItem[23]; + int _guardLoc; + int _guardFind; + int _helpLevel; + int _jasMayaFlag; + int _moreHelp; + int _startup; + bool _flashbackFlag; + int _manScaleOff; + bool _riverFlag; + bool _antOutFlag; + int _badEnd; + bool _noHints; + bool _antFlag; + bool _allenFlag; + bool _noSound; + int inv[85]; + byte _help1[366]; + byte _help2[366]; + byte _help3[366]; + int _travel; + int _ask; + int _rScrollRow; + int _rScrollCol; + int _rSrcollX; + int _rScrollY; + int _rOldRectCount; + int _rNewRectCount; + int _rKeyFlag; + int _mapOffset; + int _screenVirtX; public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index af7b77e743..068d3bf6f8 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -21,7 +21,6 @@ */ #include "access/amazon/amazon_game.h" -#include "access/amazon/amazon_globals.h" namespace Access { @@ -29,12 +28,24 @@ namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc) { - _globals = new AmazonGlobals(); _skipStart = false; + + _canoeLane = 0; + _canoeYPos = 0; + _hitCount = 0; + _saveRiver = 0; + _hitSafe = 0; + _chapter = 0; + _topList = 0; + _botList = 0; + _riverIndex = 0; + _rawInactiveX = 0; + _rawInactiveY = 0; + _inactiveYOff = 0; + Common::fill(&_esTabTable[0], &_esTabTable[100], 0); } AmazonEngine::~AmazonEngine() { - delete _globals; } void AmazonEngine::playGame() { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 42fc31d724..1b5397b033 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -24,7 +24,6 @@ #define ACCESS_AMAZON_GAME_H #include "access/access.h" -#include "access/amazon/amazon_globals.h" namespace Access { @@ -34,6 +33,22 @@ class AmazonEngine : public AccessEngine { private: bool _skipStart; + // Fields that are included in savegames + int _canoeLane; + int _canoeYPos; + int _hitCount; + int _saveRiver; + int _hitSafe; + int _chapter; + int _topList; + int _botList; + int _riverIndex; + int _rawInactiveX; + int _rawInactiveY; + int _inactiveYOff; + int _esTabTable[100]; + + /** * Do title sequence */ @@ -48,11 +63,6 @@ private: * Do tent scene of introduction */ void doTent(); - - /** - * Get globals reference - */ - AmazonGlobals &globals() { return *(AmazonGlobals *)_globals; } protected: /** * Play the game diff --git a/engines/access/amazon/amazon_globals.cpp b/engines/access/amazon/amazon_globals.cpp deleted file mode 100644 index 7982233730..0000000000 --- a/engines/access/amazon/amazon_globals.cpp +++ /dev/null @@ -1,48 +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 = 0; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/algorithm.h" -#include "access/amazon/amazon_globals.h" - -namespace Access { - -namespace Amazon { - -AmazonGlobals::AmazonGlobals() : Globals() { - _canoeLane = 0; - _canoeYPos = 0; - _hitCount = 0; - _saveRiver = 0; - _hitSafe = 0; - _chapter = 0; - _topList = 0; - _botList = 0; - _riverIndex = 0; - _rawInactiveX = 0; - _rawInactiveY = 0; - _inactiveYOff = 0; - Common::fill(&_esTabTable[0], &_esTabTable[100], 0); -} - -} // End of namespace Amazon - -} // End of namespace Access diff --git a/engines/access/amazon/amazon_globals.h b/engines/access/amazon/amazon_globals.h deleted file mode 100644 index d9631f7450..0000000000 --- a/engines/access/amazon/amazon_globals.h +++ /dev/null @@ -1,58 +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 ACCESS_AMAZON_GLOBALS_H -#define ACCESS_AMAZON_GLOBALS_H - -#include "common/scummsys.h" -#include "access/globals.h" - -namespace Access { - -namespace Amazon { - -class AmazonGlobals: public Globals { -public: - int _canoeLane; - int _canoeYPos; - int _hitCount; - int _saveRiver; - int _hitSafe; - int _chapter; - int _topList; - int _botList; - int _riverIndex; - int _rawInactiveX; - int _rawInactiveY; - int _inactiveYOff; - int _esTabTable[100]; -public: - AmazonGlobals(); - - virtual ~AmazonGlobals() {} -}; - -} // End of namespace Amazon - -} // End of namespace Access - -#endif /* ACCESS_AMAZON_GLOBALS_H */ diff --git a/engines/access/globals.cpp b/engines/access/globals.cpp deleted file mode 100644 index ab0c37b168..0000000000 --- a/engines/access/globals.cpp +++ /dev/null @@ -1,75 +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 = 0; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation = 0; 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 = 0; 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 = 0; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/algorithm.h" -#include "access/globals.h" - -namespace Access { - -Globals::Globals() { - _startData = 0; - _rawPlayerXLow = 0; - _rawPlayerX = 0; - _rawPlayerYLow = 0; - _rawPlayerY = 0; - _conversation = 0; - _currentMan = 0; - _newTime = 0; - _newDate = 0; - _intTim[3] = 0; - _timer[3] = 0; - _timerFlag = false; - Common::fill(&_flags[0], &_flags[99], 0); - Common::fill(&_useItem[0], &_useItem[23], 0); - _guardLoc = 0; - _guardFind = 0; - _helpLevel = 0; - _jasMayaFlag = 0; - _moreHelp = 0; - _startup = 0; - _flashbackFlag = false; - _manScaleOff = 0; - _riverFlag = false; - _antOutFlag = false; - _badEnd = 0; - _noHints = false; - _antFlag = false; - _allenFlag = false; - _noSound = false; - Common::fill(&inv[0], &inv[85], 0); - Common::fill(&_help1[0], &_help1[366], 0); - Common::fill(&_help2[0], &_help2[366], 0); - Common::fill(&_help1[0], &_help3[366], 0); - _travel = 0; - _ask = 0; - _rScrollRow = 0; - _rScrollCol = 0; - _rSrcollX = 0; - _rScrollY = 0; - _rOldRectCount = 0; - _rNewRectCount = 0; - _rKeyFlag = 0; - _mapOffset = 0; - _screenVirtX = 0; -} - -} // End of namespace Access diff --git a/engines/access/globals.h b/engines/access/globals.h deleted file mode 100644 index 30dbd46ad8..0000000000 --- a/engines/access/globals.h +++ /dev/null @@ -1,84 +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 ACCESS_GLOBALS_H -#define ACCESS_GLOBALS_H - -#include "common/scummsys.h" - -namespace Access { - -class Globals { -public: - int _startData; - int _rawPlayerXLow; - int _rawPlayerX; - int _rawPlayerYLow; - int _rawPlayerY; - int _conversation; - int _currentMan; - uint32 _newTime; - uint32 _newDate; - int _intTim[3]; - int _timer[3]; - bool _timerFlag; - byte _flags[99]; - byte _useItem[23]; - int _guardLoc; - int _guardFind; - int _helpLevel; - int _jasMayaFlag; - int _moreHelp; - int _startup; - bool _flashbackFlag; - int _manScaleOff; - bool _riverFlag; - bool _antOutFlag; - int _badEnd; - bool _noHints; - bool _antFlag; - bool _allenFlag; - bool _noSound; - int inv[85]; - byte _help1[366]; - byte _help2[366]; - byte _help3[366]; - int _travel; - int _ask; - int _rScrollRow; - int _rScrollCol; - int _rSrcollX; - int _rScrollY; - int _rOldRectCount; - int _rNewRectCount; - int _rKeyFlag; - int _mapOffset; - int _screenVirtX; -public: - Globals(); - - virtual ~Globals() {} -}; - -} // End of namespace Access - -#endif /* ACCESS_GLOBALS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index e49a11be41..ff4cedbdc6 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -8,12 +8,10 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ - globals.o \ resources.o \ screen.o \ sound.o \ - amazon\amazon_game.o \ - amazon\amazon_globals.o + amazon\amazon_game.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) -- cgit v1.2.3 From f1309a7b0b7e98256b45e9977c62f040452d54c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 20:59:44 -0400 Subject: ACCESS: Remainder of Amazon game initialization added --- engines/access/access.cpp | 16 ++++++-- engines/access/access.h | 21 ++++++++-- engines/access/amazon/amazon_game.cpp | 54 ++++++++++++++++++++------ engines/access/amazon/amazon_game.h | 10 +++++ engines/access/data.cpp | 46 ++++++++++++++++++++++ engines/access/data.h | 72 +++++++++++++++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/resources.cpp | 69 +++++++++++++++++++++++++++++++++ engines/access/resources.h | 2 + 9 files changed, 274 insertions(+), 17 deletions(-) create mode 100644 engines/access/data.cpp create mode 100644 engines/access/data.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index fdf6cd03b0..2a61a8ff8a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -38,8 +38,11 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _sound = nullptr; _destIn = nullptr; - _objectsTable = nullptr; + clearCellTable(); _pCount = 0; + _selectCommand = 0; + _normalMouse = true; + _mouseMode = 0; _currentMan = 0; _currentManOld = -1; _man1 = nullptr; @@ -57,7 +60,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startAboutBox = 0; _startTravelBox = 0; - _startData = 0; + _roomNumber = 0; _rawPlayerXLow = 0; _rawPlayerX = 0; _rawPlayerYLow = 0; @@ -112,7 +115,6 @@ AccessEngine::~AccessEngine() { _buffer1.free(); _buffer2.free(); - delete[] _objectsTable; } void AccessEngine::setVGA() { @@ -164,4 +166,12 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +void AccessEngine::clearCellTable() { + Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); +} + +void AccessEngine::doRoom() { + // TODO +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index fd95c912bc..869441e96b 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -30,6 +30,7 @@ #include "common/util.h" #include "engines/engine.h" #include "graphics/surface.h" +#include "access/data.h" #include "access/debugger.h" #include "access/events.h" #include "access/files.h" @@ -63,7 +64,6 @@ enum AccessDebugChannels { struct AccessGameDescription; - class AccessEngine : public Engine { private: /** @@ -81,6 +81,16 @@ protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; + /** + * Clear the cell table + */ + void clearCellTable(); + + /** + * Main handler for showing game rooms + */ + void doRoom(); + // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; @@ -99,8 +109,13 @@ public: byte *_destIn; Graphics::Surface _buffer1; Graphics::Surface _buffer2; - byte *_objectsTable; + byte *_objectsTable[100]; + Common::Array _timers; + Player _player; int _pCount; + int _selectCommand; + bool _normalMouse; + int _mouseMode; int _currentManOld; byte *_man1; @@ -119,7 +134,7 @@ public: int _startTravelBox; // Fields that are included in savegames - int _startData; + int _roomNumber; int _rawPlayerXLow; int _rawPlayerX; int _rawPlayerYLow; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 068d3bf6f8..6eef2cf93e 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -21,6 +21,7 @@ */ #include "access/amazon/amazon_game.h" +#include "access/resources.h" namespace Access { @@ -49,11 +50,30 @@ AmazonEngine::~AmazonEngine() { } void AmazonEngine::playGame() { + doIntroduction(); + if (shouldQuit()) + return; + + // Setup the game + setupGame(); + + _screen->clearScreen(); + _screen->setPanel(0); + _screen->forceFadeOut(); + + _events->showCursor(); + doRoom(); +} + +void AmazonEngine::doIntroduction() { _screen->setInitialPalettte(); _events->setCursor(CURSOR_0); _events->showCursor(); _screen->setPanel(0); - + + // TODO: Worry about implementing full intro sequence later + return; + doTitle(); if (shouldQuit()) return; @@ -72,14 +92,6 @@ void AmazonEngine::playGame() { } doTitle(); - if (shouldQuit()) - return; - - _screen->clearScreen(); - _screen->setPanel(0); - _screen->forceFadeOut(); - - } void AmazonEngine::doTitle() { @@ -100,7 +112,7 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); - _objectsTable = _files->loadFile(0, 2); + _objectsTable[0] = _files->loadFile(0, 2); _sound->playSound(1); _screen->_loadPalFlag = false; @@ -116,7 +128,7 @@ void AmazonEngine::doTitle() { _buffer2.copyFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); - _screen->plotImage(_objectsTable, id, Common::Point(xp, 71)); + _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); } // TODO: More to do } @@ -129,6 +141,26 @@ void AmazonEngine::doTent() { // TODO } +void AmazonEngine::setupGame() { + _chapter = 1; + clearCellTable(); + + // Setup timers + const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; + for (int i = 0; i < 32; ++i) { + TimerEntry te; + te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; + te._flag = true; + + _timers.push_back(te); + } + + // Set miscellaneous fields + _roomNumber = 4; + _player._playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0]; + _player._playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1]; + _selectCommand = -1; +} } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 1b5397b033..b998b1de83 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -48,6 +48,10 @@ private: int _inactiveYOff; int _esTabTable[100]; + /** + * Do the game introduction + */ + void doIntroduction(); /** * Do title sequence @@ -63,6 +67,12 @@ private: * Do tent scene of introduction */ void doTent(); + + /** + * Setup variables for the game + */ + void setupGame(); + protected: /** * Play the game diff --git a/engines/access/data.cpp b/engines/access/data.cpp new file mode 100644 index 0000000000..e5ee1e1e7f --- /dev/null +++ b/engines/access/data.cpp @@ -0,0 +1,46 @@ +/* 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 "access/data.h" +#include "common/algorithm.h" + +namespace Access { + +Player::Player() { + _field0 = 0; + _monData = nullptr; + Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0); + _rawTempL = 0; + _rawXTemp = 0; + _rawYTempL = 0; + _rawYTemp = 0; + _playerXLow = 0; + _playerX = 0; + _playerYLow = 0; + _playerY = 0; + _frame = 0; +} + +} // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h new file mode 100644 index 0000000000..069d543cb8 --- /dev/null +++ b/engines/access/data.h @@ -0,0 +1,72 @@ +/* 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 ACCESS_DATA_H +#define ACCESS_DATA_H + +#include "common/scummsys.h" +#include "common/rect.h" + +namespace Access { + +struct TimerEntry { + int _initTm; + int _timer; + bool _flag; + + TimerEntry() { + _initTm = _timer = 0; + _flag = false; + } +}; + +#define PLAYER_DATA_COUNT 8 + +class Player { +public: + int _field0; + byte *_monData; + int _walkOffRight[PLAYER_DATA_COUNT]; + int _walkOffLeft[PLAYER_DATA_COUNT]; + int _walkOffUp[PLAYER_DATA_COUNT]; + int _walkOffDown[PLAYER_DATA_COUNT]; + Common::Point _walkOffUR[PLAYER_DATA_COUNT]; + Common::Point _walkOffDR[PLAYER_DATA_COUNT]; + Common::Point _walkOffUL[PLAYER_DATA_COUNT]; + Common::Point _walkOffDL[PLAYER_DATA_COUNT]; + int _rawTempL; + int _rawXTemp; + int _rawYTempL; + int _rawYTemp; + Common::Point _playerOffset; + int _playerXLow; + int _playerX; + int _playerYLow; + int _playerY; + int _frame; +public: + Player(); +}; + +} // End of namespace Access + +#endif /* ACCESS_DATA_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index ff4cedbdc6..bab2476a4a 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -3,6 +3,7 @@ MODULE := engines/access MODULE_OBJS := \ asurface.o \ access.o \ + data.o \ debugger.o \ decompress.o \ detection.o \ diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index a47abf2b06..70d4a698b1 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -198,6 +198,75 @@ const byte CURSHELP[] = { 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 }; +const int TRAVEL_POS[][2] = { + { -1, 0 }, + { 228, 117 }, + { 28, 98 }, + { 161, 140 }, + { 130, 139 }, + { 884, 95 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 41, 185 }, + { 60, 138 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 170, 155 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 108, 95 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 100, 115 }, + { 480, 90 }, + { 154, 63 }, + { 0, 0 }, + { 145, 85 }, + { 0, 0 }, + { 110, 107 }, + { 0, 0 }, + { 105, 154 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 20, 160 }, + { 130, 314 }, + { 0, 0 }, + { 50, 125 }, + { 0, 0 }, + { 0, 0 }, + { 123, 123 }, + { -1, 7 }, + { 266, 168 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { -1, 18 }, + { -1, 19 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 203, 160 }, + { 0, 0 }, + { 283, 163 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 180, 165 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index ba335cd0ec..e73088102d 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -46,6 +46,8 @@ extern const byte CURSHELP[]; extern const byte *CURSORS[10]; +extern const int TRAVEL_POS[][2]; + } // End of namespace Amazon } // End of namespace Access -- cgit v1.2.3 From 7d605ce57316c86a247cf978e6b123b23045659c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 22:17:30 -0400 Subject: ACCESS: Implement outer room handler --- engines/access/access.cpp | 13 ++-- engines/access/access.h | 10 ++- engines/access/amazon/amazon_game.cpp | 6 +- engines/access/data.cpp | 17 ----- engines/access/data.h | 28 -------- engines/access/events.h | 2 +- engines/access/module.mk | 2 + engines/access/player.cpp | 53 ++++++++++++++ engines/access/player.h | 71 +++++++++++++++++++ engines/access/room.cpp | 130 ++++++++++++++++++++++++++++++++++ engines/access/room.h | 53 ++++++++++++++ engines/access/screen.cpp | 25 +++++++ engines/access/screen.h | 15 ++++ engines/access/sound.cpp | 5 ++ engines/access/sound.h | 2 + 15 files changed, 378 insertions(+), 54 deletions(-) create mode 100644 engines/access/player.cpp create mode 100644 engines/access/player.h create mode 100644 engines/access/room.cpp create mode 100644 engines/access/room.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2a61a8ff8a..fa1775feca 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,6 +34,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; + _player = nullptr; + _room = nullptr; _screen = nullptr; _sound = nullptr; @@ -59,6 +61,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startInvBox = 0; _startAboutBox = 0; _startTravelBox = 0; + _numImages = 0; + _nextImage = 0; + _numAnimTimers = 0; + _startup = 0; _roomNumber = 0; _rawPlayerXLow = 0; @@ -110,6 +116,8 @@ AccessEngine::~AccessEngine() { delete _debugger; delete _events; delete _files; + delete _player; + delete _room; delete _screen; delete _sound; @@ -130,6 +138,7 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); + _player = new Player(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); @@ -170,8 +179,4 @@ void AccessEngine::clearCellTable() { Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); } -void AccessEngine::doRoom() { - // TODO -} - } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 869441e96b..fce6c443f4 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -34,6 +34,8 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" +#include "access/player.h" +#include "access/room.h" #include "access/screen.h" #include "access/sound.h" @@ -103,6 +105,8 @@ public: Debugger *_debugger; EventsManager *_events; FileManager *_files; + Player *_player; + Room *_room; Screen *_screen; SoundManager *_sound; @@ -110,12 +114,16 @@ public: Graphics::Surface _buffer1; Graphics::Surface _buffer2; byte *_objectsTable[100]; + int _numAnimTimers; Common::Array _timers; - Player _player; + Common::Array _newRect; + Common::Array _oldRect; int _pCount; int _selectCommand; bool _normalMouse; int _mouseMode; + int _numImages; + int _nextImage; int _currentManOld; byte *_man1; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 6eef2cf93e..8cbd0767b2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -62,7 +62,7 @@ void AmazonEngine::playGame() { _screen->forceFadeOut(); _events->showCursor(); - doRoom(); + _room->doRoom(); } void AmazonEngine::doIntroduction() { @@ -157,8 +157,8 @@ void AmazonEngine::setupGame() { // Set miscellaneous fields _roomNumber = 4; - _player._playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0]; - _player._playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1]; + _player->_playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0]; + _player->_playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1]; _selectCommand = -1; } diff --git a/engines/access/data.cpp b/engines/access/data.cpp index e5ee1e1e7f..0ef1845892 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -25,22 +25,5 @@ namespace Access { -Player::Player() { - _field0 = 0; - _monData = nullptr; - Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); - Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); - Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); - Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0); - _rawTempL = 0; - _rawXTemp = 0; - _rawYTempL = 0; - _rawYTemp = 0; - _playerXLow = 0; - _playerX = 0; - _playerYLow = 0; - _playerY = 0; - _frame = 0; -} } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 069d543cb8..7e10e992d9 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -39,34 +39,6 @@ struct TimerEntry { } }; -#define PLAYER_DATA_COUNT 8 - -class Player { -public: - int _field0; - byte *_monData; - int _walkOffRight[PLAYER_DATA_COUNT]; - int _walkOffLeft[PLAYER_DATA_COUNT]; - int _walkOffUp[PLAYER_DATA_COUNT]; - int _walkOffDown[PLAYER_DATA_COUNT]; - Common::Point _walkOffUR[PLAYER_DATA_COUNT]; - Common::Point _walkOffDR[PLAYER_DATA_COUNT]; - Common::Point _walkOffUL[PLAYER_DATA_COUNT]; - Common::Point _walkOffDL[PLAYER_DATA_COUNT]; - int _rawTempL; - int _rawXTemp; - int _rawYTempL; - int _rawYTemp; - Common::Point _playerOffset; - int _playerXLow; - int _playerX; - int _playerYLow; - int _playerY; - int _frame; -public: - Player(); -}; - } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/events.h b/engines/access/events.h index 3cf610ece6..2e6b06b5e2 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -45,12 +45,12 @@ private: AccessEngine *_vm; uint32 _frameCounter; uint32 _priorFrameTime; - Common::Point _mousePos; void checkForNextFrameCounter(); public: CursorType _cursorId; bool _leftButton; + Common::Point _mousePos; public: /** * Constructor diff --git a/engines/access/module.mk b/engines/access/module.mk index bab2476a4a..791abcc861 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -9,7 +9,9 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ + player.o \ resources.o \ + room.o \ screen.o \ sound.o \ amazon\amazon_game.o diff --git a/engines/access/player.cpp b/engines/access/player.cpp new file mode 100644 index 0000000000..f7429bd9b5 --- /dev/null +++ b/engines/access/player.cpp @@ -0,0 +1,53 @@ +/* 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 "access/player.h" +#include "common/algorithm.h" +#include "common/textconsole.h" + +namespace Access { + +Player::Player(AccessEngine *vm): _vm(vm) { + _field0 = 0; + _monData = nullptr; + Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); + Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0); + _rawTempL = 0; + _rawXTemp = 0; + _rawYTempL = 0; + _rawYTemp = 0; + _playerXLow = 0; + _playerX = 0; + _playerYLow = 0; + _playerY = 0; + _frame = 0; + + _playerOff = false; +} + +void Player::walk() { + warning("TODO: Player::walk"); +} + +} // End of namespace Access diff --git a/engines/access/player.h b/engines/access/player.h new file mode 100644 index 0000000000..94ae9872b5 --- /dev/null +++ b/engines/access/player.h @@ -0,0 +1,71 @@ +/* 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 ACCESS_PLAYER_H +#define ACCESS_PLAYER_H + +#include "common/scummsys.h" +#include "common/rect.h" + +namespace Access { + +#define PLAYER_DATA_COUNT 8 + +class AccessEngine; + +class Player { +private: + AccessEngine *_vm; +public: + // Fields in original Player structure + int _field0; + byte *_monData; + int _walkOffRight[PLAYER_DATA_COUNT]; + int _walkOffLeft[PLAYER_DATA_COUNT]; + int _walkOffUp[PLAYER_DATA_COUNT]; + int _walkOffDown[PLAYER_DATA_COUNT]; + Common::Point _walkOffUR[PLAYER_DATA_COUNT]; + Common::Point _walkOffDR[PLAYER_DATA_COUNT]; + Common::Point _walkOffUL[PLAYER_DATA_COUNT]; + Common::Point _walkOffDL[PLAYER_DATA_COUNT]; + int _rawTempL; + int _rawXTemp; + int _rawYTempL; + int _rawYTemp; + Common::Point _playerOffset; + int _playerXLow; + int _playerX; + int _playerYLow; + int _playerY; + int _frame; + + // Additional globals we've added to new Player class + bool _playerOff; +public: + Player(AccessEngine *vm); + + void walk(); +}; + +} // End of namespace Access + +#endif /* ACCESS_PLAYER_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp new file mode 100644 index 0000000000..25d3584ede --- /dev/null +++ b/engines/access/room.cpp @@ -0,0 +1,130 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/room.h" + +namespace Access { + +Room::Room(AccessEngine *vm) : _vm(vm) { + _function = 0; +} + +void Room::doRoom() { + bool reloadFlag = false; + + while (!_vm->shouldQuit()) { + if (!reloadFlag) { + _vm->_numImages = 0; + _vm->_newRect.clear(); + _vm->_oldRect.clear(); + _vm->_nextImage = 0; + _vm->_numAnimTimers = 0; + } + + reloadFlag = false; + _vm->_startup = 0; + _function = 0; + + while (!_vm->shouldQuit()) { + _vm->_numImages = 0; + if (_vm->_startup != -1 && --_vm->_startup != 0) { + --_vm->_startup; + _vm->_events->showCursor(); + _vm->_screen->fadeIn(); + } + + _vm->_events->pollEvents(); + _vm->_nextImage = 0; + _vm->_player->walk(); + _vm->_sound->midiRepeat(); + _vm->_screen->checkScroll(); + doCommands(); + + // DOROOMFLASHBACK jump point + if (_function == 1) { + clearRoom(); + break; + } else if (_function == 2) { + clearRoom(); + return; + } else if (_function == 3) { + reloadRoom1(); + reloadFlag = true; + break; + } else if (_function == 4) { + break; + } + + if (_vm->_screen->_scrollFlag) { + _vm->_screen->copyBF1BF2(); + _vm->_newRect.clear(); + _function = 0; + roomLoop(); + + if (_function == 1) { + clearRoom(); + break; + } else { + _vm->_screen->plotList(); + _vm->_screen->copyRects(); + + _vm->_screen->copyBF2Vid(); + } + } else { + _vm->_screen->copyBF1BF2(); + _vm->_newRect.clear(); + _function = 0; + roomLoop(); + + if (_function == 1) { + clearRoom(); + break; + } else { + _vm->_screen->plotList(); + _vm->_screen->copyBlocks(); + } + } + } + } +} + +void Room::clearRoom() { + // TODO +} + +void Room::reloadRoom1() { + // TODO +} + +void Room::roomLoop() { + // TODO +} + + +void Room::doCommands() { + +} + + +} // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h new file mode 100644 index 0000000000..3b1a3347f9 --- /dev/null +++ b/engines/access/room.h @@ -0,0 +1,53 @@ +/* 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 ACCESS_ROOM_H +#define ACCESS_ROOM_H + +#include "common/scummsys.h" + +namespace Access { + +class AccessEngine; + +class Room { +private: + AccessEngine *_vm; + + void roomLoop(); +public: + int _function; +public: + Room(AccessEngine *vm); + + void doRoom(); + + void doCommands(); + + void clearRoom(); + + void reloadRoom1(); +}; + +} // End of namespace Access + +#endif /* ACCESS_ROOM_H */ diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 591bb67a7f..8c87638937 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -41,6 +41,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; _clipWidth = _clipHeight = 0; + _scrollFlag = false; } void Screen::setDisplayScan() { @@ -182,4 +183,28 @@ bool Screen::clip(Common::Rect &r) { return false; } +void Screen::checkScroll() { + // TODO +} + +void Screen::copyBF1BF2() { + // TODO +} + +void Screen::copyBF2Vid() { + // TODO +} + +void Screen::plotList() { + // TODO +} + +void Screen::copyBlocks() { + // TODO +} + +void Screen::copyRects() { + // TODO +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 295372770a..5f9fff058e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -57,6 +57,7 @@ private: bool clip(Common::Rect &r); public: bool _loadPalFlag; + bool _scrollFlag; public: Screen(AccessEngine *vm); @@ -79,6 +80,8 @@ public: */ void forceFadeIn(); + void fadeOut() { forceFadeOut(); } + void fadeIn() { forceFadeIn(); } void clearScreen() { clearBuffer(); } /** @@ -94,6 +97,18 @@ public: void copyBuffer(const byte *data); void plotImage(const byte *pData, int idx, const Common::Point &pt); + + void checkScroll(); + + void copyBF1BF2(); + + void copyBF2Vid(); + + void plotList(); + + void copyBlocks(); + + void copyRects(); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 5375485695..2a008d8c53 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -64,4 +64,9 @@ void SoundManager::playSound(byte *data, uint32 size) { */ } +void SoundManager::midiRepeat() { + // TODO +} + + } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index d3d5052c0e..613eca49ab 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -55,6 +55,8 @@ public: void queueSound(int idx, int fileNum, int subfile); void playSound(int soundIndex); + + void midiRepeat(); }; } // End of namespace Access -- cgit v1.2.3 From 8e43a6c5280e2b695753d4a0b6810811f1bd393f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 5 Aug 2014 23:23:49 -0400 Subject: ACCESS: Add scripts classes and Amazon room setup --- engines/access/access.cpp | 6 +- engines/access/access.h | 6 +- engines/access/amazon/amazon_game.cpp | 9 ++- engines/access/amazon/amazon_room.cpp | 121 +++++++++++++++++++++++++++++++ engines/access/amazon/amazon_room.h | 54 ++++++++++++++ engines/access/amazon/amazon_scripts.cpp | 36 +++++++++ engines/access/amazon/amazon_scripts.h | 42 +++++++++++ engines/access/module.mk | 5 +- engines/access/player.cpp | 8 ++ engines/access/player.h | 4 + engines/access/room.cpp | 48 ++++++++++++ engines/access/room.h | 13 +++- engines/access/screen.cpp | 4 + engines/access/screen.h | 6 +- engines/access/scripts.cpp | 42 +++++++++++ engines/access/scripts.h | 48 ++++++++++++ 16 files changed, 444 insertions(+), 8 deletions(-) create mode 100644 engines/access/amazon/amazon_room.cpp create mode 100644 engines/access/amazon/amazon_room.h create mode 100644 engines/access/amazon/amazon_scripts.cpp create mode 100644 engines/access/amazon/amazon_scripts.h create mode 100644 engines/access/scripts.cpp create mode 100644 engines/access/scripts.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index fa1775feca..e175b1c081 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -37,6 +37,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _player = nullptr; _room = nullptr; _screen = nullptr; + _scripts = nullptr; _sound = nullptr; _destIn = nullptr; @@ -48,10 +49,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _currentMan = 0; _currentManOld = -1; _man1 = nullptr; + _inactive = nullptr; _manPal1 = nullptr; _music = nullptr; _playField = nullptr; - _script = nullptr; _anim = nullptr; _title = nullptr; _converseMode = 0; @@ -65,6 +66,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _nextImage = 0; _numAnimTimers = 0; _startup = 0; + _currentCharFlag = false; + _boxSelect = false; _roomNumber = 0; _rawPlayerXLow = 0; @@ -119,6 +122,7 @@ AccessEngine::~AccessEngine() { delete _player; delete _room; delete _screen; + delete _scripts; delete _sound; _buffer1.free(); diff --git a/engines/access/access.h b/engines/access/access.h index fce6c443f4..21f8072311 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -37,6 +37,7 @@ #include "access/player.h" #include "access/room.h" #include "access/screen.h" +#include "access/scripts.h" #include "access/sound.h" /** @@ -108,6 +109,7 @@ public: Player *_player; Room *_room; Screen *_screen; + Scripts *_scripts; SoundManager *_sound; byte *_destIn; @@ -127,10 +129,10 @@ public: int _currentManOld; byte *_man1; + byte *_inactive; byte *_manPal1; byte *_music; byte *_playField; - byte *_script; byte *_anim; byte *_title; int _converseMode; @@ -140,6 +142,8 @@ public: int _startInvBox; int _startAboutBox; int _startTravelBox; + bool _currentCharFlag; + bool _boxSelect; // Fields that are included in savegames int _roomNumber; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8cbd0767b2..ffe4cb56f1 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -20,8 +20,10 @@ * */ -#include "access/amazon/amazon_game.h" #include "access/resources.h" +#include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_room.h" +#include "access/amazon/amazon_scripts.h" namespace Access { @@ -50,6 +52,7 @@ AmazonEngine::~AmazonEngine() { } void AmazonEngine::playGame() { + // Do introduction doIntroduction(); if (shouldQuit()) return; @@ -62,6 +65,10 @@ void AmazonEngine::playGame() { _screen->forceFadeOut(); _events->showCursor(); + + // Setup and execute the room + _room = new AmazonRoom(this); + _scripts = new AmazonScripts(this); _room->doRoom(); } diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp new file mode 100644 index 0000000000..ce0683f124 --- /dev/null +++ b/engines/access/amazon/amazon_room.cpp @@ -0,0 +1,121 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/amazon/amazon_room.h" + +namespace Access { + +namespace Amazon { + +AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { + _antOutFlag = false; +} + +void AmazonRoom::reloadRoom() { + loadRoom(_vm->_roomNumber); + + if (_roomFlag != 1) { + _vm->_currentMan = _roomFlag; + _vm->_currentManOld = _roomFlag; + _vm->_manScaleOff = 0; + + switch (_vm->_currentMan) { + case 0: + _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); + break; + + case 2: + _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); + break; + + case 3: + _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); + _vm->_manScaleOff = 1; + break; + + default: + break; + } + } + + reloadRoom1(); +} + +void AmazonRoom::reloadRoom1() { + if (_vm->_roomNumber == 22 || _vm->_roomNumber == 31 + || _vm->_roomNumber == 42 || _vm->_roomNumber == 44) { + _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + _vm->_currentCharFlag = false; + } + + _vm->_selectCommand = -1; + _vm->_normalMouse = 1; + _vm->_mouseMode = 0; + _vm->_boxSelect = true; + _vm->_player->_playerOff = 0; + + _vm->_screen->fadeOut(); + _vm->_screen->clearScreen(); + roomSet(); + + if (!_roomFlag && (_vm->_roomNumber != 61 || !_antOutFlag)) { + _vm->_player->load(); + _vm->_player->calcManScale(); + } + + if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24 + && _vm->_roomNumber != 33 && _vm->_roomNumber != 45) { + roomMenu(); + } + + _vm->_screen->setBufferScan(); + setupRoom(); + setWallCodes(); + buildScreen(); + + if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24 + && _vm->_roomNumber != 33) { + _vm->_screen->setPalette(); + _vm->_screen->copyBF2Vid(); + } + + _vm->_player->_frame = 0; + _vm->_oldRect.clear(); + _vm->_newRect.clear(); +} + +void AmazonRoom::roomSet() { + _vm->_numAnimTimers = 0; + _vm->_scripts->_sequence = 1000; + _vm->_scripts->searchForSeq(); + _vm->_scripts->executeCommand(); +} + +void AmazonRoom::roomMenu() { + // TODO +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h new file mode 100644 index 0000000000..6d13a4e52c --- /dev/null +++ b/engines/access/amazon/amazon_room.h @@ -0,0 +1,54 @@ +/* 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 ACCESS_AMAZON_ROOM_H +#define ACCESS_AMAZON_ROOM_H + +#include "common/scummsys.h" +#include "access/room.h" + +namespace Access { + +class AccessEngine; + +namespace Amazon { + +class AmazonRoom : public Room { +private: + bool _antOutFlag; + + void roomSet(); + + void roomMenu(); +protected: + virtual void reloadRoom(); + + virtual void reloadRoom1(); +public: + AmazonRoom(AccessEngine *vm); +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_ROOM_H */ diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp new file mode 100644 index 0000000000..1d3e7b4b76 --- /dev/null +++ b/engines/access/amazon/amazon_scripts.cpp @@ -0,0 +1,36 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/amazon/amazon_scripts.h" + +namespace Access { + +namespace Amazon { + +AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h new file mode 100644 index 0000000000..08fbc3a0f2 --- /dev/null +++ b/engines/access/amazon/amazon_scripts.h @@ -0,0 +1,42 @@ +/* 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 ACCESS_AMAZON_SCRIPTS_H +#define ACCESS_AMAZON_SCRIPTS_H + +#include "common/scummsys.h" +#include "access/scripts.h" + +namespace Access { + +namespace Amazon { + +class AmazonScripts: public Scripts { +public: + AmazonScripts(AccessEngine *vm); +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_SCRIPTS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 791abcc861..5c9203fde2 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -13,8 +13,11 @@ MODULE_OBJS := \ resources.o \ room.o \ screen.o \ + scripts.o \ sound.o \ - amazon\amazon_game.o + amazon\amazon_game.o \ + amazon\amazon_room.o \ + amazon\amazon_scripts.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index f7429bd9b5..a85df0320b 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -46,6 +46,14 @@ Player::Player(AccessEngine *vm): _vm(vm) { _playerOff = false; } +void Player::load() { + // TODO +} + +void Player::calcManScale() { + // TODO +} + void Player::walk() { warning("TODO: Player::walk"); } diff --git a/engines/access/player.h b/engines/access/player.h index 94ae9872b5..4d19601230 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -63,6 +63,10 @@ public: public: Player(AccessEngine *vm); + void load(); + + void calcManScale(); + void walk(); }; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 25d3584ede..c3a3a9f8e2 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -28,6 +28,7 @@ namespace Access { Room::Room(AccessEngine *vm) : _vm(vm) { _function = 0; + _roomFlag = 0; } void Room::doRoom() { @@ -40,6 +41,8 @@ void Room::doRoom() { _vm->_oldRect.clear(); _vm->_nextImage = 0; _vm->_numAnimTimers = 0; + + reloadRoom(); } reloadFlag = false; @@ -113,18 +116,63 @@ void Room::clearRoom() { // TODO } +void Room::reloadRoom() { + loadRoom(_vm->_roomNumber); + + if (_roomFlag != 1) { + _vm->_currentMan = _roomFlag; + _vm->_currentManOld = _roomFlag; + _vm->_manScaleOff = 0; + + switch (_vm->_currentMan) { + case 0: + _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); + break; + + case 2: + _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); + break; + + case 3: + _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); + _vm->_manScaleOff = 1; + break; + + default: + break; + } + } + + reloadRoom1(); +} + void Room::reloadRoom1() { // TODO } +void Room::loadRoom(int room) { + // TODO +} + void Room::roomLoop() { // TODO } void Room::doCommands() { + // TODO +} + +void Room::setupRoom() { + // TODO +} +void Room::setWallCodes() { + // TODO } +void Room::buildScreen() { + // TODO +} } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index 3b1a3347f9..fd5e602348 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -31,11 +31,20 @@ class AccessEngine; class Room { private: + void roomLoop(); +protected: AccessEngine *_vm; - void roomLoop(); + void setupRoom(); + void setWallCodes(); + void buildScreen(); + + virtual void reloadRoom() = 0; + + virtual void reloadRoom1() = 0; public: int _function; + int _roomFlag; public: Room(AccessEngine *vm); @@ -45,7 +54,7 @@ public: void clearRoom(); - void reloadRoom1(); + void loadRoom(int room); }; } // End of namespace Access diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 8c87638937..8dcc9f1db9 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -207,4 +207,8 @@ void Screen::copyRects() { // TODO } +void Screen::setBufferScan() { + // TODO +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 5f9fff058e..1b03d261cf 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -50,8 +50,6 @@ private: int _topSkip, _bottomSkip; int _clipWidth, _clipHeight; - void setPalette(); - void updatePalette(); bool clip(Common::Rect &r); @@ -91,6 +89,8 @@ public: void loadPalette(Common::SeekableReadStream *stream); + void setPalette(); + /** * Copy a buffer to the screen */ @@ -109,6 +109,8 @@ public: void copyBlocks(); void copyRects(); + + void setBufferScan(); }; } // End of namespace Access diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp new file mode 100644 index 0000000000..e31cd0cf5c --- /dev/null +++ b/engines/access/scripts.cpp @@ -0,0 +1,42 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/scripts.h" + +namespace Access { + +Scripts::Scripts(AccessEngine *vm) : _vm(vm) { + _script = nullptr; + _sequence = 0; +} + +void Scripts::searchForSeq() { + // TODO +} + +void Scripts::executeCommand() { + // TODO +} + +} // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h new file mode 100644 index 0000000000..b3e898f512 --- /dev/null +++ b/engines/access/scripts.h @@ -0,0 +1,48 @@ +/* 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 ACCESS_SCRIPTS_H +#define ACCESS_SCRIPTS_H + +#include "common/scummsys.h" + +namespace Access { + +class AccessEngine; + +class Scripts { +protected: + AccessEngine *_vm; +public: + byte *_script; + int _sequence; +public: + Scripts(AccessEngine *vm); + + void searchForSeq(); + + void executeCommand(); +}; + +} // End of namespace Access + +#endif /* ACCESS_SCRIPTS_H */ -- cgit v1.2.3 From c4d6dc376382de9b2d91d93ac9061f600b6a8696 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 08:28:20 -0400 Subject: ACCESS: Added room clearing --- engines/access/access.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ engines/access/access.h | 39 ++++++++++++++++++++++++++++++++++----- engines/access/room.cpp | 44 ++++++++++++-------------------------------- engines/access/room.h | 3 +++ engines/access/scripts.cpp | 9 +++++++++ engines/access/scripts.h | 4 ++++ engines/access/sound.cpp | 9 +++++++++ engines/access/sound.h | 5 +++++ 8 files changed, 121 insertions(+), 37 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index e175b1c081..6b805e4069 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -48,11 +48,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; + _man = nullptr; _man1 = nullptr; _inactive = nullptr; _manPal1 = nullptr; _music = nullptr; _playField = nullptr; + _tile = nullptr; _anim = nullptr; _title = nullptr; _converseMode = 0; @@ -127,6 +129,17 @@ AccessEngine::~AccessEngine() { _buffer1.free(); _buffer2.free(); + + freeCells(); + delete[] _man; + delete[] _man1; + delete[] _inactive; + delete[] _manPal1; + delete[] _music; + delete[] _playField; + delete[] _tile; + delete[] _anim; + delete[] _title; } void AccessEngine::setVGA() { @@ -183,4 +196,36 @@ void AccessEngine::clearCellTable() { Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); } +void AccessEngine::freeCells() { + for (int i = 0; i < 100; ++i) { + delete[] _objectsTable[i]; + _objectsTable[i] = nullptr; + } +} + +void AccessEngine::freeAnimationData() { + delete[] _anim; + _anim = nullptr; +} + +void AccessEngine::freePlayField() { + delete[] _playField; + _playField = nullptr; +} + +void AccessEngine::freeTileData() { + delete[] _tile; + _tile = nullptr; +} + +void AccessEngine::freeInactiveData() { + delete[] _inactive; + _inactive = nullptr; +} + +void AccessEngine::freeManData() { + delete[] _man; + _man = nullptr; +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 21f8072311..2e605e49ab 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -84,11 +84,6 @@ protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; - /** - * Clear the cell table - */ - void clearCellTable(); - /** * Main handler for showing game rooms */ @@ -128,11 +123,13 @@ public: int _nextImage; int _currentManOld; + byte *_man; byte *_man1; byte *_inactive; byte *_manPal1; byte *_music; byte *_playField; + byte *_tile; byte *_anim; byte *_title; int _converseMode; @@ -202,6 +199,38 @@ public: uint32 getGameFeatures() const; int getRandomNumber(int maxNumber); + + void freeAnimationData(); + + /** + * Clear the cell table + */ + void clearCellTable(); + + /** + * Free the cell data + */ + void freeCells(); + + /** + * Free the playfield data + */ + void freePlayField(); + + /** + * Free tile data + */ + void freeTileData(); + + /** + * Free the inactive data + */ + void freeInactiveData(); + + /** + * Free animation data + */ + void freeManData(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c3a3a9f8e2..0515b50ab2 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -113,41 +113,21 @@ void Room::doRoom() { } void Room::clearRoom() { - // TODO -} - -void Room::reloadRoom() { - loadRoom(_vm->_roomNumber); - - if (_roomFlag != 1) { - _vm->_currentMan = _roomFlag; - _vm->_currentManOld = _roomFlag; - _vm->_manScaleOff = 0; - - switch (_vm->_currentMan) { - case 0: - _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); - break; - - case 2: - _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); - break; - - case 3: - _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); - _vm->_manScaleOff = 1; - break; - - default: - break; - } + if (_vm->_sound->_music) { + _vm->_sound->stopSong(); + delete[] _vm->_sound->_music; + _vm->_sound->_music = nullptr; } - reloadRoom1(); -} + _vm->_sound->freeSounds(); + _vm->_numAnimTimers = 0; -void Room::reloadRoom1() { - // TODO + _vm->freeAnimationData(); + _vm->_scripts->freeScriptData(); + _vm->freeCells(); + _vm->freePlayField(); + _vm->freeInactiveData(); + _vm->freeManData(); } void Room::loadRoom(int room) { diff --git a/engines/access/room.h b/engines/access/room.h index fd5e602348..28506db7d6 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -52,6 +52,9 @@ public: void doCommands(); + /** + * Clear all the data used by the room + */ void clearRoom(); void loadRoom(int room); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index e31cd0cf5c..bd480b8b64 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -31,6 +31,10 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) { _sequence = 0; } +Scripts::~Scripts() { + freeScriptData(); +} + void Scripts::searchForSeq() { // TODO } @@ -39,4 +43,9 @@ void Scripts::executeCommand() { // TODO } +void Scripts::freeScriptData() { + delete[] _script; + _script = nullptr; +} + } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index b3e898f512..995f12930f 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -38,9 +38,13 @@ public: public: Scripts(AccessEngine *vm); + virtual ~Scripts(); + void searchForSeq(); void executeCommand(); + + void freeScriptData(); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2a008d8c53..2f64465f8f 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -32,6 +32,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); for (int i = 0; i < MAX_SOUNDS; ++i) _soundTable[i]._data = nullptr; + + _music = nullptr; } SoundManager::~SoundManager() { @@ -68,5 +70,12 @@ void SoundManager::midiRepeat() { // TODO } +void SoundManager::stopSong() { + // TODO +} + +void SoundManager::freeSounds() { + // TODO +} } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 613eca49ab..37d263eecd 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -48,6 +48,7 @@ private: public: SoundEntry _soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; + byte *_music; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); @@ -57,6 +58,10 @@ public: void playSound(int soundIndex); void midiRepeat(); + + void stopSong(); + + void freeSounds(); }; } // End of namespace Access -- cgit v1.2.3 From 3bd0f0f3394e87ee3e18c1bfda80a99ccc31c61c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 08:55:56 -0400 Subject: ACCESS: Split resources into a seperate file just for Amazon resources --- engines/access/amazon/amazon_game.cpp | 1 + engines/access/amazon/amazon_resources.cpp | 250 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 42 +++++ engines/access/events.cpp | 2 +- engines/access/files.cpp | 2 +- engines/access/module.mk | 1 + engines/access/resources.cpp | 223 ------------------------- engines/access/resources.h | 23 +-- engines/access/room.cpp | 1 + 9 files changed, 298 insertions(+), 247 deletions(-) create mode 100644 engines/access/amazon/amazon_resources.cpp create mode 100644 engines/access/amazon/amazon_resources.h diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index ffe4cb56f1..eccfc4dae7 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -22,6 +22,7 @@ #include "access/resources.h" #include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_room.h" #include "access/amazon/amazon_scripts.h" diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp new file mode 100644 index 0000000000..4d798db560 --- /dev/null +++ b/engines/access/amazon/amazon_resources.cpp @@ -0,0 +1,250 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, 0xwhose 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, 0xor (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, 0xwrite to the Free Software + * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * + */ + +#include "access/amazon/amazon_resources.h" +#include "access/access.h" + +namespace Access { + +namespace Amazon { + +const char *const FILENAMES[] = { + "S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP", + "S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP", + "S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP", + "S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP", + "S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP", + "S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP", + "S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP", + "S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP", + "C36.AP", nullptr, "S50.AP", nullptr, nullptr, "S53.AP", + "S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr, + nullptr, "S61.AP", nullptr, nullptr, "S64.AP", "C00.AP", + "C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP", + "C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP", + "C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP", + "C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP", + "C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP", + "EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP", + "NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP", + "NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP", + "NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP", + "NARATE13.AP", "NARATE14.AP" +}; + +const byte MOUSE0[] = { + 0, 0, 0, 0, + 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, + 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, + 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, + 6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, + 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3, + 3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1 +}; +const byte MOUSE1[] = { + 0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, + 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, + 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00, + 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, + 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, + 0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte MOUSE2[] = { + 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, + 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; +const byte MOUSE3[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00, + 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, + 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSEYE[] = { + 0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, + 0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, + 0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, + 0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, + 0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01, + 0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSHAND[] = { + 0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, + 0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01, + 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02, + 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B, + 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12, + 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, + 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, + 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, + 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, + 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, + 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, + 0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08, + 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, + 0x0D +}; +const byte CURSGET[] = { + 0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07, + 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E, + 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D, + 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E, + 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D, + 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E, + 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, + 0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07 +}; +const byte CURSCLIMB[] = { + 0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01, + 0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, + 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, + 0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, + 0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D, + 0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03, + 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20, + 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 +}; +const byte CURSTALK[] = { + 0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, + 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08, + 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06, + 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F, + 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01, + 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02, + 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06, + 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08, + 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06, + 0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +}; +const byte CURSHELP[] = { + 0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, + 0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, + 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, + 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, + 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24, + 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07, + 0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00, + 0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22, + 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 +}; +const byte *CURSORS[10] = { + MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP +}; + +const int TRAVEL_POS[][2] = { + { -1, 0 }, + { 228, 117 }, + { 28, 98 }, + { 161, 140 }, + { 130, 139 }, + { 884, 95 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 41, 185 }, + { 60, 138 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 170, 155 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 108, 95 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 100, 115 }, + { 480, 90 }, + { 154, 63 }, + { 0, 0 }, + { 145, 85 }, + { 0, 0 }, + { 110, 107 }, + { 0, 0 }, + { 105, 154 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 20, 160 }, + { 130, 314 }, + { 0, 0 }, + { 50, 125 }, + { 0, 0 }, + { 0, 0 }, + { 123, 123 }, + { -1, 7 }, + { 266, 168 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { -1, 18 }, + { -1, 19 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 203, 160 }, + { 0, 0 }, + { 283, 163 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 }, + { 180, 165 }, + { 0, 0 }, + { 0, 0 }, + { 0, 0 } +}; + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h new file mode 100644 index 0000000000..fba3bc2747 --- /dev/null +++ b/engines/access/amazon/amazon_resources.h @@ -0,0 +1,42 @@ +/* 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 ACCESS_AMAZON_RESOURCES_H +#define ACCESS_AMAZON_RESOURCES_H + +#include "common/scummsys.h" + +namespace Access { + +namespace Amazon { + +extern const char *const FILENAMES[]; + +extern const byte *CURSORS[10]; + +extern const int TRAVEL_POS[][2]; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_RESOURCES_H */ diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 29f6270387..1184128ffd 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -27,7 +27,7 @@ #include "engines/util.h" #include "access/access.h" #include "access/events.h" -#include "access/resources.h" +#include "access/amazon/amazon_resources.h" #define CURSOR_WIDTH 16 #define CURSOR_HEIGHT 16 diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 37b2578cea..c72d0adb7a 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -21,7 +21,7 @@ */ #include "access/files.h" -#include "access/resources.h" +#include "access/amazon/amazon_resources.h" #include "access/access.h" namespace Access { diff --git a/engines/access/module.mk b/engines/access/module.mk index 5c9203fde2..042e84ad86 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -16,6 +16,7 @@ MODULE_OBJS := \ scripts.o \ sound.o \ amazon\amazon_game.o \ + amazon\amazon_resources.o \ amazon\amazon_room.o \ amazon\amazon_scripts.o diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 70d4a698b1..8aa44b470b 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -46,227 +46,4 @@ const byte INITIAL_PALETTE[18 * 3] = { 0x00, 0x00, 0x00 }; -namespace Amazon { - -const char *const FILENAMES[] = { - "S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP", - "S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP", - "S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP", - "S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP", - "S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP", - "S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP", - "S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "C26.AP", - "S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP", - "C36.AP", nullptr, "S50.AP", nullptr, nullptr, "S53.AP", - "S54.AP", "S55.AP", "C35.AP", "S57.AP", "S58.AP", nullptr, - nullptr, "S61.AP", nullptr, nullptr, "S64.AP", "C00.AP", - "C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP", - "C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP", - "C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP", - "C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP", - "C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP", - "EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP", - "NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP", - "NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP", - "NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP", - "NARATE13.AP", "NARATE14.AP" -}; - -const byte *CURSORS[10] = { - MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP -}; - -const byte MOUSE0[] = { - 0, 0, 0, 0, - 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, - 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, - 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, - 6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, - 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3, - 3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1 -}; -const byte MOUSE1[] = { - 0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, - 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00, - 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, - 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, - 0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -const byte MOUSE2[] = { - 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, - 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, - 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 -}; -const byte MOUSE3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00, - 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, - 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -const byte CURSEYE[] = { - 0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, - 0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, - 0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, - 0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, - 0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01, - 0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 -}; -const byte CURSHAND[] = { - 0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, - 0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01, - 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02, - 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B, - 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12, - 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, - 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, - 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, - 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, - 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, - 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, - 0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08, - 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, - 0x0D -}; -const byte CURSGET[] = { - 0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07, - 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E, - 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E, - 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D, - 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E, - 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, - 0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07 -}; -const byte CURSCLIMB[] = { - 0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01, - 0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, - 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, - 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, - 0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, - 0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D, - 0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03, - 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20, - 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 -}; -const byte CURSTALK[] = { - 0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C, - 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, - 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08, - 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06, - 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F, - 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01, - 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02, - 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06, - 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08, - 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06, - 0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; -const byte CURSHELP[] = { - 0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, - 0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, - 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, - 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07, - 0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00, - 0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22, - 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 -}; - -const int TRAVEL_POS[][2] = { - { -1, 0 }, - { 228, 117 }, - { 28, 98 }, - { 161, 140 }, - { 130, 139 }, - { 884, 95 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 41, 185 }, - { 60, 138 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 170, 155 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 108, 95 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 100, 115 }, - { 480, 90 }, - { 154, 63 }, - { 0, 0 }, - { 145, 85 }, - { 0, 0 }, - { 110, 107 }, - { 0, 0 }, - { 105, 154 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 20, 160 }, - { 130, 314 }, - { 0, 0 }, - { 50, 125 }, - { 0, 0 }, - { 0, 0 }, - { 123, 123 }, - { -1, 7 }, - { 266, 168 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { -1, 18 }, - { -1, 19 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 203, 160 }, - { 0, 0 }, - { 283, 163 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 180, 165 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 } -}; - -} // End of namespace Amazon - } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index e73088102d..47d4e3ac8c 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -29,27 +29,6 @@ namespace Access { extern const byte INITIAL_PALETTE[18 * 3]; -namespace Amazon { - -extern const char *const FILENAMES[]; - -extern const byte MOUSE0[]; -extern const byte MOUSE1[]; -extern const byte MOUSE2[]; -extern const byte MOUSE3[]; -extern const byte CURSEYE[]; -extern const byte CURSHAND[]; -extern const byte CURSGET[]; -extern const byte CURSCLIMB[]; -extern const byte CURSTALK[]; -extern const byte CURSHELP[]; - -extern const byte *CURSORS[10]; - -extern const int TRAVEL_POS[][2]; - -} // End of namespace Amazon - } // End of namespace Access -#endif /* ACCESS_EVENTS_H */ +#endif /* ACCESS_RESOURCES_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0515b50ab2..f735fdb167 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/resources.h" #include "access/room.h" namespace Access { -- cgit v1.2.3 From 3645aad6fb02e0430c4ff3b325e1c0012042f4b7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 20:19:15 -0400 Subject: ACCESS: Add Amazon character and room resource lists --- engines/access/amazon/amazon_resources.cpp | 741 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 4 + 2 files changed, 745 insertions(+) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 4d798db560..2f9fe0277a 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -245,6 +245,747 @@ const int TRAVEL_POS[][2] = { { 0, 0 } }; +const byte CREDITS[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x3, 0x0, 0x30, 0x22, 0x30, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, + 0x0, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ALLISTER[] = { + 0x0, 0xFF, 0xFF, 0x61, 0x0, 0x0, 0x0, 0x36, 0x0F, 0x5E, 0x4, 0x0, 0x0, + 0x0, 0x4, 0x4, 0x0, 0x3, 0x0, 0xFF, 0x4, 0x0, 0x2, 0x0, 0x4, 0x0, 0x1, 0x0, 0x8C, + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, + 0x1, 0x0, 0x62, 0x0, 0x0B, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0C, 0x0, 0x1, 0x0, 0x62, + 0x0, 0x0D, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte HALL[] = { + 0x0, 0xFF, 0xFF, 0x61, 0x0, 0x0, 0x0, 0x40, 0x3E, 0x1A, 0x5, 0x0, 0x0, + 0x0, 0x5, 0x5, 0x0, 0x3, 0x0, 0xFF, 0x5, 0x0, 0x2, 0x0, 0x5, 0x0, 0x1, 0x0, 0xFF, + 0x30, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, 0x62, 0x0, 0x13, 0x0, 0x1, 0x0, + 0x62, 0x0, 0x14, 0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte JASONLAB[] = { + 0x1, 0x6, 0x0, 0x61, 0x0, 0x0D, 0x0, 0x40, 0x20, 0x0C4, 0x6, 0x0, 0x0, 0x0, + 0x6, 0x6, 0x0, 0x3, 0x0, 0xFF, 0x6, 0x0, 0x2, 0x0, 0x6, 0x0, 0x1, 0x0, 0xFF, 0x0, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x1, + 0x0, 0x62, 0x0, 0x1, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x26, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, + 0x62, 0x0, 0x35, 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte ALLENLAB[] = { + 0x1, 0x8, 0x0, 0x61, 0x0, 0x0D, 0x0, 0x40, 0x20, 0x0C4, 0x8, 0x0, 0x0, 0x0, + 0x8, 0x8, 0x0, 0x3, 0x0, 0xFF, 0x8, 0x0, 0x2, 0x0, 0x8, 0x0, 0x1, 0x0, 0xFF, 0x0, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x1, + 0x0, 0x62, 0x0, 0x7, 0x0, 0x1, 0x0, 0x62, 0x0, 0x8, 0x0, 0x2, 0x0, 0x62, 0x0, 0x9, + 0x0, 0x1, 0x0, 0x62, 0x0, 0x0A, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, + 0xFF, 0xFF +}; + +const byte OUTVAULT[] = { + 0x0, 0x9, 0x0, 0x61, 0x0, 0x2B, 0x0, 0x30, 0x18, 0x9B, 0x9, 0x0, 0x0, 0x0, + 0x9, 0x9, 0x0, 0x3, 0x0, 0xFF, 0x9, 0x0, 0x2, 0x0, 0x9, 0x0, 0x1, 0x0, 0x0B4, 0x10, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x3, + 0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x5, 0x0, 0x2, 0x0, 0x62, 0x0, 0x6, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x36, 0x0, 0x1, 0x0, 0x62, 0x0, 0x47, 0x0, 0x1, 0x0, + 0xFF, 0xFF +}; + +const byte VAULT[] = { + 0x0, 0xFF, 0xFF, 0x61, 0x0, 0x29, 0x0, 0x40, 0x3A, 0x37, 0x0A, 0x0, + 0x0, 0x0, 0x0A, 0x0A, 0x0, 0x3, 0x0, 0xFF, 0x0A, 0x0, 0x2, 0x0, 0x0A, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x37, 0x0, 0x2, 0x0, 0x62, 0x0, 0x39, 0x0, + 0x1, 0x0, 0x62, 0x0, 0x38, 0x0, 0x2, 0x0, 0x62, 0x0, 0x15, 0x0, 0x2, 0x0, 0xFF, + 0xFF +}; + +const byte LIBRARY[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x0C, 0x0, 0x40, 0x3A, 0x22, 0x0B, 0x0, + 0x0, 0x0, 0x0B, 0x0B, 0x0, 0x3, 0x0, 0xFF, 0x0B, 0x0, 0x2, 0x0, 0x0B, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x1, 0x0, 0x1, 0x0, 0xFF, 0xFF, +}; + +const byte JASAPT[] = { + 0x1, 0x0C, 0x0, 0x61, 0x0, 0x19, 0x0, 0x40, 0x30, 0x14, 0x0C, 0x0, 0x0, + 0x0, 0x0C, 0x0C, 0x0, 0x3, 0x0, 0xFF, 0x0C, 0x0, 0x2, 0x0, 0x0C, 0x0, 0x1, + 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x18, 0x0, 0x2, 0x0, 0x62, 0x0, 0x17, 0x0, 0x1, 0x0, 0x62, 0x0, 0x11, + 0x0, 0x1, 0x0, 0x62, 0x0, 0x0D, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte RANSACKED[] = { + 0x1, 0x0D, 0x0, 0x61, 0x0, 0x2D, 0x0, 0x40, 0x36, 0x2C, 0x0D, 0x0, 0x0, + 0x0, 0x0D, 0x0D, 0x0, 0x3, 0x0, 0xFF, 0x0D, 0x0, 0x2, 0x0, 0x0D, 0x0, 0x1, + 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x17, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte MEAN1[] = { + 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3E, 0x33, + 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0x0E, 0x0, 0x5, 0x0, 0x0E, 0x0, 0x4, 0x0, + 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte FLYSOUTH[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x10, 0x0, 0x28, 0x0C, 0x5E, 0x0F, 0x0, + 0x0, 0x0, 0x0F, 0x0F, 0x0, 0x2, 0x0, 0xFF, 0x0F, 0x0, 0x1, 0x0, 0xFF, 0xFF, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte CUZCO[] = { + 0x2, 0x10, 0x0, 0x61, 0x0, 0x10, 0x0, 0x40, 0x20, 0x30, 0x10, 0x0, 0x0, + 0x0, 0x10, 0x10, 0x0, 0x3, 0x0, 0xFF, 0x10, 0x0, 0x2, 0x0, 0x10, 0x0, 0x1, + 0x0, 0x6E, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte INAIR[] = { + 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x19, 0x2B, + 0x11, 0x0, 0x0, 0x0, 0x11, 0x11, 0x0, 0x3, 0x0, 0xFF, 0x11, 0x0, 0x2, 0x0, + 0x11, 0x0, 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF +}; + +const byte GREENMONKEY[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x11, 0x0, 0x2D, 0x14, 0x3C, 0x12, 0x0, + 0x0, 0x0, 0x12, 0x12, 0x0, 0x3, 0x0, 0xFF, 0x12, 0x0, 0x2, 0x0, 0x12, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte INPLANE[] = { + 0x2, 0x13, 0x0, 0x61, 0x0, 0x26, 0x0, 0x2D, 0x28, 0x28, 0x13, 0x0, 0x0, + 0x0, 0x13, 0x13, 0x0, 0x3, 0x0, 0xFF, 0x13, 0x0, 0x2, 0x0, 0x13, 0x0, 0x1, + 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, + 0x2, 0x0, 0x62, 0x0, 0x29, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, + 0x62, 0x0, 0x38, 0x0, 0x2, 0x0, 0x62, 0x0, 0x33, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte PILFALL[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x16, 0x0, 0x28, 0x0C, 0x5E, 0x14, 0x0, + 0x0, 0x0, 0x14, 0x14, 0x0, 0x2, 0x0, 0xFF, 0x14, 0x0, 0x1, 0x0, 0xFF, 0xFF, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte COCKPIT[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x12, 0x0, 0x3C, 0x2A, 0x29, 0x15, 0x0, + 0x0, 0x0, 0x15, 0x15, 0x0, 0x3, 0x0, 0xFF, 0x15, 0x0, 0x2, 0x0, 0x15, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x23, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte CRASH[] = { + 0x1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x2D, 0x64, + 0x16, 0x0, 0x0, 0x0, 0xFF, 0x16, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0x0, 0x0, + 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0x0, 0x2, 0x0, 0xFF, + 0xFF, 0x62, 0x0, 0x2A, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte SINKING[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x14, 0x0, 0x40, 0x3C, 0x19, 0x17, 0x0, + 0x0, 0x0, 0x17, 0x17, 0x0, 0x3, 0x0, 0xFF, 0x17, 0x0, 0x2, 0x0, 0x17, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x48, 0x0, 0x1, 0x0, 0x62, 0x0, 0x17, 0x0, + 0x1, 0x0, 0xFF, 0xFF +}; + +const byte JNGLWLK[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x17, 0x0, 0x40, 0x3F, 0x5A, 0x18, 0x0, + 0x0, 0x0, 0x18, 0x18, 0x0, 0x2, 0x0, 0xFF, 0x18, 0x0, 0x1, 0x0, 0xFF, 0xFF, + 0x0, 0x0, 0x0DC, 0x0A0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x62, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte TOWN[] = { + 0x2, 0x19, 0x0, 0x61, 0x0, 0x18, 0x0, 0x3E, 0x32, 0x80, 0x19, 0x0, 0x0, + 0x0, 0x19, 0x19, 0x0, 0x3, 0x0, 0xFF, 0x19, 0x0, 0x2, 0x0, 0x19, 0x0, 0x1, + 0x0, 0x64, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3D, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3B, 0x0, + 0x2, 0x0, 0xFF, 0xFF +}; + +const byte HOTEL[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x19, 0x0, 0x34, 0x28, 0x28, 0x1A, 0x0, + 0x0, 0x0, 0x1A, 0x1A, 0x0, 0x3, 0x0, 0xFF, 0x1A, 0x0, 0x2, 0x0, 0x1A, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x28, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2B, 0x0, 0x1, 0x0, 0x62, 0x0, 0x46, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x45, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0E, 0x0, 0x1, 0x0, + 0xFF, 0xFF +}; + +const byte CANTINA[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x27, 0x0, 0x40, 0x3A, 0x6C, 0x1B, 0x0, + 0x0, 0x0, 0x1B, 0x1B, 0x0, 0x3, 0x0, 0xFF, 0x1B, 0x0, 0x2, 0x0, 0x1B, 0x0, + 0x1, 0x0, 0x0C8, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte MASSACRE[] = { + 0x2, 0x1D, 0x0, 0x61, 0x0, 0x32, 0x0, 0x20, 0x18, 0x73, 0x1D, 0x0, 0x0, + 0x0, 0x1D, 0x1D, 0x0, 0x3, 0x0, 0xFF, 0x1D, 0x0, 0x2, 0x0, 0x1D, 0x0, 0x1, + 0x0, 0x96, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x0C, 0x0, 0x1, 0x0, 0x62, 0x0, 0x3, 0x0, 0x2, + 0x0, 0x62, 0x0, 0x49, 0x0, 0x2, 0x0, 0x62, 0x0, 0x4A, 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte TRADE[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x18, 0x0, 0x3F, 0x1C, 0x27, 0x1E, 0x0, + 0x0, 0x0, 0x1E, 0x1E, 0x0, 0x3, 0x0, 0xFF, 0x1E, 0x0, 0x2, 0x0, 0x1E, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte BRIDGE[] = { + 0x2, 0x1F, 0x0, 0x61, 0x0, 0x1B, 0x0, 0x40, 0x3F, 0x78, 0x1F, 0x0, 0x0, + 0x0, 0x1F, 0x1F, 0x0, 0x3, 0x0, 0xFF, 0x1F, 0x0, 0x2, 0x0, 0x1F, 0x0, 0x1, + 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte DOCK[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x1E, 0x0, 0x40, 0x3B, 0x4B, 0x20, 0x0, + 0x0, 0x0, 0xFF, 0x20, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0x0, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte DRIVER[] = { + 0x1, 0x21, 0x0, 0x61, 0x0, 0x28, 0x0, 0x30, 0x10, 0x51, 0x21, 0x0, 0x0, + 0x0, 0x21, 0x21, 0x0, 0x2, 0x0, 0xFF, 0x21, 0x0, 0x1, 0x0, 0xFF, 0xFF, + 0x0, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x2E, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte SHORE[] = { + 0x2, 0x24, 0x0, 0x61, 0x0, 0x4, 0x0, 0x3E, 0x3A, 0x32, 0x24, 0x0, 0x0, 0x0, + 0x24, 0x24, 0x0, 0x3, 0x0, 0xFF, 0x24, 0x0, 0x2, 0x0, 0x24, 0x0, 0x1, 0x0, + 0x0B4, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, + 0x2D, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2E, 0x0, + 0x1, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte BOAT[] = { + 0x3, 0xFF, 0xFF, 0x61, 0x0, 0x8, 0x0, 0x3F, 0x3F, 0xFF, 0x25, 0x0, + 0x0, 0x0, 0x25, 0x25, 0x0, 0x3, 0x0, 0xFF, 0x25, 0x0, 0x2, 0x0, 0x25, 0x0, + 0x1, 0x0, 0xFF, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x62, 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x21, 0x0, 0x1, 0x0, 0x62, 0x0, 0x25, + 0x0, 0x1, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x30, 0x0, 0x1, 0x0, + 0x62, 0x0, 0x32, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte CABIN[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x8, 0x0, 0x40, 0x32, 0x50, 0x26, 0x0, + 0x0, 0x0, 0x26, 0x26, 0x0, 0x3, 0x0, 0xFF, 0x26, 0x0, 0x2, 0x0, 0x26, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x22, 0x0, 0x2, 0x0, 0x62, 0x0, 0x31, 0x0, + 0x1, 0x0, 0xFF, 0xFF +}; + +const byte CAPTIVE[] = { + 0x2, 0x27, 0x0, 0x61, 0x0, 0x9, 0x0, 0x40, 0x3F, 0x37, 0x27, 0x0, 0x0, 0x0, + 0x27, 0x27, 0x0, 0x3, 0x0, 0xFF, 0x27, 0x0, 0x2, 0x0, 0x27, 0x0, 0x1, 0x0, + 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x0, + 0x0, 0x0, 0x4, 0x0, 0x62, 0x0, 0x1B, 0x0, 0x3, 0x0, 0x62, 0x0, 0x1C, 0x0, 0x1, + 0x0, 0x62, 0x0, 0x1F, 0x0, 0x2, 0x0, 0x62, 0x0, 0x23, 0x0, 0x1, 0x0, 0x62, + 0x0, 0x32, 0x0, 0x1, 0x0, 0x62, 0x0, 0x33, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte VILLAGE[] = { + 0x2, 0x2A, 0x0, 0x61, 0x0, 0x2E, 0x0, 0x1E, 0x1B, 0x6E, 0x2A, 0x0, 0x0, + 0x0, 0x2A, 0x2A, 0x0, 0x3, 0x0, 0xFF, 0x2A, 0x0, 0x2, 0x0, 0x2A, 0x0, 0x1, + 0x0, 0x0A5, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x2D, 0x0, 0x3, 0x0, 0x62, 0x0, 0x3F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x40, + 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte TREE[] = { + 0x2, 0x2C, 0x0, 0x61, 0x0, 0x31, 0x0, 0x1E, 0x1D, 0x0BE, 0x2C, 0x0, 0x0, + 0x0, 0x2C, 0x2C, 0x0, 0x3, 0x0, 0xFF, 0x2C, 0x0, 0x2, 0x0, 0x2C, 0x0, 0x1, + 0x0, 0x50, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x2E, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2F, 0x0, + 0x1, 0x0, 0x62, 0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x42, 0x0, 0x1, 0x0, 0xFF, + 0xFF +}; + +const byte CANOE[] = { + 0x1, 0x2D, 0x0, 0x61, 0x0, 0x2F, 0x0, 0x1E, 0x1D, 0x78, 0x2D, 0x0, 0x0, + 0x0, 0x2D, 0x2D, 0x0, 0x3, 0x0, 0xFF, 0x2D, 0x0, 0x2, 0x0, 0x2D, 0x0, 0x1, + 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x40, 0x0, 0x3, 0x0, 0x62, 0x0, 0x41, 0x0, 0x2, 0x0, 0x62, 0x0, 0x2E, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x2F, 0x0, 0x2, 0x0, 0x62, 0x0, 0x16, 0x0, 0x1, 0x0, + 0xFF, 0xFF +}; + +const byte INTREE[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x33, 0x0, 0x28, 0x1E, 0x32, 0x2E, 0x0, + 0x0, 0x0, 0x2E, 0x2E, 0x0, 0x3, 0x0, 0xFF, 0x2E, 0x0, 0x2, 0x0, 0x2E, 0x0, + 0x1, 0x0, 0x0F0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte FALLS[] = { + 0x1, 0xFF, 0xFF, 0x61, 0x0, 0x3B, 0x0, 0x28, 0x1E, 0x32, 0x2F, 0x0, + 0x0, 0x0, 0x2F, 0x2F, 0x0, 0x3, 0x0, 0xFF, 0x2F, 0x0, 0x2, 0x0, 0x2F, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x4, 0x0, 0x1, 0x0, 0x62, 0x0, 0x2A, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte WATERFALL[] = { + 0x1, 0x36, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x6E, 0x36, + 0x0, 0x0, 0x0, 0x36, 0x36, 0x0, 0x3, 0x0, 0xFF, 0x36, 0x0, 0x2, 0x0, 0x36, + 0x0, 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x36, 0x0, 0x4, + 0x0, 0xFF, 0xFF, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte INWATER[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x36, 0x0, 0x40, 0x3F, 0x2A, 0x37, 0x0, + 0x0, 0x0, 0x37, 0x37, 0x0, 0x3, 0x0, 0xFF, 0x37, 0x0, 0x2, 0x0, 0x37, 0x0, + 0x1, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x38, 0x0, 0x1, 0x0, 0xFF, 0xFF +}; + +const byte CAVE[] = { + 0x2, 0x39, 0x0, 0x61, 0x0, 0x37, 0x0, 0x32, 0x14, 0x73, 0x39, 0x0, 0x0, + 0x0, 0x39, 0x39, 0x0, 0x3, 0x0, 0xFF, 0x39, 0x0, 0x2, 0x0, 0x39, 0x0, 0x1, + 0x0, 0x0B4, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x0, 0x0, 0x0, 0x1, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x1, 0x0, 0x62, 0x0, 0x4B, 0x0, + 0x2, 0x0, 0x62, 0x0, 0x4C, 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte PIT[] = { + 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x38, 0x0, 0x41, 0x3F, 0x19, 0x3D, 0x0, + 0x0, 0x0, 0x3D, 0x3D, 0x0, 0x3, 0x0, 0x3E, 0x3D, 0x0, 0x4, 0x0, 0xFF, 0x3D, + 0x0, 0x2, 0x0, 0x3D, 0x0, 0x1, 0x0, 0x0BE, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x62, 0x0, 0x0, 0x0, 0x2, 0x0, 0x62, 0x0, 0x27, 0x0, 0x1, 0x0, + 0x62, 0x0, 0x4D, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0x0 +}; + +const byte *ROOM_TABLE[] = { + CREDITS, nullptr, nullptr, nullptr, ALLISTER, HALL, JASONLAB, nullptr, + ALLENLAB, OUTVAULT, VAULT, LIBRARY, JASAPT, RANSACKED, MEAN1, FLYSOUTH, + CUZCO, INAIR, GREENMONKEY, INPLANE, PILFALL, COCKPIT, CRASH, SINKING, + JNGLWLK, TOWN, HOTEL, CANTINA, nullptr, MASSACRE, TRADE, BRIDGE, DOCK, + DRIVER, nullptr, nullptr, SHORE, BOAT, CABIN, CAPTIVE, nullptr, + nullptr, VILLAGE, nullptr, TREE, CANOE, INTREE, FALLS, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, WATERFALL, INWATER, nullptr, + CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr +}; + +const byte ELAINE[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x41, 0x41, 0x0, 0x1, 0x0, 0xFF, 0x41, 0x0, 0x2, + 0x0, 0x41, 0x0, 0x0, 0x0, 0x41, 0x0, 0x3, 0x0, 0x41, 0x0, 0x25, 0x0, 0x41, + 0x0, 0x4, 0x0, 0x41, 0x0, 0x26, 0x0, 0x41, 0x0, 0x5, 0x0, 0x41, 0x0, 0x27, + 0x0, 0x41, 0x0, 0x6, 0x0, 0x41, 0x0, 0x28, 0x0, 0x41, 0x0, 0x7, 0x0, 0x41, + 0x0, 0x29, 0x0, 0x41, 0x0, 0x8, 0x0, 0x41, 0x0, 0x2A, 0x0, 0x41, 0x0, 0x9, + 0x0, 0x41, 0x0, 0x2B, 0x0, 0x41, 0x0, 0x0A, 0x0, 0x41, 0x0, 0x2C, 0x0, 0x41, + 0x0, 0x0B, 0x0, 0x41, 0x0, 0x2D, 0x0, 0x41, 0x0, 0x0C, 0x0, 0x41, 0x0, 0x2E, + 0x0, 0x41, 0x0, 0x0D, 0x0, 0x41, 0x0, 0x2F, 0x0, 0x41, 0x0, 0x0E, 0x0, 0x41, + 0x0, 0x30, 0x0, 0x41, 0x0, 0x0F, 0x0, 0x41, 0x0, 0x31, 0x0, 0x41, 0x0, 0x10, + 0x0, 0x41, 0x0, 0x32, 0x0, 0x41, 0x0, 0x11, 0x0, 0x41, 0x0, 0x33, 0x0, 0x41, + 0x0, 0x12, 0x0, 0x41, 0x0, 0x34, 0x0, 0x41, 0x0, 0x13, 0x0, 0x41, 0x0, 0x35, + 0x0, 0x41, 0x0, 0x14, 0x0, 0x41, 0x0, 0x36, 0x0, 0x41, 0x0, 0x15, 0x0, 0x41, + 0x0, 0x37, 0x0, 0x41, 0x0, 0x16, 0x0, 0x41, 0x0, 0x38, 0x0, 0x41, 0x0, 0x17, + 0x0, 0x41, 0x0, 0x39, 0x0, 0x41, 0x0, 0x18, 0x0, 0x41, 0x0, 0x3A, 0x0, 0x41, + 0x0, 0x19, 0x0, 0x41, 0x0, 0x3B, 0x0, 0x41, 0x0, 0x1A, 0x0, 0x41, 0x0, 0x3C, + 0x0, 0x41, 0x0, 0x1B, 0x0, 0x41, 0x0, 0x3D, 0x0, 0x41, 0x0, 0x1C, 0x0, 0x41, + 0x0, 0x3E, 0x0, 0x41, 0x0, 0x1D, 0x0, 0x41, 0x0, 0x3F, 0x0, 0x41, 0x0, 0x1E, + 0x0, 0x41, 0x0, 0x40, 0x0, 0x41, 0x0, 0x1F, 0x0, 0x41, 0x0, 0x41, 0x0, 0x41, + 0x0, 0x20, 0x0, 0x41, 0x0, 0x42, 0x0, 0x41, 0x0, 0x21, 0x0, 0x41, 0x0, 0x43, + 0x0, 0x41, 0x0, 0x22, 0x0, 0x41, 0x0, 0x44, 0x0, 0x41, 0x0, 0x23, 0x0, 0x41, + 0x0, 0x45, 0x0, 0x41, 0x0, 0x24, 0x0, 0x41, 0x0, 0x46, 0x0, 0xFF, 0xFF +}; + +const byte LIB[] = { + 0x1, 0xFF, 0xFF, 0x42, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x42, 0x42, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, + 0x0, 0x42, 0x0, 0x0, 0x0, 0x42, 0x0, 0x3, 0x0, 0x42, 0x0, 0x18, 0x0, 0x42, + 0x0, 0x4, 0x0, 0x42, 0x0, 0x19, 0x0, 0x42, 0x0, 0x5, 0x0, 0x42, 0x0, 0x1A, + 0x0, 0x42, 0x0, 0x6, 0x0, 0x42, 0x0, 0x1B, 0x0, 0x42, 0x0, 0x7, 0x0, 0x42, + 0x0, 0x1C, 0x0, 0x42, 0x0, 0x8, 0x0, 0x42, 0x0, 0x1D, 0x0, 0x42, 0x0, 0x9, + 0x0, 0x42, 0x0, 0x1E, 0x0, 0x42, 0x0, 0x0A, 0x0, 0x42, 0x0, 0x1F, 0x0, 0x42, + 0x0, 0x0B, 0x0, 0x42, 0x0, 0x20, 0x0, 0x42, 0x0, 0x0C, 0x0, 0x42, 0x0, 0x21, + 0x0, 0x42, 0x0, 0x0D, 0x0, 0x42, 0x0, 0x22, 0x0, 0x42, 0x0, 0x0E, 0x0, 0x42, + 0x0, 0x23, 0x0, 0x42, 0x0, 0x0F, 0x0, 0x42, 0x0, 0x24, 0x0, 0x42, 0x0, 0x10, + 0x0, 0x42, 0x0, 0x25, 0x0, 0x42, 0x0, 0x11, 0x0, 0x42, 0x0, 0x26, 0x0, 0x42, + 0x0, 0x12, 0x0, 0x42, 0x0, 0x27, 0x0, 0x42, 0x0, 0x13, 0x0, 0x42, 0x0, 0x28, + 0x0, 0x42, 0x0, 0x14, 0x0, 0x42, 0x0, 0x29, 0x0, 0x42, 0x0, 0x15, 0x0, 0x42, + 0x0, 0x2A, 0x0, 0x42, 0x0, 0x16, 0x0, 0x42, 0x0, 0x2B, 0x0, 0x42, 0x0, 0x17, + 0x0, 0x42, 0x0, 0x2C, 0x0, 0xFF, 0xFF +}; + +const byte FLASHBACK[] = { + 0x2, 0x1B, 0x0, 0x1C, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x26, 0x0, 0x1C, 0x0, 0x0, 0x0, 0x1C, + 0x0, 0x5, 0x0, 0x1C, 0x0, 0x0E, 0x0, 0x1C, 0x0, 0x6, 0x0, 0x1C, 0x0, 0x0F, + 0x0, 0x1C, 0x0, 0x7, 0x0, 0x1C, 0x0, 0x0C, 0x0, 0x1C, 0x0, 0x8, 0x0, 0x1C, + 0x0, 0x0D, 0x0, 0x2, 0x0, 0x1, 0x0, 0x1C, 0x0, 0x10, 0x0, 0x2, 0x0, 0x2, 0x0, 0x1C, + 0x0, 0x11, 0x0, 0x1C, 0x0, 0x9, 0x0, 0x1C, 0x0, 0x12, 0x0, 0x1C, 0x0, 0x0A, + 0x0, 0x1C, 0x0, 0x13, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x14, 0x0, 0x1C, + 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x15, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x16, + 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x17, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, + 0x0, 0x18, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x19, 0x0, 0x1C, 0x0, 0x0B, + 0x0, 0x1C, 0x0, 0x1A, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1B, 0x0, 0x1C, + 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1C, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1D, + 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x1E, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, + 0x0, 0x1F, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x20, 0x0, 0x1C, 0x0, 0x0B, + 0x0, 0x1C, 0x0, 0x21, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x22, 0x0, 0x1C, + 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x23, 0x0, 0x1C, 0x0, 0x0B, 0x0, 0x1C, 0x0, 0x24, + 0x0, 0xFF, 0xFF +}; + +const byte ALLENDIE[] = { + 0x2, 0xFF, 0xFF, 0x49, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x49, 0x0, 0x0, 0x0, 0x49, + 0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0x49, 0x0, 0x5, 0x0, 0x62, 0x0, 0x3A, + 0x0, 0x49, 0x0, 0x6, 0x0, 0x49, 0x0, 0x7, 0x0, 0xFF, 0xFF +}; + +const byte OVERBOARD[] = { + 0x2, 0xFF, 0xFF, 0x22, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x22, 0x22, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x22, 0x0, 0x0, 0x0, 0x22, 0x0, 0x3, 0x0, 0x22, 0x0, 0x6, 0x0, 0x22, + 0x0, 0x4, 0x0, 0x22, 0x0, 0x7, 0x0, 0x22, 0x0, 0x5, 0x0, 0x62, 0x0, 0x1D, 0x0, + 0x22, 0x0, 0x5, 0x0, 0x62, 0x0, 0x24, 0x0, 0xFF, 0xFF +}; + +const byte PILOT2[] = { + 0x0, 0x12, 0x0, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x46, 0x46, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x46, 0x0, 0x0, 0x0, 0x46, 0x0, 0x2, 0x0, 0x46, 0x0, 0x0A, 0x0, 0x46, + 0x0, 0x3, 0x0, 0x46, 0x0, 0x0B, 0x0, 0x46, 0x0, 0x4, 0x0, 0x46, 0x0, 0x0C, + 0x0, 0x46, 0x0, 0x5, 0x0, 0x46, 0x0, 0x0D, 0x0, 0x46, 0x0, 0x6, 0x0, 0x46, + 0x0, 0x0E, 0x0, 0x46, 0x0, 0x7, 0x0, 0x46, 0x0, 0x0F, 0x0, 0x46, 0x0, 0x8, + 0x0, 0x46, 0x0, 0x10, 0x0, 0x46, 0x0, 0x9, 0x0, 0x46, 0x0, 0x11, 0x0, 0x46, + 0x0, 0x9, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF +}; + +const byte TIKAGENT[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x43, 0x43, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, + 0x0, 0x43, 0x0, 0x0, 0x0, 0x43, 0x0, 0x2, 0x0, 0x43, 0x0, 0x12, 0x0, 0x43, + 0x0, 0x3, 0x0, 0x43, 0x0, 0x13, 0x0, 0x43, 0x0, 0x4, 0x0, 0x43, 0x0, 0x14, + 0x0, 0x43, 0x0, 0x5, 0x0, 0x43, 0x0, 0x15, 0x0, 0x43, 0x0, 0x6, 0x0, 0x43, + 0x0, 0x16, 0x0, 0x43, 0x0, 0x7, 0x0, 0x43, 0x0, 0x17, 0x0, 0x43, 0x0, 0x8, + 0x0, 0x43, 0x0, 0x18, 0x0, 0x43, 0x0, 0x9, 0x0, 0x43, 0x0, 0x19, 0x0, 0x43, + 0x0, 0x0A, 0x0, 0x43, 0x0, 0x1A, 0x0, 0x43, 0x0, 0x0B, 0x0, 0x43, 0x0, 0x1B, + 0x0, 0x43, 0x0, 0x0C, 0x0, 0x43, 0x0, 0x1C, 0x0, 0x43, 0x0, 0x0D, 0x0, 0x43, + 0x0, 0x1D, 0x0, 0x43, 0x0, 0x0E, 0x0, 0x43, 0x0, 0x1E, 0x0, 0x43, 0x0, 0x0F, + 0x0, 0x43, 0x0, 0x1F, 0x0, 0x43, 0x0, 0x10, 0x0, 0x43, 0x0, 0x20, 0x0, 0x43, + 0x0, 0x11, 0x0, 0x43, 0x0, 0x21, 0x0, 0xFF, 0xFF +}; + +const byte BARTENDER[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x44, 0x44, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x44, 0x0, 0x0, 0x0, 0x44, 0x0, 0x2, 0x0, 0x44, 0x0, 0x8, 0x0, 0x44, 0x0, + 0x3, 0x0, 0x44, 0x0, 0x9, 0x0, 0x44, 0x0, 0x4, 0x0, 0x44, 0x0, 0x0A, 0x0, 0x44, + 0x0, 0x5, 0x0, 0x44, 0x0, 0x0B, 0x0, 0x44, 0x0, 0x6, 0x0, 0x44, 0x0, 0x0C, + 0x0, 0x44, 0x0, 0x7, 0x0, 0x44, 0x0, 0x0D, 0x0, 0xFF, 0xFF +}; + +const byte PILOT1[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x45, 0x45, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x45, 0x0, 0x0, 0x0, 0x45, 0x0, 0x2, 0x0, 0x45, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte COOK[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x47, 0x47, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0x2, 0x0, 0x47, 0x0, 0x0, 0x0, 0x47, 0x0, 0x2, 0x0, 0x47, 0x0, 0x10, 0x0, 0x47, + 0x0, 0x3, 0x0, 0x47, 0x0, 0x11, 0x0, 0x47, 0x0, 0x4, 0x0, 0x47, 0x0, 0x12, + 0x0, 0x47, 0x0, 0x5, 0x0, 0x47, 0x0, 0x13, 0x0, 0x47, 0x0, 0x6, 0x0, 0x47, + 0x0, 0x14, 0x0, 0x47, 0x0, 0x7, 0x0, 0x47, 0x0, 0x15, 0x0, 0x47, 0x0, 0x8, + 0x0, 0x47, 0x0, 0x16, 0x0, 0x47, 0x0, 0x9, 0x0, 0x47, 0x0, 0x17, 0x0, 0x47, + 0x0, 0x0A, 0x0, 0x47, 0x0, 0x18, 0x0, 0x47, 0x0, 0x0B, 0x0, 0x47, 0x0, 0x19, + 0x0, 0x47, 0x0, 0x0C, 0x0, 0x47, 0x0, 0x1A, 0x0, 0x47, 0x0, 0x0D, 0x0, 0x47, + 0x0, 0x1B, 0x0, 0x47, 0x0, 0x0E, 0x0, 0x47, 0x0, 0x1C, 0x0, 0x47, 0x0, 0x0F, + 0x0, 0x47, 0x0, 0x1D, 0x0, 0xFF, 0xFF +}; + +const byte BEXPLODE[] = { + 0x2, 0xFF, 0xFF, 0x28, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x28, 0x28, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x28, 0x0, 0x0, 0x0, 0x28, 0x0, 0x3, 0x0, 0x28, 0x0, 0x9, 0x0, 0x28, + 0x0, 0x4, 0x0, 0x28, 0x0, 0x0A, 0x0, 0x28, 0x0, 0x5, 0x0, 0x28, 0x0, 0x0B, + 0x0, 0x28, 0x0, 0x6, 0x0, 0x62, 0x0, 0x23, 0x0, 0x28, 0x0, 0x7, 0x0, 0x62, + 0x0, 0x23, 0x0, 0x28, 0x0, 0x8, 0x0, 0x62, 0x0, 0x23, 0x0, 0xFF, 0xFF +}; + +const byte THORNICK[] = { + 0x2, 0x7, 0x0, 0x7, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0, + 0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3, + 0x0, 0x7, 0x0, 0x7, 0x0, 0x7, 0x0, 0x4, 0x0, 0x7, 0x0, 0x8, 0x0, 0xFF, 0xFF +}; + +const byte MAYA[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, + 0x48, 0x0, 0x0, 0x0, 0x48, 0x0, 0x2, 0x0, 0x48, 0x0, 0x13, 0x0, 0x48, + 0x0, 0x3, 0x0, 0x48, 0x0, 0x14, 0x0, 0x48, 0x0, 0x4, 0x0, 0x48, 0x0, 0x15, + 0x0, 0x48, 0x0, 0x5, 0x0, 0x48, 0x0, 0x16, 0x0, 0x48, 0x0, 0x6, 0x0, 0x48, + 0x0, 0x17, 0x0, 0x48, 0x0, 0x7, 0x0, 0x48, 0x0, 0x18, 0x0, 0x48, 0x0, 0x8, + 0x0, 0x48, 0x0, 0x19, 0x0, 0x48, 0x0, 0x9, 0x0, 0x48, 0x0, 0x1A, 0x0, 0x48, + 0x0, 0x0A, 0x0, 0x48, 0x0, 0x1B, 0x0, 0x48, 0x0, 0x0B, 0x0, 0x48, 0x0, 0x1C, + 0x0, 0x48, 0x0, 0x0C, 0x0, 0x48, 0x0, 0x1D, 0x0, 0x48, 0x0, 0x0D, 0x0, 0x48, + 0x0, 0x1E, 0x0, 0x48, 0x0, 0x0E, 0x0, 0x48, 0x0, 0x1F, 0x0, 0x48, 0x0, 0x0F, + 0x0, 0x48, 0x0, 0x20, 0x0, 0x48, 0x0, 0x10, 0x0, 0x48, 0x0, 0x21, 0x0, 0x48, + 0x0, 0x11, 0x0, 0x48, 0x0, 0x22, 0x0, 0x48, 0x0, 0x12, 0x0, 0x48, 0x0, 0x23, + 0x0, 0xFF, 0xFF +}; + +const byte CAPTAIN[] = { + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x4A, 0x4A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0x2, 0x0, 0x4A, 0x0, 0x0, 0x0, 0x4A, 0x0, 0x2, 0x0, 0x4A, 0x0, 0x0E, 0x0, 0x4A, + 0x0, 0x3, 0x0, 0x4A, 0x0, 0x0F, 0x0, 0x4A, 0x0, 0x4, 0x0, 0x4A, 0x0, 0x10, + 0x0, 0x4A, 0x0, 0x5, 0x0, 0x4A, 0x0, 0x11, 0x0, 0x4A, 0x0, 0x6, 0x0, 0x4A, + 0x0, 0x12, 0x0, 0x4A, 0x0, 0x7, 0x0, 0x4A, 0x0, 0x13, 0x0, 0x4A, 0x0, 0x8, + 0x0, 0x4A, 0x0, 0x14, 0x0, 0x4A, 0x0, 0x9, 0x0, 0x4A, 0x0, 0x15, 0x0, 0x4A, + 0x0, 0x0A, 0x0, 0x4A, 0x0, 0x16, 0x0, 0x4A, 0x0, 0x0B, 0x0, 0x4A, 0x0, 0x17, + 0x0, 0x4A, 0x0, 0x0C, 0x0, 0x4A, 0x0, 0x18, 0x0, 0x4A, 0x0, 0x0D, 0x0, 0x4A, + 0x0, 0x19, 0x0, 0xFF, 0xFF +}; + +const byte ALLEN[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x1E, 0x4C, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x4C, 0x0, 0x0, 0x0, 0x4C, 0x0, 0x2, 0x0, 0x4C, 0x0, 0x3, 0x0, + 0xFF, 0xFF +}; + +const byte ARCH[] = { + 0x1, 0x2B, 0x0, 0x4B, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x2B, 0x4B, 0x0, 0x40, 0x0, 0xFF, 0x4B, 0x0, 0x41, 0x0, + 0x4B, 0x0, 0x0, 0x0, 0x4B, 0x0, 0x2, 0x0, 0x4B, 0x0, 0x4, 0x0, 0x4B, 0x0, 0x3, + 0x0, 0x4B, 0x0, 0x5, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x6, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x7, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x8, 0x0, 0x4B, + 0x0, 0x3, 0x0, 0x4B, 0x0, 0x9, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0A, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0B, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x0C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0D, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x0E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x0F, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x10, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x11, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x12, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x13, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x14, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x15, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x16, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x17, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x18, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x19, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x1A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1B, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x1C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1D, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x1E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x1F, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x20, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x21, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x22, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x23, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x24, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x25, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x26, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x27, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x28, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x29, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x2A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2B, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x2C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2D, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x2E, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x2F, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x30, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x31, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x32, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x33, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x34, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x35, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x36, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x37, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x38, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x39, 0x0, 0x4B, 0x0, + 0x3, 0x0, 0x4B, 0x0, 0x3A, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3B, 0x0, + 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3C, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, + 0x3D, 0x0, 0x4B, 0x0, 0x3, 0x0, 0x4B, 0x0, 0x3E, 0x0, 0x4B, 0x0, 0x3, 0x0, + 0x4B, 0x0, 0x3F, 0x0, 0xFF, 0xFF +}; + +const byte GUARD1[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x4D, 0x4D, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x4D, 0x0, 0x0, 0x0, 0x4D, 0x0, 0x2, 0x0, 0x4D, 0x0, 0x3, 0x0, + 0xFF, 0xFF +}; + +const byte MCANOE[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x4E, 0x4E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0x4E, 0x0, 0x0, 0x0, 0x4E, 0x0, 0x2, 0x0, 0x4E, 0x0, 0x3, 0x0, + 0xFF, 0xFF +}; + +const byte CAMPFIRE[] = { + 0x2, 0x35, 0x0, 0x35, 0x0, 0x3, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x35, 0x35, 0x0, 0x1, 0x0, 0xFF, 0x35, 0x0, 0x2, 0x0, 0x35, + 0x0, 0x0, 0x0, 0x35, 0x0, 0x4, 0x0, 0x35, 0x0, 0x18, 0x0, 0x35, 0x0, 0x5, 0x0, + 0x35, 0x0, 0x19, 0x0, 0x35, 0x0, 0x6, 0x0, 0x35, 0x0, 0x1A, 0x0, 0x35, 0x0, + 0x7, 0x0, 0x35, 0x0, 0x1B, 0x0, 0x35, 0x0, 0x8, 0x0, 0x35, 0x0, 0x1C, 0x0, + 0x35, 0x0, 0x9, 0x0, 0x35, 0x0, 0x1D, 0x0, 0x35, 0x0, 0x0A, 0x0, 0x35, 0x0, + 0x1E, 0x0, 0x35, 0x0, 0x0B, 0x0, 0x35, 0x0, 0x1F, 0x0, 0x35, 0x0, 0x0C, + 0x0, 0x35, 0x0, 0x20, 0x0, 0x35, 0x0, 0x0D, 0x0, 0x35, 0x0, 0x21, 0x0, 0x35, + 0x0, 0x0E, 0x0, 0x35, 0x0, 0x22, 0x0, 0x35, 0x0, 0x0F, 0x0, 0x35, 0x0, 0x23, + 0x0, 0x35, 0x0, 0x10, 0x0, 0x35, 0x0, 0x24, 0x0, 0x35, 0x0, 0x11, 0x0, 0x35, + 0x0, 0x25, 0x0, 0x35, 0x0, 0x12, 0x0, 0x35, 0x0, 0x26, 0x0, 0x35, 0x0, 0x13, + 0x0, 0x35, 0x0, 0x27, 0x0, 0x35, 0x0, 0x14, 0x0, 0x35, 0x0, 0x28, 0x0, 0x35, + 0x0, 0x15, 0x0, 0x35, 0x0, 0x29, 0x0, 0x35, 0x0, 0x16, 0x0, 0x35, 0x0, 0x2A, + 0x0, 0x35, 0x0, 0x17, 0x0, 0x35, 0x0, 0x2B, 0x0, 0xFF, 0xFF +}; + +const byte COLONEL[] = { + 0x2, 0xFF, 0xFF, 0x0E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x0E, 0x0E, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x2, + 0x0, 0x4F, 0x0, 0x0, 0x0, 0x4F, 0x0, 0x1, 0x0, 0x4F, 0x0, 0x2, 0x0, 0x0E, 0x0, + 0x8, 0x0, 0x4F, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte SOLDIERS[] = { + 0x2, 0xFF, 0xFF, 0x50, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x50, + 0x0, 0x2, 0x0, 0x50, 0x0, 0x0, 0x0, 0xFF, 0xFF +}; + +const byte JWATER[] = { + 0x2, 0xFF, 0xFF, 0x51, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x51, 0x0, 0x0, 0x0, 0x51, + 0x0, 0x2, 0x0, 0x51, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte SHOOT[] = { + 0x2, 0xFF, 0xFF, 0x52, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x38, 0x52, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52, + 0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF +}; + +const byte ADIE[] = { + 0x2, 0xFF, 0xFF, 0x53, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x53, 0x0, 0x0, 0x0, 0x53, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4, + 0x0, 0x53, 0x0, 0x4, 0x0, 0x62, 0x0, 0x4, 0x0, 0xFF, 0xFF +}; + +const byte DYNAMITE[] = { + 0x2, 0xFF, 0xFF, 0x54, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x54, 0x0, 0x0, 0x0, 0x54, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x23, 0x0, 0xFF, 0xFF +}; + +const byte MAYASHOT[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x0, 0x0, 0x0, 0x0, 0x36, 0x55, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, + 0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, + 0x0, 0xFF, 0xFF +}; + +const byte OFFKEV[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x29, 0x0, 0x0, 0x0, 0x29, 0x0, 0x2, 0x0, 0x29, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte VALLEY[] = { + 0x2, 0x3A, 0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x3A, 0x3A, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0x3, 0x0, + 0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0, + 0x4, 0x0, 0x62, 0x0, 0x27, 0x0, 0xFF, 0xFF +}; + +const byte MEANWHILE1[] = { + 0x2, 0xFF, 0xFF, 0x0E, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x0E, 0x0E, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x3, + 0x0, 0x0E, 0x0, 0x0, 0x0, 0x0E, 0x0, 0x6, 0x0, 0x0E, 0x0, 0x0A, 0x0, 0x0E, + 0x0, 0x7, 0x0, 0x0E, 0x0, 0x0B, 0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E, 0x0, 0x0C, + 0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E, 0x0, 0x0D, 0x0, 0x0E, 0x0, 0x8, 0x0, 0x0E, + 0x0, 0x0E, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x0E, 0x0, 0x0F, 0x0, 0x0E, 0x0, 0x9, + 0x0, 0x0E, 0x0, 0x10, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x0E, 0x0, 0x11, 0x0, 0x0E, + 0x0, 0x9, 0x0, 0x0E, 0x0, 0x12, 0x0, 0x0E, 0x0, 0x9, 0x0, 0x62, 0x0, 0x1A, + 0x0, 0xFF, 0xFF +}; + +const byte MAYATREE[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x30, 0x56, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x56, 0x0, 0x0, 0x0, 0x56, 0x0, 0x2, 0x0, 0x56, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte LOCO[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x31, 0x57, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x57, 0x0, 0x0, 0x0, 0x57, 0x0, 0x2, 0x0, 0x57, 0x0, 0x3, 0x0, 0xFF, 0xFF +}; + +const byte KISS[] = { + 0x2, 0xFF, 0xFF, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x40, 0x40, 0x0, 0x5, 0x0, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x40, 0x0, 0x0, 0x0, 0x40, 0x0, 0x6, 0x0, 0x40, 0x0, 0x26, 0x0, 0x40, + 0x0, 0x7, 0x0, 0x40, 0x0, 0x27, 0x0, 0x40, 0x0, 0x8, 0x0, 0x40, 0x0, 0x28, + 0x0, 0x40, 0x0, 0x9, 0x0, 0x62, 0x0, 0x4E, 0x0, 0x40, 0x0, 0x0A, 0x0, 0x40, + 0x0, 0x29, 0x0, 0x40, 0x0, 0x0B, 0x0, 0x40, 0x0, 0x2A, 0x0, 0x40, 0x0, 0x0C, + 0x0, 0x40, 0x0, 0x2B, 0x0, 0x40, 0x0, 0x0D, 0x0, 0x40, 0x0, 0x2C, 0x0, 0x40, + 0x0, 0x0E, 0x0, 0x40, 0x0, 0x2D, 0x0, 0x40, 0x0, 0x0F, 0x0, 0x40, 0x0, 0x2E, + 0x0, 0x40, 0x0, 0x10, 0x0, 0x40, 0x0, 0x2F, 0x0, 0x40, 0x0, 0x11, 0x0, 0x40, + 0x0, 0x30, 0x0, 0x40, 0x0, 0x12, 0x0, 0x40, 0x0, 0x31, 0x0, 0x40, 0x0, 0x13, + 0x0, 0x40, 0x0, 0x32, 0x0, 0x40, 0x0, 0x14, 0x0, 0x40, 0x0, 0x33, 0x0, 0x40, + 0x0, 0x15, 0x0, 0x40, 0x0, 0x34, 0x0, 0x40, 0x0, 0x16, 0x0, 0x40, 0x0, 0x35, + 0x0, 0x40, 0x0, 0x17, 0x0, 0x40, 0x0, 0x36, 0x0, 0x40, 0x0, 0x18, 0x0, 0x40, + 0x0, 0x37, 0x0, 0x40, 0x0, 0x19, 0x0, 0x40, 0x0, 0x38, 0x0, 0x40, 0x0, 0x1A, + 0x0, 0x40, 0x0, 0x39, 0x0, 0x40, 0x0, 0x1B, 0x0, 0x40, 0x0, 0x3A, 0x0, 0x40, + 0x0, 0x1C, 0x0, 0x40, 0x0, 0x3B, 0x0, 0x40, 0x0, 0x1D, 0x0, 0x40, 0x0, 0x3C, + 0x0, 0x40, 0x0, 0x1E, 0x0, 0x40, 0x0, 0x3D, 0x0, 0x40, 0x0, 0x1F, 0x0, 0x40, + 0x0, 0x3E, 0x0, 0x40, 0x0, 0x20, 0x0, 0x40, 0x0, 0x3F, 0x0, 0x40, 0x0, 0x21, + 0x0, 0x40, 0x0, 0x40, 0x0, 0x40, 0x0, 0x22, 0x0, 0x40, 0x0, 0x41, 0x0, 0x40, + 0x0, 0x23, 0x0, 0x40, 0x0, 0x42, 0x0, 0x40, 0x0, 0x24, 0x0, 0x40, 0x0, 0x43, + 0x0, 0x40, 0x0, 0x25, 0x0, 0x40, 0x0, 0x44, 0x0, 0x40, 0x0, 0x25, 0x0, 0x40, + 0x0, 0x45, 0x0, 0x40, 0x0, 0x25, 0x0, 0x40, 0x0, 0x46, 0x0, 0x40, 0x0, 0x25, + 0x0, 0x40, 0x0, 0x47, 0x0, 0xFF, 0xFF +}; + +const byte ROBOT[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0x9, 0x58, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, + 0x58, 0x0, 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x58, 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte ANTKILL[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, + 0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59, + 0x0, 0x0, 0x0, 0x59, 0x0, 0x2, 0x0, 0x62, 0x0, 0x0E, 0x0, 0xFF, 0xFF +}; + +const byte LOCOHOT[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, + 0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A, + 0x0, 0x0, 0x0, 0x5A, 0x0, 0x2, 0x0, 0x62, 0x0, 0x3C, 0x0, 0xFF, 0xFF +}; + +const byte CRACK[] = { + 0x2, 0x38, 0x0, 0x38, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x38, + 0x0, 0x0, 0x0, 0x38, 0x0, 0x2, 0x0, 0xFF, 0xFF +}; + +const byte LETTER[] = { + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, + 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x6, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x7, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x8, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x9, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0A, 0x0, + 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0B, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, + 0x0C, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0D, 0x0, 0x30, 0x0, 0x0, 0x0, + 0x30, 0x0, 0x0E, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x0F, 0x0, 0x30, 0x0, + 0x0, 0x0, 0x30, 0x0, 0x10, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x2, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x3, 0x0, 0x30, 0x0, 0x0, 0x0, 0x30, 0x0, 0x4, 0x0, 0x30, + 0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF +}; + +extern const byte *CHARTBL[] = { + ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT, + BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, + ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS, + JWATER, SHOOT, ADIE, DYNAMITE, MAYASHOT, OFFKEV, VALLEY, + MEANWHILE1, MAYATREE, LOCO, KISS, ROBOT, ANTKILL, LOCOHOT, + CRACK, LETTER +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index fba3bc2747..7601138835 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -35,6 +35,10 @@ extern const byte *CURSORS[10]; extern const int TRAVEL_POS[][2]; +extern const byte *ROOM_TABLE[]; + +extern const byte *CHARTBL[]; + } // End of namespace Amazon } // End of namespace Access -- cgit v1.2.3 From 031cc32c847bf7387859e273069f8efd3b6d4ed0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 6 Aug 2014 22:43:40 -0400 Subject: ACCESS: Implemented room data loading --- engines/access/access.cpp | 48 +++++++++++++ engines/access/access.h | 26 ++++++- engines/access/amazon/amazon_room.cpp | 5 ++ engines/access/amazon/amazon_room.h | 2 + engines/access/asurface.h | 2 + engines/access/data.h | 8 +++ engines/access/room.cpp | 127 +++++++++++++++++++++++++++++++++- engines/access/room.h | 35 +++++++++- engines/access/screen.cpp | 9 +++ engines/access/screen.h | 4 ++ engines/access/sound.cpp | 15 ++++ engines/access/sound.h | 9 +++ 12 files changed, 285 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6b805e4069..98f5529863 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -70,6 +70,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startup = 0; _currentCharFlag = false; _boxSelect = false; + _charFlag = 0; + _scaleH1 = _scaleH2 = 0; + _scaleN1 = 0; + _scaleT1 = 0; + _scaleMaxY = 0; + _scaleI = 0; + _playFieldHeight = 0; _roomNumber = 0; _rawPlayerXLow = 0; @@ -85,6 +92,10 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _timerFlag = false; Common::fill(&_flags[0], &_flags[99], 0); Common::fill(&_useItem[0], &_useItem[23], 0); + Common::fill(&_establishTable[0], &_establishTable[100], 0); + _establishFlag = false; + _establishMode = 0; + _establishGroup = 0; _guardLoc = 0; _guardFind = 0; _helpLevel = 0; @@ -192,6 +203,13 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +void AccessEngine::loadCells(Common::Array &cells) { + for (uint i = 0; i < cells.size(); ++i) { + _objectsTable[cells[i]._cell] = _files->loadFile( + cells[i]._fileNum, cells[i]._subfile); + } +} + void AccessEngine::clearCellTable() { Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); } @@ -228,4 +246,34 @@ void AccessEngine::freeManData() { _man = nullptr; } +void AccessEngine::establish(int v) { + _establishMode = 0; + _establishGroup = 0; + doEstablish(v); +} + +void AccessEngine::establishCenter(int v) { + _establishMode = 1; + doEstablish(v); +} + +void AccessEngine::doEstablish(int v) { + _screen->forceFadeOut(); + _screen->clearScreen(); + _screen->setPanel(3); + + if (v != -1) { + _files->loadScreen(95, v); + _buffer2.copyBuffer(_screen); + } + + warning("TODO: doEstablish"); +} + +void AccessEngine::loadPlayField(int fileNum, int subfile) { + // TODO +} + + + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 2e605e49ab..1451e21296 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -80,6 +80,8 @@ private: void setVGA(); void dummyLoop(); + + void doEstablish(int v); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -108,13 +110,18 @@ public: SoundManager *_sound; byte *_destIn; - Graphics::Surface _buffer1; - Graphics::Surface _buffer2; + ASurface _buffer1; + ASurface _buffer2; byte *_objectsTable[100]; + int _establishTable[100]; + bool _establishFlag; + int _establishMode; + int _establishGroup; int _numAnimTimers; Common::Array _timers; Common::Array _newRect; Common::Array _oldRect; + Common::Array _extraCells; int _pCount; int _selectCommand; bool _normalMouse; @@ -141,6 +148,13 @@ public: int _startTravelBox; bool _currentCharFlag; bool _boxSelect; + int _charFlag; + int _scaleH1, _scaleH2; + int _scaleN1; + int _scaleT1; + int _scaleMaxY; + int _scaleI; + int _playFieldHeight; // Fields that are included in savegames int _roomNumber; @@ -202,6 +216,8 @@ public: void freeAnimationData(); + void loadCells(Common::Array &cells); + /** * Clear the cell table */ @@ -231,6 +247,12 @@ public: * Free animation data */ void freeManData(); + + void establish(int v); + + void establishCenter(int v); + + void loadPlayField(int fileNum, int subfile); }; } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index ce0683f124..21d9c6097e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_room.h" namespace Access { @@ -32,6 +33,10 @@ AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { _antOutFlag = false; } +void AmazonRoom::loadRoom(int roomNumber) { + loadRoomData(ROOM_TABLE[roomNumber]); +} + void AmazonRoom::reloadRoom() { loadRoom(_vm->_roomNumber); diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 6d13a4e52c..006aef54f6 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -40,6 +40,8 @@ private: void roomMenu(); protected: + virtual void loadRoom(int roomNumber); + virtual void reloadRoom(); virtual void reloadRoom1(); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index ecd04b9682..830a493977 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -31,6 +31,8 @@ namespace Access { class ASurface : public Graphics::Surface { public: void clearBuffer(); + + void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } }; } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 7e10e992d9..8b77e7c5b3 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -39,6 +39,14 @@ struct TimerEntry { } }; +class ExtraCell { +public: + int _vidTable; + int _vidTable1; + int _vidSTable; + int _vidSTable1; +}; + } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f735fdb167..1e9eec79b0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -21,6 +21,7 @@ */ #include "common/scummsys.h" +#include "common/memstream.h" #include "access/access.h" #include "access/resources.h" #include "access/room.h" @@ -131,8 +132,77 @@ void Room::clearRoom() { _vm->freeManData(); } -void Room::loadRoom(int room) { - // TODO +void Room::loadRoomData(const byte *roomData) { + RoomInfo roomInfo(roomData); + + _roomFlag = roomInfo._roomFlag; + + _vm->_establishFlag = false; + if (roomInfo._estIndex != -1) { + _vm->_establishFlag = true; + if (_vm->_establishTable[roomInfo._estIndex] != 1) { + _vm->_establishTable[roomInfo._estIndex] = 1; + _vm->establish(0); + } + } + + _vm->_sound->freeMusic(); + if (roomInfo._musicFile._fileNum != -1) { + _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum, + roomInfo._musicFile._subfile); + _vm->_sound->_midiSize = _vm->_files->_filesize; + _vm->_sound->midiPlay(); + _vm->_sound->_musicRepeat = true; + } + + _vm->_scaleH1 = roomInfo._scaleH1; + _vm->_scaleH2 = roomInfo._scaleH2; + _vm->_scaleN1 = roomInfo._scaleN1; + _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; + + if (roomInfo._playFieldFile._fileNum != -1) { + _vm->loadPlayField(roomInfo._playFieldFile._fileNum, + roomInfo._playFieldFile._subfile); + setupRoom(); + + _vm->_scaleMaxY = _vm->_playFieldHeight << 4; + } + + // Load cells + _vm->loadCells(roomInfo._cells); + + // Load script data + _vm->_scripts->freeScriptData(); + if (roomInfo._scriptFile._fileNum != -1) + _vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, + roomInfo._scriptFile._subfile); + + // Load animation data + _vm->freeAnimationData(); + if (roomInfo._animFile._fileNum != -1) + _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, + roomInfo._animFile._subfile); + + _vm->_scaleI = roomInfo._scaleI; + _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; + + _vm->_screen->_startColor = roomInfo._startColor; + _vm->_screen->_numColors = roomInfo._numColors; + _vm->_screen->loadPalette(roomInfo._paletteFile._fileNum, + roomInfo._paletteFile._subfile); + + // Load extra cells + _vm->_extraCells.clear(); + for (uint i = 0; i < roomInfo._vidTable.size(); ++i) { + ExtraCell ec; + ec._vidTable = roomInfo._vidTable[i] & 0xffff; + ec._vidTable1 = roomInfo._vidTable[i] >> 16; + + _vm->_extraCells.push_back(ec); + } + + // Load sounds for the scene + _vm->_sound->loadSounds(roomInfo._sounds); } void Room::roomLoop() { @@ -156,4 +226,57 @@ void Room::buildScreen() { // TODO } +/*------------------------------------------------------------------------*/ + +RoomInfo::RoomInfo(const byte *data) { + Common::MemoryReadStream stream(data, 999); + + _roomFlag = stream.readByte() != 0; + _estIndex = (int16)stream.readUint16LE(); + _musicFile._fileNum = (int16)stream.readUint16LE(); + _musicFile._subfile = stream.readUint16LE(); + _scaleH1 = stream.readByte(); + _scaleH2 = stream.readByte(); + _scaleN1 = stream.readByte(); + _playFieldFile._fileNum = (int16)stream.readUint16LE(); + _playFieldFile._subfile = stream.readUint16LE(); + + for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) { + CellIdent ci; + ci._cell = cell; + ci._fileNum = (int16)stream.readUint16LE(); + ci._subfile = stream.readUint16LE(); + + _cells.push_back(ci); + } + + _scriptFile._fileNum = (int16)stream.readUint16LE(); + _scriptFile._subfile = stream.readUint16LE(); + _animFile._fileNum = (int16)stream.readUint16LE(); + _animFile._subfile = stream.readUint16LE(); + _scaleI = stream.readByte(); + _scrollThreshold = stream.readByte(); + _paletteFile._fileNum = (int16)stream.readUint16LE(); + _paletteFile._subfile = stream.readUint16LE(); + _startColor = stream.readUint16LE(); + _numColors = stream.readUint16LE(); + + for (int16 v = (int16)stream.readUint16LE(); v != -1; + v = (int16)stream.readUint16LE()) { + uint16 v2 = stream.readUint16LE(); + + _vidTable.push_back(v | ((uint32)v2 << 16)); + } + + for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; + fileNum = (int16)stream.readUint16LE()) { + FileIdent fi; + fi._fileNum = fileNum; + fi._subfile = stream.readUint16LE(); + + _sounds.push_back(fi); + } +}; + + } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index 28506db7d6..1b803667af 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -35,10 +35,13 @@ private: protected: AccessEngine *_vm; + void loadRoomData(const byte *roomData); void setupRoom(); void setWallCodes(); void buildScreen(); + virtual void loadRoom(int roomNumber) = 0; + virtual void reloadRoom() = 0; virtual void reloadRoom1() = 0; @@ -56,8 +59,38 @@ public: * Clear all the data used by the room */ void clearRoom(); +}; + +struct FileIdent { + int _fileNum; + int _subfile; +}; - void loadRoom(int room); +struct CellIdent : FileIdent { + byte _cell; +}; + +class RoomInfo { +public: + bool _roomFlag; + int _estIndex; + FileIdent _musicFile; + int _scaleH1; + int _scaleH2; + int _scaleN1; + FileIdent _playFieldFile; + Common::Array _cells; + FileIdent _scriptFile; + FileIdent _animFile; + int _scaleI; + int _scrollThreshold; + FileIdent _paletteFile; + int _startColor; + int _numColors; + Common::Array _vidTable; + Common::Array _sounds; +public: + RoomInfo(const byte *data); }; } // End of namespace Access diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 8dcc9f1db9..3823267bc0 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -26,6 +26,7 @@ #include "common/textconsole.h" #include "common/system.h" #include "graphics/palette.h" +#include "access/access.h" #include "access/screen.h" #include "access/resources.h" @@ -42,6 +43,8 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _topSkip = _bottomSkip = 0; _clipWidth = _clipHeight = 0; _scrollFlag = false; + _scrollThreshold = 0; + _startColor = _numColors = 0; } void Screen::setDisplayScan() { @@ -71,6 +74,12 @@ void Screen::loadPalette(Common::SeekableReadStream *stream) { _loadPalFlag = true; } +void Screen::loadPalette(int fileNum, int subfile) { + byte *palette = _vm->_files->loadFile(fileNum, subfile); + Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]); + delete[] palette; +} + void Screen::setPalette() { g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT); } diff --git a/engines/access/screen.h b/engines/access/screen.h index 1b03d261cf..57d773504f 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -56,6 +56,8 @@ private: public: bool _loadPalFlag; bool _scrollFlag; + int _scrollThreshold; + int _startColor, _numColors; public: Screen(AccessEngine *vm); @@ -89,6 +91,8 @@ public: void loadPalette(Common::SeekableReadStream *stream); + void loadPalette(int fileNum, int subfile); + void setPalette(); /** diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2f64465f8f..7ac0e4d558 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -34,6 +34,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _soundTable[i]._data = nullptr; _music = nullptr; + _midiSize = 0; + _musicRepeat = false; } SoundManager::~SoundManager() { @@ -66,6 +68,14 @@ void SoundManager::playSound(byte *data, uint32 size) { */ } +void SoundManager::loadSounds(Common::Array &sounds) { + // TODO +} + +void SoundManager::midiPlay() { + // TODO +} + void SoundManager::midiRepeat() { // TODO } @@ -78,4 +88,9 @@ void SoundManager::freeSounds() { // TODO } +void SoundManager::freeMusic() { + delete[] _music; + _music = nullptr; +} + } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 37d263eecd..a127051b29 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -49,6 +49,9 @@ public: SoundEntry _soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; byte *_music; + int _midiSize; + bool _musicRepeat; + public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); @@ -57,11 +60,17 @@ public: void playSound(int soundIndex); + void loadSounds(Common::Array &sounds); + + void midiPlay(); + void midiRepeat(); void stopSong(); void freeSounds(); + + void freeMusic(); }; } // End of namespace Access -- cgit v1.2.3 From 7378443e38e2d9ad037cb3c96e28625939c1b7a9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 7 Aug 2014 15:52:43 +0700 Subject: ZVISION: Implement safe control --- engines/zvision/module.mk | 1 + .../zvision/scripting/controls/safe_control.cpp | 208 +++++++++++++++++++++ engines/zvision/scripting/controls/safe_control.h | 71 +++++++ engines/zvision/scripting/scr_file_handling.cpp | 3 + 4 files changed, 283 insertions(+) create mode 100644 engines/zvision/scripting/controls/safe_control.cpp create mode 100644 engines/zvision/scripting/controls/safe_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index ee4a2331a0..457444c5e2 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -20,6 +20,7 @@ MODULE_OBJS := \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ scripting/controls/push_toggle_control.o \ + scripting/controls/safe_control.o \ scripting/controls/save_control.o \ scripting/controls/slot_control.o \ scripting/inventory.o \ diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp new file mode 100644 index 0000000000..a6be20bce8 --- /dev/null +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -0,0 +1,208 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/safe_control.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/animation/meta_animation.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" +#include "common/file.h" +#include "common/tokenizer.h" +#include "common/system.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_SAFE) { + _num_states = 0; + _cur_state = 0; + _animation = NULL; + _radius_inner = 0; + _radius_inner_sq = 0; + _radius_outer = 0; + _radius_outer_sq = 0; + _zero_pointer = 0; + _start_pointer = 0; + _cur_frame = -1; + _to_frame = 0; + _frame_time = 0; + _lastRenderedFrame = -1; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("animation", true)) { + if (values.hasSuffix(".avi") || values.hasSuffix(".rlf")) + _animation = new MetaAnimation(values, _engine); + } else if (param.matchString("rectangle", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _rectangle = Common::Rect(x, y, width, height); + } else if (param.matchString("num_states", true)) { + _num_states = atoi(values.c_str()); + } else if (param.matchString("center", true)) { + int x; + int y; + + sscanf(values.c_str(), "%d %d", &x, &y); + _center = Common::Point(x,y); + } else if (param.matchString("dial_inner_radius", true)) { + _radius_inner = atoi(values.c_str()); + _radius_inner_sq = _radius_inner * _radius_inner; + } else if (param.matchString("radius", true)) { + _radius_outer = atoi(values.c_str()); + _radius_outer_sq = _radius_outer * _radius_outer; + } else if (param.matchString("zero_radians_offset", true)) { + _zero_pointer = atoi(values.c_str()); + } else if (param.matchString("pointer_offset", true)) { + _start_pointer = atoi(values.c_str()); + _cur_state = _start_pointer; + } else if (param.matchString("cursor", true)) { + // Not used + } else if (param.matchString("mirrored", true)) { + // Not used + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } + renderFrame(_cur_state); +} + +SafeControl::~SafeControl() { + if (_animation) + delete _animation; + +} + +void SafeControl::renderFrame(uint frameNumber) { + if (frameNumber == 0) { + _lastRenderedFrame = frameNumber; + } else if ((int16)frameNumber < _lastRenderedFrame) { + _lastRenderedFrame = frameNumber; + frameNumber = (_num_states * 2) - frameNumber; + } else { + _lastRenderedFrame = frameNumber; + } + + const Graphics::Surface *frameData; + int x = _rectangle.left; + int y = _rectangle.top; + + frameData = _animation->getFrameData(frameNumber); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); +} + +bool SafeControl::process(uint32 deltaTimeInMillis) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_cur_frame != _to_frame) { + _frame_time -= deltaTimeInMillis; + + if (_frame_time <= 0) { + if (_cur_frame < _to_frame) { + _cur_frame++; + renderFrame(_cur_frame); + } else if (_cur_frame > _to_frame) { + _cur_frame--; + renderFrame(_cur_frame); + } + _frame_time = _animation->frameTime(); + } + } + + return false; +} + +bool SafeControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_rectangle.contains(backgroundImageSpacePos)) { + int32 mR = backgroundImageSpacePos.sqrDist(_center); + if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) { + _engine->getCursorManager()->changeCursor(CursorIndex_Active); + return true; + } + } + + return false; +} + +bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_rectangle.contains(backgroundImageSpacePos)) { + int32 mR = backgroundImageSpacePos.sqrDist(_center); + if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) { + + Common::Point tmp = backgroundImageSpacePos - _center; + + float dd = atan2(tmp.x, tmp.y) * 57.29578; + + int16 dp_state = 360 / _num_states; + + int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states; + + int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1 ) % _num_states; + + _cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states; + + _cur_state = (_num_states * 2 + tmp2) % _num_states; + + _to_frame = (_cur_state + _num_states - _start_pointer) % _num_states; + + _engine->getScriptManager()->setStateValue(_key, _cur_state); + return true; + } + } + + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h new file mode 100644 index 0000000000..2477d8c26d --- /dev/null +++ b/engines/zvision/scripting/controls/safe_control.h @@ -0,0 +1,71 @@ +/* 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 ZVISION_SAFE_CONTROL_H +#define ZVISION_SAFE_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "common/list.h" +#include "common/rect.h" + + +namespace ZVision { + +class ZorkAVIDecoder; +class MetaAnimation; + +class SafeControl : public Control { +public: + SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~SafeControl(); + +private: + int16 _num_states; + int16 _cur_state; + MetaAnimation *_animation; + Common::Point _center; + Common::Rect _rectangle; + int16 _radius_inner; + int32 _radius_inner_sq; + int16 _radius_outer; + int32 _radius_outer_sq; + int16 _zero_pointer; + int16 _start_pointer; + int16 _cur_frame; + int16 _to_frame; + int32 _frame_time; + + int16 _lastRenderedFrame; + +public: + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool process(uint32 deltaTimeInMillis); + +private: + void renderFrame(uint frameNumber); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index cacde9b3ca..b8046c0fe8 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -33,6 +33,7 @@ #include "zvision/scripting/controls/slot_control.h" #include "zvision/scripting/controls/save_control.h" #include "zvision/scripting/controls/input_control.h" +#include "zvision/scripting/controls/safe_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -352,6 +353,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new InputControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("save")) { return new SaveControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("safe")) { + return new SafeControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 2cfef440d7a9d3f50ebddd3e662175c0e0bd4e94 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 7 Aug 2014 15:58:27 +0700 Subject: ZVISION: venus_id now in base control class --- engines/zvision/scripting/control.h | 1 + engines/zvision/scripting/controls/slot_control.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index ac245054ee..7c8a273419 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -121,6 +121,7 @@ public: protected: ZVision *_engine; uint32 _key; + int32 _venus_id; void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values); // Static member functions diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h index 0ac8ec9ce0..7799785aa5 100644 --- a/engines/zvision/scripting/controls/slot_control.h +++ b/engines/zvision/scripting/controls/slot_control.h @@ -67,7 +67,6 @@ private: int _cursor; char _distance_id; - int _venus_id; int _rendered_item; -- cgit v1.2.3 From bea93f3441154197a8f599912a1102ac11688d7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 09:23:31 -0400 Subject: ACCESS: Implemented setupRoom method --- engines/access/access.cpp | 7 +----- engines/access/access.h | 7 ++---- engines/access/amazon/amazon_game.cpp | 6 ++--- engines/access/amazon/amazon_room.cpp | 16 ++++++------- engines/access/asurface.cpp | 9 ++++++++ engines/access/asurface.h | 6 +++++ engines/access/player.cpp | 2 ++ engines/access/player.h | 5 ++++ engines/access/room.cpp | 43 +++++++++++++++++++++++++++++++++-- engines/access/room.h | 2 ++ engines/access/screen.cpp | 3 +++ engines/access/screen.h | 3 +++ 12 files changed, 85 insertions(+), 24 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 98f5529863..c263ae88fa 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -71,18 +71,13 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _currentCharFlag = false; _boxSelect = false; _charFlag = 0; + _scale = 0; _scaleH1 = _scaleH2 = 0; _scaleN1 = 0; _scaleT1 = 0; _scaleMaxY = 0; _scaleI = 0; - _playFieldHeight = 0; - _roomNumber = 0; - _rawPlayerXLow = 0; - _rawPlayerX = 0; - _rawPlayerYLow = 0; - _rawPlayerY = 0; _conversation = 0; _currentMan = 0; _newTime = 0; diff --git a/engines/access/access.h b/engines/access/access.h index 1451e21296..87de9ee4e6 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -136,6 +136,7 @@ public: byte *_manPal1; byte *_music; byte *_playField; + Common::Point _playFieldSize; byte *_tile; byte *_anim; byte *_title; @@ -149,6 +150,7 @@ public: bool _currentCharFlag; bool _boxSelect; int _charFlag; + int _scale; int _scaleH1, _scaleH2; int _scaleN1; int _scaleT1; @@ -157,11 +159,6 @@ public: int _playFieldHeight; // Fields that are included in savegames - int _roomNumber; - int _rawPlayerXLow; - int _rawPlayerX; - int _rawPlayerYLow; - int _rawPlayerY; int _conversation; int _currentMan; uint32 _newTime; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index eccfc4dae7..7a16036ff3 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -164,9 +164,9 @@ void AmazonEngine::setupGame() { } // Set miscellaneous fields - _roomNumber = 4; - _player->_playerX = _rawPlayerX = TRAVEL_POS[_roomNumber][0]; - _player->_playerY = _rawPlayerY = TRAVEL_POS[_roomNumber][1]; + _player->_roomNumber = 4; + _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; + _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; _selectCommand = -1; } diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 21d9c6097e..c2a0332e17 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -38,7 +38,7 @@ void AmazonRoom::loadRoom(int roomNumber) { } void AmazonRoom::reloadRoom() { - loadRoom(_vm->_roomNumber); + loadRoom(_vm->_player->_roomNumber); if (_roomFlag != 1) { _vm->_currentMan = _roomFlag; @@ -68,8 +68,8 @@ void AmazonRoom::reloadRoom() { } void AmazonRoom::reloadRoom1() { - if (_vm->_roomNumber == 22 || _vm->_roomNumber == 31 - || _vm->_roomNumber == 42 || _vm->_roomNumber == 44) { + if (_vm->_player->_roomNumber == 22 || _vm->_player->_roomNumber == 31 + || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); _vm->_currentCharFlag = false; } @@ -84,13 +84,13 @@ void AmazonRoom::reloadRoom1() { _vm->_screen->clearScreen(); roomSet(); - if (!_roomFlag && (_vm->_roomNumber != 61 || !_antOutFlag)) { + if (!_roomFlag && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) { _vm->_player->load(); _vm->_player->calcManScale(); } - if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24 - && _vm->_roomNumber != 33 && _vm->_roomNumber != 45) { + if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24 + && _vm->_player->_roomNumber != 33 && _vm->_player->_roomNumber != 45) { roomMenu(); } @@ -99,8 +99,8 @@ void AmazonRoom::reloadRoom1() { setWallCodes(); buildScreen(); - if (_vm->_roomNumber != 20 && _vm->_roomNumber != 24 - && _vm->_roomNumber != 33) { + if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24 + && _vm->_player->_roomNumber != 33) { _vm->_screen->setPalette(); _vm->_screen->copyBF2Vid(); } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index a0a790dbdc..b791186e03 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -30,4 +30,13 @@ void ASurface::clearBuffer() { Common::fill(pSrc, pSrc + w * h, 0); } +void ASurface::setScaleTable(int scale) { + int total = 0; + for (int idx = 0; idx < 256; ++idx) { + _scaleTable1[idx] = total >> 8; + _scaleTable2[idx] = total & 0xff; + total += scale; + } +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 830a493977..857067684f 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -23,16 +23,22 @@ #ifndef ACCESS_ASURFACE_H #define ACCESS_ASURFACE_H +#include "common/scummsys.h" #include "common/rect.h" #include "graphics/surface.h" namespace Access { class ASurface : public Graphics::Surface { +private: + byte _scaleTable1[256]; + byte _scaleTable2[256]; public: void clearBuffer(); void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } + + void setScaleTable(int scale); }; } // End of namespace Access diff --git a/engines/access/player.cpp b/engines/access/player.cpp index a85df0320b..e4ef0eb48e 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -44,6 +44,8 @@ Player::Player(AccessEngine *vm): _vm(vm) { _frame = 0; _playerOff = false; + + _roomNumber = 0; } void Player::load() { diff --git a/engines/access/player.h b/engines/access/player.h index 4d19601230..ec6b53fc2a 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -60,6 +60,11 @@ public: // Additional globals we've added to new Player class bool _playerOff; + + // Additional globals that need to be saved + int _roomNumber; + Common::Point _rawPlayerLow; + Common::Point _rawPlayer; public: Player(AccessEngine *vm); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 1e9eec79b0..9ead04b2ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -206,7 +206,9 @@ void Room::loadRoomData(const byte *roomData) { } void Room::roomLoop() { - // TODO + _vm->_scripts->_sequence = 2000; + _vm->_scripts->searchForSeq(); + _vm->_scripts->executeCommand(); } @@ -215,7 +217,44 @@ void Room::doCommands() { } void Room::setupRoom() { - // TODO + _vm->_screen->setScaleTable(_vm->_scale); + _vm->_screen->setBufferScan(); + + if (_roomFlag != 2) + setIconPalette(); + + if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) { + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollCol = 0; + } else { + _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - + (_vm->_player->_rawPlayer.x >> 4); + int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - + (_vm->_screen->_vWindowSize.x / 2), 0); + _vm->_screen->_scrollCol = xp; + + xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x; + if (xp >= 0) { + _vm->_screen->_scrollCol = xp + 1; + } + } + + if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) { + _vm->_screen->_scrollY = 0; + _vm->_screen->_scrollRow = 0; + } + else { + _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - + (_vm->_player->_rawPlayer.y >> 4); + int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - + (_vm->_screen->_vWindowSize.y / 2), 0); + _vm->_screen->_scrollRow = yp; + + yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y; + if (yp >= 0) { + _vm->_screen->_scrollRow = yp + 1; + } + } } void Room::setWallCodes() { diff --git a/engines/access/room.h b/engines/access/room.h index 1b803667af..70803b4f70 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -45,6 +45,8 @@ protected: virtual void reloadRoom() = 0; virtual void reloadRoom1() = 0; + + virtual void setIconPalette() {} public: int _function; int _roomFlag; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3823267bc0..1974b1a981 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -45,6 +45,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _scrollFlag = false; _scrollThreshold = 0; _startColor = _numColors = 0; + _scrollX = _scrollY = 0; + _scrollCol = _scrollRow = 0; + } void Screen::setDisplayScan() { diff --git a/engines/access/screen.h b/engines/access/screen.h index 57d773504f..c32ae18e82 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -58,6 +58,9 @@ public: bool _scrollFlag; int _scrollThreshold; int _startColor, _numColors; + Common::Point _vWindowSize; + int _scrollX, _scrollY; + int _scrollCol, _scrollRow; public: Screen(AccessEngine *vm); -- cgit v1.2.3 From 010ba5b1262f58eabd6e8fbca710309cf7e2c003 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 19:43:42 -0400 Subject: ACCESS: Fix reading last resource of container files --- engines/access/files.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index c72d0adb7a..23171dcfe7 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -141,7 +141,8 @@ void FileManager::setAppended(int fileNum) { void FileManager::gotoAppended(int subfile) { uint32 offset = _fileIndex[subfile]; - uint32 size = _fileIndex[subfile + 1] - offset; + uint32 size = (subfile == _fileIndex.size() - 1) ? _file.size() - offset : + _fileIndex[subfile + 1] - offset; _file.seek(offset); delete _stream; -- cgit v1.2.3 From 0183007d0b4f3b951ef2c704894655e894ce4a71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 20:31:42 -0400 Subject: ACCESS: Fixes for loading room data --- engines/access/access.cpp | 2 +- engines/access/access.h | 2 +- engines/access/files.cpp | 2 +- engines/access/room.cpp | 24 ++++++++++++++++-------- engines/access/room.h | 25 +++++++++++++++---------- engines/access/sound.cpp | 2 +- engines/access/sound.h | 2 +- 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c263ae88fa..ce5d8640f0 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -198,7 +198,7 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::loadCells(Common::Array &cells) { +void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { _objectsTable[cells[i]._cell] = _files->loadFile( cells[i]._fileNum, cells[i]._subfile); diff --git a/engines/access/access.h b/engines/access/access.h index 87de9ee4e6..a30c905dd7 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -213,7 +213,7 @@ public: void freeAnimationData(); - void loadCells(Common::Array &cells); + void loadCells(Common::Array &cells); /** * Clear the cell table diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 23171dcfe7..017102b92a 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -141,7 +141,7 @@ void FileManager::setAppended(int fileNum) { void FileManager::gotoAppended(int subfile) { uint32 offset = _fileIndex[subfile]; - uint32 size = (subfile == _fileIndex.size() - 1) ? _file.size() - offset : + uint32 size = (subfile == (int)_fileIndex.size() - 1) ? _file.size() - offset : _fileIndex[subfile + 1] - offset; _file.seek(offset); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9ead04b2ac..afa42c82f0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -186,10 +186,13 @@ void Room::loadRoomData(const byte *roomData) { _vm->_scaleI = roomInfo._scaleI; _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; - _vm->_screen->_startColor = roomInfo._startColor; - _vm->_screen->_numColors = roomInfo._numColors; - _vm->_screen->loadPalette(roomInfo._paletteFile._fileNum, - roomInfo._paletteFile._subfile); + // Handle loading scene palette data + if (roomInfo._paletteFile._fileNum != -1) { + _vm->_screen->_startColor = roomInfo._startColor; + _vm->_screen->_numColors = roomInfo._numColors; + _vm->_screen->loadPalette(roomInfo._paletteFile._fileNum, + roomInfo._paletteFile._subfile); + } // Load extra cells _vm->_extraCells.clear(); @@ -270,7 +273,7 @@ void Room::buildScreen() { RoomInfo::RoomInfo(const byte *data) { Common::MemoryReadStream stream(data, 999); - _roomFlag = stream.readByte() != 0; + _roomFlag = stream.readByte(); _estIndex = (int16)stream.readUint16LE(); _musicFile._fileNum = (int16)stream.readUint16LE(); _musicFile._subfile = stream.readUint16LE(); @@ -297,8 +300,12 @@ RoomInfo::RoomInfo(const byte *data) { _scrollThreshold = stream.readByte(); _paletteFile._fileNum = (int16)stream.readUint16LE(); _paletteFile._subfile = stream.readUint16LE(); - _startColor = stream.readUint16LE(); - _numColors = stream.readUint16LE(); + if (_paletteFile._fileNum == -1) { + _startColor = _numColors = 0; + } else { + _startColor = stream.readUint16LE(); + _numColors = stream.readUint16LE(); + } for (int16 v = (int16)stream.readUint16LE(); v != -1; v = (int16)stream.readUint16LE()) { @@ -309,9 +316,10 @@ RoomInfo::RoomInfo(const byte *data) { for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; fileNum = (int16)stream.readUint16LE()) { - FileIdent fi; + SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); + fi._priority = stream.readUint16LE(); _sounds.push_back(fi); } diff --git a/engines/access/room.h b/engines/access/room.h index 70803b4f70..c42c3f1142 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -63,18 +63,23 @@ public: void clearRoom(); }; -struct FileIdent { - int _fileNum; - int _subfile; -}; - -struct CellIdent : FileIdent { - byte _cell; -}; class RoomInfo { public: - bool _roomFlag; + struct FileIdent { + int _fileNum; + int _subfile; + }; + + struct CellIdent : FileIdent { + byte _cell; + }; + + struct SoundIdent : FileIdent { + int _priority; + }; +public: + int _roomFlag; int _estIndex; FileIdent _musicFile; int _scaleH1; @@ -90,7 +95,7 @@ public: int _startColor; int _numColors; Common::Array _vidTable; - Common::Array _sounds; + Common::Array _sounds; public: RoomInfo(const byte *data); }; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 7ac0e4d558..c6897282fa 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -68,7 +68,7 @@ void SoundManager::playSound(byte *data, uint32 size) { */ } -void SoundManager::loadSounds(Common::Array &sounds) { +void SoundManager::loadSounds(Common::Array &sounds) { // TODO } diff --git a/engines/access/sound.h b/engines/access/sound.h index a127051b29..dd94396fa9 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -60,7 +60,7 @@ public: void playSound(int soundIndex); - void loadSounds(Common::Array &sounds); + void loadSounds(Common::Array &sounds); void midiPlay(); -- cgit v1.2.3 From 0c38730f3fd4965fbf1b854f76ff936dddf9f931 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 21:54:22 -0400 Subject: ACCESS: Implement buildScreen --- engines/access/data.h | 9 +++++++++ engines/access/room.cpp | 38 +++++++++++++++++++++++++++++++++++--- engines/access/room.h | 30 ++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 5 deletions(-) diff --git a/engines/access/data.h b/engines/access/data.h index 8b77e7c5b3..cf8394baf9 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -28,6 +28,15 @@ namespace Access { +class AccessEngine; + +class Manager { +protected: + AccessEngine *_vm; +public: + Manager(AccessEngine *vm) : _vm(vm) {} +}; + struct TimerEntry { int _initTm; int _timer; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index afa42c82f0..7a07f58bcb 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -26,9 +26,12 @@ #include "access/resources.h" #include "access/room.h" +#define TILE_WIDTH 16 +#define TILE_HEIGHT 16 + namespace Access { -Room::Room(AccessEngine *vm) : _vm(vm) { +Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; } @@ -261,11 +264,40 @@ void Room::setupRoom() { } void Room::setWallCodes() { - // TODO + _jetFrame.clear(); + _jetFrame.resize(_plotter._walls.size()); + + _vm->_player->_rawXTemp = _vm->_player->_rawPlayer.x; + _vm->_player->_rawYTemp = _vm->_player->_rawPlayer.y; } void Room::buildScreen() { - // TODO + int scrollCol = _vm->_screen->_scrollCol; + int cnt = _vm->_screen->_vWindowSize.x + 1; + int offset = 0; + + for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { + buildColumn(_vm->_screen->_scrollCol, offset); + ++_vm->_screen->_scrollCol; + } + + _vm->_screen->_scrollCol = scrollCol; + _vm->_screen->copyBF1BF2(); +} + +void Room::buildColumn(int playX, int screenX) { + const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * + _vm->_playFieldSize.x + playX; + byte *pDest = (byte *)_vm->_buffer1.getPixels(); + + for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { + byte *pTile = _vm->_tile + (*pSrc << 8); + + for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { + Common::copy(pTile, pTile + TILE_WIDTH, pDest); + pDest += _vm->_screen->_vWindowSize.x; + } + } } /*------------------------------------------------------------------------*/ diff --git a/engines/access/room.h b/engines/access/room.h index c42c3f1142..fa41d32552 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -24,12 +24,34 @@ #define ACCESS_ROOM_H #include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "access/data.h" namespace Access { -class AccessEngine; +class Plotter { +public: + Common::Array _walls; + Common::Array _blocks; + int _blockIn; + int _delta; +}; + +class JetFrame { +public: + int _wallCode; + int _wallCodeOld; + int _wallCode1; + int _wallCode1Old; + + JetFrame() { + _wallCode = _wallCodeOld = 0; + _wallCode1 = _wallCode1Old = 0; + } +}; -class Room { +class Room: public Manager { private: void roomLoop(); protected: @@ -48,6 +70,8 @@ protected: virtual void setIconPalette() {} public: + Plotter _plotter; + Common::Array _jetFrame; int _function; int _roomFlag; public: @@ -61,6 +85,8 @@ public: * Clear all the data used by the room */ void clearRoom(); + + void buildColumn(int playX, int screenX); }; -- cgit v1.2.3 From 6715bb0864212edaf88076dce88e5df1138333da Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 21:59:45 -0400 Subject: ACCESS: Move playField and tile data to Room class --- engines/access/access.cpp | 14 -------------- engines/access/access.h | 13 ------------- engines/access/room.cpp | 33 +++++++++++++++++++++++++-------- engines/access/room.h | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ce5d8640f0..78274f1d59 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -53,8 +53,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _inactive = nullptr; _manPal1 = nullptr; _music = nullptr; - _playField = nullptr; - _tile = nullptr; _anim = nullptr; _title = nullptr; _converseMode = 0; @@ -142,8 +140,6 @@ AccessEngine::~AccessEngine() { delete[] _inactive; delete[] _manPal1; delete[] _music; - delete[] _playField; - delete[] _tile; delete[] _anim; delete[] _title; } @@ -221,16 +217,6 @@ void AccessEngine::freeAnimationData() { _anim = nullptr; } -void AccessEngine::freePlayField() { - delete[] _playField; - _playField = nullptr; -} - -void AccessEngine::freeTileData() { - delete[] _tile; - _tile = nullptr; -} - void AccessEngine::freeInactiveData() { delete[] _inactive; _inactive = nullptr; diff --git a/engines/access/access.h b/engines/access/access.h index a30c905dd7..a0099402fd 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -135,9 +135,6 @@ public: byte *_inactive; byte *_manPal1; byte *_music; - byte *_playField; - Common::Point _playFieldSize; - byte *_tile; byte *_anim; byte *_title; int _converseMode; @@ -225,16 +222,6 @@ public: */ void freeCells(); - /** - * Free the playfield data - */ - void freePlayField(); - - /** - * Free tile data - */ - void freeTileData(); - /** * Free the inactive data */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7a07f58bcb..136d6027e6 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -34,6 +34,23 @@ namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; + _playField = nullptr; + _tile = nullptr; +} + +Room::~Room() { + delete[] _playField; + delete[] _tile; +} + +void Room::freePlayField() { + delete[] _playField; + _playField = nullptr; +} + +void Room::freeTileData() { + delete[] _tile; + _tile = nullptr; } void Room::doRoom() { @@ -130,7 +147,7 @@ void Room::clearRoom() { _vm->freeAnimationData(); _vm->_scripts->freeScriptData(); _vm->freeCells(); - _vm->freePlayField(); + freePlayField(); _vm->freeInactiveData(); _vm->freeManData(); } @@ -229,7 +246,7 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vm->_screen->_vWindowSize.x == _vm->_playFieldSize.x) { + if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { @@ -239,13 +256,13 @@ void Room::setupRoom() { (_vm->_screen->_vWindowSize.x / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vm->_screen->_vWindowSize.x - _vm->_playFieldSize.x; + xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vm->_screen->_vWindowSize.y == _vm->_playFieldSize.y) { + if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; } @@ -256,7 +273,7 @@ void Room::setupRoom() { (_vm->_screen->_vWindowSize.y / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vm->_screen->_vWindowSize.y - _vm->_playFieldSize.y; + yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -286,12 +303,12 @@ void Room::buildScreen() { } void Room::buildColumn(int playX, int screenX) { - const byte *pSrc = _vm->_playField + _vm->_screen->_scrollRow * - _vm->_playFieldSize.x + playX; + const byte *pSrc = _playField + _vm->_screen->_scrollRow * + _playFieldSize.x + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { - byte *pTile = _vm->_tile + (*pSrc << 8); + byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); diff --git a/engines/access/room.h b/engines/access/room.h index fa41d32552..a202e437bb 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -62,6 +62,17 @@ protected: void setWallCodes(); void buildScreen(); + /** + * Free the playfield data + */ + void freePlayField(); + + /** + * Free tile data + */ + void freeTileData(); + + virtual void loadRoom(int roomNumber) = 0; virtual void reloadRoom() = 0; @@ -74,9 +85,14 @@ public: Common::Array _jetFrame; int _function; int _roomFlag; + byte *_playField; + Common::Point _playFieldSize; + byte *_tile; public: Room(AccessEngine *vm); + virtual ~Room(); + void doRoom(); void doCommands(); -- cgit v1.2.3 From 52721cf2cb666affa7ae7ab952987d51c35fe0e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 22:04:01 -0400 Subject: ACCESS: General cleanup of Room class --- engines/access/room.cpp | 6 ------ engines/access/room.h | 6 ++---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 136d6027e6..de9a41c2d3 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -234,11 +234,6 @@ void Room::roomLoop() { _vm->_scripts->executeCommand(); } - -void Room::doCommands() { - // TODO -} - void Room::setupRoom() { _vm->_screen->setScaleTable(_vm->_scale); _vm->_screen->setBufferScan(); @@ -374,5 +369,4 @@ RoomInfo::RoomInfo(const byte *data) { } }; - } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index a202e437bb..c01a753d0a 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -55,8 +55,6 @@ class Room: public Manager { private: void roomLoop(); protected: - AccessEngine *_vm; - void loadRoomData(const byte *roomData); void setupRoom(); void setWallCodes(); @@ -80,6 +78,8 @@ protected: virtual void reloadRoom1() = 0; virtual void setIconPalette() {} + + virtual void doCommands() {} public: Plotter _plotter; Common::Array _jetFrame; @@ -95,8 +95,6 @@ public: void doRoom(); - void doCommands(); - /** * Clear all the data used by the room */ -- cgit v1.2.3 From 745aa3daf9934846e183d5c5034d1ec8801fa5bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 7 Aug 2014 22:53:02 -0400 Subject: ACCESS: Implemented skeleton script command method list --- engines/access/amazon/amazon_room.cpp | 2 +- engines/access/room.cpp | 2 +- engines/access/scripts.cpp | 132 ++++++++++++++++++++++++++++++++-- engines/access/scripts.h | 85 ++++++++++++++++++++-- 4 files changed, 208 insertions(+), 13 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index c2a0332e17..da7b7e18ee 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -113,7 +113,7 @@ void AmazonRoom::reloadRoom1() { void AmazonRoom::roomSet() { _vm->_numAnimTimers = 0; _vm->_scripts->_sequence = 1000; - _vm->_scripts->searchForSeq(); + _vm->_scripts->searchForSequence(); _vm->_scripts->executeCommand(); } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index de9a41c2d3..e3e3700b51 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -230,7 +230,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; - _vm->_scripts->searchForSeq(); + _vm->_scripts->searchForSequence(); _vm->_scripts->executeCommand(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bd480b8b64..6652b2922c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -24,28 +24,146 @@ #include "access/access.h" #include "access/scripts.h" +#define SCRIPT_START_BYTE 0xE0 + namespace Access { +const ScriptMethodPtr COMMAND_LIST[] = { + &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, + &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, + &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, + &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, + &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, + &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, + &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, + &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, + &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, + &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, + &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, + &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, + &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH +}; + Scripts::Scripts(AccessEngine *vm) : _vm(vm) { + _commandList = COMMAND_LIST; + _script = nullptr; + _scriptLoc = nullptr; _sequence = 0; + _endFlag = false; + _returnCode = 0; } Scripts::~Scripts() { freeScriptData(); } -void Scripts::searchForSeq() { - // TODO +void Scripts::freeScriptData() { + delete[] _script; + _script = nullptr; } -void Scripts::executeCommand() { - // TODO +void Scripts::searchForSequence() { + assert(_script); + byte *pSrc = _script; + int sequenceId; + do { + while (*pSrc++ != SCRIPT_START_BYTE) ; + sequenceId = READ_LE_UINT16(pSrc); + pSrc += 2; + } while (sequenceId != _sequence); + + _scriptLoc = pSrc; } -void Scripts::freeScriptData() { - delete[] _script; - _script = nullptr; +int Scripts::executeCommand() { + assert(_scriptLoc); + _endFlag = 0; + _returnCode = 0; + + do { + byte *pSrc = _scriptLoc; + for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; + _scriptCommand = *pSrc++; + + (this->*_commandList[_scriptCommand - 0x80])(); + _scriptLoc = pSrc; + } while (!_endFlag); + + return _returnCode; } +void Scripts::CMDENDOBJECT() { } +void Scripts::CMDJUMPLOOK() { } +void Scripts::CMDJUMPHELP() { } +void Scripts::CMDJUMPGET() { } +void Scripts::CMDJUMPMOVE() { } +void Scripts::CMDJUMPUSE() { } +void Scripts::CMDJUMPTALK() { } +void Scripts::CMDNULL() { } +void Scripts::CMDPRINT() { } +void Scripts::CMDRETPOS() { } +void Scripts::CMDANIM() { } +void Scripts::CMDSETFLAG() { } +void Scripts::CMDCHECKFLAG() { } +void Scripts::CMDGOTO() { } +void Scripts::CMDSETINV() { } +void Scripts::CMDCHECKINV() { } +void Scripts::CMDSETTEX() { } +void Scripts::CMDNEWROOM() { } +void Scripts::CMDCONVERSE() { } +void Scripts::CMDCHECKFRAME() { } +void Scripts::CMDCHECKANIM() { } +void Scripts::CMDSND() { } +void Scripts::CMDRETNEG() { } +void Scripts::CMDCHECKLOC() { } +void Scripts::CMDSETANIM() { } +void Scripts::CMDDISPINV() { } +void Scripts::CMDSETTIMER() { } +void Scripts::CMDCHECKTIMER() { } +void Scripts::CMDSETTRAVEL() { } +void Scripts::CMDSETVID() { } +void Scripts::CMDPLAYVID() { } +void Scripts::CMDPLOTIMAGE() { } +void Scripts::CMDSETDISPLAY() { } +void Scripts::CMDSETBUFFER() { } +void Scripts::CMDSETSCROLL() { } +void Scripts::CMDSAVERECT() { } +void Scripts::CMDSETBUFVID() { } +void Scripts::CMDPLAYBUFVID() { } +void Scripts::CMDREMOVELAST() { } +void Scripts::CMDSPECIAL() { } +void Scripts::CMDSETCYCLE() { } +void Scripts::CMDCYCLE() { } +void Scripts::CMDCHARSPEAK() { } +void Scripts::CMDTEXSPEAK() { } +void Scripts::CMDTEXCHOICE() { } +void Scripts::CMDWAIT() { } +void Scripts::CMDSETCONPOS() { } +void Scripts::CMDCHECKVFRAME() { } +void Scripts::CMDJUMPCHOICE() { } +void Scripts::CMDRETURNCHOICE() { } +void Scripts::CMDCLEARBLOCK() { } +void Scripts::CMDLOADSOUND() { } +void Scripts::CMDFREESOUND() { } +void Scripts::CMDSETVIDSND() { } +void Scripts::CMDPLAYVIDSND() { } +void Scripts::CMDPUSHLOCATION() { } +void Scripts::CMDPLAYEROFF() { } +void Scripts::CMDPLAYERON() { } +void Scripts::CMDDEAD() { } +void Scripts::CMDFADEOUT() { } +void Scripts::CMDENDVID() { } +void Scripts::CMDHELP() { } +void Scripts::CMDCYCLEBACK() { } +void Scripts::CMDCHAPTER() { } +void Scripts::CMDSETHELP() { } +void Scripts::CMDCENTERPANEL() { } +void Scripts::CMDMAINPANEL() { } +void Scripts::CMDRETFLASH() { } + + } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 995f12930f..99e35384a7 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -28,23 +28,100 @@ namespace Access { class AccessEngine; +class Scripts; + +typedef void(Scripts::*ScriptMethodPtr)(); class Scripts { protected: AccessEngine *_vm; + const ScriptMethodPtr *_commandList; +public: + void CMDENDOBJECT(); + void CMDJUMPLOOK(); + void CMDJUMPHELP(); + void CMDJUMPGET(); + void CMDJUMPMOVE(); + void CMDJUMPUSE(); + void CMDJUMPTALK(); + void CMDNULL(); + void CMDPRINT(); + void CMDRETPOS(); + void CMDANIM(); + void CMDSETFLAG(); + void CMDCHECKFLAG(); + void CMDGOTO(); + void CMDSETINV(); + void CMDCHECKINV(); + void CMDSETTEX(); + void CMDNEWROOM(); + void CMDCONVERSE(); + void CMDCHECKFRAME(); + void CMDCHECKANIM(); + void CMDSND(); + void CMDRETNEG(); + void CMDCHECKLOC(); + void CMDSETANIM(); + void CMDDISPINV(); + void CMDSETTIMER(); + void CMDCHECKTIMER(); + void CMDSETTRAVEL(); + void CMDSETVID(); + void CMDPLAYVID(); + void CMDPLOTIMAGE(); + void CMDSETDISPLAY(); + void CMDSETBUFFER(); + void CMDSETSCROLL(); + void CMDSAVERECT(); + void CMDSETBUFVID(); + void CMDPLAYBUFVID(); + void CMDREMOVELAST(); + void CMDSPECIAL(); + void CMDSETCYCLE(); + void CMDCYCLE(); + void CMDCHARSPEAK(); + void CMDTEXSPEAK(); + void CMDTEXCHOICE(); + void CMDWAIT(); + void CMDSETCONPOS(); + void CMDCHECKVFRAME(); + void CMDJUMPCHOICE(); + void CMDRETURNCHOICE(); + void CMDCLEARBLOCK(); + void CMDLOADSOUND(); + void CMDFREESOUND(); + void CMDSETVIDSND(); + void CMDPLAYVIDSND(); + void CMDPUSHLOCATION(); + void CMDPLAYEROFF(); + void CMDPLAYERON(); + void CMDDEAD(); + void CMDFADEOUT(); + void CMDENDVID(); + void CMDHELP(); + void CMDCYCLEBACK(); + void CMDCHAPTER(); + void CMDSETHELP(); + void CMDCENTERPANEL(); + void CMDMAINPANEL(); + void CMDRETFLASH(); public: byte *_script; + byte *_scriptLoc; int _sequence; + bool _endFlag; + int _returnCode; + int _scriptCommand; public: Scripts(AccessEngine *vm); virtual ~Scripts(); - void searchForSeq(); - - void executeCommand(); - void freeScriptData(); + + void searchForSequence(); + + int executeCommand(); }; } // End of namespace Access -- cgit v1.2.3 From 9aefd90939de855fa5533a9501b0d23e109cc385 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Aug 2014 09:13:41 -0400 Subject: ACCESS: Fix opening files by name --- engines/access/files.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 017102b92a..1ebc2fa8eb 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -66,7 +66,7 @@ void FileManager::openFile(const Common::String &filename) { // Open up the file _fileNumber = -1; _file.close(); - if (_file.open(filename)) + if (!_file.open(filename)) error("Could not open file - %s", filename.c_str()); _filesize = _file.size(); -- cgit v1.2.3 From 80c8fbe024230aaba63d93f9a2ff1c1bf25ae922 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Aug 2014 09:19:38 -0400 Subject: ACCESS: Simplify command list array to use a virtual method --- engines/access/amazon/amazon_room.cpp | 2 +- engines/access/room.cpp | 2 +- engines/access/scripts.cpp | 48 ++++++++++++++++++----------------- engines/access/scripts.h | 6 ++--- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index da7b7e18ee..df2a6b759d 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -114,7 +114,7 @@ void AmazonRoom::roomSet() { _vm->_numAnimTimers = 0; _vm->_scripts->_sequence = 1000; _vm->_scripts->searchForSequence(); - _vm->_scripts->executeCommand(); + _vm->_scripts->executeScript(); } void AmazonRoom::roomMenu() { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3e3700b51..80ab3329ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -231,7 +231,7 @@ void Room::loadRoomData(const byte *roomData) { void Room::roomLoop() { _vm->_scripts->_sequence = 2000; _vm->_scripts->searchForSequence(); - _vm->_scripts->executeCommand(); + _vm->_scripts->executeScript(); } void Room::setupRoom() { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6652b2922c..6513f34a86 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -28,28 +28,7 @@ namespace Access { -const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, - &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, - &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, - &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, - &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, - &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, - &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, - &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, - &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, - &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, - &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, - &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, - &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH -}; - Scripts::Scripts(AccessEngine *vm) : _vm(vm) { - _commandList = COMMAND_LIST; - _script = nullptr; _scriptLoc = nullptr; _sequence = 0; @@ -79,7 +58,7 @@ void Scripts::searchForSequence() { _scriptLoc = pSrc; } -int Scripts::executeCommand() { +int Scripts::executeScript() { assert(_scriptLoc); _endFlag = 0; _returnCode = 0; @@ -89,13 +68,36 @@ int Scripts::executeCommand() { for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; _scriptCommand = *pSrc++; - (this->*_commandList[_scriptCommand - 0x80])(); + executeCommand(_scriptCommand - 0x80); _scriptLoc = pSrc; } while (!_endFlag); return _returnCode; } +void Scripts::executeCommand(int commandIndex) { + static const ScriptMethodPtr COMMAND_LIST[] = { + &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, + &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, + &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, + &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, + &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, + &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, + &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, + &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, + &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, + &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, + &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, + &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, + &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH + }; + + (this->*COMMAND_LIST[commandIndex])(); +} + void Scripts::CMDENDOBJECT() { } void Scripts::CMDJUMPLOOK() { } void Scripts::CMDJUMPHELP() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 99e35384a7..b9c8b2cd56 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -35,8 +35,8 @@ typedef void(Scripts::*ScriptMethodPtr)(); class Scripts { protected: AccessEngine *_vm; - const ScriptMethodPtr *_commandList; -public: + + virtual void executeCommand(int commandIndex); void CMDENDOBJECT(); void CMDJUMPLOOK(); void CMDJUMPHELP(); @@ -121,7 +121,7 @@ public: void searchForSequence(); - int executeCommand(); + int executeScript(); }; } // End of namespace Access -- cgit v1.2.3 From fb0a1f5597145581cf082f0ef3ffcf9bea141cc9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Aug 2014 09:30:16 -0400 Subject: ACCESS: Implemented cmdGoto script command --- engines/access/scripts.cpp | 156 +++++++++++++++++++++++---------------------- engines/access/scripts.h | 151 ++++++++++++++++++++++--------------------- 2 files changed, 159 insertions(+), 148 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6513f34a86..337aa43eb5 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -45,9 +45,9 @@ void Scripts::freeScriptData() { _script = nullptr; } -void Scripts::searchForSequence() { +const byte *Scripts::searchForSequence() { assert(_script); - byte *pSrc = _script; + const byte *pSrc = _script; int sequenceId; do { while (*pSrc++ != SCRIPT_START_BYTE) ; @@ -56,6 +56,7 @@ void Scripts::searchForSequence() { } while (sequenceId != _sequence); _scriptLoc = pSrc; + return pSrc; } int Scripts::executeScript() { @@ -64,22 +65,22 @@ int Scripts::executeScript() { _returnCode = 0; do { - byte *pSrc = _scriptLoc; + const byte *pSrc = _scriptLoc; for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; _scriptCommand = *pSrc++; - executeCommand(_scriptCommand - 0x80); + executeCommand(_scriptCommand - 0x80, pSrc); _scriptLoc = pSrc; } while (!_endFlag); return _returnCode; } -void Scripts::executeCommand(int commandIndex) { +void Scripts::executeCommand(int commandIndex, const byte *&pScript) { static const ScriptMethodPtr COMMAND_LIST[] = { &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, - &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::CMDGOTO, &Scripts::CMDSETINV, &Scripts::CMDSETINV, + &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, @@ -95,77 +96,82 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH }; - (this->*COMMAND_LIST[commandIndex])(); + (this->*COMMAND_LIST[commandIndex])(pScript); } -void Scripts::CMDENDOBJECT() { } -void Scripts::CMDJUMPLOOK() { } -void Scripts::CMDJUMPHELP() { } -void Scripts::CMDJUMPGET() { } -void Scripts::CMDJUMPMOVE() { } -void Scripts::CMDJUMPUSE() { } -void Scripts::CMDJUMPTALK() { } -void Scripts::CMDNULL() { } -void Scripts::CMDPRINT() { } -void Scripts::CMDRETPOS() { } -void Scripts::CMDANIM() { } -void Scripts::CMDSETFLAG() { } -void Scripts::CMDCHECKFLAG() { } -void Scripts::CMDGOTO() { } -void Scripts::CMDSETINV() { } -void Scripts::CMDCHECKINV() { } -void Scripts::CMDSETTEX() { } -void Scripts::CMDNEWROOM() { } -void Scripts::CMDCONVERSE() { } -void Scripts::CMDCHECKFRAME() { } -void Scripts::CMDCHECKANIM() { } -void Scripts::CMDSND() { } -void Scripts::CMDRETNEG() { } -void Scripts::CMDCHECKLOC() { } -void Scripts::CMDSETANIM() { } -void Scripts::CMDDISPINV() { } -void Scripts::CMDSETTIMER() { } -void Scripts::CMDCHECKTIMER() { } -void Scripts::CMDSETTRAVEL() { } -void Scripts::CMDSETVID() { } -void Scripts::CMDPLAYVID() { } -void Scripts::CMDPLOTIMAGE() { } -void Scripts::CMDSETDISPLAY() { } -void Scripts::CMDSETBUFFER() { } -void Scripts::CMDSETSCROLL() { } -void Scripts::CMDSAVERECT() { } -void Scripts::CMDSETBUFVID() { } -void Scripts::CMDPLAYBUFVID() { } -void Scripts::CMDREMOVELAST() { } -void Scripts::CMDSPECIAL() { } -void Scripts::CMDSETCYCLE() { } -void Scripts::CMDCYCLE() { } -void Scripts::CMDCHARSPEAK() { } -void Scripts::CMDTEXSPEAK() { } -void Scripts::CMDTEXCHOICE() { } -void Scripts::CMDWAIT() { } -void Scripts::CMDSETCONPOS() { } -void Scripts::CMDCHECKVFRAME() { } -void Scripts::CMDJUMPCHOICE() { } -void Scripts::CMDRETURNCHOICE() { } -void Scripts::CMDCLEARBLOCK() { } -void Scripts::CMDLOADSOUND() { } -void Scripts::CMDFREESOUND() { } -void Scripts::CMDSETVIDSND() { } -void Scripts::CMDPLAYVIDSND() { } -void Scripts::CMDPUSHLOCATION() { } -void Scripts::CMDPLAYEROFF() { } -void Scripts::CMDPLAYERON() { } -void Scripts::CMDDEAD() { } -void Scripts::CMDFADEOUT() { } -void Scripts::CMDENDVID() { } -void Scripts::CMDHELP() { } -void Scripts::CMDCYCLEBACK() { } -void Scripts::CMDCHAPTER() { } -void Scripts::CMDSETHELP() { } -void Scripts::CMDCENTERPANEL() { } -void Scripts::CMDMAINPANEL() { } -void Scripts::CMDRETFLASH() { } +void Scripts::CMDENDOBJECT(const byte *&pScript) { } +void Scripts::CMDJUMPLOOK(const byte *&pScript) { } +void Scripts::CMDJUMPHELP(const byte *&pScript) { } +void Scripts::CMDJUMPGET(const byte *&pScript) { } +void Scripts::CMDJUMPMOVE(const byte *&pScript) { } +void Scripts::CMDJUMPUSE(const byte *&pScript) { } +void Scripts::CMDJUMPTALK(const byte *&pScript) { } +void Scripts::CMDNULL(const byte *&pScript) { } +void Scripts::CMDPRINT(const byte *&pScript) { } +void Scripts::CMDRETPOS(const byte *&pScript) { } +void Scripts::CMDANIM(const byte *&pScript) { } +void Scripts::CMDSETFLAG(const byte *&pScript) { } +void Scripts::CMDCHECKFLAG(const byte *&pScript) { } + +void Scripts::cmdGoto(const byte *&pScript) { + _sequence = READ_LE_UINT16(pScript); + pScript = searchForSequence(); +} + +void Scripts::CMDSETINV(const byte *&pScript) { } +void Scripts::CMDCHECKINV(const byte *&pScript) { } +void Scripts::CMDSETTEX(const byte *&pScript) { } +void Scripts::CMDNEWROOM(const byte *&pScript) { } +void Scripts::CMDCONVERSE(const byte *&pScript) { } +void Scripts::CMDCHECKFRAME(const byte *&pScript) { } +void Scripts::CMDCHECKANIM(const byte *&pScript) { } +void Scripts::CMDSND(const byte *&pScript) { } +void Scripts::CMDRETNEG(const byte *&pScript) { } +void Scripts::CMDCHECKLOC(const byte *&pScript) { } +void Scripts::CMDSETANIM(const byte *&pScript) { } +void Scripts::CMDDISPINV(const byte *&pScript) { } +void Scripts::CMDSETTIMER(const byte *&pScript) { } +void Scripts::CMDCHECKTIMER(const byte *&pScript) { } +void Scripts::CMDSETTRAVEL(const byte *&pScript) { } +void Scripts::CMDSETVID(const byte *&pScript) { } +void Scripts::CMDPLAYVID(const byte *&pScript) { } +void Scripts::CMDPLOTIMAGE(const byte *&pScript) { } +void Scripts::CMDSETDISPLAY(const byte *&pScript) { } +void Scripts::CMDSETBUFFER(const byte *&pScript) { } +void Scripts::CMDSETSCROLL(const byte *&pScript) { } +void Scripts::CMDSAVERECT(const byte *&pScript) { } +void Scripts::CMDSETBUFVID(const byte *&pScript) { } +void Scripts::CMDPLAYBUFVID(const byte *&pScript) { } +void Scripts::CMDREMOVELAST(const byte *&pScript) { } +void Scripts::CMDSPECIAL(const byte *&pScript) { } +void Scripts::CMDSETCYCLE(const byte *&pScript) { } +void Scripts::CMDCYCLE(const byte *&pScript) { } +void Scripts::CMDCHARSPEAK(const byte *&pScript) { } +void Scripts::CMDTEXSPEAK(const byte *&pScript) { } +void Scripts::CMDTEXCHOICE(const byte *&pScript) { } +void Scripts::CMDWAIT(const byte *&pScript) { } +void Scripts::CMDSETCONPOS(const byte *&pScript) { } +void Scripts::CMDCHECKVFRAME(const byte *&pScript) { } +void Scripts::CMDJUMPCHOICE(const byte *&pScript) { } +void Scripts::CMDRETURNCHOICE(const byte *&pScript) { } +void Scripts::CMDCLEARBLOCK(const byte *&pScript) { } +void Scripts::CMDLOADSOUND(const byte *&pScript) { } +void Scripts::CMDFREESOUND(const byte *&pScript) { } +void Scripts::CMDSETVIDSND(const byte *&pScript) { } +void Scripts::CMDPLAYVIDSND(const byte *&pScript) { } +void Scripts::CMDPUSHLOCATION(const byte *&pScript) { } +void Scripts::CMDPLAYEROFF(const byte *&pScript) { } +void Scripts::CMDPLAYERON(const byte *&pScript) { } +void Scripts::CMDDEAD(const byte *&pScript) { } +void Scripts::CMDFADEOUT(const byte *&pScript) { } +void Scripts::CMDENDVID(const byte *&pScript) { } +void Scripts::CMDHELP(const byte *&pScript) { } +void Scripts::CMDCYCLEBACK(const byte *&pScript) { } +void Scripts::CMDCHAPTER(const byte *&pScript) { } +void Scripts::CMDSETHELP(const byte *&pScript) { } +void Scripts::CMDCENTERPANEL(const byte *&pScript) { } +void Scripts::CMDMAINPANEL(const byte *&pScript) { } +void Scripts::CMDRETFLASH(const byte *&pScript) { } } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index b9c8b2cd56..fc75e9e9ab 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -30,84 +30,89 @@ namespace Access { class AccessEngine; class Scripts; -typedef void(Scripts::*ScriptMethodPtr)(); +typedef void(Scripts::*ScriptMethodPtr)(const byte *&pScript); class Scripts { protected: AccessEngine *_vm; - virtual void executeCommand(int commandIndex); - void CMDENDOBJECT(); - void CMDJUMPLOOK(); - void CMDJUMPHELP(); - void CMDJUMPGET(); - void CMDJUMPMOVE(); - void CMDJUMPUSE(); - void CMDJUMPTALK(); - void CMDNULL(); - void CMDPRINT(); - void CMDRETPOS(); - void CMDANIM(); - void CMDSETFLAG(); - void CMDCHECKFLAG(); - void CMDGOTO(); - void CMDSETINV(); - void CMDCHECKINV(); - void CMDSETTEX(); - void CMDNEWROOM(); - void CMDCONVERSE(); - void CMDCHECKFRAME(); - void CMDCHECKANIM(); - void CMDSND(); - void CMDRETNEG(); - void CMDCHECKLOC(); - void CMDSETANIM(); - void CMDDISPINV(); - void CMDSETTIMER(); - void CMDCHECKTIMER(); - void CMDSETTRAVEL(); - void CMDSETVID(); - void CMDPLAYVID(); - void CMDPLOTIMAGE(); - void CMDSETDISPLAY(); - void CMDSETBUFFER(); - void CMDSETSCROLL(); - void CMDSAVERECT(); - void CMDSETBUFVID(); - void CMDPLAYBUFVID(); - void CMDREMOVELAST(); - void CMDSPECIAL(); - void CMDSETCYCLE(); - void CMDCYCLE(); - void CMDCHARSPEAK(); - void CMDTEXSPEAK(); - void CMDTEXCHOICE(); - void CMDWAIT(); - void CMDSETCONPOS(); - void CMDCHECKVFRAME(); - void CMDJUMPCHOICE(); - void CMDRETURNCHOICE(); - void CMDCLEARBLOCK(); - void CMDLOADSOUND(); - void CMDFREESOUND(); - void CMDSETVIDSND(); - void CMDPLAYVIDSND(); - void CMDPUSHLOCATION(); - void CMDPLAYEROFF(); - void CMDPLAYERON(); - void CMDDEAD(); - void CMDFADEOUT(); - void CMDENDVID(); - void CMDHELP(); - void CMDCYCLEBACK(); - void CMDCHAPTER(); - void CMDSETHELP(); - void CMDCENTERPANEL(); - void CMDMAINPANEL(); - void CMDRETFLASH(); + virtual void executeCommand(int commandIndex, const byte *&pScript); + void CMDENDOBJECT(const byte *&pScript); + void CMDJUMPLOOK(const byte *&pScript); + void CMDJUMPHELP(const byte *&pScript); + void CMDJUMPGET(const byte *&pScript); + void CMDJUMPMOVE(const byte *&pScript); + void CMDJUMPUSE(const byte *&pScript); + void CMDJUMPTALK(const byte *&pScript); + void CMDNULL(const byte *&pScript); + void CMDPRINT(const byte *&pScript); + void CMDRETPOS(const byte *&pScript); + void CMDANIM(const byte *&pScript); + void CMDSETFLAG(const byte *&pScript); + void CMDCHECKFLAG(const byte *&pScript); + + /** + * Jump to another script + */ + void cmdGoto(const byte *&pScript); + + void CMDSETINV(const byte *&pScript); + void CMDCHECKINV(const byte *&pScript); + void CMDSETTEX(const byte *&pScript); + void CMDNEWROOM(const byte *&pScript); + void CMDCONVERSE(const byte *&pScript); + void CMDCHECKFRAME(const byte *&pScript); + void CMDCHECKANIM(const byte *&pScript); + void CMDSND(const byte *&pScript); + void CMDRETNEG(const byte *&pScript); + void CMDCHECKLOC(const byte *&pScript); + void CMDSETANIM(const byte *&pScript); + void CMDDISPINV(const byte *&pScript); + void CMDSETTIMER(const byte *&pScript); + void CMDCHECKTIMER(const byte *&pScript); + void CMDSETTRAVEL(const byte *&pScript); + void CMDSETVID(const byte *&pScript); + void CMDPLAYVID(const byte *&pScript); + void CMDPLOTIMAGE(const byte *&pScript); + void CMDSETDISPLAY(const byte *&pScript); + void CMDSETBUFFER(const byte *&pScript); + void CMDSETSCROLL(const byte *&pScript); + void CMDSAVERECT(const byte *&pScript); + void CMDSETBUFVID(const byte *&pScript); + void CMDPLAYBUFVID(const byte *&pScript); + void CMDREMOVELAST(const byte *&pScript); + void CMDSPECIAL(const byte *&pScript); + void CMDSETCYCLE(const byte *&pScript); + void CMDCYCLE(const byte *&pScript); + void CMDCHARSPEAK(const byte *&pScript); + void CMDTEXSPEAK(const byte *&pScript); + void CMDTEXCHOICE(const byte *&pScript); + void CMDWAIT(const byte *&pScript); + void CMDSETCONPOS(const byte *&pScript); + void CMDCHECKVFRAME(const byte *&pScript); + void CMDJUMPCHOICE(const byte *&pScript); + void CMDRETURNCHOICE(const byte *&pScript); + void CMDCLEARBLOCK(const byte *&pScript); + void CMDLOADSOUND(const byte *&pScript); + void CMDFREESOUND(const byte *&pScript); + void CMDSETVIDSND(const byte *&pScript); + void CMDPLAYVIDSND(const byte *&pScript); + void CMDPUSHLOCATION(const byte *&pScript); + void CMDPLAYEROFF(const byte *&pScript); + void CMDPLAYERON(const byte *&pScript); + void CMDDEAD(const byte *&pScript); + void CMDFADEOUT(const byte *&pScript); + void CMDENDVID(const byte *&pScript); + void CMDHELP(const byte *&pScript); + void CMDCYCLEBACK(const byte *&pScript); + void CMDCHAPTER(const byte *&pScript); + void CMDSETHELP(const byte *&pScript); + void CMDCENTERPANEL(const byte *&pScript); + void CMDMAINPANEL(const byte *&pScript); + void CMDRETFLASH(const byte *&pScript); public: - byte *_script; - byte *_scriptLoc; + const byte *_script; + const byte *_scriptLoc; int _sequence; bool _endFlag; int _returnCode; @@ -119,7 +124,7 @@ public: void freeScriptData(); - void searchForSequence(); + const byte *searchForSequence(); int executeScript(); }; -- cgit v1.2.3 From a9b8369274c74e2364e40b8ac3e0fb735443ae51 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 8 Aug 2014 23:29:17 -0400 Subject: ACCESS: Implemented several script commands --- engines/access/scripts.cpp | 76 +++++++++++++++++++++++++++++++++++++++------- engines/access/scripts.h | 14 ++++----- 2 files changed, 72 insertions(+), 18 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 337aa43eb5..38f9f92329 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -78,9 +78,9 @@ int Scripts::executeScript() { void Scripts::executeCommand(int commandIndex, const byte *&pScript) { static const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDENDOBJECT, &Scripts::CMDJUMPLOOK, &Scripts::CMDJUMPHELP, &Scripts::CMDJUMPGET, &Scripts::CMDJUMPMOVE, - &Scripts::CMDJUMPUSE, &Scripts::CMDJUMPTALK, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, - &Scripts::CMDSETFLAG, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV, + &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, + &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, + &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, @@ -100,18 +100,72 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { } void Scripts::CMDENDOBJECT(const byte *&pScript) { } -void Scripts::CMDJUMPLOOK(const byte *&pScript) { } -void Scripts::CMDJUMPHELP(const byte *&pScript) { } -void Scripts::CMDJUMPGET(const byte *&pScript) { } -void Scripts::CMDJUMPMOVE(const byte *&pScript) { } -void Scripts::CMDJUMPUSE(const byte *&pScript) { } -void Scripts::CMDJUMPTALK(const byte *&pScript) { } + +void Scripts::cmdJumpLook(const byte *&pScript) { + if (_vm->_selectCommand == 0) + cmdGoto(pScript); + else + pScript += 2; +} + +void Scripts::cmdJumpHelp(const byte *&pScript) { + if (_vm->_selectCommand == 8) + cmdGoto(pScript); + else + pScript += 2; +} + +void Scripts::cmdJumpGet(const byte *&pScript) { + if (_vm->_selectCommand == 3) + cmdGoto(pScript); + else + pScript += 2; +} + +void Scripts::cmdJumpMove(const byte *&pScript) { + if (_vm->_selectCommand == 2) + cmdGoto(pScript); + else + pScript += 2; +} + +void Scripts::cmdJumpUse(const byte *&pScript) { + if (_vm->_selectCommand == 4) + cmdGoto(pScript); + else + pScript += 2; +} + +void Scripts::cmdJumpTalk(const byte *&pScript) { + if (_vm->_selectCommand == 6) + cmdGoto(pScript); + else + pScript += 2; +} + void Scripts::CMDNULL(const byte *&pScript) { } void Scripts::CMDPRINT(const byte *&pScript) { } void Scripts::CMDRETPOS(const byte *&pScript) { } void Scripts::CMDANIM(const byte *&pScript) { } -void Scripts::CMDSETFLAG(const byte *&pScript) { } -void Scripts::CMDCHECKFLAG(const byte *&pScript) { } + +void Scripts::cmdSetFlag(const byte *&pScript) { + int flagNum = *pScript++; + byte flagVal = *pScript++; + assert(flagNum < 100); + _vm->_flags[flagNum] = flagVal; +} + +void Scripts::CMDCHECKFLAG(const byte *&pScript) { + int flagNum = READ_LE_UINT16(pScript); + int flagVal = READ_LE_UINT16(pScript + 2); + pScript += 4; + assert(flagNum < 100); + + if (_vm->_flags[flagNum] == (flagVal & 0xff)) + cmdGoto(pScript); + else + pScript += 2; +} void Scripts::cmdGoto(const byte *&pScript) { _sequence = READ_LE_UINT16(pScript); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index fc75e9e9ab..5e733dbd47 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -38,17 +38,17 @@ protected: virtual void executeCommand(int commandIndex, const byte *&pScript); void CMDENDOBJECT(const byte *&pScript); - void CMDJUMPLOOK(const byte *&pScript); - void CMDJUMPHELP(const byte *&pScript); - void CMDJUMPGET(const byte *&pScript); - void CMDJUMPMOVE(const byte *&pScript); - void CMDJUMPUSE(const byte *&pScript); - void CMDJUMPTALK(const byte *&pScript); + void cmdJumpLook(const byte *&pScript); + void cmdJumpHelp(const byte *&pScript); + void cmdJumpGet(const byte *&pScript); + void cmdJumpMove(const byte *&pScript); + void cmdJumpUse(const byte *&pScript); + void cmdJumpTalk(const byte *&pScript); void CMDNULL(const byte *&pScript); void CMDPRINT(const byte *&pScript); void CMDRETPOS(const byte *&pScript); void CMDANIM(const byte *&pScript); - void CMDSETFLAG(const byte *&pScript); + void cmdSetFlag(const byte *&pScript); void CMDCHECKFLAG(const byte *&pScript); /** -- cgit v1.2.3 From c930c7e6ed0128ea012d7cc09ce855e7a06b6c3c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Aug 2014 15:38:40 +0200 Subject: ACCESS: Implement some script opcodes --- engines/access/scripts.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- engines/access/scripts.h | 10 +++++----- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 38f9f92329..c78ecf573d 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -79,10 +79,10 @@ int Scripts::executeScript() { void Scripts::executeCommand(int commandIndex, const byte *&pScript) { static const ScriptMethodPtr COMMAND_LIST[] = { &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, - &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::CMDNULL, &Scripts::CMDPRINT, &Scripts::CMDRETPOS, &Scripts::CMDANIM, + &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, - &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::CMDRETPOS, &Scripts::CMDCHECKLOC, &Scripts::CMDSETANIM, + &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, @@ -91,7 +91,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPLAYEROFF, &Scripts::CMDPLAYERON, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH }; @@ -143,9 +143,16 @@ void Scripts::cmdJumpTalk(const byte *&pScript) { pScript += 2; } -void Scripts::CMDNULL(const byte *&pScript) { } +void Scripts::cmdNull(const byte *&pScript) { +} + void Scripts::CMDPRINT(const byte *&pScript) { } -void Scripts::CMDRETPOS(const byte *&pScript) { } + +void Scripts::cmdRetPos(const byte *&pScript) { + _endFlag = true; + _returnCode = 0; +} + void Scripts::CMDANIM(const byte *&pScript) { } void Scripts::cmdSetFlag(const byte *&pScript) { @@ -181,7 +188,22 @@ void Scripts::CMDCHECKFRAME(const byte *&pScript) { } void Scripts::CMDCHECKANIM(const byte *&pScript) { } void Scripts::CMDSND(const byte *&pScript) { } void Scripts::CMDRETNEG(const byte *&pScript) { } -void Scripts::CMDCHECKLOC(const byte *&pScript) { } + +void Scripts::cmdCheckLoc(const byte *&pScript) { + int minX = READ_LE_UINT16(pScript); + int minY = READ_LE_UINT16(pScript); + int maxX = READ_LE_UINT16(pScript); + int maxY = READ_LE_UINT16(pScript); + + int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x; + int curY = _vm->_player->_rawPlayer.y; + + if ((curX > minX) && (curX < maxX) && (curY > minY) && (curY < maxY)) + cmdGoto(pScript); + else + pScript += 2; +} + void Scripts::CMDSETANIM(const byte *&pScript) { } void Scripts::CMDDISPINV(const byte *&pScript) { } void Scripts::CMDSETTIMER(const byte *&pScript) { } @@ -214,8 +236,15 @@ void Scripts::CMDFREESOUND(const byte *&pScript) { } void Scripts::CMDSETVIDSND(const byte *&pScript) { } void Scripts::CMDPLAYVIDSND(const byte *&pScript) { } void Scripts::CMDPUSHLOCATION(const byte *&pScript) { } -void Scripts::CMDPLAYEROFF(const byte *&pScript) { } -void Scripts::CMDPLAYERON(const byte *&pScript) { } + +void Scripts::cmdPlayerOff(const byte *&pScript) { + _vm->_player->_playerOff = true; +} + +void Scripts::cmdPlayerOn(const byte *&pScript) { + _vm->_player->_playerOff = false; +} + void Scripts::CMDDEAD(const byte *&pScript) { } void Scripts::CMDFADEOUT(const byte *&pScript) { } void Scripts::CMDENDVID(const byte *&pScript) { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 5e733dbd47..a65c36530f 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -44,9 +44,9 @@ protected: void cmdJumpMove(const byte *&pScript); void cmdJumpUse(const byte *&pScript); void cmdJumpTalk(const byte *&pScript); - void CMDNULL(const byte *&pScript); + void cmdNull(const byte *&pScript); void CMDPRINT(const byte *&pScript); - void CMDRETPOS(const byte *&pScript); + void cmdRetPos(const byte *&pScript); void CMDANIM(const byte *&pScript); void cmdSetFlag(const byte *&pScript); void CMDCHECKFLAG(const byte *&pScript); @@ -65,7 +65,7 @@ protected: void CMDCHECKANIM(const byte *&pScript); void CMDSND(const byte *&pScript); void CMDRETNEG(const byte *&pScript); - void CMDCHECKLOC(const byte *&pScript); + void cmdCheckLoc(const byte *&pScript); void CMDSETANIM(const byte *&pScript); void CMDDISPINV(const byte *&pScript); void CMDSETTIMER(const byte *&pScript); @@ -98,8 +98,8 @@ protected: void CMDSETVIDSND(const byte *&pScript); void CMDPLAYVIDSND(const byte *&pScript); void CMDPUSHLOCATION(const byte *&pScript); - void CMDPLAYEROFF(const byte *&pScript); - void CMDPLAYERON(const byte *&pScript); + void cmdPlayerOff(const byte *&pScript); + void cmdPlayerOn(const byte *&pScript); void CMDDEAD(const byte *&pScript); void CMDFADEOUT(const byte *&pScript); void CMDENDVID(const byte *&pScript); -- cgit v1.2.3 From 5a3dfb1a7bd27bef578479b3666a6dbf9a08ce3b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 9 Aug 2014 15:54:08 +0200 Subject: ACCESS: Fix implementation of cmdCheckLoc() --- engines/access/scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index c78ecf573d..01fb73ecb4 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -198,7 +198,7 @@ void Scripts::cmdCheckLoc(const byte *&pScript) { int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x; int curY = _vm->_player->_rawPlayer.y; - if ((curX > minX) && (curX < maxX) && (curY > minY) && (curY < maxY)) + if ((curX >= minX) && (curX <= maxX) && (curY >= minY) && (curY <= maxY)) cmdGoto(pScript); else pScript += 2; -- cgit v1.2.3 From 814d4ebdd01163f0a21d8eb4d04f8201e98cf57f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 12:12:39 -0400 Subject: ACCESS: Add detection entry and subfolder adding for CD version --- engines/access/access.cpp | 12 ++++++++++++ engines/access/access.h | 1 + engines/access/detection.cpp | 4 ++++ engines/access/detection_tables.h | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 78274f1d59..cb1977a7f1 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -154,6 +154,18 @@ void AccessEngine::initialize() { DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts"); DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling"); + if (isCD()) { + const Common::FSNode gameDataDir(ConfMan.get("path")); + const Common::FSNode cdromDir = gameDataDir.getChild("cdrom"); + + for (int idx = 0; idx < 15; ++idx) { + Common::String folder = (idx == 0) ? "game" : + Common::String::format("chap%.2d", idx); + SearchMan.addSubDirectoryMatching(cdromDir, folder); + } + } + + // Create sub-objects of the engine _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); diff --git a/engines/access/access.h b/engines/access/access.h index a0099402fd..18278bf56b 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -200,6 +200,7 @@ public: virtual ~AccessEngine(); uint32 getFeatures() const; + bool isCD() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; uint16 getVersion() const; diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index ca04a64b0d..47f7af6191 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -56,6 +56,10 @@ uint32 AccessEngine::getFeatures() const { return _gameDescription->desc.flags; } +bool AccessEngine::isCD() const { + return (bool)(_gameDescription->desc.flags & ADGF_CD); +} + Common::Language AccessEngine::getLanguage() const { return _gameDescription->desc.language; } diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index cbef1d3b63..ad962f47b2 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -41,6 +41,24 @@ static const AccessGameDescription gameDescriptions[] = { 0 }, + { + // Amazon Guadians of Eden - CD English + { + "amazon", + "CD", + { + { "checksum.crc", 0, "bef85478132fec74cb5d9067f3a37d24", 8 }, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_CD, + GUIO1(GUIO_NONE) + }, + GType_Amazon, + 0 + }, + { AD_TABLE_END_MARKER, 0, 0 } }; -- cgit v1.2.3 From 3fb6c99017a0dd1502f3f01352a401c30ee3132b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 12:25:52 -0400 Subject: ACCESS: Add missing CMDOBJECT method to script command list --- engines/access/scripts.cpp | 43 ++++++++++++++++++++++++++++--------------- engines/access/scripts.h | 1 + 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 01fb73ecb4..98ab7f8a54 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -78,27 +78,40 @@ int Scripts::executeScript() { void Scripts::executeCommand(int commandIndex, const byte *&pScript) { static const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, - &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, - &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, &Scripts::CMDSETINV, &Scripts::CMDSETINV, - &Scripts::CMDCHECKINV, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, - &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::CMDSETANIM, - &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, - &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, - &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, - &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, - &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, &Scripts::CMDRETURNCHOICE, - &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, - &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, - &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, + &Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, + &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, + &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, + &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, + &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, + &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, + &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, + &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, + &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, + &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, + &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, + &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, + &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, + &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, + &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, + &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, + &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, + &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, + &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, + &Scripts::CMDRETURNCHOICE, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, + &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, + &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, + &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, + &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH }; (this->*COMMAND_LIST[commandIndex])(pScript); } +void Scripts::CMDOBJECT(const byte *&pScript) { } + void Scripts::CMDENDOBJECT(const byte *&pScript) { } void Scripts::cmdJumpLook(const byte *&pScript) { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index a65c36530f..8035450881 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -37,6 +37,7 @@ protected: AccessEngine *_vm; virtual void executeCommand(int commandIndex, const byte *&pScript); + void CMDOBJECT(const byte *&pScript); void CMDENDOBJECT(const byte *&pScript); void cmdJumpLook(const byte *&pScript); void cmdJumpHelp(const byte *&pScript); -- cgit v1.2.3 From 1171400ccb65025a77f04dae3a224a3aec5920a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 15:54:35 -0400 Subject: ACCESS: Beginnings of animation manager --- engines/access/access.cpp | 10 ++---- engines/access/access.h | 5 ++- engines/access/animation.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++ engines/access/animation.h | 68 ++++++++++++++++++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 10 ++++-- engines/access/room.h | 2 ++ engines/access/screen.cpp | 1 + engines/access/screen.h | 1 + engines/access/scripts.cpp | 20 ++++++++--- engines/access/scripts.h | 4 +-- 11 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 engines/access/animation.cpp create mode 100644 engines/access/animation.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cb1977a7f1..c98588f5ce 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -31,6 +31,7 @@ namespace Access { AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { + _animation = nullptr; _debugger = nullptr; _events = nullptr; _files = nullptr; @@ -53,7 +54,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _inactive = nullptr; _manPal1 = nullptr; _music = nullptr; - _anim = nullptr; _title = nullptr; _converseMode = 0; _startInvItem = 0; @@ -122,6 +122,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) } AccessEngine::~AccessEngine() { + delete _animation; delete _debugger; delete _events; delete _files; @@ -140,7 +141,6 @@ AccessEngine::~AccessEngine() { delete[] _inactive; delete[] _manPal1; delete[] _music; - delete[] _anim; delete[] _title; } @@ -166,6 +166,7 @@ void AccessEngine::initialize() { } // Create sub-objects of the engine + _animation = new AnimationManager(this); _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); @@ -224,11 +225,6 @@ void AccessEngine::freeCells() { } } -void AccessEngine::freeAnimationData() { - delete[] _anim; - _anim = nullptr; -} - void AccessEngine::freeInactiveData() { delete[] _inactive; _inactive = nullptr; diff --git a/engines/access/access.h b/engines/access/access.h index 18278bf56b..56600e4fb8 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -30,6 +30,7 @@ #include "common/util.h" #include "engines/engine.h" #include "graphics/surface.h" +#include "access\/animation.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -100,6 +101,7 @@ protected: */ virtual void playGame() = 0; public: + AnimationManager *_animation; Debugger *_debugger; EventsManager *_events; FileManager *_files; @@ -135,7 +137,6 @@ public: byte *_inactive; byte *_manPal1; byte *_music; - byte *_anim; byte *_title; int _converseMode; int _startInvItem; @@ -209,8 +210,6 @@ public: int getRandomNumber(int maxNumber); - void freeAnimationData(); - void loadCells(Common::Array &cells); /** diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp new file mode 100644 index 0000000000..4d73801e5d --- /dev/null +++ b/engines/access/animation.cpp @@ -0,0 +1,79 @@ +/* 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 "common/endian.h" +#include "access/animation.h" + +namespace Access { + +AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) { + _anim = nullptr; + _animation = nullptr; +} + +AnimationManager::~AnimationManager() { + delete[] _anim; + delete _animation; +} + +void AnimationManager::freeAnimationData() { + delete[] _anim; + _anim = nullptr; + _animation = nullptr; +} + +void AnimationManager::clearTimers() { + for (uint i = 0; i < _animationTimers.size(); ++i) + delete _animationTimers[i]; + + _animationTimers.clear(); +} + +Animation *AnimationManager::setAnimation(int animId) { + Animation *anim = findAnimation(animId); + + anim->_countdownTicks = anim->_ticks; + anim->_frameNumber = 0; + + anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : + anim->_loopCount; + anim->_field10 = 0; + + return anim; +} + +void AnimationManager::setAnimTimer(Animation *anim) { + +} + +Animation *AnimationManager::findAnimation(int animId) { + _animation = new Animation(_anim + READ_LE_UINT16(_anim + animId * 4 + 2)); + return _animation; +} + +/*------------------------------------------------------------------------*/ + +Animation::Animation(const byte *data) { + +} + +} // End of namespace Access diff --git a/engines/access/animation.h b/engines/access/animation.h new file mode 100644 index 0000000000..010fab98ac --- /dev/null +++ b/engines/access/animation.h @@ -0,0 +1,68 @@ +/* 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 ACCESS_ANIMATION_H +#define ACCESS_ANIMATION_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "access/data.h" + +namespace Access { + +class Animation; + +class AnimationManager : public Manager { +private: + Animation *findAnimation(int animId); +public: + const byte *_anim; + Animation *_animation; + Common::Array _animationTimers; +public: + AnimationManager(AccessEngine *vm); + ~AnimationManager(); + void freeAnimationData(); + void clearTimers(); + + Animation *setAnimation(int animId); + + void setAnimTimer(Animation *anim); +}; + +class Animation { +public: + int _type; + int _scaling; + int _frameNumber; + int _ticks; + int _loopCount; + int _countdownTicks; + int _currentLoopCount; + int _field10; +public: + Animation(const byte *data); +}; + +} // End of namespace Access + +#endif /* ACCESS_ANIMATION_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 042e84ad86..24c237a18f 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -1,6 +1,7 @@ MODULE := engines/access MODULE_OBJS := \ + animation.o \ asurface.o \ access.o \ data.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 80ab3329ac..fb70e35ee0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -144,7 +144,7 @@ void Room::clearRoom() { _vm->_sound->freeSounds(); _vm->_numAnimTimers = 0; - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); _vm->_scripts->freeScriptData(); _vm->freeCells(); freePlayField(); @@ -198,9 +198,9 @@ void Room::loadRoomData(const byte *roomData) { roomInfo._scriptFile._subfile); // Load animation data - _vm->freeAnimationData(); + _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) - _vm->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, + _vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, roomInfo._animFile._subfile); _vm->_scaleI = roomInfo._scaleI; @@ -312,6 +312,10 @@ void Room::buildColumn(int playX, int screenX) { } } +void Room::init4Quads() { + error("TODO: init4Quads"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { diff --git a/engines/access/room.h b/engines/access/room.h index c01a753d0a..72963371d6 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -101,6 +101,8 @@ public: void clearRoom(); void buildColumn(int playX, int screenX); + + void init4Quads(); }; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 1974b1a981..428c3d5df8 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -35,6 +35,7 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + _vesaMode = 0; _vesaCurrentWin = 0; _currentPanel = 0; _hideFlag = true; diff --git a/engines/access/screen.h b/engines/access/screen.h index c32ae18e82..c4beacf17c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -54,6 +54,7 @@ private: bool clip(Common::Rect &r); public: + int _vesaMode; bool _loadPalFlag; bool _scrollFlag; int _scrollThreshold; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 98ab7f8a54..2705d70d9f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::CMDSETANIM, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, + &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, @@ -104,7 +104,7 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, - &Scripts::CMDMAINPANEL, &Scripts::CMDRETFLASH + &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH }; (this->*COMMAND_LIST[commandIndex])(pScript); @@ -217,7 +217,12 @@ void Scripts::cmdCheckLoc(const byte *&pScript) { pScript += 2; } -void Scripts::CMDSETANIM(const byte *&pScript) { } +void Scripts::cmdSetAnim(const byte *&pScript) { + int animId = *pScript++; + Animation *anim = _vm->_animation->setAnimation(animId); + _vm->_animation->setAnimTimer(anim); +} + void Scripts::CMDDISPINV(const byte *&pScript) { } void Scripts::CMDSETTIMER(const byte *&pScript) { } void Scripts::CMDCHECKTIMER(const byte *&pScript) { } @@ -266,7 +271,14 @@ void Scripts::CMDCYCLEBACK(const byte *&pScript) { } void Scripts::CMDCHAPTER(const byte *&pScript) { } void Scripts::CMDSETHELP(const byte *&pScript) { } void Scripts::CMDCENTERPANEL(const byte *&pScript) { } -void Scripts::CMDMAINPANEL(const byte *&pScript) { } + +void Scripts::cmdMainPanel(const byte *&pScript) { + if (_vm->_screen->_vesaMode) { + _vm->_room->init4Quads(); + _vm->_screen->setPanel(0); + } +} + void Scripts::CMDRETFLASH(const byte *&pScript) { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 8035450881..d78b74840d 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -67,7 +67,7 @@ protected: void CMDSND(const byte *&pScript); void CMDRETNEG(const byte *&pScript); void cmdCheckLoc(const byte *&pScript); - void CMDSETANIM(const byte *&pScript); + void cmdSetAnim(const byte *&pScript); void CMDDISPINV(const byte *&pScript); void CMDSETTIMER(const byte *&pScript); void CMDCHECKTIMER(const byte *&pScript); @@ -109,7 +109,7 @@ protected: void CMDCHAPTER(const byte *&pScript); void CMDSETHELP(const byte *&pScript); void CMDCENTERPANEL(const byte *&pScript); - void CMDMAINPANEL(const byte *&pScript); + void cmdMainPanel(const byte *&pScript); void CMDRETFLASH(const byte *&pScript); public: const byte *_script; -- cgit v1.2.3 From 00633b94be93bd80fc8d1244f59647002f12fbe1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 16:31:23 -0400 Subject: ACCESS: Convert Scripts class to use a MemoryReadStream --- engines/access/room.cpp | 8 +- engines/access/scripts.cpp | 245 +++++++++++++++++++++++---------------------- engines/access/scripts.h | 152 ++++++++++++++-------------- 3 files changed, 207 insertions(+), 198 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index fb70e35ee0..e0acf1c32a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -193,9 +193,11 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); - if (roomInfo._scriptFile._fileNum != -1) - _vm->_scripts->_script = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, - roomInfo._scriptFile._subfile); + if (roomInfo._scriptFile._fileNum != -1) { + const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, + roomInfo._scriptFile._subfile); + _vm->_scripts->setScript(data, _vm->_files->_filesize); + } // Load animation data _vm->_animation->freeAnimationData(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2705d70d9f..bc86e09fcb 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -29,8 +29,8 @@ namespace Access { Scripts::Scripts(AccessEngine *vm) : _vm(vm) { - _script = nullptr; - _scriptLoc = nullptr; + _rawData = nullptr; + _data = nullptr; _sequence = 0; _endFlag = false; _returnCode = 0; @@ -40,43 +40,47 @@ Scripts::~Scripts() { freeScriptData(); } +void Scripts::setScript(const byte *data, int size) { + _rawData = data; + _data = new Common::MemoryReadStream(data, size, DisposeAfterUse::NO); +} + void Scripts::freeScriptData() { - delete[] _script; - _script = nullptr; + delete[] _rawData; + delete _data; + _data = nullptr; + _rawData = nullptr; } -const byte *Scripts::searchForSequence() { - assert(_script); - const byte *pSrc = _script; +void Scripts::searchForSequence() { + assert(_data); + + _data->seek(0); int sequenceId; do { - while (*pSrc++ != SCRIPT_START_BYTE) ; - sequenceId = READ_LE_UINT16(pSrc); - pSrc += 2; + while (_data->readByte() != SCRIPT_START_BYTE) ; + sequenceId = _data->readUint16LE(); } while (sequenceId != _sequence); - - _scriptLoc = pSrc; - return pSrc; } int Scripts::executeScript() { - assert(_scriptLoc); - _endFlag = 0; + assert(_data); + _endFlag = false; _returnCode = 0; do { - const byte *pSrc = _scriptLoc; - for (pSrc = _scriptLoc; *pSrc == SCRIPT_START_BYTE; pSrc += 3) ; - _scriptCommand = *pSrc++; + // Get next command, skipping over script start start if it's being pointed to + for (_scriptCommand = _data->readByte(); _scriptCommand == SCRIPT_START_BYTE; + _data->skip(2)); - executeCommand(_scriptCommand - 0x80, pSrc); - _scriptLoc = pSrc; + assert(_scriptCommand >= 0x80); + executeCommand(_scriptCommand - 0x80); } while (!_endFlag); return _returnCode; } -void Scripts::executeCommand(int commandIndex, const byte *&pScript) { +void Scripts::executeCommand(int commandIndex) { static const ScriptMethodPtr COMMAND_LIST[] = { &Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, @@ -107,179 +111,178 @@ void Scripts::executeCommand(int commandIndex, const byte *&pScript) { &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH }; - (this->*COMMAND_LIST[commandIndex])(pScript); + (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::CMDOBJECT(const byte *&pScript) { } +void Scripts::CMDOBJECT() { } -void Scripts::CMDENDOBJECT(const byte *&pScript) { } +void Scripts::CMDENDOBJECT() { } -void Scripts::cmdJumpLook(const byte *&pScript) { +void Scripts::cmdJumpLook() { if (_vm->_selectCommand == 0) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdJumpHelp(const byte *&pScript) { +void Scripts::cmdJumpHelp() { if (_vm->_selectCommand == 8) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdJumpGet(const byte *&pScript) { +void Scripts::cmdJumpGet() { if (_vm->_selectCommand == 3) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdJumpMove(const byte *&pScript) { +void Scripts::cmdJumpMove() { if (_vm->_selectCommand == 2) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdJumpUse(const byte *&pScript) { +void Scripts::cmdJumpUse() { if (_vm->_selectCommand == 4) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdJumpTalk(const byte *&pScript) { +void Scripts::cmdJumpTalk() { if (_vm->_selectCommand == 6) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdNull(const byte *&pScript) { +void Scripts::cmdNull() { } -void Scripts::CMDPRINT(const byte *&pScript) { } +void Scripts::CMDPRINT() { } -void Scripts::cmdRetPos(const byte *&pScript) { +void Scripts::cmdRetPos() { _endFlag = true; _returnCode = 0; } -void Scripts::CMDANIM(const byte *&pScript) { } +void Scripts::CMDANIM() { } -void Scripts::cmdSetFlag(const byte *&pScript) { - int flagNum = *pScript++; - byte flagVal = *pScript++; +void Scripts::cmdSetFlag() { + int flagNum = _data->readByte(); + byte flagVal = _data->readByte(); assert(flagNum < 100); _vm->_flags[flagNum] = flagVal; } -void Scripts::CMDCHECKFLAG(const byte *&pScript) { - int flagNum = READ_LE_UINT16(pScript); - int flagVal = READ_LE_UINT16(pScript + 2); - pScript += 4; +void Scripts::CMDCHECKFLAG() { + int flagNum = _data->readUint16LE(); + int flagVal = _data->readUint16LE(); assert(flagNum < 100); if (_vm->_flags[flagNum] == (flagVal & 0xff)) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdGoto(const byte *&pScript) { - _sequence = READ_LE_UINT16(pScript); - pScript = searchForSequence(); +void Scripts::cmdGoto() { + _sequence = _data->readUint16LE(); + searchForSequence(); } -void Scripts::CMDSETINV(const byte *&pScript) { } -void Scripts::CMDCHECKINV(const byte *&pScript) { } -void Scripts::CMDSETTEX(const byte *&pScript) { } -void Scripts::CMDNEWROOM(const byte *&pScript) { } -void Scripts::CMDCONVERSE(const byte *&pScript) { } -void Scripts::CMDCHECKFRAME(const byte *&pScript) { } -void Scripts::CMDCHECKANIM(const byte *&pScript) { } -void Scripts::CMDSND(const byte *&pScript) { } -void Scripts::CMDRETNEG(const byte *&pScript) { } - -void Scripts::cmdCheckLoc(const byte *&pScript) { - int minX = READ_LE_UINT16(pScript); - int minY = READ_LE_UINT16(pScript); - int maxX = READ_LE_UINT16(pScript); - int maxY = READ_LE_UINT16(pScript); +void Scripts::CMDSETINV() { } +void Scripts::CMDCHECKINV() { } +void Scripts::CMDSETTEX() { } +void Scripts::CMDNEWROOM() { } +void Scripts::CMDCONVERSE() { } +void Scripts::CMDCHECKFRAME() { } +void Scripts::CMDCHECKANIM() { } +void Scripts::CMDSND() { } +void Scripts::CMDRETNEG() { } + +void Scripts::cmdCheckLoc() { + int minX = _data->readUint16LE(); + int minY = _data->readUint16LE(); + int maxX = _data->readUint16LE(); + int maxY = _data->readUint16LE(); int curX = _vm->_player->_rawPlayer.x + _vm->_player->_playerOffset.x; int curY = _vm->_player->_rawPlayer.y; if ((curX >= minX) && (curX <= maxX) && (curY >= minY) && (curY <= maxY)) - cmdGoto(pScript); + cmdGoto(); else - pScript += 2; + _data->skip(2); } -void Scripts::cmdSetAnim(const byte *&pScript) { - int animId = *pScript++; +void Scripts::cmdSetAnim() { + int animId = _data->readByte(); Animation *anim = _vm->_animation->setAnimation(animId); _vm->_animation->setAnimTimer(anim); } -void Scripts::CMDDISPINV(const byte *&pScript) { } -void Scripts::CMDSETTIMER(const byte *&pScript) { } -void Scripts::CMDCHECKTIMER(const byte *&pScript) { } -void Scripts::CMDSETTRAVEL(const byte *&pScript) { } -void Scripts::CMDSETVID(const byte *&pScript) { } -void Scripts::CMDPLAYVID(const byte *&pScript) { } -void Scripts::CMDPLOTIMAGE(const byte *&pScript) { } -void Scripts::CMDSETDISPLAY(const byte *&pScript) { } -void Scripts::CMDSETBUFFER(const byte *&pScript) { } -void Scripts::CMDSETSCROLL(const byte *&pScript) { } -void Scripts::CMDSAVERECT(const byte *&pScript) { } -void Scripts::CMDSETBUFVID(const byte *&pScript) { } -void Scripts::CMDPLAYBUFVID(const byte *&pScript) { } -void Scripts::CMDREMOVELAST(const byte *&pScript) { } -void Scripts::CMDSPECIAL(const byte *&pScript) { } -void Scripts::CMDSETCYCLE(const byte *&pScript) { } -void Scripts::CMDCYCLE(const byte *&pScript) { } -void Scripts::CMDCHARSPEAK(const byte *&pScript) { } -void Scripts::CMDTEXSPEAK(const byte *&pScript) { } -void Scripts::CMDTEXCHOICE(const byte *&pScript) { } -void Scripts::CMDWAIT(const byte *&pScript) { } -void Scripts::CMDSETCONPOS(const byte *&pScript) { } -void Scripts::CMDCHECKVFRAME(const byte *&pScript) { } -void Scripts::CMDJUMPCHOICE(const byte *&pScript) { } -void Scripts::CMDRETURNCHOICE(const byte *&pScript) { } -void Scripts::CMDCLEARBLOCK(const byte *&pScript) { } -void Scripts::CMDLOADSOUND(const byte *&pScript) { } -void Scripts::CMDFREESOUND(const byte *&pScript) { } -void Scripts::CMDSETVIDSND(const byte *&pScript) { } -void Scripts::CMDPLAYVIDSND(const byte *&pScript) { } -void Scripts::CMDPUSHLOCATION(const byte *&pScript) { } - -void Scripts::cmdPlayerOff(const byte *&pScript) { +void Scripts::CMDDISPINV() { } +void Scripts::CMDSETTIMER() { } +void Scripts::CMDCHECKTIMER() { } +void Scripts::CMDSETTRAVEL() { } +void Scripts::CMDSETVID() { } +void Scripts::CMDPLAYVID() { } +void Scripts::CMDPLOTIMAGE() { } +void Scripts::CMDSETDISPLAY() { } +void Scripts::CMDSETBUFFER() { } +void Scripts::CMDSETSCROLL() { } +void Scripts::CMDSAVERECT() { } +void Scripts::CMDSETBUFVID() { } +void Scripts::CMDPLAYBUFVID() { } +void Scripts::CMDREMOVELAST() { } +void Scripts::CMDSPECIAL() { } +void Scripts::CMDSETCYCLE() { } +void Scripts::CMDCYCLE() { } +void Scripts::CMDCHARSPEAK() { } +void Scripts::CMDTEXSPEAK() { } +void Scripts::CMDTEXCHOICE() { } +void Scripts::CMDWAIT() { } +void Scripts::CMDSETCONPOS() { } +void Scripts::CMDCHECKVFRAME() { } +void Scripts::CMDJUMPCHOICE() { } +void Scripts::CMDRETURNCHOICE() { } +void Scripts::CMDCLEARBLOCK() { } +void Scripts::CMDLOADSOUND() { } +void Scripts::CMDFREESOUND() { } +void Scripts::CMDSETVIDSND() { } +void Scripts::CMDPLAYVIDSND() { } +void Scripts::CMDPUSHLOCATION() { } + +void Scripts::cmdPlayerOff() { _vm->_player->_playerOff = true; } -void Scripts::cmdPlayerOn(const byte *&pScript) { +void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::CMDDEAD(const byte *&pScript) { } -void Scripts::CMDFADEOUT(const byte *&pScript) { } -void Scripts::CMDENDVID(const byte *&pScript) { } -void Scripts::CMDHELP(const byte *&pScript) { } -void Scripts::CMDCYCLEBACK(const byte *&pScript) { } -void Scripts::CMDCHAPTER(const byte *&pScript) { } -void Scripts::CMDSETHELP(const byte *&pScript) { } -void Scripts::CMDCENTERPANEL(const byte *&pScript) { } +void Scripts::CMDDEAD() { } +void Scripts::CMDFADEOUT() { } +void Scripts::CMDENDVID() { } +void Scripts::CMDHELP() { } +void Scripts::CMDCYCLEBACK() { } +void Scripts::CMDCHAPTER() { } +void Scripts::CMDSETHELP() { } +void Scripts::CMDCENTERPANEL() { } -void Scripts::cmdMainPanel(const byte *&pScript) { +void Scripts::cmdMainPanel() { if (_vm->_screen->_vesaMode) { _vm->_room->init4Quads(); _vm->_screen->setPanel(0); } } -void Scripts::CMDRETFLASH(const byte *&pScript) { } +void Scripts::CMDRETFLASH() { } } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index d78b74840d..4375934b7c 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -24,96 +24,98 @@ #define ACCESS_SCRIPTS_H #include "common/scummsys.h" +#include "common/memstream.h" namespace Access { class AccessEngine; class Scripts; -typedef void(Scripts::*ScriptMethodPtr)(const byte *&pScript); +typedef void(Scripts::*ScriptMethodPtr)(); class Scripts { +private: + const byte *_rawData; + Common::MemoryReadStream *_data; protected: AccessEngine *_vm; - virtual void executeCommand(int commandIndex, const byte *&pScript); - void CMDOBJECT(const byte *&pScript); - void CMDENDOBJECT(const byte *&pScript); - void cmdJumpLook(const byte *&pScript); - void cmdJumpHelp(const byte *&pScript); - void cmdJumpGet(const byte *&pScript); - void cmdJumpMove(const byte *&pScript); - void cmdJumpUse(const byte *&pScript); - void cmdJumpTalk(const byte *&pScript); - void cmdNull(const byte *&pScript); - void CMDPRINT(const byte *&pScript); - void cmdRetPos(const byte *&pScript); - void CMDANIM(const byte *&pScript); - void cmdSetFlag(const byte *&pScript); - void CMDCHECKFLAG(const byte *&pScript); + virtual void executeCommand(int commandIndex); + void CMDOBJECT(); + void CMDENDOBJECT(); + void cmdJumpLook(); + void cmdJumpHelp(); + void cmdJumpGet(); + void cmdJumpMove(); + void cmdJumpUse(); + void cmdJumpTalk(); + void cmdNull(); + void CMDPRINT(); + void cmdRetPos(); + void CMDANIM(); + void cmdSetFlag(); + void CMDCHECKFLAG(); /** * Jump to another script */ - void cmdGoto(const byte *&pScript); + void cmdGoto(); - void CMDSETINV(const byte *&pScript); - void CMDCHECKINV(const byte *&pScript); - void CMDSETTEX(const byte *&pScript); - void CMDNEWROOM(const byte *&pScript); - void CMDCONVERSE(const byte *&pScript); - void CMDCHECKFRAME(const byte *&pScript); - void CMDCHECKANIM(const byte *&pScript); - void CMDSND(const byte *&pScript); - void CMDRETNEG(const byte *&pScript); - void cmdCheckLoc(const byte *&pScript); - void cmdSetAnim(const byte *&pScript); - void CMDDISPINV(const byte *&pScript); - void CMDSETTIMER(const byte *&pScript); - void CMDCHECKTIMER(const byte *&pScript); - void CMDSETTRAVEL(const byte *&pScript); - void CMDSETVID(const byte *&pScript); - void CMDPLAYVID(const byte *&pScript); - void CMDPLOTIMAGE(const byte *&pScript); - void CMDSETDISPLAY(const byte *&pScript); - void CMDSETBUFFER(const byte *&pScript); - void CMDSETSCROLL(const byte *&pScript); - void CMDSAVERECT(const byte *&pScript); - void CMDSETBUFVID(const byte *&pScript); - void CMDPLAYBUFVID(const byte *&pScript); - void CMDREMOVELAST(const byte *&pScript); - void CMDSPECIAL(const byte *&pScript); - void CMDSETCYCLE(const byte *&pScript); - void CMDCYCLE(const byte *&pScript); - void CMDCHARSPEAK(const byte *&pScript); - void CMDTEXSPEAK(const byte *&pScript); - void CMDTEXCHOICE(const byte *&pScript); - void CMDWAIT(const byte *&pScript); - void CMDSETCONPOS(const byte *&pScript); - void CMDCHECKVFRAME(const byte *&pScript); - void CMDJUMPCHOICE(const byte *&pScript); - void CMDRETURNCHOICE(const byte *&pScript); - void CMDCLEARBLOCK(const byte *&pScript); - void CMDLOADSOUND(const byte *&pScript); - void CMDFREESOUND(const byte *&pScript); - void CMDSETVIDSND(const byte *&pScript); - void CMDPLAYVIDSND(const byte *&pScript); - void CMDPUSHLOCATION(const byte *&pScript); - void cmdPlayerOff(const byte *&pScript); - void cmdPlayerOn(const byte *&pScript); - void CMDDEAD(const byte *&pScript); - void CMDFADEOUT(const byte *&pScript); - void CMDENDVID(const byte *&pScript); - void CMDHELP(const byte *&pScript); - void CMDCYCLEBACK(const byte *&pScript); - void CMDCHAPTER(const byte *&pScript); - void CMDSETHELP(const byte *&pScript); - void CMDCENTERPANEL(const byte *&pScript); - void cmdMainPanel(const byte *&pScript); - void CMDRETFLASH(const byte *&pScript); + void CMDSETINV(); + void CMDCHECKINV(); + void CMDSETTEX(); + void CMDNEWROOM(); + void CMDCONVERSE(); + void CMDCHECKFRAME(); + void CMDCHECKANIM(); + void CMDSND(); + void CMDRETNEG(); + void cmdCheckLoc(); + void cmdSetAnim(); + void CMDDISPINV(); + void CMDSETTIMER(); + void CMDCHECKTIMER(); + void CMDSETTRAVEL(); + void CMDSETVID(); + void CMDPLAYVID(); + void CMDPLOTIMAGE(); + void CMDSETDISPLAY(); + void CMDSETBUFFER(); + void CMDSETSCROLL(); + void CMDSAVERECT(); + void CMDSETBUFVID(); + void CMDPLAYBUFVID(); + void CMDREMOVELAST(); + void CMDSPECIAL(); + void CMDSETCYCLE(); + void CMDCYCLE(); + void CMDCHARSPEAK(); + void CMDTEXSPEAK(); + void CMDTEXCHOICE(); + void CMDWAIT(); + void CMDSETCONPOS(); + void CMDCHECKVFRAME(); + void CMDJUMPCHOICE(); + void CMDRETURNCHOICE(); + void CMDCLEARBLOCK(); + void CMDLOADSOUND(); + void CMDFREESOUND(); + void CMDSETVIDSND(); + void CMDPLAYVIDSND(); + void CMDPUSHLOCATION(); + void cmdPlayerOff(); + void cmdPlayerOn(); + void CMDDEAD(); + void CMDFADEOUT(); + void CMDENDVID(); + void CMDHELP(); + void CMDCYCLEBACK(); + void CMDCHAPTER(); + void CMDSETHELP(); + void CMDCENTERPANEL(); + void cmdMainPanel(); + void CMDRETFLASH(); public: - const byte *_script; - const byte *_scriptLoc; int _sequence; bool _endFlag; int _returnCode; @@ -123,9 +125,11 @@ public: virtual ~Scripts(); + void setScript(const byte *data, int size); + void freeScriptData(); - const byte *searchForSequence(); + void searchForSequence(); int executeScript(); }; -- cgit v1.2.3 From d04a6d2d7a9bfc3bcfd3ad94c48f878d1143ee32 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 17:57:34 -0400 Subject: ACCESS: Beginnings of inventory management --- engines/access/access.cpp | 8 ++-- engines/access/access.h | 7 ++-- engines/access/amazon/amazon_game.cpp | 1 + engines/access/amazon/amazon_resources.cpp | 21 ++++++++++ engines/access/amazon/amazon_resources.h | 2 + engines/access/inventory.cpp | 61 ++++++++++++++++++++++++++++++ engines/access/inventory.h | 56 +++++++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/scripts.cpp | 26 +++++++++++-- engines/access/scripts.h | 4 +- 10 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 engines/access/inventory.cpp create mode 100644 engines/access/inventory.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c98588f5ce..ee524d7afe 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -35,6 +35,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _debugger = nullptr; _events = nullptr; _files = nullptr; + _inventory = nullptr; _player = nullptr; _room = nullptr; _screen = nullptr; @@ -56,10 +57,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _music = nullptr; _title = nullptr; _converseMode = 0; - _startInvItem = 0; - _startAboutItem = 0; - _startTravelItem = 0; - _startInvBox = 0; _startAboutBox = 0; _startTravelBox = 0; _numImages = 0; @@ -104,7 +101,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _antFlag = false; _allenFlag = false; _noSound = false; - Common::fill(&inv[0], &inv[85], 0); Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); Common::fill(&_help1[0], &_help3[366], 0); @@ -126,6 +122,7 @@ AccessEngine::~AccessEngine() { delete _debugger; delete _events; delete _files; + delete _inventory; delete _player; delete _room; delete _screen; @@ -170,6 +167,7 @@ void AccessEngine::initialize() { _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); + _inventory = new InventoryManager(this); _player = new Player(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); diff --git a/engines/access/access.h b/engines/access/access.h index 56600e4fb8..0fa2c149cd 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -35,6 +35,7 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" +#include "access/inventory.h" #include "access/player.h" #include "access/room.h" #include "access/screen.h" @@ -105,6 +106,7 @@ public: Debugger *_debugger; EventsManager *_events; FileManager *_files; + InventoryManager *_inventory; Player *_player; Room *_room; Screen *_screen; @@ -139,10 +141,8 @@ public: byte *_music; byte *_title; int _converseMode; - int _startInvItem; int _startAboutItem; int _startTravelItem; - int _startInvBox; int _startAboutBox; int _startTravelBox; bool _currentCharFlag; @@ -164,7 +164,7 @@ public: int _intTim[3]; int _timer[3]; bool _timerFlag; - byte _flags[99]; + Common::Array _flags; byte _useItem[23]; int _guardLoc; int _guardFind; @@ -181,7 +181,6 @@ public: bool _antFlag; bool _allenFlag; bool _noSound; - int inv[85]; byte _help1[366]; byte _help2[366]; byte _help3[366]; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 7a16036ff3..8267c8549a 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -47,6 +47,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rawInactiveY = 0; _inactiveYOff = 0; Common::fill(&_esTabTable[0], &_esTabTable[100], 0); + _flags.resize(122); } AmazonEngine::~AmazonEngine() { diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 2f9fe0277a..87f2966d8e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -986,6 +986,27 @@ extern const byte *CHARTBL[] = { CRACK, LETTER }; +const char *const INVENTORY_NAMES[] = { + "RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM", + "VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY", + "DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY", + "DISPLAY CASE KEY", "FLITCH', 27h, 'S CAR KEYS", "COAT HANGER", + "CROWBAR", "COMPASS", "MAP", "LETTER OPENER", "LETTER", + "DECODER", "DIPPED DART", "LOADED BLOWGUN", "CARD", "JERRYCAN", + "CIGARETTES", "BIKE PUMP", "PARACHUTE", "PESO", "PEPPERS", + "MACHETE", "POISON ROOT", "AMMUNITION", "PADDLE", "FISHING NET", + "RAT TRAP", "CHEESE", "LOADED TRAP", "KNIFE", "CHOPPED PEPPERS", + "LIGHTER", "LADDER", "SMALL POLE", "JEEP KEY", "CHAIN", "ARROW", + "FILLED JERRY CAN", "EXPLOSIVES", "GEIGER COUNTER", "VINE", + "GOLD NUGGET", "HOLLOW REED", "AMAZON QUEEN KEYS", "FISHING POLE", + "HARPOON", "RAG", "BOTTLE OF RUM", "RAG IN BOTTLE", "MOLOTOV COCKTAIL", + "JUNGLE PLANT", "LADLE", "WORM", "FISH", "FIREWORKS", "BAITED POLE", + "FILLED LADLE", "EMERALD", "SMALL KEY", "SCROLL", "LIT EXPLOSIVES", + "LIGHTER", "BROKEN SPEAR", "SHOE LACES", "TORCH", "LACES AND SPEAR", + "KNIFE SPEAR", "GARBAGE CAN", "RAFT", "INFLATED RAFT", + "JASON'S CAR KEYS", "PESO BILLS", "PLANK" +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 7601138835..c9e3fe98e6 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -39,6 +39,8 @@ extern const byte *ROOM_TABLE[]; extern const byte *CHARTBL[]; +extern const char *const INVENTORY_NAMES[]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp new file mode 100644 index 0000000000..b36c5346a5 --- /dev/null +++ b/engines/access/inventory.cpp @@ -0,0 +1,61 @@ +/* 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 "access/inventory.h" +#include "access/access.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { + _startInvItem = 0; + _startInvBox = 0; + _invChangeFlag = true; + _startAboutItem = 0; + _startTravelItem = 0; + + const char *const *names = Amazon::INVENTORY_NAMES; + switch (vm->getGameID()) { + case GType_Amazon: + _inv.resize(85); + break; + default: + error("Unknown game"); + } + + for (uint i = 0; i < _inv.size(); ++i) + _names.push_back(names[i]); +} + +int &InventoryManager::operator[](int idx) { + return _inv[idx]; +} + +int InventoryManager::useItem() { + return _vm->_flags[USE_ITEM_FLAG_INDEX]; +} + +void InventoryManager::setUseItem(int itemId) { + _vm->_flags[USE_ITEM_FLAG_INDEX] = itemId; +} + +} // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h new file mode 100644 index 0000000000..2f1248e8b2 --- /dev/null +++ b/engines/access/inventory.h @@ -0,0 +1,56 @@ +/* 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 ACCESS_INVENTORY_H +#define ACCESS_INVENTORY_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "common/str-array.h" +#include "access/data.h" + +namespace Access { + +#define USE_ITEM_FLAG_INDEX 100 + +class InventoryManager : public Manager { +public: + Common::Array _inv; + Common::StringArray _names; + int _startInvItem; + int _startInvBox; + bool _invChangeFlag; + int _startAboutItem; + int _startTravelItem; +public: + InventoryManager(AccessEngine *vm); + + int &operator[](int idx); + + int useItem(); + void setUseItem(int itemId); +}; + +} // End of namespace Access + +#endif /* ACCESS_INVENTORY_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 24c237a18f..7c089fefb3 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -10,6 +10,7 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ + inventory.o \ player.o \ resources.o \ room.o \ diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bc86e09fcb..66b16e9826 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, - &Scripts::CMDSETINV, &Scripts::CMDSETINV, &Scripts::CMDCHECKINV, + &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, @@ -175,7 +175,7 @@ void Scripts::CMDANIM() { } void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); byte flagVal = _data->readByte(); - assert(flagNum < 100); + _vm->_flags[flagNum] = flagVal; } @@ -195,8 +195,26 @@ void Scripts::cmdGoto() { searchForSequence(); } -void Scripts::CMDSETINV() { } -void Scripts::CMDCHECKINV() { } +void Scripts::cmdSetInventory() { + int itemId = _data->readByte(); + int itemVal = _data->readByte(); + + (*_vm->_inventory)[itemId] = itemVal; + _vm->_inventory->_startInvItem = 0; + _vm->_inventory->_startInvBox = 0; + _vm->_inventory->_invChangeFlag = true; +} + +void Scripts::cmdCheckInventory() { + int itemId = _data->readUint16LE(); + int itemVal = _data->readUint16LE(); + + if ((*_vm->_inventory)[itemId] == itemVal) + cmdGoto(); + else + _data->skip(2); +} + void Scripts::CMDSETTEX() { } void Scripts::CMDNEWROOM() { } void Scripts::CMDCONVERSE() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 4375934b7c..6bf69c4ee3 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -61,8 +61,8 @@ protected: */ void cmdGoto(); - void CMDSETINV(); - void CMDCHECKINV(); + void cmdSetInventory(); + void cmdCheckInventory(); void CMDSETTEX(); void CMDNEWROOM(); void CMDCONVERSE(); -- cgit v1.2.3 From 127a0eeadd16719e212c19d7938158d75f51568e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 18:28:33 -0400 Subject: ACCESS: Cleanup of Amazon game flags --- engines/access/access.cpp | 21 +++------------------ engines/access/access.h | 24 +++++++----------------- engines/access/amazon/amazon_game.cpp | 8 ++++++-- engines/access/amazon/amazon_game.h | 15 +++++++++++++++ engines/access/inventory.cpp | 4 ++-- engines/access/inventory.h | 2 -- 6 files changed, 33 insertions(+), 41 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ee524d7afe..122a8a0882 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -30,7 +30,8 @@ namespace Access { AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : - _gameDescription(gameDesc), Engine(syst), _randomSource("Access") { + _gameDescription(gameDesc), Engine(syst), _randomSource("Access"), + _useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; _debugger = nullptr; _events = nullptr; @@ -80,27 +81,11 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _intTim[3] = 0; _timer[3] = 0; _timerFlag = false; - Common::fill(&_flags[0], &_flags[99], 0); - Common::fill(&_useItem[0], &_useItem[23], 0); Common::fill(&_establishTable[0], &_establishTable[100], 0); + Common::fill(&_flags[0], &_flags[256], 0); _establishFlag = false; _establishMode = 0; _establishGroup = 0; - _guardLoc = 0; - _guardFind = 0; - _helpLevel = 0; - _jasMayaFlag = 0; - _moreHelp = 0; - _startup = 0; - _flashbackFlag = false; - _manScaleOff = 0; - _riverFlag = false; - _antOutFlag = false; - _badEnd = 0; - _noHints = false; - _antFlag = false; - _allenFlag = false; - _noSound = false; Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); Common::fill(&_help1[0], &_help3[366], 0); diff --git a/engines/access/access.h b/engines/access/access.h index 0fa2c149cd..99bc201b07 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -164,23 +164,7 @@ public: int _intTim[3]; int _timer[3]; bool _timerFlag; - Common::Array _flags; - byte _useItem[23]; - int _guardLoc; - int _guardFind; - int _helpLevel; - int _jasMayaFlag; - int _moreHelp; - int _startup; - bool _flashbackFlag; - int _manScaleOff; - bool _riverFlag; - bool _antOutFlag; - int _badEnd; - bool _noHints; - bool _antFlag; - bool _allenFlag; - bool _noSound; + int _flags[256]; byte _help1[366]; byte _help2[366]; byte _help3[366]; @@ -195,6 +179,12 @@ public: int _rKeyFlag; int _mapOffset; int _screenVirtX; + + // Fields mapped into the flags array + int &_useItem; + int &_startup; + int &_manScaleOff; + public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8267c8549a..9c516168de 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -31,7 +31,12 @@ namespace Access { namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : - AccessEngine(syst, gameDesc) { + AccessEngine(syst, gameDesc), + _guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), + _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), + _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), + _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), + _noSound(_flags[239]) { _skipStart = false; _canoeLane = 0; @@ -47,7 +52,6 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rawInactiveY = 0; _inactiveYOff = 0; Common::fill(&_esTabTable[0], &_esTabTable[100], 0); - _flags.resize(122); } AmazonEngine::~AmazonEngine() { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index b998b1de83..c927ad90d7 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -48,6 +48,21 @@ private: int _inactiveYOff; int _esTabTable[100]; + // Fields that are mapped to flags + int &_guardLocation; + int &_guardFind; + int &_helpLevel; + int &_jasMayaFlag; + int &_moreHelp; + int &_flashbackFlag; + int &_riverFlag; + int &_aniOutFlag; + int &_badEnd; + int &_noHints; + int &_aniFlag; + int &_allenFlag; + int &_noSound; + /** * Do the game introduction */ diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index b36c5346a5..5d2957bd30 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -51,11 +51,11 @@ int &InventoryManager::operator[](int idx) { } int InventoryManager::useItem() { - return _vm->_flags[USE_ITEM_FLAG_INDEX]; + return _vm->_useItem; } void InventoryManager::setUseItem(int itemId) { - _vm->_flags[USE_ITEM_FLAG_INDEX] = itemId; + _vm->_useItem = itemId; } } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 2f1248e8b2..1f229dd8ee 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -31,8 +31,6 @@ namespace Access { -#define USE_ITEM_FLAG_INDEX 100 - class InventoryManager : public Manager { public: Common::Array _inv; -- cgit v1.2.3 From 33f432d9891fd07a9d8d6130ef76a8bb14b13a4b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 19:18:10 -0400 Subject: ACCESS: Fix skipping bytes in executeScript method --- engines/access/scripts.cpp | 11 ++++++----- engines/access/scripts.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 66b16e9826..dc3c62a9c1 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -70,8 +70,8 @@ int Scripts::executeScript() { do { // Get next command, skipping over script start start if it's being pointed to - for (_scriptCommand = _data->readByte(); _scriptCommand == SCRIPT_START_BYTE; - _data->skip(2)); + while ((_scriptCommand = _data->readByte()) == SCRIPT_START_BYTE) + _data->skip(2); assert(_scriptCommand >= 0x80); executeCommand(_scriptCommand - 0x80); @@ -86,7 +86,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, - &Scripts::cmdSetFlag, &Scripts::CMDCHECKFLAG, &Scripts::cmdGoto, + &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, @@ -176,15 +176,16 @@ void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); byte flagVal = _data->readByte(); + assert(flagNum < 256); _vm->_flags[flagNum] = flagVal; } -void Scripts::CMDCHECKFLAG() { +void Scripts::cmdCheckFlag() { int flagNum = _data->readUint16LE(); int flagVal = _data->readUint16LE(); assert(flagNum < 100); - if (_vm->_flags[flagNum] == (flagVal & 0xff)) + if (_vm->_flags[flagNum] == flagVal) cmdGoto(); else _data->skip(2); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 6bf69c4ee3..30bffe8112 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -54,7 +54,7 @@ protected: void cmdRetPos(); void CMDANIM(); void cmdSetFlag(); - void CMDCHECKFLAG(); + void cmdCheckFlag(); /** * Jump to another script -- cgit v1.2.3 From f495d390993a8a0d1e785c71fa36553fab17f90b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Aug 2014 01:44:24 +0200 Subject: ACCESS: Implement some more opcodes --- engines/access/animation.h | 3 +-- engines/access/scripts.cpp | 31 +++++++++++++++++++++++++------ engines/access/scripts.h | 6 +++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/engines/access/animation.h b/engines/access/animation.h index 010fab98ac..879d1e9318 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -32,8 +32,6 @@ namespace Access { class Animation; class AnimationManager : public Manager { -private: - Animation *findAnimation(int animId); public: const byte *_anim; Animation *_animation; @@ -44,6 +42,7 @@ public: void freeAnimationData(); void clearTimers(); + Animation *findAnimation(int animId); Animation *setAnimation(int animId); void setAnimTimer(Animation *anim); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index dc3c62a9c1..fe53c675c2 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -89,14 +89,14 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, - &Scripts::CMDCHECKFRAME, &Scripts::CMDCHECKANIM, &Scripts::CMDSND, + &Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, - &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::CMDREMOVELAST, + &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, @@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, - &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::CMDFADEOUT, + &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH @@ -220,7 +220,18 @@ void Scripts::CMDSETTEX() { } void Scripts::CMDNEWROOM() { } void Scripts::CMDCONVERSE() { } void Scripts::CMDCHECKFRAME() { } -void Scripts::CMDCHECKANIM() { } + +void Scripts::cmdCheckAnim() { + int id = _data->readUint16LE(); + Animation *anim = _vm->_animation->findAnimation(id); + + if (anim->_currentLoopCount == -1) { + _data->skip(2); + cmdGoto(); + } else + _data->skip(4); +} + void Scripts::CMDSND() { } void Scripts::CMDRETNEG() { } @@ -258,7 +269,11 @@ void Scripts::CMDSETSCROLL() { } void Scripts::CMDSAVERECT() { } void Scripts::CMDSETBUFVID() { } void Scripts::CMDPLAYBUFVID() { } -void Scripts::CMDREMOVELAST() { } + +void Scripts::cmeRemoveLast() { + --_vm->_numAnimTimers; +} + void Scripts::CMDSPECIAL() { } void Scripts::CMDSETCYCLE() { } void Scripts::CMDCYCLE() { } @@ -286,7 +301,11 @@ void Scripts::cmdPlayerOn() { } void Scripts::CMDDEAD() { } -void Scripts::CMDFADEOUT() { } + +void Scripts::cmdFadeOut() { + _vm->_screen->forceFadeOut(); +} + void Scripts::CMDENDVID() { } void Scripts::CMDHELP() { } void Scripts::CMDCYCLEBACK() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 30bffe8112..79ae478cc9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -67,7 +67,7 @@ protected: void CMDNEWROOM(); void CMDCONVERSE(); void CMDCHECKFRAME(); - void CMDCHECKANIM(); + void cmdCheckAnim(); void CMDSND(); void CMDRETNEG(); void cmdCheckLoc(); @@ -85,7 +85,7 @@ protected: void CMDSAVERECT(); void CMDSETBUFVID(); void CMDPLAYBUFVID(); - void CMDREMOVELAST(); + void cmeRemoveLast(); void CMDSPECIAL(); void CMDSETCYCLE(); void CMDCYCLE(); @@ -106,7 +106,7 @@ protected: void cmdPlayerOff(); void cmdPlayerOn(); void CMDDEAD(); - void CMDFADEOUT(); + void cmdFadeOut(); void CMDENDVID(); void CMDHELP(); void CMDCYCLEBACK(); -- cgit v1.2.3 From c1613178c3c89d6a088814eeeeffc6935852140f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 22:07:28 -0400 Subject: ACCESS: Implemented player loading --- engines/access/access.cpp | 1 - engines/access/asurface.cpp | 9 ---- engines/access/asurface.h | 5 --- engines/access/player.cpp | 103 +++++++++++++++++++++++++++++++++++++++---- engines/access/player.h | 13 +++++- engines/access/resources.cpp | 25 +++++++++++ engines/access/resources.h | 25 +++++++++++ engines/access/screen.cpp | 12 +++++ engines/access/screen.h | 5 +++ 9 files changed, 173 insertions(+), 25 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 122a8a0882..d0bc1a8846 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -118,7 +118,6 @@ AccessEngine::~AccessEngine() { _buffer2.free(); freeCells(); - delete[] _man; delete[] _man1; delete[] _inactive; delete[] _manPal1; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index b791186e03..a0a790dbdc 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -30,13 +30,4 @@ void ASurface::clearBuffer() { Common::fill(pSrc, pSrc + w * h, 0); } -void ASurface::setScaleTable(int scale) { - int total = 0; - for (int idx = 0; idx < 256; ++idx) { - _scaleTable1[idx] = total >> 8; - _scaleTable2[idx] = total & 0xff; - total += scale; - } -} - } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 857067684f..ace1b2382c 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -30,15 +30,10 @@ namespace Access { class ASurface : public Graphics::Surface { -private: - byte _scaleTable1[256]; - byte _scaleTable2[256]; public: void clearBuffer(); void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } - - void setScaleTable(int scale); }; } // End of namespace Access diff --git a/engines/access/player.cpp b/engines/access/player.cpp index e4ef0eb48e..f0cceb7180 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -20,19 +20,22 @@ * */ -#include "access/player.h" #include "common/algorithm.h" #include "common/textconsole.h" +#include "access/player.h" +#include "access/access.h" +#include "access/resources.h" namespace Access { -Player::Player(AccessEngine *vm): _vm(vm) { - _field0 = 0; - _monData = nullptr; +Player::Player(AccessEngine *vm): Manager(vm) { Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0); + + _field0 = 0; + _monData = nullptr; _rawTempL = 0; _rawXTemp = 0; _rawYTempL = 0; @@ -42,18 +45,102 @@ Player::Player(AccessEngine *vm): _vm(vm) { _playerYLow = 0; _playerY = 0; _frame = 0; - _playerOff = false; - + _leftDelta = _rightDelta = 0; + _upDelta = _downDelta = 0; + _scrollConst = 0; _roomNumber = 0; } void Player::load() { - // TODO + if (_vm->_room->_roomFlag == 3) { + _playerOffset.x = _vm->_screen->_scaleTable1[8]; + _playerOffset.y = _vm->_screen->_scaleTable1[11]; + _leftDelta = 0; + _rightDelta = 8; + _upDelta = 2; + _downDelta = -2; + _scrollConst = 2; + + for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { + _walkOffRight[i] = OVEROFFR[i]; + _walkOffLeft[i] = OVEROFFL[i]; + _walkOffUp[i] = OVEROFFU[i]; + _walkOffDown[i] = OVEROFFD[i]; + _walkOffUR[i].x = OVEROFFURX[i]; + _walkOffUR[i].y = OVEROFFURY[i]; + _walkOffDR[i].x = OVEROFFDRX[i]; + _walkOffDR[i].y = OVEROFFDRY[i]; + _walkOffUL[i].x = OVEROFFULX[i]; + _walkOffUL[i].y = OVEROFFULY[i]; + _walkOffDL[i].x = OVEROFFDLX[i]; + _walkOffDL[i].y = OVEROFFDLY[i]; + } + + _vm->_timers[8]._initTm = 7; + _vm->_timers[8]._timer = 7; + _vm->_timers[8]._flag = true; + + _sideWalkMin = 0; + _sideWalkMax = 5; + _upWalkMin = 12; + _upWalkMax = 17; + _downWalkMin = 6; + _downWalkMax = 11; + _diagUpWalkMin = 0; + _diagUpWalkMax = 5; + _diagDownWalkMin = 0; + _diagDownWalkMax = 5; + _guard = Common::Point(56, 190); + } else { + _playerOffset.x = _vm->_screen->_scaleTable1[25]; + _playerOffset.y = _vm->_screen->_scaleTable1[67]; + _leftDelta = -3; + _rightDelta = 33; + _upDelta = 5; + _downDelta = -10; + _scrollConst = 5; + + for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { + _walkOffRight[i] = SIDEOFFR[i]; + _walkOffLeft[i] = SIDEOFFL[i]; + _walkOffUp[i] = SIDEOFFU[i]; + _walkOffDown[i] = SIDEOFFD[i]; + _walkOffUR[i].x = DIAGOFFURX[i]; + _walkOffUR[i].y = DIAGOFFURY[i]; + _walkOffDR[i].x = DIAGOFFDRX[i]; + _walkOffDR[i].y = DIAGOFFDRY[i]; + _walkOffUL[i].x = DIAGOFFULX[i]; + _walkOffUL[i].y = DIAGOFFULY[i]; + _walkOffDL[i].x = DIAGOFFDLX[i]; + _walkOffDL[i].y = DIAGOFFDLY[i]; + } + + _sideWalkMin = 0; + _sideWalkMax = 7; + _upWalkMin = 16; + _upWalkMax = 23; + _downWalkMin = 8; + _downWalkMax = 15; + _diagUpWalkMin = 0; + _diagUpWalkMax = 7; + _diagDownWalkMin = 0; + _diagDownWalkMax = 7; + } + + _vm->_man = _vm->_man1; + Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); } void Player::calcManScale() { - // TODO + if (!_vm->_manScaleOff) { + _vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * + _vm->_scaleT1 + (_vm->_scaleH2 << 8)) / _vm->_scaleH1 * _vm->_scaleI) >> 8; + _vm->_screen->setScaleTable(_vm->_scale); + + _playerOffset.x = _vm->_screen->_scaleTable1[20]; + _playerOffset.y = _vm->_screen->_scaleTable1[67]; + } } void Player::walk() { diff --git a/engines/access/player.h b/engines/access/player.h index ec6b53fc2a..7625fa2cc7 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "access/data.h" namespace Access { @@ -32,9 +33,17 @@ namespace Access { class AccessEngine; -class Player { +class Player: public Manager { private: - AccessEngine *_vm; + int _leftDelta, _rightDelta; + int _upDelta, _downDelta; + int _scrollConst; + int _sideWalkMin, _sideWalkMax; + int _upWalkMin, _upWalkMax; + int _downWalkMin, _downWalkMax; + int _diagUpWalkMin, _diagUpWalkMax; + int _diagDownWalkMin, _diagDownWalkMax; + Common::Point _guard; public: // Fields in original Player structure int _field0; diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 8aa44b470b..841ab70f04 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -46,4 +46,29 @@ const byte INITIAL_PALETTE[18 * 3] = { 0x00, 0x00, 0x00 }; +const int SIDEOFFR[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 }; +const int SIDEOFFL[] = { 5, 5, 5, 5, 5, 5, 5, 5, 0 }; +const int SIDEOFFU[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 }; +const int SIDEOFFD[] = { 2, 2, 2, 2, 2, 2, 2, 2, 0 }; +const int DIAGOFFURX[] = { 4, 5, 2, 2, 3, 4, 2, 2, 0 }; +const int DIAGOFFURY[] = { 2, 3, 2, 2, 2, 3, 1, 1, 0 }; +const int DIAGOFFDRX[] = { 4, 5, 4, 3, 5, 4, 5, 1, 0 }; +const int DIAGOFFDRY[] = { 3, 2, 1, 2, 2, 1, 2, 1, 0 }; +const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 }; +const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 }; +const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 }; +const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 }; +const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; +const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; +const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 }; +const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; +const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 }; +const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; + } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index 47d4e3ac8c..1b49b598ca 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -29,6 +29,31 @@ namespace Access { extern const byte INITIAL_PALETTE[18 * 3]; +extern const int SIDEOFFR[]; +extern const int SIDEOFFL[]; +extern const int SIDEOFFU[]; +extern const int SIDEOFFD[]; +extern const int DIAGOFFURX[]; +extern const int DIAGOFFURY[]; +extern const int DIAGOFFDRX[]; +extern const int DIAGOFFDRY[]; +extern const int DIAGOFFULX[]; +extern const int DIAGOFFULY[]; +extern const int DIAGOFFDLX[]; +extern const int DIAGOFFDLY[]; +extern const int OVEROFFR[]; +extern const int OVEROFFL[]; +extern const int OVEROFFU[]; +extern const int OVEROFFD[]; +extern const int OVEROFFURX[]; +extern const int OVEROFFURY[]; +extern const int OVEROFFDRX[]; +extern const int OVEROFFDRY[]; +extern const int OVEROFFULX[]; +extern const int OVEROFFULY[]; +extern const int OVEROFFDLX[]; +extern const int OVEROFFDLY[]; + } // End of namespace Access #endif /* ACCESS_RESOURCES_H */ diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 428c3d5df8..45379b6a51 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -35,6 +35,9 @@ namespace Access { Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); + Common::fill(&_manPal[0], &_manPal[0x60], 0); + Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0); + Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0); _vesaMode = 0; _vesaCurrentWin = 0; _currentPanel = 0; @@ -224,4 +227,13 @@ void Screen::setBufferScan() { // TODO } +void Screen::setScaleTable(int scale) { + int total = 0; + for (int idx = 0; idx < 256; ++idx) { + _scaleTable1[idx] = total >> 8; + _scaleTable2[idx] = total & 0xff; + total += scale; + } +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index c4beacf17c..69a28bdce1 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -62,6 +62,9 @@ public: Common::Point _vWindowSize; int _scrollX, _scrollY; int _scrollCol, _scrollRow; + byte _manPal[0x60]; + byte _scaleTable1[256]; + byte _scaleTable2[256]; public: Screen(AccessEngine *vm); @@ -119,6 +122,8 @@ public: void copyRects(); void setBufferScan(); + + void setScaleTable(int scale); }; } // End of namespace Access -- cgit v1.2.3 From 9d590687e99cfee4b20dce5224edd78b33d61fd5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Aug 2014 22:24:35 -0400 Subject: ACCESS: Implemented roomMenu --- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_room.cpp | 15 ++++++++++++++- engines/access/amazon/amazon_room.h | 3 +++ engines/access/screen.cpp | 22 +++++++++++++++------- engines/access/screen.h | 4 ++++ 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 99bc201b07..e6a3f332c6 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -113,7 +113,7 @@ public: Scripts *_scripts; SoundManager *_sound; - byte *_destIn; + ASurface *_destIn; ASurface _buffer1; ASurface _buffer2; byte *_objectsTable[100]; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 9c516168de..d1ba0e0258 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -109,7 +109,7 @@ void AmazonEngine::doIntroduction() { void AmazonEngine::doTitle() { _screen->setDisplayScan(); - _destIn = (byte *)_buffer2.getPixels(); + _destIn = &_buffer2; _screen->forceFadeOut(); _events->hideCursor(); diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index df2a6b759d..565b1ccada 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -31,6 +31,10 @@ namespace Amazon { AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { _antOutFlag = false; + _icon = nullptr; +} + +AmazonRoom::~AmazonRoom() { } void AmazonRoom::loadRoom(int roomNumber) { @@ -118,7 +122,16 @@ void AmazonRoom::roomSet() { } void AmazonRoom::roomMenu() { - // TODO + _icon = _vm->_files->loadFile("ICONS.LZ"); + _vm->_screen->saveScreen(); + _vm->_screen->setDisplayScan(); + _vm->_destIn = _vm->_screen; + _vm->_screen->plotImage(_icon, 0, Common::Point(0, 177)); + _vm->_screen->plotImage(_icon, 1, Common::Point(143, 177)); + + _vm->_screen->restoreScan(); + delete[] _icon; + _icon = nullptr; } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 006aef54f6..546ea9698a 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -35,6 +35,7 @@ namespace Amazon { class AmazonRoom : public Room { private: bool _antOutFlag; + const byte *_icon; void roomSet(); @@ -47,6 +48,8 @@ protected: virtual void reloadRoom1(); public: AmazonRoom(AccessEngine *vm); + + virtual ~AmazonRoom(); }; } // End of namespace Amazon diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 45379b6a51..6a241d0c2b 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -200,31 +200,35 @@ bool Screen::clip(Common::Rect &r) { } void Screen::checkScroll() { - // TODO + warning("TODO"); } void Screen::copyBF1BF2() { - // TODO + warning("TODO"); } void Screen::copyBF2Vid() { - // TODO + warning("TODO"); } void Screen::plotList() { - // TODO + warning("TODO: plotList"); } void Screen::copyBlocks() { - // TODO + warning("TODO: copyBlocks"); } void Screen::copyRects() { - // TODO + warning("TODO: copyRects"); } void Screen::setBufferScan() { - // TODO + warning("TODO: setBufferScan"); +} + +void Screen::restoreScan() { + warning("TODO: restoreScan"); } void Screen::setScaleTable(int scale) { @@ -236,4 +240,8 @@ void Screen::setScaleTable(int scale) { } } +void Screen::saveScreen() { + warning("TODO: saveScreen"); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 69a28bdce1..a2eac29312 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -70,6 +70,8 @@ public: void setDisplayScan(); + void restoreScan(); + void setPanel(int num); /** @@ -124,6 +126,8 @@ public: void setBufferScan(); void setScaleTable(int scale); + + void saveScreen(); }; } // End of namespace Access -- cgit v1.2.3 From 00901b200bffcbff69694ff6b54d55908fd74180 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Aug 2014 14:49:46 +0200 Subject: ACCESS: Fix bug in reloadRoom1 --- engines/access/amazon/amazon_room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 565b1ccada..5627325f6e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -72,7 +72,7 @@ void AmazonRoom::reloadRoom() { } void AmazonRoom::reloadRoom1() { - if (_vm->_player->_roomNumber == 22 || _vm->_player->_roomNumber == 31 + if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); _vm->_currentCharFlag = false; -- cgit v1.2.3 From cce0c2ff97878b2b0b8a87e25395c3ef98bc584e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 11:47:15 -0400 Subject: ACCESS: Adding sprite resources and screen saving --- engines/access/access.h | 3 +- engines/access/amazon/amazon_game.cpp | 6 ++- engines/access/amazon/amazon_room.cpp | 16 ++++--- engines/access/asurface.cpp | 76 +++++++++++++++++++++++++++++ engines/access/asurface.h | 14 ++++++ engines/access/data.cpp | 39 ++++++++++++++- engines/access/data.h | 23 +++++++++ engines/access/player.cpp | 6 ++- engines/access/screen.cpp | 90 +++++++++++------------------------ engines/access/screen.h | 34 +++++++++---- 10 files changed, 223 insertions(+), 84 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index e6a3f332c6..c93a1b32e5 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -58,7 +58,8 @@ namespace Access { enum { GType_Amazon = 1, - GType_MeanStreets = 2 + GType_MeanStreets = 2, + GType_Noctropolis = 3 }; enum AccessDebugChannels { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d1ba0e0258..5c2cda61aa 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -126,6 +126,8 @@ void AmazonEngine::doTitle() { _sound->playSound(1); _objectsTable[0] = _files->loadFile(0, 2); + SpriteResource *spr = new SpriteResource(this, _objectsTable[0], _files->_filesize); + _sound->playSound(1); _screen->_loadPalFlag = false; @@ -141,9 +143,11 @@ void AmazonEngine::doTitle() { _buffer2.copyFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); - _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); + _screen->plotImage(spr, id, Common::Point(xp, 71)); } // TODO: More to do + + delete spr; } void AmazonEngine::doOpening() { diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 5627325f6e..056fa8f1eb 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -122,16 +122,18 @@ void AmazonRoom::roomSet() { } void AmazonRoom::roomMenu() { - _icon = _vm->_files->loadFile("ICONS.LZ"); + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, _icon, _vm->_files->_filesize); + delete[] iconData; + _vm->_screen->saveScreen(); _vm->_screen->setDisplayScan(); - _vm->_destIn = _vm->_screen; - _vm->_screen->plotImage(_icon, 0, Common::Point(0, 177)); - _vm->_screen->plotImage(_icon, 1, Common::Point(143, 177)); + _vm->_destIn = _vm->_screen; // TODO: Redundant + _vm->_screen->plotImage(spr, 0, Common::Point(0, 177)); + _vm->_screen->plotImage(spr, 1, Common::Point(143, 177)); - _vm->_screen->restoreScan(); - delete[] _icon; - _icon = nullptr; + _vm->_screen->restoreScreen(); + delete spr; } } // End of namespace Amazon diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index a0a790dbdc..0fb8f7d43a 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -25,9 +25,85 @@ namespace Access { + +/*------------------------------------------------------------------------*/ + +int ASurface::_leftSkip; +int ASurface::_rightSkip; +int ASurface::_topSkip; +int ASurface::_bottomSkip; +int ASurface::_clipWidth; +int ASurface::_clipHeight; +int ASurface::_lastBoundsX; +int ASurface::_lastBoundsY; +int ASurface::_lastBoundsW; +int ASurface::_lastBoundsH; + void ASurface::clearBuffer() { byte *pSrc = (byte *)getPixels(); Common::fill(pSrc, pSrc + w * h, 0); } +bool ASurface::clip(Common::Rect &r) { + int skip; + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + + if (r.left > _clipWidth) { + skip = -r.left; + r.setWidth(r.width() - skip); + _leftSkip = skip; + r.moveTo(0, r.top); + } + else if (r.left >= 0) + return true; + + int right = r.right - 1; + if (right < 0) + return true; + else if (right > _clipWidth) { + skip = right - _clipWidth; + r.setWidth(r.width() - skip); + _rightSkip = skip; + } + + if (r.top > _clipHeight) { + skip = -r.top; + r.setHeight(r.height() - skip); + _topSkip = skip; + r.moveTo(r.left, 0); + } + else if (r.top >= 0) + return true; + + int bottom = r.bottom - 1; + if (bottom < 0) + return true; + else if (bottom > _clipHeight) { + skip = bottom - _clipHeight; + _bottomSkip = skip; + r.setHeight(r.height() - skip); + } + + return false; +} + +void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) { + SpriteFrame *frame = sprite->getFrame(frameNum); + Common::Rect r(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h); + + if (!clip(r)) { + _lastBoundsX = r.left; + _lastBoundsY = r.top; + _lastBoundsW = r.width(); + _lastBoundsH = r.height(); + +// plotImage(frame, , ) + } +} + +void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { + +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index ace1b2382c..7d1ee6c57a 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -24,16 +24,30 @@ #define ACCESS_ASURFACE_H #include "common/scummsys.h" +#include "common/array.h" #include "common/rect.h" #include "graphics/surface.h" +#include "access/data.h" namespace Access { class ASurface : public Graphics::Surface { +public: + static int _leftSkip, _rightSkip; + static int _topSkip, _bottomSkip; + static int _clipWidth, _clipHeight; + static int _lastBoundsX, _lastBoundsY; + static int _lastBoundsW, _lastBoundsH; +protected: + virtual void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt); public: void clearBuffer(); void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } + + bool clip(Common::Rect &r); + + void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); }; } // End of namespace Access diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 0ef1845892..ed913c9be9 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -20,10 +20,47 @@ * */ -#include "access/data.h" #include "common/algorithm.h" +#include "common/endian.h" +#include "common/memstream.h" +#include "access/access.h" +#include "access/data.h" namespace Access { +SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) { + Common::MemoryReadStream stream(data, size); + Common::Array offsets; + int count = stream.readUint16LE(); + + for (int i = 0; i < count; i++) + offsets.push_back(stream.readUint32LE()); + offsets.push_back(size); // For easier calculations of Noctropolis sizes + + // Build up the frames + for (int i = 0; i < count; ++i) { + stream.seek(offsets[i]); + + SpriteFrame *frame = new SpriteFrame(); + frame->_width = stream.readUint16LE(); + frame->_height = stream.readUint16LE(); + frame->_size = (vm->getGameID() == GType_MeanStreets) ? stream.readUint16LE() : + offsets[i + 1] - offsets[i]; + + frame->_data = new byte[frame->_size]; + stream.read(frame->_data, frame->_size); + + _frames.push_back(frame); + } +} + +SpriteResource::~SpriteResource() { + for (uint i = 0; i < _frames.size(); ++i) + delete _frames[i]; +} + +SpriteFrame::~SpriteFrame() { + delete[] _data; +} } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index cf8394baf9..bd1e1563fc 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -24,7 +24,9 @@ #define ACCESS_DATA_H #include "common/scummsys.h" +#include "common/array.h" #include "common/rect.h" +#include "graphics/surface.h" namespace Access { @@ -56,6 +58,27 @@ public: int _vidSTable1; }; +class SpriteFrame : public Graphics::Surface { +public: + uint16 _width, _height; + byte *_data; + uint32 _size; + + ~SpriteFrame(); +}; + +class SpriteResource { +public: + Common::Array _frames; +public: + SpriteResource(AccessEngine *vm, const byte *data, uint32 size); + ~SpriteResource(); + + int getCount() { return _frames.size(); } + + SpriteFrame *getFrame(int idx) { return _frames[idx]; } +}; + } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/player.cpp b/engines/access/player.cpp index f0cceb7180..b28e6c92bc 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -129,7 +129,11 @@ void Player::load() { } _vm->_man = _vm->_man1; - Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); + if (_vm->_manPal1) { + Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); + } else { + Common::fill(_vm->_screen->_manPal + 0x270, _vm->_screen->_manPal + 0x270 + 0x60, 0); + } } void Player::calcManScale() { diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 6a241d0c2b..c1a4d9143c 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -43,15 +43,13 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _currentPanel = 0; _hideFlag = true; _loadPalFlag = false; - _leftSkip = _rightSkip = 0; - _topSkip = _bottomSkip = 0; - _clipWidth = _clipHeight = 0; _scrollFlag = false; _scrollThreshold = 0; _startColor = _numColors = 0; _scrollX = _scrollY = 0; _scrollCol = _scrollRow = 0; - + _windowXAdd = _windowYAdd = 0; + _screenYOff = 0; } void Screen::setDisplayScan() { @@ -145,60 +143,6 @@ void Screen::copyBuffer(const byte *data) { g_system->copyRectToScreen(destP, w, 0, 0, w, h); } -void Screen::plotImage(const byte *pData, int idx, const Common::Point &pt) { - const byte *sizeP = pData + READ_LE_UINT16(pData + idx * 4); - int w = READ_LE_UINT16(sizeP); - int h = READ_LE_UINT16(sizeP + 2); - Common::Rect r(pt.x, pt.y, pt.x + w, pt.y + h); - - if (!clip(r)) { - _lastBounds = r; - //plotf(); - } -} - -bool Screen::clip(Common::Rect &r) { - int skip; - _leftSkip = _rightSkip = 0; - _topSkip = _bottomSkip = 0; - - if (r.left > _clipWidth) { - skip = -r.left; - r.setWidth(r.width() - skip); - _leftSkip = skip; - r.moveTo(0, r.top); - } else if (r.left >= 0) - return true; - - int right = r.right - 1; - if (right < 0) - return true; - else if (right > _clipWidth) { - skip = right - _clipWidth; - r.setWidth(r.width() - skip); - _rightSkip = skip; - } - - if (r.top > _clipHeight) { - skip = -r.top; - r.setHeight(r.height() - skip); - _topSkip = skip; - r.moveTo(r.left, 0); - } else if (r.top >= 0) - return true; - - int bottom = r.bottom - 1; - if (bottom < 0) - return true; - else if (bottom > _clipHeight) { - skip = bottom - _clipHeight; - _bottomSkip = skip; - r.setHeight(r.height() - skip); - } - - return false; -} - void Screen::checkScroll() { warning("TODO"); } @@ -227,10 +171,6 @@ void Screen::setBufferScan() { warning("TODO: setBufferScan"); } -void Screen::restoreScan() { - warning("TODO: restoreScan"); -} - void Screen::setScaleTable(int scale) { int total = 0; for (int idx = 0; idx < 256; ++idx) { @@ -241,7 +181,31 @@ void Screen::setScaleTable(int scale) { } void Screen::saveScreen() { - warning("TODO: saveScreen"); + _screenSave._clipWidth = _clipWidth; + _screenSave._clipHeight = _clipHeight; + _screenSave._windowXAdd = _windowXAdd; + _screenSave._windowYAdd = _windowYAdd; + _screenSave._scroll.x = _scrollX; + _screenSave._scroll.y = _scrollY; + _screenSave._scrollCol = _scrollCol; + _screenSave._scrollRow = _scrollRow; + _screenSave._bufferStart.x = _bufferStart.x; + _screenSave._bufferStart.y = _bufferStart.y; + _screenSave._screenYOff = _screenYOff; +} + +void Screen::restoreScreen() { + _clipWidth = _screenSave._clipWidth; + _clipHeight = _screenSave._clipHeight; + _windowXAdd = _screenSave._windowXAdd; + _windowYAdd = _screenSave._windowYAdd; + _scrollX = _screenSave._scroll.x; + _scrollY = _screenSave._scroll.y; + _scrollCol = _screenSave._scrollCol; + _scrollRow = _screenSave._scrollRow; + _bufferStart.x = _screenSave._bufferStart.x; + _bufferStart.y = _screenSave._bufferStart.y; + _screenYOff = _screenSave._screenYOff; } } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index a2eac29312..8dc56d273c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -35,6 +35,18 @@ class AccessEngine; #define PALETTE_COUNT 256 #define PALETTE_SIZE (256 * 3) +struct ScreenSave { + int _clipWidth; + int _clipHeight; + int _windowXAdd; + int _windowYAdd; + Common::Point _scroll; + int _scrollCol; + int _scrollRow; + Common::Point _bufferStart; + int _screenYOff; +}; + class Screen: public ASurface { private: AccessEngine *_vm; @@ -45,14 +57,9 @@ private: Common::Point _msVirtualOffset; Common::Point _virtualOffsetsTable[4]; bool _hideFlag; - Common::Rect _lastBounds; - int _leftSkip, _rightSkip; - int _topSkip, _bottomSkip; - int _clipWidth, _clipHeight; + ScreenSave _screenSave; void updatePalette(); - - bool clip(Common::Rect &r); public: int _vesaMode; bool _loadPalFlag; @@ -60,8 +67,11 @@ public: int _scrollThreshold; int _startColor, _numColors; Common::Point _vWindowSize; + Common::Point _bufferStart; int _scrollX, _scrollY; int _scrollCol, _scrollRow; + int _windowXAdd, _windowYAdd; + int _screenYOff; byte _manPal[0x60]; byte _scaleTable1[256]; byte _scaleTable2[256]; @@ -70,8 +80,6 @@ public: void setDisplayScan(); - void restoreScan(); - void setPanel(int num); /** @@ -109,8 +117,6 @@ public: */ void copyBuffer(const byte *data); - void plotImage(const byte *pData, int idx, const Common::Point &pt); - void checkScroll(); void copyBF1BF2(); @@ -127,7 +133,15 @@ public: void setScaleTable(int scale); + /** + * Save all the screen display state variables + */ void saveScreen(); + + /** + * Restores previously saved screen display state variables + */ + void restoreScreen(); }; } // End of namespace Access -- cgit v1.2.3 From 00f7a3404db0598429f6c733a15d766675624b36 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Aug 2014 17:49:44 +0200 Subject: ACCESS: Implement 3 more opcodes --- engines/access/access.cpp | 1 + engines/access/access.h | 1 + engines/access/scripts.cpp | 29 ++++++++++++++++++++++++----- engines/access/scripts.h | 6 +++--- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d0bc1a8846..dc9bf527eb 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -44,6 +44,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _sound = nullptr; _destIn = nullptr; + _current = nullptr; clearCellTable(); _pCount = 0; _selectCommand = 0; diff --git a/engines/access/access.h b/engines/access/access.h index c93a1b32e5..0733ab4bef 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -115,6 +115,7 @@ public: SoundManager *_sound; ASurface *_destIn; + ASurface *_current; ASurface _buffer1; ASurface _buffer2; byte *_objectsTable[100]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index fe53c675c2..2a825212fd 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -90,11 +90,11 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, - &Scripts::CMDRETNEG, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, + &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, - &Scripts::CMDPLOTIMAGE, &Scripts::CMDSETDISPLAY, &Scripts::CMDSETBUFFER, + &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, @@ -233,7 +233,11 @@ void Scripts::cmdCheckAnim() { } void Scripts::CMDSND() { } -void Scripts::CMDRETNEG() { } + +void Scripts::cmdRetNeg() { + _endFlag = true; + _returnCode = -1; +} void Scripts::cmdCheckLoc() { int minX = _data->readUint16LE(); @@ -262,8 +266,23 @@ void Scripts::CMDCHECKTIMER() { } void Scripts::CMDSETTRAVEL() { } void Scripts::CMDSETVID() { } void Scripts::CMDPLAYVID() { } -void Scripts::CMDPLOTIMAGE() { } -void Scripts::CMDSETDISPLAY() { } + +void Scripts::cmdPlotImage() { + _vm->_destIn = _vm->_current; + + int destX = _data->readUint16LE(); + int destY = _data->readUint16LE(); + int objId = _data->readUint16LE(); + int imgId = _data->readUint16LE(); + + _vm->_screen->plotImage(_vm->_objectsTable[objId], imgId, Common::Point(destX, destY)); +} + +void Scripts::cmdSetDisplay() { + _vm->_screen->setDisplayScan(); + _vm->_current = _vm->_screen; +} + void Scripts::CMDSETBUFFER() { } void Scripts::CMDSETSCROLL() { } void Scripts::CMDSAVERECT() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 79ae478cc9..0bdc746d78 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -69,7 +69,7 @@ protected: void CMDCHECKFRAME(); void cmdCheckAnim(); void CMDSND(); - void CMDRETNEG(); + void cmdRetNeg(); void cmdCheckLoc(); void cmdSetAnim(); void CMDDISPINV(); @@ -78,8 +78,8 @@ protected: void CMDSETTRAVEL(); void CMDSETVID(); void CMDPLAYVID(); - void CMDPLOTIMAGE(); - void CMDSETDISPLAY(); + void cmdPlotImage(); + void cmdSetDisplay(); void CMDSETBUFFER(); void CMDSETSCROLL(); void CMDSAVERECT(); -- cgit v1.2.3 From ba1f8b2f6bf7362d011d01aa7106e5bd6d38366d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 10 Aug 2014 17:52:34 +0200 Subject: ACCESS: Fix typo in variable name --- engines/access/access.cpp | 2 +- engines/access/access.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index dc9bf527eb..d194d8497f 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -94,7 +94,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _ask = 0; _rScrollRow = 0; _rScrollCol = 0; - _rSrcollX = 0; + _rScrollX = 0; _rScrollY = 0; _rOldRectCount = 0; _rNewRectCount = 0; diff --git a/engines/access/access.h b/engines/access/access.h index 0733ab4bef..873eb3d0f7 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -174,7 +174,7 @@ public: int _ask; int _rScrollRow; int _rScrollCol; - int _rSrcollX; + int _rScrollX; int _rScrollY; int _rOldRectCount; int _rNewRectCount; -- cgit v1.2.3 From 0e3f9e983d51759e0d6373e95c71b2130e7f181c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 11:56:14 -0400 Subject: ACCESS: Changed _objectsTable from raw data array to SpriteResource array --- engines/access/access.cpp | 10 +++++++--- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 9 +++++---- engines/access/data.cpp | 6 +++++- engines/access/data.h | 4 +++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d194d8497f..27300f86a2 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -192,13 +192,17 @@ int AccessEngine::getRandomNumber(int maxNumber) { void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { - _objectsTable[cells[i]._cell] = _files->loadFile( - cells[i]._fileNum, cells[i]._subfile); + byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile); + _objectsTable[cells[i]._cell] = new SpriteResource(this, + spriteData, _files->_filesize, DisposeAfterUse::YES); } } void AccessEngine::clearCellTable() { - Common::fill(&_objectsTable[0], &_objectsTable[100], (byte *)nullptr); + for (int i = 0; i < 100; ++i) { + delete _objectsTable[i]; + _objectsTable[i] = nullptr; + } } void AccessEngine::freeCells() { diff --git a/engines/access/access.h b/engines/access/access.h index 873eb3d0f7..5fa0aed1c7 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -118,7 +118,7 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; - byte *_objectsTable[100]; + SpriteResource *_objectsTable[100]; int _establishTable[100]; bool _establishFlag; int _establishMode; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 5c2cda61aa..fe158125b5 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -125,8 +125,9 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); - _objectsTable[0] = _files->loadFile(0, 2); - SpriteResource *spr = new SpriteResource(this, _objectsTable[0], _files->_filesize); + byte *spriteData = _files->loadFile(0, 2); + _objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize, + DisposeAfterUse::YES); _sound->playSound(1); @@ -143,11 +144,11 @@ void AmazonEngine::doTitle() { _buffer2.copyFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); - _screen->plotImage(spr, id, Common::Point(xp, 71)); + _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); } // TODO: More to do - delete spr; + delete _objectsTable[0]; } void AmazonEngine::doOpening() { diff --git a/engines/access/data.cpp b/engines/access/data.cpp index ed913c9be9..3203020322 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -28,7 +28,8 @@ namespace Access { -SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) { +SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory) { Common::MemoryReadStream stream(data, size); Common::Array offsets; int count = stream.readUint16LE(); @@ -52,6 +53,9 @@ SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size) _frames.push_back(frame); } + + if (disposeMemory == DisposeAfterUse::YES) + delete[] data; } SpriteResource::~SpriteResource() { diff --git a/engines/access/data.h b/engines/access/data.h index bd1e1563fc..bb5ef90e55 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/rect.h" +#include "common/types.h" #include "graphics/surface.h" namespace Access { @@ -71,7 +72,8 @@ class SpriteResource { public: Common::Array _frames; public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size); + SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); ~SpriteResource(); int getCount() { return _frames.size(); } -- cgit v1.2.3 From 47d75ae128d2b29ace73925373901cf7bbc6325d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 15:50:22 -0400 Subject: ACCESS: Beginnings of logic for drawing sprite frames --- engines/access/access.cpp | 1 + engines/access/asurface.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- engines/access/asurface.h | 5 ++++- engines/access/screen.cpp | 1 - engines/access/screen.h | 1 - 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 27300f86a2..f625fa096a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -148,6 +148,7 @@ void AccessEngine::initialize() { } // Create sub-objects of the engine + ASurface::init(); _animation = new AnimationManager(this); _debugger = new Debugger(this); _events = new EventsManager(this); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 0fb8f7d43a..438bfbf852 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -38,6 +38,17 @@ int ASurface::_lastBoundsX; int ASurface::_lastBoundsY; int ASurface::_lastBoundsW; int ASurface::_lastBoundsH; +int ASurface::_scrollX; +int ASurface::_scrollY; + +void ASurface::init() { + _leftSkip = _rightSkip = 0; + _topSkip = _bottomSkip = 0; + _clipWidth = _clipHeight = 0; + _lastBoundsX = _lastBoundsY = 0; + _lastBoundsW = _lastBoundsH = 0; + _scrollX = _scrollY = 0; +} void ASurface::clearBuffer() { byte *pSrc = (byte *)getPixels(); @@ -98,12 +109,41 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi _lastBoundsW = r.width(); _lastBoundsH = r.height(); -// plotImage(frame, , ) + plotFrame(frame, pt); } } -void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { +void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { + byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y); + byte *srcP = frame->_data; + + int8 leftVal1 = 18; + int8 leftVal2 = -8; + if (_leftSkip) { + ++leftVal2; + leftVal1 = -12; + } + int8 rightVal = (_rightSkip) ? -7 : -8; + // Skip over any lines of the frame + for (int yp = 0; yp < _topSkip; ++yp) { + srcP += *(srcP + 1) + 2; + } + + byte *srcLineP = srcP; + byte *destLineP = destP; + for (int yp = 0; yp < frame->h; ++yp, srcP = srcLineP, destP = destLineP) { + // Get length of line + int v = *srcP++; + int len = *srcP++; + srcLineP = srcP + len; + destLineP = destP + this->pitch; + + // Draw the line of the frame + if (v != 0 || len != 0) { + warning("TODO: Line draw"); + } + } } } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 7d1ee6c57a..d1e6b64a9e 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -38,8 +38,11 @@ public: static int _clipWidth, _clipHeight; static int _lastBoundsX, _lastBoundsY; static int _lastBoundsW, _lastBoundsH; + static int _scrollX, _scrollY; + + static void init(); protected: - virtual void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt); + virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt); public: void clearBuffer(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index c1a4d9143c..63fd98b566 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -46,7 +46,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _scrollFlag = false; _scrollThreshold = 0; _startColor = _numColors = 0; - _scrollX = _scrollY = 0; _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; diff --git a/engines/access/screen.h b/engines/access/screen.h index 8dc56d273c..f32761347b 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -68,7 +68,6 @@ public: int _startColor, _numColors; Common::Point _vWindowSize; Common::Point _bufferStart; - int _scrollX, _scrollY; int _scrollCol, _scrollRow; int _windowXAdd, _windowYAdd; int _screenYOff; -- cgit v1.2.3 From 6801cb0855cef796ea22c969c9c9f25866cdfa72 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 16:55:06 -0400 Subject: ACCESS: Decompress sprite resource frames immediately on creation --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_room.cpp | 2 +- engines/access/asurface.cpp | 58 +++++++++++++++++++++++++++++++++++ engines/access/asurface.h | 20 ++++++++++++ engines/access/data.cpp | 42 ------------------------- engines/access/data.h | 22 ------------- 6 files changed, 80 insertions(+), 66 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f625fa096a..2f505c2ffa 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -45,7 +45,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _destIn = nullptr; _current = nullptr; - clearCellTable(); _pCount = 0; _selectCommand = 0; _normalMouse = true; @@ -82,6 +81,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _intTim[3] = 0; _timer[3] = 0; _timerFlag = false; + Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); Common::fill(&_establishTable[0], &_establishTable[100], 0); Common::fill(&_flags[0], &_flags[256], 0); _establishFlag = false; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 056fa8f1eb..5b840afc2e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -123,7 +123,7 @@ void AmazonRoom::roomSet() { void AmazonRoom::roomMenu() { byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, _icon, _vm->_files->_filesize); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); delete[] iconData; _vm->_screen->saveScreen(); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 438bfbf852..a9d97aa48c 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -21,10 +21,64 @@ */ #include "common/algorithm.h" +#include "common/endian.h" +#include "common/memstream.h" +#include "access/access.h" #include "access/asurface.h" namespace Access { +SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory) { + Common::MemoryReadStream stream(data, size); + Common::Array offsets; + int count = stream.readUint16LE(); + + for (int i = 0; i < count; i++) + offsets.push_back(stream.readUint32LE()); + offsets.push_back(size); // For easier calculations of Noctropolis sizes + + // Build up the frames + for (int i = 0; i < count; ++i) { + stream.seek(offsets[i]); + int frameSize = offsets[i + 1] - offsets[i]; + + SpriteFrame *frame = new SpriteFrame(vm, stream, frameSize); + _frames.push_back(frame); + } + + if (disposeMemory == DisposeAfterUse::YES) + delete[] data; +} + +SpriteResource::~SpriteResource() { + for (uint i = 0; i < _frames.size(); ++i) + delete _frames[i]; +} + +SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) { + int w = stream.readUint16LE(); + int h = stream.readUint16LE(); + create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + + // Empty surface + byte *data = (byte *)getPixels(); + Common::fill(data, data + w * h, 0); + + // Decode the data + for (int y = 0; y < h; ++y) { + int offset = stream.readByte(); + int len = stream.readByte(); + assert((offset + len) <= w); + + byte *destP = (byte *)getBasePtr(offset, y); + stream.read(destP, len); + } +} + +SpriteFrame::~SpriteFrame() { + free(); +} /*------------------------------------------------------------------------*/ @@ -114,6 +168,9 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { + return; + +/* byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y); byte *srcP = frame->_data; @@ -144,6 +201,7 @@ void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { warning("TODO: Line draw"); } } + */ } } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index d1e6b64a9e..d726e6aeae 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -25,12 +25,32 @@ #include "common/scummsys.h" #include "common/array.h" +#include "common/memstream.h" #include "common/rect.h" #include "graphics/surface.h" #include "access/data.h" namespace Access { +class SpriteFrame : public Graphics::Surface { +public: + SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize); + ~SpriteFrame(); +}; + +class SpriteResource { +public: + Common::Array _frames; +public: + SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); + ~SpriteResource(); + + int getCount() { return _frames.size(); } + + SpriteFrame *getFrame(int idx) { return _frames[idx]; } +}; + class ASurface : public Graphics::Surface { public: static int _leftSkip, _rightSkip; diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 3203020322..c3a6bb3d90 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -21,50 +21,8 @@ */ #include "common/algorithm.h" -#include "common/endian.h" -#include "common/memstream.h" -#include "access/access.h" #include "access/data.h" namespace Access { -SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory) { - Common::MemoryReadStream stream(data, size); - Common::Array offsets; - int count = stream.readUint16LE(); - - for (int i = 0; i < count; i++) - offsets.push_back(stream.readUint32LE()); - offsets.push_back(size); // For easier calculations of Noctropolis sizes - - // Build up the frames - for (int i = 0; i < count; ++i) { - stream.seek(offsets[i]); - - SpriteFrame *frame = new SpriteFrame(); - frame->_width = stream.readUint16LE(); - frame->_height = stream.readUint16LE(); - frame->_size = (vm->getGameID() == GType_MeanStreets) ? stream.readUint16LE() : - offsets[i + 1] - offsets[i]; - - frame->_data = new byte[frame->_size]; - stream.read(frame->_data, frame->_size); - - _frames.push_back(frame); - } - - if (disposeMemory == DisposeAfterUse::YES) - delete[] data; -} - -SpriteResource::~SpriteResource() { - for (uint i = 0; i < _frames.size(); ++i) - delete _frames[i]; -} - -SpriteFrame::~SpriteFrame() { - delete[] _data; -} - } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index bb5ef90e55..b9da858216 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -59,28 +59,6 @@ public: int _vidSTable1; }; -class SpriteFrame : public Graphics::Surface { -public: - uint16 _width, _height; - byte *_data; - uint32 _size; - - ~SpriteFrame(); -}; - -class SpriteResource { -public: - Common::Array _frames; -public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); - ~SpriteResource(); - - int getCount() { return _frames.size(); } - - SpriteFrame *getFrame(int idx) { return _frames[idx]; } -}; - } // End of namespace Access #endif /* ACCESS_DATA_H */ -- cgit v1.2.3 From b2596cab0edc0a4709fba872ca0c20a782caabe4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 18:36:34 -0400 Subject: ACCESS: Implement loadPlayField --- engines/access/access.cpp | 6 ---- engines/access/access.h | 2 -- engines/access/room.cpp | 92 +++++++++++++++++++++++++++++++++++++++++------ engines/access/room.h | 16 ++++++++- engines/access/screen.cpp | 6 +++- engines/access/screen.h | 3 +- 6 files changed, 103 insertions(+), 22 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2f505c2ffa..a21a97c0b0 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -247,10 +247,4 @@ void AccessEngine::doEstablish(int v) { warning("TODO: doEstablish"); } -void AccessEngine::loadPlayField(int fileNum, int subfile) { - // TODO -} - - - } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 5fa0aed1c7..26ae88e6fb 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -226,8 +226,6 @@ public: void establish(int v); void establishCenter(int v); - - void loadPlayField(int fileNum, int subfile); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e0acf1c32a..6f449268c6 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -35,7 +35,13 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _function = 0; _roomFlag = 0; _playField = nullptr; + _playFieldWidth = _playFieldHeight = 0; + _matrixSize = 0; _tile = nullptr; + _vWindowWidth = _vWindowHeight = 0; + _vWindowBytesWide = 0; + _bufferBytesWide = 0; + _vWindowLinesTall = 0; } Room::~Room() { @@ -181,7 +187,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; if (roomInfo._playFieldFile._fileNum != -1) { - _vm->loadPlayField(roomInfo._playFieldFile._fileNum, + loadPlayField(roomInfo._playFieldFile._fileNum, roomInfo._playFieldFile._subfile); setupRoom(); @@ -243,23 +249,23 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vm->_screen->_vWindowSize.x == _playFieldSize.x) { + if (_vWindowWidth == _playFieldWidth) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - (_vm->_player->_rawPlayer.x >> 4); int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vm->_screen->_vWindowSize.x / 2), 0); + (_vWindowWidth / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vm->_screen->_vWindowSize.x - _playFieldSize.x; + xp = xp + _vWindowWidth - _playFieldWidth; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vm->_screen->_vWindowSize.y == _playFieldSize.y) { + if (_vWindowHeight == _playFieldHeight) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; } @@ -267,10 +273,10 @@ void Room::setupRoom() { _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vm->_screen->_vWindowSize.y / 2), 0); + (_vWindowHeight / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vm->_screen->_vWindowSize.y - _playFieldSize.y; + yp = yp + _vWindowHeight - _playFieldHeight; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -287,7 +293,7 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vm->_screen->_vWindowSize.x + 1; + int cnt = _vWindowWidth + 1; int offset = 0; for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { @@ -301,15 +307,15 @@ void Room::buildScreen() { void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * - _playFieldSize.x + playX; + _playFieldWidth + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); - for (int y = 0; y <= _vm->_screen->_vWindowSize.y; ++y) { + for (int y = 0; y <= _vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vm->_screen->_vWindowSize.x; + pDest += _vWindowWidth; } } } @@ -318,6 +324,70 @@ void Room::init4Quads() { error("TODO: init4Quads"); } +void Room::loadPlayField(int fileNum, int subfile) { + byte *playData = _vm->_files->loadFile(fileNum, subfile); + Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + + // Copy the new palette + _vm->_screen->loadRawPalette(&stream); + + // Copy off the tile data + _tileSize = playData[2] << 8; + _tile = new byte[_tileSize]; + stream.read(_tile, _tileSize); + + // Copy off the playfield data + _matrixSize = playData[0] * playData[1]; + _playField = new byte[_matrixSize]; + stream.read(_playField, _matrixSize); + + // Load the plotter data + int numWalls = READ_LE_UINT16(playData + 6); + int numBlocks = playData[8]; + _plotter.load(&stream, numWalls, numBlocks); + + _vWindowWidth = playData[3]; + _vWindowBytesWide = _vWindowWidth << 4; + _bufferBytesWide = _vWindowBytesWide + 16; + _vWindowHeight = playData[4]; + _vWindowLinesTall = _vWindowHeight << 4; + + _vm->_screen->setBufferScan(); + delete[] playData; +} + +/*------------------------------------------------------------------------*/ + +Plotter::Plotter() { + _delta = _blockIn = 0; +} + +void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) { + // Load the wall count + _walls.resize(wallCount); + + for (int i = 0; i < wallCount; ++i) + _walls[i].left = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].top = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].right = stream->readSint16LE(); + for (int i = 0; i < wallCount; ++i) + _walls[i].bottom = stream->readSint16LE(); + + // Load the block list + _blocks.resize(blockCount); + + for (int i = 0; i < blockCount; ++i) + _blocks[i].left = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].top = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].right = stream->readSint16LE(); + for (int i = 0; i < blockCount; ++i) + _blocks[i].bottom = stream->readSint16LE(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { diff --git a/engines/access/room.h b/engines/access/room.h index 72963371d6..0c19308469 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -36,6 +36,10 @@ public: Common::Array _blocks; int _blockIn; int _delta; +public: + Plotter(); + + void load(Common::SeekableReadStream *stream, int wallCount, int blockCount); }; class JetFrame { @@ -54,6 +58,8 @@ public: class Room: public Manager { private: void roomLoop(); + + void loadPlayField(int fileNum, int subfile); protected: void loadRoomData(const byte *roomData); void setupRoom(); @@ -86,8 +92,16 @@ public: int _function; int _roomFlag; byte *_playField; - Common::Point _playFieldSize; + int _matrixSize; + int _playFieldWidth; + int _playFieldHeight; byte *_tile; + int _tileSize; + int _vWindowWidth; + int _vWindowHeight; + int _vWindowBytesWide; + int _bufferBytesWide; + int _vWindowLinesTall; public: Room(AccessEngine *vm); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 63fd98b566..b2cb7da8cc 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -73,7 +73,7 @@ void Screen::setInitialPalettte() { } void Screen::loadPalette(Common::SeekableReadStream *stream) { - stream->read(&_rawPalette[0], PALETTE_SIZE); + loadRawPalette(stream); setPalette(); _loadPalFlag = true; } @@ -88,6 +88,10 @@ void Screen::setPalette() { g_system->getPaletteManager()->setPalette(&_rawPalette[0], 0, PALETTE_COUNT); } +void Screen::loadRawPalette(Common::SeekableReadStream *stream) { + stream->read(&_rawPalette[0], PALETTE_SIZE); +} + void Screen::updatePalette() { g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT); updateScreen(); diff --git a/engines/access/screen.h b/engines/access/screen.h index f32761347b..45db7d0fb1 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -66,7 +66,6 @@ public: bool _scrollFlag; int _scrollThreshold; int _startColor, _numColors; - Common::Point _vWindowSize; Common::Point _bufferStart; int _scrollCol, _scrollRow; int _windowXAdd, _windowYAdd; @@ -111,6 +110,8 @@ public: void setPalette(); + void loadRawPalette(Common::SeekableReadStream *stream); + /** * Copy a buffer to the screen */ -- cgit v1.2.3 From 6f2bc7fc1f5426a01d196e5a61faafbb7b40ad13 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Aug 2014 00:52:03 +0200 Subject: ACCESS: Implement 2 opcodes --- engines/access/scripts.cpp | 24 +++++++++++++++++++----- engines/access/scripts.h | 4 ++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2a825212fd..a6ecfa3eff 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -92,10 +92,10 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, - &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::CMDSETTRAVEL, - &Scripts::CMDSETTRAVEL, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, + &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, + &Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, - &Scripts::CMDSETSCROLL, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, + &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, @@ -263,7 +263,14 @@ void Scripts::cmdSetAnim() { void Scripts::CMDDISPINV() { } void Scripts::CMDSETTIMER() { } void Scripts::CMDCHECKTIMER() { } -void Scripts::CMDSETTRAVEL() { } + +void Scripts::cmdSetTravel() { + if (_vm->_selectCommand == 5) + cmdGoto(); + else + _data->skip(2); +} + void Scripts::CMDSETVID() { } void Scripts::CMDPLAYVID() { } @@ -284,7 +291,14 @@ void Scripts::cmdSetDisplay() { } void Scripts::CMDSETBUFFER() { } -void Scripts::CMDSETSCROLL() { } + +void Scripts::cmdSetScroll() { + _vm->_screen->_scrollCol = _data->readUint16LE(); + _vm->_screen->_scrollRow = _data->readUint16LE(); + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollY = 0; +} + void Scripts::CMDSAVERECT() { } void Scripts::CMDSETBUFVID() { } void Scripts::CMDPLAYBUFVID() { } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 0bdc746d78..3173c8a587 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -75,13 +75,13 @@ protected: void CMDDISPINV(); void CMDSETTIMER(); void CMDCHECKTIMER(); - void CMDSETTRAVEL(); + void cmdSetTravel(); void CMDSETVID(); void CMDPLAYVID(); void cmdPlotImage(); void cmdSetDisplay(); void CMDSETBUFFER(); - void CMDSETSCROLL(); + void cmdSetScroll(); void CMDSAVERECT(); void CMDSETBUFVID(); void CMDPLAYBUFVID(); -- cgit v1.2.3 From e833ae66e2a90e539ad004983acbdae2e4ee94f3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 19:19:32 -0400 Subject: ACCESS: Fix loop in buildScreen --- engines/access/asurface.cpp | 18 +++++++++++++++++- engines/access/asurface.h | 42 ++++++++++++++++++++++++------------------ engines/access/room.cpp | 2 +- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index a9d97aa48c..3a381a10e5 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -168,7 +168,10 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { - return; + frame->copyTo(this, pt); +// g_system->copyRectToScreen((byte *)getPixels(), 320, 0, 0, 320, 200); +// g_system->updateScreen(); + /* byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y); @@ -204,4 +207,17 @@ void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { */ } +void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { + for (int yp = 0; yp < h; ++yp) { + byte *srcP = (byte *)getBasePtr(0, yp); + byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp); + + for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) { + if (*srcP != 0) + *destP = *srcP; + } + } +} + + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index d726e6aeae..c4dfc5442d 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -32,24 +32,8 @@ namespace Access { -class SpriteFrame : public Graphics::Surface { -public: - SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize); - ~SpriteFrame(); -}; - -class SpriteResource { -public: - Common::Array _frames; -public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); - ~SpriteResource(); - - int getCount() { return _frames.size(); } - - SpriteFrame *getFrame(int idx) { return _frames[idx]; } -}; +class SpriteResource; +class SpriteFrame; class ASurface : public Graphics::Surface { public: @@ -71,8 +55,30 @@ public: bool clip(Common::Rect &r); void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); + + void copyTo(ASurface *dest, const Common::Point &destPos); }; +class SpriteFrame : public ASurface { +public: + SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize); + ~SpriteFrame(); +}; + +class SpriteResource { +public: + Common::Array _frames; +public: + SpriteResource(AccessEngine *vm, const byte *data, uint32 size, + DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); + ~SpriteResource(); + + int getCount() { return _frames.size(); } + + SpriteFrame *getFrame(int idx) { return _frames[idx]; } +}; + + } // End of namespace Access #endif /* ACCESS_ASURFACE_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 6f449268c6..371b714467 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -296,7 +296,7 @@ void Room::buildScreen() { int cnt = _vWindowWidth + 1; int offset = 0; - for (int idx = 0; idx < cnt, offset += TILE_WIDTH; ++idx) { + for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; } -- cgit v1.2.3 From b6c946003198d84112e87cc2974eac6e9dc7c4f4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 19:42:33 -0400 Subject: ACCESS: Fix palette translation during loading --- engines/access/screen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index b2cb7da8cc..bc913c5e78 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -32,6 +32,8 @@ namespace Access { +#define VGA_COLOR_TRANS(x) ((x) * 255 / 63) + Screen::Screen(AccessEngine *vm) : _vm(vm) { create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); @@ -90,6 +92,8 @@ void Screen::setPalette() { void Screen::loadRawPalette(Common::SeekableReadStream *stream) { stream->read(&_rawPalette[0], PALETTE_SIZE); + for (byte *p = &_rawPalette[0]; p < &_rawPalette[PALETTE_SIZE]; ++p) + *p = VGA_COLOR_TRANS(*p); } void Screen::updatePalette() { -- cgit v1.2.3 From 69ecc15c028208f6b0f28d6df4d86d1a8ba7e26a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 22:25:30 -0400 Subject: ACCESS: Add decoding of animation resources --- engines/access/animation.cpp | 129 +++++++++++++++++++++++++++++++++++++++---- engines/access/animation.h | 53 ++++++++++++++++-- engines/access/room.cpp | 8 ++- engines/access/scripts.cpp | 91 +++++++++++++++--------------- engines/access/scripts.h | 2 +- 5 files changed, 219 insertions(+), 64 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 4d73801e5d..0d8589d4f1 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -21,24 +21,123 @@ */ #include "common/endian.h" +#include "common/memstream.h" #include "access/animation.h" namespace Access { +AnimationResource::AnimationResource(const byte *data, int size) { + Common::MemoryReadStream stream(data, size); + int count = stream.readUint16LE(); + + Common::Array offsets; + for (int i = 0; i < count; ++i) + offsets.push_back(stream.readUint32LE()); + + _animations.reserve(count); + for (int i = 0; i < count; ++i) { + stream.seek(offsets[i]); + Animation *anim = new Animation(stream); + _animations.push_back(anim); + } +} + +AnimationResource::~AnimationResource() { + for (int i = 0; i < (int)_animations.size(); ++i) + delete _animations[i]; +} + +/*------------------------------------------------------------------------*/ + +Animation::Animation(Common::MemoryReadStream &stream) { + uint32 startOfs = stream.pos(); + + _type = stream.readByte(); + _scaling = stream.readByte(); + stream.readByte(); // unk + _frameNumber = stream.readByte(); + _initialTicks = stream.readUint16LE(); + stream.readUint16LE(); // unk + stream.readUint16LE(); // unk + _loopCount = stream.readUint16LE(); + _countdownTicks = stream.readUint16LE(); + _currentLoopCount = stream.readUint16LE(); + stream.readUint16LE(); // unk + + Common::Array frameOffsets; + uint16 ofs; + while ((ofs = stream.readUint16LE()) != 0) + frameOffsets.push_back(ofs); + + for (int i = 0; i < (int)frameOffsets.size(); i++) { + stream.seek(startOfs + frameOffsets[i]); + + AnimationFrame *frame = new AnimationFrame(stream, startOfs); + _frames.push_back(frame); + } +} + +Animation::~Animation() { + for (int i = 0; i < (int)_frames.size(); ++i) + delete _frames[i]; +} + +void Animation::animate() { + error("TODO"); +} + +/*------------------------------------------------------------------------*/ + +AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) { + uint16 nextOffset; + + stream.readByte(); // unk + _baseX = stream.readUint16LE(); + _baseY = stream.readUint16LE(); + _frameDelay = stream.readUint16LE(); + nextOffset = stream.readUint16LE(); + + while (nextOffset != 0) { + stream.seek(startOffset + nextOffset); + + AnimationFramePart *framePart = new AnimationFramePart(stream); + _parts.push_back(framePart); + + nextOffset = stream.readUint16LE(); + } +} + +AnimationFrame::~AnimationFrame() { + for (int i = 0; i < (int)_parts.size(); ++i) + delete _parts[i]; +} + +/*------------------------------------------------------------------------*/ + +AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { + _flags = stream.readByte(); + _slotIndex = stream.readByte(); + _spriteIndex = stream.readByte(); + _position.x = stream.readUint16LE(); + _position.y = stream.readUint16LE(); + _priority = stream.readUint16LE(); +} + +/*------------------------------------------------------------------------*/ + AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) { - _anim = nullptr; _animation = nullptr; + _animStart = nullptr; } AnimationManager::~AnimationManager() { - delete[] _anim; delete _animation; } void AnimationManager::freeAnimationData() { - delete[] _anim; - _anim = nullptr; + delete _animation; _animation = nullptr; + _animStart = nullptr; } void AnimationManager::clearTimers() { @@ -48,10 +147,17 @@ void AnimationManager::clearTimers() { _animationTimers.clear(); } +void AnimationManager::loadAnimations(const byte *data, int size) { + _animationTimers.clear(); + delete _animation; + _animation = new AnimationResource(data, size); +} + + Animation *AnimationManager::setAnimation(int animId) { Animation *anim = findAnimation(animId); - anim->_countdownTicks = anim->_ticks; + anim->_countdownTicks = anim->_initialTicks; anim->_frameNumber = 0; anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : @@ -62,18 +168,17 @@ Animation *AnimationManager::setAnimation(int animId) { } void AnimationManager::setAnimTimer(Animation *anim) { - + _animationTimers.push_back(anim); } Animation *AnimationManager::findAnimation(int animId) { - _animation = new Animation(_anim + READ_LE_UINT16(_anim + animId * 4 + 2)); - return _animation; + _animStart = _animation->getAnimation(animId); + return _animStart; } -/*------------------------------------------------------------------------*/ - -Animation::Animation(const byte *data) { - +void AnimationManager::animate(int animId) { + Animation *anim = findAnimation(animId); + anim->animate(); } } // End of namespace Access diff --git a/engines/access/animation.h b/engines/access/animation.h index 879d1e9318..45a59efb68 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -25,41 +25,86 @@ #include "common/scummsys.h" #include "common/array.h" +#include "common/memstream.h" #include "access/data.h" namespace Access { +class AnimationResource; class Animation; +class AnimationFrame; +class AnimationFramePart; class AnimationManager : public Manager { public: - const byte *_anim; - Animation *_animation; Common::Array _animationTimers; + AnimationResource *_animation; + Animation *_animStart; public: AnimationManager(AccessEngine *vm); ~AnimationManager(); void freeAnimationData(); + void loadAnimations(const byte *data, int size); + void clearTimers(); Animation *findAnimation(int animId); Animation *setAnimation(int animId); void setAnimTimer(Animation *anim); + + void animate(int animId); +}; + +class AnimationResource { +private: + Common::Array _animations; +public: + AnimationResource(const byte *data, int size); + ~AnimationResource(); + + int getCount() { return _animations.size(); } + Animation *getAnimation(int idx) { return _animations[idx]; } }; class Animation { +private: + Common::Array _frames; public: int _type; int _scaling; int _frameNumber; - int _ticks; + int _initialTicks; int _loopCount; int _countdownTicks; int _currentLoopCount; int _field10; public: - Animation(const byte *data); + Animation(Common::MemoryReadStream &stream); + ~Animation(); + + void animate(); +}; + +class AnimationFrame { +public: + int _baseX, _baseY; + int _frameDelay; + Common::Array _parts; +public: + AnimationFrame(Common::MemoryReadStream &stream, int startOffset); + ~AnimationFrame(); +}; + +class AnimationFramePart { +public: + byte _flags; + int _slotIndex; + int _spriteIndex; + Common::Point _position; + int _priority; +public: + AnimationFramePart(Common::MemoryReadStream &stream); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 371b714467..98e9d5ed6f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -207,9 +207,11 @@ void Room::loadRoomData(const byte *roomData) { // Load animation data _vm->_animation->freeAnimationData(); - if (roomInfo._animFile._fileNum != -1) - _vm->_animation->_anim = _vm->_files->loadFile(roomInfo._animFile._fileNum, - roomInfo._animFile._subfile); + if (roomInfo._animFile._fileNum != -1) { + byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum, + roomInfo._animFile._subfile); + _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + } _vm->_scaleI = roomInfo._scaleI; _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index a6ecfa3eff..fd42530eb9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -85,7 +85,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, - &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::CMDANIM, + &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, @@ -114,9 +114,9 @@ void Scripts::executeCommand(int commandIndex) { (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::CMDOBJECT() { } +void Scripts::CMDOBJECT() { error("TODO"); } -void Scripts::CMDENDOBJECT() { } +void Scripts::CMDENDOBJECT() { error("TODO"); } void Scripts::cmdJumpLook() { if (_vm->_selectCommand == 0) @@ -163,14 +163,17 @@ void Scripts::cmdJumpTalk() { void Scripts::cmdNull() { } -void Scripts::CMDPRINT() { } +void Scripts::CMDPRINT() { error("TODO"); } void Scripts::cmdRetPos() { _endFlag = true; _returnCode = 0; } -void Scripts::CMDANIM() { } +void Scripts::cmdAnim() { + int animId = _data->readUint16LE(); + _vm->_animation->animate(animId); +} void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); @@ -216,10 +219,10 @@ void Scripts::cmdCheckInventory() { _data->skip(2); } -void Scripts::CMDSETTEX() { } -void Scripts::CMDNEWROOM() { } -void Scripts::CMDCONVERSE() { } -void Scripts::CMDCHECKFRAME() { } +void Scripts::CMDSETTEX() { error("TODO"); } +void Scripts::CMDNEWROOM() { error("TODO"); } +void Scripts::CMDCONVERSE() { error("TODO"); } +void Scripts::CMDCHECKFRAME() { error("TODO"); } void Scripts::cmdCheckAnim() { int id = _data->readUint16LE(); @@ -232,7 +235,7 @@ void Scripts::cmdCheckAnim() { _data->skip(4); } -void Scripts::CMDSND() { } +void Scripts::CMDSND() { error("TODO"); } void Scripts::cmdRetNeg() { _endFlag = true; @@ -260,9 +263,9 @@ void Scripts::cmdSetAnim() { _vm->_animation->setAnimTimer(anim); } -void Scripts::CMDDISPINV() { } -void Scripts::CMDSETTIMER() { } -void Scripts::CMDCHECKTIMER() { } +void Scripts::CMDDISPINV() { error("TODO"); } +void Scripts::CMDSETTIMER() { error("TODO"); } +void Scripts::CMDCHECKTIMER() { error("TODO"); } void Scripts::cmdSetTravel() { if (_vm->_selectCommand == 5) @@ -271,8 +274,8 @@ void Scripts::cmdSetTravel() { _data->skip(2); } -void Scripts::CMDSETVID() { } -void Scripts::CMDPLAYVID() { } +void Scripts::CMDSETVID() { error("TODO"); } +void Scripts::CMDPLAYVID() { error("TODO"); } void Scripts::cmdPlotImage() { _vm->_destIn = _vm->_current; @@ -290,7 +293,7 @@ void Scripts::cmdSetDisplay() { _vm->_current = _vm->_screen; } -void Scripts::CMDSETBUFFER() { } +void Scripts::CMDSETBUFFER() { error("TODO"); } void Scripts::cmdSetScroll() { _vm->_screen->_scrollCol = _data->readUint16LE(); @@ -299,31 +302,31 @@ void Scripts::cmdSetScroll() { _vm->_screen->_scrollY = 0; } -void Scripts::CMDSAVERECT() { } -void Scripts::CMDSETBUFVID() { } -void Scripts::CMDPLAYBUFVID() { } +void Scripts::CMDSAVERECT() { error("TODO"); } +void Scripts::CMDSETBUFVID() { error("TODO"); } +void Scripts::CMDPLAYBUFVID() { error("TODO"); } void Scripts::cmeRemoveLast() { --_vm->_numAnimTimers; } -void Scripts::CMDSPECIAL() { } -void Scripts::CMDSETCYCLE() { } -void Scripts::CMDCYCLE() { } -void Scripts::CMDCHARSPEAK() { } -void Scripts::CMDTEXSPEAK() { } -void Scripts::CMDTEXCHOICE() { } -void Scripts::CMDWAIT() { } -void Scripts::CMDSETCONPOS() { } -void Scripts::CMDCHECKVFRAME() { } -void Scripts::CMDJUMPCHOICE() { } -void Scripts::CMDRETURNCHOICE() { } -void Scripts::CMDCLEARBLOCK() { } -void Scripts::CMDLOADSOUND() { } -void Scripts::CMDFREESOUND() { } -void Scripts::CMDSETVIDSND() { } -void Scripts::CMDPLAYVIDSND() { } -void Scripts::CMDPUSHLOCATION() { } +void Scripts::CMDSPECIAL() { error("TODO"); } +void Scripts::CMDSETCYCLE() { error("TODO"); } +void Scripts::CMDCYCLE() { error("TODO"); } +void Scripts::CMDCHARSPEAK() { error("TODO"); } +void Scripts::CMDTEXSPEAK() { error("TODO"); } +void Scripts::CMDTEXCHOICE() { error("TODO"); } +void Scripts::CMDWAIT() { error("TODO"); } +void Scripts::CMDSETCONPOS() { error("TODO"); } +void Scripts::CMDCHECKVFRAME() { error("TODO"); } +void Scripts::CMDJUMPCHOICE() { error("TODO"); } +void Scripts::CMDRETURNCHOICE() { error("TODO"); } +void Scripts::CMDCLEARBLOCK() { error("TODO"); } +void Scripts::CMDLOADSOUND() { error("TODO"); } +void Scripts::CMDFREESOUND() { error("TODO"); } +void Scripts::CMDSETVIDSND() { error("TODO"); } +void Scripts::CMDPLAYVIDSND() { error("TODO"); } +void Scripts::CMDPUSHLOCATION() { error("TODO"); } void Scripts::cmdPlayerOff() { _vm->_player->_playerOff = true; @@ -333,18 +336,18 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::CMDDEAD() { } +void Scripts::CMDDEAD() { error("TODO"); } void Scripts::cmdFadeOut() { _vm->_screen->forceFadeOut(); } -void Scripts::CMDENDVID() { } -void Scripts::CMDHELP() { } -void Scripts::CMDCYCLEBACK() { } -void Scripts::CMDCHAPTER() { } -void Scripts::CMDSETHELP() { } -void Scripts::CMDCENTERPANEL() { } +void Scripts::CMDENDVID() { error("TODO"); } +void Scripts::CMDHELP() { error("TODO"); } +void Scripts::CMDCYCLEBACK() { error("TODO"); } +void Scripts::CMDCHAPTER() { error("TODO"); } +void Scripts::CMDSETHELP() { error("TODO"); } +void Scripts::CMDCENTERPANEL() { error("TODO"); } void Scripts::cmdMainPanel() { if (_vm->_screen->_vesaMode) { @@ -353,7 +356,7 @@ void Scripts::cmdMainPanel() { } } -void Scripts::CMDRETFLASH() { } +void Scripts::CMDRETFLASH() { error("TODO"); } } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 3173c8a587..c8f951deae 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -52,7 +52,7 @@ protected: void cmdNull(); void CMDPRINT(); void cmdRetPos(); - void CMDANIM(); + void cmdAnim(); void cmdSetFlag(); void cmdCheckFlag(); -- cgit v1.2.3 From a0b9afded37693673485549d41d3b3513bcb2dab Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 10 Aug 2014 23:17:53 -0400 Subject: ACCESS: Implemented animation anim methods --- engines/access/animation.cpp | 143 +++++++++++++++++++++++++++++++++++++++++-- engines/access/animation.h | 22 +++++-- engines/access/scripts.cpp | 2 +- 3 files changed, 158 insertions(+), 9 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 0d8589d4f1..705fd7bf8f 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -22,11 +22,12 @@ #include "common/endian.h" #include "common/memstream.h" +#include "access/access.h" #include "access/animation.h" namespace Access { -AnimationResource::AnimationResource(const byte *data, int size) { +AnimationResource::AnimationResource(AccessEngine *vm, const byte *data, int size) { Common::MemoryReadStream stream(data, size); int count = stream.readUint16LE(); @@ -37,7 +38,7 @@ AnimationResource::AnimationResource(const byte *data, int size) { _animations.reserve(count); for (int i = 0; i < count; ++i) { stream.seek(offsets[i]); - Animation *anim = new Animation(stream); + Animation *anim = new Animation(vm, stream); _animations.push_back(anim); } } @@ -49,7 +50,8 @@ AnimationResource::~AnimationResource() { /*------------------------------------------------------------------------*/ -Animation::Animation(Common::MemoryReadStream &stream) { +Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream): + Manager(vm) { uint32 startOfs = stream.pos(); _type = stream.readByte(); @@ -82,10 +84,143 @@ Animation::~Animation() { delete _frames[i]; } +typedef void(Animation::*AnimationMethodPtr)(); + void Animation::animate() { + static const AnimationMethodPtr METHODS[8] = + { &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, + &Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 }; + + (this->*METHODS[_type])(); +} + +void Animation::anim0() { + if (_currentLoopCount != -1) { + if (_countdownTicks != 0) { + calcFrame(); + setFrame1(); + } else { + _countdownTicks = _initialTicks; + ++_frameNumber; + calcFrame(); + + if (this == _vm->_animation->_animStart) { + _frameNumber = 0; + _currentLoopCount = -1; + } + + setFrame(); + } + } +} + +void Animation::anim1() { + if (_currentLoopCount == -1 || _countdownTicks != 0) { + calcFrame(); + setFrame1(); + } else { + _countdownTicks = _initialTicks; + ++_frameNumber; + calcFrame(); + + if (this == _vm->_animation->_animStart) { + --_frameNumber; + _currentLoopCount = -1; + } + + setFrame(); + } +} + +void Animation::anim2() { + if (_countdownTicks != 0) { + calcFrame(); + setFrame1(); + } else { + _countdownTicks = _initialTicks; + ++_frameNumber; + calcFrame(); + + if (this == _vm->_animation->_animStart) { + _frameNumber = 0; + calcFrame(); + } + + setFrame(); + } +} + +void Animation::anim3() { + if (_currentLoopCount != -1) { + if (_countdownTicks != 0) { + calcFrame(); + setFrame1(); + } else { + _countdownTicks = _initialTicks; + ++_frameNumber; + calcFrame(); + + if (this == _vm->_animation->_animStart) { + --_currentLoopCount; + _frameNumber = 0; + calcFrame(); + } + + setFrame(); + } + } +} + +void Animation::anim4() { + if (_currentLoopCount == -1 || _countdownTicks != 0) { + calcFrame(); + setFrame1(); + } else { + _countdownTicks = _initialTicks; + ++_frameNumber; + calcFrame(); + + if (this == _vm->_animation->_animStart) { + if (--_currentLoopCount == -1) { + calcFrame(); + setFrame1(); + return; + } else { + _frameNumber = 0; + calcFrame(); + } + } + + setFrame(); + } +} + +void Animation::animNone() { + // No implementation +} + +void Animation::anim7() { + calcFrame1(); + setFrame(); +} + +void Animation::calcFrame() { + error("TODO"); +} + +void Animation::calcFrame1() { + error("TODO"); +} + +void Animation::setFrame() { error("TODO"); } +void Animation::setFrame1() { + error("TODO"); +} + + /*------------------------------------------------------------------------*/ AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) { @@ -150,7 +285,7 @@ void AnimationManager::clearTimers() { void AnimationManager::loadAnimations(const byte *data, int size) { _animationTimers.clear(); delete _animation; - _animation = new AnimationResource(data, size); + _animation = new AnimationResource(_vm, data, size); } diff --git a/engines/access/animation.h b/engines/access/animation.h index 45a59efb68..38065bb4c9 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -36,9 +36,10 @@ class AnimationFrame; class AnimationFramePart; class AnimationManager : public Manager { -public: +private: Common::Array _animationTimers; AnimationResource *_animation; +public: Animation *_animStart; public: AnimationManager(AccessEngine *vm); @@ -60,16 +61,29 @@ class AnimationResource { private: Common::Array _animations; public: - AnimationResource(const byte *data, int size); + AnimationResource(AccessEngine *vm, const byte *data, int size); ~AnimationResource(); int getCount() { return _animations.size(); } Animation *getAnimation(int idx) { return _animations[idx]; } }; -class Animation { +class Animation: public Manager { private: Common::Array _frames; + + void anim0(); + void anim1(); + void anim2(); + void anim3(); + void anim4(); + void animNone(); + void anim7(); + + void calcFrame(); + void calcFrame1(); + void setFrame(); + void setFrame1(); public: int _type; int _scaling; @@ -80,7 +94,7 @@ public: int _currentLoopCount; int _field10; public: - Animation(Common::MemoryReadStream &stream); + Animation(AccessEngine *vm, Common::MemoryReadStream &stream); ~Animation(); void animate(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index fd42530eb9..8018f503a3 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -171,7 +171,7 @@ void Scripts::cmdRetPos() { } void Scripts::cmdAnim() { - int animId = _data->readUint16LE(); + int animId = _data->readByte(); _vm->_animation->animate(animId); } -- cgit v1.2.3 From 5344143027b87fa38203dbdd97f2f6fd68a566b2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Aug 2014 23:03:49 +0200 Subject: ACCESS: Implement cmdCheckFrame --- engines/access/scripts.cpp | 14 ++++++++++++-- engines/access/scripts.h | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 8018f503a3..aa1bfcd71c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -89,7 +89,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, - &Scripts::CMDCHECKFRAME, &Scripts::cmdCheckAnim, &Scripts::CMDSND, + &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::CMDSND, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, @@ -222,7 +222,17 @@ void Scripts::cmdCheckInventory() { void Scripts::CMDSETTEX() { error("TODO"); } void Scripts::CMDNEWROOM() { error("TODO"); } void Scripts::CMDCONVERSE() { error("TODO"); } -void Scripts::CMDCHECKFRAME() { error("TODO"); } + +void Scripts::cmdCheckFrame() { + int id = _data->readUint16LE(); + Animation *anim = _vm->_animation->findAnimation(id); + + int frame = _data->readUint16LE(); + if (anim->_frameNumber == frame) + cmdGoto(); + else + _data->skip(2); +} void Scripts::cmdCheckAnim() { int id = _data->readUint16LE(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index c8f951deae..3832f0d0e1 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -66,7 +66,7 @@ protected: void CMDSETTEX(); void CMDNEWROOM(); void CMDCONVERSE(); - void CMDCHECKFRAME(); + void cmdCheckFrame(); void cmdCheckAnim(); void CMDSND(); void cmdRetNeg(); -- cgit v1.2.3 From 69c7f989b12de26ada8d399233e95777421ee65b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Aug 2014 23:05:48 +0200 Subject: ACCESS: Fix the implementation of cmdCheckAnim --- engines/access/scripts.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index aa1bfcd71c..e7827fba01 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -238,11 +238,10 @@ void Scripts::cmdCheckAnim() { int id = _data->readUint16LE(); Animation *anim = _vm->_animation->findAnimation(id); - if (anim->_currentLoopCount == -1) { - _data->skip(2); + if (anim->_currentLoopCount == -1) cmdGoto(); - } else - _data->skip(4); + else + _data->skip(2); } void Scripts::CMDSND() { error("TODO"); } -- cgit v1.2.3 From 5c7699799d4d35ac863470b0ad52817de170f4f9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Aug 2014 23:43:27 +0200 Subject: ACCESS: Implement 3 more opcodes, fix a typo --- engines/access/scripts.cpp | 35 ++++++++++++++++++++++++++--------- engines/access/scripts.h | 10 ++++++---- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index e7827fba01..bb45cd44d2 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -34,6 +34,8 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) { _sequence = 0; _endFlag = false; _returnCode = 0; + _choice = 0; + _choiceStart = 0; } Scripts::~Scripts() { @@ -94,14 +96,14 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, &Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, - &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::CMDSETBUFFER, + &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, - &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmeRemoveLast, + &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, - &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::CMDJUMPCHOICE, - &Scripts::CMDRETURNCHOICE, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, + &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, + &Scripts::cmdReturnChoice, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, @@ -302,7 +304,9 @@ void Scripts::cmdSetDisplay() { _vm->_current = _vm->_screen; } -void Scripts::CMDSETBUFFER() { error("TODO"); } +void Scripts::cmdSetBuffer() { + _vm->_current = &_vm->_buffer2; +} void Scripts::cmdSetScroll() { _vm->_screen->_scrollCol = _data->readUint16LE(); @@ -315,7 +319,7 @@ void Scripts::CMDSAVERECT() { error("TODO"); } void Scripts::CMDSETBUFVID() { error("TODO"); } void Scripts::CMDPLAYBUFVID() { error("TODO"); } -void Scripts::cmeRemoveLast() { +void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; } @@ -324,12 +328,25 @@ void Scripts::CMDSETCYCLE() { error("TODO"); } void Scripts::CMDCYCLE() { error("TODO"); } void Scripts::CMDCHARSPEAK() { error("TODO"); } void Scripts::CMDTEXSPEAK() { error("TODO"); } -void Scripts::CMDTEXCHOICE() { error("TODO"); } +void Scripts::CMDTEXCHOICE() { error("TODO"); } // _choiceStart = _data->pos() - 1; void Scripts::CMDWAIT() { error("TODO"); } void Scripts::CMDSETCONPOS() { error("TODO"); } void Scripts::CMDCHECKVFRAME() { error("TODO"); } -void Scripts::CMDJUMPCHOICE() { error("TODO"); } -void Scripts::CMDRETURNCHOICE() { error("TODO"); } + +void Scripts::cmdJumpChoice() { + int val = (_data->readUint16LE() && 0xFF); + + if (val == _choice) { + _sequence = _data->readUint16LE(); + searchForSequence(); + } else + _data->skip(2); +} + +void Scripts::cmdReturnChoice() { + _data->seek(_choiceStart); +} + void Scripts::CMDCLEARBLOCK() { error("TODO"); } void Scripts::CMDLOADSOUND() { error("TODO"); } void Scripts::CMDFREESOUND() { error("TODO"); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 3832f0d0e1..25f4dc192d 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -80,12 +80,12 @@ protected: void CMDPLAYVID(); void cmdPlotImage(); void cmdSetDisplay(); - void CMDSETBUFFER(); + void cmdSetBuffer(); void cmdSetScroll(); void CMDSAVERECT(); void CMDSETBUFVID(); void CMDPLAYBUFVID(); - void cmeRemoveLast(); + void cmdRemoveLast(); void CMDSPECIAL(); void CMDSETCYCLE(); void CMDCYCLE(); @@ -95,8 +95,8 @@ protected: void CMDWAIT(); void CMDSETCONPOS(); void CMDCHECKVFRAME(); - void CMDJUMPCHOICE(); - void CMDRETURNCHOICE(); + void cmdJumpChoice(); + void cmdReturnChoice(); void CMDCLEARBLOCK(); void CMDLOADSOUND(); void CMDFREESOUND(); @@ -120,6 +120,8 @@ public: bool _endFlag; int _returnCode; int _scriptCommand; + int _choice; + int32 _choiceStart; public: Scripts(AccessEngine *vm); -- cgit v1.2.3 From 617aa98ede4167fe2f9a7a419738d0030d8c48ff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 11 Aug 2014 23:57:06 +0200 Subject: ACCESS: Implement cmdSnd() --- engines/access/scripts.cpp | 7 +++++-- engines/access/scripts.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bb45cd44d2..19633544f4 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -91,7 +91,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, - &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::CMDSND, + &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, @@ -246,7 +246,10 @@ void Scripts::cmdCheckAnim() { _data->skip(2); } -void Scripts::CMDSND() { error("TODO"); } +void Scripts::cmdSnd() { + int id = _data->readByte(); + _vm->_sound->playSound(id); +} void Scripts::cmdRetNeg() { _endFlag = true; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 25f4dc192d..495c4c5f9f 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -68,7 +68,7 @@ protected: void CMDCONVERSE(); void cmdCheckFrame(); void cmdCheckAnim(); - void CMDSND(); + void cmdSnd(); void cmdRetNeg(); void cmdCheckLoc(); void cmdSetAnim(); -- cgit v1.2.3 From 768e144683847734cc16c9a7ec786379be6301e2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Aug 2014 20:27:19 -0400 Subject: ACCESS: Properly implement Animation calcFrame/calcFrame1 methods --- engines/access/animation.cpp | 69 ++++++++++++++++++++------------------------ engines/access/animation.h | 8 ++--- 2 files changed, 35 insertions(+), 42 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 705fd7bf8f..6c9f300931 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -97,101 +97,95 @@ void Animation::animate() { void Animation::anim0() { if (_currentLoopCount != -1) { if (_countdownTicks != 0) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); } else { _countdownTicks = _initialTicks; ++_frameNumber; - calcFrame(); + AnimationFrame *frame = calcFrame(); - if (this == _vm->_animation->_animStart) { + if (frame == nullptr) { _frameNumber = 0; _currentLoopCount = -1; } - setFrame(); + setFrame(frame); } } } void Animation::anim1() { if (_currentLoopCount == -1 || _countdownTicks != 0) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); } else { _countdownTicks = _initialTicks; ++_frameNumber; - calcFrame(); + AnimationFrame *frame = calcFrame(); - if (this == _vm->_animation->_animStart) { + if (frame == nullptr) { --_frameNumber; _currentLoopCount = -1; } - setFrame(); + setFrame(frame); } } void Animation::anim2() { if (_countdownTicks != 0) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); } else { _countdownTicks = _initialTicks; ++_frameNumber; - calcFrame(); + AnimationFrame *frame = calcFrame(); - if (this == _vm->_animation->_animStart) { + if (frame == nullptr) { _frameNumber = 0; - calcFrame(); + frame = calcFrame(); } - setFrame(); + setFrame(frame); } } void Animation::anim3() { if (_currentLoopCount != -1) { if (_countdownTicks != 0) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); } else { _countdownTicks = _initialTicks; ++_frameNumber; - calcFrame(); + AnimationFrame *frame = calcFrame(); - if (this == _vm->_animation->_animStart) { + if (frame == nullptr) { --_currentLoopCount; _frameNumber = 0; - calcFrame(); + frame = calcFrame(); } - setFrame(); + setFrame(frame); } } } void Animation::anim4() { if (_currentLoopCount == -1 || _countdownTicks != 0) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); } else { _countdownTicks = _initialTicks; ++_frameNumber; - calcFrame(); + AnimationFrame *frame = calcFrame(); - if (this == _vm->_animation->_animStart) { + if (frame == nullptr) { if (--_currentLoopCount == -1) { - calcFrame(); - setFrame1(); + setFrame1(calcFrame()); return; } else { _frameNumber = 0; - calcFrame(); + frame = calcFrame(); } } - setFrame(); + setFrame(frame); } } @@ -200,23 +194,22 @@ void Animation::animNone() { } void Animation::anim7() { - calcFrame1(); - setFrame(); + setFrame(calcFrame1()); } -void Animation::calcFrame() { - error("TODO"); +AnimationFrame *Animation::calcFrame() { + return _frames[_frameNumber]; } -void Animation::calcFrame1() { - error("TODO"); +AnimationFrame *Animation::calcFrame1() { + return _frames[0]; } -void Animation::setFrame() { +void Animation::setFrame(AnimationFrame *frame) { error("TODO"); } -void Animation::setFrame1() { +void Animation::setFrame1(AnimationFrame *frame) { error("TODO"); } diff --git a/engines/access/animation.h b/engines/access/animation.h index 38065bb4c9..d9b10085ce 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -80,10 +80,10 @@ private: void animNone(); void anim7(); - void calcFrame(); - void calcFrame1(); - void setFrame(); - void setFrame1(); + AnimationFrame *calcFrame(); + AnimationFrame *calcFrame1(); + void setFrame(AnimationFrame *frame); + void setFrame1(AnimationFrame *frame); public: int _type; int _scaling; -- cgit v1.2.3 From 7d4180c3e2b70ab3efa8d82f071e427a71adb1f0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Aug 2014 21:34:39 -0400 Subject: ACCESS: Implemented Animation setFrame code --- engines/access/access.h | 10 ++++++++++ engines/access/animation.cpp | 44 ++++++++++++++++++++++++++++++++++++-------- engines/access/animation.h | 6 ++++-- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 26ae88e6fb..f84a7bd1ca 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -70,6 +70,15 @@ enum AccessDebugChannels { struct AccessGameDescription; +class ImageEntry { +public: + int _field0; + SpriteResource *_spritesPtr; + int _priority; + Common::Point _position; + int _flags; +}; + class AccessEngine : public Engine { private: /** @@ -128,6 +137,7 @@ public: Common::Array _newRect; Common::Array _oldRect; Common::Array _extraCells; + Common::Array _images; int _pCount; int _selectCommand; bool _normalMouse; diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 6c9f300931..a17c30f495 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -55,15 +55,15 @@ Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream): uint32 startOfs = stream.pos(); _type = stream.readByte(); - _scaling = stream.readByte(); + _scaling = stream.readSByte(); stream.readByte(); // unk _frameNumber = stream.readByte(); _initialTicks = stream.readUint16LE(); stream.readUint16LE(); // unk stream.readUint16LE(); // unk - _loopCount = stream.readUint16LE(); + _loopCount = stream.readSint16LE(); _countdownTicks = stream.readUint16LE(); - _currentLoopCount = stream.readUint16LE(); + _currentLoopCount = stream.readSint16LE(); stream.readUint16LE(); // unk Common::Array frameOffsets; @@ -206,13 +206,39 @@ AnimationFrame *Animation::calcFrame1() { } void Animation::setFrame(AnimationFrame *frame) { - error("TODO"); + _countdownTicks += frame->_frameDelay; + setFrame1(frame); } -void Animation::setFrame1(AnimationFrame *frame) { - error("TODO"); +static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { + return ie1._priority < ie2._priority; } +void Animation::setFrame1(AnimationFrame *frame) { + _vm->_animation->_base.x = frame->_baseX; + _vm->_animation->_base.y = frame->_baseY; + + // Loop to add image draw requests for the parts of the frame + for (uint i = 0; i < frame->_parts.size(); ++i) { + AnimationFramePart *part = frame->_parts[i]; + ImageEntry ie; + + // Set the flags + ie._flags = part->_flags & 0xF7; + if (_vm->_animation->_frameScale == -1) + ie._flags |= 8; + + // Set the other fields + ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex]; + ie._field0 = part->_frameIndex; + ie._position = part->_position + _vm->_animation->_base; + ie._priority = part->_priority - ie._position.y; + + assert(_vm->_images.size() < 35); + _vm->_images.push_back(ie); + Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY); + } +} /*------------------------------------------------------------------------*/ @@ -244,8 +270,8 @@ AnimationFrame::~AnimationFrame() { AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { _flags = stream.readByte(); - _slotIndex = stream.readByte(); - _spriteIndex = stream.readByte(); + _spritesIndex = stream.readByte(); + _frameIndex = stream.readByte(); _position.x = stream.readUint16LE(); _position.y = stream.readUint16LE(); _priority = stream.readUint16LE(); @@ -256,6 +282,7 @@ AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { AnimationManager::AnimationManager(AccessEngine *vm) : Manager(vm) { _animation = nullptr; _animStart = nullptr; + _frameScale = 0; } AnimationManager::~AnimationManager() { @@ -306,6 +333,7 @@ Animation *AnimationManager::findAnimation(int animId) { void AnimationManager::animate(int animId) { Animation *anim = findAnimation(animId); + _frameScale = anim->_scaling; anim->animate(); } diff --git a/engines/access/animation.h b/engines/access/animation.h index d9b10085ce..c1b44a5621 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -41,6 +41,8 @@ private: AnimationResource *_animation; public: Animation *_animStart; + Common::Point _base; + int _frameScale; public: AnimationManager(AccessEngine *vm); ~AnimationManager(); @@ -113,8 +115,8 @@ public: class AnimationFramePart { public: byte _flags; - int _slotIndex; - int _spriteIndex; + int _spritesIndex; + int _frameIndex; Common::Point _position; int _priority; public: -- cgit v1.2.3 From eee84b8760dd38079fe97f263a6fa9361ad5696f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 11 Aug 2014 23:12:53 -0400 Subject: ACCESS: Implemented plotList --- engines/access/access.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++ engines/access/access.h | 6 +++++- engines/access/animation.cpp | 2 +- engines/access/asurface.cpp | 11 ++++++++++ engines/access/asurface.h | 8 ++++++- engines/access/player.cpp | 8 +++++++ engines/access/player.h | 2 ++ engines/access/room.cpp | 4 ++-- engines/access/screen.cpp | 4 ---- engines/access/screen.h | 2 -- 10 files changed, 87 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a21a97c0b0..9fb0287883 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -73,6 +73,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleT1 = 0; _scaleMaxY = 0; _scaleI = 0; + _scaleFlag = false; _conversation = 0; _currentMan = 0; @@ -247,4 +248,54 @@ void AccessEngine::doEstablish(int v) { warning("TODO: doEstablish"); } +void AccessEngine::plotList() { + _player->calcPlayer(); + plotList1(); +} + +void AccessEngine::plotList1() { + for (uint idx = 0; idx < _images.size(); ++idx) { + ImageEntry &ie = _images[idx]; + + _scaleFlag = (ie._flags & 8) != 0; + Common::Point pt = ie._position - _screen->_bufferStart; + SpriteResource *sprites = ie._spritesPtr; + SpriteFrame *frame = sprites->getFrame(ie._frameNumber); + + Common::Rect bounds(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h); + if (!_scaleFlag) { + bounds.setWidth(_screen->_scaleTable1[frame->w]); + bounds.setHeight(_screen->_scaleTable1[frame->h]); + } + + if (_buffer2.clip(bounds)) { + ie._flags |= 1; + } else { + ie._flags &= ~1; + if (_buffer2._leftSkip != 0 || _buffer2._rightSkip != 0 + || _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0) + ie._flags |= 1; + + _newRect.push_back(bounds); + + if (!_scaleFlag) { + _buffer2._rightSkip /= _scale; + bounds.setWidth(bounds.width() / _scale); + + if (ie._flags & 2) { + _buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top)); + } else { + _buffer2.sPlotF(frame, Common::Point(bounds.left, bounds.top)); + } + } else { + if (ie._flags & 2) { + _buffer2.plotB(frame, Common::Point(bounds.left, bounds.top)); + } else { + _buffer2.plotFrame(frame, Common::Point(bounds.left, bounds.top)); + } + } + } + } +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index f84a7bd1ca..819f7faaa7 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -72,7 +72,7 @@ struct AccessGameDescription; class ImageEntry { public: - int _field0; + int _frameNumber; SpriteResource *_spritesPtr; int _priority; Common::Point _position; @@ -166,6 +166,7 @@ public: int _scaleT1; int _scaleMaxY; int _scaleI; + bool _scaleFlag; int _playFieldHeight; // Fields that are included in savegames @@ -236,6 +237,9 @@ public: void establish(int v); void establishCenter(int v); + + void plotList(); + void plotList1(); }; } // End of namespace Access diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index a17c30f495..20772af8f0 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -230,7 +230,7 @@ void Animation::setFrame1(AnimationFrame *frame) { // Set the other fields ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex]; - ie._field0 = part->_frameIndex; + ie._frameNumber = part->_frameIndex; ie._position = part->_position + _vm->_animation->_base; ie._priority = part->_priority - ie._position.y; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 3a381a10e5..fe11612075 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -219,5 +219,16 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { } } +void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) { + error("TODO"); +} + +void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) { + error("TODO"); +} + +void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { + error("TODO"); +} } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index c4dfc5442d..99f99ae696 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -45,7 +45,7 @@ public: static int _scrollX, _scrollY; static void init(); -protected: +public: virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt); public: void clearBuffer(); @@ -56,6 +56,12 @@ public: void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); + void sPlotB(SpriteFrame *frame, const Common::Point &pt); + + void sPlotF(SpriteFrame *frame, const Common::Point &pt); + + void plotB(SpriteFrame *frame, const Common::Point &pt); + void copyTo(ASurface *dest, const Common::Point &destPos); }; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index b28e6c92bc..794fc08fa4 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -151,4 +151,12 @@ void Player::walk() { warning("TODO: Player::walk"); } +void Player::calcPlayer() { + Screen &scr = *_vm->_screen; + scr._bufferStart.x = (scr._scrollCol << 4) + scr._scrollX; + scr._bufferStart.y = (scr._scrollRow << 4) + scr._scrollY; + _playerX = _rawPlayer.x - scr._bufferStart.x; + _playerY = _rawPlayer.y - scr._bufferStart.y; +} + } // End of namespace Access diff --git a/engines/access/player.h b/engines/access/player.h index 7625fa2cc7..b491ed7e85 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -82,6 +82,8 @@ public: void calcManScale(); void walk(); + + void calcPlayer(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 98e9d5ed6f..b39e99815b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -117,7 +117,7 @@ void Room::doRoom() { clearRoom(); break; } else { - _vm->_screen->plotList(); + _vm->plotList(); _vm->_screen->copyRects(); _vm->_screen->copyBF2Vid(); @@ -132,7 +132,7 @@ void Room::doRoom() { clearRoom(); break; } else { - _vm->_screen->plotList(); + _vm->plotList(); _vm->_screen->copyBlocks(); } } diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index bc913c5e78..2dc86982b7 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -162,10 +162,6 @@ void Screen::copyBF2Vid() { warning("TODO"); } -void Screen::plotList() { - warning("TODO: plotList"); -} - void Screen::copyBlocks() { warning("TODO: copyBlocks"); } diff --git a/engines/access/screen.h b/engines/access/screen.h index 45db7d0fb1..6c1d96e360 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -123,8 +123,6 @@ public: void copyBF2Vid(); - void plotList(); - void copyBlocks(); void copyRects(); -- cgit v1.2.3 From c0cb03cea276832b2d178155786c0418eccfd21d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 08:38:12 -0400 Subject: ACCESS: Implemented copyBlocks --- engines/access/access.cpp | 16 +++++++++++++++- engines/access/access.h | 6 ++++-- engines/access/amazon/amazon_room.cpp | 4 ++-- engines/access/asurface.cpp | 11 +++++++++++ engines/access/asurface.h | 2 ++ engines/access/room.cpp | 10 +++++----- engines/access/screen.cpp | 4 ---- engines/access/screen.h | 2 -- 8 files changed, 39 insertions(+), 16 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9fb0287883..29e5188fb3 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -276,7 +276,7 @@ void AccessEngine::plotList1() { || _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0) ie._flags |= 1; - _newRect.push_back(bounds); + _newRects.push_back(bounds); if (!_scaleFlag) { _buffer2._rightSkip /= _scale; @@ -298,4 +298,18 @@ void AccessEngine::plotList1() { } } +void AccessEngine::copyBlocks() { + // Copy the block list from the previous frame + for (uint i = 0; i < _oldRects.size(); ++i) { + _screen->copyBlock(&_buffer2, _oldRects[i]); + } + + // Copy the new block list, replacing the old one at the same time + _oldRects.clear(); + for (uint i = 0; i < _newRects.size(); ++i) { + _screen->copyBlock(&_buffer2, _newRects[i]); + _oldRects.push_back(_newRects[i]); + } +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 819f7faaa7..3cd98f0c45 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -134,8 +134,8 @@ public: int _establishGroup; int _numAnimTimers; Common::Array _timers; - Common::Array _newRect; - Common::Array _oldRect; + Common::Array _newRects; + Common::Array _oldRects; Common::Array _extraCells; Common::Array _images; int _pCount; @@ -240,6 +240,8 @@ public: void plotList(); void plotList1(); + + void copyBlocks(); }; } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 5b840afc2e..b8ed0d20de 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -110,8 +110,8 @@ void AmazonRoom::reloadRoom1() { } _vm->_player->_frame = 0; - _vm->_oldRect.clear(); - _vm->_newRect.clear(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); } void AmazonRoom::roomSet() { diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index fe11612075..5a090afaca 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -231,4 +231,15 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { error("TODO"); } +void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { + byte *srcP = (byte *)getBasePtr(bounds.left, bounds.top + _scrollY); + byte *destP = (byte *)getBasePtr(bounds.left, bounds.top); /* + _windowYAdd */ + + for (int y = 0; y < bounds.height(); ++y) { + Common::copy(srcP, srcP + bounds.width(), destP); + srcP += src->pitch; + destP += this->pitch; + } +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 99f99ae696..776b9506e9 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -62,6 +62,8 @@ public: void plotB(SpriteFrame *frame, const Common::Point &pt); + void copyBlock(ASurface *src, const Common::Rect &bounds); + void copyTo(ASurface *dest, const Common::Point &destPos); }; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b39e99815b..ab3592a247 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -65,8 +65,8 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { if (!reloadFlag) { _vm->_numImages = 0; - _vm->_newRect.clear(); - _vm->_oldRect.clear(); + _vm->_newRects.clear(); + _vm->_oldRects.clear(); _vm->_nextImage = 0; _vm->_numAnimTimers = 0; @@ -109,7 +109,7 @@ void Room::doRoom() { if (_vm->_screen->_scrollFlag) { _vm->_screen->copyBF1BF2(); - _vm->_newRect.clear(); + _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -124,7 +124,7 @@ void Room::doRoom() { } } else { _vm->_screen->copyBF1BF2(); - _vm->_newRect.clear(); + _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -133,7 +133,7 @@ void Room::doRoom() { break; } else { _vm->plotList(); - _vm->_screen->copyBlocks(); + _vm->copyBlocks(); } } } diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 2dc86982b7..b47cd3e005 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -162,10 +162,6 @@ void Screen::copyBF2Vid() { warning("TODO"); } -void Screen::copyBlocks() { - warning("TODO: copyBlocks"); -} - void Screen::copyRects() { warning("TODO: copyRects"); } diff --git a/engines/access/screen.h b/engines/access/screen.h index 6c1d96e360..670da8282d 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -123,8 +123,6 @@ public: void copyBF2Vid(); - void copyBlocks(); - void copyRects(); void setBufferScan(); -- cgit v1.2.3 From 94eda108eb36594329c20ecbc525d9934083e535 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 09:01:29 -0400 Subject: ACCESS: Fix incorrect decrementing of _startup --- engines/access/room.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index ab3592a247..4996527b74 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -80,12 +80,13 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { _vm->_numImages = 0; if (_vm->_startup != -1 && --_vm->_startup != 0) { - --_vm->_startup; _vm->_events->showCursor(); _vm->_screen->fadeIn(); } + // Handle any events _vm->_events->pollEvents(); + _vm->_nextImage = 0; _vm->_player->walk(); _vm->_sound->midiRepeat(); -- cgit v1.2.3 From 9107cc103fa8ca65e12d0213c7b915ec990fb6cf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 09:16:14 -0400 Subject: ACCESS: Added a temporary frame delay and screen update --- engines/access/events.cpp | 8 ++++++++ engines/access/events.h | 2 ++ engines/access/room.cpp | 4 ++++ engines/access/screen.cpp | 2 ++ 4 files changed, 16 insertions(+) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 1184128ffd..73feefee97 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -148,7 +148,15 @@ void EventsManager::checkForNextFrameCounter() { // Signal the ScummVM debugger _vm->_debugger->onFrame(); + + // TODO: Refactor for dirty rects + _vm->_screen->updateScreen(); } } +void EventsManager::delay(int time) { + g_system->delayMillis(time); +} + + } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index 2e6b06b5e2..55f04f17af 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -88,6 +88,8 @@ public: bool isCursorVisible(); void pollEvents(); + + void delay(int time); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 4996527b74..d3f0f8ff06 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -84,6 +84,10 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } + // TODO: Game loop doesn't seem to have any delay. For now, + // introduce a slight delay here + _vm->_events->delay(50); + // Handle any events _vm->_events->pollEvents(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index b47cd3e005..cdd5f2021e 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -64,6 +64,8 @@ void Screen::setPanel(int num) { } void Screen::updateScreen() { + g_system->copyRectToScreen((byte *)getPixels(), this->pitch, 0, 0, + this->w, this->h); g_system->updateScreen(); } -- cgit v1.2.3 From b579dbb71b4aafa533b06589ced928d788a1c2e6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 21:12:11 -0400 Subject: ACCESS: Fixes for clipping --- engines/access/asurface.cpp | 10 ++++++---- engines/access/screen.cpp | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 5a090afaca..ba75607637 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -115,13 +115,14 @@ bool ASurface::clip(Common::Rect &r) { _topSkip = _bottomSkip = 0; if (r.left > _clipWidth) { + if (r.left >= 0) + return true; + skip = -r.left; r.setWidth(r.width() - skip); _leftSkip = skip; r.moveTo(0, r.top); } - else if (r.left >= 0) - return true; int right = r.right - 1; if (right < 0) @@ -133,13 +134,14 @@ bool ASurface::clip(Common::Rect &r) { } if (r.top > _clipHeight) { + if (r.top >= 0) + return true; + skip = -r.top; r.setHeight(r.height() - skip); _topSkip = skip; r.moveTo(r.left, 0); } - else if (r.top >= 0) - return true; int bottom = r.bottom - 1; if (bottom < 0) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index cdd5f2021e..9cefa356ef 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -51,10 +51,18 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; + + setDisplayScan(); } void Screen::setDisplayScan() { - warning("TODO: setDisplayScan"); + _clipWidth = this->w - 1; + _clipHeight = this->h - 1; + _windowXAdd = _windowYAdd = 0; + _scrollX = _scrollY = 0; + _scrollCol = _scrollRow = 0; + _bufferStart.x = _bufferStart.y = 0; + _screenYOff = 0; } void Screen::setPanel(int num) { -- cgit v1.2.3 From 483bc1eb03b54db70d3136f3265fca1989b5b417 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 21:40:14 -0400 Subject: ACCESS: Implemented setBufferScan and copyRects --- engines/access/access.cpp | 5 ++++- engines/access/access.h | 2 ++ engines/access/room.cpp | 3 +-- engines/access/screen.cpp | 9 ++++----- engines/access/screen.h | 2 -- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 29e5188fb3..75a3b8d47b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -304,7 +304,10 @@ void AccessEngine::copyBlocks() { _screen->copyBlock(&_buffer2, _oldRects[i]); } - // Copy the new block list, replacing the old one at the same time + copyRects(); +} + +void AccessEngine::copyRects() { _oldRects.clear(); for (uint i = 0; i < _newRects.size(); ++i) { _screen->copyBlock(&_buffer2, _newRects[i]); diff --git a/engines/access/access.h b/engines/access/access.h index 3cd98f0c45..4efe1b4349 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -242,6 +242,8 @@ public: void plotList1(); void copyBlocks(); + + void copyRects(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d3f0f8ff06..22ced20f08 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -123,8 +123,7 @@ void Room::doRoom() { break; } else { _vm->plotList(); - _vm->_screen->copyRects(); - + _vm->copyRects(); _vm->_screen->copyBF2Vid(); } } else { diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 9cefa356ef..d450cc1067 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -172,12 +172,11 @@ void Screen::copyBF2Vid() { warning("TODO"); } -void Screen::copyRects() { - warning("TODO: copyRects"); -} - void Screen::setBufferScan() { - warning("TODO: setBufferScan"); + _clipWidth = _vm->_room->_vWindowBytesWide - 1; + _windowXAdd = (320 - _clipWidth) >> 1; + _clipHeight = _vm->_room->_vWindowLinesTall - 1; + _windowYAdd = (176 - _clipHeight) >> 1; } void Screen::setScaleTable(int scale) { diff --git a/engines/access/screen.h b/engines/access/screen.h index 670da8282d..875b665c18 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -123,8 +123,6 @@ public: void copyBF2Vid(); - void copyRects(); - void setBufferScan(); void setScaleTable(int scale); -- cgit v1.2.3 From 89772d55a5c97b3c58bdf685e2419e78335ba02d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 12 Aug 2014 23:34:23 -0400 Subject: ACCESS: Implemented window size fields setup and copyBF2Vid --- engines/access/access.cpp | 16 ++++++++++++ engines/access/access.h | 4 +++ engines/access/amazon/amazon_room.cpp | 6 +++-- engines/access/player.cpp | 2 +- engines/access/room.cpp | 46 ++++++++++++++++------------------- engines/access/room.h | 5 ---- engines/access/screen.cpp | 17 +++++-------- engines/access/screen.h | 9 ++++--- 8 files changed, 57 insertions(+), 48 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 75a3b8d47b..9c0df1ac30 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -315,4 +315,20 @@ void AccessEngine::copyRects() { } } +void AccessEngine::copyBF1BF2() { + _buffer2.copyFrom(_buffer1); +} + +void AccessEngine::copyBF2Vid() { + const byte *srcP = (const byte *)_buffer2.getPixels(); + byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd, + _screen->_windowYAdd + _screen->_screenYOff); + + for (int yp = 0; yp < _screen->_vWindowLinesTall; ++yp) { + Common::copy(srcP, srcP + _screen->_vWindowBytesWide, destP); + srcP += _buffer2.pitch; + destP += _screen->pitch; + } +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 4efe1b4349..770bd030ff 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -244,6 +244,10 @@ public: void copyBlocks(); void copyRects(); + + void copyBF1BF2(); + + void copyBF2Vid(); }; } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index b8ed0d20de..db163977ca 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -103,10 +103,12 @@ void AmazonRoom::reloadRoom1() { setWallCodes(); buildScreen(); - if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24 + if (!_vm->_screen->_vesaMode) { + _vm->copyBF2Vid(); + } else if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24 && _vm->_player->_roomNumber != 33) { _vm->_screen->setPalette(); - _vm->_screen->copyBF2Vid(); + _vm->copyBF2Vid(); } _vm->_player->_frame = 0; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 794fc08fa4..969df0025f 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -132,7 +132,7 @@ void Player::load() { if (_vm->_manPal1) { Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); } else { - Common::fill(_vm->_screen->_manPal + 0x270, _vm->_screen->_manPal + 0x270 + 0x60, 0); + Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0); } } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 22ced20f08..c258e076d8 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -38,10 +38,6 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _playFieldWidth = _playFieldHeight = 0; _matrixSize = 0; _tile = nullptr; - _vWindowWidth = _vWindowHeight = 0; - _vWindowBytesWide = 0; - _bufferBytesWide = 0; - _vWindowLinesTall = 0; } Room::~Room() { @@ -113,7 +109,7 @@ void Room::doRoom() { } if (_vm->_screen->_scrollFlag) { - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -124,10 +120,10 @@ void Room::doRoom() { } else { _vm->plotList(); _vm->copyRects(); - _vm->_screen->copyBF2Vid(); + _vm->copyBF2Vid(); } } else { - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; roomLoop(); @@ -255,34 +251,33 @@ void Room::setupRoom() { if (_roomFlag != 2) setIconPalette(); - if (_vWindowWidth == _playFieldWidth) { + if (_vm->_screen->_vWindowWidth == _playFieldWidth) { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - (_vm->_player->_rawPlayer.x >> 4); int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vWindowWidth / 2), 0); + (_vm->_screen->_vWindowWidth / 2), 0); _vm->_screen->_scrollCol = xp; - xp = xp + _vWindowWidth - _playFieldWidth; + xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth; if (xp >= 0) { _vm->_screen->_scrollCol = xp + 1; } } - if (_vWindowHeight == _playFieldHeight) { + if (_vm->_screen->_vWindowHeight == _playFieldHeight) { _vm->_screen->_scrollY = 0; _vm->_screen->_scrollRow = 0; - } - else { + } else { _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vWindowHeight / 2), 0); + (_vm->_screen->_vWindowHeight / 2), 0); _vm->_screen->_scrollRow = yp; - yp = yp + _vWindowHeight - _playFieldHeight; + yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight; if (yp >= 0) { _vm->_screen->_scrollRow = yp + 1; } @@ -299,7 +294,7 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vWindowWidth + 1; + int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { @@ -308,7 +303,7 @@ void Room::buildScreen() { } _vm->_screen->_scrollCol = scrollCol; - _vm->_screen->copyBF1BF2(); + _vm->copyBF1BF2(); } void Room::buildColumn(int playX, int screenX) { @@ -316,12 +311,12 @@ void Room::buildColumn(int playX, int screenX) { _playFieldWidth + playX; byte *pDest = (byte *)_vm->_buffer1.getPixels(); - for (int y = 0; y <= _vWindowHeight; ++y) { + for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vWindowWidth; + pDest += _vm->_screen->_vWindowWidth; } } } @@ -333,9 +328,10 @@ void Room::init4Quads() { void Room::loadPlayField(int fileNum, int subfile) { byte *playData = _vm->_files->loadFile(fileNum, subfile); Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + Screen &screen = *_vm->_screen; // Copy the new palette - _vm->_screen->loadRawPalette(&stream); + screen.loadRawPalette(&stream); // Copy off the tile data _tileSize = playData[2] << 8; @@ -352,11 +348,11 @@ void Room::loadPlayField(int fileNum, int subfile) { int numBlocks = playData[8]; _plotter.load(&stream, numWalls, numBlocks); - _vWindowWidth = playData[3]; - _vWindowBytesWide = _vWindowWidth << 4; - _bufferBytesWide = _vWindowBytesWide + 16; - _vWindowHeight = playData[4]; - _vWindowLinesTall = _vWindowHeight << 4; + screen._vWindowWidth = playData[3]; + screen._vWindowBytesWide = screen._vWindowWidth << 4; + screen._bufferBytesWide = screen._vWindowBytesWide + 16; + screen._vWindowHeight = playData[4]; + screen._vWindowLinesTall = screen._vWindowHeight << 4; _vm->_screen->setBufferScan(); delete[] playData; diff --git a/engines/access/room.h b/engines/access/room.h index 0c19308469..ce3c4dc36e 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -97,11 +97,6 @@ public: int _playFieldHeight; byte *_tile; int _tileSize; - int _vWindowWidth; - int _vWindowHeight; - int _vWindowBytesWide; - int _bufferBytesWide; - int _vWindowLinesTall; public: Room(AccessEngine *vm); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index d450cc1067..6f9b53994d 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -52,7 +52,10 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _windowXAdd = _windowYAdd = 0; _screenYOff = 0; - setDisplayScan(); + _bufferBytesWide = _vWindowBytesWide = this->w; + _vWindowLinesTall = this->h; + _clipWidth = _vWindowBytesWide - 1; + _clipHeight = _vWindowLinesTall - 1; } void Screen::setDisplayScan() { @@ -164,18 +167,10 @@ void Screen::checkScroll() { warning("TODO"); } -void Screen::copyBF1BF2() { - warning("TODO"); -} - -void Screen::copyBF2Vid() { - warning("TODO"); -} - void Screen::setBufferScan() { - _clipWidth = _vm->_room->_vWindowBytesWide - 1; + _clipWidth = _vWindowBytesWide - 1; _windowXAdd = (320 - _clipWidth) >> 1; - _clipHeight = _vm->_room->_vWindowLinesTall - 1; + _clipHeight = _vWindowLinesTall - 1; _windowYAdd = (176 - _clipHeight) >> 1; } diff --git a/engines/access/screen.h b/engines/access/screen.h index 875b665c18..6ede482e61 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -73,6 +73,11 @@ public: byte _manPal[0x60]; byte _scaleTable1[256]; byte _scaleTable2[256]; + int _vWindowWidth; + int _vWindowHeight; + int _vWindowBytesWide; + int _bufferBytesWide; + int _vWindowLinesTall; public: Screen(AccessEngine *vm); @@ -119,10 +124,6 @@ public: void checkScroll(); - void copyBF1BF2(); - - void copyBF2Vid(); - void setBufferScan(); void setScaleTable(int scale); -- cgit v1.2.3 From 146f6b5df40d2800432866389f549838921203d2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 20:56:06 -0400 Subject: ACCESS: Fix rendering of scene background --- engines/access/access.cpp | 7 +++++-- engines/access/room.cpp | 12 +++++++----- engines/access/room.h | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9c0df1ac30..9b10e4f8c3 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -159,7 +159,7 @@ void AccessEngine::initialize() { _screen = new Screen(this); _sound = new SoundManager(this, _mixer); - _buffer1.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); _buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); } @@ -316,7 +316,10 @@ void AccessEngine::copyRects() { } void AccessEngine::copyBF1BF2() { - _buffer2.copyFrom(_buffer1); + _buffer2.copyRectToSurface(_buffer1, 0, 0, + Common::Rect(_buffer1._scrollX, _buffer1._scrollY, + _buffer1._scrollX + _screen->_vWindowBytesWide, + _buffer1._scrollY + _screen->_vWindowLinesTall)); } void AccessEngine::copyBF2Vid() { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c258e076d8..cd39109e63 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -26,9 +26,6 @@ #include "access/resources.h" #include "access/room.h" -#define TILE_WIDTH 16 -#define TILE_HEIGHT 16 - namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { @@ -309,15 +306,18 @@ void Room::buildScreen() { void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; - byte *pDest = (byte *)_vm->_buffer1.getPixels(); for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { byte *pTile = _tile + (*pSrc << 8); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); - pDest += _vm->_screen->_vWindowWidth; + pTile += TILE_WIDTH; + pDest += _vm->_buffer1.pitch; } + + pSrc += _playFieldWidth; } } @@ -348,6 +348,8 @@ void Room::loadPlayField(int fileNum, int subfile) { int numBlocks = playData[8]; _plotter.load(&stream, numWalls, numBlocks); + _playFieldWidth = playData[0]; + _playFieldHeight = playData[1]; screen._vWindowWidth = playData[3]; screen._vWindowBytesWide = screen._vWindowWidth << 4; screen._bufferBytesWide = screen._vWindowBytesWide + 16; diff --git a/engines/access/room.h b/engines/access/room.h index ce3c4dc36e..18637e4283 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -28,6 +28,9 @@ #include "common/rect.h" #include "access/data.h" +#define TILE_WIDTH 16 +#define TILE_HEIGHT 16 + namespace Access { class Plotter { -- cgit v1.2.3 From ed645e435a641cc3be95bfe946d2c08d2ab3836b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 21:07:27 -0400 Subject: ACCESS: Fix clearing pending images list each frame --- engines/access/access.cpp | 2 -- engines/access/access.h | 2 -- engines/access/room.cpp | 6 ++---- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9b10e4f8c3..3a773a94c1 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -60,8 +60,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _converseMode = 0; _startAboutBox = 0; _startTravelBox = 0; - _numImages = 0; - _nextImage = 0; _numAnimTimers = 0; _startup = 0; _currentCharFlag = false; diff --git a/engines/access/access.h b/engines/access/access.h index 770bd030ff..08b5ae3935 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -142,8 +142,6 @@ public: int _selectCommand; bool _normalMouse; int _mouseMode; - int _numImages; - int _nextImage; int _currentManOld; byte *_man; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index cd39109e63..3e9e9e65aa 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -57,10 +57,9 @@ void Room::doRoom() { while (!_vm->shouldQuit()) { if (!reloadFlag) { - _vm->_numImages = 0; + _vm->_images.clear(); _vm->_newRects.clear(); _vm->_oldRects.clear(); - _vm->_nextImage = 0; _vm->_numAnimTimers = 0; reloadRoom(); @@ -71,7 +70,7 @@ void Room::doRoom() { _function = 0; while (!_vm->shouldQuit()) { - _vm->_numImages = 0; + _vm->_images.clear(); if (_vm->_startup != -1 && --_vm->_startup != 0) { _vm->_events->showCursor(); _vm->_screen->fadeIn(); @@ -84,7 +83,6 @@ void Room::doRoom() { // Handle any events _vm->_events->pollEvents(); - _vm->_nextImage = 0; _vm->_player->walk(); _vm->_sound->midiRepeat(); _vm->_screen->checkScroll(); -- cgit v1.2.3 From 28bfe7374930cd78f722451b8754822a11dd500d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 22:23:08 -0400 Subject: ACCESS: Implemented cmdSpecial script opcode --- engines/access/amazon/amazon_scripts.cpp | 5 +++++ engines/access/amazon/amazon_scripts.h | 2 ++ engines/access/screen.cpp | 18 ++++++++++++++++++ engines/access/screen.h | 6 ++++++ engines/access/scripts.cpp | 21 ++++++++++++++++++++- engines/access/scripts.h | 2 ++ 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 1d3e7b4b76..d7e84394b5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -31,6 +31,11 @@ namespace Amazon { AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { } +void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { + warning("TODO"); +} + + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 08fbc3a0f2..b8fdaaa7f3 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -31,6 +31,8 @@ namespace Access { namespace Amazon { class AmazonScripts: public Scripts { +protected: + virtual void executeSpecial(int commandIndex, int param1, int param2); public: AmazonScripts(AccessEngine *vm); }; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 6f9b53994d..4673bb6136 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -40,6 +40,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { Common::fill(&_manPal[0], &_manPal[0x60], 0); Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0); Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0); + _savedPaletteCount = 0; _vesaMode = 0; _vesaCurrentWin = 0; _currentPanel = 0; @@ -114,6 +115,23 @@ void Screen::updatePalette() { updateScreen(); } +void Screen::savePalette() { + Common::copy(&_rawPalette[0], &_rawPalette[PALETTE_SIZE], + &_savedPalettes[_savedPaletteCount][0]); + + if (++_savedPaletteCount == 2) + _savedPaletteCount = 1; +} + +void Screen::restorePalette() { + if (--_savedPaletteCount < 0) + _savedPaletteCount = 0; + + Common::copy(&_savedPalettes[_savedPaletteCount][0], + &_savedPalettes[_savedPaletteCount][PALETTE_SIZE], &_rawPalette[0]); +} + + void Screen::forceFadeOut() { const int FADE_AMOUNT = 2; bool repeatFlag; diff --git a/engines/access/screen.h b/engines/access/screen.h index 6ede482e61..d759ae119e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -52,6 +52,8 @@ private: AccessEngine *_vm; byte _tempPalette[PALETTE_SIZE]; byte _rawPalette[PALETTE_SIZE]; + byte _savedPalettes[2][PALETTE_SIZE]; + int _savedPaletteCount; int _vesaCurrentWin; int _currentPanel; Common::Point _msVirtualOffset; @@ -117,6 +119,10 @@ public: void loadRawPalette(Common::SeekableReadStream *stream); + void savePalette(); + + void restorePalette(); + /** * Copy a buffer to the screen */ diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 19633544f4..0e1d421c34 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -326,7 +326,26 @@ void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; } -void Scripts::CMDSPECIAL() { error("TODO"); } +void Scripts::CMDSPECIAL() { + _specialFunction = _data->readUint16LE(); + int p1 = _data->readUint16LE(); + int p2 = _data->readUint16LE(); + + if (_specialFunction == 1) { + if (_vm->_establishTable[p2] == 1) + return; + + _vm->_screen->savePalette(); + } + + executeSpecial(_specialFunction, p1, p2); + + if (_specialFunction == 1) { + _vm->_screen->restorePalette(); + _vm->_room->_function = 3; + } +} + void Scripts::CMDSETCYCLE() { error("TODO"); } void Scripts::CMDCYCLE() { error("TODO"); } void Scripts::CMDCHARSPEAK() { error("TODO"); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 495c4c5f9f..0916b9e9b1 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -37,9 +37,11 @@ class Scripts { private: const byte *_rawData; Common::MemoryReadStream *_data; + int _specialFunction; protected: AccessEngine *_vm; + virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); void CMDOBJECT(); void CMDENDOBJECT(); -- cgit v1.2.3 From d6404a10adc4a1b6973894291ffbc6d87ac96071 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 22:45:15 -0400 Subject: ACCESS: Fix compiler warnings and deallocation crash on exit --- engines/access/access.cpp | 12 +----------- engines/access/access.h | 9 ++------- engines/access/amazon/amazon_game.cpp | 1 - engines/access/asurface.cpp | 4 ++++ engines/access/asurface.h | 4 +++- engines/access/screen.h | 2 ++ 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 3a773a94c1..2ffc479748 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -114,9 +114,6 @@ AccessEngine::~AccessEngine() { delete _scripts; delete _sound; - _buffer1.free(); - _buffer2.free(); - freeCells(); delete[] _man1; delete[] _inactive; @@ -198,16 +195,9 @@ void AccessEngine::loadCells(Common::Array &cells) { } } -void AccessEngine::clearCellTable() { - for (int i = 0; i < 100; ++i) { - delete _objectsTable[i]; - _objectsTable[i] = nullptr; - } -} - void AccessEngine::freeCells() { for (int i = 0; i < 100; ++i) { - delete[] _objectsTable[i]; + delete _objectsTable[i]; _objectsTable[i] = nullptr; } } diff --git a/engines/access/access.h b/engines/access/access.h index 08b5ae3935..d919ae83f9 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -30,7 +30,7 @@ #include "common/util.h" #include "engines/engine.h" #include "graphics/surface.h" -#include "access\/animation.h" +#include "access/animation.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -213,12 +213,7 @@ public: void loadCells(Common::Array &cells); /** - * Clear the cell table - */ - void clearCellTable(); - - /** - * Free the cell data + * Free the sprites list */ void freeCells(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index fe158125b5..d0a5b6eecc 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -161,7 +161,6 @@ void AmazonEngine::doTent() { void AmazonEngine::setupGame() { _chapter = 1; - clearCellTable(); // Setup timers const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index ba75607637..619c4499e9 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -104,6 +104,10 @@ void ASurface::init() { _scrollX = _scrollY = 0; } +ASurface::~ASurface() { + free(); +} + void ASurface::clearBuffer() { byte *pSrc = (byte *)getPixels(); Common::fill(pSrc, pSrc + w * h, 0); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 776b9506e9..4f172ae309 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -46,8 +46,10 @@ public: static void init(); public: - virtual void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt); + virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); public: + virtual ~ASurface(); + void clearBuffer(); void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } diff --git a/engines/access/screen.h b/engines/access/screen.h index d759ae119e..ba1c22931c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -83,6 +83,8 @@ public: public: Screen(AccessEngine *vm); + virtual ~Screen() {} + void setDisplayScan(); void setPanel(int num); -- cgit v1.2.3 From 79e743ba82b14dce808f3dcda6e173fa6f138137 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 22:54:04 -0400 Subject: ACCESS: Fix more gcc compiler warnings --- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_resources.cpp | 2 +- engines/access/asurface.cpp | 6 +++--- engines/access/decompress.h | 5 ----- engines/access/module.mk | 8 ++++---- engines/access/room.cpp | 2 +- 6 files changed, 10 insertions(+), 15 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d0a5b6eecc..49ae766325 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -140,7 +140,7 @@ void AmazonEngine::doTitle() { _sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (int _pCount = 0; _pCount < 3; ++_pCount) { + for (_pCount = 0; _pCount < 3; ++_pCount) { _buffer2.copyFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 87f2966d8e..15cf190d4a 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -977,7 +977,7 @@ const byte LETTER[] = { 0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF }; -extern const byte *CHARTBL[] = { +const byte *CHARTBL[] = { ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT, BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS, diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 619c4499e9..6df8a4ae3d 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -57,9 +57,9 @@ SpriteResource::~SpriteResource() { } SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) { - int w = stream.readUint16LE(); - int h = stream.readUint16LE(); - create(w, h, Graphics::PixelFormat::createFormatCLUT8()); + int xSize = stream.readUint16LE(); + int ySize = stream.readUint16LE(); + create(xSize, ySize, Graphics::PixelFormat::createFormatCLUT8()); // Empty surface byte *data = (byte *)getPixels(); diff --git a/engines/access/decompress.h b/engines/access/decompress.h index 522bfb2acf..400aee476c 100644 --- a/engines/access/decompress.h +++ b/engines/access/decompress.h @@ -1,8 +1,3 @@ -/* 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. /* ScummVM - Graphic Adventure Engine * * ScummVM is the legal property of its developers, whose names diff --git a/engines/access/module.mk b/engines/access/module.mk index 7c089fefb3..6f906a9c21 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -17,10 +17,10 @@ MODULE_OBJS := \ screen.o \ scripts.o \ sound.o \ - amazon\amazon_game.o \ - amazon\amazon_resources.o \ - amazon\amazon_room.o \ - amazon\amazon_scripts.o + amazon/amazon_game.o \ + amazon/amazon_resources.o \ + amazon/amazon_room.o \ + amazon/amazon_scripts.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3e9e9e65aa..66231e60e1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -445,6 +445,6 @@ RoomInfo::RoomInfo(const byte *data) { _sounds.push_back(fi); } -}; +} } // End of namespace Access -- cgit v1.2.3 From cf901ae142044227f5c34c33ab45eb8a0351ce93 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 13 Aug 2014 23:03:18 -0400 Subject: ACCESS: Give default draw implementations for sprite drawing routines --- engines/access/asurface.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 6df8a4ae3d..5824545af7 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -226,26 +226,19 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { } void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) { - error("TODO"); + frame->copyTo(this, pt); } void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) { - error("TODO"); + frame->copyTo(this, pt); } void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { - error("TODO"); + frame->copyTo(this, pt); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { - byte *srcP = (byte *)getBasePtr(bounds.left, bounds.top + _scrollY); - byte *destP = (byte *)getBasePtr(bounds.left, bounds.top); /* + _windowYAdd */ - - for (int y = 0; y < bounds.height(); ++y) { - Common::copy(srcP, srcP + bounds.width(), destP); - srcP += src->pitch; - destP += this->pitch; - } + copyRectToSurface(*src, bounds.left, bounds.top, bounds); } } // End of namespace Access -- cgit v1.2.3 From f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Aug 2014 20:49:30 -0400 Subject: ACCESS: Implemented player walk methods --- engines/access/events.cpp | 1 + engines/access/events.h | 1 + engines/access/player.cpp | 400 +++++++++++++++++++++++++++++++++++++++++++++- engines/access/player.h | 22 +++ engines/access/screen.cpp | 1 + engines/access/screen.h | 1 + 6 files changed, 425 insertions(+), 1 deletion(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 73feefee97..88e783e6d2 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -39,6 +39,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _frameCounter = 10; _priorFrameTime = 0; _leftButton = false; + _mouseMove = false; } EventsManager::~EventsManager() { diff --git a/engines/access/events.h b/engines/access/events.h index 55f04f17af..aa01543381 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -51,6 +51,7 @@ public: CursorType _cursorId; bool _leftButton; Common::Point _mousePos; + bool _mouseMove; public: /** * Constructor diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 969df0025f..6fab689ee0 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -50,6 +50,9 @@ Player::Player(AccessEngine *vm): Manager(vm) { _upDelta = _downDelta = 0; _scrollConst = 0; _roomNumber = 0; + _collideFlag = false; + _move = NONE; + _playerDirection = NONE; } void Player::load() { @@ -148,7 +151,53 @@ void Player::calcManScale() { } void Player::walk() { - warning("TODO: Player::walk"); + _collideFlag = false; + _playerDirection = NONE; + + if (_playerOff != 0) + return; + else if (_vm->_timerFlag) { + plotCom3(); + return; + } + + switch (_move) { + case UP: + _vm->_events->_mouseMove = false; + walkUp(); + break; + case DOWN: + _vm->_events->_mouseMove = false; + walkDown(); + break; + case LEFT: + _vm->_events->_mouseMove = false; + walkLeft(); + break; + case RIGHT: + _vm->_events->_mouseMove = false; + walkRight(); + break; + case UPLEFT: + _vm->_events->_mouseMove = false; + walkUpLeft(); + break; + case DOWNLEFT: + _vm->_events->_mouseMove = false; + walkDownLeft(); + break; + case UPRIGHT: + _vm->_events->_mouseMove = false; + walkUpRight(); + break; + case DOWNRIGHT: + _vm->_events->_mouseMove = false; + walkDownRight(); + break; + default: + checkMove(); + break; + } } void Player::calcPlayer() { @@ -159,4 +208,353 @@ void Player::calcPlayer() { _playerY = _rawPlayer.y - scr._bufferStart.y; } +void Player::walkUp() { + if (_frame > _upWalkMax || _frame < _upWalkMin) + _frame = _upWalkMin; + + _playerDirection = UP; + int walkOff = _walkOffUp[_frame - _upWalkMin]; + _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + _rawXTemp = _rawPlayer.x; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.y = _rawYTempL; + + calcManScale(); + if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) { + error("TODO: si = 0?"); + // si = 0 + } + + if (++_frame > _upWalkMax) + _frame = _upWalkMin; + + plotCom(0); + } +} + +void Player::walkDown() { + if (_frame > _downWalkMax || _frame < _downWalkMin) + _frame = _downWalkMin; + + _playerDirection = DOWN; + int walkOff = _walkOffDown[_frame - _downWalkMin]; + _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + _rawXTemp = _rawPlayer.x; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.y = _rawYTempL; + + calcManScale(); + if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) { + error("TODO: si = 0?"); + // si = 0 + } + + if (++_frame > _upWalkMax) + _frame = _upWalkMin; + + plotCom(0); + } +} + +void Player::walkLeft() { + if (_frame > _sideWalkMax || _frame < _sideWalkMin) + _frame = _sideWalkMin; + + _playerDirection = LEFT; + + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + _rawYTemp = _rawPlayer.y; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayerLow.x = _rawTempL; + ++_frame; + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _sideWalkMax) + _frame = _sideWalkMin; + + plotCom1(); + } +} + +void Player::walkRight() { + if (_frame > _sideWalkMax || _frame < _sideWalkMin) + _frame = _sideWalkMin; + + _playerDirection = RIGHT; + + bool flag = _vm->_screen->_scrollEnd == 2; + if (!flag) { + calcPlayer(); + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + _rawYTemp = _rawPlayer.y; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayerLow.x = _rawTempL; + ++_frame; + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _sideWalkMax) + _frame = _sideWalkMin; + + plotCom1(); + } +} + +void Player::walkUpLeft() { + if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin) + _frame = _diagUpWalkMin; + + _playerDirection = UPLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagUpWalkMax) + _frame = _diagUpWalkMin; + + plotCom1(); + } +} + +void Player::walkDownLeft() { + if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin) + _frame = _diagDownWalkMin; + + _playerDirection = DOWNLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffDL[_frame - _sideWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagDownWalkMax) + _frame = _diagDownWalkMin; + + plotCom1(); + } +} + +void Player::walkUpRight() { + if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin) + _frame = _diagUpWalkMin; + + _playerDirection = UPLEFT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagUpWalkMax) + _frame = _diagUpWalkMin; + + plotCom(0); + } +} + +void Player::walkDownRight() { + if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin) + _frame = _diagDownWalkMin; + + _playerDirection = DOWNRIGHT; + + int walkOffset; + bool flag = _vm->_screen->_scrollEnd == 1; + if (!flag) { + calcPlayer(); + flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + _vm->_screen->_scrollThreshold) > 0; + } + if (flag) { + walkOffset = _walkOffUR[_frame - _sideWalkMin].x; + _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + } + else { + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + } + + walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y; + _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + + if (codeWalls()) { + plotCom2(); + } else { + _rawPlayer.x = _rawXTemp; + _rawPlayer.y = _rawYTemp; + _rawPlayerLow.x = _rawTempL; + _rawPlayerLow.y = _rawYTempL; + + ++_frame; + calcManScale(); + + if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { + error("TODO: si = 0?"); + } + + if (_frame > _diagDownWalkMax) + _frame = _diagDownWalkMin; + + plotCom1(); + } +} + +void Player::checkMove() { + error("TODO"); +} + +void Player::plotCom(int v) { + error("TODO"); +} + +void Player::plotCom1() { + plotCom(2); +} + +void Player::plotCom2() { + error("TODO"); +} + +void Player::plotCom3() { + error("TODO"); +} + +bool Player::codeWalls() { + error("TODO"); +} + } // End of namespace Access diff --git a/engines/access/player.h b/engines/access/player.h index b491ed7e85..28189706de 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -31,6 +31,9 @@ namespace Access { #define PLAYER_DATA_COUNT 8 +enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4, + UPRIGHT = 5, DOWNRIGHT = 6, UPLEFT = 7, DOWNLEFT = 8 }; + class AccessEngine; class Player: public Manager { @@ -44,6 +47,25 @@ private: int _diagUpWalkMin, _diagUpWalkMax; int _diagDownWalkMin, _diagDownWalkMax; Common::Point _guard; + bool _collideFlag; + Direction _playerDirection; + Direction _move; + + bool codeWalls(); + void checkMove(); + void plotCom(int v1); + void plotCom1(); + void plotCom2(); + void plotCom3(); + + void walkUp(); + void walkDown(); + void walkLeft(); + void walkRight(); + void walkUpLeft(); + void walkDownLeft(); + void walkUpRight(); + void walkDownRight(); public: // Fields in original Player structure int _field0; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 4673bb6136..ca87784458 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -52,6 +52,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; + _scrollEnd = 0; _bufferBytesWide = _vWindowBytesWide = this->w; _vWindowLinesTall = this->h; diff --git a/engines/access/screen.h b/engines/access/screen.h index ba1c22931c..5ac6931b63 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -80,6 +80,7 @@ public: int _vWindowBytesWide; int _bufferBytesWide; int _vWindowLinesTall; + int _scrollEnd; public: Screen(AccessEngine *vm); -- cgit v1.2.3 From 9547efad776899d1ff49a22e1baa5893080e5830 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Aug 2014 22:02:47 -0400 Subject: ACCESS: Implemented player plotting methods --- engines/access/access.cpp | 10 --- engines/access/access.h | 19 +----- engines/access/amazon/amazon_room.cpp | 6 +- engines/access/animation.cpp | 8 +-- engines/access/asurface.cpp | 12 ++++ engines/access/asurface.h | 13 ++++ engines/access/player.cpp | 119 +++++++++++++++++++++++++++++++--- engines/access/player.h | 14 +++- engines/access/room.cpp | 2 +- 9 files changed, 152 insertions(+), 51 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2ffc479748..ad8405800b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -51,10 +51,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; - _man = nullptr; - _man1 = nullptr; _inactive = nullptr; - _manPal1 = nullptr; _music = nullptr; _title = nullptr; _converseMode = 0; @@ -115,9 +112,7 @@ AccessEngine::~AccessEngine() { delete _sound; freeCells(); - delete[] _man1; delete[] _inactive; - delete[] _manPal1; delete[] _music; delete[] _title; } @@ -207,11 +202,6 @@ void AccessEngine::freeInactiveData() { _inactive = nullptr; } -void AccessEngine::freeManData() { - delete[] _man; - _man = nullptr; -} - void AccessEngine::establish(int v) { _establishMode = 0; _establishGroup = 0; diff --git a/engines/access/access.h b/engines/access/access.h index d919ae83f9..1e83c6e97c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -70,15 +70,6 @@ enum AccessDebugChannels { struct AccessGameDescription; -class ImageEntry { -public: - int _frameNumber; - SpriteResource *_spritesPtr; - int _priority; - Common::Point _position; - int _flags; -}; - class AccessEngine : public Engine { private: /** @@ -137,17 +128,14 @@ public: Common::Array _newRects; Common::Array _oldRects; Common::Array _extraCells; - Common::Array _images; + ImageEntryList _images; int _pCount; int _selectCommand; bool _normalMouse; int _mouseMode; int _currentManOld; - byte *_man; - byte *_man1; byte *_inactive; - byte *_manPal1; byte *_music; byte *_title; int _converseMode; @@ -222,11 +210,6 @@ public: */ void freeInactiveData(); - /** - * Free animation data - */ - void freeManData(); - void establish(int v); void establishCenter(int v); diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index db163977ca..5cb1dfe59c 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -51,15 +51,15 @@ void AmazonRoom::reloadRoom() { switch (_vm->_currentMan) { case 0: - _vm->_man1 = _vm->_files->loadFile("MAN.LZ"); + _vm->_player->loadSprites("MAN.LZ"); break; case 2: - _vm->_man1 = _vm->_files->loadFile("JMAN.LZ"); + _vm->_player->loadSprites("JMAN.LZ"); break; case 3: - _vm->_man1 = _vm->_files->loadFile("OVERHEAD.LZ"); + _vm->_player->loadSprites("OVERHEAD.LZ"); _vm->_manScaleOff = 1; break; diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 20772af8f0..4965f41105 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -210,10 +210,6 @@ void Animation::setFrame(AnimationFrame *frame) { setFrame1(frame); } -static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { - return ie1._priority < ie2._priority; -} - void Animation::setFrame1(AnimationFrame *frame) { _vm->_animation->_base.x = frame->_baseX; _vm->_animation->_base.y = frame->_baseY; @@ -234,9 +230,7 @@ void Animation::setFrame1(AnimationFrame *frame) { ie._position = part->_position + _vm->_animation->_base; ie._priority = part->_priority - ie._position.y; - assert(_vm->_images.size() < 35); - _vm->_images.push_back(ie); - Common::sort(_vm->_images.begin(), _vm->_images.end(), sortImagesY); + _vm->_images.addToList(&ie); } } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 5824545af7..ed614df974 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -82,6 +82,18 @@ SpriteFrame::~SpriteFrame() { /*------------------------------------------------------------------------*/ +static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { + return ie1._priority < ie2._priority; +} + +void ImageEntryList::addToList(ImageEntry *ie) { + assert(size() < 35); + push_back(*ie); + Common::sort(begin(), end(), sortImagesY); +} + +/*------------------------------------------------------------------------*/ + int ASurface::_leftSkip; int ASurface::_rightSkip; int ASurface::_topSkip; diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 4f172ae309..d660ff60b6 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -88,6 +88,19 @@ public: SpriteFrame *getFrame(int idx) { return _frames[idx]; } }; +class ImageEntry { +public: + int _frameNumber; + SpriteResource *_spritesPtr; + int _priority; + Common::Point _position; + int _flags; +}; + +class ImageEntryList : public Common::Array { +public: + void addToList(ImageEntry *ie); +}; } // End of namespace Access diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 6fab689ee0..7c07c69b1a 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -28,13 +28,16 @@ namespace Access { -Player::Player(AccessEngine *vm): Manager(vm) { +Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffDown[0], &_walkOffDown[PLAYER_DATA_COUNT], 0); - _field0 = 0; + _playerSprites = nullptr; + _playerSprites1 = nullptr; + _manPal1 = nullptr; + _frameNumber = 0; _monData = nullptr; _rawTempL = 0; _rawXTemp = 0; @@ -53,6 +56,12 @@ Player::Player(AccessEngine *vm): Manager(vm) { _collideFlag = false; _move = NONE; _playerDirection = NONE; + _xFlag = _yFlag = 0; +} + +Player::~Player() { + delete _playerSprites1; + delete[] _manPal1; } void Player::load() { @@ -131,14 +140,28 @@ void Player::load() { _diagDownWalkMax = 7; } - _vm->_man = _vm->_man1; - if (_vm->_manPal1) { - Common::copy(_vm->_manPal1 + 0x270, _vm->_manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); + _playerSprites = _playerSprites1; + if (_manPal1) { + Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); } else { Common::fill(_vm->_screen->_manPal, _vm->_screen->_manPal + 0x60, 0); } } +void Player::loadSprites(const Common::String &name) { + delete _playerSprites1; + _playerSprites = nullptr; + + const byte *data = _vm->_files->loadFile(name); + _playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize, + DisposeAfterUse::YES); +} + +void Player::freeSprites() { + delete _playerSprites; + _playerSprites = nullptr; +} + void Player::calcManScale() { if (!_vm->_manScaleOff) { _vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * @@ -534,11 +557,80 @@ void Player::walkDownRight() { } void Player::checkMove() { - error("TODO"); + if (!_vm->_events->_mouseMove) + return; + + if (_xFlag == 0 && _yFlag == 0) { + int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; + if (xp < 0) + xp = -xp; + int yp = _rawPlayer.y - _moveTo.y; + if (yp < 0) + yp = -yp; + + if (xp < yp) + _xFlag = 1; + else + _yFlag = 1; + } + + if (_yFlag == 1) { + int yd = _rawPlayer.y - _moveTo.y; + if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) { + ++_yFlag; + if (_xFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } else { + ++_xFlag; + } + } else { + if (yd >= 0) + walkUp(); + else + walkDown(); + + if (_collideFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } + } + } else if (_xFlag == 1) { + int xd = _rawPlayer.x - _moveTo.x; + if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { + ++_xFlag; + + if (_yFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } + } else { + if (xd >= 0) + walkLeft(); + else + walkRight(); + + if (_collideFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } + } + } else if (!_yFlag) { + ++_yFlag; + } else { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } + + plotCom3(); } -void Player::plotCom(int v) { - error("TODO"); +void Player::plotCom(int flags) { + _flags &= ~2; + _flags &= ~8; + _flags |= flags; + + plotCom3(); } void Player::plotCom1() { @@ -546,11 +638,18 @@ void Player::plotCom1() { } void Player::plotCom2() { - error("TODO"); + if (_playerOff != 1) + _vm->_images.addToList(this); } void Player::plotCom3() { - error("TODO"); + // Update the base ImageEntry fields for the player + _position = _rawPlayer; + _priority = _playerOffset.y; + _spritesPtr = _playerSprites; + _frameNumber = _frame; + + plotCom2(); } bool Player::codeWalls() { diff --git a/engines/access/player.h b/engines/access/player.h index 28189706de..a0167838a0 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "access/asurface.h" #include "access/data.h" namespace Access { @@ -36,7 +37,7 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4, class AccessEngine; -class Player: public Manager { +class Player: public ImageEntry, Manager { private: int _leftDelta, _rightDelta; int _upDelta, _downDelta; @@ -50,6 +51,11 @@ private: bool _collideFlag; Direction _playerDirection; Direction _move; + int _xFlag, _yFlag; + Common::Point _moveTo; + SpriteResource *_playerSprites; + SpriteResource *_playerSprites1; + byte *_manPal1; bool codeWalls(); void checkMove(); @@ -68,7 +74,6 @@ private: void walkDownRight(); public: // Fields in original Player structure - int _field0; byte *_monData; int _walkOffRight[PLAYER_DATA_COUNT]; int _walkOffLeft[PLAYER_DATA_COUNT]; @@ -98,9 +103,14 @@ public: Common::Point _rawPlayer; public: Player(AccessEngine *vm); + ~Player(); void load(); + void loadSprites(const Common::String &name); + + void freeSprites(); + void calcManScale(); void walk(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 66231e60e1..80bcc0082b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -150,7 +150,7 @@ void Room::clearRoom() { _vm->freeCells(); freePlayField(); _vm->freeInactiveData(); - _vm->freeManData(); + _vm->_player->freeSprites(); } void Room::loadRoomData(const byte *roomData) { -- cgit v1.2.3 From 66b2d471cf9cd23afe7b9d409a1cc5bd9f92464b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 14 Aug 2014 22:06:19 -0400 Subject: ACCESS: Change walking errors to TODO comments --- engines/access/player.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 7c07c69b1a..8cd129f0b2 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -249,8 +249,7 @@ void Player::walkUp() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) { - error("TODO: si = 0?"); - // si = 0 + // TODO: si = 0? } if (++_frame > _upWalkMax) @@ -278,8 +277,7 @@ void Player::walkDown() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) { - error("TODO: si = 0?"); - // si = 0 + // TODO: si = 0? } if (++_frame > _upWalkMax) @@ -318,7 +316,7 @@ void Player::walkLeft() { ++_frame; if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _sideWalkMax) @@ -357,7 +355,7 @@ void Player::walkRight() { ++_frame; if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _sideWalkMax) @@ -404,7 +402,7 @@ void Player::walkUpLeft() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _diagUpWalkMax) @@ -451,7 +449,7 @@ void Player::walkDownLeft() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _diagDownWalkMax) @@ -498,7 +496,7 @@ void Player::walkUpRight() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _diagUpWalkMax) @@ -546,7 +544,7 @@ void Player::walkDownRight() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - error("TODO: si = 0?"); + // TODO: si = 0? } if (_frame > _diagDownWalkMax) -- cgit v1.2.3 From 4a3ce2d27dabc2abe6e562089df4f37859e410f9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 09:27:05 -0400 Subject: ACCESS: Implementing checkScroll --- engines/access/player.cpp | 175 ++++++++++++++++++++++++++++++++++++++++++---- engines/access/player.h | 12 +++- engines/access/room.cpp | 10 ++- engines/access/room.h | 2 + engines/access/screen.cpp | 19 +++-- engines/access/screen.h | 11 +-- 6 files changed, 201 insertions(+), 28 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 8cd129f0b2..a50b835e3e 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -52,6 +52,10 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { _leftDelta = _rightDelta = 0; _upDelta = _downDelta = 0; _scrollConst = 0; + _scrollFlag = false; + _scrollThreshold = 0; + _scrollAmount = 0; + _scrollEnd = 0; _roomNumber = 0; _collideFlag = false; _move = NONE; @@ -293,11 +297,11 @@ void Player::walkLeft() { _playerDirection = LEFT; - bool flag = _vm->_screen->_scrollEnd == 1; + bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; @@ -332,11 +336,11 @@ void Player::walkRight() { _playerDirection = RIGHT; - bool flag = _vm->_screen->_scrollEnd == 2; + bool flag = _scrollEnd == 2; if (!flag) { calcPlayer(); flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; @@ -372,11 +376,11 @@ void Player::walkUpLeft() { _playerDirection = UPLEFT; int walkOffset; - bool flag = _vm->_screen->_scrollEnd == 1; + bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x; @@ -419,11 +423,11 @@ void Player::walkDownLeft() { _playerDirection = DOWNLEFT; int walkOffset; - bool flag = _vm->_screen->_scrollEnd == 1; + bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { walkOffset = _walkOffDL[_frame - _sideWalkMin].x; @@ -466,11 +470,11 @@ void Player::walkUpRight() { _playerDirection = UPLEFT; int walkOffset; - bool flag = _vm->_screen->_scrollEnd == 1; + bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x; @@ -513,11 +517,11 @@ void Player::walkDownRight() { _playerDirection = DOWNRIGHT; int walkOffset; - bool flag = _vm->_screen->_scrollEnd == 1; + bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - - _vm->_screen->_scrollThreshold) > 0; + _vm->_player->_scrollThreshold) > 0; } if (flag) { walkOffset = _walkOffUR[_frame - _sideWalkMin].x; @@ -654,4 +658,151 @@ bool Player::codeWalls() { error("TODO"); } +void Player::checkScroll() { + _scrollFlag = false; + if (_playerDirection == NONE) + return; + + if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT || + _playerDirection == LEFT) && _playerX <= _scrollThreshold) { + // Scroll right + _scrollAmount = -(_playerX - _scrollThreshold); + _scrollFlag = true; + _vm->_screen->_scrollX -= _scrollAmount; + if (_vm->_screen->_scrollX < 0) { + _scrollFlag = true; + _vm->_screen->_scrollX += _scrollAmount; + + while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { + _vm->_screen->_scrollX -= TILE_WIDTH; + _vm->_screen->moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol - + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + + if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) { + if (_playerDirection != DOWNRIGHT) + return; + goto finish; + } + } + + _scrollEnd = 1; + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollCol = 0; + } + } else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT || + _playerDirection == RIGHT) && (_vm->_screen->_clipWidth - + _playerX - _scrollThreshold) <= 0) { + // Scroll left + _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); + if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) { + _scrollEnd = 2; + _vm->_screen->_scrollX = 0; + _scrollFlag = true; + } else { + _scrollFlag = true; + _vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount; + + while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + _vm->_screen->moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + + if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) { + if (_playerDirection != DOWNRIGHT) + return; + goto finish; + } + } + + _scrollEnd = 2; + _vm->_screen->_scrollX = 0; + _scrollFlag = true; + } + } + + if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT || + _playerDirection == UP) && _playerY <= _scrollThreshold) { + _scrollAmount = -(_playerY - _scrollThreshold); + _scrollFlag = true; + _vm->_screen->_scrollY -= _scrollAmount; + if (_vm->_screen->_scrollY >= 0) + return; + + do { + _vm->_screen->_scrollY += TILE_HEIGHT; + if (--_vm->_screen->_scrollRow < 0) + break; + + _vm->_screen->moveBufferDown(); + _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); + + if (_vm->_screen->_scrollY >= 0) + return; + } while (!_vm->shouldQuit()); + + _scrollEnd = 3; + _vm->_screen->_scrollY = 0; + _vm->_screen->_scrollRow = 0; + return; + } + +finish: + if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT || + _playerDirection == DOWN) && (_vm->_screen->_clipHeight - + _playerY - _scrollThreshold) <= 0) { + // Scroll up + if (scrollUp()) { + _scrollEnd = 4; + _vm->_screen->_scrollY = TILE_HEIGHT; + _scrollFlag = true; + } + } +} + +bool Player::scrollUp() { + _scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold); + if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + _vm->_room->_playFieldHeight) + return true; + + _scrollFlag = true; + _vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount; + + while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_screen->_scrollY -= TILE_HEIGHT; + ++_vm->_screen->_scrollRow; + _vm->_screen->moveBufferUp(); + + _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, + _vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide); + + if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + _vm->_room->_playFieldHeight) + return true; + + if (_vm->_screen->_scrollY <= TILE_HEIGHT) + return false; + } + + return false; +} + +bool Player::scrollDown() { + // TODO: Refactor checkScroll code here + return false; +} + +bool Player::scrollLeft() { + // TODO: Refactor checkScroll code here + return false; +} + +bool Player::scrollRight() { + // TODO: Refactor checkScroll code here + return false; +} + } // End of namespace Access diff --git a/engines/access/player.h b/engines/access/player.h index a0167838a0..a291f4589d 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -56,6 +56,7 @@ private: SpriteResource *_playerSprites; SpriteResource *_playerSprites1; byte *_manPal1; + int _scrollEnd; bool codeWalls(); void checkMove(); @@ -72,6 +73,10 @@ private: void walkDownLeft(); void walkUpRight(); void walkDownRight(); + bool scrollUp(); + bool scrollDown(); + bool scrollLeft(); + bool scrollRight(); public: // Fields in original Player structure byte *_monData; @@ -94,8 +99,11 @@ public: int _playerY; int _frame; - // Additional globals we've added to new Player class + // Additional public globals we've added to new Player class bool _playerOff; + bool _scrollFlag; + int _scrollThreshold; + int _scrollAmount; // Additional globals that need to be saved int _roomNumber; @@ -116,6 +124,8 @@ public: void walk(); void calcPlayer(); + + void checkScroll(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 80bcc0082b..1eeedb7c29 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -85,7 +85,7 @@ void Room::doRoom() { _vm->_player->walk(); _vm->_sound->midiRepeat(); - _vm->_screen->checkScroll(); + _vm->_player->checkScroll(); doCommands(); // DOROOMFLASHBACK jump point @@ -103,7 +103,7 @@ void Room::doRoom() { break; } - if (_vm->_screen->_scrollFlag) { + if (_vm->_player->_scrollFlag) { _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; @@ -209,7 +209,7 @@ void Room::loadRoomData(const byte *roomData) { } _vm->_scaleI = roomInfo._scaleI; - _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold; + _vm->_player->_scrollThreshold = roomInfo._scrollThreshold; // Handle loading scene palette data if (roomInfo._paletteFile._fileNum != -1) { @@ -319,6 +319,10 @@ void Room::buildColumn(int playX, int screenX) { } } +void Room::buildRow(int playY, int screenY) { + error("TODO: buildRow"); +} + void Room::init4Quads() { error("TODO: init4Quads"); } diff --git a/engines/access/room.h b/engines/access/room.h index 18637e4283..0569a925c9 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -114,6 +114,8 @@ public: void buildColumn(int playX, int screenX); + void buildRow(int playY, int screenY); + void init4Quads(); }; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index ca87784458..771cfef7d2 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -46,13 +46,10 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _currentPanel = 0; _hideFlag = true; _loadPalFlag = false; - _scrollFlag = false; - _scrollThreshold = 0; _startColor = _numColors = 0; _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; - _scrollEnd = 0; _bufferBytesWide = _vWindowBytesWide = this->w; _vWindowLinesTall = this->h; @@ -182,10 +179,6 @@ void Screen::copyBuffer(const byte *data) { g_system->copyRectToScreen(destP, w, 0, 0, w, h); } -void Screen::checkScroll() { - warning("TODO"); -} - void Screen::setBufferScan() { _clipWidth = _vWindowBytesWide - 1; _windowXAdd = (320 - _clipWidth) >> 1; @@ -230,4 +223,16 @@ void Screen::restoreScreen() { _screenYOff = _screenSave._screenYOff; } +void Screen::moveBufferLeft() { + error("TODO: LEFT"); +} + +void Screen::moveBufferDown() { + error("TODO: LEFT"); +} + +void Screen::moveBufferUp() { + error("TODO: UP"); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 5ac6931b63..79c978f1d0 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -65,8 +65,6 @@ private: public: int _vesaMode; bool _loadPalFlag; - bool _scrollFlag; - int _scrollThreshold; int _startColor, _numColors; Common::Point _bufferStart; int _scrollCol, _scrollRow; @@ -80,7 +78,6 @@ public: int _vWindowBytesWide; int _bufferBytesWide; int _vWindowLinesTall; - int _scrollEnd; public: Screen(AccessEngine *vm); @@ -131,8 +128,6 @@ public: */ void copyBuffer(const byte *data); - void checkScroll(); - void setBufferScan(); void setScaleTable(int scale); @@ -146,6 +141,12 @@ public: * Restores previously saved screen display state variables */ void restoreScreen(); + + void moveBufferLeft(); + + void moveBufferDown(); + + void moveBufferUp(); }; } // End of namespace Access -- cgit v1.2.3 From e3687ea12347f65d3e6e9927e161e076774ad252 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 20:09:56 -0400 Subject: ACCESS: Refactored scroll direction code into separate methods --- engines/access/player.cpp | 171 +++++++++++++++++++++++----------------------- 1 file changed, 85 insertions(+), 86 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index a50b835e3e..6f1df97072 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -666,98 +666,38 @@ void Player::checkScroll() { if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT || _playerDirection == LEFT) && _playerX <= _scrollThreshold) { // Scroll right - _scrollAmount = -(_playerX - _scrollThreshold); - _scrollFlag = true; - _vm->_screen->_scrollX -= _scrollAmount; - if (_vm->_screen->_scrollX < 0) { - _scrollFlag = true; - _vm->_screen->_scrollX += _scrollAmount; - - while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { - _vm->_screen->_scrollX -= TILE_WIDTH; - _vm->_screen->moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol - - _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); - - if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) { - if (_playerDirection != DOWNRIGHT) - return; - goto finish; - } - } - - _scrollEnd = 1; - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollCol = 0; + if (!scrollRight()) { + if (_playerDirection == DOWNLEFT) + goto scrollUp; + + return; } } else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT || _playerDirection == RIGHT) && (_vm->_screen->_clipWidth - _playerX - _scrollThreshold) <= 0) { // Scroll left - _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); - if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) { - _scrollEnd = 2; - _vm->_screen->_scrollX = 0; - _scrollFlag = true; - } else { - _scrollFlag = true; - _vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount; - - while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; - _vm->_screen->moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + - _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); - - if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) { - if (_playerDirection != DOWNRIGHT) - return; - goto finish; - } - } - - _scrollEnd = 2; - _vm->_screen->_scrollX = 0; - _scrollFlag = true; + if (!scrollLeft()) { + if (_playerDirection == DOWNRIGHT) + goto scrollUp; + + return; } } if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT || _playerDirection == UP) && _playerY <= _scrollThreshold) { - _scrollAmount = -(_playerY - _scrollThreshold); - _scrollFlag = true; - _vm->_screen->_scrollY -= _scrollAmount; - if (_vm->_screen->_scrollY >= 0) - return; - - do { - _vm->_screen->_scrollY += TILE_HEIGHT; - if (--_vm->_screen->_scrollRow < 0) - break; - - _vm->_screen->moveBufferDown(); - _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); - - if (_vm->_screen->_scrollY >= 0) - return; - } while (!_vm->shouldQuit()); - - _scrollEnd = 3; - _vm->_screen->_scrollY = 0; - _vm->_screen->_scrollRow = 0; - return; - } - -finish: - if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT || + scrollDown(); + } else { +scrollUp: + if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT || _playerDirection == DOWN) && (_vm->_screen->_clipHeight - _playerY - _scrollThreshold) <= 0) { - // Scroll up - if (scrollUp()) { - _scrollEnd = 4; - _vm->_screen->_scrollY = TILE_HEIGHT; - _scrollFlag = true; + // Scroll up + if (scrollUp()) { + _scrollEnd = 4; + _vm->_screen->_scrollY = TILE_HEIGHT; + _scrollFlag = true; + } } } } @@ -791,18 +731,77 @@ bool Player::scrollUp() { } bool Player::scrollDown() { - // TODO: Refactor checkScroll code here - return false; + _scrollAmount = -(_playerY - _scrollThreshold); + _scrollFlag = true; + _vm->_screen->_scrollY -= _scrollAmount; + if (_vm->_screen->_scrollY >= 0) + return true; + + do { + _vm->_screen->_scrollY += TILE_HEIGHT; + if (--_vm->_screen->_scrollRow < 0) + break; + + _vm->_screen->moveBufferDown(); + _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); + + if (_vm->_screen->_scrollY >= 0) + return false; + } while (!_vm->shouldQuit()); + + _scrollEnd = 3; + _vm->_screen->_scrollY = 0; + _vm->_screen->_scrollRow = 0; + return true; } bool Player::scrollLeft() { - // TODO: Refactor checkScroll code here - return false; + _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); + if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) { + _scrollEnd = 2; + _vm->_screen->_scrollX = 0; + _scrollFlag = true; + return true; + } else { + _scrollFlag = true; + _vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount; + + while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + _vm->_screen->moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + + if (_vm->_screen->_scrollX < TILE_WIDTH) + return _playerDirection == UPRIGHT; + } + + return true; + } } bool Player::scrollRight() { - // TODO: Refactor checkScroll code here - return false; + _scrollAmount = -(_playerX - _scrollThreshold); + _scrollFlag = true; + _vm->_screen->_scrollX -= _scrollAmount; + + if (_vm->_screen->_scrollX < 0) { + _scrollFlag = true; + _vm->_screen->_scrollX += _scrollAmount; + + while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { + _vm->_screen->_scrollX -= TILE_WIDTH; + _vm->_screen->moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol - + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + + if (_vm->_screen->_scrollX < TILE_WIDTH) + return _playerDirection == UPLEFT; + } + } + + return true; } } // End of namespace Access -- cgit v1.2.3 From f8d64ae6bc47c0d1ea6efea45c28dd4902780ecb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 20:26:09 -0400 Subject: ACCESS: Added code to update animations each frame --- engines/access/animation.cpp | 7 +++++++ engines/access/animation.h | 17 ++++++++++++++--- engines/access/events.cpp | 19 ++++++++++++------- engines/access/events.h | 2 ++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 4965f41105..31e53e5cf0 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -331,4 +331,11 @@ void AnimationManager::animate(int animId) { anim->animate(); } +void AnimationManager::updateTimers() { + for (uint idx = 0; idx < _animationTimers.size(); ++idx) { + if (_animationTimers[idx]->_countdownTicks > 0) + _animationTimers[idx]->_countdownTicks--; + } +} + } // End of namespace Access diff --git a/engines/access/animation.h b/engines/access/animation.h index c1b44a5621..f70aa3239d 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -49,14 +49,25 @@ public: void freeAnimationData(); void loadAnimations(const byte *data, int size); - void clearTimers(); - Animation *findAnimation(int animId); Animation *setAnimation(int animId); + void animate(int animId); + + /** + * Clear the list of currently active animations + */ + void clearTimers(); + + /** + * Add an animation to the list of currently animating ones + */ void setAnimTimer(Animation *anim); - void animate(int animId); + /** + * Update the timing of all currently active animation + */ + void updateTimers(); }; class AnimationResource { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 88e783e6d2..db69f7ba2d 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -144,15 +144,20 @@ void EventsManager::checkForNextFrameCounter() { ++_frameCounter; _priorFrameTime = milli; - // Give time to the debugger - _vm->_debugger->onFrame(); + nextFrame(); + } +} - // Signal the ScummVM debugger - _vm->_debugger->onFrame(); +void EventsManager::nextFrame() { - // TODO: Refactor for dirty rects - _vm->_screen->updateScreen(); - } + // Give time to the debugger + _vm->_debugger->onFrame(); + + // Update timers + _vm->_animation->updateTimers(); + + // TODO: Refactor for dirty rects + _vm->_screen->updateScreen(); } void EventsManager::delay(int time) { diff --git a/engines/access/events.h b/engines/access/events.h index aa01543381..c3faf6333b 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -47,6 +47,8 @@ private: uint32 _priorFrameTime; void checkForNextFrameCounter(); + + void nextFrame(); public: CursorType _cursorId; bool _leftButton; -- cgit v1.2.3 From 3475fda076779fa79f931b98d24e300fc02b479b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 20:34:09 -0400 Subject: ACCESS: Fixes for updating animation frames --- engines/access/animation.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 31e53e5cf0..3a7424f1d0 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -106,6 +106,7 @@ void Animation::anim0() { if (frame == nullptr) { _frameNumber = 0; _currentLoopCount = -1; + frame = calcFrame(); } setFrame(frame); @@ -124,6 +125,7 @@ void Animation::anim1() { if (frame == nullptr) { --_frameNumber; _currentLoopCount = -1; + frame = calcFrame(); } setFrame(frame); @@ -198,7 +200,7 @@ void Animation::anim7() { } AnimationFrame *Animation::calcFrame() { - return _frames[_frameNumber]; + return (_frameNumber < (int)_frames.size()) ? _frames[_frameNumber] : nullptr; } AnimationFrame *Animation::calcFrame1() { @@ -206,6 +208,7 @@ AnimationFrame *Animation::calcFrame1() { } void Animation::setFrame(AnimationFrame *frame) { + assert(frame); _countdownTicks += frame->_frameDelay; setFrame1(frame); } -- cgit v1.2.3 From a347435f26b32464944c3e304369c4c7df663478 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 15 Aug 2014 21:32:16 -0400 Subject: ACCESS: Added extra mouse handling to pollEvents --- engines/access/events.cpp | 12 +++++++++++- engines/access/events.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index db69f7ba2d..f373c8b829 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -38,7 +38,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _cursorId = CURSOR_NONE; _frameCounter = 10; _priorFrameTime = 0; - _leftButton = false; + _leftButton = _rightButton = false; _mouseMove = false; } @@ -126,10 +126,20 @@ void EventsManager::pollEvents() { return; case Common::EVENT_KEYUP: return; + case Common::EVENT_MOUSEMOVE: + _mousePos = event.mouse; + break; case Common::EVENT_LBUTTONDOWN: _leftButton = true; return; case Common::EVENT_LBUTTONUP: + _leftButton = false; + return; + case Common::EVENT_RBUTTONDOWN: + _rightButton = true; + return; + case Common::EVENT_RBUTTONUP: + _rightButton = false; return; default: break; diff --git a/engines/access/events.h b/engines/access/events.h index c3faf6333b..7ee03ac21e 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -51,7 +51,7 @@ private: void nextFrame(); public: CursorType _cursorId; - bool _leftButton; + bool _leftButton, _rightButton; Common::Point _mousePos; bool _mouseMove; public: -- cgit v1.2.3 From fab6d7883e56a4fdebcabaaf0f911265fbd06a30 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Aug 2014 11:27:37 +0200 Subject: ACCESS: Update TODOs --- engines/access/amazon/amazon_game.cpp | 4 +- engines/access/amazon/amazon_scripts.cpp | 2 +- engines/access/player.cpp | 2 +- engines/access/screen.cpp | 2 +- engines/access/scripts.cpp | 72 ++++++++++++++++---------------- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 49ae766325..0497dd8d4d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -152,11 +152,11 @@ void AmazonEngine::doTitle() { } void AmazonEngine::doOpening() { - // TODO + warning("TODO doOpening"); } void AmazonEngine::doTent() { - // TODO + warning("TODO doTent"); } void AmazonEngine::setupGame() { diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d7e84394b5..bc86c95a6d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -32,7 +32,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { } void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { - warning("TODO"); + warning("TODO executeSpecial"); } diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 6f1df97072..0e005f936e 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -655,7 +655,7 @@ void Player::plotCom3() { } bool Player::codeWalls() { - error("TODO"); + error("TODO codeWalls"); } void Player::checkScroll() { diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 771cfef7d2..9871fb1c3e 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -228,7 +228,7 @@ void Screen::moveBufferLeft() { } void Screen::moveBufferDown() { - error("TODO: LEFT"); + error("TODO: DOWN"); } void Screen::moveBufferUp() { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0e1d421c34..ea93a04e9b 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -116,9 +116,9 @@ void Scripts::executeCommand(int commandIndex) { (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::CMDOBJECT() { error("TODO"); } +void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); } -void Scripts::CMDENDOBJECT() { error("TODO"); } +void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); } void Scripts::cmdJumpLook() { if (_vm->_selectCommand == 0) @@ -165,7 +165,7 @@ void Scripts::cmdJumpTalk() { void Scripts::cmdNull() { } -void Scripts::CMDPRINT() { error("TODO"); } +void Scripts::CMDPRINT() { error("TODO CMDPRINT"); } void Scripts::cmdRetPos() { _endFlag = true; @@ -221,9 +221,9 @@ void Scripts::cmdCheckInventory() { _data->skip(2); } -void Scripts::CMDSETTEX() { error("TODO"); } -void Scripts::CMDNEWROOM() { error("TODO"); } -void Scripts::CMDCONVERSE() { error("TODO"); } +void Scripts::CMDSETTEX() { error("TODO CMDSETTEX"); } +void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); } +void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); } void Scripts::cmdCheckFrame() { int id = _data->readUint16LE(); @@ -277,9 +277,9 @@ void Scripts::cmdSetAnim() { _vm->_animation->setAnimTimer(anim); } -void Scripts::CMDDISPINV() { error("TODO"); } -void Scripts::CMDSETTIMER() { error("TODO"); } -void Scripts::CMDCHECKTIMER() { error("TODO"); } +void Scripts::CMDDISPINV() { error("TODO CMDDISPINV"); } +void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); } +void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); } void Scripts::cmdSetTravel() { if (_vm->_selectCommand == 5) @@ -288,8 +288,8 @@ void Scripts::cmdSetTravel() { _data->skip(2); } -void Scripts::CMDSETVID() { error("TODO"); } -void Scripts::CMDPLAYVID() { error("TODO"); } +void Scripts::CMDSETVID() { error("TODO CMDSETVID"); } +void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); } void Scripts::cmdPlotImage() { _vm->_destIn = _vm->_current; @@ -318,9 +318,9 @@ void Scripts::cmdSetScroll() { _vm->_screen->_scrollY = 0; } -void Scripts::CMDSAVERECT() { error("TODO"); } -void Scripts::CMDSETBUFVID() { error("TODO"); } -void Scripts::CMDPLAYBUFVID() { error("TODO"); } +void Scripts::CMDSAVERECT() { error("TODO CMDSAVERECT"); } +void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); } +void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); } void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; @@ -346,14 +346,14 @@ void Scripts::CMDSPECIAL() { } } -void Scripts::CMDSETCYCLE() { error("TODO"); } -void Scripts::CMDCYCLE() { error("TODO"); } -void Scripts::CMDCHARSPEAK() { error("TODO"); } -void Scripts::CMDTEXSPEAK() { error("TODO"); } -void Scripts::CMDTEXCHOICE() { error("TODO"); } // _choiceStart = _data->pos() - 1; -void Scripts::CMDWAIT() { error("TODO"); } -void Scripts::CMDSETCONPOS() { error("TODO"); } -void Scripts::CMDCHECKVFRAME() { error("TODO"); } +void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); } +void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); } +void Scripts::CMDCHARSPEAK() { error("TODO CMDCHARSPEAK"); } +void Scripts::CMDTEXSPEAK() { error("TODO CMDTEXSPEAK"); } +void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1; +void Scripts::CMDWAIT() { error("TODO CMDWAIT"); } +void Scripts::CMDSETCONPOS() { error("TODO CMDSETCONPOS"); } +void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); } void Scripts::cmdJumpChoice() { int val = (_data->readUint16LE() && 0xFF); @@ -369,12 +369,12 @@ void Scripts::cmdReturnChoice() { _data->seek(_choiceStart); } -void Scripts::CMDCLEARBLOCK() { error("TODO"); } -void Scripts::CMDLOADSOUND() { error("TODO"); } -void Scripts::CMDFREESOUND() { error("TODO"); } -void Scripts::CMDSETVIDSND() { error("TODO"); } -void Scripts::CMDPLAYVIDSND() { error("TODO"); } -void Scripts::CMDPUSHLOCATION() { error("TODO"); } +void Scripts::CMDCLEARBLOCK() { error("TODO CMDCLEARBLOCK"); } +void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); } +void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } +void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); } +void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); } +void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } void Scripts::cmdPlayerOff() { _vm->_player->_playerOff = true; @@ -384,18 +384,18 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::CMDDEAD() { error("TODO"); } +void Scripts::CMDDEAD() { error("TODO CMDDEAD"); } void Scripts::cmdFadeOut() { _vm->_screen->forceFadeOut(); } -void Scripts::CMDENDVID() { error("TODO"); } -void Scripts::CMDHELP() { error("TODO"); } -void Scripts::CMDCYCLEBACK() { error("TODO"); } -void Scripts::CMDCHAPTER() { error("TODO"); } -void Scripts::CMDSETHELP() { error("TODO"); } -void Scripts::CMDCENTERPANEL() { error("TODO"); } +void Scripts::CMDENDVID() { error("TODO CMDENDVID"); } +void Scripts::CMDHELP() { error("TODO CMDHELP"); } +void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); } +void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); } +void Scripts::CMDSETHELP() { error("TODO CMDSETHELP"); } +void Scripts::CMDCENTERPANEL() { error("TODO CMDCENTERPANEL"); } void Scripts::cmdMainPanel() { if (_vm->_screen->_vesaMode) { @@ -404,7 +404,7 @@ void Scripts::cmdMainPanel() { } } -void Scripts::CMDRETFLASH() { error("TODO"); } +void Scripts::CMDRETFLASH() { error("TODO CMDRETFLASH"); } } // End of namespace Access -- cgit v1.2.3 From 0b0d16d6a5793f8ae73da9c64527cda05850416e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Aug 2014 11:47:13 +0200 Subject: ACCESS: Add details in executeSpecial TODO --- engines/access/amazon/amazon_scripts.cpp | 38 +++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index bc86c95a6d..f0c580ec34 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -32,7 +32,43 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { } void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { - warning("TODO executeSpecial"); + switch (commandIndex) { + case 1: + warning("TODO ESTABLISH"); + break; + case 2: + warning("TODO LOADBACKGROUND"); + break; + case 3: + warning("TODO DOCAST"); + break; + case 4: + warning("TODO SETINACTIVE"); + break; + case 6: + warning("TODO MWHILE"); + break; + case 9: + warning("TODO GUARD"); + break; + case 10: + warning("TODO NEWMUSIC"); + break; + case 11: + warning("TODO PLOTINACTIVE"); + break; + case 13: + warning("TODO RIVER"); + break; + case 14: + warning("TODO ANT"); + break; + case 15: + warning("TODO BOATWALLS"); + break; + default: + warning("Unexpected Special code %d - Skipped", commandIndex); + } } -- cgit v1.2.3 From 86484802589f547348ca9ff7fc771801c5b7123e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 16 Aug 2014 12:24:26 +0200 Subject: ACCESS: Add a second parameter to doEstablish() --- engines/access/access.cpp | 14 +++++++------- engines/access/access.h | 6 +++--- engines/access/amazon/amazon_scripts.cpp | 2 +- engines/access/room.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ad8405800b..eaa65c7545 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -202,24 +202,24 @@ void AccessEngine::freeInactiveData() { _inactive = nullptr; } -void AccessEngine::establish(int v) { +void AccessEngine::establish(int v1, int v2) { _establishMode = 0; _establishGroup = 0; - doEstablish(v); + doEstablish(v1, v2); } -void AccessEngine::establishCenter(int v) { +void AccessEngine::establishCenter(int v1, int v2) { _establishMode = 1; - doEstablish(v); + doEstablish(v1, v2); } -void AccessEngine::doEstablish(int v) { +void AccessEngine::doEstablish(int v1, int v2) { _screen->forceFadeOut(); _screen->clearScreen(); _screen->setPanel(3); - if (v != -1) { - _files->loadScreen(95, v); + if (v1 != -1) { + _files->loadScreen(95, v1); _buffer2.copyBuffer(_screen); } diff --git a/engines/access/access.h b/engines/access/access.h index 1e83c6e97c..921d064a1d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -84,7 +84,7 @@ private: void dummyLoop(); - void doEstablish(int v); + void doEstablish(int v1, int v2); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -210,9 +210,9 @@ public: */ void freeInactiveData(); - void establish(int v); + void establish(int v1, int v2); - void establishCenter(int v); + void establishCenter(int v1, int v2); void plotList(); void plotList1(); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f0c580ec34..2fdbcc94a2 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -34,7 +34,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: - warning("TODO ESTABLISH"); + _vm->establish(param1, param2); break; case 2: warning("TODO LOADBACKGROUND"); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 1eeedb7c29..f42c8b092c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -163,7 +163,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(0); + _vm->establish(0, roomInfo._estIndex); } } -- cgit v1.2.3 From b3ab8a42a6bf77d99b6b349793f1fa7393359d24 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 09:35:38 -0400 Subject: ACCESS: Implementing doCommand --- engines/access/access.cpp | 5 +- engines/access/access.h | 3 +- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_room.cpp | 7 +- engines/access/amazon/amazon_room.h | 6 +- engines/access/events.cpp | 33 +++++++- engines/access/events.h | 13 +++- engines/access/inventory.cpp | 9 +++ engines/access/inventory.h | 4 + engines/access/resources.cpp | 5 ++ engines/access/resources.h | 2 + engines/access/room.cpp | 141 +++++++++++++++++++++++++++++++++- engines/access/room.h | 19 ++++- engines/access/screen.cpp | 1 + engines/access/screen.h | 1 + engines/access/scripts.cpp | 18 ++--- 16 files changed, 245 insertions(+), 24 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index eaa65c7545..d6f19924b7 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -46,7 +46,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _destIn = nullptr; _current = nullptr; _pCount = 0; - _selectCommand = 0; _normalMouse = true; _mouseMode = 0; _currentMan = 0; @@ -312,4 +311,8 @@ void AccessEngine::copyBF2Vid() { } } +void AccessEngine::doLoadSave() { + error("TODO: doLoadSave"); +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 921d064a1d..81b1185922 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -130,7 +130,6 @@ public: Common::Array _extraCells; ImageEntryList _images; int _pCount; - int _selectCommand; bool _normalMouse; int _mouseMode; @@ -224,6 +223,8 @@ public: void copyBF1BF2(); void copyBF2Vid(); + + void doLoadSave(); }; } // End of namespace Access diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 0497dd8d4d..36d6d80e47 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -176,7 +176,7 @@ void AmazonEngine::setupGame() { _player->_roomNumber = 4; _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; - _selectCommand = -1; + _room->_selectCommand = -1; } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 5cb1dfe59c..cb6c8140ef 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/resources.h" #include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_room.h" @@ -78,7 +79,7 @@ void AmazonRoom::reloadRoom1() { _vm->_currentCharFlag = false; } - _vm->_selectCommand = -1; + _selectCommand = -1; _vm->_normalMouse = 1; _vm->_mouseMode = 0; _vm->_boxSelect = true; @@ -138,6 +139,10 @@ void AmazonRoom::roomMenu() { delete spr; } +void AmazonRoom::mainAreaClick() { + +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 546ea9698a..838b108fb5 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -38,14 +38,16 @@ private: const byte *_icon; void roomSet(); - - void roomMenu(); protected: virtual void loadRoom(int roomNumber); virtual void reloadRoom(); virtual void reloadRoom1(); + + virtual void roomMenu(); + + virtual void mainAreaClick(); public: AmazonRoom(AccessEngine *vm); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index f373c8b829..8f02d41547 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -40,6 +40,10 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _priorFrameTime = 0; _leftButton = _rightButton = false; _mouseMove = false; + _mouseCol = _mouseRow = 0; + _normalMouse = 0; + _mouseMode = 0; + _cursorExitFlag = false; } EventsManager::~EventsManager() { @@ -103,10 +107,9 @@ bool EventsManager::isCursorVisible() { return CursorMan.isVisible(); } -void EventsManager::pollEvents() { - checkForNextFrameCounter(); - - _leftButton = false; +void EventsManager::pollEvents(bool suppressFrames) { + if (!suppressFrames) + checkForNextFrameCounter(); Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { @@ -122,6 +125,8 @@ void EventsManager::pollEvents() { // Attach to the debugger _vm->_debugger->attach(); _vm->_debugger->onFrame(); + } else { + } return; case Common::EVENT_KEYUP: @@ -174,5 +179,25 @@ void EventsManager::delay(int time) { g_system->delayMillis(time); } +void EventsManager::zeroKeys() { + _keypresses.clear(); +} + +bool EventsManager::getKey(Common::KeyState &key) { + if (_keypresses.empty()) { + return false; + } else { + key = _keypresses.pop(); + return true; + } +} + +void EventsManager::debounceLeft() { + while (_leftButton && !_vm->shouldQuit()) { + pollEvents(true); + g_system->delayMillis(10); + } +} + } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index 7ee03ac21e..5ca08068f1 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -53,7 +53,12 @@ public: CursorType _cursorId; bool _leftButton, _rightButton; Common::Point _mousePos; + int _mouseCol, _mouseRow; bool _mouseMove; + int _normalMouse; + int _mouseMode; + bool _cursorExitFlag; + Common::FixedStack _keypresses; public: /** * Constructor @@ -90,9 +95,15 @@ public: */ bool isCursorVisible(); - void pollEvents(); + void pollEvents(bool suppressFrames = false); + + void zeroKeys(); + + bool getKey(Common::KeyState &key); void delay(int time); + + void debounceLeft(); }; } // End of namespace Access diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 5d2957bd30..e784b873c9 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -58,4 +58,13 @@ void InventoryManager::setUseItem(int itemId) { _vm->_useItem = itemId; } +void InventoryManager::refreshInventory() { + error("TODO: refreshInventory"); +} + +int InventoryManager::newDisplayInv() { + error("TODO: newDisplayInv"); +} + + } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 1f229dd8ee..399c763483 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -47,6 +47,10 @@ public: int useItem(); void setUseItem(int itemId); + + void refreshInventory(); + + int newDisplayInv(); }; } // End of namespace Access diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 841ab70f04..40daf2b121 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -71,4 +71,9 @@ const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 }; const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; +const int RMOUSE[10][2] = { + { 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 }, + { 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 } +}; + } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index 1b49b598ca..678cbc0614 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -54,6 +54,8 @@ extern const int OVEROFFULY[]; extern const int OVEROFFDLX[]; extern const int OVEROFFDLY[]; +extern const int RMOUSE[10][2]; + } // End of namespace Access #endif /* ACCESS_RESOURCES_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f42c8b092c..773a42b9d4 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -35,6 +35,8 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _playFieldWidth = _playFieldHeight = 0; _matrixSize = 0; _tile = nullptr; + _selectCommand = 0; + _conFlag = false; } Room::~Room() { @@ -394,6 +396,138 @@ void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockC _blocks[i].bottom = stream->readSint16LE(); } +void Room::doCommands() { + int commandId = 0; + Common::KeyState keyState; + + if (_vm->_startup != -1) + return; + + if (_vm->_inventory->_invChangeFlag) + _vm->_inventory->refreshInventory(); + + if (_vm->_screen->_screenChangeFlag) { + _vm->_screen->_screenChangeFlag = false; + _vm->_events->_cursorExitFlag = true; + executeCommand(4); + } else if (_vm->_events->_leftButton) { + if (_vm->_events->_mouseRow >= 22) { + // Mouse in user interface area + for (commandId = 0; commandId < 10; ++commandId) { + if (_vm->_events->_mousePos.x >= RMOUSE[commandId][0] && + _vm->_events->_mousePos.x < RMOUSE[commandId][1]) + break; + } + if (commandId < 10) + handleCommand(commandId); + + } else { + // Mouse click in main game area + mainAreaClick(); + } + } else if (_vm->_events->getKey(keyState)) { + if (keyState.ascii >= ';' && keyState.ascii <= 'D') { + handleCommand((int)keyState.ascii - ';'); + } + } +} + +void Room::handleCommand(int commandId) { + if (commandId == 1) + --commandId; + + if (commandId == 9) + _vm->doLoadSave(); + else if (commandId == _selectCommand) { + _vm->_events->debounceLeft(); + commandOff(); + } else { + _vm->_events->debounceLeft(); + executeCommand(commandId); + } +} + +void Room::executeCommand(int commandId) { + _selectCommand = commandId; + + switch (commandId) { + case 0: + _vm->_events->_normalMouse = 4; + _vm->_events->_mouseMode = 0; + break; + case 2: + _vm->_events->_normalMouse = 5; + _vm->_events->_mouseMode = 0; + break; + case 3: + _vm->_events->_normalMouse = 6; + _vm->_events->_mouseMode = 0; + break; + case 4: + _vm->_events->_normalMouse = 1; + _vm->_events->setCursor(CURSOR_0); + if (_vm->_inventory->newDisplayInv() == 2) { + commandOff(); + return; + } else { + warning("TODO: al = _useItem"); + } + break; + case 5: + _vm->_events->_normalMouse = 7; + _vm->_events->_mouseMode = 0; + break; + case 6: + _vm->_events->_normalMouse = 8; + _vm->_events->_mouseMode = 0; + break; + case 7: + _vm->_events->_normalMouse = 1; + _vm->_scripts->_sequence = 5000; + _vm->_scripts->searchForSequence(); + roomMenu(); + _selectCommand = -1; + _vm->_events->_normalMouse = 1; + _vm->_events->_mouseMode = 0; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + _vm->_boxSelect = true; + break; + case 8: + _vm->_events->_normalMouse = 9; + _vm->_events->_mouseMode = 0; + break; + default: + break; + } + + roomMenu(); + _vm->_screen->saveScreen(); + _vm->_screen->setDisplayScan(); + + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); + delete[] iconData; + + // Draw the button as selected + _vm->_screen->plotImage(spr, _selectCommand + 2, + Common::Point(RMOUSE[_selectCommand][0], 176)); + + _vm->_screen->restoreScreen(); + _vm->_boxSelect = true; +} + +void Room::commandOff() { + _selectCommand = -1; + _vm->_events->_normalMouse = 1; + _vm->_events->_mouseMode = 4; + roomMenu(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -428,20 +562,21 @@ RoomInfo::RoomInfo(const byte *data) { _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; - } else { + } + else { _startColor = stream.readUint16LE(); _numColors = stream.readUint16LE(); } for (int16 v = (int16)stream.readUint16LE(); v != -1; - v = (int16)stream.readUint16LE()) { + v = (int16)stream.readUint16LE()) { uint16 v2 = stream.readUint16LE(); _vidTable.push_back(v | ((uint32)v2 << 16)); } for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; - fileNum = (int16)stream.readUint16LE()) { + fileNum = (int16)stream.readUint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); diff --git a/engines/access/room.h b/engines/access/room.h index 0569a925c9..00de53f0a7 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -63,6 +63,8 @@ private: void roomLoop(); void loadPlayField(int fileNum, int subfile); + + void commandOff(); protected: void loadRoomData(const byte *roomData); void setupRoom(); @@ -79,6 +81,15 @@ protected: */ void freeTileData(); + /** + * Switch to a given command mode + */ + void handleCommand(int commandId); + + /** + * Inner handler for switching to a given command mode + */ + void executeCommand(int commandId); virtual void loadRoom(int roomNumber) = 0; @@ -88,7 +99,11 @@ protected: virtual void setIconPalette() {} - virtual void doCommands() {} + virtual void doCommands(); + + virtual void roomMenu() = 0; + + virtual void mainAreaClick() = 0; public: Plotter _plotter; Common::Array _jetFrame; @@ -100,6 +115,8 @@ public: int _playFieldHeight; byte *_tile; int _tileSize; + int _selectCommand; + bool _conFlag; public: Room(AccessEngine *vm); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 9871fb1c3e..8e9b08234f 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -50,6 +50,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; + _screenChangeFlag = false; _bufferBytesWide = _vWindowBytesWide = this->w; _vWindowLinesTall = this->h; diff --git a/engines/access/screen.h b/engines/access/screen.h index 79c978f1d0..98e77b4cf4 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -78,6 +78,7 @@ public: int _vWindowBytesWide; int _bufferBytesWide; int _vWindowLinesTall; + bool _screenChangeFlag; public: Screen(AccessEngine *vm); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index ea93a04e9b..0cfce787a9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -121,42 +121,42 @@ void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); } void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); } void Scripts::cmdJumpLook() { - if (_vm->_selectCommand == 0) + if (_vm->_room->_selectCommand == 0) cmdGoto(); else _data->skip(2); } void Scripts::cmdJumpHelp() { - if (_vm->_selectCommand == 8) + if (_vm->_room->_selectCommand == 8) cmdGoto(); else _data->skip(2); } void Scripts::cmdJumpGet() { - if (_vm->_selectCommand == 3) + if (_vm->_room->_selectCommand == 3) cmdGoto(); else _data->skip(2); } void Scripts::cmdJumpMove() { - if (_vm->_selectCommand == 2) + if (_vm->_room->_selectCommand == 2) cmdGoto(); else _data->skip(2); } void Scripts::cmdJumpUse() { - if (_vm->_selectCommand == 4) + if (_vm->_room->_selectCommand == 4) cmdGoto(); else _data->skip(2); } void Scripts::cmdJumpTalk() { - if (_vm->_selectCommand == 6) + if (_vm->_room->_selectCommand == 6) cmdGoto(); else _data->skip(2); @@ -180,15 +180,15 @@ void Scripts::cmdAnim() { void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); byte flagVal = _data->readByte(); - assert(flagNum < 256); + _vm->_flags[flagNum] = flagVal; } void Scripts::cmdCheckFlag() { int flagNum = _data->readUint16LE(); int flagVal = _data->readUint16LE(); - assert(flagNum < 100); + assert(flagNum < 256); if (_vm->_flags[flagNum] == flagVal) cmdGoto(); @@ -282,7 +282,7 @@ void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); } void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); } void Scripts::cmdSetTravel() { - if (_vm->_selectCommand == 5) + if (_vm->_room->_selectCommand == 5) cmdGoto(); else _data->skip(2); -- cgit v1.2.3 From dc5500e2464d3457d9dee70993ecd4340963946e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 10:33:03 -0400 Subject: ACCESS: Cleanup of timer flags and some inventory logic --- engines/access/access.cpp | 1 - engines/access/access.h | 3 +-- engines/access/amazon/amazon_game.cpp | 1 - engines/access/amazon/amazon_room.cpp | 2 +- engines/access/data.cpp | 19 +++++++++++++++++++ engines/access/data.h | 19 +++++++++++++++++++ engines/access/inventory.cpp | 10 ++++++++-- engines/access/inventory.h | 2 ++ engines/access/player.cpp | 6 +++--- engines/access/room.cpp | 1 + 10 files changed, 54 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d6f19924b7..6a61527ef9 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -75,7 +75,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _newDate = 0; _intTim[3] = 0; _timer[3] = 0; - _timerFlag = false; Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); Common::fill(&_establishTable[0], &_establishTable[100], 0); Common::fill(&_flags[0], &_flags[256], 0); diff --git a/engines/access/access.h b/engines/access/access.h index 81b1185922..105b00b0ff 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -124,7 +124,7 @@ public: int _establishMode; int _establishGroup; int _numAnimTimers; - Common::Array _timers; + TimerList _timers; Common::Array _newRects; Common::Array _oldRects; Common::Array _extraCells; @@ -161,7 +161,6 @@ public: uint32 _newDate; int _intTim[3]; int _timer[3]; - bool _timerFlag; int _flags[256]; byte _help1[366]; byte _help2[366]; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 36d6d80e47..1b824ac730 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -176,7 +176,6 @@ void AmazonEngine::setupGame() { _player->_roomNumber = 4; _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; - _room->_selectCommand = -1; } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index cb6c8140ef..405889fe1a 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -83,7 +83,7 @@ void AmazonRoom::reloadRoom1() { _vm->_normalMouse = 1; _vm->_mouseMode = 0; _vm->_boxSelect = true; - _vm->_player->_playerOff = 0; + _vm->_player->_playerOff = false; _vm->_screen->fadeOut(); _vm->_screen->clearScreen(); diff --git a/engines/access/data.cpp b/engines/access/data.cpp index c3a6bb3d90..f5dbbb367f 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -25,4 +25,23 @@ namespace Access { +TimerList::TimerList() : Common::Array() { + _timersSavedFlag = false; +} + +void TimerList::saveTimers() { + if (!_timersSavedFlag /* && !_flashbackFlag */) { + _savedTimers = *this; + _timersSavedFlag = true; + } +} + +void TimerList::restoreTimers() { + if (_timersSavedFlag /* && !_flashbackFlag */) { + clear(); + *static_cast *>(this) = _savedTimers; + _timersSavedFlag = false; + } +} + } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index b9da858216..67b9cfe9fd 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -51,6 +51,25 @@ struct TimerEntry { } }; +class TimerList : public Common::Array { +private: + Common::Array _savedTimers; +public: + bool _timersSavedFlag; +public: + TimerList(); + + /** + * Save a copy of all current timers + */ + void saveTimers(); + + /** + * Resetore the set of previously saved timers + */ + void restoreTimers(); +}; + class ExtraCell { public: int _vidTable; diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index e784b873c9..15668b0bc2 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -30,6 +30,8 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _startInvItem = 0; _startInvBox = 0; _invChangeFlag = true; + _invRefreshFlag = false; + _invModeFlag = false; _startAboutItem = 0; _startTravelItem = 0; @@ -59,11 +61,15 @@ void InventoryManager::setUseItem(int itemId) { } void InventoryManager::refreshInventory() { - error("TODO: refreshInventory"); + if (_vm->_screen->_vesaMode) { + _invRefreshFlag = true; + newDisplayInv(); + } } int InventoryManager::newDisplayInv() { - error("TODO: newDisplayInv"); + warning("TODO: newDisplayInv"); + return 0; } diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 399c763483..dddfe2eda1 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -38,6 +38,8 @@ public: int _startInvItem; int _startInvBox; bool _invChangeFlag; + bool _invRefreshFlag; + bool _invModeFlag; int _startAboutItem; int _startTravelItem; public: diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 0e005f936e..72cafde243 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -181,9 +181,9 @@ void Player::walk() { _collideFlag = false; _playerDirection = NONE; - if (_playerOff != 0) + if (_playerOff) return; - else if (_vm->_timerFlag) { + else if (_vm->_timers[0]._flag) { plotCom3(); return; } @@ -640,7 +640,7 @@ void Player::plotCom1() { } void Player::plotCom2() { - if (_playerOff != 1) + if (!_playerOff) _vm->_images.addToList(this); } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 773a42b9d4..cf8da17f05 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -37,6 +37,7 @@ Room::Room(AccessEngine *vm) : Manager(vm) { _tile = nullptr; _selectCommand = 0; _conFlag = false; + _selectCommand = -1; } Room::~Room() { -- cgit v1.2.3 From 5ff004b2d839a4e3a06112916efe0412a5112903 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 11:58:59 -0400 Subject: ACCESS: Fix initialisation of player positioning and scaling values --- engines/access/access.h | 3 --- engines/access/player.cpp | 10 +++++++--- engines/access/player.h | 1 + engines/access/room.cpp | 7 ++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 105b00b0ff..32be053089 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -138,8 +138,6 @@ public: byte *_music; byte *_title; int _converseMode; - int _startAboutItem; - int _startTravelItem; int _startAboutBox; int _startTravelBox; bool _currentCharFlag; @@ -152,7 +150,6 @@ public: int _scaleMaxY; int _scaleI; bool _scaleFlag; - int _playFieldHeight; // Fields that are included in savegames int _conversation; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 72cafde243..79ce2190f3 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -61,6 +61,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { _move = NONE; _playerDirection = NONE; _xFlag = _yFlag = 0; + _inactiveYOff = 0; } Player::~Player() { @@ -168,12 +169,13 @@ void Player::freeSprites() { void Player::calcManScale() { if (!_vm->_manScaleOff) { - _vm->_scale = (((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * - _vm->_scaleT1 + (_vm->_scaleH2 << 8)) / _vm->_scaleH1 * _vm->_scaleI) >> 8; + _vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * + _vm->_scaleT1 + (_vm->_scaleH2 << 8)) & 0xff00) / _vm->_scaleH1 * _vm->_scaleI) >> 8; _vm->_screen->setScaleTable(_vm->_scale); _playerOffset.x = _vm->_screen->_scaleTable1[20]; _playerOffset.y = _vm->_screen->_scaleTable1[67]; + _inactiveYOff = _playerOffset.y; } } @@ -188,6 +190,7 @@ void Player::walk() { return; } + _vm->_timers[0]._flag = true; switch (_move) { case UP: _vm->_events->_mouseMove = false; @@ -646,7 +649,8 @@ void Player::plotCom2() { void Player::plotCom3() { // Update the base ImageEntry fields for the player - _position = _rawPlayer; + _position.x = _rawPlayer.x; + _position.y = _rawPlayer.y - _playerOffset.y; _priority = _playerOffset.y; _spritesPtr = _playerSprites; _frameNumber = _frame; diff --git a/engines/access/player.h b/engines/access/player.h index a291f4589d..a9efff2433 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -57,6 +57,7 @@ private: SpriteResource *_playerSprites1; byte *_manPal1; int _scrollEnd; + int _inactiveYOff; bool codeWalls(); void checkMove(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index cf8da17f05..ccd19b0ed9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -182,14 +182,14 @@ void Room::loadRoomData(const byte *roomData) { _vm->_scaleH1 = roomInfo._scaleH1; _vm->_scaleH2 = roomInfo._scaleH2; _vm->_scaleN1 = roomInfo._scaleN1; - _vm->_scaleT1 = ((_vm->_scaleH2 - _vm->_scaleH1) << 8) / _vm->_scaleN1; + _vm->_scaleT1 = ((_vm->_scaleH1 - _vm->_scaleH2) << 8) / _vm->_scaleN1; if (roomInfo._playFieldFile._fileNum != -1) { loadPlayField(roomInfo._playFieldFile._fileNum, roomInfo._playFieldFile._subfile); setupRoom(); - _vm->_scaleMaxY = _vm->_playFieldHeight << 4; + _vm->_scaleMaxY = _playFieldHeight << 4; } // Load cells @@ -211,7 +211,8 @@ void Room::loadRoomData(const byte *roomData) { _vm->_animation->loadAnimations(data, _vm->_files->_filesize); } - _vm->_scaleI = roomInfo._scaleI; + _vm->_scale = _vm->_scaleI = roomInfo._scaleI; + _vm->_screen->setScaleTable(_vm->_scale); _vm->_player->_scrollThreshold = roomInfo._scrollThreshold; // Handle loading scene palette data -- cgit v1.2.3 From fa099b848094388225b4f7e84ad4a15d7c42ce34 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 15:47:25 -0400 Subject: ACCESS: Implement routine for scaled drawing of player --- engines/access/access.cpp | 6 ++++- engines/access/asurface.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++-- engines/access/asurface.h | 6 ++++- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6a61527ef9..1503e380c2 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -244,6 +244,10 @@ void AccessEngine::plotList1() { bounds.setHeight(_screen->_scaleTable1[frame->h]); } + // Make a copy - some of the drawing methods I've adapted need the full + // scaled dimensions on-screen, and handle clipping themselves + Common::Rect destBounds = bounds; + if (_buffer2.clip(bounds)) { ie._flags |= 1; } else { @@ -261,7 +265,7 @@ void AccessEngine::plotList1() { if (ie._flags & 2) { _buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top)); } else { - _buffer2.sPlotF(frame, Common::Point(bounds.left, bounds.top)); + _buffer2.sPlotF(frame, destBounds); } } else { if (ie._flags & 2) { diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index ed614df974..4abd1aab26 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -82,6 +82,15 @@ SpriteFrame::~SpriteFrame() { /*------------------------------------------------------------------------*/ +ImageEntry::ImageEntry() { + _frameNumber = 0; + _spritesPtr = nullptr; + _priority = 0; + _flags = 0; +} + +/*------------------------------------------------------------------------*/ + static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { return ie1._priority < ie2._priority; } @@ -237,12 +246,59 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { } } +void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { + const int SCALE_LIMIT = 0x100; + int scaleX = SCALE_LIMIT * bounds.width() / this->w; + int scaleY = SCALE_LIMIT * bounds.height() / this->h; + int scaleXCtr = 0, scaleYCtr = 0; + + int y = bounds.top; + for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) { + // Handle skipping lines if Y scaling + scaleYCtr += scaleY; + if (scaleYCtr < SCALE_LIMIT) + continue; + scaleYCtr -= SCALE_LIMIT; + + // Handle off-screen lines + if (y < 0) + continue; + else if (y >= dest->h) + break; + + // Handle drawing the line + byte *pSrc = (byte *)getBasePtr(0, yCtr); + byte *pDest = (byte *)dest->getBasePtr(bounds.left, y); + scaleXCtr = 0; + int x = bounds.left; + + for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) { + // Handle horizontal scaling + scaleXCtr += scaleX; + if (scaleXCtr < SCALE_LIMIT) + continue; + scaleXCtr -= SCALE_LIMIT; + + // Only handle on-scren pixels + if (x >= dest->w) + break; + if (x >= 0 && *pSrc != 0) + *pDest = *pSrc; + + ++pDest; + ++x; + } + + ++y; + } +} + void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) { frame->copyTo(this, pt); } -void ASurface::sPlotF(SpriteFrame *frame, const Common::Point &pt) { - frame->copyTo(this, pt); +void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { + frame->copyTo(this, bounds); } void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index d660ff60b6..365852dadf 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -60,13 +60,15 @@ public: void sPlotB(SpriteFrame *frame, const Common::Point &pt); - void sPlotF(SpriteFrame *frame, const Common::Point &pt); + void sPlotF(SpriteFrame *frame, const Common::Rect &bounds); void plotB(SpriteFrame *frame, const Common::Point &pt); void copyBlock(ASurface *src, const Common::Rect &bounds); void copyTo(ASurface *dest, const Common::Point &destPos); + + void copyTo(ASurface *dest, const Common::Rect &bounds); }; class SpriteFrame : public ASurface { @@ -95,6 +97,8 @@ public: int _priority; Common::Point _position; int _flags; +public: + ImageEntry(); }; class ImageEntryList : public Common::Array { -- cgit v1.2.3 From bca9f14719dda5185c443cae6c16b6a374f50ab2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 16:04:09 -0400 Subject: ACCESS: Fix display of mouse cursor --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/events.cpp | 7 ++++++- engines/access/events.h | 6 +++--- engines/access/room.cpp | 28 +++++++++++++++++----------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 1503e380c2..fde5ab8754 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -170,7 +170,7 @@ void AccessEngine::dummyLoop() { if (_events->_leftButton) { CursorType cursorId = _events->getCursor(); - _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_0 : (CursorType)(cursorId + 1)); + _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1)); } } diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 1b824ac730..042fd415da 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -80,7 +80,7 @@ void AmazonEngine::playGame() { void AmazonEngine::doIntroduction() { _screen->setInitialPalettte(); - _events->setCursor(CURSOR_0); + _events->setCursor(CURSOR_ARROW); _events->showCursor(); _screen->setPanel(0); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 8f02d41547..9c6b45737d 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -36,12 +36,12 @@ namespace Access { EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _cursorId = CURSOR_NONE; + _normalMouse = CURSOR_CROSSHAIRS; _frameCounter = 10; _priorFrameTime = 0; _leftButton = _rightButton = false; _mouseMove = false; _mouseCol = _mouseRow = 0; - _normalMouse = 0; _mouseMode = 0; _cursorExitFlag = false; } @@ -54,6 +54,11 @@ void EventsManager::setCursor(CursorType cursorId) { return; _cursorId = cursorId; + if (_mouseMode == 1 && cursorId == CURSOR_ARROW) + _mouseMode = 2; + else if (_mouseMode == 2 && cursorId != CURSOR_ARROW) + _mouseMode = 1; + // Get a pointer to the mouse data to use, and get the cursor hotspot const byte *srcP = Amazon::CURSORS[cursorId]; int hotspotX = (int16)READ_LE_UINT16(srcP); diff --git a/engines/access/events.h b/engines/access/events.h index 5ca08068f1..c76f62b265 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -31,8 +31,8 @@ namespace Access { enum CursorType { CURSOR_NONE = -1, - CURSOR_0 = 0, CURSOR_1, CURSOR_2, CURSOR_3, CURSOR_EYE, CURSOR_HAND, - CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP + CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_EYE, + CURSOR_HAND, CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP }; #define GAME_FRAME_RATE 50 @@ -51,11 +51,11 @@ private: void nextFrame(); public: CursorType _cursorId; + CursorType _normalMouse; bool _leftButton, _rightButton; Common::Point _mousePos; int _mouseCol, _mouseRow; bool _mouseMove; - int _normalMouse; int _mouseMode; bool _cursorExitFlag; Common::FixedStack _keypresses; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index ccd19b0ed9..dd6f21877c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -131,6 +131,12 @@ void Room::doRoom() { break; } else { _vm->plotList(); + + if (_vm->_events->_mousePos.y < 177) { + _vm->_events->setCursor(_vm->_events->_normalMouse); + } else { + _vm->_events->setCursor(CURSOR_ARROW); + } _vm->copyBlocks(); } } @@ -454,20 +460,20 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = 4; + _vm->_events->_normalMouse = CURSOR_EYE; _vm->_events->_mouseMode = 0; break; case 2: - _vm->_events->_normalMouse = 5; + _vm->_events->_normalMouse = CURSOR_HAND; _vm->_events->_mouseMode = 0; break; case 3: - _vm->_events->_normalMouse = 6; + _vm->_events->_normalMouse = CURSOR_GET; _vm->_events->_mouseMode = 0; break; case 4: - _vm->_events->_normalMouse = 1; - _vm->_events->setCursor(CURSOR_0); + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + _vm->_events->setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; @@ -476,20 +482,20 @@ void Room::executeCommand(int commandId) { } break; case 5: - _vm->_events->_normalMouse = 7; + _vm->_events->_normalMouse = CURSOR_CLIMB; _vm->_events->_mouseMode = 0; break; case 6: - _vm->_events->_normalMouse = 8; + _vm->_events->_normalMouse = CURSOR_TALK; _vm->_events->_mouseMode = 0; break; case 7: - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->_mouseMode = 0; _conFlag = true; @@ -500,7 +506,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->_normalMouse = 9; + _vm->_events->_normalMouse = CURSOR_HELP; _vm->_events->_mouseMode = 0; break; default: @@ -525,7 +531,7 @@ void Room::executeCommand(int commandId) { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->_mouseMode = 4; roomMenu(); } -- cgit v1.2.3 From 0b7078397417a3f54d33cebcd602034c8d0d1a1e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 16:15:48 -0400 Subject: ACCESS: Fix selecting buttons from the bottom of the screen --- engines/access/events.cpp | 6 +++--- engines/access/events.h | 6 +++--- engines/access/room.cpp | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 9c6b45737d..765d57cf35 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -118,7 +118,6 @@ void EventsManager::pollEvents(bool suppressFrames) { Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { - // Handle keypress switch (event.type) { case Common::EVENT_QUIT: case Common::EVENT_RTL: @@ -131,13 +130,15 @@ void EventsManager::pollEvents(bool suppressFrames) { _vm->_debugger->attach(); _vm->_debugger->onFrame(); } else { - + _keypresses.push(event.kbd); } return; case Common::EVENT_KEYUP: return; case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; + _mouseCol = _mousePos.x / 8; + _mouseRow = _mousePos.y / 8; break; case Common::EVENT_LBUTTONDOWN: _leftButton = true; @@ -169,7 +170,6 @@ void EventsManager::checkForNextFrameCounter() { } void EventsManager::nextFrame() { - // Give time to the debugger _vm->_debugger->onFrame(); diff --git a/engines/access/events.h b/engines/access/events.h index c76f62b265..b442b1507b 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -31,11 +31,11 @@ namespace Access { enum CursorType { CURSOR_NONE = -1, - CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_EYE, - CURSOR_HAND, CURSOR_GET, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP + CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, + CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP }; -#define GAME_FRAME_RATE 50 +#define GAME_FRAME_RATE 40 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) class AccessEngine; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index dd6f21877c..796a441a25 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -460,15 +460,15 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = CURSOR_EYE; + _vm->_events->_normalMouse = CURSOR_LOOK; _vm->_events->_mouseMode = 0; break; case 2: - _vm->_events->_normalMouse = CURSOR_HAND; + _vm->_events->_normalMouse = CURSOR_USE; _vm->_events->_mouseMode = 0; break; case 3: - _vm->_events->_normalMouse = CURSOR_GET; + _vm->_events->_normalMouse = CURSOR_TAKE; _vm->_events->_mouseMode = 0; break; case 4: @@ -513,10 +513,12 @@ void Room::executeCommand(int commandId) { break; } + // Draw the default toolbar menu at the bottom of the screen roomMenu(); _vm->_screen->saveScreen(); _vm->_screen->setDisplayScan(); + // Get the toolbar icons resource byte *iconData = _vm->_files->loadFile("ICONS.LZ"); SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); delete[] iconData; -- cgit v1.2.3 From a42e52fb5baa2d9ed9e2d726cfdf0365acd15472 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 17:24:22 -0400 Subject: ACCESS: Implemented code for clicking in room area --- engines/access/amazon/amazon_game.h | 30 +++++++++++------------ engines/access/amazon/amazon_room.cpp | 25 ++++++++++++++++++- engines/access/amazon/amazon_room.h | 3 +++ engines/access/room.cpp | 46 +++++++++++++++++++++++++++++++++++ engines/access/room.h | 7 ++++++ 5 files changed, 95 insertions(+), 16 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index c927ad90d7..848af85f30 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -48,21 +48,6 @@ private: int _inactiveYOff; int _esTabTable[100]; - // Fields that are mapped to flags - int &_guardLocation; - int &_guardFind; - int &_helpLevel; - int &_jasMayaFlag; - int &_moreHelp; - int &_flashbackFlag; - int &_riverFlag; - int &_aniOutFlag; - int &_badEnd; - int &_noHints; - int &_aniFlag; - int &_allenFlag; - int &_noSound; - /** * Do the game introduction */ @@ -93,6 +78,21 @@ protected: * Play the game */ virtual void playGame(); +public: + // Fields that are mapped to flags + int &_guardLocation; + int &_guardFind; + int &_helpLevel; + int &_jasMayaFlag; + int &_moreHelp; + int &_flashbackFlag; + int &_riverFlag; + int &_aniOutFlag; + int &_badEnd; + int &_noHints; + int &_aniFlag; + int &_allenFlag; + int &_noSound; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 405889fe1a..bf3c2501bb 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "access/access.h" #include "access/resources.h" +#include "access/amazon/amazon_game.h" #include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_room.h" @@ -31,6 +32,7 @@ namespace Access { namespace Amazon { AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { + _game = (AmazonEngine *)vm; _antOutFlag = false; _icon = nullptr; } @@ -140,7 +142,28 @@ void AmazonRoom::roomMenu() { } void AmazonRoom::mainAreaClick() { - + if (_selectCommand == -1) { + if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 || + _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) { + switch (checkBoxes1(_vm->_events->_mousePos)) { + case 0: + _game->_jasMayaFlag = 0; + break; + case 1: + _game->_jasMayaFlag = 1; + break; + default: + break; + } + } + } else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd && + _vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide && + _vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd && + _vm->_events->_mousePos.y <= _vm->_screen->_vWindowLinesTall) { + if (checkBoxes1(_vm->_events->_mousePos) >= 0) { + checkBoxes3(); + } + } } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 838b108fb5..c7d8e0c0ae 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -32,8 +32,11 @@ class AccessEngine; namespace Amazon { +class AmazonEngine; + class AmazonRoom : public Room { private: + AmazonEngine *_game; bool _antOutFlag; const byte *_icon; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 796a441a25..4da207b290 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -538,6 +538,52 @@ void Room::commandOff() { roomMenu(); } +int Room::checkBoxes() { + return checkBoxes1(_vm->_player->_rawPlayer); +} + +int Room::checkBoxes1(const Common::Point &pt) { + return checkBoxes2(pt, 0, _plotter._blocks.size()); +} + +int Room::checkBoxes2(const Common::Point &pt, int start, int count) { + for (; count > 0; --count, ++start) { + if (_plotter._blocks[start].contains(pt)) { + _plotter._blockIn = start; + return start; + } + } + + return -1; +} + +void Room::checkBoxes3() { + for (int start = 0; start < _plotter._blocks.size(); ++start) { + if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { + _plotter._blockIn = start; + if (!(validateBox(start) & 0x80)) { + _vm->_events->debounceLeft(); + _vm->_boxSelect = start; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + + _vm->_boxSelect = -1; + return; + } + } + } +} + +int Room::validateBox(int boxId) { + _vm->_scripts->_sequence = boxId; + _vm->_scripts->searchForSequence(); + return _vm->_scripts->executeScript(); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { diff --git a/engines/access/room.h b/engines/access/room.h index 00de53f0a7..19c3cc423b 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -86,6 +86,13 @@ protected: */ void handleCommand(int commandId); + int checkBoxes(); + int checkBoxes1(const Common::Point &pt); + int checkBoxes2(const Common::Point &pt, int start, int count); + void checkBoxes3(); + + int validateBox(int boxId); + /** * Inner handler for switching to a given command mode */ -- cgit v1.2.3 From 8d6c8ed452bc60a963774ea7a26ff92472752d63 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 20:26:17 -0400 Subject: ACCESS: Beginnings of code for text bubble drawing --- engines/access/access.h | 1 + engines/access/asurface.cpp | 21 ++++++++++++++++++ engines/access/asurface.h | 12 +++++++++- engines/access/data.h | 13 +++++++++++ engines/access/events.cpp | 3 +++ engines/access/events.h | 2 ++ engines/access/room.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++ engines/access/room.h | 24 ++++++++++++++++++++ engines/access/scripts.cpp | 27 ++++++++++++++++++++--- engines/access/scripts.h | 2 +- 10 files changed, 154 insertions(+), 5 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 32be053089..511cce835c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -125,6 +125,7 @@ public: int _establishGroup; int _numAnimTimers; TimerList _timers; + Font _font; Common::Array _newRects; Common::Array _oldRects; Common::Array _extraCells; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 4abd1aab26..32e54036ad 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -127,6 +127,7 @@ void ASurface::init() { ASurface::~ASurface() { free(); + _savedBlock.free(); } void ASurface::clearBuffer() { @@ -309,4 +310,24 @@ void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { copyRectToSurface(*src, bounds.left, bounds.top, bounds); } +void ASurface::saveBlock(const Common::Rect &bounds) { + _savedBounds = bounds; + _savedBounds.clip(Common::Rect(0, 0, this->w, this->h)); + + _savedBlock.free(); + _savedBlock.create(bounds.width(), bounds.height(), + Graphics::PixelFormat::createFormatCLUT8()); + _savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds); +} + +void ASurface::restoreBlock() { + if (!_savedBounds.isEmpty()) { + copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top, + Common::Rect(0, 0, _savedBlock.w, _savedBlock.h)); + + _savedBlock.free(); + _savedBounds = Common::Rect(0, 0, 0, 0); + } +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 365852dadf..1efee28494 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -36,6 +36,9 @@ class SpriteResource; class SpriteFrame; class ASurface : public Graphics::Surface { +private: + Graphics::Surface _savedBlock; + Common::Rect _savedBounds; public: static int _leftSkip, _rightSkip; static int _topSkip, _bottomSkip; @@ -46,7 +49,8 @@ public: static void init(); public: - virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); + Common::Point _printOrg; + Common::Point _printStart; public: virtual ~ASurface(); @@ -69,6 +73,12 @@ public: void copyTo(ASurface *dest, const Common::Point &destPos); void copyTo(ASurface *dest, const Common::Rect &bounds); + + void saveBlock(const Common::Rect &bounds); + + void restoreBlock(); + + virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); }; class SpriteFrame : public ASurface { diff --git a/engines/access/data.h b/engines/access/data.h index 67b9cfe9fd..93184563c4 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -78,6 +78,19 @@ public: int _vidSTable1; }; +struct FontVal { +public: + int _lo, _hi; + + FontVal() { _lo = _hi = 0; } +}; + +class Font { +public: + FontVal _charSet; + FontVal _charFor; +}; + } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 765d57cf35..521e8895c8 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -204,5 +204,8 @@ void EventsManager::debounceLeft() { } } +void EventsManager::waitKeyMouse() { + error("TODO: waitKeyPress"); +} } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index b442b1507b..dc89829312 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -104,6 +104,8 @@ public: void delay(int time); void debounceLeft(); + + void waitKeyMouse(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 4da207b290..9969f336fd 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,6 +584,34 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } +void Room::placeBubble() { + _bubbleBox._maxChars = 27; + placeBubble1(); +} + +void Room::placeBubble1() { + _bubbleBox.clearBubbles(); + _vm->_font._charSet._lo = 1; + _vm->_font._charSet._hi = 8; + _vm->_font._charFor._lo = 29; + _vm->_font._charFor._hi = 32; + + calcBubble(); + + Common::Rect r = _bubbleBox._bubbles[0]; + r.translate(-2, 0); + _vm->_screen->saveBlock(r); + printBubble(); +} + +void Room::calcBubble() { + error("TODO: calcBubble"); +} + +void Room::printBubble() { + error("TODO: printBubble"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -642,4 +670,30 @@ RoomInfo::RoomInfo(const byte *data) { } } +/*------------------------------------------------------------------------*/ + +BubbleBox::BubbleBox() { + _field0 = 2; + _bounds = Common::Rect(64, 32, 130, 122); + _bubblePtr = -1; + _maxChars = 0; +} + +void BubbleBox::load(Common::SeekableReadStream *stream) { + _bubbleTit.clear(); + + byte v; + do { + v = stream->readByte(); + _bubbleTit.push_back(v); + } while (v != 0); + + _bubblePtr = 0; +} + +void BubbleBox::clearBubbles() { + _bubbles.clear(); +} + + } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index 19c3cc423b..9b26ed24e8 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -58,6 +58,22 @@ public: } }; +class BubbleBox { +public: + int _field0; + Common::Rect _bounds; + Common::Array _bubbleTit; + int _bubblePtr; + int _maxChars; + Common::Array _bubbles; +public: + BubbleBox(); + + void load(Common::SeekableReadStream *stream); + + void clearBubbles(); +}; + class Room: public Manager { private: void roomLoop(); @@ -114,6 +130,7 @@ protected: public: Plotter _plotter; Common::Array _jetFrame; + BubbleBox _bubbleBox; int _function; int _roomFlag; byte *_playField; @@ -141,6 +158,13 @@ public: void buildRow(int playY, int screenY); void init4Quads(); + + void placeBubble(); + void placeBubble1(); + + void calcBubble(); + + void printBubble(); }; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0cfce787a9..0c3cd2e92a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -87,7 +87,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, - &Scripts::CMDPRINT, &Scripts::cmdRetPos, &Scripts::cmdAnim, + &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, @@ -116,7 +116,11 @@ void Scripts::executeCommand(int commandIndex) { (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::CMDOBJECT() { error("TODO CMDOBJECT"); } +void Scripts::CMDOBJECT() { + byte id; + + _vm->_room->_bubbleBox.load(_data); +} void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); } @@ -165,7 +169,24 @@ void Scripts::cmdJumpTalk() { void Scripts::cmdNull() { } -void Scripts::CMDPRINT() { error("TODO CMDPRINT"); } +#define PRINT_TIMER 25 + +void Scripts::cmdPrint() { + _vm->_screen->_printOrg = Common::Point(20, 42); + _vm->_screen->_printStart = Common::Point(20, 42); + _vm->_timers[PRINT_TIMER]._timer = 50; + _vm->_timers[PRINT_TIMER]._initTm = 50; + _vm->_timers[PRINT_TIMER]._flag = true; + + _vm->_room->placeBubble(); + _vm->_events->waitKeyMouse(); + + while (_vm->_timers[PRINT_TIMER]._flag) { + _vm->_events->pollEvents(); + } + + _vm->_screen->restoreBlock(); +} void Scripts::cmdRetPos() { _endFlag = true; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 0916b9e9b1..78e54f56c6 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -52,7 +52,7 @@ protected: void cmdJumpUse(); void cmdJumpTalk(); void cmdNull(); - void CMDPRINT(); + void cmdPrint(); void cmdRetPos(); void cmdAnim(); void cmdSetFlag(); -- cgit v1.2.3 From f784b4efba7518806195f96d0177ccdc6e2dbaf8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 22:18:53 -0400 Subject: ACCESS: Added data for font2 and font6x6 --- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 6 +- engines/access/amazon/amazon_resources.cpp | 180 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 8 ++ engines/access/asurface.h | 3 - engines/access/data.cpp | 34 ++++++ engines/access/data.h | 31 +++++ engines/access/room.cpp | 25 +++- engines/access/scripts.cpp | 4 +- 9 files changed, 281 insertions(+), 12 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 511cce835c..fa2d24ec44 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -125,7 +125,7 @@ public: int _establishGroup; int _numAnimTimers; TimerList _timers; - Font _font; + FontManager _fonts; Common::Array _newRects; Common::Array _oldRects; Common::Array _extraCells; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 042fd415da..072675c55e 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -172,7 +172,11 @@ void AmazonEngine::setupGame() { _timers.push_back(te); } - // Set miscellaneous fields + // Miscellaenous + _fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA); + _fonts._font2.load(FONT2_INDEX, FONT2_DATA); + + // Set player room and position _player->_roomNumber = 4; _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 15cf190d4a..b7a2472a3c 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1007,6 +1007,186 @@ const char *const INVENTORY_NAMES[] = { "JASON'S CAR KEYS", "PESO BILLS", "PLANK" }; +const int FONT2_INDEX[] = { + 62, 2, 6, + 0x0000, 0x0019, 0x0021, 0x002e, 0x0041, 0x005a, 0x0073, 0x008c, 0x0093, 0x009b, + 0x00a3, 0x00bc, 0x00d5, 0x00dd, 0x00ea, 0x00f1, 0x00fe, 0x010b, 0x0118, 0x0125, + 0x0132, 0x013f, 0x014c, 0x0159, 0x0166, 0x0173, 0x0180, 0x0187, 0x018e, 0x01a7, + 0x01b4, 0x01cd, 0x01dc, 0x01f5, 0x0208, 0x0215, 0x0222, 0x022f, 0x023c, 0x0249, + 0x025c, 0x0269, 0x0276, 0x0285, 0x0292, 0x029f, 0x02b2, 0x02c5, 0x02d2, 0x02df, + 0x02ee, 0x02fb, 0x0308, 0x0315, 0x0322, 0x032f, 0x0342, 0x034f, 0x0362, 0x036f, + 0x0388, 0x03a1, +}; + +const byte FONT2_DATA[] = { + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xf0, 0xf0, 0xf0, 0xf0, + 0x00, 0xf0, 0x00, 0x06, 0xf3, 0xc0, 0xc3, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x07, 0x1c, 0x00, + 0x67, 0x9e, 0xc0, 0x07, 0x1c, 0x00, 0x67, 0x9e, 0xc0, 0x07, + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x09, 0x02, 0xc0, 0x00, 0x3f, + 0xfc, 0x00, 0xb2, 0xc0, 0x00, 0x3f, 0xfc, 0x00, 0x02, 0xcb, + 0x00, 0x3f, 0xfc, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x18, 0x60, + 0x70, 0x70, 0x60, 0x1c, 0x00, 0x04, 0x60, 0x18, 0x1c, 0x1c, + 0x1c, 0x70, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x30, + 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf0, 0xf0, + 0x00, 0x07, 0x00, 0xf0, 0x03, 0xc0, 0x0f, 0x00, 0x3c, 0x00, + 0xf0, 0x00, 0x00, 0x00, 0x07, 0x3f, 0xc0, 0x70, 0x70, 0x70, + 0x70, 0x70, 0x70, 0x3f, 0xc0, 0x00, 0x00, 0x07, 0x1f, 0x00, + 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0xff, 0xf0, 0x00, 0x00, + 0x08, 0x2b, 0xf0, 0xb0, 0x2c, 0x00, 0xa0, 0x0a, 0x00, 0xff, + 0xfc, 0x00, 0x00, 0x07, 0xff, 0xc0, 0x00, 0x70, 0x03, 0xc0, + 0x00, 0x70, 0xff, 0xc0, 0x00, 0x00, 0x07, 0x0b, 0xc0, 0x2d, + 0xc0, 0xb1, 0xc0, 0xaa, 0xa0, 0x01, 0xc0, 0x00, 0x00, 0x07, + 0xff, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x00, 0xb0, 0xbf, 0xc0, + 0x00, 0x00, 0x07, 0x2f, 0xc0, 0x70, 0x00, 0x7f, 0xc0, 0x70, + 0x70, 0x3f, 0xc0, 0x00, 0x00, 0x08, 0xff, 0xfc, 0x00, 0xb0, + 0x02, 0xc0, 0x02, 0xc0, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x2f, + 0xf0, 0xb0, 0x1c, 0x2f, 0xf0, 0xb0, 0x1c, 0x2f, 0xf0, 0x00, + 0x00, 0x07, 0x3f, 0xc0, 0x70, 0x70, 0x3f, 0xf0, 0x00, 0x70, + 0x3f, 0xc0, 0x00, 0x00, 0x03, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, + 0x00, 0x03, 0xf0, 0xf0, 0x00, 0xf0, 0x30, 0x00, 0x09, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x00, + 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x06, 0xff, 0x00, 0x03, 0xc0, 0x0f, 0x00, 0x3c, 0x00, + 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0a, 0x00, 0x40, 0x00, 0x01, 0xf0, 0x00, 0x07, 0x1c, + 0x00, 0x1f, 0xff, 0x00, 0x70, 0x01, 0xc0, 0x00, 0x00, 0x00, + 0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xf0, 0x70, 0x1c, 0x6a, + 0xb0, 0x00, 0x00, 0x08, 0x2f, 0xfc, 0x70, 0x00, 0x70, 0x00, + 0x70, 0x00, 0x2a, 0xa8, 0x00, 0x00, 0x08, 0x7f, 0xf0, 0x70, + 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x6a, 0xb0, 0x00, 0x00, 0x07, + 0x7f, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x70, 0x00, 0x6a, 0xa0, + 0x00, 0x00, 0x07, 0x7f, 0xf0, 0x70, 0x00, 0x7f, 0xc0, 0x70, + 0x00, 0x60, 0x00, 0x00, 0x00, 0x09, 0x3f, 0xfc, 0x00, 0x70, + 0x00, 0x00, 0x70, 0xff, 0x00, 0x70, 0x1c, 0x00, 0x2a, 0xbc, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x70, 0x1c, 0x70, 0x1c, 0x7f, + 0xfc, 0x70, 0x1c, 0x70, 0x1c, 0x00, 0x00, 0x07, 0xff, 0xf0, + 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0xaa, 0xa0, 0x00, 0x00, + 0x08, 0x0f, 0xfc, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x70, + 0x70, 0x2a, 0x40, 0x00, 0x00, 0x08, 0x70, 0x2c, 0x72, 0xc0, + 0x7f, 0x00, 0x72, 0xc0, 0x70, 0x28, 0x00, 0x00, 0x07, 0x70, + 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x6a, 0xa0, 0x00, + 0x00, 0x0a, 0x70, 0x02, 0xc0, 0x7c, 0x09, 0xc0, 0x77, 0x2d, + 0xc0, 0x71, 0xb1, 0xc0, 0x60, 0xc1, 0x80, 0x00, 0x00, 0x00, + 0x09, 0x70, 0x07, 0x00, 0x77, 0x07, 0x00, 0x71, 0xc7, 0x00, + 0x70, 0x77, 0x00, 0x60, 0x06, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x2f, 0xf0, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x2a, 0xa0, + 0x00, 0x00, 0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xf0, 0x70, + 0x00, 0x60, 0x00, 0x00, 0x00, 0x08, 0x2f, 0xf0, 0x70, 0x1c, + 0x70, 0x1c, 0x71, 0xdc, 0x2a, 0xa0, 0x00, 0x1c, 0x00, 0x00, + 0x08, 0x7f, 0xf0, 0x70, 0x1c, 0x7f, 0xc0, 0x70, 0x70, 0x60, + 0x18, 0x00, 0x00, 0x07, 0x2f, 0xf0, 0x70, 0x00, 0x2f, 0xc0, + 0x00, 0xb0, 0xbf, 0xc0, 0x00, 0x00, 0x07, 0xff, 0xf0, 0x0b, + 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x08, + 0x70, 0x1c, 0x70, 0x1c, 0x70, 0x1c, 0x70, 0xdc, 0x1f, 0x1c, + 0x00, 0x00, 0x08, 0xf0, 0x1c, 0xb0, 0x1c, 0x70, 0xb0, 0x72, + 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x0b, 0xf0, 0x00, 0xb0, 0xb0, + 0x00, 0x70, 0x70, 0xc0, 0x70, 0x72, 0x72, 0xc0, 0x7c, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x08, 0xf0, 0x3c, 0x1c, 0xe0, 0x07, + 0xc0, 0x1c, 0x70, 0x70, 0x1c, 0x00, 0x00, 0x09, 0x70, 0x07, + 0x00, 0x1c, 0x1c, 0x00, 0x07, 0xf0, 0x00, 0x01, 0xc0, 0x00, + 0x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xfc, 0x00, + 0x70, 0x07, 0x00, 0x1c, 0x00, 0xaa, 0xac, 0x00, 0x00, 0x09, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +const int FONT6x6_INDEX[] = { + 62, 1, 6, + 0x0000, 0x0007, 0x000e, 0x0015, 0x001c, 0x0023, 0x002a, 0x0031, 0x0038, 0x003f, + 0x0046, 0x004d, 0x0054, 0x005b, 0x0062, 0x0069, 0x0070, 0x0077, 0x007e, 0x0085, + 0x008c, 0x0093, 0x009a, 0x00a1, 0x00a8, 0x00af, 0x00b6, 0x00bd, 0x00c4, 0x00cb, + 0x00d2, 0x00d9, 0x00e0, 0x00e7, 0x00ee, 0x00f5, 0x00fc, 0x0103, 0x010a, 0x0111, + 0x0118, 0x011f, 0x0126, 0x012d, 0x0134, 0x013b, 0x0142, 0x0149, 0x0150, 0x0157, + 0x015e, 0x0165, 0x016c, 0x0173, 0x017a, 0x0181, 0x0188, 0x018f, 0x0196, 0x019d, + 0x01a4, 0x01ab, +}; + +const byte FONT6x6_DATA[] = { + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x30, 0x30, + 0x30, 0x30, 0x00, 0x30, 0x06, 0xd8, 0xd8, 0x90, 0x00, 0x00, + 0x00, 0x06, 0x50, 0xf8, 0x50, 0xf8, 0x50, 0x00, 0x06, 0x78, + 0xa0, 0x70, 0x28, 0xf0, 0x20, 0x06, 0xc8, 0xd0, 0x20, 0x58, + 0x98, 0x00, 0x06, 0x60, 0xd0, 0x60, 0xe8, 0xd0, 0x68, 0x06, + 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x06, 0x30, 0x60, 0x60, + 0x60, 0x30, 0x00, 0x07, 0x30, 0x18, 0x18, 0x18, 0x30, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x20, 0x20, + 0xf8, 0x20, 0x20, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x30, + 0x60, 0x06, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x06, 0x00, + 0x00, 0x00, 0x60, 0x60, 0x00, 0x06, 0x18, 0x30, 0x60, 0xc0, + 0x80, 0x00, 0x06, 0x70, 0x98, 0xa8, 0xc8, 0x70, 0x00, 0x06, + 0x10, 0x30, 0x10, 0x10, 0x10, 0x00, 0x06, 0xf0, 0x08, 0x70, + 0x80, 0xf8, 0x00, 0x06, 0xf0, 0x08, 0x70, 0x08, 0xf0, 0x00, + 0x06, 0x30, 0x50, 0x90, 0xf8, 0x10, 0x00, 0x06, 0xf0, 0x80, + 0xf0, 0x08, 0xf0, 0x00, 0x06, 0x70, 0x80, 0xf0, 0x88, 0x70, + 0x00, 0x06, 0xf8, 0x08, 0x10, 0x20, 0x20, 0x00, 0x06, 0x70, + 0x88, 0x70, 0x88, 0x70, 0x00, 0x06, 0x70, 0x88, 0x78, 0x08, + 0x70, 0x00, 0x06, 0x60, 0x60, 0x00, 0x60, 0x60, 0x00, 0x06, + 0x60, 0x60, 0x00, 0x60, 0x20, 0x40, 0x06, 0x18, 0x30, 0x60, + 0x30, 0x18, 0x00, 0x06, 0x00, 0x78, 0x00, 0x78, 0x00, 0x00, + 0x06, 0x60, 0x30, 0x18, 0x30, 0x60, 0x00, 0x06, 0x70, 0x98, + 0x30, 0x30, 0x00, 0x30, 0x06, 0x70, 0x88, 0xb8, 0xb0, 0x80, + 0x78, 0x06, 0x70, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x06, 0xf0, + 0x88, 0xf0, 0x88, 0xf0, 0x00, 0x06, 0x78, 0x80, 0x80, 0x80, + 0x78, 0x00, 0x06, 0xf0, 0x88, 0x88, 0x88, 0xf0, 0x00, 0x06, + 0xf8, 0x80, 0xf0, 0x80, 0xf8, 0x00, 0x06, 0xf8, 0x80, 0xf0, + 0x80, 0x80, 0x00, 0x06, 0x78, 0x80, 0x98, 0x88, 0x78, 0x00, + 0x06, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x06, 0x70, 0x20, + 0x20, 0x20, 0x70, 0x00, 0x06, 0x08, 0x08, 0x08, 0x88, 0x70, + 0x00, 0x06, 0x90, 0xa0, 0xc0, 0xa0, 0x90, 0x00, 0x06, 0x80, + 0x80, 0x80, 0x80, 0xf0, 0x00, 0x06, 0x88, 0xd8, 0xa8, 0x88, + 0x88, 0x00, 0x06, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x00, 0x06, + 0x70, 0x88, 0x88, 0x88, 0x70, 0x00, 0x06, 0xf0, 0x88, 0xf0, + 0x80, 0x80, 0x00, 0x06, 0x70, 0x88, 0x88, 0x88, 0x70, 0x18, + 0x06, 0xf0, 0x88, 0xf0, 0xa0, 0x98, 0x00, 0x06, 0x78, 0x80, + 0x70, 0x08, 0xf0, 0x00, 0x06, 0xf8, 0x20, 0x20, 0x20, 0x20, + 0x00, 0x06, 0x88, 0x88, 0x88, 0x88, 0x78, 0x00, 0x06, 0x88, + 0x88, 0x88, 0x50, 0x20, 0x00, 0x06, 0x88, 0x88, 0xa8, 0xd8, + 0x88, 0x00, 0x06, 0x88, 0x50, 0x20, 0x50, 0x88, 0x00, 0x06, + 0x88, 0x88, 0x50, 0x20, 0x20, 0x00, 0x06, 0xf8, 0x10, 0x20, + 0x40, 0xf8, 0x00, 0x06, 0x78, 0x60, 0x60, 0x60, 0x78, 0x00, + 0x06, 0xc0, 0x60, 0x30, 0x18, 0x08, 0x00, 0x06, 0x78, 0x18, + 0x18, 0x18, 0x78, 0x00, 0x00, 0x52, 0x41, 0x54, 0x00, 0x41, + 0x4c, 0x43, 0x4f, 0x48, 0x4f, 0x4c, 0x00, 0x53, 0x41, 0x46, + 0x45, 0x20, 0x43, 0x4f, 0x4d, 0x42, 0x49, 0x4e, 0x41, 0x54, + 0x49, 0x4f, 0x4e, 0x00, 0x42, 0x45, 0x41, 0x4b, 0x45, 0x52, + 0x00, 0x4d, 0x49, 0x43, 0x52, 0x4f, 0x46, 0x49, 0x4c, 0x4d, + 0x00, 0x56, 0x41, 0x55, 0x4c, 0x54, 0x20, 0x4b, 0x45, 0x59, + 0x00, 0x42, 0x4f, 0x4c, 0x54, 0x20, 0x43, 0x55, 0x54, 0x54, + 0x45, 0x52, 0x53, 0x00, 0x42, 0x4c, 0x4f, 0x57, 0x47, 0x55, + 0x4e, 0x00, 0x4c, 0x4f, 0x56, 0x45, 0x20, 0x50, 0x4f, 0x54, + 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x4e, 0x45, 0x59, 0x00, + 0x44, 0x41, 0x52, 0x54, 0x53, 0x00, 0x54, 0x41, 0x50, 0x45, + 0x00, 0x4a, 0x55, 0x4e, 0x47, 0x4c, 0x45, 0x20, 0x50, 0x4f, + 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49, +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index c9e3fe98e6..838bd29b70 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -41,6 +41,14 @@ extern const byte *CHARTBL[]; extern const char *const INVENTORY_NAMES[]; +extern const int FONT2_INDEX[]; + +extern const byte FONT2_DATA[]; + +extern const int FONT6x6_INDEX[]; + +extern const byte FONT6x6_DATA[]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 1efee28494..85550d9eee 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -48,9 +48,6 @@ public: static int _scrollX, _scrollY; static void init(); -public: - Common::Point _printOrg; - Common::Point _printStart; public: virtual ~ASurface(); diff --git a/engines/access/data.cpp b/engines/access/data.cpp index f5dbbb367f..1f8b33ef43 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -44,4 +44,38 @@ void TimerList::restoreTimers() { } } +/*------------------------------------------------------------------------*/ + +Font::Font() { +} + +void Font::load(const int *index, const byte *data) { + int count = index[0]; + _v1 = index[1]; + _v2 = index[2]; + + _chars.clear(); + for (int idx = 0; idx < count; ++idx) + _chars.push_back(data + index[idx + 3]); +} + +int Font::charWidth(char c) { + error("TODO"); +} + +int Font::stringWidth(const Common::String &msg) { + int total = 0; + + for (const char *c = msg.c_str(); *c != '\0'; ++c) + total += charWidth(*c); + + return 0; +} + +/*------------------------------------------------------------------------*/ + +FontManager::FontManager() { + _printMaxX = 0; +} + } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 93184563c4..6d783b15dc 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -86,9 +86,40 @@ public: }; class Font { +private: + int _v1; + int _v2; + Common::Array _chars; +public: + Font(); + + /** + * Load the given font data + */ + void load(const int *index, const byte *data); + + /** + * Get the width of a given character + */ + int charWidth(char c); + + /** + * Get the width of a given string + */ + int stringWidth(const Common::String &msg); +}; + +class FontManager { public: FontVal _charSet; FontVal _charFor; + Common::Point _printOrg; + Common::Point _printStart; + int _printMaxX; + Font _font6x6; + Font _font2; +public: + FontManager(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9969f336fd..74a30d8f2a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -591,10 +591,10 @@ void Room::placeBubble() { void Room::placeBubble1() { _bubbleBox.clearBubbles(); - _vm->_font._charSet._lo = 1; - _vm->_font._charSet._hi = 8; - _vm->_font._charFor._lo = 29; - _vm->_font._charFor._hi = 32; + _vm->_fonts._charSet._lo = 1; + _vm->_fonts._charSet._hi = 8; + _vm->_fonts._charFor._lo = 29; + _vm->_fonts._charFor._hi = 32; calcBubble(); @@ -605,10 +605,25 @@ void Room::placeBubble1() { } void Room::calcBubble() { - error("TODO: calcBubble"); + Common::Point printOrg = _vm->_fonts._printOrg; + Common::Point printStart = _vm->_fonts._printStart; + + Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + + if (_bubbleBox._field0 == 4) { + _vm->_fonts._printMaxX = 110; + } else { + + } + + + + _vm->_fonts._printOrg = printOrg; + _vm->_fonts._printStart = printStart; } void Room::printBubble() { + //drawBubble(_bubbleBox._bubbles.size() - 1); error("TODO: printBubble"); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0c3cd2e92a..2f221d9f52 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -172,8 +172,8 @@ void Scripts::cmdNull() { #define PRINT_TIMER 25 void Scripts::cmdPrint() { - _vm->_screen->_printOrg = Common::Point(20, 42); - _vm->_screen->_printStart = Common::Point(20, 42); + _vm->_fonts._printOrg = Common::Point(20, 42); + _vm->_fonts._printStart = Common::Point(20, 42); _vm->_timers[PRINT_TIMER]._timer = 50; _vm->_timers[PRINT_TIMER]._initTm = 50; _vm->_timers[PRINT_TIMER]._flag = true; -- cgit v1.2.3 From ff01ee6807ccd6e5a71ddc945196d68b87f3aa65 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 16 Aug 2014 23:18:53 -0400 Subject: ACCESS: Added code for bubble box size calculations --- engines/access/data.cpp | 41 ++++++++++++++++++++++++++- engines/access/data.h | 11 ++++++++ engines/access/room.cpp | 73 +++++++++++++++++++++++++++++++++++++++---------- engines/access/room.h | 10 +++++-- 4 files changed, 117 insertions(+), 18 deletions(-) diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 1f8b33ef43..65702db9f1 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -60,7 +60,7 @@ void Font::load(const int *index, const byte *data) { } int Font::charWidth(char c) { - error("TODO"); + return *_chars[c - ' ']; } int Font::stringWidth(const Common::String &msg) { @@ -72,6 +72,45 @@ int Font::stringWidth(const Common::String &msg) { return 0; } +bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) { + width = 0; + const char *src = s.c_str(); + char c; + + while ((c = *src) != '\0') { + if (c == '\r') { + // End of line, so return calculated line + line = Common::String(s.c_str(), src - 1); + s = Common::String(src + 1); + return false; + } + + ++src; + width += charWidth(c); + if (width < maxWidth) + continue; + + // Reached maximum allowed. Work backwards to find space at the + // start of the current word as a point to split the line on + while (*src != ' ' && src >= s.c_str()) { + width -= charWidth(*src); + --src; + } + if (src < s.c_str()) + error("Could not fit line"); + + // Split the line around the space + line = Common::String(s.c_str(), src - 1); + s = Common::String(src + 1); + return false; + } + + // Return entire string + line = s; + s = Common::String(); + return true; +} + /*------------------------------------------------------------------------*/ FontManager::FontManager() { diff --git a/engines/access/data.h b/engines/access/data.h index 6d783b15dc..910e2523d1 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -107,6 +107,17 @@ public: * Get the width of a given string */ int stringWidth(const Common::String &msg); + + /** + * Get a partial string that will fit in a given width + * @param s Source string. Modified to remove line + * @param maxWidth Maximum width allowed + * @param line Output line + * @param width Calculated width of returned line + * @returns True if last line + */ + bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width); + }; class FontManager { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 74a30d8f2a..b46363b32d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -558,7 +558,7 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) { } void Room::checkBoxes3() { - for (int start = 0; start < _plotter._blocks.size(); ++start) { + for (uint start = 0; start < _plotter._blocks.size(); ++start) { if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { _plotter._blockIn = start; if (!(validateBox(start) & 0x80)) { @@ -571,7 +571,7 @@ void Room::checkBoxes3() { _vm->_scripts->executeScript(); } - _vm->_boxSelect = -1; + _vm->_boxSelect = true; return; } } @@ -605,19 +605,57 @@ void Room::placeBubble1() { } void Room::calcBubble() { + // Save points Common::Point printOrg = _vm->_fonts._printOrg; Common::Point printStart = _vm->_fonts._printStart; - Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); - - if (_bubbleBox._field0 == 4) { + // Figure out maximum width allowed + if (_bubbleBox._type == 4) { _vm->_fonts._printMaxX = 110; } else { - + _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr); } + // Start of with a rect with the given starting x and y + Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + + // Loop through getting lines + Common::String msg(_bubbleBox._bubblePtr); + Common::String line; + int width = 0; + bool lastLine; + do { + lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); + width = MIN(width, _vm->_fonts._printMaxX); + + _vm->_fonts._printOrg.y += 6; + _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + } while (!lastLine); + + if (_bubbleBox._type == 4) + ++_vm->_fonts._printOrg.y += 6; + // Determine the width for the area + width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; + if (width >= 24) + width += 20 - ((width - 24) % 20); + bounds.setWidth(width); + // Determine the height for area + int y = _vm->_fonts._printOrg.y + 6; + if (_bubbleBox._type == 4) + y += 6; + int height = y - bounds.top; + bounds.setHeight(height); + + height -= (_bubbleBox._type == 4) ? 30 : 24; + if (height >= 0) + bounds.setHeight(bounds.height() + 13 - (height % 13)); + + // Add the new bounds to the bubbles list + _bubbleBox._bubbles.push_back(bounds); + + // Restore points _vm->_fonts._printOrg = printOrg; _vm->_fonts._printStart = printStart; } @@ -627,6 +665,15 @@ void Room::printBubble() { error("TODO: printBubble"); } +void Room::drawBubble(int index) { + _bubbleBox._bounds = _bubbleBox._bubbles[index]; + doBox(); +} + +void Room::doBox() { + error("TODO: doBox"); +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -688,22 +735,20 @@ RoomInfo::RoomInfo(const byte *data) { /*------------------------------------------------------------------------*/ BubbleBox::BubbleBox() { - _field0 = 2; + _type = 2; _bounds = Common::Rect(64, 32, 130, 122); - _bubblePtr = -1; + _bubblePtr = nullptr; _maxChars = 0; } void BubbleBox::load(Common::SeekableReadStream *stream) { - _bubbleTit.clear(); + _bubbleTitle.clear(); byte v; - do { - v = stream->readByte(); - _bubbleTit.push_back(v); - } while (v != 0); + while ((v = stream->readByte()) != 0) + _bubbleTitle += (char)v; - _bubblePtr = 0; + _bubblePtr = _bubbleTitle.c_str(); } void BubbleBox::clearBubbles() { diff --git a/engines/access/room.h b/engines/access/room.h index 9b26ed24e8..3035561892 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -60,10 +60,10 @@ public: class BubbleBox { public: - int _field0; + int _type; Common::Rect _bounds; - Common::Array _bubbleTit; - int _bubblePtr; + Common::String _bubbleTitle; + const char *_bubblePtr; int _maxChars; Common::Array _bubbles; public: @@ -165,6 +165,10 @@ public: void calcBubble(); void printBubble(); + + void drawBubble(int index); + + void doBox(); }; -- cgit v1.2.3 From 1ab89400e52da33207a14051410fad01c257d14c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Aug 2014 10:39:00 +0200 Subject: ACCESS: Remove two unused variables --- engines/access/asurface.cpp | 1 - engines/access/scripts.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 32e54036ad..08caa8a3b2 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -253,7 +253,6 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { int scaleY = SCALE_LIMIT * bounds.height() / this->h; int scaleXCtr = 0, scaleYCtr = 0; - int y = bounds.top; for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) { // Handle skipping lines if Y scaling scaleYCtr += scaleY; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2f221d9f52..a4d67c87f1 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -117,8 +117,6 @@ void Scripts::executeCommand(int commandIndex) { } void Scripts::CMDOBJECT() { - byte id; - _vm->_room->_bubbleBox.load(_data); } -- cgit v1.2.3 From 3e61eb9cc3f233fabf34f54069a1a1209e257008 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Aug 2014 11:16:31 +0200 Subject: ACCESS: Implement some opcodes --- engines/access/access.cpp | 6 ++++++ engines/access/access.h | 1 + engines/access/room.h | 3 +-- engines/access/scripts.cpp | 38 +++++++++++++++++++++++++++++++------- engines/access/scripts.h | 8 ++++---- 5 files changed, 43 insertions(+), 13 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index fde5ab8754..d2967c0377 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -84,6 +84,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); Common::fill(&_help1[0], &_help3[366], 0); + _helpTbl[0] = _help1; + _helpTbl[1] = _help2; + _helpTbl[2] = _help3; _travel = 0; _ask = 0; _rScrollRow = 0; @@ -221,6 +224,9 @@ void AccessEngine::doEstablish(int v1, int v2) { _buffer2.copyBuffer(_screen); } + _room->setIconPalette(); + _screen->forceFadeIn(); + warning("TODO: doEstablish"); } diff --git a/engines/access/access.h b/engines/access/access.h index fa2d24ec44..37be9cfc36 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -163,6 +163,7 @@ public: byte _help1[366]; byte _help2[366]; byte _help3[366]; + byte *_helpTbl[3]; int _travel; int _ask; int _rScrollRow; diff --git a/engines/access/room.h b/engines/access/room.h index 3035561892..22dbd16411 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -120,8 +120,6 @@ protected: virtual void reloadRoom1() = 0; - virtual void setIconPalette() {} - virtual void doCommands(); virtual void roomMenu() = 0; @@ -159,6 +157,7 @@ public: void init4Quads(); + virtual void setIconPalette() {} void placeBubble(); void placeBubble1(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index a4d67c87f1..f781ec14d0 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -93,7 +93,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::cmdSetAnim, &Scripts::CMDDISPINV, &Scripts::CMDSETTIMER, + &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, &Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, @@ -103,13 +103,13 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, - &Scripts::cmdReturnChoice, &Scripts::CMDCLEARBLOCK, &Scripts::CMDLOADSOUND, + &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, - &Scripts::CMDCHAPTER, &Scripts::CMDSETHELP, &Scripts::CMDCENTERPANEL, + &Scripts::CMDCHAPTER, &Scripts::cmdSetHelp, &Scripts::cmdCenterPanel, &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH }; @@ -296,7 +296,10 @@ void Scripts::cmdSetAnim() { _vm->_animation->setAnimTimer(anim); } -void Scripts::CMDDISPINV() { error("TODO CMDDISPINV"); } +void Scripts::cmdDispInv() { + _vm->_inventory->newDisplayInv(); +} + void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); } void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); } @@ -388,7 +391,10 @@ void Scripts::cmdReturnChoice() { _data->seek(_choiceStart); } -void Scripts::CMDCLEARBLOCK() { error("TODO CMDCLEARBLOCK"); } +void Scripts::cmdClearBlock() { + _vm->_screen->restoreBlock(); +} + void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); } void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); } @@ -413,8 +419,26 @@ void Scripts::CMDENDVID() { error("TODO CMDENDVID"); } void Scripts::CMDHELP() { error("TODO CMDHELP"); } void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); } void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); } -void Scripts::CMDSETHELP() { error("TODO CMDSETHELP"); } -void Scripts::CMDCENTERPANEL() { error("TODO CMDCENTERPANEL"); } + +void Scripts::cmdSetHelp() { + int arrayId = (_data->readUint16LE() && 0xFF) - 1; + int helpId = _data->readUint16LE() && 0xFF; + + byte *help = _vm->_helpTbl[arrayId]; + help[helpId] = 1; + + if (_vm->_useItem == 0) { + _sequence = 11000; + searchForSequence(); + } +} + +void Scripts::cmdCenterPanel() { + if (_vm->_screen->_vesaMode) { + _vm->_screen->clearScreen(); + _vm->_screen->setPanel(3); + } +} void Scripts::cmdMainPanel() { if (_vm->_screen->_vesaMode) { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 78e54f56c6..4cf969e8c9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -74,7 +74,7 @@ protected: void cmdRetNeg(); void cmdCheckLoc(); void cmdSetAnim(); - void CMDDISPINV(); + void cmdDispInv(); void CMDSETTIMER(); void CMDCHECKTIMER(); void cmdSetTravel(); @@ -99,7 +99,7 @@ protected: void CMDCHECKVFRAME(); void cmdJumpChoice(); void cmdReturnChoice(); - void CMDCLEARBLOCK(); + void cmdClearBlock(); void CMDLOADSOUND(); void CMDFREESOUND(); void CMDSETVIDSND(); @@ -113,8 +113,8 @@ protected: void CMDHELP(); void CMDCYCLEBACK(); void CMDCHAPTER(); - void CMDSETHELP(); - void CMDCENTERPANEL(); + void cmdSetHelp(); + void cmdCenterPanel(); void cmdMainPanel(); void CMDRETFLASH(); public: -- cgit v1.2.3 From 404c7cd5d33e81c7724cb78dfce5701b26b4659b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 11:14:30 -0400 Subject: ACCESS: Split the bubble box code from Room into it's own file --- engines/access/access.cpp | 3 + engines/access/access.h | 2 + engines/access/bubble_box.cpp | 144 ++++++++++++++++++++++++++++++++++++++++++ engines/access/bubble_box.h | 75 ++++++++++++++++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 114 --------------------------------- engines/access/room.h | 32 +--------- engines/access/scripts.cpp | 4 +- 8 files changed, 229 insertions(+), 146 deletions(-) create mode 100644 engines/access/bubble_box.cpp create mode 100644 engines/access/bubble_box.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d2967c0377..7d12ba5b35 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -33,6 +33,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _gameDescription(gameDesc), Engine(syst), _randomSource("Access"), _useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; + _bubbleBox = nullptr; _debugger = nullptr; _events = nullptr; _files = nullptr; @@ -102,6 +103,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine::~AccessEngine() { delete _animation; + delete _bubbleBox; delete _debugger; delete _events; delete _files; @@ -142,6 +144,7 @@ void AccessEngine::initialize() { // Create sub-objects of the engine ASurface::init(); _animation = new AnimationManager(this); + _bubbleBox = new BubbleBox(this); _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); diff --git a/engines/access/access.h b/engines/access/access.h index 37be9cfc36..88b6c837a5 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -31,6 +31,7 @@ #include "engines/engine.h" #include "graphics/surface.h" #include "access/animation.h" +#include "access/bubble_box.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -104,6 +105,7 @@ protected: virtual void playGame() = 0; public: AnimationManager *_animation; + BubbleBox *_bubbleBox; Debugger *_debugger; EventsManager *_events; FileManager *_files; diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp new file mode 100644 index 0000000000..2b6d9dd11a --- /dev/null +++ b/engines/access/bubble_box.cpp @@ -0,0 +1,144 @@ +/* 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 "common/algorithm.h" +#include "access/bubble_box.h" +#include "access/access.h" + +namespace Access { + +Box::Box(AccessEngine *vm) : Manager(vm) { + _edgeSize = 0; +} + +void Box::doBox(int item, int box) { + error("TODO: doBox"); +} + +/*------------------------------------------------------------------------*/ + +BubbleBox::BubbleBox(AccessEngine *vm) : Box(vm) { + _bubblePtr = nullptr; + _maxChars = 0; +} + +void BubbleBox::load(Common::SeekableReadStream *stream) { + _bubbleTitle.clear(); + + byte v; + while ((v = stream->readByte()) != 0) + _bubbleTitle += (char)v; + + _bubblePtr = _bubbleTitle.c_str(); +} + +void BubbleBox::clearBubbles() { + _bubbles.clear(); +} + +void BubbleBox::placeBubble() { + BubbleBox::_maxChars = 27; + placeBubble1(); +} + +void BubbleBox::placeBubble1() { + BubbleBox::clearBubbles(); + _vm->_fonts._charSet._lo = 1; + _vm->_fonts._charSet._hi = 8; + _vm->_fonts._charFor._lo = 29; + _vm->_fonts._charFor._hi = 32; + + calcBubble(); + + Common::Rect r = BubbleBox::_bubbles[0]; + r.translate(-2, 0); + _vm->_screen->saveBlock(r); + printBubble(); +} + +void BubbleBox::calcBubble() { + // Save points + Common::Point printOrg = _vm->_fonts._printOrg; + Common::Point printStart = _vm->_fonts._printStart; + + // Figure out maximum width allowed + if (_edgeSize == 4) { + _vm->_fonts._printMaxX = 110; + } else { + _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(BubbleBox::_bubblePtr); + } + + // Start of with a rect with the given starting x and y + Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + + // Loop through getting lines + Common::String msg(BubbleBox::_bubblePtr); + Common::String line; + int width = 0; + bool lastLine; + do { + lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); + width = MIN(width, _vm->_fonts._printMaxX); + + _vm->_fonts._printOrg.y += 6; + _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + } while (!lastLine); + + if (_edgeSize == 4) + ++_vm->_fonts._printOrg.y += 6; + + // Determine the width for the area + width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; + if (width >= 24) + width += 20 - ((width - 24) % 20); + bounds.setWidth(width); + + // Determine the height for area + int y = _vm->_fonts._printOrg.y + 6; + if (_edgeSize == 4) + y += 6; + int height = y - bounds.top; + bounds.setHeight(height); + + height -= (_edgeSize == 4) ? 30 : 24; + if (height >= 0) + bounds.setHeight(bounds.height() + 13 - (height % 13)); + + // Add the new bounds to the bubbles list + BubbleBox::_bubbles.push_back(bounds); + + // Restore points + _vm->_fonts._printOrg = printOrg; + _vm->_fonts._printStart = printStart; +} + +void BubbleBox::printBubble() { + //drawBubble(BubbleBox::_bubbles.size() - 1); + error("TODO: printBubble"); +} + +void BubbleBox::drawBubble(int index) { + _bounds = BubbleBox::_bubbles[index]; + doBox(0, 0); +} + +} // End of namespace Access diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h new file mode 100644 index 0000000000..e02fa7c572 --- /dev/null +++ b/engines/access/bubble_box.h @@ -0,0 +1,75 @@ +/* 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 ACCESS_BUBBLE_BOX_H +#define ACCESS_BUBBLE_BOX_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "common/stream.h" +#include "common/types.h" +#include "graphics/surface.h" +#include "access/data.h" + +namespace Access { + +class AccessEngine; + +class Box: public Manager { +public: + int _edgeSize; + Common::Rect _bounds; +public: + Box(AccessEngine *vm); + + void doBox(int item, int box); +}; + +class BubbleBox: public Box { +public: + Common::String _bubbleTitle; + const char *_bubblePtr; + int _maxChars; + Common::Array _bubbles; +public: + BubbleBox(AccessEngine *vm); + + void load(Common::SeekableReadStream *stream); + + void clearBubbles(); + + void placeBubble(); + void placeBubble1(); + + void calcBubble(); + + void printBubble(); + + void drawBubble(int index); + + +}; + +} // End of namespace Access + +#endif /* ACCESS_BUBBLE_BOX_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 6f906a9c21..d74892c241 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS := \ animation.o \ asurface.o \ access.o \ + bubble_box.o \ data.o \ debugger.o \ decompress.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b46363b32d..0405e7c4ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,96 +584,6 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } -void Room::placeBubble() { - _bubbleBox._maxChars = 27; - placeBubble1(); -} - -void Room::placeBubble1() { - _bubbleBox.clearBubbles(); - _vm->_fonts._charSet._lo = 1; - _vm->_fonts._charSet._hi = 8; - _vm->_fonts._charFor._lo = 29; - _vm->_fonts._charFor._hi = 32; - - calcBubble(); - - Common::Rect r = _bubbleBox._bubbles[0]; - r.translate(-2, 0); - _vm->_screen->saveBlock(r); - printBubble(); -} - -void Room::calcBubble() { - // Save points - Common::Point printOrg = _vm->_fonts._printOrg; - Common::Point printStart = _vm->_fonts._printStart; - - // Figure out maximum width allowed - if (_bubbleBox._type == 4) { - _vm->_fonts._printMaxX = 110; - } else { - _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleBox._bubblePtr); - } - - // Start of with a rect with the given starting x and y - Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); - - // Loop through getting lines - Common::String msg(_bubbleBox._bubblePtr); - Common::String line; - int width = 0; - bool lastLine; - do { - lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); - width = MIN(width, _vm->_fonts._printMaxX); - - _vm->_fonts._printOrg.y += 6; - _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; - } while (!lastLine); - - if (_bubbleBox._type == 4) - ++_vm->_fonts._printOrg.y += 6; - - // Determine the width for the area - width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; - if (width >= 24) - width += 20 - ((width - 24) % 20); - bounds.setWidth(width); - - // Determine the height for area - int y = _vm->_fonts._printOrg.y + 6; - if (_bubbleBox._type == 4) - y += 6; - int height = y - bounds.top; - bounds.setHeight(height); - - height -= (_bubbleBox._type == 4) ? 30 : 24; - if (height >= 0) - bounds.setHeight(bounds.height() + 13 - (height % 13)); - - // Add the new bounds to the bubbles list - _bubbleBox._bubbles.push_back(bounds); - - // Restore points - _vm->_fonts._printOrg = printOrg; - _vm->_fonts._printStart = printStart; -} - -void Room::printBubble() { - //drawBubble(_bubbleBox._bubbles.size() - 1); - error("TODO: printBubble"); -} - -void Room::drawBubble(int index) { - _bubbleBox._bounds = _bubbleBox._bubbles[index]; - doBox(); -} - -void Room::doBox() { - error("TODO: doBox"); -} - /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { @@ -732,28 +642,4 @@ RoomInfo::RoomInfo(const byte *data) { } } -/*------------------------------------------------------------------------*/ - -BubbleBox::BubbleBox() { - _type = 2; - _bounds = Common::Rect(64, 32, 130, 122); - _bubblePtr = nullptr; - _maxChars = 0; -} - -void BubbleBox::load(Common::SeekableReadStream *stream) { - _bubbleTitle.clear(); - - byte v; - while ((v = stream->readByte()) != 0) - _bubbleTitle += (char)v; - - _bubblePtr = _bubbleTitle.c_str(); -} - -void BubbleBox::clearBubbles() { - _bubbles.clear(); -} - - } // End of namespace Access diff --git a/engines/access/room.h b/engines/access/room.h index 22dbd16411..f76db6f681 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -58,22 +58,6 @@ public: } }; -class BubbleBox { -public: - int _type; - Common::Rect _bounds; - Common::String _bubbleTitle; - const char *_bubblePtr; - int _maxChars; - Common::Array _bubbles; -public: - BubbleBox(); - - void load(Common::SeekableReadStream *stream); - - void clearBubbles(); -}; - class Room: public Manager { private: void roomLoop(); @@ -125,10 +109,11 @@ protected: virtual void roomMenu() = 0; virtual void mainAreaClick() = 0; +public: + virtual void setIconPalette() {} public: Plotter _plotter; Common::Array _jetFrame; - BubbleBox _bubbleBox; int _function; int _roomFlag; byte *_playField; @@ -156,21 +141,8 @@ public: void buildRow(int playY, int screenY); void init4Quads(); - - virtual void setIconPalette() {} - void placeBubble(); - void placeBubble1(); - - void calcBubble(); - - void printBubble(); - - void drawBubble(int index); - - void doBox(); }; - class RoomInfo { public: struct FileIdent { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f781ec14d0..f91b49c9ef 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -117,7 +117,7 @@ void Scripts::executeCommand(int commandIndex) { } void Scripts::CMDOBJECT() { - _vm->_room->_bubbleBox.load(_data); + _vm->_bubbleBox->load(_data); } void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); } @@ -176,7 +176,7 @@ void Scripts::cmdPrint() { _vm->_timers[PRINT_TIMER]._initTm = 50; _vm->_timers[PRINT_TIMER]._flag = true; - _vm->_room->placeBubble(); + _vm->_bubbleBox->placeBubble(); _vm->_events->waitKeyMouse(); while (_vm->_timers[PRINT_TIMER]._flag) { -- cgit v1.2.3 From 77626b72a59f0a9bf35da3f77032c018fe5d7963 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 12:01:28 -0400 Subject: ACCESS: Add missing string parameters to bubble box methods --- engines/access/bubble_box.cpp | 22 +++++++++++----------- engines/access/bubble_box.h | 24 +++++++++++++++++------- engines/access/scripts.cpp | 11 ++++++++++- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 2b6d9dd11a..5f0cb9443b 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -55,27 +55,27 @@ void BubbleBox::clearBubbles() { _bubbles.clear(); } -void BubbleBox::placeBubble() { +void BubbleBox::placeBubble(const Common::String &msg) { BubbleBox::_maxChars = 27; - placeBubble1(); + placeBubble1(msg); } -void BubbleBox::placeBubble1() { +void BubbleBox::placeBubble1(const Common::String &msg) { BubbleBox::clearBubbles(); _vm->_fonts._charSet._lo = 1; _vm->_fonts._charSet._hi = 8; _vm->_fonts._charFor._lo = 29; _vm->_fonts._charFor._hi = 32; - calcBubble(); + calcBubble(msg); Common::Rect r = BubbleBox::_bubbles[0]; r.translate(-2, 0); _vm->_screen->saveBlock(r); - printBubble(); + printBubble(msg); } -void BubbleBox::calcBubble() { +void BubbleBox::calcBubble(const Common::String &msg) { // Save points Common::Point printOrg = _vm->_fonts._printOrg; Common::Point printStart = _vm->_fonts._printStart; @@ -84,19 +84,19 @@ void BubbleBox::calcBubble() { if (_edgeSize == 4) { _vm->_fonts._printMaxX = 110; } else { - _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(BubbleBox::_bubblePtr); + _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr); } // Start of with a rect with the given starting x and y Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); // Loop through getting lines - Common::String msg(BubbleBox::_bubblePtr); + Common::String s = msg; Common::String line; int width = 0; bool lastLine; do { - lastLine = _vm->_fonts._font2.getLine(msg, _vm->_fonts._printMaxX, line, width); + lastLine = _vm->_fonts._font2.getLine(s, _vm->_fonts._printMaxX, line, width); width = MIN(width, _vm->_fonts._printMaxX); _vm->_fonts._printOrg.y += 6; @@ -131,8 +131,8 @@ void BubbleBox::calcBubble() { _vm->_fonts._printStart = printStart; } -void BubbleBox::printBubble() { - //drawBubble(BubbleBox::_bubbles.size() - 1); +void BubbleBox::printBubble(const Common::String &msg) { + drawBubble(BubbleBox::_bubbles.size() - 1); error("TODO: printBubble"); } diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index e02fa7c572..189e0b1c04 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -58,13 +58,23 @@ public: void clearBubbles(); - void placeBubble(); - void placeBubble1(); - - void calcBubble(); - - void printBubble(); - + void placeBubble(const Common::String &msg); + void placeBubble1(const Common::String &msg); + + /** + * Calculate the size of a bubble needed to hold a given string + */ + void calcBubble(const Common::String &msg); + + /** + * Prints a text bubble and it's contents + */ + void printBubble(const Common::String &msg); + + /* + * Draws the background for a text bubble + * @param index Index of bounds in _bubbles array + */ void drawBubble(int index); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f91b49c9ef..640514aca7 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -176,13 +176,22 @@ void Scripts::cmdPrint() { _vm->_timers[PRINT_TIMER]._initTm = 50; _vm->_timers[PRINT_TIMER]._flag = true; - _vm->_bubbleBox->placeBubble(); + // Get a text line for display + Common::String msg; + byte c; + while ((c = (char)_data->readByte()) != '\0') + msg += c; + + // Display the text in a bubble, and wait for a keypress or mouse click + _vm->_bubbleBox->placeBubble(msg); _vm->_events->waitKeyMouse(); + // Wait until the bubble display is expired while (_vm->_timers[PRINT_TIMER]._flag) { _vm->_events->pollEvents(); } + // Restore the original screen over the text bubble _vm->_screen->restoreBlock(); } -- cgit v1.2.3 From 1b69da3d17c7dce0c64eb23e7c5499a20c60cd47 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Aug 2014 21:49:07 +0200 Subject: ACCESS: Implement some more opcodes --- engines/access/scripts.cpp | 55 +++++++++++++++++++++++++++++++++++++++++----- engines/access/scripts.h | 9 +++++--- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 640514aca7..a209efcd04 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -36,6 +36,8 @@ Scripts::Scripts(AccessEngine *vm) : _vm(vm) { _returnCode = 0; _choice = 0; _choiceStart = 0; + _charsOrg = Common::Point(0, 0); + _texsOrg = Common::Point(0, 0); } Scripts::~Scripts() { @@ -65,6 +67,10 @@ void Scripts::searchForSequence() { } while (sequenceId != _sequence); } +void Scripts::findNull() { + // No implementation required in ScummVM, the strings in the script files are already skipped by the use of readByte() +} + int Scripts::executeScript() { assert(_data); _endFlag = false; @@ -100,9 +106,9 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::CMDCHARSPEAK, - &Scripts::CMDTEXSPEAK, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, - &Scripts::CMDSETCONPOS, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, + &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, + &Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, + &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, @@ -379,11 +385,48 @@ void Scripts::CMDSPECIAL() { void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); } void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); } -void Scripts::CMDCHARSPEAK() { error("TODO CMDCHARSPEAK"); } -void Scripts::CMDTEXSPEAK() { error("TODO CMDTEXSPEAK"); } + +void Scripts::cmdCharSpeak() { + _vm->_fonts._printOrg = _charsOrg; + _vm->_fonts._printStart = _charsOrg; + + byte v; + Common::String tmpStr = ""; + while ((v = _data->readByte()) != 0) + tmpStr += (char)v; + + _vm->_bubbleBox->placeBubble(tmpStr); + findNull(); +} + +void Scripts::cmdTexSpeak() { + _vm->_fonts._printOrg = _texsOrg; + _vm->_fonts._printStart = _texsOrg; + _vm->_bubbleBox->_maxChars = 20; + + byte v; + Common::String tmpStr = ""; + while ((v = _data->readByte()) != 0) + tmpStr += (char)v; + + _vm->_bubbleBox->_bubblePtr = Common::String("JASON").c_str(); + _vm->_bubbleBox->placeBubble1(tmpStr); + findNull(); +} + void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1; void Scripts::CMDWAIT() { error("TODO CMDWAIT"); } -void Scripts::CMDSETCONPOS() { error("TODO CMDSETCONPOS"); } + +void Scripts::cmdSetConPos() { + int x = _data->readSint16LE(); + int y = _data->readSint16LE(); + _charsOrg = Common::Point(x, y); + + x = _data->readSint16LE(); + y = _data->readSint16LE(); + _texsOrg = Common::Point(x, y); +} + void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); } void Scripts::cmdJumpChoice() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 4cf969e8c9..aae31464bf 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -91,11 +91,11 @@ protected: void CMDSPECIAL(); void CMDSETCYCLE(); void CMDCYCLE(); - void CMDCHARSPEAK(); - void CMDTEXSPEAK(); + void cmdCharSpeak(); + void cmdTexSpeak(); void CMDTEXCHOICE(); void CMDWAIT(); - void CMDSETCONPOS(); + void cmdSetConPos(); void CMDCHECKVFRAME(); void cmdJumpChoice(); void cmdReturnChoice(); @@ -124,6 +124,7 @@ public: int _scriptCommand; int _choice; int32 _choiceStart; + Common::Point _charsOrg, _texsOrg; public: Scripts(AccessEngine *vm); @@ -136,6 +137,8 @@ public: void searchForSequence(); int executeScript(); + + void findNull(); }; } // End of namespace Access -- cgit v1.2.3 From 4ea9339d183cb53f465d7752e739cf8a153a7978 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 17 Aug 2014 22:42:28 +0200 Subject: ACCESS: Implement cmdSetTex() --- engines/access/player.h | 4 ++-- engines/access/room.h | 3 ++- engines/access/scripts.cpp | 36 ++++++++++++++++++++++++++++++++---- engines/access/scripts.h | 4 ++-- 4 files changed, 38 insertions(+), 9 deletions(-) diff --git a/engines/access/player.h b/engines/access/player.h index a9efff2433..b904e46170 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -49,11 +49,9 @@ private: int _diagDownWalkMin, _diagDownWalkMax; Common::Point _guard; bool _collideFlag; - Direction _playerDirection; Direction _move; int _xFlag, _yFlag; Common::Point _moveTo; - SpriteResource *_playerSprites; SpriteResource *_playerSprites1; byte *_manPal1; int _scrollEnd; @@ -79,6 +77,8 @@ private: bool scrollLeft(); bool scrollRight(); public: + Direction _playerDirection; + SpriteResource *_playerSprites; // Fields in original Player structure byte *_monData; int _walkOffRight[PLAYER_DATA_COUNT]; diff --git a/engines/access/room.h b/engines/access/room.h index f76db6f681..a90c6e400e 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -68,7 +68,6 @@ private: protected: void loadRoomData(const byte *roomData); void setupRoom(); - void setWallCodes(); void buildScreen(); /** @@ -110,6 +109,8 @@ protected: virtual void mainAreaClick() = 0; public: + void setWallCodes(); + virtual void setIconPalette() {} public: Plotter _plotter; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index a209efcd04..0d232cc779 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -96,7 +96,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, - &Scripts::CMDSETTEX, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, + &Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, @@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, - &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, &Scripts::CMDSPECIAL, + &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, @@ -255,7 +255,35 @@ void Scripts::cmdCheckInventory() { _data->skip(2); } -void Scripts::CMDSETTEX() { error("TODO CMDSETTEX"); } +void Scripts::cmdSetTex() { + _vm->_player->_playerDirection = RIGHT; + int posX = _data->readSint16LE() - (_vm->_player->_playerOffset.x / 2); + if (posX <= _vm->_player->_rawPlayer.x) + _vm->_player->_playerDirection = LEFT; + + _vm->_player->_rawPlayer.x = posX; + _vm->_player->checkScroll(); + bool scrlTemp = _vm->_player->_scrollFlag; + + _vm->_player->_playerDirection = UP; + int posY = _data->readSint16LE(); + if (posY <= _vm->_player->_rawPlayer.y) + _vm->_player->_playerDirection = DOWN; + + _vm->_player->_rawPlayer.y = posY; + _vm->_player->_frame = 5; + _vm->_player->checkScroll(); + + _vm->_player->_scrollFlag |= scrlTemp; + + _vm->_player->_position = Common::Point(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y - _vm->_player->_playerOffset.y); + _vm->_player->_priority = _vm->_player->_playerOffset.y; + _vm->_player->_spritesPtr = _vm->_player->_playerSprites; + _vm->_player->_frameNumber = _vm->_player->_frame; + + _vm->_room->setWallCodes(); +} + void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); } void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); } @@ -363,7 +391,7 @@ void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; } -void Scripts::CMDSPECIAL() { +void Scripts::cmdSpecial() { _specialFunction = _data->readUint16LE(); int p1 = _data->readUint16LE(); int p2 = _data->readUint16LE(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index aae31464bf..70d79c4b65 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -65,7 +65,7 @@ protected: void cmdSetInventory(); void cmdCheckInventory(); - void CMDSETTEX(); + void cmdSetTex(); void CMDNEWROOM(); void CMDCONVERSE(); void cmdCheckFrame(); @@ -88,7 +88,7 @@ protected: void CMDSETBUFVID(); void CMDPLAYBUFVID(); void cmdRemoveLast(); - void CMDSPECIAL(); + void cmdSpecial(); void CMDSETCYCLE(); void CMDCYCLE(); void cmdCharSpeak(); -- cgit v1.2.3 From 9393f6d7559653a28166fe74da9745e95b76f85b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 18:56:05 -0400 Subject: ACCESS: Implemented bubble box drawing code --- engines/access/asurface.cpp | 12 +++ engines/access/asurface.h | 7 +- engines/access/bubble_box.cpp | 167 ++++++++++++++++++++++++++++++++++++------ engines/access/bubble_box.h | 27 ++++--- engines/access/data.cpp | 85 ++++++++++++++++++--- engines/access/data.h | 19 ++++- 6 files changed, 271 insertions(+), 46 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 08caa8a3b2..99292278f3 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -115,6 +115,11 @@ int ASurface::_lastBoundsW; int ASurface::_lastBoundsH; int ASurface::_scrollX; int ASurface::_scrollY; +int ASurface::_orgX1; +int ASurface::_orgY1; +int ASurface::_orgX2; +int ASurface::_orgY2; +int ASurface::_lColor; void ASurface::init() { _leftSkip = _rightSkip = 0; @@ -123,6 +128,9 @@ void ASurface::init() { _lastBoundsX = _lastBoundsY = 0; _lastBoundsW = _lastBoundsH = 0; _scrollX = _scrollY = 0; + _orgX1 = _orgY1 = 0; + _orgX2 = _orgY2 = 0; + _lColor = 0; } ASurface::~ASurface() { @@ -329,4 +337,8 @@ void ASurface::restoreBlock() { } } +void ASurface::drawRect() { + Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor); +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 85550d9eee..400dd07b4d 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -46,8 +46,13 @@ public: static int _lastBoundsX, _lastBoundsY; static int _lastBoundsW, _lastBoundsH; static int _scrollX, _scrollY; + static int _orgX1, _orgY1; + static int _orgX2, _orgY2; + static int _lColor; static void init(); +public: + virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); public: virtual ~ASurface(); @@ -75,7 +80,7 @@ public: void restoreBlock(); - virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); + void drawRect(); }; class SpriteFrame : public ASurface { diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 5f0cb9443b..f910028fc5 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -26,18 +26,15 @@ namespace Access { -Box::Box(AccessEngine *vm) : Manager(vm) { - _edgeSize = 0; -} - -void Box::doBox(int item, int box) { - error("TODO: doBox"); -} - -/*------------------------------------------------------------------------*/ - -BubbleBox::BubbleBox(AccessEngine *vm) : Box(vm) { +BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) { + _type = TYPE_2; + _bounds = Common::Rect(64, 32, 64 + 130, 32 + 122); _bubblePtr = nullptr; + _fieldD = 0; + _fieldE = 0; + _fieldF = 0; + _field10 = 0; + _maxChars = 0; } @@ -69,7 +66,7 @@ void BubbleBox::placeBubble1(const Common::String &msg) { calcBubble(msg); - Common::Rect r = BubbleBox::_bubbles[0]; + Common::Rect r = _bubbles[0]; r.translate(-2, 0); _vm->_screen->saveBlock(r); printBubble(msg); @@ -81,7 +78,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { Common::Point printStart = _vm->_fonts._printStart; // Figure out maximum width allowed - if (_edgeSize == 4) { + if (_type == TYPE_4) { _vm->_fonts._printMaxX = 110; } else { _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr); @@ -96,14 +93,14 @@ void BubbleBox::calcBubble(const Common::String &msg) { int width = 0; bool lastLine; do { - lastLine = _vm->_fonts._font2.getLine(s, _vm->_fonts._printMaxX, line, width); - width = MIN(width, _vm->_fonts._printMaxX); + lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width); + width = MAX(width, _vm->_fonts._printMaxX); _vm->_fonts._printOrg.y += 6; _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; } while (!lastLine); - if (_edgeSize == 4) + if (_type == TYPE_4) ++_vm->_fonts._printOrg.y += 6; // Determine the width for the area @@ -114,17 +111,17 @@ void BubbleBox::calcBubble(const Common::String &msg) { // Determine the height for area int y = _vm->_fonts._printOrg.y + 6; - if (_edgeSize == 4) + if (_type == TYPE_4) y += 6; int height = y - bounds.top; bounds.setHeight(height); - height -= (_edgeSize == 4) ? 30 : 24; + height -= (_type == TYPE_4) ? 30 : 24; if (height >= 0) bounds.setHeight(bounds.height() + 13 - (height % 13)); // Add the new bounds to the bubbles list - BubbleBox::_bubbles.push_back(bounds); + _bubbles.push_back(bounds); // Restore points _vm->_fonts._printOrg = printOrg; @@ -132,13 +129,139 @@ void BubbleBox::calcBubble(const Common::String &msg) { } void BubbleBox::printBubble(const Common::String &msg) { - drawBubble(BubbleBox::_bubbles.size() - 1); - error("TODO: printBubble"); + drawBubble(_bubbles.size() - 1); + + // Loop through drawing the lines + Common::String s = msg; + Common::String line; + int width = 0; + bool lastLine; + do { + // Get next line + Font &font2 = _vm->_fonts._font2; + lastLine = font2.getLine(s, _maxChars * 6, line, width); + + // Set font colors + font2._fontColors[0] = 0; + font2._fontColors[1] = 0; + font2._fontColors[2] = 0; + font2._fontColors[3] = 0; + + int xp = _vm->_fonts._printOrg.x; + if (_type == TYPE_4) + xp = (_bounds.width() - width) / 2 + _bounds.left - 4; + + // Draw the text + font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y)); + + // Move print position + _vm->_fonts._printOrg.y += 6; + _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + } while (!lastLine); } void BubbleBox::drawBubble(int index) { - _bounds = BubbleBox::_bubbles[index]; + _bounds = _bubbles[index]; doBox(0, 0); } +void BubbleBox::doBox(int item, int box) { + FontManager &fonts = _vm->_fonts; + ASurface &screen = *_vm->_screen; + + _startItem = item; + _startBox = box; + + // Save state information + FontVal charSet = fonts._charSet; + FontVal charFor = fonts._charFor; + Common::Point printOrg = fonts._printOrg; + Common::Point printStart = fonts._printStart; + int charCol = _charCol; + int rowOff = _rowOff; + + _vm->_screen->saveScreen(); + _vm->_screen->setDisplayScan(); + fonts._charFor._hi = 0xff; + fonts._charSet._lo = 1; + fonts._charSet._hi = 0; + + if (_type == TYPE_4) { + fonts._charFor._lo = 0xFF; + error("TODO: filename listing"); + return; + } + + // Get icons data + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *icons = new SpriteResource(_vm, iconData, _vm->_files->_filesize); + delete[] iconData; + + // Set the up boundaries and color to use for the box background + _vm->_screen->_orgX1 = _bounds.left; + _vm->_screen->_orgY1 = _bounds.top; + _vm->_screen->_orgX2 = _bounds.right; + _vm->_screen->_orgY2 = _bounds.bottom; + _vm->_screen->_lColor = 1; + + int h = _bounds.height() - (_type == TYPE_4) ? 30 : 24; + int ySize = (h < 0) ? 0 : (h + 12) / 13; + int w = _bounds.width() - 24; + int xSize = (w < 0) ? 0 : (w + 19) / 20; + + // Draw a background for the entire area + screen.drawRect(); + + // Draw images to form the top border + int xp, yp; + screen.plotImage(icons, 20, Common::Point(screen._orgX1, screen._orgY1)); + xp = screen._orgX1 + 12; + for (int x = 0; x < xSize; ++x, xp += 20) + screen.plotImage(icons, 24 + x, Common::Point(xp, screen._orgY1)); + screen.plotImage(icons, 21, Common::Point(xp, screen._orgY1)); + + // Draw images to form the bottom border + yp = screen._orgY2 - (_type == TYPE_4) ? 18 : 12; + screen.plotImage(icons, (_type == TYPE_4) ? 72 : 22, + Common::Point(screen._orgX1, yp)); + xp = screen._orgX1 + 12; + yp += (_type == TYPE_4) ? 4 : 8; + + for (int x = 0; x < xSize; ++x, xp += 20) { + screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x, + Common::Point(xp, yp)); + } + + yp -= (_type == TYPE_4) ? 18 : 12; + screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, + Common::Point(screen._orgX1, yp)); + + if (_type == TYPE_4) { + // Further stuff + warning("YSIZE not yet used %d", ySize); + error("TODO: Box type 4"); + } + + // Handle drawing title + int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr); + Font &font2 = _vm->_fonts._font2; + font2._fontColors[0] = 0; + font2._fontColors[1] = 3; + font2._fontColors[2] = 2; + font2._fontColors[3] = 1; + font2.drawString(_vm->_screen, _bubblePtr, Common::Point( + _bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1)); + + // Restore positional state + fonts._charSet = charSet; + fonts._charFor = charFor; + fonts._printOrg = printOrg; + fonts._printStart = printStart; + _charCol = charCol; + _rowOff = rowOff; + + // Free icons data + delete icons; +} + } // End of namespace Access diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 189e0b1c04..3ddb2f72e3 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/rect.h" +#include "common/str-array.h" #include "common/stream.h" #include "common/types.h" #include "graphics/surface.h" @@ -35,20 +36,24 @@ namespace Access { class AccessEngine; -class Box: public Manager { -public: - int _edgeSize; - Common::Rect _bounds; -public: - Box(AccessEngine *vm); - - void doBox(int item, int box); -}; +enum BoxType { TYPE_2 = 2, TYPE_4 = 4 }; -class BubbleBox: public Box { +class BubbleBox: public Manager { +private: + int _startItem, _startBox; + int _charCol, _rowOff; + Common::Point _fileStart; public: + BoxType _type; + Common::Rect _bounds; + Common::StringArray _nameIndex; Common::String _bubbleTitle; const char *_bubblePtr; + int _fieldD; + int _fieldE; + int _fieldF; + int _field10; + int _maxChars; Common::Array _bubbles; public: @@ -77,7 +82,7 @@ public: */ void drawBubble(int index); - + void doBox(int item, int box); }; } // End of namespace Access diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 65702db9f1..1fba854f19 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -46,21 +46,57 @@ void TimerList::restoreTimers() { /*------------------------------------------------------------------------*/ +byte Font::_fontColors[4]; + Font::Font() { } +Font::~Font() { + for (uint i = 0; i < _chars.size(); ++i) + _chars[i].free(); +} + void Font::load(const int *index, const byte *data) { + assert(_chars.size() == 0); int count = index[0]; - _v1 = index[1]; - _v2 = index[2]; - - _chars.clear(); - for (int idx = 0; idx < count; ++idx) - _chars.push_back(data + index[idx + 3]); + _bitWidth = index[1]; + _height = index[2]; + + _chars.resize(count); + + for (int i = 0; i < count; ++i) { + const byte *pData = data + index[i + 3]; + _chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8()); + + for (int y = 0; y < _height; ++y) { + int bitsLeft = 0; + byte srcByte = 0; + byte pixel; + + byte *pDest = (byte *)_chars[i].getBasePtr(0, y); + for (int x = 0; x < _chars[i].w; ++x, ++pDest) { + // Get the pixel + pixel = 0; + for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr) { + // No bits in current byte left, so get next byte + if (bitsLeft == 0) { + bitsLeft = 8; + srcByte = *pData++; + } + + pixel = (pixel << 1) | (srcByte >> 7); + srcByte <<= 1; + } + + // Write out the pixel + *pDest = pixel; + } + } + } } int Font::charWidth(char c) { - return *_chars[c - ' ']; + return _chars[c - ' '].w; } int Font::stringWidth(const Common::String &msg) { @@ -69,10 +105,11 @@ int Font::stringWidth(const Common::String &msg) { for (const char *c = msg.c_str(); *c != '\0'; ++c) total += charWidth(*c); - return 0; + return total; } bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) { + assert(maxWidth > 0); width = 0; const char *src = s.c_str(); char c; @@ -92,7 +129,8 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w // Reached maximum allowed. Work backwards to find space at the // start of the current word as a point to split the line on - while (*src != ' ' && src >= s.c_str()) { + --src; + while (src >= s.c_str() && *src != ' ') { width -= charWidth(*src); --src; } @@ -111,10 +149,39 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w return true; } +void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) { + Common::Point currPt = pt; + const char *msgP = msg.c_str(); + + while (*msgP) { + currPt.x += drawChar(s, *msgP, currPt); + ++msgP; + } +} + +int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) { + Graphics::Surface &ch = _chars[c - ' ']; + + // Loop through the lines of the character + for (int y = 0; y < ch.h; ++y) { + byte *pSrc = (byte *)ch.getBasePtr(0, y); + byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y); + + // Loop through the horizontal pixels of the line + for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) { + if (*pSrc != 0) + *pDest = _fontColors[*pSrc]; + } + } + + return ch.w; +} + /*------------------------------------------------------------------------*/ FontManager::FontManager() { _printMaxX = 0; + Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0); } } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 910e2523d1..fd3c889ddb 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -87,12 +87,16 @@ public: class Font { private: - int _v1; - int _v2; - Common::Array _chars; + int _bitWidth; + int _height; + Common::Array _chars; +public: + static byte _fontColors[4]; public: Font(); + ~Font(); + /** * Load the given font data */ @@ -118,6 +122,15 @@ public: */ bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width); + /** + * Draw a string on a given surface + */ + void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt); + + /** + * Draw a character on a given surface + */ + int drawChar(Graphics::Surface *s, char c, Common::Point &pt); }; class FontManager { -- cgit v1.2.3 From 483bca3d96b7012774d13875e78cfd8b649657f7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 20:17:38 -0400 Subject: ACCESS: Fixes for drawing bubble box backgrounds --- engines/access/bubble_box.cpp | 21 +++++++++++++-------- engines/access/events.cpp | 29 +++++++++++++++++++---------- engines/access/events.h | 4 ++-- engines/access/scripts.cpp | 2 +- 4 files changed, 35 insertions(+), 21 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index f910028fc5..b896e5ef1a 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -94,7 +94,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { bool lastLine; do { lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width); - width = MAX(width, _vm->_fonts._printMaxX); + _vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX); _vm->_fonts._printOrg.y += 6; _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; @@ -150,10 +150,10 @@ void BubbleBox::printBubble(const Common::String &msg) { int xp = _vm->_fonts._printOrg.x; if (_type == TYPE_4) xp = (_bounds.width() - width) / 2 + _bounds.left - 4; - + // Draw the text font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y)); - + // Move print position _vm->_fonts._printOrg.y += 6; _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; @@ -221,7 +221,7 @@ void BubbleBox::doBox(int item, int box) { screen.plotImage(icons, 21, Common::Point(xp, screen._orgY1)); // Draw images to form the bottom border - yp = screen._orgY2 - (_type == TYPE_4) ? 18 : 12; + yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12); screen.plotImage(icons, (_type == TYPE_4) ? 72 : 22, Common::Point(screen._orgX1, yp)); xp = screen._orgX1 + 12; @@ -232,16 +232,21 @@ void BubbleBox::doBox(int item, int box) { Common::Point(xp, yp)); } - yp -= (_type == TYPE_4) ? 18 : 12; - screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, - Common::Point(screen._orgX1, yp)); + yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12); + screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp)); if (_type == TYPE_4) { // Further stuff - warning("YSIZE not yet used %d", ySize); error("TODO: Box type 4"); } + // Draw images to form the sides + yp = screen._orgY1 + 12; + for (int y = 0; y < ySize; ++y) { + screen.plotImage(icons, 44 + y, Common::Point(screen._orgX1, yp)); + screen.plotImage(icons, 53 + y, Common::Point(screen._orgX2 - 4, yp)); + } + // Handle drawing title int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr); Font &font2 = _vm->_fonts._font2; diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 521e8895c8..71ed5f433e 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -112,9 +112,10 @@ bool EventsManager::isCursorVisible() { return CursorMan.isVisible(); } -void EventsManager::pollEvents(bool suppressFrames) { - if (!suppressFrames) - checkForNextFrameCounter(); +void EventsManager::pollEvents() { + if (checkForNextFrameCounter()) { + nextFrame(); + } Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { @@ -158,24 +159,26 @@ void EventsManager::pollEvents(bool suppressFrames) { } } -void EventsManager::checkForNextFrameCounter() { +bool EventsManager::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { ++_frameCounter; _priorFrameTime = milli; - nextFrame(); + return true; } + + return false; } void EventsManager::nextFrame() { - // Give time to the debugger - _vm->_debugger->onFrame(); - // Update timers _vm->_animation->updateTimers(); + // Give time to the debugger + _vm->_debugger->onFrame(); + // TODO: Refactor for dirty rects _vm->_screen->updateScreen(); } @@ -199,13 +202,19 @@ bool EventsManager::getKey(Common::KeyState &key) { void EventsManager::debounceLeft() { while (_leftButton && !_vm->shouldQuit()) { - pollEvents(true); + pollEvents(); g_system->delayMillis(10); } } void EventsManager::waitKeyMouse() { - error("TODO: waitKeyPress"); + while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { + pollEvents(); + g_system->delayMillis(10); + } + + zeroKeys(); + debounceLeft(); } } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index dc89829312..c6702ec7af 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -46,7 +46,7 @@ private: uint32 _frameCounter; uint32 _priorFrameTime; - void checkForNextFrameCounter(); + bool checkForNextFrameCounter(); void nextFrame(); public: @@ -95,7 +95,7 @@ public: */ bool isCursorVisible(); - void pollEvents(bool suppressFrames = false); + void pollEvents(); void zeroKeys(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0d232cc779..2e4e2adca6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -193,7 +193,7 @@ void Scripts::cmdPrint() { _vm->_events->waitKeyMouse(); // Wait until the bubble display is expired - while (_vm->_timers[PRINT_TIMER]._flag) { + while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) { _vm->_events->pollEvents(); } -- cgit v1.2.3 From be4639802c469c8b85e1f801a7cac1897a18863b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 20:32:25 -0400 Subject: ACCESS: Fix positioning of bubble boxes --- engines/access/bubble_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index b896e5ef1a..4bd4b74588 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -85,7 +85,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { } // Start of with a rect with the given starting x and y - Common::Rect bounds(printOrg.x - 2, printOrg.y, printOrg.x - 2, printOrg.y); + Common::Rect bounds(printOrg.x - 2, printOrg.y - 10, printOrg.x - 2, printOrg.y - 10); // Loop through getting lines Common::String s = msg; -- cgit v1.2.3 From c576b201f6638fa3702593cdb45cff64057d35ef Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 21:08:58 -0400 Subject: ACCESS: Fix decoding of font data --- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/data.cpp | 12 ++++++------ engines/access/data.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 072675c55e..663d6996d2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -173,8 +173,8 @@ void AmazonEngine::setupGame() { } // Miscellaenous - _fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA); _fonts._font2.load(FONT2_INDEX, FONT2_DATA); + _fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA); // Set player room and position _player->_roomNumber = 4; diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 1fba854f19..36797b62ea 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -56,16 +56,16 @@ Font::~Font() { _chars[i].free(); } -void Font::load(const int *index, const byte *data) { +void Font::load(const int *fontIndex, const byte *fontData) { assert(_chars.size() == 0); - int count = index[0]; - _bitWidth = index[1]; - _height = index[2]; + int count = fontIndex[0]; + _bitWidth = fontIndex[1]; + _height = fontIndex[2]; _chars.resize(count); for (int i = 0; i < count; ++i) { - const byte *pData = data + index[i + 3]; + const byte *pData = fontData + fontIndex[i + 3]; _chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8()); for (int y = 0; y < _height; ++y) { @@ -77,7 +77,7 @@ void Font::load(const int *index, const byte *data) { for (int x = 0; x < _chars[i].w; ++x, ++pDest) { // Get the pixel pixel = 0; - for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr) { + for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) { // No bits in current byte left, so get next byte if (bitsLeft == 0) { bitsLeft = 8; diff --git a/engines/access/data.h b/engines/access/data.h index fd3c889ddb..7ddc5d610e 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -100,7 +100,7 @@ public: /** * Load the given font data */ - void load(const int *index, const byte *data); + void load(const int *fontIndex, const byte *fontData); /** * Get the width of a given character -- cgit v1.2.3 From a8a7018926f68d4792f3114ea8496ae721c2490c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 21:53:46 -0400 Subject: ACCESS: Fix showing bubble box text correctly --- engines/access/bubble_box.cpp | 6 +++--- engines/access/data.cpp | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 4bd4b74588..5a17b3b1a3 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -143,9 +143,9 @@ void BubbleBox::printBubble(const Common::String &msg) { // Set font colors font2._fontColors[0] = 0; - font2._fontColors[1] = 0; - font2._fontColors[2] = 0; - font2._fontColors[3] = 0; + font2._fontColors[1] = 27; + font2._fontColors[2] = 28; + font2._fontColors[3] = 29; int xp = _vm->_fonts._printOrg.x; if (_type == TYPE_4) diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 36797b62ea..90f712af3b 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -22,6 +22,8 @@ #include "common/algorithm.h" #include "access/data.h" +#include "graphics/palette.h" +#include "common/system.h" namespace Access { @@ -127,9 +129,13 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w if (width < maxWidth) continue; - // Reached maximum allowed. Work backwards to find space at the - // start of the current word as a point to split the line on - --src; + // Reached maximum allowed size + // If this was the last character of the string, let it go + if (*src == '\0') + break; + + // Work backwards to find space at the start of the current word + // as a point to split the line on while (src >= s.c_str() && *src != ' ') { width -= charWidth(*src); --src; @@ -138,7 +144,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w error("Could not fit line"); // Split the line around the space - line = Common::String(s.c_str(), src - 1); + line = Common::String(s.c_str(), src); s = Common::String(src + 1); return false; } -- cgit v1.2.3 From 38acce33fd95171a5d3a7a00cad57bb4a5711bad Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 22:09:03 -0400 Subject: ACCESS: Add updateTimers so bubble boxes can be removed --- engines/access/bubble_box.cpp | 4 ++-- engines/access/data.cpp | 12 ++++++++++++ engines/access/data.h | 5 +++++ engines/access/events.cpp | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 5a17b3b1a3..6ea7ed8a0b 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -198,9 +198,9 @@ void BubbleBox::doBox(int item, int box) { delete[] iconData; // Set the up boundaries and color to use for the box background - _vm->_screen->_orgX1 = _bounds.left; + _vm->_screen->_orgX1 = _bounds.left - 2; _vm->_screen->_orgY1 = _bounds.top; - _vm->_screen->_orgX2 = _bounds.right; + _vm->_screen->_orgX2 = _bounds.right - 2; _vm->_screen->_orgY2 = _bounds.bottom; _vm->_screen->_lColor = 1; diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 90f712af3b..124bfbca5a 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -46,6 +46,18 @@ void TimerList::restoreTimers() { } } +void TimerList::updateTimers() { + for (uint i = 0; i < size(); ++i) { + TimerEntry &te = (*this)[i]; + if (te._flag) { + if (!--te._timer) { + te._timer = te._initTm; + te._flag = false; + } + } + } +} + /*------------------------------------------------------------------------*/ byte Font::_fontColors[4]; diff --git a/engines/access/data.h b/engines/access/data.h index 7ddc5d610e..8ba3c58c82 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -68,6 +68,11 @@ public: * Resetore the set of previously saved timers */ void restoreTimers(); + + /** + * Update the timer list + */ + void updateTimers(); }; class ExtraCell { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 71ed5f433e..25a77f82de 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -175,6 +175,7 @@ bool EventsManager::checkForNextFrameCounter() { void EventsManager::nextFrame() { // Update timers _vm->_animation->updateTimers(); + _vm->_timers.updateTimers(); // Give time to the debugger _vm->_debugger->onFrame(); -- cgit v1.2.3 From 9e98a1edcc7610e9ccdb00026a7d9eb349b0c2ee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 22:13:45 -0400 Subject: ACCESS: Correct drawing the vertical edges of bubble boxes --- engines/access/bubble_box.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 6ea7ed8a0b..21e104028c 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -204,7 +204,7 @@ void BubbleBox::doBox(int item, int box) { _vm->_screen->_orgY2 = _bounds.bottom; _vm->_screen->_lColor = 1; - int h = _bounds.height() - (_type == TYPE_4) ? 30 : 24; + int h = _bounds.height() - (_type == TYPE_4 ? 30 : 24); int ySize = (h < 0) ? 0 : (h + 12) / 13; int w = _bounds.width() - 24; int xSize = (w < 0) ? 0 : (w + 19) / 20; @@ -242,7 +242,7 @@ void BubbleBox::doBox(int item, int box) { // Draw images to form the sides yp = screen._orgY1 + 12; - for (int y = 0; y < ySize; ++y) { + for (int y = 0; y < ySize; ++y, yp += 13) { screen.plotImage(icons, 44 + y, Common::Point(screen._orgX1, yp)); screen.plotImage(icons, 53 + y, Common::Point(screen._orgX2 - 4, yp)); } -- cgit v1.2.3 From 7fef53b68ccddcb8ed93c567456c73fe503ee006 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 22:32:26 -0400 Subject: ACCESS: Implemented cmdEndObject --- engines/access/resources.cpp | 13 +++++++++++++ engines/access/resources.h | 2 ++ engines/access/scripts.cpp | 25 ++++++++++++++++--------- engines/access/scripts.h | 4 +++- 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 40daf2b121..f0d74ccd2a 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -76,4 +76,17 @@ const int RMOUSE[10][2] = { { 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 } }; +const char *LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST."; +const char *GET_MESSAGE = "YOU CAN'T TAKE THAT."; +const char *OPEN_MESSAGE = "THAT DOESN'T OPEN."; +const char *MOVE_MESSAGE = "THAT WON'T MOVE."; +const char *USE_MESSAGE = "THAT DOESN'T SEEM TO WORK."; +const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT."; +const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS"; +const char *TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE."; +const char *const GENERAL_MESSAGES[] = { + LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, + GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE +}; + } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index 678cbc0614..241ed3a636 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -56,6 +56,8 @@ extern const int OVEROFFDLY[]; extern const int RMOUSE[10][2]; +extern const char *const GENERAL_MESSAGES[]; + } // End of namespace Access #endif /* ACCESS_RESOURCES_H */ diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2e4e2adca6..fba947a174 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/resources.h" #include "access/scripts.h" #define SCRIPT_START_BYTE 0xE0 @@ -90,7 +91,7 @@ int Scripts::executeScript() { void Scripts::executeCommand(int commandIndex) { static const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDOBJECT, &Scripts::CMDENDOBJECT, &Scripts::cmdJumpLook, + &Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, @@ -126,7 +127,9 @@ void Scripts::CMDOBJECT() { _vm->_bubbleBox->load(_data); } -void Scripts::CMDENDOBJECT() { error("TODO ENDOBJECT"); } +void Scripts::cmdEndObject() { + printString(GENERAL_MESSAGES[_vm->_room->_selectCommand]); +} void Scripts::cmdJumpLook() { if (_vm->_room->_selectCommand == 0) @@ -175,18 +178,22 @@ void Scripts::cmdNull() { #define PRINT_TIMER 25 -void Scripts::cmdPrint() { - _vm->_fonts._printOrg = Common::Point(20, 42); - _vm->_fonts._printStart = Common::Point(20, 42); - _vm->_timers[PRINT_TIMER]._timer = 50; - _vm->_timers[PRINT_TIMER]._initTm = 50; - _vm->_timers[PRINT_TIMER]._flag = true; - +void Scripts::cmdPrint() { // Get a text line for display Common::String msg; byte c; while ((c = (char)_data->readByte()) != '\0') msg += c; + + printString(msg); +} + +void Scripts::printString(const Common::String &msg) { + _vm->_fonts._printOrg = Common::Point(20, 42); + _vm->_fonts._printStart = Common::Point(20, 42); + _vm->_timers[PRINT_TIMER]._timer = 50; + _vm->_timers[PRINT_TIMER]._initTm = 50; + _vm->_timers[PRINT_TIMER]._flag = true; // Display the text in a bubble, and wait for a keypress or mouse click _vm->_bubbleBox->placeBubble(msg); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 70d79c4b65..ac2bae005c 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -38,13 +38,15 @@ private: const byte *_rawData; Common::MemoryReadStream *_data; int _specialFunction; + + void printString(const Common::String &msg); protected: AccessEngine *_vm; virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); void CMDOBJECT(); - void CMDENDOBJECT(); + void cmdEndObject(); void cmdJumpLook(); void cmdJumpHelp(); void cmdJumpGet(); -- cgit v1.2.3 From 9150e1816c57e3852fd86123ba8e0d1c9dee8ff4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 22:44:31 -0400 Subject: ACCESS: Shifted some Amazon specific opcodes to the AmazonScripts class --- engines/access/amazon/amazon_scripts.cpp | 57 ++++++++++++++++++++++++++++++++ engines/access/amazon/amazon_scripts.h | 9 +++++ engines/access/scripts.cpp | 41 +++-------------------- engines/access/scripts.h | 15 ++------- 4 files changed, 73 insertions(+), 49 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 2fdbcc94a2..38cf9d6a84 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -71,6 +71,63 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { } } +typedef void(AmazonScripts::*AmazonScriptMethodPtr)(); + +void AmazonScripts::executeCommand(int commandIndex) { + static const AmazonScriptMethodPtr COMMAND_LIST[] = { + &AmazonScripts::CMDHELP, &AmazonScripts::CMDCYCLEBACK, + &AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp, + &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, + &AmazonScripts::CMDRETFLASH + }; + + if (commandIndex >= 73) + (this->*COMMAND_LIST[commandIndex - 73])(); + else + Scripts::executeCommand(commandIndex); +} + +void AmazonScripts::CMDHELP() { + error("TODO CMDHELP"); +} + +void AmazonScripts::CMDCYCLEBACK() { + error("TODO CMDCYCLEBACK"); +} +void AmazonScripts::CMDCHAPTER() { + error("TODO CMDCHAPTER"); +} + +void AmazonScripts::cmdSetHelp() { + int arrayId = (_data->readUint16LE() && 0xFF) - 1; + int helpId = _data->readUint16LE() && 0xFF; + + byte *help = _vm->_helpTbl[arrayId]; + help[helpId] = 1; + + if (_vm->_useItem == 0) { + _sequence = 11000; + searchForSequence(); + } +} + +void AmazonScripts::cmdCenterPanel() { + if (_vm->_screen->_vesaMode) { + _vm->_screen->clearScreen(); + _vm->_screen->setPanel(3); + } +} + +void AmazonScripts::cmdMainPanel() { + if (_vm->_screen->_vesaMode) { + _vm->_room->init4Quads(); + _vm->_screen->setPanel(0); + } +} + +void AmazonScripts::CMDRETFLASH() { + error("TODO CMDRETFLASH"); +} } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index b8fdaaa7f3..c9a889e3ad 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -33,6 +33,15 @@ namespace Amazon { class AmazonScripts: public Scripts { protected: virtual void executeSpecial(int commandIndex, int param1, int param2); + virtual void executeCommand(int commandIndex); + + void CMDHELP(); + void CMDCYCLEBACK(); + void CMDCHAPTER(); + void cmdSetHelp(); + void cmdCenterPanel(); + void cmdMainPanel(); + void CMDRETFLASH(); public: AmazonScripts(AccessEngine *vm); }; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index fba947a174..3c60065bfe 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -29,7 +29,7 @@ namespace Access { -Scripts::Scripts(AccessEngine *vm) : _vm(vm) { +Scripts::Scripts(AccessEngine *vm) : Manager(vm) { _rawData = nullptr; _data = nullptr; _sequence = 0; @@ -89,6 +89,8 @@ int Scripts::executeScript() { return _returnCode; } +typedef void(Scripts::*ScriptMethodPtr)(); + void Scripts::executeCommand(int commandIndex) { static const ScriptMethodPtr COMMAND_LIST[] = { &Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, @@ -115,9 +117,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, - &Scripts::CMDENDVID, &Scripts::CMDHELP, &Scripts::CMDCYCLEBACK, - &Scripts::CMDCHAPTER, &Scripts::cmdSetHelp, &Scripts::cmdCenterPanel, - &Scripts::cmdMainPanel, &Scripts::CMDRETFLASH + &Scripts::CMDENDVID }; (this->*COMMAND_LIST[commandIndex])(); @@ -503,38 +503,5 @@ void Scripts::cmdFadeOut() { } void Scripts::CMDENDVID() { error("TODO CMDENDVID"); } -void Scripts::CMDHELP() { error("TODO CMDHELP"); } -void Scripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); } -void Scripts::CMDCHAPTER() { error("TODO CMDCHAPTER"); } - -void Scripts::cmdSetHelp() { - int arrayId = (_data->readUint16LE() && 0xFF) - 1; - int helpId = _data->readUint16LE() && 0xFF; - - byte *help = _vm->_helpTbl[arrayId]; - help[helpId] = 1; - - if (_vm->_useItem == 0) { - _sequence = 11000; - searchForSequence(); - } -} - -void Scripts::cmdCenterPanel() { - if (_vm->_screen->_vesaMode) { - _vm->_screen->clearScreen(); - _vm->_screen->setPanel(3); - } -} - -void Scripts::cmdMainPanel() { - if (_vm->_screen->_vesaMode) { - _vm->_room->init4Quads(); - _vm->_screen->setPanel(0); - } -} - -void Scripts::CMDRETFLASH() { error("TODO CMDRETFLASH"); } - } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ac2bae005c..1f0bf84443 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -25,23 +25,21 @@ #include "common/scummsys.h" #include "common/memstream.h" +#include "access/data.h" namespace Access { class AccessEngine; class Scripts; -typedef void(Scripts::*ScriptMethodPtr)(); - -class Scripts { +class Scripts: public Manager { private: const byte *_rawData; - Common::MemoryReadStream *_data; int _specialFunction; void printString(const Common::String &msg); protected: - AccessEngine *_vm; + Common::MemoryReadStream *_data; virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); @@ -112,13 +110,6 @@ protected: void CMDDEAD(); void cmdFadeOut(); void CMDENDVID(); - void CMDHELP(); - void CMDCYCLEBACK(); - void CMDCHAPTER(); - void cmdSetHelp(); - void cmdCenterPanel(); - void cmdMainPanel(); - void CMDRETFLASH(); public: int _sequence; bool _endFlag; -- cgit v1.2.3 From d31b27ba1b26a38401387f85ca2ce46be455d0a2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 23:04:05 -0400 Subject: ACCESS: Partially implement cmdHelp --- engines/access/amazon/amazon_game.cpp | 6 ++++++ engines/access/amazon/amazon_game.h | 5 +++++ engines/access/amazon/amazon_resources.cpp | 7 +++++++ engines/access/amazon/amazon_resources.h | 3 +++ engines/access/amazon/amazon_scripts.cpp | 29 ++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 6 +++++- engines/access/scripts.cpp | 15 ++++++++++----- engines/access/scripts.h | 12 +++++++++++- 8 files changed, 73 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 663d6996d2..857d1b3551 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -51,7 +51,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rawInactiveX = 0; _rawInactiveY = 0; _inactiveYOff = 0; + Common::fill(&_esTabTable[0], &_esTabTable[100], 0); + _hintLevel = 0; } AmazonEngine::~AmazonEngine() { @@ -182,6 +184,10 @@ void AmazonEngine::setupGame() { _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; } +void AmazonEngine::drawHelp() { + error("TODO: drawHelp"); +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 848af85f30..c331830501 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -93,10 +93,15 @@ public: int &_aniFlag; int &_allenFlag; int &_noSound; + + // Other game specific fields + int _hintLevel; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AmazonEngine(); + + void drawHelp(); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index b7a2472a3c..1f666e1abb 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1187,6 +1187,13 @@ const byte FONT6x6_DATA[] = { 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49, }; +const char *const NO_HELP_MESSAGE = + "WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS. YOUR IQ \ +HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \ +YOU CAN UNDERSTAND."; +const char *const NO_HINTS_MESSAGE = + "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 838bd29b70..d618ca54c2 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -49,6 +49,9 @@ extern const int FONT6x6_INDEX[]; extern const byte FONT6x6_DATA[]; +extern const char *const NO_HELP_MESSAGE; +extern const char *const NO_HINTS_MESSAGE; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 38cf9d6a84..104473ac7d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -22,6 +22,8 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_scripts.h" namespace Access { @@ -29,6 +31,7 @@ namespace Access { namespace Amazon { AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { + _game = (AmazonEngine *)_vm; } void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { @@ -75,7 +78,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)(); void AmazonScripts::executeCommand(int commandIndex) { static const AmazonScriptMethodPtr COMMAND_LIST[] = { - &AmazonScripts::CMDHELP, &AmazonScripts::CMDCYCLEBACK, + &AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK, &AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp, &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, &AmazonScripts::CMDRETFLASH @@ -87,8 +90,28 @@ void AmazonScripts::executeCommand(int commandIndex) { Scripts::executeCommand(commandIndex); } -void AmazonScripts::CMDHELP() { - error("TODO CMDHELP"); +void AmazonScripts::cmdHelp() { + Common::String helpMessage = readString(); + + if (_game->_helpLevel == 0) { + _game->_timers.saveTimers(); + _game->_useItem = 0; + + if (_game->_noHints) { + printString(NO_HELP_MESSAGE); + return; + } else if (_game->_hintLevel == 0) { + printString(NO_HINTS_MESSAGE); + return; + } + } + + int level = _game->_hintLevel - 1; + if (level < _game->_helpLevel) + _game->_moreHelp = 0; + + _game->drawHelp(); + error("TODO: more cmdHelp"); } void AmazonScripts::CMDCYCLEBACK() { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index c9a889e3ad..978ef0105c 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -30,12 +30,16 @@ namespace Access { namespace Amazon { +class AmazonEngine; + class AmazonScripts: public Scripts { +private: + AmazonEngine *_game; protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); - void CMDHELP(); + void cmdHelp(); void CMDCYCLEBACK(); void CMDCHAPTER(); void cmdSetHelp(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 3c60065bfe..958696e09d 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -180,11 +180,7 @@ void Scripts::cmdNull() { void Scripts::cmdPrint() { // Get a text line for display - Common::String msg; - byte c; - while ((c = (char)_data->readByte()) != '\0') - msg += c; - + Common::String msg = readString(); printString(msg); } @@ -208,6 +204,15 @@ void Scripts::printString(const Common::String &msg) { _vm->_screen->restoreBlock(); } +Common::String Scripts::readString() { + Common::String msg; + byte c; + while ((c = (char)_data->readByte()) != '\0') + msg += c; + + return msg; +} + void Scripts::cmdRetPos() { _endFlag = true; _returnCode = 0; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 1f0bf84443..5f849410dc 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -37,12 +37,22 @@ private: const byte *_rawData; int _specialFunction; - void printString(const Common::String &msg); protected: Common::MemoryReadStream *_data; virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); + + /** + * Print a given message to the screen in a bubble box + */ + void printString(const Common::String &msg); + + /** + * Read a null terminated string from the script + */ + Common::String readString(); + void CMDOBJECT(); void cmdEndObject(); void cmdJumpLook(); -- cgit v1.2.3 From 5ec8c445bd21e9b7fd592bf1cc8785a0d44bde23 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 23:08:14 -0400 Subject: ACCESS: Fix player flickering --- engines/access/player.cpp | 113 +++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 79ce2190f3..dfbee48134 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -562,71 +562,70 @@ void Player::walkDownRight() { } void Player::checkMove() { - if (!_vm->_events->_mouseMove) - return; - - if (_xFlag == 0 && _yFlag == 0) { - int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; - if (xp < 0) - xp = -xp; - int yp = _rawPlayer.y - _moveTo.y; - if (yp < 0) - yp = -yp; - - if (xp < yp) - _xFlag = 1; - else - _yFlag = 1; - } + if (_vm->_events->_mouseMove) { + if (_xFlag == 0 && _yFlag == 0) { + int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; + if (xp < 0) + xp = -xp; + int yp = _rawPlayer.y - _moveTo.y; + if (yp < 0) + yp = -yp; + + if (xp < yp) + _xFlag = 1; + else + _yFlag = 1; + } - if (_yFlag == 1) { - int yd = _rawPlayer.y - _moveTo.y; - if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) { - ++_yFlag; - if (_xFlag) { - _vm->_events->_mouseMove = false; - _xFlag = _yFlag = 0; + if (_yFlag == 1) { + int yd = _rawPlayer.y - _moveTo.y; + if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) { + ++_yFlag; + if (_xFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } else { + ++_xFlag; + } } else { - ++_xFlag; + if (yd >= 0) + walkUp(); + else + walkDown(); + + if (_collideFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } } - } else { - if (yd >= 0) - walkUp(); - else - walkDown(); + } else if (_xFlag == 1) { + int xd = _rawPlayer.x - _moveTo.x; + if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { + ++_xFlag; - if (_collideFlag) { - _vm->_events->_mouseMove = false; - _xFlag = _yFlag = 0; - } - } - } else if (_xFlag == 1) { - int xd = _rawPlayer.x - _moveTo.x; - if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { - ++_xFlag; - - if (_yFlag) { - _vm->_events->_mouseMove = false; - _xFlag = _yFlag = 0; + if (_yFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } + } else { + if (xd >= 0) + walkLeft(); + else + walkRight(); + + if (_collideFlag) { + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; + } } + } else if (!_yFlag) { + ++_yFlag; } else { - if (xd >= 0) - walkLeft(); - else - walkRight(); - - if (_collideFlag) { - _vm->_events->_mouseMove = false; - _xFlag = _yFlag = 0; - } + _vm->_events->_mouseMove = false; + _xFlag = _yFlag = 0; } - } else if (!_yFlag) { - ++_yFlag; - } else { - _vm->_events->_mouseMove = false; - _xFlag = _yFlag = 0; } - + plotCom3(); } -- cgit v1.2.3 From d570da065ec422132b4dd409b9b4ecf9cea92fc8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 17 Aug 2014 23:15:32 -0400 Subject: ACCESS: Fix selecting location for player to walk to --- engines/access/amazon/amazon_room.cpp | 9 ++++++--- engines/access/events.cpp | 1 - engines/access/events.h | 1 - engines/access/player.cpp | 29 +++++++++++++++-------------- engines/access/player.h | 3 ++- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index bf3c2501bb..79c70c0b33 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -148,14 +148,17 @@ void AmazonRoom::mainAreaClick() { switch (checkBoxes1(_vm->_events->_mousePos)) { case 0: _game->_jasMayaFlag = 0; - break; + return; case 1: _game->_jasMayaFlag = 1; - break; + return; default: break; } - } + } + + _vm->_player->_moveTo = _vm->_events->_mousePos; + _vm->_player->_playerMove = true; } else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd && _vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide && _vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd && diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 25a77f82de..1afc5515b0 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -40,7 +40,6 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _frameCounter = 10; _priorFrameTime = 0; _leftButton = _rightButton = false; - _mouseMove = false; _mouseCol = _mouseRow = 0; _mouseMode = 0; _cursorExitFlag = false; diff --git a/engines/access/events.h b/engines/access/events.h index c6702ec7af..4c052f96f0 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -55,7 +55,6 @@ public: bool _leftButton, _rightButton; Common::Point _mousePos; int _mouseCol, _mouseRow; - bool _mouseMove; int _mouseMode; bool _cursorExitFlag; Common::FixedStack _keypresses; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index dfbee48134..cde1a74de2 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -49,6 +49,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { _playerY = 0; _frame = 0; _playerOff = false; + _playerMove = false; _leftDelta = _rightDelta = 0; _upDelta = _downDelta = 0; _scrollConst = 0; @@ -193,35 +194,35 @@ void Player::walk() { _vm->_timers[0]._flag = true; switch (_move) { case UP: - _vm->_events->_mouseMove = false; + _playerMove = false; walkUp(); break; case DOWN: - _vm->_events->_mouseMove = false; + _playerMove = false; walkDown(); break; case LEFT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkLeft(); break; case RIGHT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkRight(); break; case UPLEFT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkUpLeft(); break; case DOWNLEFT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkDownLeft(); break; case UPRIGHT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkUpRight(); break; case DOWNRIGHT: - _vm->_events->_mouseMove = false; + _playerMove = false; walkDownRight(); break; default: @@ -562,7 +563,7 @@ void Player::walkDownRight() { } void Player::checkMove() { - if (_vm->_events->_mouseMove) { + if (_playerMove) { if (_xFlag == 0 && _yFlag == 0) { int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; if (xp < 0) @@ -582,7 +583,7 @@ void Player::checkMove() { if ((yd >= 0 && yd <= _upDelta) || (yd < 0 && -yd <= _upDelta)) { ++_yFlag; if (_xFlag) { - _vm->_events->_mouseMove = false; + _playerMove = false; _xFlag = _yFlag = 0; } else { ++_xFlag; @@ -594,7 +595,7 @@ void Player::checkMove() { walkDown(); if (_collideFlag) { - _vm->_events->_mouseMove = false; + _playerMove = false; _xFlag = _yFlag = 0; } } @@ -604,7 +605,7 @@ void Player::checkMove() { ++_xFlag; if (_yFlag) { - _vm->_events->_mouseMove = false; + _playerMove = false; _xFlag = _yFlag = 0; } } else { @@ -614,14 +615,14 @@ void Player::checkMove() { walkRight(); if (_collideFlag) { - _vm->_events->_mouseMove = false; + _playerMove = false; _xFlag = _yFlag = 0; } } } else if (!_yFlag) { ++_yFlag; } else { - _vm->_events->_mouseMove = false; + _playerMove = false; _xFlag = _yFlag = 0; } } diff --git a/engines/access/player.h b/engines/access/player.h index b904e46170..b11cc4a826 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -51,7 +51,6 @@ private: bool _collideFlag; Direction _move; int _xFlag, _yFlag; - Common::Point _moveTo; SpriteResource *_playerSprites1; byte *_manPal1; int _scrollEnd; @@ -102,6 +101,8 @@ public: // Additional public globals we've added to new Player class bool _playerOff; + bool _playerMove; + Common::Point _moveTo; bool _scrollFlag; int _scrollThreshold; int _scrollAmount; -- cgit v1.2.3 From 17315a4dd71d4f9151724166bb5ddd7fdc0074f7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 00:29:01 -0400 Subject: ACCESS: Implemented wall checks for pathfinding --- engines/access/player.cpp | 20 +++---- engines/access/player.h | 3 +- engines/access/room.cpp | 135 ++++++++++++++++++++++++++++++++++++++++++++++ engines/access/room.h | 12 ++++- 4 files changed, 154 insertions(+), 16 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index cde1a74de2..0733e80c7d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -249,7 +249,7 @@ void Player::walkUp() { _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; _rawXTemp = _rawPlayer.x; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.y = _rawYTemp; @@ -277,7 +277,7 @@ void Player::walkDown() { _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; _rawXTemp = _rawPlayer.x; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.y = _rawYTemp; @@ -316,7 +316,7 @@ void Player::walkLeft() { } _rawYTemp = _rawPlayer.y; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -355,7 +355,7 @@ void Player::walkRight() { } _rawYTemp = _rawPlayer.y; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -398,7 +398,7 @@ void Player::walkUpLeft() { _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -445,7 +445,7 @@ void Player::walkDownLeft() { _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -492,7 +492,7 @@ void Player::walkUpRight() { _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -540,7 +540,7 @@ void Player::walkDownRight() { _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; - if (codeWalls()) { + if (_vm->_room->codeWalls()) { plotCom2(); } else { _rawPlayer.x = _rawXTemp; @@ -658,10 +658,6 @@ void Player::plotCom3() { plotCom2(); } -bool Player::codeWalls() { - error("TODO codeWalls"); -} - void Player::checkScroll() { _scrollFlag = false; if (_playerDirection == NONE) diff --git a/engines/access/player.h b/engines/access/player.h index b11cc4a826..876c0e5ea4 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -48,7 +48,6 @@ private: int _diagUpWalkMin, _diagUpWalkMax; int _diagDownWalkMin, _diagDownWalkMax; Common::Point _guard; - bool _collideFlag; Direction _move; int _xFlag, _yFlag; SpriteResource *_playerSprites1; @@ -56,7 +55,6 @@ private: int _scrollEnd; int _inactiveYOff; - bool codeWalls(); void checkMove(); void plotCom(int v1); void plotCom1(); @@ -103,6 +101,7 @@ public: bool _playerOff; bool _playerMove; Common::Point _moveTo; + bool _collideFlag; bool _scrollFlag; int _scrollThreshold; int _scrollAmount; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0405e7c4ac..9c2bd01650 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -584,6 +584,141 @@ int Room::validateBox(int boxId) { return _vm->_scripts->executeScript(); } +void Room::swapOrg() { + SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); + SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); +} + +int Room::calcLR(int yp) { + const Screen &screen = *_vm->_screen; + + int yv = (yp - screen._orgY1) * (screen._orgX2 - screen._orgX1); + int yd = screen._orgY2 - screen._orgY1; + + int rem = (yv % yd) << 1; + yv /= yd; + if (rem >= yd) + ++yv; + + return yv + screen._orgX1; +} + +int Room::calcUD(int xp) { + const Screen &screen = *_vm->_screen; + + int xv = (xp - screen._orgX1) * (screen._orgY2 - screen._orgY1); + int xd = screen._orgX2 - screen._orgX1; + + int rem = (xv % xd) << 1; + xv /= xd; + if (rem >= xd) + ++xv; + + return xv + screen._orgY1; +} + +bool Room::codeWalls() { + Screen &screen = *_vm->_screen; + Player &player = *_vm->_player; + + if (_plotter._walls.size() == 0) + return false; + + for (uint i = 0; i < _plotter._walls.size(); ++i) { + Common::Rect &r = _plotter._walls[i]; + JetFrame &jf = _jetFrame[i]; + + jf._wallCode = 0; + jf._wallCode1 = 0; + screen._orgX1 = r.left; + screen._orgY1 = r.top; + screen._orgX2 = r.right; + screen._orgY2 = r.bottom; + + if (screen._orgY2 != screen._orgY1) { + if (screen._orgY2 < screen._orgY1) + swapOrg(); + + if ((player._rawYTemp >= screen._orgY1) && + (player._rawYTemp <= screen._orgY2)) { + jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; + jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1; + } + } + + if (screen._orgX2 != screen._orgX1) { + if (screen._orgX2 < screen._orgX1) + swapOrg(); + + if ((player._rawXTemp >= screen._orgX1) && + (player._rawXTemp <= screen._orgX2)) { + int y = screen._orgY2; + if (y == screen._orgY1) + y = calcUD(player._rawXTemp); + + jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8; + } + + int x = player._rawXTemp + player._playerOffset.x; + if ((x >= screen._orgX1) && (x <= screen._orgX2)) { + int y = screen._orgY2; + if (screen._orgY2 != screen._orgY1) + y = calcUD(player._rawXTemp + player._playerOffset.x); + + jf._wallCode1 |= (player._rawYTemp - y) < 0 ? 4 : 8; + } + } + } + + for (uint i = 0; i < _jetFrame.size(); ++i) { + JetFrame &jf = _jetFrame[i]; + if (checkCode(jf._wallCode, jf._wallCodeOld) || + checkCode(jf._wallCode1, jf._wallCode1Old)) + return true; + } + + // Copy the current wall calculations to the old properties + for (uint i = 0; i < _jetFrame.size(); ++i) { + JetFrame &jf = _jetFrame[i]; + jf._wallCodeOld = jf._wallCode; + jf._wallCode1Old = jf._wallCode1; + } + + return false; +} + +bool Room::checkCode(int v1, int v2) { + Player &p = *_vm->_player; + + if (!v1) { + p._collideFlag = true; + return true; + } if (!v2 || (v1 == v2)) { + } else if (v1 & 1) { + if (v2 & 2) { + p._collideFlag = true; + return true; + } + } else if (v1 & 2) { + if (v2 & 1) { + p._collideFlag = true; + return true; + } + } else if (v1 & 4) { + if (v2 & 8) { + p._collideFlag = true; + return true; + } + } else if (v1 & 8) { + if (v2 & 4) { + p._collideFlag = true; + return true; + } + } + + return false; +} + /*------------------------------------------------------------------------*/ RoomInfo::RoomInfo(const byte *data) { diff --git a/engines/access/room.h b/engines/access/room.h index a90c6e400e..c76bd7021b 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -65,6 +65,12 @@ private: void loadPlayField(int fileNum, int subfile); void commandOff(); + + void swapOrg(); + int calcLR(int yp); + int calcUD(int xp); + + bool checkCode(int v1, int v2); protected: void loadRoomData(const byte *roomData); void setupRoom(); @@ -109,8 +115,6 @@ protected: virtual void mainAreaClick() = 0; public: - void setWallCodes(); - virtual void setIconPalette() {} public: Plotter _plotter; @@ -142,6 +146,10 @@ public: void buildRow(int playY, int screenY); void init4Quads(); + + void setWallCodes(); + + bool codeWalls(); }; class RoomInfo { -- cgit v1.2.3 From 080a030116862ee21e0ebcec019fdc3f8e073650 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 07:32:17 -0400 Subject: ACCESS: Some initial pathfinding bugfixes --- engines/access/player.cpp | 6 ++++-- engines/access/player.h | 4 ++-- engines/access/room.cpp | 4 +--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 0733e80c7d..44dd0d2182 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -565,6 +565,8 @@ void Player::walkDownRight() { void Player::checkMove() { if (_playerMove) { if (_xFlag == 0 && _yFlag == 0) { + // Figure out whether a greater horizontal movement than vertical + // movement will be required, or vice versa int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; if (xp < 0) xp = -xp; @@ -572,7 +574,7 @@ void Player::checkMove() { if (yp < 0) yp = -yp; - if (xp < yp) + if (xp > yp) _xFlag = 1; else _yFlag = 1; @@ -600,7 +602,7 @@ void Player::checkMove() { } } } else if (_xFlag == 1) { - int xd = _rawPlayer.x - _moveTo.x; + int xd = _playerOffset.x / 2 + _rawPlayer.x - _moveTo.x; if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { ++_xFlag; diff --git a/engines/access/player.h b/engines/access/player.h index 876c0e5ea4..7ba0c05b21 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -86,9 +86,9 @@ public: Common::Point _walkOffDR[PLAYER_DATA_COUNT]; Common::Point _walkOffUL[PLAYER_DATA_COUNT]; Common::Point _walkOffDL[PLAYER_DATA_COUNT]; - int _rawTempL; + byte _rawTempL; int _rawXTemp; - int _rawYTempL; + byte _rawYTempL; int _rawYTemp; Common::Point _playerOffset; int _playerXLow; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9c2bd01650..5e3a4d743d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -653,7 +653,7 @@ bool Room::codeWalls() { if ((player._rawXTemp >= screen._orgX1) && (player._rawXTemp <= screen._orgX2)) { int y = screen._orgY2; - if (y == screen._orgY1) + if (y != screen._orgY1) y = calcUD(player._rawXTemp); jf._wallCode |= (player._rawYTemp - y) < 0 ? 4 : 8; @@ -691,8 +691,6 @@ bool Room::checkCode(int v1, int v2) { Player &p = *_vm->_player; if (!v1) { - p._collideFlag = true; - return true; } if (!v2 || (v1 == v2)) { } else if (v1 & 1) { if (v2 & 2) { -- cgit v1.2.3 From 46d1c106ca560c285c556a0b02b54d76bc6a29ba Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 18 Aug 2014 13:45:20 +0200 Subject: AGOS: Give each MIDI track its own loop flag This is needed because the MIDI resources have their own loop flag that overrides the global one. This makes a difference for games that use MIDI both for music and sound effects, such as (limited to?) the floppy version of Simon the Sorcerer 1. --- engines/agos/midi.cpp | 22 ++++++++++++---------- engines/agos/midi.h | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index c26fbe3331..045fd9dac5 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -52,7 +52,7 @@ MidiPlayer::MidiPlayer() { _paused = false; _currentTrack = 255; - _loopTrack = 0; + _loopTrackDefault = false; _queuedTrack = 255; _loopQueuedTrack = 0; } @@ -166,13 +166,13 @@ void MidiPlayer::metaEvent(byte type, byte *data, uint16 length) { return; } else if (_current == &_sfx) { clearConstructs(_sfx); - } else if (_loopTrack) { + } else if (_current->loopTrack) { _current->parser->jumpToTick(0); } else if (_queuedTrack != 255) { _currentTrack = 255; byte destination = _queuedTrack; _queuedTrack = 255; - _loopTrack = _loopQueuedTrack; + _current->loopTrack = _loopQueuedTrack; _loopQueuedTrack = false; // Remember, we're still inside the locked mutex. @@ -300,7 +300,7 @@ void MidiPlayer::setVolume(int musicVol, int sfxVol) { void MidiPlayer::setLoop(bool loop) { Common::StackLock lock(_mutex); - _loopTrack = loop; + _loopTrackDefault = loop; } void MidiPlayer::queueTrack(int track, bool loop) { @@ -405,7 +405,7 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) { uint32 timerRate = _driver->getBaseTempo(); - if (!memcmp(p->data, "GMF\x1", 4)) { + if (isGMF) { // The GMF header // 3 BYTES: 'GMF' // 1 BYTE : Major version @@ -426,11 +426,9 @@ void MidiPlayer::loadSMF(Common::File *in, int song, bool sfx) { // It seems that 4 corresponds to our base tempo, so // this should be the right way to calculate it. timerRate = (4 * _driver->getBaseTempo()) / p->data[5]; - - // According to bug #1004919 calling setLoop() from - // within a lock causes a lockup, though I have no - // idea when this actually happens. - _loopTrack = (p->data[6] != 0); + p->loopTrack = (p->data[6] != 0); + } else { + p->loopTrack = _loopTrackDefault; } MidiParser *parser = MidiParser::createParser_SMF(); @@ -500,6 +498,8 @@ void MidiPlayer::loadMultipleSMF(Common::File *in, bool sfx) { p->song_sizes[i] = size; } + p->loopTrack = _loopTrackDefault; + if (!sfx) { _currentTrack = 255; resetVolumeTable(); @@ -531,6 +531,7 @@ void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) { in->seek(pos, 0); p->data = (byte *)calloc(size, 1); in->read(p->data, size); + p->loopTrack = _loopTrackDefault; } else { error("Expected 'FORM' tag but found '%c%c%c%c' instead", buf[0], buf[1], buf[2], buf[3]); } @@ -575,6 +576,7 @@ void MidiPlayer::loadS1D(Common::File *in, bool sfx) { _currentTrack = 255; resetVolumeTable(); } + p->loopTrack = _loopTrackDefault; p->parser = parser; // That plugs the power cord into the wall } diff --git a/engines/agos/midi.h b/engines/agos/midi.h index 3efadddc2f..398e445535 100644 --- a/engines/agos/midi.h +++ b/engines/agos/midi.h @@ -36,6 +36,7 @@ namespace AGOS { struct MusicInfo { MidiParser *parser; byte *data; + bool loopTrack; byte num_songs; // For Type 1 SMF resources byte *songs[16]; // For Type 1 SMF resources uint32 song_sizes[16]; // For Type 1 SMF resources @@ -46,6 +47,7 @@ struct MusicInfo { MusicInfo() { clear(); } void clear() { parser = 0; data = 0; num_songs = 0; + loopTrack = false; memset(songs, 0, sizeof(songs)); memset(song_sizes, 0, sizeof(song_sizes)); memset(channel, 0, sizeof(channel)); @@ -71,7 +73,7 @@ protected: // These are only used for music. byte _currentTrack; - bool _loopTrack; + bool _loopTrackDefault; byte _queuedTrack; bool _loopQueuedTrack; -- cgit v1.2.3 From b6dc7a1dd4bdbc020254943e73355a17d521487c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Aug 2014 00:18:42 +0200 Subject: ACCESS: Implement two more opcodes --- engines/access/scripts.cpp | 117 +++++++++++++++++++++++++++++++++++++++++++-- engines/access/scripts.h | 6 ++- 2 files changed, 117 insertions(+), 6 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 958696e09d..1e5bbc8982 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -110,9 +110,9 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, - &Scripts::cmdTexSpeak, &Scripts::CMDTEXCHOICE, &Scripts::CMDWAIT, + &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, - &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::CMDLOADSOUND, + &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, @@ -454,7 +454,111 @@ void Scripts::cmdTexSpeak() { findNull(); } -void Scripts::CMDTEXCHOICE() { error("TODO CMDTEXCHOICE"); } // _choiceStart = _data->pos() - 1; +int Scripts::checkMouseBox1(Common::Rect *rectArr) { + int i = 0; + for (i = 0; ; i++){ + if (rectArr[i].left == -1) + return -1; + + if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right) + && (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom)) + return i; + } +} + +void Scripts::cmdTexChoice() { + static Common::Point cMouse[7] = { + Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232), + Common::Point(233, 276), Common::Point(0, 0), Common::Point(277, 319), + Common::Point(297, 319) + }; + + _vm->_oldRects.clear(); + _choiceStart = _data->pos() - 1; + _vm->_fonts._charSet._lo = 1; + _vm->_fonts._charSet._hi = 8; + _vm->_fonts._charFor._lo = 55; + _vm->_fonts._charFor._hi = 255; + _vm->_bubbleBox->_maxChars = 20; + + _vm->_fonts._printOrg = _texsOrg; + _vm->_fonts._printStart = _texsOrg; + + _vm->_bubbleBox->clearBubbles(); + _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str(); + + byte v; + Common::String tmpStr = ""; + while ((v = _data->readByte()) != 0) + tmpStr += (char)v; + + _vm->_bubbleBox->calcBubble(tmpStr); + _vm->_bubbleBox->printBubble(tmpStr); + + Common::Rect responseCoords[2]; + responseCoords[0] = _vm->_bubbleBox->_bounds; + responseCoords[1] = Common::Rect(0, 0, 0, 0); + _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + + findNull(); + + bool choice2Fl = false; + tmpStr = ""; + while ((v = _data->readByte()) != 0) + tmpStr += (char)v; + + Common::Rect termResponse2 = Common::Rect(-1, 0, 0, 0); + if (tmpStr.size() != 0) { + choice2Fl = true; + _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str(); + _vm->_bubbleBox->calcBubble(tmpStr); + _vm->_bubbleBox->printBubble(tmpStr); + responseCoords[1] = _vm->_bubbleBox->_bounds; + _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + } + + findNull(); + + bool choice3Fl = false; + tmpStr = ""; + while ((v = _data->readByte()) != 0) + tmpStr += (char)v; + + if (tmpStr.size() != 0) { + _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str(); + _vm->_bubbleBox->calcBubble(tmpStr); + _vm->_bubbleBox->printBubble(tmpStr); + termResponse2 = _vm->_bubbleBox->_bounds; + _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + } + + findNull(); + + int choice = -1; + do { + warning("TODO CHARLOOP"); + _vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str(); + if (_vm->_events->_leftButton) { + if (_vm->_events->_mouseRow >= 22) { + _vm->_events->debounceLeft(); + int x = _vm->_events->_mousePos.x; + for (int i = 0; i < 7; i++) { + if ((x >= cMouse->x) && (x < cMouse->y)) { + choice = i; + break; + } + } + } else { + _vm->_events->debounceLeft(); + choice = checkMouseBox1(responseCoords); + } + } + } while ((choice == -1) || ((choice == 2) && choice3Fl)); + + _choice = choice + 1; + _vm->_bubbleBox->clearBubbles(); +} + void Scripts::CMDWAIT() { error("TODO CMDWAIT"); } void Scripts::cmdSetConPos() { @@ -487,7 +591,12 @@ void Scripts::cmdClearBlock() { _vm->_screen->restoreBlock(); } -void Scripts::CMDLOADSOUND() { error("TODO CMDLOADSOUND"); } +void Scripts::cmdLoadSound() { + int idx = _data->readSint16LE(); + _vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSTable, _vm->_extraCells[idx]._vidSTable1); + _vm->_sound->_soundPriority[0] = 1; +} + void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); } void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 5f849410dc..6941c047d1 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -43,6 +43,8 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); + int checkMouseBox1(Common::Rect *rectArr); + /** * Print a given message to the screen in a bubble box */ @@ -103,14 +105,14 @@ protected: void CMDCYCLE(); void cmdCharSpeak(); void cmdTexSpeak(); - void CMDTEXCHOICE(); + void cmdTexChoice(); void CMDWAIT(); void cmdSetConPos(); void CMDCHECKVFRAME(); void cmdJumpChoice(); void cmdReturnChoice(); void cmdClearBlock(); - void CMDLOADSOUND(); + void cmdLoadSound(); void CMDFREESOUND(); void CMDSETVIDSND(); void CMDPLAYVIDSND(); -- cgit v1.2.3 From ad0be89459f318147f47e9c2bda29583a64592aa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 20:15:43 -0400 Subject: ACCESS: Simplified surface creation, added drawing for scaled flipped images --- engines/access/access.cpp | 6 +++--- engines/access/asurface.cpp | 24 +++++++++++++++++++++--- engines/access/asurface.h | 14 ++++++++++++-- engines/access/screen.cpp | 2 +- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 7d12ba5b35..ab58f8effc 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -153,8 +153,8 @@ void AccessEngine::initialize() { _screen = new Screen(this); _sound = new SoundManager(this, _mixer); - _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); - _buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); + _buffer2.create(g_system->getWidth(), g_system->getHeight()); } Common::Error AccessEngine::run() { @@ -272,7 +272,7 @@ void AccessEngine::plotList1() { bounds.setWidth(bounds.width() / _scale); if (ie._flags & 2) { - _buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top)); + _buffer2.sPlotB(frame, destBounds); } else { _buffer2.sPlotF(frame, destBounds); } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 99292278f3..746e8d0f5a 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -59,7 +59,7 @@ SpriteResource::~SpriteResource() { SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) { int xSize = stream.readUint16LE(); int ySize = stream.readUint16LE(); - create(xSize, ySize, Graphics::PixelFormat::createFormatCLUT8()); + create(xSize, ySize); // Empty surface byte *data = (byte *)getPixels(); @@ -138,6 +138,10 @@ ASurface::~ASurface() { _savedBlock.free(); } +void ASurface::create(uint16 width, uint16 height) { + Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8()); +} + void ASurface::clearBuffer() { byte *pSrc = (byte *)getPixels(); Common::fill(pSrc, pSrc + w * h, 0); @@ -301,8 +305,10 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { } } -void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) { - frame->copyTo(this, pt); +void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { + ASurface flippedFrame; + frame->flipHorizontal(flippedFrame); + flippedFrame.copyTo(this, bounds); } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { @@ -341,4 +347,16 @@ void ASurface::drawRect() { Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor); } +void ASurface::flipHorizontal(ASurface &dest) { + dest.create(this->w, this->h); + for (int y = 0; y < h; ++y) { + const byte *pSrc = (const byte *)getBasePtr(this->w - 1, y); + byte *pDest = (byte *)dest.getBasePtr(0, y); + + for (int x = 0; x < w; ++x, --pSrc, ++pDest) + *pDest = *pSrc; + } +} + + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 400dd07b4d..460f73d2c0 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -39,6 +39,8 @@ class ASurface : public Graphics::Surface { private: Graphics::Surface _savedBlock; Common::Rect _savedBounds; + + void flipHorizontal(ASurface &dest); public: static int _leftSkip, _rightSkip; static int _topSkip, _bottomSkip; @@ -56,6 +58,8 @@ public: public: virtual ~ASurface(); + void create(uint16 width, uint16 height); + void clearBuffer(); void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } @@ -64,10 +68,16 @@ public: void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); - void sPlotB(SpriteFrame *frame, const Common::Point &pt); - + /** + * Scaled draw frame + */ void sPlotF(SpriteFrame *frame, const Common::Rect &bounds); + /** + * Scaled flipped horizontal draw frame + */ + void sPlotB(SpriteFrame *frame, const Common::Rect &bounds); + void plotB(SpriteFrame *frame, const Common::Point &pt); void copyBlock(ASurface *src, const Common::Rect &bounds); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 8e9b08234f..3092d7e152 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -35,7 +35,7 @@ namespace Access { #define VGA_COLOR_TRANS(x) ((x) * 255 / 63) Screen::Screen(AccessEngine *vm) : _vm(vm) { - create(320, 200, Graphics::PixelFormat::createFormatCLUT8()); + create(320, 200); Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0); Common::fill(&_manPal[0], &_manPal[0x60], 0); Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0); -- cgit v1.2.3 From c4a3770cfea0169b24ff46317febaa5ba82a5359 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 22:15:23 -0400 Subject: ACCESS: Bugfixes for walking --- engines/access/player.cpp | 98 +++++++++++++++++++++++++++++------------------ 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 44dd0d2182..13c99eefc3 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -245,8 +245,11 @@ void Player::walkUp() { _playerDirection = UP; int walkOff = _walkOffUp[_frame - _upWalkMin]; - _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + int tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOff]; + _rawYTempL = (byte)tempL; + int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] - + (tempL < 0 ? 1 : 0); + _rawYTemp = yTemp; _rawXTemp = _rawPlayer.x; if (_vm->_room->codeWalls()) { @@ -273,8 +276,9 @@ void Player::walkDown() { _playerDirection = DOWN; int walkOff = _walkOffDown[_frame - _downWalkMin]; - _rawYTempL = _vm->_screen->_scaleTable2[walkOff]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff]; + int tempL = _vm->_screen->_scaleTable2[walkOff] + _rawPlayerLow.y; + _rawYTempL = (byte)tempL; + _rawYTemp = _vm->_screen->_scaleTable1[walkOff] + _rawPlayer.y + (tempL >= 0x100 ? 1 : 0); _rawXTemp = _rawPlayer.x; if (_vm->_room->codeWalls()) { @@ -288,8 +292,8 @@ void Player::walkDown() { // TODO: si = 0? } - if (++_frame > _upWalkMax) - _frame = _upWalkMin; + if (++_frame > _downWalkMax) + _frame = _downWalkMin; plotCom(0); } @@ -309,8 +313,10 @@ void Player::walkLeft() { } if (flag) { int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + int tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] - + (tempL < 0 ? 1 : 0); } else { _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; } @@ -347,11 +353,13 @@ void Player::walkRight() { _vm->_player->_scrollThreshold) > 0; } if (flag) { - int walkOffset = _walkOffLeft[_frame - _sideWalkMin]; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + int walkOffset = _walkOffRight[_frame - _sideWalkMin]; + int tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] - + (tempL >= 0x100 ? 1 : 0); } else { - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst]; } _rawYTemp = _rawPlayer.y; @@ -379,7 +387,7 @@ void Player::walkUpLeft() { _playerDirection = UPLEFT; - int walkOffset; + int walkOffset, tempL; bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); @@ -388,15 +396,19 @@ void Player::walkUpLeft() { } if (flag) { walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] - + (tempL < 0 ? 1 : 0); } else { _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; } walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; - _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTempL = (byte)tempL; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset] - + (tempL < 0 ? 1 : 0);; if (_vm->_room->codeWalls()) { plotCom2(); @@ -426,7 +438,7 @@ void Player::walkDownLeft() { _playerDirection = DOWNLEFT; - int walkOffset; + int walkOffset, tempL; bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); @@ -435,15 +447,19 @@ void Player::walkDownLeft() { } if (flag) { walkOffset = _walkOffDL[_frame - _sideWalkMin].x; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset] - + (tempL < 0 ? 1 : 0); } else { _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; } walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y; - _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.y + _vm->_screen->_scaleTable2[walkOffset]; + _rawYTempL = (byte)tempL; + _rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] + + (tempL >= 0x100 ? 1 : 0); if (_vm->_room->codeWalls()) { plotCom2(); @@ -473,7 +489,7 @@ void Player::walkUpRight() { _playerDirection = UPLEFT; - int walkOffset; + int walkOffset, tempL; bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); @@ -482,15 +498,19 @@ void Player::walkUpRight() { } if (flag) { walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] + + (tempL >= 0x100 ? 1 : 0); } else { - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst]; } walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; - _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTempL = (byte)tempL; + _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset] - + (tempL < 0 ? 1 : 0); if (_vm->_room->codeWalls()) { plotCom2(); @@ -520,7 +540,7 @@ void Player::walkDownRight() { _playerDirection = DOWNRIGHT; - int walkOffset; + int walkOffset, tempL; bool flag = _scrollEnd == 1; if (!flag) { calcPlayer(); @@ -529,16 +549,20 @@ void Player::walkDownRight() { } if (flag) { walkOffset = _walkOffUR[_frame - _sideWalkMin].x; - _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset]; - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset]; + _rawTempL = (byte)tempL; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] + + (tempL >= 0x100 ? 1 : 0); } else { - _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst]; } walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y; - _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; - _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset]; + tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + _rawYTempL = (byte)tempL; + _rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] + + (tempL >= 0x100 ? 1 : 0); if (_vm->_room->codeWalls()) { plotCom2(); @@ -565,8 +589,6 @@ void Player::walkDownRight() { void Player::checkMove() { if (_playerMove) { if (_xFlag == 0 && _yFlag == 0) { - // Figure out whether a greater horizontal movement than vertical - // movement will be required, or vice versa int xp = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; if (xp < 0) xp = -xp; @@ -574,7 +596,7 @@ void Player::checkMove() { if (yp < 0) yp = -yp; - if (xp > yp) + if (xp >= yp) _xFlag = 1; else _yFlag = 1; @@ -602,7 +624,7 @@ void Player::checkMove() { } } } else if (_xFlag == 1) { - int xd = _playerOffset.x / 2 + _rawPlayer.x - _moveTo.x; + int xd = _rawPlayer.x - _moveTo.x; if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { ++_xFlag; -- cgit v1.2.3 From 8d45ad265d0da07a1d2541cb74140185a8847417 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 18 Aug 2014 22:53:58 -0400 Subject: ACCESS: Fix walking right --- engines/access/player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 13c99eefc3..72d6389602 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -356,7 +356,7 @@ void Player::walkRight() { int walkOffset = _walkOffRight[_frame - _sideWalkMin]; int tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset]; _rawTempL = (byte)tempL; - _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] - + _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] + (tempL >= 0x100 ? 1 : 0); } else { _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst]; @@ -377,7 +377,7 @@ void Player::walkRight() { if (_frame > _sideWalkMax) _frame = _sideWalkMin; - plotCom1(); + plotCom(0); } } -- cgit v1.2.3 From 992ea95cd796aafeb1a1c61fcf29d57c7ecba8db Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 19 Aug 2014 07:48:00 +0200 Subject: ACCESS: Implement two opcodes --- engines/access/data.h | 2 +- engines/access/scripts.cpp | 33 +++++++++++++++++++++++++++++---- engines/access/scripts.h | 4 ++-- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/engines/access/data.h b/engines/access/data.h index 8ba3c58c82..1d1f85966a 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -43,7 +43,7 @@ public: struct TimerEntry { int _initTm; int _timer; - bool _flag; + byte _flag; TimerEntry() { _initTm = _timer = 0; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 1e5bbc8982..b4a231c784 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -102,8 +102,8 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::CMDSETTIMER, - &Scripts::CMDSETTIMER, &Scripts::CMDCHECKTIMER, &Scripts::cmdSetTravel, + &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, + &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, &Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, @@ -355,8 +355,33 @@ void Scripts::cmdDispInv() { _vm->_inventory->newDisplayInv(); } -void Scripts::CMDSETTIMER() { error("TODO CMDSETTIMER"); } -void Scripts::CMDCHECKTIMER() { error("TODO CMDCHECKTIMER"); } +void Scripts::cmdSetTimer() { + int idx = _data->readUint16LE(); + int val = _data->readUint16LE(); + + ++_vm->_timers[idx]._flag; + _vm->_timers[idx]._timer = val; + _vm->_timers[idx]._initTm = val; + + _vm->_events->debounceLeft(); + _vm->_events->zeroKeys(); +} + +void Scripts::cmdCheckTimer() { + int idx = _data->readUint16LE(); + + if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { + _vm->_events->zeroKeys(); + _vm->_timers[9]._timer = 0; + _vm->_timers[9]._flag = 0; + } + + int val = _data->readUint16LE() & 0xFF; + if (_vm->_timers[idx]._flag == val) + cmdGoto(); + else + _data->skip(2); +} void Scripts::cmdSetTravel() { if (_vm->_room->_selectCommand == 5) diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 6941c047d1..40f667a2f1 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -87,8 +87,8 @@ protected: void cmdCheckLoc(); void cmdSetAnim(); void cmdDispInv(); - void CMDSETTIMER(); - void CMDCHECKTIMER(); + void cmdSetTimer(); + void cmdCheckTimer(); void cmdSetTravel(); void CMDSETVID(); void CMDPLAYVID(); -- cgit v1.2.3 From b4f74b9b5e3b5eebcd695f8c07dd2d78e6a53a61 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Aug 2014 01:46:46 +0200 Subject: ACCESS: Use a variable delay of up to 20ms instead of a fix 50ms --- engines/access/access.cpp | 13 ++++++++++++- engines/access/access.h | 2 ++ engines/access/room.cpp | 4 ---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ab58f8effc..71271230dd 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -99,6 +99,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rKeyFlag = 0; _mapOffset = 0; _screenVirtX = 0; + _lastTime = g_system->getMillis(); + _curTime = 0; } AccessEngine::~AccessEngine() { @@ -171,7 +173,16 @@ void AccessEngine::dummyLoop() { // Dummy game loop while (!shouldQuit()) { _events->pollEvents(); - g_system->delayMillis(50); + + _curTime = g_system->getMillis(); + // Process machine once every tick + while (_curTime - _lastTime < 20) { + g_system->delayMillis(5); + _curTime = g_system->getMillis(); + } + + _lastTime = _curTime; + g_system->updateScreen(); if (_events->_leftButton) { diff --git a/engines/access/access.h b/engines/access/access.h index 88b6c837a5..f775310805 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -73,6 +73,8 @@ struct AccessGameDescription; class AccessEngine : public Engine { private: + uint32 _lastTime, _curTime; + /** * Handles basic initialisation */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 5e3a4d743d..e40c6b7096 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -79,10 +79,6 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } - // TODO: Game loop doesn't seem to have any delay. For now, - // introduce a slight delay here - _vm->_events->delay(50); - // Handle any events _vm->_events->pollEvents(); -- cgit v1.2.3 From 6066afb020b6213bc6f9ef5ba5c3d7171c695340 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Aug 2014 20:31:23 -0400 Subject: ACCESS: Fix z ordering of sprites on the screen --- engines/access/animation.cpp | 4 ++-- engines/access/animation.h | 2 +- engines/access/asurface.cpp | 4 ++-- engines/access/asurface.h | 2 +- engines/access/events.h | 2 +- engines/access/player.cpp | 2 +- engines/access/scripts.cpp | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 3a7424f1d0..d9a24e7a58 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -231,7 +231,7 @@ void Animation::setFrame1(AnimationFrame *frame) { ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex]; ie._frameNumber = part->_frameIndex; ie._position = part->_position + _vm->_animation->_base; - ie._priority = part->_priority - ie._position.y; + ie._offsetY = part->_offsetY - ie._position.y; _vm->_images.addToList(&ie); } @@ -271,7 +271,7 @@ AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { _frameIndex = stream.readByte(); _position.x = stream.readUint16LE(); _position.y = stream.readUint16LE(); - _priority = stream.readUint16LE(); + _offsetY = stream.readUint16LE(); } /*------------------------------------------------------------------------*/ diff --git a/engines/access/animation.h b/engines/access/animation.h index f70aa3239d..7e94f58cbd 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -129,7 +129,7 @@ public: int _spritesIndex; int _frameIndex; Common::Point _position; - int _priority; + int _offsetY; public: AnimationFramePart(Common::MemoryReadStream &stream); }; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 746e8d0f5a..44686ab8f4 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -85,14 +85,14 @@ SpriteFrame::~SpriteFrame() { ImageEntry::ImageEntry() { _frameNumber = 0; _spritesPtr = nullptr; - _priority = 0; + _offsetY = 0; _flags = 0; } /*------------------------------------------------------------------------*/ static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { - return ie1._priority < ie2._priority; + return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY); } void ImageEntryList::addToList(ImageEntry *ie) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 460f73d2c0..88e156100b 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -116,7 +116,7 @@ class ImageEntry { public: int _frameNumber; SpriteResource *_spritesPtr; - int _priority; + int _offsetY; Common::Point _position; int _flags; public: diff --git a/engines/access/events.h b/engines/access/events.h index 4c052f96f0..f7a5e9ce53 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -35,7 +35,7 @@ enum CursorType { CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP }; -#define GAME_FRAME_RATE 40 +#define GAME_FRAME_RATE 100 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) class AccessEngine; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 72d6389602..f3593d5dfc 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -675,7 +675,7 @@ void Player::plotCom3() { // Update the base ImageEntry fields for the player _position.x = _rawPlayer.x; _position.y = _rawPlayer.y - _playerOffset.y; - _priority = _playerOffset.y; + _offsetY = _playerOffset.y; _spritesPtr = _playerSprites; _frameNumber = _frame; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index b4a231c784..57f5788022 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -289,7 +289,7 @@ void Scripts::cmdSetTex() { _vm->_player->_scrollFlag |= scrlTemp; _vm->_player->_position = Common::Point(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y - _vm->_player->_playerOffset.y); - _vm->_player->_priority = _vm->_player->_playerOffset.y; + _vm->_player->_offsetY = _vm->_player->_playerOffset.y; _vm->_player->_spritesPtr = _vm->_player->_playerSprites; _vm->_player->_frameNumber = _vm->_player->_frame; -- cgit v1.2.3 From 23a442443f22f63a32e602b4e796981dbb9ee561 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 19 Aug 2014 20:43:32 -0400 Subject: ACCESS: Implemented cmdNewRoom opcode --- engines/access/access.cpp | 6 ++++++ engines/access/access.h | 2 ++ engines/access/scripts.cpp | 16 ++++++++++++++-- engines/access/scripts.h | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 71271230dd..6fcd64ecca 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -338,4 +338,10 @@ void AccessEngine::doLoadSave() { error("TODO: doLoadSave"); } +void AccessEngine::freeChar() { + _scripts->freeScriptData(); + _animation->clearTimers(); + _animation->freeAnimationData(); +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index f775310805..8cb1e72cfc 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -227,6 +227,8 @@ public: void copyBF2Vid(); void doLoadSave(); + + void freeChar(); }; } // End of namespace Access diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 57f5788022..3a3fb06b1a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -99,7 +99,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, - &Scripts::cmdSetTex, &Scripts::CMDNEWROOM, &Scripts::CMDCONVERSE, + &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::CMDCONVERSE, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, @@ -296,7 +296,19 @@ void Scripts::cmdSetTex() { _vm->_room->setWallCodes(); } -void Scripts::CMDNEWROOM() { error("TODO CMDNEWROOM"); } +#define CURRENT_ROOM 0xFF + +void Scripts::cmdNewRoom() { + int roomNumber = _data->readByte(); + if (roomNumber != CURRENT_ROOM) + _vm->_player->_roomNumber = roomNumber; + + _vm->_room->_function = 1; + _vm->freeChar(); + _vm->_converseMode = 0; + cmdRetPos(); +} + void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); } void Scripts::cmdCheckFrame() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 40f667a2f1..4b224c32bd 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -78,7 +78,7 @@ protected: void cmdSetInventory(); void cmdCheckInventory(); void cmdSetTex(); - void CMDNEWROOM(); + void cmdNewRoom(); void CMDCONVERSE(); void cmdCheckFrame(); void cmdCheckAnim(); -- cgit v1.2.3 From 70b8efacfbe4c314e73dcb946f16db4c49eab85b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 20 Aug 2014 23:04:04 +0200 Subject: ACCESS: Finish moving timer flag from bool to byte based on the assembly, modify some comments and TODOs --- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/data.cpp | 2 +- engines/access/data.h | 2 +- engines/access/player.cpp | 20 ++++++++++---------- engines/access/scripts.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 857d1b3551..c7fa6a7bdc 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -169,12 +169,12 @@ void AmazonEngine::setupGame() { for (int i = 0; i < 32; ++i) { TimerEntry te; te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; - te._flag = true; + te._flag = 1; _timers.push_back(te); } - // Miscellaenous + // Miscellaneous _fonts._font2.load(FONT2_INDEX, FONT2_DATA); _fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA); diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 124bfbca5a..094272b05c 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -52,7 +52,7 @@ void TimerList::updateTimers() { if (te._flag) { if (!--te._timer) { te._timer = te._initTm; - te._flag = false; + te._flag = 0; } } } diff --git a/engines/access/data.h b/engines/access/data.h index 1d1f85966a..e7a6d13fa1 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -47,7 +47,7 @@ struct TimerEntry { TimerEntry() { _initTm = _timer = 0; - _flag = false; + _flag = 0; } }; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index f3593d5dfc..420404bf48 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -97,7 +97,7 @@ void Player::load() { _vm->_timers[8]._initTm = 7; _vm->_timers[8]._timer = 7; - _vm->_timers[8]._flag = true; + ++_vm->_timers[8]._flag; _sideWalkMin = 0; _sideWalkMax = 5; @@ -191,7 +191,7 @@ void Player::walk() { return; } - _vm->_timers[0]._flag = true; + ++_vm->_timers[0]._flag; switch (_move) { case UP: _playerMove = false; @@ -260,7 +260,7 @@ void Player::walkUp() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) { - // TODO: si = 0? + warning("TODO: walkUp - si = 0?"); } if (++_frame > _upWalkMax) @@ -289,7 +289,7 @@ void Player::walkDown() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) { - // TODO: si = 0? + warning("TODO: walkDown - si = 0?"); } if (++_frame > _downWalkMax) @@ -330,7 +330,7 @@ void Player::walkLeft() { ++_frame; if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkLeft - si = 0?"); } if (_frame > _sideWalkMax) @@ -371,7 +371,7 @@ void Player::walkRight() { ++_frame; if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkRight - si = 0?"); } if (_frame > _sideWalkMax) @@ -422,7 +422,7 @@ void Player::walkUpLeft() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkUpLeft - si = 0?"); } if (_frame > _diagUpWalkMax) @@ -473,7 +473,7 @@ void Player::walkDownLeft() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkDownLeft - si = 0?"); } if (_frame > _diagDownWalkMax) @@ -524,7 +524,7 @@ void Player::walkUpRight() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkUpRight - si = 0?"); } if (_frame > _diagUpWalkMax) @@ -576,7 +576,7 @@ void Player::walkDownRight() { calcManScale(); if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - // TODO: si = 0? + warning("TODO: walkDownRight - si = 0?"); } if (_frame > _diagDownWalkMax) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 3a3fb06b1a..70a8d6a7a9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -189,7 +189,7 @@ void Scripts::printString(const Common::String &msg) { _vm->_fonts._printStart = Common::Point(20, 42); _vm->_timers[PRINT_TIMER]._timer = 50; _vm->_timers[PRINT_TIMER]._initTm = 50; - _vm->_timers[PRINT_TIMER]._flag = true; + ++_vm->_timers[PRINT_TIMER]._flag; // Display the text in a bubble, and wait for a keypress or mouse click _vm->_bubbleBox->placeBubble(msg); -- cgit v1.2.3 From c7d4958984f199e4f3a6677056c9904d7f235fbe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 21 Aug 2014 00:32:11 +0200 Subject: ACCESS: Implement partially doEstablish --- engines/access/access.cpp | 39 +++++++++++++++++++++++++++++++++------ engines/access/access.h | 13 ++++++++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6fcd64ecca..32835a01c8 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -217,18 +217,23 @@ void AccessEngine::freeInactiveData() { _inactive = nullptr; } -void AccessEngine::establish(int v1, int v2) { +void AccessEngine::establish(int v1, int sub) { _establishMode = 0; _establishGroup = 0; - doEstablish(v1, v2); + doEstablish(v1, sub); } -void AccessEngine::establishCenter(int v1, int v2) { +void AccessEngine::establishCenter(int v1, int sub) { _establishMode = 1; - doEstablish(v1, v2); + doEstablish(v1, sub); } -void AccessEngine::doEstablish(int v1, int v2) { +byte *AccessEngine::loadEstablish(int sub) { + warning("TODO: loadEstablish"); + return nullptr; +} + +void AccessEngine::doEstablish(int v1, int sub) { _screen->forceFadeOut(); _screen->clearScreen(); _screen->setPanel(3); @@ -241,7 +246,29 @@ void AccessEngine::doEstablish(int v1, int v2) { _room->setIconPalette(); _screen->forceFadeIn(); - warning("TODO: doEstablish"); + _fonts._charSet._lo = 1; + _fonts._charSet._hi = 10; + _fonts._charFor._lo = 29; + _fonts._charFor._hi = 32; + + _bubbleBox->_maxChars = 37; + _fonts._printOrg = _fonts._printStart = Common::Point(48, 35); + _eseg = loadEstablish(sub); + _et = sub; + warning("CHECKME: Use of di"); + _printEnd = 155; + if (_txtPages == 0) + warning("TODO: printText();"); + else + warning("TODO: speakText();"); + + _screen->forceFadeOut(); + _screen->clearScreen(); + + free(_eseg); + if (_establishMode == 0) { + warning("TODO: init4Quads();"); + } } void AccessEngine::plotList() { diff --git a/engines/access/access.h b/engines/access/access.h index 8cb1e72cfc..5423354800 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -87,7 +87,7 @@ private: void dummyLoop(); - void doEstablish(int v1, int v2); + void doEstablish(int v1, int sub); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -156,6 +156,11 @@ public: int _scaleI; bool _scaleFlag; + byte *_eseg; + int _et; + int _printEnd; + int _txtPages; + // Fields that are included in savegames int _conversation; int _currentMan; @@ -211,9 +216,11 @@ public: */ void freeInactiveData(); - void establish(int v1, int v2); + byte *AccessEngine::loadEstablish(int sub); + + void establish(int v1, int sub); - void establishCenter(int v1, int v2); + void establishCenter(int v1, int sub); void plotList(); void plotList1(); -- cgit v1.2.3 From 5870b18e175b8beee29654978d711d94ad92ddf5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 20:02:17 -0400 Subject: ACCESS: Fix for collision detection --- engines/access/player.cpp | 2 +- engines/access/room.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 420404bf48..063aa76c56 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -624,7 +624,7 @@ void Player::checkMove() { } } } else if (_xFlag == 1) { - int xd = _rawPlayer.x - _moveTo.x; + int xd = (_playerOffset.x / 2) + _rawPlayer.x - _moveTo.x; if ((xd >= 0 && xd <= -_leftDelta) || (xd < 0 && -xd <= -_leftDelta)) { ++_xFlag; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e40c6b7096..e7008c5ab7 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -593,7 +593,7 @@ int Room::calcLR(int yp) { int rem = (yv % yd) << 1; yv /= yd; - if (rem >= yd) + if (rem >= yd || rem < 0) ++yv; return yv + screen._orgX1; @@ -607,7 +607,7 @@ int Room::calcUD(int xp) { int rem = (xv % xd) << 1; xv /= xd; - if (rem >= xd) + if (rem >= xd || rem < 0) ++xv; return xv + screen._orgY1; @@ -638,7 +638,8 @@ bool Room::codeWalls() { if ((player._rawYTemp >= screen._orgY1) && (player._rawYTemp <= screen._orgY2)) { jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; - jf._wallCode1 |= (calcLR(player._rawYTemp) - player._playerOffset.x) < 0 ? 2 : 1; + jf._wallCode1 |= (calcLR(player._rawYTemp) - + (player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1; } } -- cgit v1.2.3 From 4e5eb04e47c96f98cdc6519ae79b908efc9888e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 20:22:35 -0400 Subject: ACCESS: Fix freeing player sprites when the scene changes --- engines/access/animation.cpp | 3 --- engines/access/player.cpp | 6 +++--- engines/access/room.cpp | 12 ++++++------ engines/access/room.h | 2 ++ engines/access/scripts.cpp | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index d9a24e7a58..b286237bfb 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -293,9 +293,6 @@ void AnimationManager::freeAnimationData() { } void AnimationManager::clearTimers() { - for (uint i = 0; i < _animationTimers.size(); ++i) - delete _animationTimers[i]; - _animationTimers.clear(); } diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 063aa76c56..e85b68a24d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -155,8 +155,7 @@ void Player::load() { } void Player::loadSprites(const Common::String &name) { - delete _playerSprites1; - _playerSprites = nullptr; + freeSprites(); const byte *data = _vm->_files->loadFile(name); _playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize, @@ -164,7 +163,8 @@ void Player::loadSprites(const Common::String &name) { } void Player::freeSprites() { - delete _playerSprites; + delete _playerSprites1; + _playerSprites1 = nullptr; _playerSprites = nullptr; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e7008c5ab7..f45ffe7afb 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -88,17 +88,17 @@ void Room::doRoom() { doCommands(); // DOROOMFLASHBACK jump point - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; - } else if (_function == 2) { + } else if (_function == FN_CLEAR2) { clearRoom(); return; - } else if (_function == 3) { + } else if (_function == FN_RELOAD) { reloadRoom1(); reloadFlag = true; break; - } else if (_function == 4) { + } else if (_function == FN_BREAK) { break; } @@ -108,7 +108,7 @@ void Room::doRoom() { _function = 0; roomLoop(); - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; } else { @@ -122,7 +122,7 @@ void Room::doRoom() { _function = 0; roomLoop(); - if (_function == 1) { + if (_function == FN_CLEAR1) { clearRoom(); break; } else { diff --git a/engines/access/room.h b/engines/access/room.h index c76bd7021b..9b3f922528 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -58,6 +58,8 @@ public: } }; +enum Function { FN_NONE = 0, FN_CLEAR1 = 1, FN_CLEAR2 = 2, FN_RELOAD = 3, FN_BREAK = 4 }; + class Room: public Manager { private: void roomLoop(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 70a8d6a7a9..f6879584f3 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -303,7 +303,7 @@ void Scripts::cmdNewRoom() { if (roomNumber != CURRENT_ROOM) _vm->_player->_roomNumber = roomNumber; - _vm->_room->_function = 1; + _vm->_room->_function = FN_CLEAR1; _vm->freeChar(); _vm->_converseMode = 0; cmdRetPos(); -- cgit v1.2.3 From a8dd2defaa3a6680102e230d091d705d54f87d7e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 20:27:52 -0400 Subject: ACCESS: Added scene debugger command --- engines/access/debugger.cpp | 36 ++++++++++++++++++++++++++++++++++++ engines/access/debugger.h | 1 + 2 files changed, 37 insertions(+) diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index e92e3402ac..d20b5d3e6b 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -28,6 +28,42 @@ namespace Access { Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); +} + +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +bool Debugger::Cmd_LoadScene(int argc, const char **argv) { + if (argc != 2) { + debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); + debugPrintf("Usage: %s \n", argv[0]); + return true; + } + else { + _vm->_player->_roomNumber = strToInt(argv[1]); + + _vm->_room->_function = FN_CLEAR1; + _vm->freeChar(); + _vm->_converseMode = 0; + _vm->_scripts->_endFlag = true; + _vm->_scripts->_returnCode = 0; + + return false; + } } } // End of namespace Access diff --git a/engines/access/debugger.h b/engines/access/debugger.h index dcf49c4ecd..6c8424dac4 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -34,6 +34,7 @@ class Debugger : public GUI::Debugger { private: AccessEngine *_vm; protected: + bool Cmd_LoadScene(int argc, const char **argv); public: public: Debugger(AccessEngine *vm); -- cgit v1.2.3 From afc41c7eecc5c8d6b410534b5c66aa02807d11cb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 20 Aug 2014 23:36:57 -0400 Subject: ACCESS: Added initial resources and detection entry for Martian Memorandum --- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/data.h | 2 +- engines/access/detection.cpp | 5 + engines/access/detection_tables.h | 18 + engines/access/files.cpp | 4 + engines/access/inventory.cpp | 8 +- engines/access/martian/martian_game.cpp | 172 +++++++ engines/access/martian/martian_game.h | 79 ++++ engines/access/martian/martian_resources.cpp | 649 +++++++++++++++++++++++++++ engines/access/martian/martian_resources.h | 48 ++ engines/access/martian/martian_room.cpp | 139 ++++++ engines/access/martian/martian_room.h | 62 +++ engines/access/martian/martian_scripts.cpp | 48 ++ engines/access/martian/martian_scripts.h | 49 ++ engines/access/module.mk | 6 +- 16 files changed, 1288 insertions(+), 5 deletions(-) create mode 100644 engines/access/martian/martian_game.cpp create mode 100644 engines/access/martian/martian_game.h create mode 100644 engines/access/martian/martian_resources.cpp create mode 100644 engines/access/martian/martian_resources.h create mode 100644 engines/access/martian/martian_room.cpp create mode 100644 engines/access/martian/martian_room.h create mode 100644 engines/access/martian/martian_scripts.cpp create mode 100644 engines/access/martian/martian_scripts.h diff --git a/engines/access/access.h b/engines/access/access.h index 5423354800..2185916c5a 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -59,7 +59,7 @@ namespace Access { enum { GType_Amazon = 1, - GType_MeanStreets = 2, + GType_MartianMemorandum = 2, GType_Noctropolis = 3 }; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index c7fa6a7bdc..286a7126bc 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -175,8 +175,8 @@ void AmazonEngine::setupGame() { } // Miscellaneous + _fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA); _fonts._font2.load(FONT2_INDEX, FONT2_DATA); - _fonts._font6x6.load(FONT6x6_INDEX, FONT6x6_DATA); // Set player room and position _player->_roomNumber = 4; diff --git a/engines/access/data.h b/engines/access/data.h index e7a6d13fa1..1601c689bf 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -145,7 +145,7 @@ public: Common::Point _printOrg; Common::Point _printStart; int _printMaxX; - Font _font6x6; + Font _font1; Font _font2; public: FontManager(); diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index 47f7af6191..dd75b28177 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -23,6 +23,7 @@ #include "access/access.h" #include "access/amazon/amazon_game.h" +#include "access/martian/martian_game.h" #include "base/plugins.h" #include "common/savefile.h" @@ -73,6 +74,7 @@ Common::Platform AccessEngine::getPlatform() const { static const PlainGameDescriptor AccessGames[] = { {"Access", "Access"}, {"amazon", "Amazon: Guardians of Eden"}, + { "martian", "Martian Memorandum"}, {0, 0} }; @@ -123,6 +125,9 @@ bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGa case Access::GType_Amazon: *engine = new Access::Amazon::AmazonEngine(syst, gd); break; + case Access::GType_MartianMemorandum: + *engine = new Access::Martian::MartianEngine(syst, gd); + break; default: error("Unknown game"); } diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index ad962f47b2..6a281a7e96 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -59,6 +59,24 @@ static const AccessGameDescription gameDescriptions[] = { 0 }, + { + // Martian Memorandum + { + "martian", + nullptr, + { + { "r00.ap", 0, "af98db5ee7f9ef86c6b1f43187a3691b", 31 }, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + GType_MartianMemorandum, + 0 + }, + { AD_TABLE_END_MARKER, 0, 0 } }; diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 1ebc2fa8eb..970b0b9019 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -22,6 +22,7 @@ #include "access/files.h" #include "access/amazon/amazon_resources.h" +#include "access/martian/martian_resources.h" #include "access/access.h" namespace Access { @@ -31,6 +32,9 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) { case GType_Amazon: _filenames = &Amazon::FILENAMES[0]; break; + case GType_MartianMemorandum: + _filenames = &Martian::FILENAMES[0]; + break; default: error("Unknown game"); } diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 15668b0bc2..e90ad62344 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -23,6 +23,7 @@ #include "access/inventory.h" #include "access/access.h" #include "access/amazon/amazon_resources.h" +#include "access/martian/martian_resources.h" namespace Access { @@ -35,11 +36,16 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _startAboutItem = 0; _startTravelItem = 0; - const char *const *names = Amazon::INVENTORY_NAMES; + const char *const *names; switch (vm->getGameID()) { case GType_Amazon: + names = Amazon::INVENTORY_NAMES; _inv.resize(85); break; + case GType_MartianMemorandum: + names = Martian::INVENTORY_NAMES; + _inv.resize(54); + break; default: error("Unknown game"); } diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp new file mode 100644 index 0000000000..f087b56ac6 --- /dev/null +++ b/engines/access/martian/martian_game.cpp @@ -0,0 +1,172 @@ +/* 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 "access/resources.h" +#include "access/martian/martian_game.h" +#include "access/martian/martian_resources.h" +#include "access/martian/martian_room.h" +#include "access/martian/martian_scripts.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +namespace Martian { + +MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) : + AccessEngine(syst, gameDesc) { +} + +MartianEngine::~MartianEngine() { +} + +void MartianEngine::playGame() { + // Do introduction + doIntroduction(); + if (shouldQuit()) + return; + + // Setup the game + setupGame(); + + _screen->clearScreen(); + _screen->setPanel(0); + _screen->forceFadeOut(); + + _events->showCursor(); + + // Setup and execute the room + _room = new MartianRoom(this); + _scripts = new MartianScripts(this); + _room->doRoom(); +} + +void MartianEngine::doIntroduction() { + _screen->setInitialPalettte(); + _events->setCursor(CURSOR_ARROW); + _events->showCursor(); + _screen->setPanel(0); + + // TODO: Worry about implementing full intro sequence later + return; + + doTitle(); + if (shouldQuit()) + return; + + if (!_skipStart) { + _screen->setPanel(3); + doOpening(); + if (shouldQuit()) + return; + + if (!_skipStart) { + doTent(); + if (shouldQuit()) + return; + } + } + + doTitle(); +} + +void MartianEngine::doTitle() { + _screen->setDisplayScan(); + _destIn = &_buffer2; + + _screen->forceFadeOut(); + _events->hideCursor(); + + _sound->queueSound(0, 98, 30); + _sound->_soundPriority[0] = 1; + + _screen->_loadPalFlag = false; + _files->loadScreen(0, 3); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _screen->forceFadeIn(); + _sound->playSound(1); + + byte *spriteData = _files->loadFile(0, 2); + _objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize, + DisposeAfterUse::YES); + + _sound->playSound(1); + + _screen->_loadPalFlag = false; + _files->loadScreen(0, 4); + _sound->playSound(1); + + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _sound->playSound(1); + + const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; + for (_pCount = 0; _pCount < 3; ++_pCount) { + _buffer2.copyFrom(_buffer1); + int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); + int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); + _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); + } + // TODO: More to do + + delete _objectsTable[0]; +} + +void MartianEngine::doOpening() { + warning("TODO doOpening"); +} + +void MartianEngine::doTent() { + warning("TODO doTent"); +} + +void MartianEngine::setupGame() { + + // Setup timers + const int TIMER_DEFAULTS[] = { 4, 10, 8, 1, 1, 1, 1, 2 }; + for (int i = 0; i < 32; ++i) { + TimerEntry te; + te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; + te._flag = 1; + + _timers.push_back(te); + } + + // Miscellaneous + // TODO: Replace with Martian fonts when located + _fonts._font1.load(Amazon::FONT6x6_INDEX, Amazon::FONT6x6_DATA); + _fonts._font2.load(Amazon::FONT2_INDEX, Amazon::FONT2_DATA); + + // Set player room and position + _player->_roomNumber = 7; + _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; + _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; +} + +void MartianEngine::drawHelp() { + error("TODO: drawHelp"); +} + +} // End of namespace Martian + +} // End of namespace Access diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h new file mode 100644 index 0000000000..29fdd1b2ce --- /dev/null +++ b/engines/access/martian/martian_game.h @@ -0,0 +1,79 @@ +/* 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 ACCESS_MARTIAN_GAME_H +#define ACCESS_MARTIAN_GAME_H + +#include "access/access.h" + +namespace Access { + +namespace Martian { + +class MartianEngine : public AccessEngine { +private: + bool _skipStart; + + /** + * Do the game introduction + */ + void doIntroduction(); + + /** + * Do title sequence + */ + void doTitle(); + + /** + * Do opening sequence + */ + void doOpening(); + + /** + * Do tent scene of introduction + */ + void doTent(); + + /** + * Setup variables for the game + */ + void setupGame(); + +protected: + /** + * Play the game + */ + virtual void playGame(); +public: +public: + MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc); + + virtual ~MartianEngine(); + + void drawHelp(); +}; + +} // End of namespace Martian + +} // End of namespace Access + +#endif /* ACCESS_MARTIAN_GAME_H */ diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp new file mode 100644 index 0000000000..6e881f3b36 --- /dev/null +++ b/engines/access/martian/martian_resources.cpp @@ -0,0 +1,649 @@ +/* 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 "access/martian/martian_resources.h" +#include "access/access.h" + +namespace Access { + +namespace Martian { + +const char *const FILENAMES[] = { + "R00.AP", "R01.AP", "R02.AP", "R03.AP", "R04.AP", "R05.AP", "R06.AP", "R07.AP", + "R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP", + "R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP", + "R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP", + "R32.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", "R40.AP", + "TITLE.AP","R42.AP","S01.AP", "R45.AP","SOUND.AP","MUSIC.AP","DEAD.AP","EST.AP", + "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", "C07.AP", "LOVE.AP", + "CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", "C12.AP", "C16.AP", + "CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", "C16A.AP","C09.AP", + "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP" +}; + +const byte MOUSE0[] = { + 0, 0, 0, 0, 0, 2, 0xF7, 5, 0, 3, 0xF7, 0xF7, 5, 0, 3, + 0xF7, 0xF7, 5, 0, 4, 0xF7, 0xF7, 0xF7, 5, 0, 4, 0xF7, + 0xF7, 0xF7, 5, 0, 5, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 5, + 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 6, 0xF7, 0xF7, 0xF7, 0xF7, + 0xF7, 5, 0, 6, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 7, + 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 5, 0, 6, 0xF7, 0xF7, + 0xF7, 0xF7, 0xF7, 5, 0, 5, 0xF7, 0xF7, 0xF7, 0xF7, 5, + 2, 3, 0xF7, 0xF7, 5, 3, 3, 0xF7, 0xF7, 5, 3, 3, 0xF7, + 0xF7, 5, 4, 2, 0xF7, 5 +}; +const byte MOUSE1[] = { + 7, 0, 7, 0, 6, 1, 0xF7, 4, 5, 0xFF, 0xFF, 0, 0xFF, 0xFF, + 3, 7, 0xFF, 0, 0, 0, 0, 0, 0xFF, 2, 9, 0xFF, 0, 0, 0, + 0xF7, 0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0xF7, 0, 0, + 0, 0, 0xFF, 0, 13, 0xF7, 0, 0, 0xF7, 0, 0xF7, 0, 0xF7, + 0, 0xF7, 0, 0, 0xF7, 1, 11, 0xFF, 0, 0, 0, 0, 0xF7, + 0, 0, 0, 0, 0xFF, 1, 11, 0xFF, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0xFF, 2, 9, 0xFF, 0, 0, 0, 0xF7, 0, 0, 0, 0xFF, + 3, 7, 0xFF, 0, 0, 0, 0, 0, 0xFF, 4, 5, 0xFF, 0xFF, 0, + 0xFF, 0xFF, 6, 1, 0xF7, 0, 0, 0, 0, 0, 0 +}; +const byte MOUSE2[] = { + 8, 0, 8, 0, 0, 0, 0, 0, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, + 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 2, 12, 4, 4, 4, 4, 4, + 0, 4, 4, 4, 4, 4, 5, 7, 2, 4, 5, 7, 2, 4, 5, 7, 2, 4, + 5, 7, 2, 4, 5, 7, 2, 4, 5, 0, 0, 0, 0, 0, 0 +}; +const byte MOUSE3[] = { + 0, 0, 0, 0, 0, 11, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 0, 12, 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 5, 0, 12, + 6, 7, 7, 7, 7, 7, 7, 7, 7, 6, 5, 5, 0, 12, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 5, + 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 5, 0, 0, 6, 6, + 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 0, 6, 6, 6, 6, 6, 5, + 0, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, + 6, 6, 5, 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 5, + 6, 6, 6, 6, 6, 5, 0, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 5, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, + 0, 0, 0, 0, 0 +}; +const byte *CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 }; + +const int TRAVEL_POS[][2] = { + { -1, 0 }, + { 228, 117 }, + { 28, 98 }, + { 161, 140 }, + { 160, 116 }, + { 34, 119 }, + { 166, 105 }, + { 260, 126 }, + { 37, 107 }, + { 78, 139 }, + { 0, 0 }, + { 13, 112 }, + { 0, 0 }, + { 16, 122 }, + { 33, 126 }, + { 10, 160 }, + { 150, 102 }, + { 134, 160 }, + { 160, 76 }, + { 0, 0 }, + { 0, 0 }, + { 36, 116 }, + { 214, 113 }, + { 30, 127 }, + { 143, 131 }, + { 163, 103 }, + { 254, 106 }, + { 28, 161 }, + { 11, 164 }, + { 276, 134 }, + { 93, 118 }, + { 22, 150 }, + { 282, 156 }, + { 149, 92 }, + { 0, 0 }, + { 43, 410 }, + { 0, 0 }, + { 10, 136 }, + { 41, 100 }, + { 157, 97 }, + { -1, 5 }, + { -1, 4 }, + { -1, 10 }, + { -1, 7 }, + { -1, 3 }, + { -1, 8 }, + { -1, 6 }, + { -1, 20 }, + { -1, 18 }, + { -1, 19 }, + { -1, 21 } +}; + +const char *const INVENTORY_NAMES[] = { + "CAMERA", "LENS", "PHOTOS", "MAIL", "GUN", "CASH", "COMLINK", "AMMO", + "LOCKPICK KIT", "EARRING", "RECIEPTS", "PAPER", "LADDER", "BOOTS", + "DOCUMENTS", "KNIFE", "DAGGER", "KEYS", "ROCK", "LOG", "SHOVEL", + "STONE", "REMOTE CONTROL", "FOOD AND WATER", "DOOR CARD KEY", + "FLASHLIGHT", "INTERLOCK KEY", "TOOLS", "REBREATHER", "JET PACK", + "ROD", "HCL2", "SAFE CARD KEY", "TUNING FORK", "STONE", "ROSE", + "KEY", "NOTE", "ALLEN WRENCH", "HOVER BOARD", "BLUE PRINTS", + "LETTER", "MEMORANDUM", "MARKERS", "FILM", "ANDRETTI FILM", + "GLASSES", "AMULET", "FACIAL KIT", "CAT FOOD", "MONKEY WRENCH", + "BIG DICK CARD", "BRA", "BOLT" +}; + +const byte ROOM_TABLE1[] = { + 0x00, 0x2f, 0x00, 0x0d, 0x00, 0x30, 0x22, 0x30, 0x01, 0x00, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0xff, 0x01, 0x00, + 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0xc0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE2[] = { + 0x00, 0x2f, 0x00, 0x0d, 0x00, 0x32, 0x28, 0x25, 0x02, 0x00, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x03, 0x00, 0xff, 0x02, 0x00, + 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x06, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE3[] = { + 0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1e, 0x19, 0x24, 0x03, 0x00, + 0x00, 0x00, 0x03, 0x03, 0x00, 0x03, 0x00, 0xff, 0x03, 0x00, + 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x78, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x03, 0x00, 0x05, 0x00, + 0x01, 0x00, 0x03, 0x00, 0x06, 0x00, 0x01, 0x00, 0x2e, 0x00, + 0x01, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE4[] = { + 0x00, 0x2f, 0x00, 0x06, 0x00, 0x36, 0x27, 0x32, 0x04, 0x00, + 0x00, 0x00, 0x04, 0x04, 0x00, 0x03, 0x00, 0xff, 0x04, 0x00, + 0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x05, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE5[] = { + 0x00, 0x2f, 0x00, 0x00, 0x00, 0x28, 0x19, 0x36, 0x05, 0x00, + 0x00, 0x00, 0x05, 0x05, 0x00, 0x03, 0x00, 0xff, 0x05, 0x00, + 0x02, 0x00, 0x05, 0x00, 0x01, 0x00, 0xa0, 0x20, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x02, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x03, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE6[] = { + 0x00, 0x2f, 0x00, 0x07, 0x00, 0x40, 0x36, 0x36, 0x06, 0x00, + 0x00, 0x00, 0x06, 0x06, 0x00, 0x03, 0x00, 0xff, 0x06, 0x00, + 0x02, 0x00, 0x06, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x13, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x08, 0x00, + 0x01, 0x00, 0x2e, 0x00, 0x14, 0x00, 0x01, 0x00, 0x2e, 0x00, + 0x07, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE7[] = { + 0x00, 0x2f, 0x00, 0x0e, 0x00, 0x40, 0x32, 0x3b, 0x07, 0x00, + 0x00, 0x00, 0x07, 0x07, 0x00, 0x03, 0x00, 0xff, 0x07, 0x00, + 0x02, 0x00, 0x07, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x14, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE8[] = { + 0x00, 0x2f, 0x00, 0x0a, 0x00, 0x30, 0x22, 0x46, 0x08, 0x00, + 0x00, 0x00, 0x08, 0x08, 0x00, 0x03, 0x00, 0xff, 0x08, 0x00, + 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0xc0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE9[] = { + 0x00, 0x2f, 0x00, 0x07, 0x00, 0x32, 0x0c, 0x29, 0x09, 0x00, + 0x00, 0x00, 0x09, 0x09, 0x00, 0x03, 0x00, 0xff, 0x09, 0x00, + 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE11[] = { + 0x00, 0x2f, 0x00, 0x00, 0x00, 0x40, 0x3a, 0x22, 0x0b, 0x00, + 0x00, 0x00, 0x0b, 0x0b, 0x00, 0x03, 0x00, 0xff, 0x0b, 0x00, + 0x02, 0x00, 0x0b, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE13[] = { + 0x00, 0x2f, 0x00, 0x0c, 0x00, 0x40, 0x36, 0x2c, 0x0d, 0x00, + 0x00, 0x00, 0x0d, 0x0d, 0x00, 0x03, 0x00, 0xff, 0x0d, 0x00, + 0x02, 0x00, 0x0d, 0x00, 0x01, 0x00, 0xe6, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0x2e, 0x00, 0x0b, 0x00, 0x01, 0x00, 0x2e, 0x00, + 0x15, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE14[] = { + 0x00, 0x2f, 0x00, 0x05, 0x00, 0x40, 0x3e, 0x33, 0x0e, 0x00, + 0x00, 0x00, 0x0e, 0x0e, 0x00, 0x03, 0x00, 0xff, 0x0e, 0x00, + 0x02, 0x00, 0x0e, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x09, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0x2e, 0x00, 0x13, 0x00, 0x01, 0x00, 0x2e, 0x00, + 0x0a, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE15[] = { + 0x00, 0x2f, 0x00, 0x0c, 0x00, 0x28, 0x0c, 0x5e, 0x0f, 0x00, + 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x03, 0x00, 0xff, 0x0f, 0x00, + 0x02, 0x00, 0x0f, 0x00, 0x01, 0x00, 0xb4, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x11, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE16[] = { + 0x00, 0x2f, 0x00, 0x05, 0x00, 0x28, 0x1e, 0x24, 0x10, 0x00, + 0x00, 0x00, 0x10, 0x10, 0x00, 0x03, 0x00, 0xff, 0x10, 0x00, + 0x02, 0x00, 0x10, 0x00, 0x01, 0x00, 0xa0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE17[] = { + 0x00, 0x2f, 0x00, 0x06, 0x00, 0x28, 0x19, 0x2b, 0x11, 0x00, + 0x00, 0x00, 0x11, 0x11, 0x00, 0x03, 0x00, 0xff, 0x11, 0x00, + 0x02, 0x00, 0x11, 0x00, 0x01, 0x00, 0xa0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE18[] = { + 0x00, 0x2f, 0x00, 0x00, 0x00, 0x2d, 0x14, 0x3c, 0x12, 0x00, + 0x00, 0x00, 0x12, 0x12, 0x00, 0x03, 0x00, 0xff, 0x12, 0x00, + 0x02, 0x00, 0x12, 0x00, 0x01, 0x00, 0xb1, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE21[] = { + 0x00, 0x2f, 0x00, 0x07, 0x00, 0x3c, 0x2a, 0x29, 0x15, 0x00, + 0x00, 0x00, 0x15, 0x15, 0x00, 0x03, 0x00, 0xff, 0x15, 0x00, + 0x02, 0x00, 0x15, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x12, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE22[] = { + 0x00, 0x2f, 0x00, 0x0a, 0x00, 0x40, 0x2d, 0x27, 0x16, 0x00, + 0x00, 0x00, 0x16, 0x16, 0x00, 0x03, 0x00, 0xff, 0x16, 0x00, + 0x02, 0x00, 0x16, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE23[] = { + 0x00, 0x2f, 0x00, 0x0a, 0x00, 0x40, 0x38, 0x24, 0x17, 0x00, + 0x00, 0x00, 0x17, 0x17, 0x00, 0x03, 0x00, 0xff, 0x17, 0x00, + 0x02, 0x00, 0x17, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x17, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE24[] = { + 0x00, 0x2f, 0x00, 0x06, 0x00, 0x3e, 0x10, 0x62, 0x18, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x03, 0x00, 0xff, 0x18, 0x00, + 0x02, 0x00, 0x18, 0x00, 0x01, 0x00, 0xf8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE25[] = { + 0x00, 0x2f, 0x00, 0x0e, 0x00, 0x3e, 0x37, 0x19, 0x19, 0x00, + 0x00, 0x00, 0x19, 0x19, 0x00, 0x03, 0x00, 0xff, 0x19, 0x00, + 0x02, 0x00, 0x19, 0x00, 0x01, 0x00, 0xf8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x10, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE26[] = { + 0x00, 0x2f, 0x00, 0x06, 0x00, 0x34, 0x28, 0x28, 0x1a, 0x00, + 0x00, 0x00, 0x1a, 0x1a, 0x00, 0x03, 0x00, 0xff, 0x1a, 0x00, + 0x02, 0x00, 0x1a, 0x00, 0x01, 0x00, 0xd0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE27[] = { + 0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1b, 0x16, 0x18, 0x1b, 0x00, + 0x00, 0x00, 0x1b, 0x1b, 0x00, 0x03, 0x00, 0xff, 0x1b, 0x00, + 0x02, 0x00, 0x1b, 0x00, 0x01, 0x00, 0x70, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE28[] = { + 0x00, 0x2f, 0x00, 0x09, 0x00, 0x25, 0x10, 0x43, 0x1c, 0x00, + 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x03, 0x00, 0xff, 0x1c, 0x00, + 0x02, 0x00, 0x1c, 0x00, 0x01, 0x00, 0x94, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE29[] = { + 0x00, 0x2f, 0x00, 0x0a, 0x00, 0x20, 0x18, 0x56, 0x1d, 0x00, + 0x00, 0x00, 0x1d, 0x1d, 0x00, 0x03, 0x00, 0xff, 0x1d, 0x00, + 0x02, 0x00, 0x1d, 0x00, 0x01, 0x00, 0x80, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x17, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x10, 0x00, + 0x02, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE30[] = { + 0x00, 0x2f, 0x00, 0x07, 0x00, 0x3f, 0x1c, 0x27, 0x1e, 0x00, + 0x00, 0x00, 0x1e, 0x1e, 0x00, 0x03, 0x00, 0xff, 0x1e, 0x00, + 0x02, 0x00, 0x1e, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x1e, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x15, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE31[] = { + 0x00, 0x2f, 0x00, 0x0d, 0x00, 0x32, 0x2e, 0x69, 0x1f, 0x00, + 0x00, 0x00, 0x1f, 0x1f, 0x00, 0x03, 0x00, 0xff, 0x1f, 0x00, + 0x02, 0x00, 0x1f, 0x00, 0x01, 0x00, 0xc8, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE32[] = { + 0x00, 0x2f, 0x00, 0x07, 0x00, 0x40, 0x3b, 0x4b, 0x20, 0x00, + 0x00, 0x00, 0x20, 0x20, 0x00, 0x03, 0x00, 0xff, 0x20, 0x00, + 0x02, 0x00, 0x20, 0x00, 0x01, 0x00, 0xfe, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x05, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE33[] = { + 0x00, 0x2f, 0x00, 0x0b, 0x00, 0x30, 0x10, 0x51, 0x21, 0x00, + 0x00, 0x00, 0x21, 0x21, 0x00, 0x03, 0x00, 0xff, 0x21, 0x00, + 0x02, 0x00, 0x21, 0x00, 0x01, 0x00, 0xc0, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xff, 0xff, +}; +const byte ROOM_TABLE35[] = { + 0x00, 0x2f, 0x00, 0x0f, 0x00, 0x1e, 0x18, 0x25, 0x23, 0x00, + 0x00, 0x00, 0x23, 0x23, 0x00, 0x03, 0x00, 0xff, 0x23, 0x00, + 0x02, 0x00, 0x23, 0x00, 0x01, 0x00, 0x78, 0x18, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x07, 0x00, + 0x01, 0x00, 0x2e, 0x00, 0x16, 0x00, 0x01, 0x00, 0x2e, 0x00, + 0x0c, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE37[] = { + 0x00, 0x2f, 0x00, 0x0f, 0x00, 0x3f, 0x3a, 0x1a, 0x25, 0x00, + 0x00, 0x00, 0x25, 0x25, 0x00, 0x03, 0x00, 0xff, 0x25, 0x00, + 0x02, 0x00, 0x25, 0x00, 0x01, 0x00, 0xfe, 0x40, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0d, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE38[] = { + 0x00, 0x2f, 0x00, 0x0d, 0x00, 0x40, 0x32, 0x32, 0x26, 0x00, + 0x00, 0x00, 0x26, 0x26, 0x00, 0x03, 0x00, 0xff, 0x26, 0x00, + 0x02, 0x00, 0x26, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x0b, 0x00, 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE39[] = { + 0x00, 0x2f, 0x00, 0x0a, 0x00, 0x3c, 0x10, 0x4c, 0x27, 0x00, + 0x00, 0x00, 0x27, 0x27, 0x00, 0x03, 0x00, 0xff, 0x27, 0x00, + 0x02, 0x00, 0x27, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x2e, 0x00, 0x11, 0x00, 0x01, 0x00, 0x2e, 0x00, 0x0f, 0x00, + 0x01, 0x00, 0xff, 0xff, +}; +const byte ROOM_TABLE47[] = { + 0x00, 0x2f, 0x00, 0x06, 0x00, 0x28, 0x1e, 0x32, 0x2b, 0x00, + 0x00, 0x00, 0x46, 0x2b, 0x00, 0x03, 0x00, 0xff, 0x2b, 0x00, + 0x02, 0x00, 0x2b, 0x00, 0x01, 0x00, 0xf0, 0x00, 0xff, 0xff, + 0xff, 0xff, 0x2b, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00, + 0x04, 0x00, 0x01, 0x00, 0xff, 0xff, 0x00, +}; +const byte *ROOM_TABLE[] = { + nullptr, ROOM_TABLE1, ROOM_TABLE2, ROOM_TABLE3, ROOM_TABLE4, ROOM_TABLE5, ROOM_TABLE6, + ROOM_TABLE7, ROOM_TABLE8, ROOM_TABLE9, nullptr, ROOM_TABLE11, nullptr, ROOM_TABLE13, + ROOM_TABLE14, ROOM_TABLE15, ROOM_TABLE16, ROOM_TABLE17, ROOM_TABLE18, nullptr, nullptr, + ROOM_TABLE21, ROOM_TABLE22, ROOM_TABLE23, ROOM_TABLE24, ROOM_TABLE25, ROOM_TABLE26, ROOM_TABLE27, + ROOM_TABLE28, ROOM_TABLE29, ROOM_TABLE30, ROOM_TABLE31, ROOM_TABLE32, ROOM_TABLE33, nullptr, + ROOM_TABLE35, nullptr, ROOM_TABLE37, ROOM_TABLE38, ROOM_TABLE39, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47 +}; + +const byte CHAR_TABLE0[] = { + 0x02, 0x31, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE2[] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x32, 0x33, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x00, 0x33, + 0x00, 0x02, 0x00, 0x33, 0x00, 0x0b, 0x00, 0x33, 0x00, 0x03, + 0x00, 0x33, 0x00, 0x0c, 0x00, 0x33, 0x00, 0x04, 0x00, 0x33, + 0x00, 0x0d, 0x00, 0x33, 0x00, 0x05, 0x00, 0x33, 0x00, 0x0e, + 0x00, 0x33, 0x00, 0x06, 0x00, 0x33, 0x00, 0x0f, 0x00, 0x33, + 0x00, 0x07, 0x00, 0x33, 0x00, 0x10, 0x00, 0x33, 0x00, 0x08, + 0x00, 0x33, 0x00, 0x11, 0x00, 0x33, 0x00, 0x09, 0x00, 0x33, + 0x00, 0x12, 0x00, 0x33, 0x00, 0x0a, 0x00, 0x33, 0x00, 0x13, + 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE3[] = { + 0x02, 0x31, 0x00, 0x03, 0x00, 0x35, 0x00, 0x37, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x4b, 0x37, 0x00, 0x01, 0x00, + 0xff, 0x37, 0x00, 0x03, 0x00, 0x37, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE4[] = { + 0x01, 0x31, 0x00, 0x0a, 0x00, 0x36, 0x00, 0x35, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x49, 0x35, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x35, 0x00, 0x00, 0x00, 0x35, + 0x00, 0x03, 0x00, 0x35, 0x00, 0x0c, 0x00, 0x35, 0x00, 0x04, + 0x00, 0x35, 0x00, 0x0d, 0x00, 0x35, 0x00, 0x05, 0x00, 0x35, + 0x00, 0x0e, 0x00, 0x35, 0x00, 0x06, 0x00, 0x35, 0x00, 0x0f, + 0x00, 0x35, 0x00, 0x07, 0x00, 0x35, 0x00, 0x10, 0x00, 0x35, + 0x00, 0x08, 0x00, 0x35, 0x00, 0x11, 0x00, 0x35, 0x00, 0x09, + 0x00, 0x35, 0x00, 0x12, 0x00, 0x35, 0x00, 0x0a, 0x00, 0x35, + 0x00, 0x13, 0x00, 0x35, 0x00, 0x0b, 0x00, 0x35, 0x00, 0x14, + 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE5[] = { + 0x01, 0x31, 0x00, 0x08, 0x00, 0x37, 0x00, 0x34, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x48, 0x34, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x34, 0x00, 0x00, 0x00, 0x43, + 0x00, 0x00, 0x00, 0x34, 0x00, 0x03, 0x00, 0x43, 0x00, 0x01, + 0x00, 0x34, 0x00, 0x04, 0x00, 0x43, 0x00, 0x02, 0x00, 0x34, + 0x00, 0x05, 0x00, 0x43, 0x00, 0x03, 0x00, 0x34, 0x00, 0x06, + 0x00, 0x43, 0x00, 0x04, 0x00, 0x34, 0x00, 0x07, 0x00, 0x43, + 0x00, 0x05, 0x00, 0x34, 0x00, 0x08, 0x00, 0x43, 0x00, 0x06, + 0x00, 0x34, 0x00, 0x09, 0x00, 0x43, 0x00, 0x07, 0x00, 0x34, + 0x00, 0x0a, 0x00, 0x43, 0x00, 0x08, 0x00, 0x34, 0x00, 0x0b, + 0x00, 0x43, 0x00, 0x09, 0x00, 0x34, 0x00, 0x0c, 0x00, 0x43, + 0x00, 0x0a, 0x00, 0x34, 0x00, 0x0d, 0x00, 0x43, 0x00, 0x0b, + 0x00, 0x34, 0x00, 0x0e, 0x00, 0x43, 0x00, 0x0c, 0x00, 0x34, + 0x00, 0x0f, 0x00, 0x43, 0x00, 0x0d, 0x00, 0x34, 0x00, 0x10, + 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE6[] = { + 0x02, 0x31, 0x00, 0x03, 0x00, 0x38, 0x00, 0x44, 0x00, 0x03, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x4e, 0x44, 0x00, 0x01, 0x00, + 0xff, 0x44, 0x00, 0x02, 0x00, 0x44, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE7[] = { + 0x02, 0x31, 0x00, 0x01, 0x00, 0x39, 0x00, 0x38, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x4c, 0x38, 0x00, 0x01, 0x00, + 0xff, 0x38, 0x00, 0x03, 0x00, 0x38, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE8[] = { + 0x03, 0xff, 0xff, 0xff, 0xff, 0x3a, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x3b, 0x00, 0x01, 0x00, + 0xff, 0x3b, 0x00, 0x02, 0x00, 0x3b, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE9[] = { + 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x59, 0x4a, 0x00, 0x01, 0x00, + 0xff, 0x4a, 0x00, 0x02, 0x00, 0x4a, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE10[] = { + 0x01, 0x31, 0x00, 0x0a, 0x00, 0x3c, 0x00, 0x36, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x4a, 0x36, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x36, 0x00, 0x00, 0x00, 0x36, + 0x00, 0x03, 0x00, 0x36, 0x00, 0x13, 0x00, 0x36, 0x00, 0x04, + 0x00, 0x36, 0x00, 0x14, 0x00, 0x36, 0x00, 0x05, 0x00, 0x36, + 0x00, 0x15, 0x00, 0x36, 0x00, 0x06, 0x00, 0x36, 0x00, 0x16, + 0x00, 0x36, 0x00, 0x07, 0x00, 0x36, 0x00, 0x17, 0x00, 0x36, + 0x00, 0x08, 0x00, 0x36, 0x00, 0x18, 0x00, 0x36, 0x00, 0x09, + 0x00, 0x36, 0x00, 0x19, 0x00, 0x36, 0x00, 0x0a, 0x00, 0x36, + 0x00, 0x1a, 0x00, 0x36, 0x00, 0x0b, 0x00, 0x36, 0x00, 0x1b, + 0x00, 0x36, 0x00, 0x0c, 0x00, 0x36, 0x00, 0x1c, 0x00, 0x36, + 0x00, 0x0d, 0x00, 0x36, 0x00, 0x1d, 0x00, 0x36, 0x00, 0x0e, + 0x00, 0x36, 0x00, 0x1e, 0x00, 0x36, 0x00, 0x0f, 0x00, 0x36, + 0x00, 0x1f, 0x00, 0x36, 0x00, 0x10, 0x00, 0x36, 0x00, 0x20, + 0x00, 0x36, 0x00, 0x11, 0x00, 0x36, 0x00, 0x21, 0x00, 0x36, + 0x00, 0x12, 0x00, 0x36, 0x00, 0x22, 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE11[] = { + 0x03, 0xff, 0xff, 0xff, 0xff, 0x3d, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x55, 0x45, 0x00, 0x01, 0x00, + 0xff, 0x45, 0x00, 0x02, 0x00, 0x45, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE12[] = { + 0x03, 0xff, 0xff, 0xff, 0xff, 0x3e, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x40, 0x00, 0x01, 0x00, + 0xff, 0x40, 0x00, 0x02, 0x00, 0x40, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE13[] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x46, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x56, 0x46, 0x00, 0x01, 0x00, + 0xff, 0x46, 0x00, 0x03, 0x00, 0x46, 0x00, 0x00, 0x00, 0x46, + 0x00, 0x04, 0x00, 0x46, 0x00, 0x0d, 0x00, 0x46, 0x00, 0x05, + 0x00, 0x46, 0x00, 0x0e, 0x00, 0x46, 0x00, 0x06, 0x00, 0x46, + 0x00, 0x0f, 0x00, 0x46, 0x00, 0x07, 0x00, 0x46, 0x00, 0x10, + 0x00, 0x46, 0x00, 0x08, 0x00, 0x46, 0x00, 0x11, 0x00, 0x46, + 0x00, 0x09, 0x00, 0x46, 0x00, 0x12, 0x00, 0x46, 0x00, 0x0a, + 0x00, 0x46, 0x00, 0x13, 0x00, 0x46, 0x00, 0x0b, 0x00, 0x46, + 0x00, 0x14, 0x00, 0x46, 0x00, 0x0c, 0x00, 0x46, 0x00, 0x15, + 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE15[] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0x41, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x57, 0x47, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x47, + 0x00, 0x02, 0x00, 0x47, 0x00, 0x05, 0x00, 0x47, 0x00, 0x03, + 0x00, 0x47, 0x00, 0x06, 0x00, 0x47, 0x00, 0x04, 0x00, 0x47, + 0x00, 0x07, 0x00, 0xff, 0xff, +}; +const byte CHAR_TABLE16[] = { + 0x03, 0xff, 0xff, 0xff, 0xff, 0x42, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x54, 0x41, 0x00, 0x01, 0x00, + 0xff, 0x41, 0x00, 0x02, 0x00, 0x41, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE18[] = { + 0x02, 0x31, 0x00, 0x07, 0x00, 0x44, 0x00, 0x3c, 0x00, 0x03, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x50, 0x3c, 0x00, 0x01, 0x00, + 0xff, 0x3c, 0x00, 0x02, 0x00, 0x3c, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE19[] = { + 0x02, 0x31, 0x00, 0x07, 0x00, 0x45, 0x00, 0x3d, 0x00, 0x03, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x51, 0x3d, 0x00, 0x01, 0x00, + 0xff, 0x3d, 0x00, 0x02, 0x00, 0x3d, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE20[] = { + 0x02, 0x31, 0x00, 0x02, 0x00, 0x46, 0x00, 0x48, 0x00, 0x02, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x58, 0x48, 0x00, 0x01, 0x00, + 0xff, 0x48, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE21[] = { + 0x02, 0x31, 0x00, 0x07, 0x00, 0x47, 0x00, 0x3e, 0x00, 0x03, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x52, 0x3e, 0x00, 0x01, 0x00, + 0xff, 0x3e, 0x00, 0x02, 0x00, 0x3e, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE23[] = { + 0x02, 0x31, 0x00, 0x08, 0x00, 0x49, 0x00, 0x3f, 0x00, 0x03, + 0x00, 0x80, 0x00, 0xf7, 0x00, 0x53, 0x3f, 0x00, 0x01, 0x00, + 0xff, 0x3f, 0x00, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0xff, + 0xff, +}; +const byte CHAR_TABLE24[] = { + 0x02, 0x32, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x47, 0x32, 0x00, 0x02, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x32, 0x00, 0x01, 0x00, 0x32, + 0x00, 0x03, 0x00, 0x32, 0x00, 0x0a, 0x00, 0x32, 0x00, 0x04, + 0x00, 0x32, 0x00, 0x0b, 0x00, 0x32, 0x00, 0x05, 0x00, 0x32, + 0x00, 0x0c, 0x00, 0x32, 0x00, 0x06, 0x00, 0x32, 0x00, 0x0d, + 0x00, 0x32, 0x00, 0x07, 0x00, 0x32, 0x00, 0x0e, 0x00, 0x32, + 0x00, 0x08, 0x00, 0x32, 0x00, 0x0f, 0x00, 0x32, 0x00, 0x09, + 0x00, 0x32, 0x00, 0x10, 0x00, 0xff, 0xff +}; +const byte CHAR_TABLE25[] = { + 0x02, 0x39, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x39, 0x00, 0x00, 0x00, 0x39, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0xFF +}; +const byte CHAR_TABLE26[] = { + 0x01, 0x3a, 0x00, 0x01, 0x00, 0x0a, 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x3a, 0x00, 0x02, 0x00, + 0xff, 0x3a, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x42, + 0x00, 0x00, 0x00, 0x3a, 0x00, 0x04, 0x00, 0x42, 0x00, 0x01, + 0x00, 0x3a, 0x00, 0x05, 0x00, 0x42, 0x00, 0x02, 0x00, 0x3a, + 0x00, 0x06, 0x00, 0x42, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x07, + 0x00, 0x42, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x08, 0x00, 0x42, + 0x00, 0x05, 0x00, 0x3a, 0x00, 0x09, 0x00, 0x42, 0x00, 0x06, + 0x00, 0x3a, 0x00, 0x0a, 0x00, 0x42, 0x00, 0x07, 0x00, 0x3a, + 0x00, 0x0b, 0x00, 0x42, 0x00, 0x08, 0x00, 0x3a, 0x00, 0x0c, + 0x00, 0x42, 0x00, 0x09, 0x00, 0x3a, 0x00, 0x0d, 0x00, 0x42, + 0x00, 0x0a, 0x00, 0x3a, 0x00, 0x0e, 0x00, 0x42, 0x00, 0x0b, + 0x00, 0x3a, 0x00, 0x0f, 0x00, 0x42, 0x00, 0x0c, 0x00, 0x3a, + 0x00, 0x10, 0x00, 0x42, 0x00, 0x0d, 0x00, 0x3a, 0x00, 0x11, + 0x00, 0x42, 0x00, 0x0e, 0x00, 0x3a, 0x00, 0x12, 0x00, 0x42, + 0x00, 0x0f, 0x00, 0x3a, 0x00, 0x13, 0x00, 0x42, 0x00, 0x10, + 0x00, 0x3a, 0x00, 0x14, 0x00, 0x42, 0x00, 0x11, 0x00, 0x3a, + 0x00, 0x15, 0x00, 0xff, 0xff +}; +const byte CHAR_TABLE27[] = { + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x58, 0x49, 0x00, 0x01, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x49, 0x00, 0x00, 0x00, 0x49, + 0x00, 0x02, 0x00, 0x49, 0x00, 0x0a, 0x00, 0x49, 0x00, 0x03, + 0x00, 0x49, 0x00, 0x0b, 0x00, 0x49, 0x00, 0x04, 0x00, 0x49, + 0x00, 0x0c, 0x00, 0x49, 0x00, 0x05, 0x00, 0x49, 0x00, 0x0d, + 0x00, 0x49, 0x00, 0x06, 0x00, 0x49, 0x00, 0x0e, 0x00, 0x49, + 0x00, 0x07, 0x00, 0x49, 0x00, 0x0f, 0x00, 0x49, 0x00, 0x08, + 0x00, 0x49, 0x00, 0x10, 0x00, 0x49, 0x00, 0x09, 0x00, 0x49, + 0x00, 0x11, 0x00, 0xff, 0xff, +}; +const byte *CHAR_TABLE[] = { + CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5, + CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10, + CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, + CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20, + CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25, + CHAR_TABLE26, CHAR_TABLE27 +}; + +} // End of namespace Martian + +} // End of namespace Access diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h new file mode 100644 index 0000000000..a6ababeec3 --- /dev/null +++ b/engines/access/martian/martian_resources.h @@ -0,0 +1,48 @@ +/* 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 ACCESS_MARTIAN_RESOURCES_H +#define ACCESS_MARTIAN_RESOURCES_H + +#include "common/scummsys.h" + +namespace Access { + +namespace Martian { + +extern const char *const FILENAMES[]; + +extern const byte *CURSORS[4]; + +extern const int TRAVEL_POS[][2]; + +extern const char *const INVENTORY_NAMES[]; + +extern const byte *ROOM_TABLE[]; + +extern const byte *CHAR_TABLE[]; + +} // End of namespace Martian + +} // End of namespace Access + +#endif /* ACCESS_MARTIAN_RESOURCES_H */ diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp new file mode 100644 index 0000000000..80eaf59fec --- /dev/null +++ b/engines/access/martian/martian_room.cpp @@ -0,0 +1,139 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/resources.h" +#include "access/martian/martian_game.h" +#include "access/martian/martian_resources.h" +#include "access/martian/martian_room.h" + +namespace Access { + +namespace Martian { + +MartianRoom::MartianRoom(AccessEngine *vm): Room(vm) { + _game = (MartianEngine *)vm; +} + +MartianRoom::~MartianRoom() { +} + +void MartianRoom::loadRoom(int roomNumber) { + loadRoomData(ROOM_TABLE[roomNumber]); +} + +void MartianRoom::reloadRoom() { + loadRoom(_vm->_player->_roomNumber); + + if (_roomFlag != 1) { + _vm->_currentMan = _roomFlag; + _vm->_currentManOld = _roomFlag; + _vm->_manScaleOff = 0; + + switch (_vm->_currentMan) { + case 0: + _vm->_player->loadSprites("MAN.LZ"); + break; + + case 2: + _vm->_player->loadSprites("JMAN.LZ"); + break; + + case 3: + _vm->_player->loadSprites("OVERHEAD.LZ"); + _vm->_manScaleOff = 1; + break; + + default: + break; + } + } + + reloadRoom1(); +} + +void MartianRoom::reloadRoom1() { + if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 + || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { + _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + _vm->_currentCharFlag = false; + } + + _selectCommand = -1; + _vm->_normalMouse = 1; + _vm->_mouseMode = 0; + _vm->_boxSelect = true; + _vm->_player->_playerOff = false; + + _vm->_screen->fadeOut(); + _vm->_screen->clearScreen(); + roomSet(); + + // TODO: Refactor + + _vm->_screen->setBufferScan(); + setupRoom(); + setWallCodes(); + buildScreen(); + + if (!_vm->_screen->_vesaMode) { + _vm->copyBF2Vid(); + } else if (_vm->_player->_roomNumber != 20 && _vm->_player->_roomNumber != 24 + && _vm->_player->_roomNumber != 33) { + _vm->_screen->setPalette(); + _vm->copyBF2Vid(); + } + + _vm->_player->_frame = 0; + _vm->_oldRects.clear(); + _vm->_newRects.clear(); +} + +void MartianRoom::roomSet() { + _vm->_numAnimTimers = 0; + _vm->_scripts->_sequence = 1000; + _vm->_scripts->searchForSequence(); + _vm->_scripts->executeScript(); +} + +void MartianRoom::roomMenu() { + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); + delete[] iconData; + + _vm->_screen->saveScreen(); + _vm->_screen->setDisplayScan(); + _vm->_destIn = _vm->_screen; // TODO: Redundant + _vm->_screen->plotImage(spr, 0, Common::Point(0, 177)); + _vm->_screen->plotImage(spr, 1, Common::Point(143, 177)); + + _vm->_screen->restoreScreen(); + delete spr; +} + +void MartianRoom::mainAreaClick() { +} + +} // End of namespace Martian + +} // End of namespace Access diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h new file mode 100644 index 0000000000..526de56240 --- /dev/null +++ b/engines/access/martian/martian_room.h @@ -0,0 +1,62 @@ +/* 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 ACCESS_MARTIAN_ROOM_H +#define ACCESS_MARTIAN_ROOM_H + +#include "common/scummsys.h" +#include "access/room.h" + +namespace Access { + +class AccessEngine; + +namespace Martian { + +class MartianEngine; + +class MartianRoom : public Room { +private: + MartianEngine *_game; + + void roomSet(); +protected: + virtual void loadRoom(int roomNumber); + + virtual void reloadRoom(); + + virtual void reloadRoom1(); + + virtual void roomMenu(); + + virtual void mainAreaClick(); +public: + MartianRoom(AccessEngine *vm); + + virtual ~MartianRoom(); +}; + +} // End of namespace Martian + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_ROOM_H */ diff --git a/engines/access/martian/martian_scripts.cpp b/engines/access/martian/martian_scripts.cpp new file mode 100644 index 0000000000..0578872092 --- /dev/null +++ b/engines/access/martian/martian_scripts.cpp @@ -0,0 +1,48 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/martian/martian_game.h" +#include "access/martian/martian_resources.h" +#include "access/martian/martian_scripts.h" + +namespace Access { + +namespace Martian { + +MartianScripts::MartianScripts(AccessEngine *vm) : Scripts(vm) { + _game = (MartianEngine *)_vm; +} + +void MartianScripts::executeSpecial(int commandIndex, int param1, int param2) { +} + +typedef void(MartianScripts::*MartianScriptMethodPtr)(); + +void MartianScripts::executeCommand(int commandIndex) { + Scripts::executeCommand(commandIndex); +} + +} // End of namespace Martian + +} // End of namespace Access diff --git a/engines/access/martian/martian_scripts.h b/engines/access/martian/martian_scripts.h new file mode 100644 index 0000000000..9f90643e22 --- /dev/null +++ b/engines/access/martian/martian_scripts.h @@ -0,0 +1,49 @@ +/* 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 ACCESS_MARTIAN_SCRIPTS_H +#define ACCESS_MARTIAN_SCRIPTS_H + +#include "common/scummsys.h" +#include "access/scripts.h" + +namespace Access { + +namespace Martian { + +class MartianEngine; + +class MartianScripts: public Scripts { +private: + MartianEngine *_game; +protected: + virtual void executeSpecial(int commandIndex, int param1, int param2); + virtual void executeCommand(int commandIndex); +public: + MartianScripts(AccessEngine *vm); +}; + +} // End of namespace Martian + +} // End of namespace Access + +#endif /* ACCESS_MARTIAN_SCRIPTS_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index d74892c241..46f96693fa 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -21,7 +21,11 @@ MODULE_OBJS := \ amazon/amazon_game.o \ amazon/amazon_resources.o \ amazon/amazon_room.o \ - amazon/amazon_scripts.o + amazon/amazon_scripts.o \ + martian/martian_game.o \ + martian/martian_resources.o \ + martian/martian_room.o \ + martian/martian_scripts.o # This module can be built as a plugin ifeq ($(ENABLE_ACCESS), DYNAMIC_PLUGIN) -- cgit v1.2.3 From 966515a7d0f0e9bccc8ad2a761020372d4bae19f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Aug 2014 07:44:41 -0400 Subject: ACCESS: Fix room data loading for MM --- engines/access/martian/martian_resources.cpp | 12 ++++++------ engines/access/room.cpp | 14 +++++++++----- engines/access/room.h | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp index 6e881f3b36..b596797ab5 100644 --- a/engines/access/martian/martian_resources.cpp +++ b/engines/access/martian/martian_resources.cpp @@ -32,12 +32,12 @@ const char *const FILENAMES[] = { "R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP", "R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP", "R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP", - "R32.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", "R40.AP", - "TITLE.AP","R42.AP","S01.AP", "R45.AP","SOUND.AP","MUSIC.AP","DEAD.AP","EST.AP", - "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", "C07.AP", "LOVE.AP", - "CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", "C12.AP", "C16.AP", - "CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", "C16A.AP","C09.AP", - "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP" + "R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", + "R40.AP","TITLE.AP","R42.AP","S01.AP", "R44.AP", "R45.AP","SOUND.AP","MUSIC.AP", + "DEAD.AP","EST.AP", "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", + "C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", + "C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", + "C16A.AP","C09.AP", "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP" }; const byte MOUSE0[] = { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f45ffe7afb..0e6cba052d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -159,7 +159,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData); + RoomInfo roomInfo(roomData, _vm->getGameID()); _roomFlag = roomInfo._roomFlag; @@ -716,11 +716,16 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data) { +RoomInfo::RoomInfo(const byte *data, int gameType) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); - _estIndex = (int16)stream.readUint16LE(); + + if (gameType != GType_MartianMemorandum) + _estIndex = (int16)stream.readUint16LE(); + else + _estIndex = -1; + _musicFile._fileNum = (int16)stream.readUint16LE(); _musicFile._subfile = stream.readUint16LE(); _scaleH1 = stream.readByte(); @@ -748,8 +753,7 @@ RoomInfo::RoomInfo(const byte *data) { _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; - } - else { + } else { _startColor = stream.readUint16LE(); _numColors = stream.readUint16LE(); } diff --git a/engines/access/room.h b/engines/access/room.h index 9b3f922528..e1a26a4e4e 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -187,7 +187,7 @@ public: Common::Array _vidTable; Common::Array _sounds; public: - RoomInfo(const byte *data); + RoomInfo(const byte *data, int gameType); }; } // End of namespace Access -- cgit v1.2.3 From 8d1d1f6739b3b9f456d618a8740d754ddac2eb41 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Aug 2014 21:03:44 -0400 Subject: ACCESS: Fix displaying background in scrolling rooms --- engines/access/room.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0e6cba052d..83fcce1a15 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -256,15 +256,13 @@ void Room::setupRoom() { _vm->_screen->_scrollX = 0; _vm->_screen->_scrollCol = 0; } else { - _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x - - (_vm->_player->_rawPlayer.x >> 4); - int xp = MAX((_vm->_player->_rawPlayer.x >> 4) - - (_vm->_screen->_vWindowWidth / 2), 0); - _vm->_screen->_scrollCol = xp; - - xp = xp + _vm->_screen->_vWindowWidth - _playFieldWidth; - if (xp >= 0) { - _vm->_screen->_scrollCol = xp + 1; + int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; + _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + _vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0); + + int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth; + if (sx >= 0) { + _vm->_screen->_scrollCol -= sx + 1; } } -- cgit v1.2.3 From 41df7734db18cf1cb7a2fe4004e3adef98a8cb41 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 21 Aug 2014 22:15:00 -0400 Subject: ACCESS: Standardise plotting methods and added comments --- engines/access/access.cpp | 2 +- engines/access/asurface.cpp | 63 ++++++++++++--------------------------------- engines/access/asurface.h | 14 +++++++--- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 32835a01c8..ae03dfc7fa 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -318,7 +318,7 @@ void AccessEngine::plotList1() { if (ie._flags & 2) { _buffer2.plotB(frame, Common::Point(bounds.left, bounds.top)); } else { - _buffer2.plotFrame(frame, Common::Point(bounds.left, bounds.top)); + _buffer2.plotF(frame, Common::Point(bounds.left, bounds.top)); } } } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 44686ab8f4..d3503ef645 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -203,50 +203,10 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi _lastBoundsW = r.width(); _lastBoundsH = r.height(); - plotFrame(frame, pt); + plotF(frame, pt); } } -void ASurface::plotFrame(SpriteFrame *frame, const Common::Point &pt) { - frame->copyTo(this, pt); -// g_system->copyRectToScreen((byte *)getPixels(), 320, 0, 0, 320, 200); -// g_system->updateScreen(); - - -/* - byte *destP = (byte *)getBasePtr(pt.x, _scrollY + pt.y); - byte *srcP = frame->_data; - - int8 leftVal1 = 18; - int8 leftVal2 = -8; - if (_leftSkip) { - ++leftVal2; - leftVal1 = -12; - } - int8 rightVal = (_rightSkip) ? -7 : -8; - - // Skip over any lines of the frame - for (int yp = 0; yp < _topSkip; ++yp) { - srcP += *(srcP + 1) + 2; - } - - byte *srcLineP = srcP; - byte *destLineP = destP; - for (int yp = 0; yp < frame->h; ++yp, srcP = srcLineP, destP = destLineP) { - // Get length of line - int v = *srcP++; - int len = *srcP++; - srcLineP = srcP + len; - destLineP = destP + this->pitch; - - // Draw the line of the frame - if (v != 0 || len != 0) { - warning("TODO: Line draw"); - } - } - */ -} - void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { for (int yp = 0; yp < h; ++yp) { byte *srcP = (byte *)getBasePtr(0, yp); @@ -305,22 +265,33 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { } } -void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { + +void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { + frame->copyTo(this, pt); +} + +void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - flippedFrame.copyTo(this, bounds); + flippedFrame.copyTo(this, pt); } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { frame->copyTo(this, bounds); } -void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { - frame->copyTo(this, pt); +void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { + ASurface flippedFrame; + frame->flipHorizontal(flippedFrame); + flippedFrame.copyTo(this, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { - copyRectToSurface(*src, bounds.left, bounds.top, bounds); + Common::Rect r = bounds; + r.clip(Common::Rect(0, 0, this->w, this->h)); + + if (r.isValidRect()) + copyRectToSurface(*src, r.left, r.top, r); } void ASurface::saveBlock(const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 88e156100b..be3597d217 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -53,8 +53,6 @@ public: static int _lColor; static void init(); -public: - virtual void plotFrame(SpriteFrame *frame, const Common::Point &pt); public: virtual ~ASurface(); @@ -69,15 +67,23 @@ public: void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); /** - * Scaled draw frame + * Scaled draw frame in forward orientation */ void sPlotF(SpriteFrame *frame, const Common::Rect &bounds); /** - * Scaled flipped horizontal draw frame + * Scaled draw frame in backwards orientation */ void sPlotB(SpriteFrame *frame, const Common::Rect &bounds); + /** + * Draw an image full-size in forward orientation + */ + void plotF(SpriteFrame *frame, const Common::Point &pt); + + /** + * Draw an image full-size in backwards orientation + */ void plotB(SpriteFrame *frame, const Common::Point &pt); void copyBlock(ASurface *src, const Common::Rect &bounds); -- cgit v1.2.3 From e5130bcc6c2c813fa2ab9238fce277f51a999990 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Aug 2014 22:15:53 -0400 Subject: ACCESS: Remapping of plotting methods --- engines/access/asurface.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index d3503ef645..f023f9342d 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -267,13 +267,11 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { - frame->copyTo(this, pt); + sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h)); } void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { - ASurface flippedFrame; - frame->flipHorizontal(flippedFrame); - flippedFrame.copyTo(this, pt); + sPlotB(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h)); } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { @@ -287,11 +285,10 @@ void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { - Common::Rect r = bounds; - r.clip(Common::Rect(0, 0, this->w, this->h)); + Common::Rect destBounds = bounds; + //destBounds.translate(src->_scrollX, src->_scrollY); - if (r.isValidRect()) - copyRectToSurface(*src, r.left, r.top, r); + copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); } void ASurface::saveBlock(const Common::Rect &bounds) { -- cgit v1.2.3 From b4d2484633e80ac2a1caccfedb51980cd7926c11 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Aug 2014 22:55:17 -0400 Subject: ACCESS: Fixes for drawing scrolling scenes --- engines/access/asurface.cpp | 9 +++------ engines/access/asurface.h | 2 +- engines/access/room.cpp | 4 ++++ engines/access/screen.cpp | 7 +++++++ engines/access/screen.h | 2 ++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index f023f9342d..e88bd27c91 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -152,7 +152,7 @@ bool ASurface::clip(Common::Rect &r) { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; - if (r.left > _clipWidth) { + if (r.left > _clipWidth || r.left < 0) { if (r.left >= 0) return true; @@ -171,7 +171,7 @@ bool ASurface::clip(Common::Rect &r) { _rightSkip = skip; } - if (r.top > _clipHeight) { + if (r.top > _clipHeight || r.top < 0) { if (r.top >= 0) return true; @@ -285,10 +285,7 @@ void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { - Common::Rect destBounds = bounds; - //destBounds.translate(src->_scrollX, src->_scrollY); - - copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); + copyRectToSurface(*src, bounds.left, bounds.top, bounds); } void ASurface::saveBlock(const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index be3597d217..84fe90dbbd 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -86,7 +86,7 @@ public: */ void plotB(SpriteFrame *frame, const Common::Point &pt); - void copyBlock(ASurface *src, const Common::Rect &bounds); + virtual void copyBlock(ASurface *src, const Common::Rect &bounds); void copyTo(ASurface *dest, const Common::Point &destPos); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 83fcce1a15..225cd80548 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -296,6 +296,10 @@ void Room::buildScreen() { int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; + // Clear current background buffer + _vm->_buffer1.clearBuffer(); + + // Loop through drawing each column of tiles forming the background for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3092d7e152..af97e2e236 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -236,4 +236,11 @@ void Screen::moveBufferUp() { error("TODO: UP"); } +void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { + Common::Rect destBounds = bounds; + destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff); + + copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 98e77b4cf4..e66a7a3759 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -79,6 +79,8 @@ public: int _bufferBytesWide; int _vWindowLinesTall; bool _screenChangeFlag; +public: + virtual void copyBlock(ASurface *src, const Common::Rect &bounds); public: Screen(AccessEngine *vm); -- cgit v1.2.3 From 44436def8328accecf756d34103f5322d0fe0f6f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 22 Aug 2014 22:58:44 -0400 Subject: ACCESS: Stop player moving when scene changes --- engines/access/amazon/amazon_room.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 79c70c0b33..bc0f605d8e 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -114,7 +114,11 @@ void AmazonRoom::reloadRoom1() { _vm->copyBF2Vid(); } + // Stop player moving + _vm->_player->_playerMove = false; _vm->_player->_frame = 0; + + // Clear any dirty rects from the old scene _vm->_oldRects.clear(); _vm->_newRects.clear(); } -- cgit v1.2.3 From 6343ff72c462219afb2f11fea69539725794efd6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 10:21:50 -0400 Subject: ACCESS: Fix cursor positioning in scrolled screens, and background restores --- engines/access/amazon/amazon_room.cpp | 17 ++++++++++------- engines/access/bubble_box.cpp | 3 ++- engines/access/events.cpp | 12 ++++++++++++ engines/access/events.h | 4 ++++ engines/access/room.cpp | 4 +++- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index bc0f605d8e..c0076fd78a 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -146,10 +146,13 @@ void AmazonRoom::roomMenu() { } void AmazonRoom::mainAreaClick() { + Common::Point &mousePos = _vm->_events->_mousePos; + Common::Point pt = _vm->_events->calcRawMouse(); + if (_selectCommand == -1) { if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) { - switch (checkBoxes1(_vm->_events->_mousePos)) { + switch (checkBoxes1(pt)) { case 0: _game->_jasMayaFlag = 0; return; @@ -161,13 +164,13 @@ void AmazonRoom::mainAreaClick() { } } - _vm->_player->_moveTo = _vm->_events->_mousePos; + _vm->_player->_moveTo = pt; _vm->_player->_playerMove = true; - } else if (_vm->_events->_mousePos.x >= _vm->_screen->_windowXAdd && - _vm->_events->_mousePos.x <= _vm->_screen->_vWindowBytesWide && - _vm->_events->_mousePos.y >= _vm->_screen->_windowYAdd && - _vm->_events->_mousePos.y <= _vm->_screen->_vWindowLinesTall) { - if (checkBoxes1(_vm->_events->_mousePos) >= 0) { + } else if (mousePos.x >= _vm->_screen->_windowXAdd && + mousePos.x <= _vm->_screen->_vWindowBytesWide && + mousePos.y >= _vm->_screen->_windowYAdd && + mousePos.y <= _vm->_screen->_vWindowLinesTall) { + if (checkBoxes1(pt) >= 0) { checkBoxes3(); } } diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 21e104028c..a709fbd92d 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -236,7 +236,7 @@ void BubbleBox::doBox(int item, int box) { screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp)); if (_type == TYPE_4) { - // Further stuff + // Further stuff for filename dialog error("TODO: Box type 4"); } @@ -264,6 +264,7 @@ void BubbleBox::doBox(int item, int box) { fonts._printStart = printStart; _charCol = charCol; _rowOff = rowOff; + _vm->_screen->restoreScreen(); // Free icons data delete icons; diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 1afc5515b0..78bbdbf1ea 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -217,4 +217,16 @@ void EventsManager::waitKeyMouse() { debounceLeft(); } +Common::Point EventsManager::calcRawMouse() { + Screen &screen = *_vm->_screen; + Common::Point pt; + pt.x = _mousePos.x - screen._windowXAdd + + (screen._scrollCol * TILE_WIDTH) + screen._scrollX; + pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd + + (screen._scrollRow * TILE_HEIGHT) + screen._scrollY; + + return pt; +} + + } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index f7a5e9ce53..2ced71f50e 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -105,6 +105,10 @@ public: void debounceLeft(); void waitKeyMouse(); + + Common::Point &getMousePos() { return _mousePos; } + + Common::Point calcRawMouse(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 225cd80548..b5f8554612 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -556,8 +556,10 @@ int Room::checkBoxes2(const Common::Point &pt, int start, int count) { } void Room::checkBoxes3() { + Common::Point pt = _vm->_events->calcRawMouse(); + for (uint start = 0; start < _plotter._blocks.size(); ++start) { - if (_plotter._blocks[start].contains(_vm->_events->_mousePos)) { + if (_plotter._blocks[start].contains(pt)) { _plotter._blockIn = start; if (!(validateBox(start) & 0x80)) { _vm->_events->debounceLeft(); -- cgit v1.2.3 From 7aa2c7fe5cca8eaa9c68c471cef4595b99021206 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 12:09:27 -0400 Subject: ACCESS: Beginnings of character/converse manager --- engines/access/access.cpp | 9 ++++- engines/access/access.h | 7 +++- engines/access/char.cpp | 89 ++++++++++++++++++++++++++++++++++++++++++++++ engines/access/char.h | 58 ++++++++++++++++++++++++++++++ engines/access/data.h | 14 ++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 38 ++++++++++---------- engines/access/room.h | 11 +----- engines/access/scripts.cpp | 19 ++++++++-- engines/access/scripts.h | 2 +- 10 files changed, 213 insertions(+), 35 deletions(-) create mode 100644 engines/access/char.cpp create mode 100644 engines/access/char.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index ae03dfc7fa..c84ac8b28d 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -34,6 +34,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; _bubbleBox = nullptr; + _char = nullptr; _debugger = nullptr; _events = nullptr; _files = nullptr; @@ -106,6 +107,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) AccessEngine::~AccessEngine() { delete _animation; delete _bubbleBox; + delete _char; delete _debugger; delete _events; delete _files; @@ -147,6 +149,7 @@ void AccessEngine::initialize() { ASurface::init(); _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); + _char = new CharManager(this); _debugger = new Debugger(this); _events = new EventsManager(this); _files = new FileManager(this); @@ -197,7 +200,7 @@ int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } -void AccessEngine::loadCells(Common::Array &cells) { +void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile); _objectsTable[cells[i]._cell] = new SpriteResource(this, @@ -371,4 +374,8 @@ void AccessEngine::freeChar() { _animation->freeAnimationData(); } +void AccessEngine::loadChar(int charId) { + +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 2185916c5a..974277280c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -32,6 +32,7 @@ #include "graphics/surface.h" #include "access/animation.h" #include "access/bubble_box.h" +#include "access/char.h" #include "access/data.h" #include "access/debugger.h" #include "access/events.h" @@ -108,6 +109,7 @@ protected: public: AnimationManager *_animation; BubbleBox *_bubbleBox; + CharManager *_char; Debugger *_debugger; EventsManager *_events; FileManager *_files; @@ -122,6 +124,7 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; + Common::Array _charTable; SpriteResource *_objectsTable[100]; int _establishTable[100]; bool _establishFlag; @@ -204,7 +207,7 @@ public: int getRandomNumber(int maxNumber); - void loadCells(Common::Array &cells); + void loadCells(Common::Array &cells); /** * Free the sprites list @@ -236,6 +239,8 @@ public: void doLoadSave(); void freeChar(); + + void loadChar(int charId); }; } // End of namespace Access diff --git a/engines/access/char.cpp b/engines/access/char.cpp new file mode 100644 index 0000000000..a01643b651 --- /dev/null +++ b/engines/access/char.cpp @@ -0,0 +1,89 @@ +/* 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 "common/memstream.h" +#include "access/access.h" +#include "access/char.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +CharEntry::CharEntry(const byte *data) { + Common::MemoryReadStream s(data, 999); + + _charFlag = s.readByte(); + _estabFlag = s.readSint16LE(); + _screenFile._fileNum = s.readSint16LE(); + _screenFile._subfile = s.readSint16LE(); + + _paletteFile._fileNum = s.readSint16LE(); + _paletteFile._subfile = s.readUint16LE(); + _startColor = s.readUint16LE(); + _numColors = s.readUint16LE(); + + // Load cells + for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) { + CellIdent ci; + ci._cell = cell; + ci._fileNum = s.readSint16LE(); + ci._subfile = s.readUint16LE(); + + _cells.push_back(ci); + } + + _animFile._fileNum = s.readSint16LE(); + _animFile._subfile = s.readUint16LE(); + _scriptFile._fileNum = s.readSint16LE(); + _scriptFile._subfile = s.readUint16LE(); + + for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) { + ExtraCell ec; + ec._vidTable = v; + ec._vidTable1 = s.readSint16LE(); + ec._vidSTable = s.readSint16LE(); + ec._vidSTable1 = s.readSint16LE(); + + _extraCells.push_back(ec); + } +} + +CharEntry::CharEntry() { + _charFlag = 0; + _estabFlag = 0; + _startColor = _numColors = 0; +} + +/*------------------------------------------------------------------------*/ + +CharManager::CharManager(AccessEngine *vm) : Manager(vm) { + switch (vm->getGameID()) { + case GType_Amazon: + // Setup character list + for (int i = 0; i < 37; ++i) + _charTable.push_back(CharEntry(Amazon::CHARTBL[i])); + break; + default: + error("Unknown game"); + } +} + +} // End of namespace Access diff --git a/engines/access/char.h b/engines/access/char.h new file mode 100644 index 0000000000..8d6c49d47a --- /dev/null +++ b/engines/access/char.h @@ -0,0 +1,58 @@ +/* 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 ACCESS_CHAR_H +#define ACCESS_CHAR_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "access/data.h" + +namespace Access { + +class CharEntry { +public: + int _charFlag; + int _estabFlag; + FileIdent _screenFile; + FileIdent _paletteFile; + int _startColor, _numColors; + Common::Array _cells; + FileIdent _animFile; + FileIdent _scriptFile; + Common::Array _extraCells; +public: + CharEntry(const byte *data); + + CharEntry(); +}; + +class CharManager: public Manager { +public: + Common::Array _charTable; +public: + CharManager(AccessEngine *vm); +}; + +} // End of namespace Access + +#endif /* ACCESS_CHAR_H */ diff --git a/engines/access/data.h b/engines/access/data.h index 1601c689bf..c10b2b7f17 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -40,6 +40,20 @@ public: Manager(AccessEngine *vm) : _vm(vm) {} }; +struct FileIdent { + int _fileNum; + int _subfile; + + FileIdent() { + _fileNum = -1; + _subfile = 0; + } +}; + +struct CellIdent : FileIdent { + byte _cell; +}; + struct TimerEntry { int _initTm; int _timer; diff --git a/engines/access/module.mk b/engines/access/module.mk index 46f96693fa..31f0760491 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ asurface.o \ access.o \ bubble_box.o \ + char.o \ data.o \ debugger.o \ decompress.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b5f8554612..d703114090 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -227,13 +227,8 @@ void Room::loadRoomData(const byte *roomData) { // Load extra cells _vm->_extraCells.clear(); - for (uint i = 0; i < roomInfo._vidTable.size(); ++i) { - ExtraCell ec; - ec._vidTable = roomInfo._vidTable[i] & 0xffff; - ec._vidTable1 = roomInfo._vidTable[i] >> 16; - - _vm->_extraCells.push_back(ec); - } + for (uint i = 0; i < roomInfo._extraCells.size(); ++i) + _vm->_extraCells.push_back(roomInfo._extraCells[i]); // Load sounds for the scene _vm->_sound->loadSounds(roomInfo._sounds); @@ -726,34 +721,34 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _roomFlag = stream.readByte(); if (gameType != GType_MartianMemorandum) - _estIndex = (int16)stream.readUint16LE(); + _estIndex = stream.readSint16LE(); else _estIndex = -1; - _musicFile._fileNum = (int16)stream.readUint16LE(); + _musicFile._fileNum = stream.readSint16LE(); _musicFile._subfile = stream.readUint16LE(); _scaleH1 = stream.readByte(); _scaleH2 = stream.readByte(); _scaleN1 = stream.readByte(); - _playFieldFile._fileNum = (int16)stream.readUint16LE(); + _playFieldFile._fileNum = stream.readSint16LE(); _playFieldFile._subfile = stream.readUint16LE(); for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) { CellIdent ci; ci._cell = cell; - ci._fileNum = (int16)stream.readUint16LE(); + ci._fileNum = stream.readSint16LE(); ci._subfile = stream.readUint16LE(); _cells.push_back(ci); } - _scriptFile._fileNum = (int16)stream.readUint16LE(); + _scriptFile._fileNum = stream.readSint16LE(); _scriptFile._subfile = stream.readUint16LE(); - _animFile._fileNum = (int16)stream.readUint16LE(); + _animFile._fileNum = stream.readSint16LE(); _animFile._subfile = stream.readUint16LE(); _scaleI = stream.readByte(); _scrollThreshold = stream.readByte(); - _paletteFile._fileNum = (int16)stream.readUint16LE(); + _paletteFile._fileNum = stream.readSint16LE(); _paletteFile._subfile = stream.readUint16LE(); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; @@ -762,15 +757,18 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _numColors = stream.readUint16LE(); } - for (int16 v = (int16)stream.readUint16LE(); v != -1; - v = (int16)stream.readUint16LE()) { - uint16 v2 = stream.readUint16LE(); + for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) { + ExtraCell ec; + ec._vidTable = v; + ec._vidTable1 = stream.readSint16LE(); + ec._vidSTable = stream.readSint16LE(); + ec._vidSTable1 = stream.readSint16LE(); - _vidTable.push_back(v | ((uint32)v2 << 16)); + _extraCells.push_back(ec); } - for (int16 fileNum = (int16)stream.readUint16LE(); fileNum != -1; - fileNum = (int16)stream.readUint16LE()) { + for (int16 fileNum = stream.readSint16LE(); fileNum != -1; + fileNum = stream.readSint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); diff --git a/engines/access/room.h b/engines/access/room.h index e1a26a4e4e..40290956cd 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -156,15 +156,6 @@ public: class RoomInfo { public: - struct FileIdent { - int _fileNum; - int _subfile; - }; - - struct CellIdent : FileIdent { - byte _cell; - }; - struct SoundIdent : FileIdent { int _priority; }; @@ -184,7 +175,7 @@ public: FileIdent _paletteFile; int _startColor; int _numColors; - Common::Array _vidTable; + Common::Array _extraCells; Common::Array _sounds; public: RoomInfo(const byte *data, int gameType); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f6879584f3..f4934d45a3 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -99,7 +99,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, - &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::CMDCONVERSE, + &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, @@ -309,7 +309,22 @@ void Scripts::cmdNewRoom() { cmdRetPos(); } -void Scripts::CMDCONVERSE() { error("TODO CMDCONVERSE"); } +void Scripts::cmdConverse() { + _vm->_conversation = _data->readUint16LE(); + _vm->_room->clearRoom(); + _vm->freeChar(); + _vm->loadChar(_vm->_conversation); + _vm->_events->setCursor(CURSOR_ARROW); + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 0; + searchForSequence(); + + if (_vm->_screen->_vesaMode) { + _vm->_converseMode = 1; + } +} void Scripts::cmdCheckFrame() { int id = _data->readUint16LE(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 4b224c32bd..ae4c7559e0 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -79,7 +79,7 @@ protected: void cmdCheckInventory(); void cmdSetTex(); void cmdNewRoom(); - void CMDCONVERSE(); + void cmdConverse(); void cmdCheckFrame(); void cmdCheckAnim(); void cmdSnd(); -- cgit v1.2.3 From 31c8a524a35c19291bbd7bed3d117791a90c7401 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 13:13:56 -0400 Subject: ACCESS: More implementation of CharManager --- engines/access/access.cpp | 25 ++++++++--------- engines/access/access.h | 11 +++----- engines/access/char.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++-- engines/access/char.h | 11 +++++++- engines/access/room.cpp | 37 ++++++++++++------------- engines/access/room.h | 2 -- engines/access/screen.h | 5 ++++ engines/access/scripts.cpp | 2 +- 8 files changed, 115 insertions(+), 45 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c84ac8b28d..0718fd697e 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -62,7 +62,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _startup = 0; _currentCharFlag = false; _boxSelect = false; - _charFlag = 0; _scale = 0; _scaleH1 = _scaleH2 = 0; _scaleN1 = 0; @@ -78,7 +77,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _intTim[3] = 0; _timer[3] = 0; Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); - Common::fill(&_establishTable[0], &_establishTable[100], 0); + Common::fill(&_establishTable[0], &_establishTable[100], false); Common::fill(&_flags[0], &_flags[256], 0); _establishFlag = false; _establishMode = 0; @@ -220,15 +219,15 @@ void AccessEngine::freeInactiveData() { _inactive = nullptr; } -void AccessEngine::establish(int v1, int sub) { +void AccessEngine::establish(int esatabIndex, int sub) { _establishMode = 0; _establishGroup = 0; - doEstablish(v1, sub); + doEstablish(esatabIndex, sub); } -void AccessEngine::establishCenter(int v1, int sub) { +void AccessEngine::establishCenter(int esatabIndex, int sub) { _establishMode = 1; - doEstablish(v1, sub); + doEstablish(esatabIndex, sub); } byte *AccessEngine::loadEstablish(int sub) { @@ -236,17 +235,19 @@ byte *AccessEngine::loadEstablish(int sub) { return nullptr; } -void AccessEngine::doEstablish(int v1, int sub) { +void AccessEngine::doEstablish(int esatabIndex, int sub) { + _establishMode = 1; + _screen->forceFadeOut(); _screen->clearScreen(); _screen->setPanel(3); - if (v1 != -1) { - _files->loadScreen(95, v1); + if (esatabIndex != -1) { + _files->loadScreen(95, esatabIndex); _buffer2.copyBuffer(_screen); } - _room->setIconPalette(); + _screen->setIconPalette(); _screen->forceFadeIn(); _fonts._charSet._lo = 1; @@ -374,8 +375,4 @@ void AccessEngine::freeChar() { _animation->freeAnimationData(); } -void AccessEngine::loadChar(int charId) { - -} - } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 974277280c..2e2358f268 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -88,7 +88,7 @@ private: void dummyLoop(); - void doEstablish(int v1, int sub); + void doEstablish(int esatabIndex, int sub); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -126,7 +126,7 @@ public: ASurface _buffer2; Common::Array _charTable; SpriteResource *_objectsTable[100]; - int _establishTable[100]; + bool _establishTable[100]; bool _establishFlag; int _establishMode; int _establishGroup; @@ -150,7 +150,6 @@ public: int _startTravelBox; bool _currentCharFlag; bool _boxSelect; - int _charFlag; int _scale; int _scaleH1, _scaleH2; int _scaleN1; @@ -221,9 +220,9 @@ public: byte *AccessEngine::loadEstablish(int sub); - void establish(int v1, int sub); + void establish(int esatabIndex, int sub); - void establishCenter(int v1, int sub); + void establishCenter(int esatabIndex, int sub); void plotList(); void plotList1(); @@ -239,8 +238,6 @@ public: void doLoadSave(); void freeChar(); - - void loadChar(int charId); }; } // End of namespace Access diff --git a/engines/access/char.cpp b/engines/access/char.cpp index a01643b651..40f3bf376a 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -31,7 +31,7 @@ CharEntry::CharEntry(const byte *data) { Common::MemoryReadStream s(data, 999); _charFlag = s.readByte(); - _estabFlag = s.readSint16LE(); + _estabIndex = s.readSint16LE(); _screenFile._fileNum = s.readSint16LE(); _screenFile._subfile = s.readSint16LE(); @@ -68,7 +68,7 @@ CharEntry::CharEntry(const byte *data) { CharEntry::CharEntry() { _charFlag = 0; - _estabFlag = 0; + _estabIndex = 0; _startColor = _numColors = 0; } @@ -84,6 +84,69 @@ CharManager::CharManager(AccessEngine *vm) : Manager(vm) { default: error("Unknown game"); } + + _charFlag = 0; +} + +void CharManager::loadChar(int charId) { + CharEntry &ce = _charTable[charId]; + _charFlag = ce._charFlag; + + _vm->_establishFlag = false; + if (ce._estabIndex != -1) { + _vm->_establishFlag = true; + if (!_vm->_establishTable[ce._estabIndex]) { + _vm->_establishTable[ce._estabIndex] = true; + _vm->establish(ce._estabIndex, 0); + } + } + + if (_charFlag != 0 && _charFlag != 3) { + if (!_vm->_establishFlag) + _vm->_screen->fadeOut(); + + _vm->_files->loadScreen(ce._screenFile._fileNum, ce._screenFile._subfile); + _vm->_screen->setIconPalette(); + _vm->_screen->fadeIn(); + } + + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->copyFrom(_vm->_buffer2); + _vm->_screen->setDisplayScan(); + + if (_charFlag != 2 && _charFlag != 3) { + charMenu(); + } + + _vm->_screen->_startColor = ce._startColor; + _vm->_screen->_numColors = ce._numColors; + if (ce._paletteFile._fileNum != -1) { + _vm->_screen->loadPalette(ce._paletteFile._fileNum, ce._paletteFile._subfile); + } + _vm->_screen->setIconPalette(); + _vm->_screen->setPalette(); + + _vm->loadCells(ce._cells); + if (ce._animFile._fileNum != -1) { + byte *data = _vm->_files->loadFile(ce._animFile._fileNum, ce._animFile._subfile); + _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + } + + // Load script data + _vm->_scripts->freeScriptData(); + if (ce._scriptFile._fileNum != -1) { + const byte *data = _vm->_files->loadFile(ce._scriptFile._fileNum, ce._scriptFile._subfile); + _vm->_scripts->setScript(data, _vm->_files->_filesize); + } + + // Load extra cells + _vm->_extraCells.clear(); + for (uint i = 0; i < ce._extraCells.size(); ++i) + _vm->_extraCells.push_back(ce._extraCells[i]); +} + +void CharManager::charMenu() { + error("TODO: charMenu"); } } // End of namespace Access diff --git a/engines/access/char.h b/engines/access/char.h index 8d6c49d47a..4bd38d7c6d 100644 --- a/engines/access/char.h +++ b/engines/access/char.h @@ -32,7 +32,7 @@ namespace Access { class CharEntry { public: int _charFlag; - int _estabFlag; + int _estabIndex; FileIdent _screenFile; FileIdent _paletteFile; int _startColor, _numColors; @@ -47,10 +47,19 @@ public: }; class CharManager: public Manager { +private: + void charMenu(); public: Common::Array _charTable; + int _converseMode; + int _charFlag; + + // Fields that are included in savegames + int _conversation; public: CharManager(AccessEngine *vm); + + void loadChar(int charId); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d703114090..3ff4d66337 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -241,39 +241,40 @@ void Room::roomLoop() { } void Room::setupRoom() { - _vm->_screen->setScaleTable(_vm->_scale); - _vm->_screen->setBufferScan(); + Screen &screen = *_vm->_screen; + screen.setScaleTable(_vm->_scale); + screen.setBufferScan(); if (_roomFlag != 2) - setIconPalette(); + screen.setIconPalette(); - if (_vm->_screen->_vWindowWidth == _playFieldWidth) { - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollCol = 0; + if (screen._vWindowWidth == _playFieldWidth) { + screen._scrollX = 0; + screen._scrollCol = 0; } else { int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; - _vm->_screen->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; - _vm->_screen->_scrollCol = MAX(xv - (_vm->_screen->_vWindowWidth / 2), 0); + screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); - int sx = _vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth - _playFieldWidth; + int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth; if (sx >= 0) { - _vm->_screen->_scrollCol -= sx + 1; + screen._scrollCol -= sx + 1; } } - if (_vm->_screen->_vWindowHeight == _playFieldHeight) { - _vm->_screen->_scrollY = 0; - _vm->_screen->_scrollRow = 0; + if (screen._vWindowHeight == _playFieldHeight) { + screen._scrollY = 0; + screen._scrollRow = 0; } else { - _vm->_screen->_scrollY = _vm->_player->_rawPlayer.y - + screen._scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y >> 4); int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - - (_vm->_screen->_vWindowHeight / 2), 0); - _vm->_screen->_scrollRow = yp; + (screen._vWindowHeight / 2), 0); + screen._scrollRow = yp; - yp = yp + _vm->_screen->_vWindowHeight - _playFieldHeight; + yp = yp + screen._vWindowHeight - _playFieldHeight; if (yp >= 0) { - _vm->_screen->_scrollRow = yp + 1; + screen._scrollRow = yp + 1; } } } diff --git a/engines/access/room.h b/engines/access/room.h index 40290956cd..d876a30875 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -116,8 +116,6 @@ protected: virtual void roomMenu() = 0; virtual void mainAreaClick() = 0; -public: - virtual void setIconPalette() {} public: Plotter _plotter; Common::Array _jetFrame; diff --git a/engines/access/screen.h b/engines/access/screen.h index e66a7a3759..5ffba5ad3e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -114,6 +114,11 @@ public: */ void setInitialPalettte(); + /** + * Set icon palette + */ + void setIconPalette() {} + void loadPalette(Common::SeekableReadStream *stream); void loadPalette(int fileNum, int subfile); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f4934d45a3..985f5cba66 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -313,7 +313,7 @@ void Scripts::cmdConverse() { _vm->_conversation = _data->readUint16LE(); _vm->_room->clearRoom(); _vm->freeChar(); - _vm->loadChar(_vm->_conversation); + _vm->_char->loadChar(_vm->_conversation); _vm->_events->setCursor(CURSOR_ARROW); _vm->_images.clear(); -- cgit v1.2.3 From 1e2d79eb598a0ed73a59cc540cddbaddf0bc90dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 14:13:26 -0400 Subject: ACCESS: Implement more opcodes, stubbed beginning of video player --- engines/access/access.cpp | 5 ++++- engines/access/access.h | 2 ++ engines/access/char.cpp | 41 +++++++++++++++++++++++------------------ engines/access/data.cpp | 5 +++-- engines/access/data.h | 21 +++------------------ engines/access/files.cpp | 16 ++++++++++++++++ engines/access/files.h | 18 ++++++++++++++++++ engines/access/module.mk | 1 + engines/access/room.cpp | 34 ++++++++++++---------------------- engines/access/scripts.cpp | 29 ++++++++++++++++++++++++----- engines/access/scripts.h | 4 ++-- engines/access/sound.cpp | 2 ++ engines/access/sound.h | 3 ++- engines/access/video.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/access/video.h | 41 +++++++++++++++++++++++++++++++++++++++++ 15 files changed, 188 insertions(+), 69 deletions(-) create mode 100644 engines/access/video.cpp create mode 100644 engines/access/video.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 0718fd697e..4035870dad 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -44,6 +44,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _screen = nullptr; _scripts = nullptr; _sound = nullptr; + _video = nullptr; _destIn = nullptr; _current = nullptr; @@ -116,6 +117,7 @@ AccessEngine::~AccessEngine() { delete _screen; delete _scripts; delete _sound; + delete _video; freeCells(); delete[] _inactive; @@ -156,6 +158,7 @@ void AccessEngine::initialize() { _player = new Player(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); + _video = new VideoPlayer(this); _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); _buffer2.create(g_system->getWidth(), g_system->getHeight()); @@ -201,7 +204,7 @@ int AccessEngine::getRandomNumber(int maxNumber) { void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { - byte *spriteData = _files->loadFile(cells[i]._fileNum, cells[i]._subfile); + byte *spriteData = _files->loadFile(cells[i]); _objectsTable[cells[i]._cell] = new SpriteResource(this, spriteData, _files->_filesize, DisposeAfterUse::YES); } diff --git a/engines/access/access.h b/engines/access/access.h index 2e2358f268..0d4ad19452 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -43,6 +43,7 @@ #include "access/screen.h" #include "access/scripts.h" #include "access/sound.h" +#include "access/video.h" /** * This is the namespace of the Access engine. @@ -119,6 +120,7 @@ public: Screen *_screen; Scripts *_scripts; SoundManager *_sound; + VideoPlayer *_video; ASurface *_destIn; ASurface *_current; diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 40f3bf376a..09335fc017 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -32,11 +32,8 @@ CharEntry::CharEntry(const byte *data) { _charFlag = s.readByte(); _estabIndex = s.readSint16LE(); - _screenFile._fileNum = s.readSint16LE(); - _screenFile._subfile = s.readSint16LE(); - - _paletteFile._fileNum = s.readSint16LE(); - _paletteFile._subfile = s.readUint16LE(); + _screenFile.load(s); + _paletteFile.load(s); _startColor = s.readUint16LE(); _numColors = s.readUint16LE(); @@ -44,23 +41,19 @@ CharEntry::CharEntry(const byte *data) { for (byte cell = s.readByte(); cell != 0xff; cell = s.readByte()) { CellIdent ci; ci._cell = cell; - ci._fileNum = s.readSint16LE(); - ci._subfile = s.readUint16LE(); + ci.load(s); _cells.push_back(ci); } - _animFile._fileNum = s.readSint16LE(); - _animFile._subfile = s.readUint16LE(); - _scriptFile._fileNum = s.readSint16LE(); - _scriptFile._subfile = s.readUint16LE(); + _animFile.load(s); + _scriptFile.load(s); for (int16 v = s.readSint16LE(); v != -1; v = s.readSint16LE()) { ExtraCell ec; - ec._vidTable = v; - ec._vidTable1 = s.readSint16LE(); - ec._vidSTable = s.readSint16LE(); - ec._vidSTable1 = s.readSint16LE(); + ec._vid._fileNum = v; + ec._vid._subfile = s.readSint16LE(); + ec._vidSound.load(s); _extraCells.push_back(ec); } @@ -128,14 +121,14 @@ void CharManager::loadChar(int charId) { _vm->loadCells(ce._cells); if (ce._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(ce._animFile._fileNum, ce._animFile._subfile); + byte *data = _vm->_files->loadFile(ce._animFile); _vm->_animation->loadAnimations(data, _vm->_files->_filesize); } // Load script data _vm->_scripts->freeScriptData(); if (ce._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(ce._scriptFile._fileNum, ce._scriptFile._subfile); + const byte *data = _vm->_files->loadFile(ce._scriptFile); _vm->_scripts->setScript(data, _vm->_files->_filesize); } @@ -146,7 +139,19 @@ void CharManager::loadChar(int charId) { } void CharManager::charMenu() { - error("TODO: charMenu"); + byte *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); + delete[] iconData; + + Screen &screen = *_vm->_screen; + screen.saveScreen(); + screen.setDisplayScan(); + + screen.plotImage(spr, 17, Common::Point(0, 176)); + screen.plotImage(spr, 18, Common::Point(155, 176)); + + screen.restoreScreen(); + delete spr; } } // End of namespace Access diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 094272b05c..a13c6d9a67 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -21,9 +21,10 @@ */ #include "common/algorithm.h" -#include "access/data.h" -#include "graphics/palette.h" +#include "common/stream.h" #include "common/system.h" +#include "graphics/palette.h" +#include "access/data.h" namespace Access { diff --git a/engines/access/data.h b/engines/access/data.h index c10b2b7f17..3238dafa33 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -28,6 +28,7 @@ #include "common/rect.h" #include "common/types.h" #include "graphics/surface.h" +#include "access/files.h" namespace Access { @@ -40,20 +41,6 @@ public: Manager(AccessEngine *vm) : _vm(vm) {} }; -struct FileIdent { - int _fileNum; - int _subfile; - - FileIdent() { - _fileNum = -1; - _subfile = 0; - } -}; - -struct CellIdent : FileIdent { - byte _cell; -}; - struct TimerEntry { int _initTm; int _timer; @@ -91,10 +78,8 @@ public: class ExtraCell { public: - int _vidTable; - int _vidTable1; - int _vidSTable; - int _vidSTable1; + FileIdent _vid; + FileIdent _vidSound; }; struct FontVal { diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 970b0b9019..c805121d50 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -27,6 +27,18 @@ namespace Access { +FileIdent::FileIdent() { + _fileNum = -1; + _subfile = 0; +} + +void FileIdent::load(Common::SeekableReadStream &s) { + _fileNum = s.readSint16LE(); + _subfile = s.readUint16LE(); +} + +/*------------------------------------------------------------------------*/ + FileManager::FileManager(AccessEngine *vm): _vm(vm) { switch (vm->getGameID()) { case GType_Amazon: @@ -55,6 +67,10 @@ byte *FileManager::loadFile(int fileNum, int subfile) { return handleFile(); } +byte *FileManager::loadFile(FileIdent &fileIdent) { + return loadFile(fileIdent._fileNum, fileIdent._subfile); +} + byte *FileManager::loadFile(const Common::String &filename) { // Open the file openFile(filename); diff --git a/engines/access/files.h b/engines/access/files.h index 848ee0d2ca..38d9179195 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -32,6 +32,19 @@ namespace Access { class AccessEngine; +struct FileIdent { + int _fileNum; + int _subfile; + + FileIdent(); + + void load(Common::SeekableReadStream &s); +}; + +struct CellIdent : FileIdent { + byte _cell; +}; + class FileManager { private: AccessEngine *_vm; @@ -55,6 +68,11 @@ public: */ byte *loadFile(int fileNum, int subfile); + /** + * Loads a resource specified by a file identifier + */ + byte *loadFile(FileIdent &fileIdent); + /** * Load a given file by name */ diff --git a/engines/access/module.mk b/engines/access/module.mk index 31f0760491..e92c2cc564 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -19,6 +19,7 @@ MODULE_OBJS := \ screen.o \ scripts.o \ sound.o \ + video.o \ amazon/amazon_game.o \ amazon/amazon_resources.o \ amazon/amazon_room.o \ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3ff4d66337..90ef3470db 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -174,8 +174,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_sound->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile._fileNum, - roomInfo._musicFile._subfile); + _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); _vm->_sound->_midiSize = _vm->_files->_filesize; _vm->_sound->midiPlay(); _vm->_sound->_musicRepeat = true; @@ -200,16 +199,14 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); if (roomInfo._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(roomInfo._scriptFile._fileNum, - roomInfo._scriptFile._subfile); + const byte *data = _vm->_files->loadFile(roomInfo._scriptFile); _vm->_scripts->setScript(data, _vm->_files->_filesize); } // Load animation data _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(roomInfo._animFile._fileNum, - roomInfo._animFile._subfile); + byte *data = _vm->_files->loadFile(roomInfo._animFile); _vm->_animation->loadAnimations(data, _vm->_files->_filesize); } @@ -726,31 +723,25 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { else _estIndex = -1; - _musicFile._fileNum = stream.readSint16LE(); - _musicFile._subfile = stream.readUint16LE(); + _musicFile.load(stream); _scaleH1 = stream.readByte(); _scaleH2 = stream.readByte(); _scaleN1 = stream.readByte(); - _playFieldFile._fileNum = stream.readSint16LE(); - _playFieldFile._subfile = stream.readUint16LE(); + _playFieldFile.load(stream); for (byte cell = stream.readByte(); cell != 0xff; cell = stream.readByte()) { CellIdent ci; ci._cell = cell; - ci._fileNum = stream.readSint16LE(); - ci._subfile = stream.readUint16LE(); + ci.load(stream); _cells.push_back(ci); } - _scriptFile._fileNum = stream.readSint16LE(); - _scriptFile._subfile = stream.readUint16LE(); - _animFile._fileNum = stream.readSint16LE(); - _animFile._subfile = stream.readUint16LE(); + _scriptFile.load(stream); + _animFile.load(stream); _scaleI = stream.readByte(); _scrollThreshold = stream.readByte(); - _paletteFile._fileNum = stream.readSint16LE(); - _paletteFile._subfile = stream.readUint16LE(); + _paletteFile.load(stream); if (_paletteFile._fileNum == -1) { _startColor = _numColors = 0; } else { @@ -760,10 +751,9 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { for (int16 v = stream.readSint16LE(); v != -1; v = stream.readSint16LE()) { ExtraCell ec; - ec._vidTable = v; - ec._vidTable1 = stream.readSint16LE(); - ec._vidSTable = stream.readSint16LE(); - ec._vidSTable1 = stream.readSint16LE(); + ec._vid._fileNum = v; + ec._vid._subfile = stream.readSint16LE(); + ec._vidSound.load(stream); _extraCells.push_back(ec); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 985f5cba66..2a834f8855 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -104,7 +104,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, - &Scripts::cmdSetTravel, &Scripts::CMDSETVID, &Scripts::CMDPLAYVID, + &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, @@ -113,7 +113,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, - &Scripts::CMDFREESOUND, &Scripts::CMDSETVIDSND, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, @@ -417,7 +417,16 @@ void Scripts::cmdSetTravel() { _data->skip(2); } -void Scripts::CMDSETVID() { error("TODO CMDSETVID"); } +void Scripts::cmdSetVideo() { + FileIdent fi; + fi._fileNum = _data->readSint16LE(); + fi._subfile = _data->readUint16LE(); + int cellIndex = _data->readUint16LE(); + int rate = _data->readUint16LE(); + + _vm->_video->setVideo(_vm->_extraCells[cellIndex]._vid, fi, rate); +} + void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); } void Scripts::cmdPlotImage() { @@ -645,12 +654,22 @@ void Scripts::cmdClearBlock() { void Scripts::cmdLoadSound() { int idx = _data->readSint16LE(); - _vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSTable, _vm->_extraCells[idx]._vidSTable1); + _vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); _vm->_sound->_soundPriority[0] = 1; } void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } -void Scripts::CMDSETVIDSND() { error("TODO CMDSETVIDSND"); } + +void Scripts::cmdSetVideoSound() { + _data->skip(4); + cmdLoadSound(); + _data->skip(-6); + cmdSetVideo(); + + _vm->_sound->_soundFrame = _data->readUint16LE(); + _vm->_sound->_soundFlag = false; +} + void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); } void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ae4c7559e0..93cd495be6 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -90,7 +90,7 @@ protected: void cmdSetTimer(); void cmdCheckTimer(); void cmdSetTravel(); - void CMDSETVID(); + void cmdSetVideo(); void CMDPLAYVID(); void cmdPlotImage(); void cmdSetDisplay(); @@ -114,7 +114,7 @@ protected: void cmdClearBlock(); void cmdLoadSound(); void CMDFREESOUND(); - void CMDSETVIDSND(); + void cmdSetVideoSound(); void CMDPLAYVIDSND(); void CMDPUSHLOCATION(); void cmdPlayerOff(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index c6897282fa..aebd76fe84 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -36,6 +36,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _music = nullptr; _midiSize = 0; _musicRepeat = false; + _soundFrame = 0; + _soundFlag = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index dd94396fa9..cb73bae52c 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -51,7 +51,8 @@ public: byte *_music; int _midiSize; bool _musicRepeat; - + int _soundFrame; + bool _soundFlag; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); diff --git a/engines/access/video.cpp b/engines/access/video.cpp new file mode 100644 index 0000000000..a025d31022 --- /dev/null +++ b/engines/access/video.cpp @@ -0,0 +1,35 @@ +/* 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 "access/video.h" + +namespace Access { + +VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { + +} + +void VideoPlayer::setVideo(FileIdent &fi1, FileIdent &fi2, int rate) { + error("TODO: setVideo"); +} + +} // End of namespace Access diff --git a/engines/access/video.h b/engines/access/video.h new file mode 100644 index 0000000000..b21f006a97 --- /dev/null +++ b/engines/access/video.h @@ -0,0 +1,41 @@ +/* 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 ACCESS_VIDEO_H +#define ACCESS_VIDEO_H + +#include "common/scummsys.h" +#include "access/data.h" +#include "access/files.h" + +namespace Access { + +class VideoPlayer: public Manager { +public: + VideoPlayer(AccessEngine *vm); + + void setVideo(FileIdent &fi1, FileIdent &fi2, int rate); +}; + +} // End of namespace Access + +#endif /* ACCESS_VIDEO_H */ -- cgit v1.2.3 From 148eb972abad3d1ac8b8685a25b88f74fb5dae5e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 14:28:07 -0400 Subject: ACCESS: Fix fade outs --- engines/access/screen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index af97e2e236..f62c2f5baf 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -139,7 +139,7 @@ void Screen::forceFadeOut() { do { repeatFlag = false; - for (srcP = &_tempPalette[0], count = 0; count < PALETTE_COUNT; ++count, ++srcP) { + for (srcP = &_tempPalette[0], count = 0; count < PALETTE_SIZE; ++count, ++srcP) { int v = *srcP; if (v) { repeatFlag = true; @@ -149,7 +149,7 @@ void Screen::forceFadeOut() { updatePalette(); g_system->delayMillis(10); - } while (repeatFlag); + } while (repeatFlag && !_vm->shouldQuit()); } void Screen::forceFadeIn() { -- cgit v1.2.3 From ec70f3feaf3f2e81376d0bbb0ab6c11554ef1fbc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 14:47:06 -0400 Subject: ACCESS: Fix graphic glitch when scrolling up --- engines/access/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index e85b68a24d..4be24f4253 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -719,7 +719,7 @@ scrollUp: // Scroll up if (scrollUp()) { _scrollEnd = 4; - _vm->_screen->_scrollY = TILE_HEIGHT; + _vm->_screen->_scrollY &= TILE_HEIGHT; _scrollFlag = true; } } -- cgit v1.2.3 From f98d4668d718b04713ebe9ed2abc41f8bcaed609 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 17:19:54 -0400 Subject: ACCESS: Improvements for horizontal scrolling --- engines/access/asurface.cpp | 20 ++++++++++++++++++ engines/access/asurface.h | 8 +++++++ engines/access/player.cpp | 51 ++++++++++++++++++++++----------------------- engines/access/screen.cpp | 12 ----------- engines/access/screen.h | 6 ------ 5 files changed, 53 insertions(+), 44 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index e88bd27c91..138978f9d9 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -324,4 +324,24 @@ void ASurface::flipHorizontal(ASurface &dest) { } +void ASurface::moveBufferLeft() { + byte *p = (byte *)getPixels(); + Common::copy(p + TILE_WIDTH, p + (w * h), p); +} + +void ASurface::moveBufferRight() { + byte *p = (byte *)getPixels(); + Common::copy_backward(p, p + (w * h) - TILE_WIDTH, p + (w * h)); +} + +void ASurface::moveBufferUp() { + byte *p = (byte *)getPixels(); + Common::copy(p + w, p + (w * h), p); +} + +void ASurface::moveBufferDown() { + byte *p = (byte *)getPixels(); + Common::copy_backward(p, p + (w * (h - 1)), p + (w * h)); +} + } // End of namespace Access diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 84fe90dbbd..62e292334d 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -97,6 +97,14 @@ public: void restoreBlock(); void drawRect(); + + void moveBufferLeft(); + + void moveBufferRight(); + + void moveBufferUp(); + + void moveBufferDown(); }; class SpriteFrame : public ASurface { diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 4be24f4253..7df277c3a0 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -738,7 +738,7 @@ bool Player::scrollUp() { while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { _vm->_screen->_scrollY -= TILE_HEIGHT; ++_vm->_screen->_scrollRow; - _vm->_screen->moveBufferUp(); + _vm->_buffer1.moveBufferUp(); _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide); @@ -766,7 +766,7 @@ bool Player::scrollDown() { if (--_vm->_screen->_scrollRow < 0) break; - _vm->_screen->moveBufferDown(); + _vm->_buffer1.moveBufferDown(); _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); if (_vm->_screen->_scrollY >= 0) @@ -780,28 +780,29 @@ bool Player::scrollDown() { } bool Player::scrollLeft() { - _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); - if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) { + Screen &screen = *_vm->_screen; + _scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold); + if ((_vm->_rScrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { _scrollEnd = 2; - _vm->_screen->_scrollX = 0; + screen._scrollX = 0; _scrollFlag = true; return true; } else { _scrollFlag = true; - _vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount; + screen._scrollX = screen._scrollX + _scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; - _vm->_screen->moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + - _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + do { + if (screen._scrollX < TILE_WIDTH) + return true; - if (_vm->_screen->_scrollX < TILE_WIDTH) - return _playerDirection == UPRIGHT; - } + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, + screen._vWindowBytesWide); + } while (!_vm->shouldQuit() && (screen._scrollX >= TILE_WIDTH)); - return true; + return (_playerDirection == UPRIGHT); } } @@ -811,18 +812,16 @@ bool Player::scrollRight() { _vm->_screen->_scrollX -= _scrollAmount; if (_vm->_screen->_scrollX < 0) { - _scrollFlag = true; - _vm->_screen->_scrollX += _scrollAmount; + do { + _vm->_screen->_scrollX += TILE_WIDTH; + if (--_vm->_screen->_scrollCol < 0) + return true; - while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) { - _vm->_screen->_scrollX -= TILE_WIDTH; - _vm->_screen->moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol - - _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + _vm->_buffer1.moveBufferRight(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); + } while (!_vm->shouldQuit() && (_vm->_screen->_scrollX >= 0)); - if (_vm->_screen->_scrollX < TILE_WIDTH) - return _playerDirection == UPLEFT; - } + return false; } return true; diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index f62c2f5baf..57002c0f7c 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -224,18 +224,6 @@ void Screen::restoreScreen() { _screenYOff = _screenSave._screenYOff; } -void Screen::moveBufferLeft() { - error("TODO: LEFT"); -} - -void Screen::moveBufferDown() { - error("TODO: DOWN"); -} - -void Screen::moveBufferUp() { - error("TODO: UP"); -} - void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { Common::Rect destBounds = bounds; destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff); diff --git a/engines/access/screen.h b/engines/access/screen.h index 5ffba5ad3e..3935f2c149 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -149,12 +149,6 @@ public: * Restores previously saved screen display state variables */ void restoreScreen(); - - void moveBufferLeft(); - - void moveBufferDown(); - - void moveBufferUp(); }; } // End of namespace Access -- cgit v1.2.3 From 955df7a94ce21d311d6e34d263d96070548d855e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Aug 2014 23:49:08 +0200 Subject: ACCESS: Start implementing loadEstablish --- engines/access/access.cpp | 34 ++++++++++++++++++++++++++++++---- engines/access/access.h | 8 +++++++- engines/access/files.cpp | 4 ++++ engines/access/files.h | 5 +++++ 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 4035870dad..e90e5bad22 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -83,6 +83,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _establishFlag = false; _establishMode = 0; _establishGroup = 0; + _establishCtrlTblOfs = 0; Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); Common::fill(&_help1[0], &_help3[366], 0); @@ -102,6 +103,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _screenVirtX = 0; _lastTime = g_system->getMillis(); _curTime = 0; + _narateFile = 0; + _txtPages = 0; + _sndSubFile = 0; } AccessEngine::~AccessEngine() { @@ -233,9 +237,31 @@ void AccessEngine::establishCenter(int esatabIndex, int sub) { doEstablish(esatabIndex, sub); } -byte *AccessEngine::loadEstablish(int sub) { - warning("TODO: loadEstablish"); - return nullptr; +const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" }; + +void AccessEngine::loadEstablish(int sub) { + if (!_files->existFile("ETEXT.DAT")) { + int oldGroup = _establishGroup; + _establishGroup = 0; + + _eseg = _files->loadFile(_estTable[oldGroup]); + } else { + _eseg = _files->loadFile("ETEXT.DAT"); + } + + _establishCtrlTblOfs = READ_LE_UINT16(_eseg); + + int ofs = _establishCtrlTblOfs + (sub * 2); + int idx = READ_LE_UINT16(_eseg + ofs); + _narateFile = READ_LE_UINT16(_eseg + idx); + _txtPages = READ_LE_UINT16(_eseg + idx + 2); + + if (!_txtPages) + return; + + _sndSubFile = READ_LE_UINT16(_eseg + idx + 4); + for (int i = 0; i < _txtPages; ++i) + _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); } void AccessEngine::doEstablish(int esatabIndex, int sub) { @@ -260,7 +286,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { _bubbleBox->_maxChars = 37; _fonts._printOrg = _fonts._printStart = Common::Point(48, 35); - _eseg = loadEstablish(sub); + loadEstablish(sub); _et = sub; warning("CHECKME: Use of di"); _printEnd = 155; diff --git a/engines/access/access.h b/engines/access/access.h index 0d4ad19452..db969357aa 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -73,6 +73,8 @@ enum AccessDebugChannels { struct AccessGameDescription; +extern const char *const _estTable[]; + class AccessEngine : public Engine { private: uint32 _lastTime, _curTime; @@ -132,6 +134,7 @@ public: bool _establishFlag; int _establishMode; int _establishGroup; + int _establishCtrlTblOfs; int _numAnimTimers; TimerList _timers; FontManager _fonts; @@ -164,6 +167,9 @@ public: int _et; int _printEnd; int _txtPages; + int _narateFile; + int _sndSubFile; + int _countTbl[6]; // Fields that are included in savegames int _conversation; @@ -220,7 +226,7 @@ public: */ void freeInactiveData(); - byte *AccessEngine::loadEstablish(int sub); + void AccessEngine::loadEstablish(int sub); void establish(int esatabIndex, int sub); diff --git a/engines/access/files.cpp b/engines/access/files.cpp index c805121d50..da3842492c 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -82,6 +82,10 @@ byte *FileManager::loadFile(const Common::String &filename) { return handleFile(); } +bool FileManager::existFile(const Common::String &filename) { + return _file.exists(filename); +} + void FileManager::openFile(const Common::String &filename) { // Open up the file _fileNumber = -1; diff --git a/engines/access/files.h b/engines/access/files.h index 38d9179195..b91da7d6ff 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -63,6 +63,11 @@ public: FileManager(AccessEngine *vm); ~FileManager(); + /** + * Check the existence of a given file + */ + bool FileManager::existFile(const Common::String &filename); + /** * Load a given subfile from a container file */ -- cgit v1.2.3 From ee62d6c1cfce009331050fb9bf8bfecbb8f51472 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 23 Aug 2014 23:21:17 -0400 Subject: ACCESS: In progress inventory display screen --- engines/access/asurface.cpp | 3 + engines/access/asurface.h | 2 + engines/access/events.cpp | 88 ++++++++++--------- engines/access/events.h | 10 ++- engines/access/files.cpp | 8 ++ engines/access/files.h | 3 + engines/access/inventory.cpp | 202 ++++++++++++++++++++++++++++++++++++++++++- engines/access/inventory.h | 41 +++++++++ engines/access/resources.cpp | 29 +++++++ engines/access/resources.h | 2 + engines/access/room.cpp | 27 ++---- engines/access/room.h | 12 ++- 12 files changed, 363 insertions(+), 64 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 138978f9d9..ce977f6d83 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -265,6 +265,9 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { } } +void ASurface::copyTo(ASurface *dest) { + copyTo(dest, Common::Point()); +} void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h)); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 62e292334d..f5e5f48e7b 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -92,6 +92,8 @@ public: void copyTo(ASurface *dest, const Common::Rect &bounds); + void copyTo(ASurface *dest); + void saveBlock(const Common::Rect &bounds); void restoreBlock(); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 78bbdbf1ea..15c8f8cff0 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -41,11 +41,11 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _priorFrameTime = 0; _leftButton = _rightButton = false; _mouseCol = _mouseRow = 0; - _mouseMode = 0; _cursorExitFlag = false; } EventsManager::~EventsManager() { + _invCursor.free(); } void EventsManager::setCursor(CursorType cursorId) { @@ -53,50 +53,56 @@ void EventsManager::setCursor(CursorType cursorId) { return; _cursorId = cursorId; - if (_mouseMode == 1 && cursorId == CURSOR_ARROW) - _mouseMode = 2; - else if (_mouseMode == 2 && cursorId != CURSOR_ARROW) - _mouseMode = 1; - - // Get a pointer to the mouse data to use, and get the cursor hotspot - const byte *srcP = Amazon::CURSORS[cursorId]; - int hotspotX = (int16)READ_LE_UINT16(srcP); - int hotspotY = (int16)READ_LE_UINT16(srcP + 2); - srcP += 4; - - // Create a surface to build up the cursor on - Graphics::Surface cursorSurface; - cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8()); - byte *destP = (byte *)cursorSurface.getPixels(); - Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0); - - // Loop to build up the cursor - for (int y = 0; y < CURSOR_HEIGHT; ++y) { - destP = (byte *)cursorSurface.getBasePtr(0, y); - int width = CURSOR_WIDTH; - int skip = *srcP++; - int plot = *srcP++; - if (skip >= width) - break; + if (cursorId == CURSOR_INVENTORY) { + // Set the cursor + CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h, + 0, 0, 0); + } else { + // Get a pointer to the mouse data to use, and get the cursor hotspot + const byte *srcP = Amazon::CURSORS[cursorId]; + int hotspotX = (int16)READ_LE_UINT16(srcP); + int hotspotY = (int16)READ_LE_UINT16(srcP + 2); + srcP += 4; + + // Create a surface to build up the cursor on + Graphics::Surface cursorSurface; + cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8()); + byte *destP = (byte *)cursorSurface.getPixels(); + Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0); + + // Loop to build up the cursor + for (int y = 0; y < CURSOR_HEIGHT; ++y) { + destP = (byte *)cursorSurface.getBasePtr(0, y); + int width = CURSOR_WIDTH; + int skip = *srcP++; + int plot = *srcP++; + if (skip >= width) + break; + + // Skip over pixels + destP += skip; + width -= skip; + + // Write out the pixels to plot + while (plot > 0 && width > 0) { + *destP++ = *srcP++; + --plot; + --width; + } + } - // Skip over pixels - destP += skip; - width -= skip; + // Set the cursor + CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT, + hotspotX, hotspotY, 0); - // Write out the pixels to plot - while (plot > 0 && width > 0) { - *destP++ = *srcP++; - --plot; - --width; - } + // Free the cursor surface + cursorSurface.free(); } +} - // Set the cursor - CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT, - hotspotX, hotspotY, 0); - - // Free the cursor surface - cursorSurface.free(); +void EventsManager::setCursorData(Graphics::Surface *src, const Common::Rect &r) { + _invCursor.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8()); + _invCursor.copyRectToSurface(*src, 0, 0, r); } void EventsManager::showCursor() { diff --git a/engines/access/events.h b/engines/access/events.h index 2ced71f50e..fdfb0a5043 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -32,7 +32,8 @@ namespace Access { enum CursorType { CURSOR_NONE = -1, CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, - CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP + CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP, + CURSOR_INVENTORY = 99 }; #define GAME_FRAME_RATE 100 @@ -45,6 +46,7 @@ private: AccessEngine *_vm; uint32 _frameCounter; uint32 _priorFrameTime; + Graphics::Surface _invCursor; bool checkForNextFrameCounter(); @@ -55,7 +57,6 @@ public: bool _leftButton, _rightButton; Common::Point _mousePos; int _mouseCol, _mouseRow; - int _mouseMode; bool _cursorExitFlag; Common::FixedStack _keypresses; public: @@ -74,6 +75,11 @@ public: */ void setCursor(CursorType cursorId); + /** + * Set the image for the inventory cursor + */ + void setCursorData(Graphics::Surface *src, const Common::Rect &r); + /** * Return the current cursor Id */ diff --git a/engines/access/files.cpp b/engines/access/files.cpp index da3842492c..230d2a8715 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -39,6 +39,14 @@ void FileIdent::load(Common::SeekableReadStream &s) { /*------------------------------------------------------------------------*/ +CellIdent::CellIdent(int cell, int fileNum, int subfile) { + _cell = cell; + _fileNum = fileNum; + _subfile = subfile; +} + +/*------------------------------------------------------------------------*/ + FileManager::FileManager(AccessEngine *vm): _vm(vm) { switch (vm->getGameID()) { case GType_Amazon: diff --git a/engines/access/files.h b/engines/access/files.h index b91da7d6ff..d1a4d5aafd 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -43,6 +43,9 @@ struct FileIdent { struct CellIdent : FileIdent { byte _cell; + + CellIdent() {} + CellIdent(int cell, int fileNum, int subfile); }; class FileManager { diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index e90ad62344..6c56f6b90b 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -22,6 +22,7 @@ #include "access/inventory.h" #include "access/access.h" +#include "access/resources.h" #include "access/amazon/amazon_resources.h" #include "access/martian/martian_resources.h" @@ -35,6 +36,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _invModeFlag = false; _startAboutItem = 0; _startTravelItem = 0; + _iconDisplayFlag = false; const char *const *names; switch (vm->getGameID()) { @@ -74,9 +76,205 @@ void InventoryManager::refreshInventory() { } int InventoryManager::newDisplayInv() { - warning("TODO: newDisplayInv"); - return 0; + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Room &room = *_vm->_room; + FileManager &files = *_vm->_files; + + _invModeFlag = true; + _vm->_timers.saveTimers(); + + if (room._tile && !_invRefreshFlag) { + _vm->_buffer1.copyTo(&_savedBuffer1); + screen.copyTo(&_savedScreen); + } + + savedFields(); + screen.setPanel(1); + events._cursorExitFlag = false; + getList(); + initFields(); + + files.loadScreen(99, 0); + _vm->_buffer1.copyTo(&_vm->_buffer2); + _vm->copyBF2Vid(); + + // Set cells + Common::Array cells; + cells.push_back(CellIdent(99, 99, 1)); + _vm->loadCells(cells); + + showAllItems(); + + if (!_invRefreshFlag) { + chooseItem(); + if (_vm->_useItem != -1) { + int savedScale = _vm->_scale; + _vm->_scale = 153; + _vm->_screen->setScaleTable(_vm->_scale); + _vm->_buffer1.clearBuffer(); + + SpriteResource *spr = _vm->_objectsTable[99]; + SpriteFrame *frame = spr->getFrame(_vm->_useItem); + + int w = screen._scaleTable1[46]; + int h = screen._scaleTable1[35]; + _vm->_buffer1.sPlotF(frame, Common::Rect(0, 0, w, h)); + events.setCursorData(&_vm->_buffer1, Common::Rect(0, 0, w, h)); + + _vm->_scale = savedScale; + screen.setScaleTable(_vm->_scale); + } + } + + freeInvCells(); + screen.setPanel(0); + events.debounceLeft(); + + restoreFields(); + screen.restorePalette(); + if (!screen._vesaMode && !_invRefreshFlag) { + screen.clearBuffer(); + screen.setPalette(); + } + + if (!room._tile && !_invRefreshFlag) { + _savedBuffer1.copyTo(&_vm->_buffer1); + _savedScreen.copyTo(_vm->_screen); + } else { + screen.setBufferScan(); + room.buildScreen(); + + if (!screen._vesaMode) { + screen.fadeOut(); + _vm->copyBF2Vid(); + } + } + + events._cursorExitFlag = false; + screen._screenChangeFlag = false; + _invModeFlag = false; + events.debounceLeft(); + _vm->_timers.restoreTimers(); + _vm->_startup = 1; + + int result = 0; + if (!_invRefreshFlag) { + if (_vm->_useItem == -1) { + result = 2; + } + } + + _invRefreshFlag = false; + _invChangeFlag = false; + return result; +} + +void InventoryManager::savedFields() { + Screen &screen = *_vm->_screen; + Room &room = *_vm->_room; + + _fields._vWindowHeight = screen._vWindowHeight; + _fields._vWindowLinesTall = screen._vWindowLinesTall; + _fields._vWindowWidth = screen._vWindowWidth; + _fields._vWindowBytesWide = screen._vWindowBytesWide; + _fields._playFieldHeight = room._playFieldHeight; + _fields._playFieldWidth = room._playFieldWidth; + _fields._windowXAdd = screen._windowXAdd; + _fields._windowYAdd = screen._windowYAdd; + _fields._screenYOff = screen._screenYOff; + _fields._scrollX = screen._scrollX; + _fields._scrollY = screen._scrollY; + _fields._clipWidth = screen._clipWidth; + _fields._clipHeight = screen._clipHeight; + _fields._bufferStart = screen._bufferStart; + _fields._scrollCol = screen._scrollCol; + _fields._scrollRow = screen._scrollRow; +} + +void InventoryManager::restoreFields() { + Screen &screen = *_vm->_screen; + Room &room = *_vm->_room; + + screen._vWindowHeight = _fields._vWindowHeight; + screen._vWindowLinesTall = _fields._vWindowLinesTall; + screen._vWindowWidth = _fields._vWindowWidth; + screen._vWindowBytesWide = _fields._vWindowBytesWide; + room._playFieldHeight = _fields._playFieldHeight; + room._playFieldWidth = _fields._playFieldWidth; + screen._windowXAdd = _fields._windowXAdd; + screen._windowYAdd = _fields._windowYAdd; + screen._screenYOff = _fields._screenYOff; + screen._scrollX = _fields._scrollX; + screen._scrollY = _fields._scrollY; + screen._clipWidth = _fields._clipWidth; + screen._clipHeight = _fields._clipHeight; + screen._bufferStart = _fields._bufferStart; + screen._scrollCol = _fields._scrollCol; + screen._scrollRow = _fields._scrollRow; +} + +void InventoryManager::initFields() { + Screen &screen = *_vm->_screen; + Room &room = *_vm->_room; + + screen._vWindowHeight = screen.h; + room._playFieldHeight = screen.h; + screen._vWindowLinesTall = screen.h; + screen._clipHeight = screen.h; + room._playFieldWidth = screen.w; + screen._vWindowWidth = screen.w; + screen._vWindowBytesWide = screen.w; + screen._clipWidth = screen.w; + + screen._windowXAdd = 0; + screen._windowYAdd = 0; + screen._screenYOff = 0; + screen._scrollX = screen._scrollY = 0; + screen._bufferStart.x = 0; + screen._bufferStart.y = 0; + + _vm->_buffer1.clearBuffer(); + _vm->_buffer2.clearBuffer(); + if (!_invRefreshFlag && !screen._vesaMode) + screen.clearBuffer(); + + screen.savePalette(); +} + +void InventoryManager::getList() { + _items.clear(); + for (uint i = 0; i < _inv.size(); ++i) { + if (_inv[i]) + _items.push_back(i); + } +} + +void InventoryManager::showAllItems() { + for (uint i = 0; i < _items.size(); ++i) + putInvIcon(i, _items[i]); +} + +void InventoryManager::putInvIcon(int itemIndex, int itemId) { + SpriteResource *spr = _vm->_objectsTable[99]; + assert(spr); + Common::Point pt((itemIndex % 6) * 46 + 23, (itemIndex / 6) * 35 + 15); + _vm->_buffer2.plotImage(spr, itemId, pt); + + if (_iconDisplayFlag) { + _vm->_buffer1.copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35)); + } +} + +void InventoryManager::chooseItem() { + _vm->_useItem = -1; + + error("TODO: chooseItem"); } +void InventoryManager::freeInvCells() { + delete _vm->_objectsTable[99]; + _vm->_objectsTable[99] = nullptr; +} } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index dddfe2eda1..019d7f4215 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -28,10 +28,51 @@ #include "common/rect.h" #include "common/str-array.h" #include "access/data.h" +#include "access/asurface.h" namespace Access { class InventoryManager : public Manager { + struct SavedFields { + int _vWindowHeight; + int _vWindowLinesTall; + int _vWindowWidth; + int _vWindowBytesWide; + int _playFieldHeight; + int _playFieldWidth; + int _windowXAdd; + int _windowYAdd; + int _screenYOff; + int _scrollX; + int _scrollY; + int _clipWidth; + int _clipHeight; + Common::Point _bufferStart; + int _scrollCol; + int _scrollRow; + }; +private: + Common::Array _items; + ASurface _savedBuffer1; + ASurface _savedScreen; + SavedFields _fields; + bool _iconDisplayFlag; + + void savedFields(); + + void restoreFields(); + + void initFields(); + + void getList(); + + void showAllItems(); + + void putInvIcon(int itemIndex, int itemId); + + void chooseItem(); + + void freeInvCells(); public: Common::Array _inv; Common::StringArray _names; diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index f0d74ccd2a..e5a27a8ba1 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -89,4 +89,33 @@ const char *const GENERAL_MESSAGES[] = { GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE }; +const int INVCOORDS[][4] = { + { 23, 68, 15, 49 }, + { 69, 114, 15, 49 }, + { 115, 160, 15, 49 }, + { 161, 206, 15, 49 }, + { 207, 252, 15, 49 }, + { 253, 298, 15, 49 }, + { 23, 68, 50, 84 }, + { 69, 114, 50, 84 }, + { 115, 160, 50, 84 }, + { 161, 206, 50, 84 }, + { 207, 252, 50, 84 }, + { 253, 298, 50, 84 }, + { 23, 68, 85, 119 }, + { 69, 114, 85, 119 }, + { 115, 160, 85, 119 }, + { 161, 206, 85, 119 }, + { 207, 252, 85, 119 }, + { 253, 298, 85, 119 }, + { 23, 68, 120, 154 }, + { 69, 114, 120, 154 }, + { 115, 160, 120, 154 }, + { 161, 206, 120, 154 }, + { 207, 252, 120, 154 }, + { 253, 298, 120, 154 }, + { 237, 298, 177, 193 }, + { 25, 85, 177, 193 } +}; + } // End of namespace Access diff --git a/engines/access/resources.h b/engines/access/resources.h index 241ed3a636..6fb781e0d1 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -58,6 +58,8 @@ extern const int RMOUSE[10][2]; extern const char *const GENERAL_MESSAGES[]; +extern const int INVCOORDS[][4]; + } // End of namespace Access #endif /* ACCESS_RESOURCES_H */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 90ef3470db..a4be02d263 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -451,34 +451,28 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - _vm->_events->_normalMouse = CURSOR_LOOK; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_LOOK); break; case 2: - _vm->_events->_normalMouse = CURSOR_USE; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_USE); break; case 3: - _vm->_events->_normalMouse = CURSOR_TAKE; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_TAKE); break; case 4: - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; } else { - warning("TODO: al = _useItem"); + // TODO: al = _useItem? } break; case 5: - _vm->_events->_normalMouse = CURSOR_CLIMB; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_CLIMB); break; case 6: - _vm->_events->_normalMouse = CURSOR_TALK; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_TALK); break; case 7: _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; @@ -486,8 +480,7 @@ void Room::executeCommand(int commandId) { _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_CROSSHAIRS); _conFlag = true; while (_conFlag && !_vm->shouldQuit()) { @@ -497,8 +490,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->_normalMouse = CURSOR_HELP; - _vm->_events->_mouseMode = 0; + _vm->_events->setCursor(CURSOR_HELP); break; default: break; @@ -524,8 +516,7 @@ void Room::executeCommand(int commandId) { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->_mouseMode = 4; + _vm->_events->setCursor(CURSOR_CROSSHAIRS); roomMenu(); } diff --git a/engines/access/room.h b/engines/access/room.h index d876a30875..6cd3b8cad0 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -76,7 +76,6 @@ private: protected: void loadRoomData(const byte *roomData); void setupRoom(); - void buildScreen(); /** * Free the playfield data @@ -141,8 +140,19 @@ public: */ void clearRoom(); + /** + * Builds up a game screen + */ + void buildScreen(); + + /** + * Draw a column of a game scene + */ void buildColumn(int playX, int screenX); + /** + * Draw a row of a game scene + */ void buildRow(int playY, int screenY); void init4Quads(); -- cgit v1.2.3 From 7b1d0064fe3718142af2d764699d705cd2258669 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Aug 2014 11:02:14 +0200 Subject: ACCESS: Fix the loading of text in doEstablish --- engines/access/access.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index e90e5bad22..0db3376697 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -289,11 +289,16 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { loadEstablish(sub); _et = sub; warning("CHECKME: Use of di"); + Common::String msg; + int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2); + for (int i = idx; _eseg[i] != 0; ++i) + msg += _eseg[i]; + _printEnd = 155; if (_txtPages == 0) - warning("TODO: printText();"); + warning("TODO: printText(%s)", msg.c_str()); else - warning("TODO: speakText();"); + warning("TODO: speakText(%s)", msg.c_str()); _screen->forceFadeOut(); _screen->clearScreen(); -- cgit v1.2.3 From 1073646c8e20940ec606edac06ffd3e2eb015f49 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 12:18:41 -0400 Subject: ACCESS: Fix negative seek in cmdSetVideoSound --- engines/access/scripts.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2a834f8855..37d1d50899 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -660,12 +660,14 @@ void Scripts::cmdLoadSound() { void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } -void Scripts::cmdSetVideoSound() { +void Scripts::cmdSetVideoSound() { + uint32 startPos = _data->pos(); _data->skip(4); cmdLoadSound(); - _data->skip(-6); + _data->seek(startPos); cmdSetVideo(); + _data->skip(2); _vm->_sound->_soundFrame = _data->readUint16LE(); _vm->_sound->_soundFlag = false; } -- cgit v1.2.3 From 89a3c43da1318644b14531b69ed1b38708a6413a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 12:32:11 -0400 Subject: ACCESS: More work on inventory screen setup --- engines/access/asurface.cpp | 3 +++ engines/access/files.cpp | 8 ++++++-- engines/access/files.h | 6 ++++++ engines/access/inventory.cpp | 40 +++++++++++++++++++++++++++++++++++++--- engines/access/inventory.h | 3 +++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index ce977f6d83..0db44c4934 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -208,6 +208,9 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { + if (dest->getPixels() == nullptr) + dest->create(w, h); + for (int yp = 0; yp < h; ++yp) { byte *srcP = (byte *)getBasePtr(0, yp); byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp); diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 230d2a8715..5cf467077d 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -104,17 +104,21 @@ void FileManager::openFile(const Common::String &filename) { _filesize = _file.size(); } -void FileManager::loadScreen(int fileNum, int subfile) { +void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) { setAppended(fileNum); gotoAppended(subfile); _vm->_screen->loadPalette(_stream); // Get the data for the screen, and copy it over byte *pSrc = handleFile(); - Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); + Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels()); delete[] pSrc; } +void FileManager::loadScreen(int fileNum, int subfile) { + loadScreen(_vm->_screen, fileNum, subfile); +} + void FileManager::loadScreen(const Common::String &filename) { // Open the file openFile(filename); diff --git a/engines/access/files.h b/engines/access/files.h index d1a4d5aafd..b13a796925 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/file.h" +#include "graphics/surface.h" #include "access/decompress.h" namespace Access { @@ -96,6 +97,11 @@ public: */ void loadScreen(const Common::String &filename); + /** + * Load a screen resource onto a designated surface + */ + void loadScreen(Graphics::Surface *dest, int fileNum, int subfile); + /** * Open up a sub-file container file */ diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 6c56f6b90b..80336e4dcc 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -54,6 +54,11 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { for (uint i = 0; i < _inv.size(); ++i) _names.push_back(names[i]); + + for (uint i = 0; i < 26; ++i) { + const int *r = INVCOORDS[i]; + _invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3])); + } } int &InventoryManager::operator[](int idx) { @@ -95,7 +100,7 @@ int InventoryManager::newDisplayInv() { getList(); initFields(); - files.loadScreen(99, 0); + _vm->_files->loadScreen(&_vm->_buffer1, 99, 0); _vm->_buffer1.copyTo(&_vm->_buffer2); _vm->copyBF2Vid(); @@ -267,9 +272,26 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) { } void InventoryManager::chooseItem() { + EventsManager &events = *_vm->_events; _vm->_useItem = -1; - - error("TODO: chooseItem"); + int selIndex; + + while (!_vm->shouldQuit()) { + g_system->delayMillis(10); + + // Poll events and wait for a click on a known area + events.pollEvents(); + if (!events._leftButton || ((selIndex = coordIndexOf()) == -1)) + continue; + + if (selIndex > 23) { + if (selIndex == 25) + _vm->_useItem = -1; + break; + } else if (selIndex < (int)_items.size()) { + warning("TODO: Combine items"); + } + } } void InventoryManager::freeInvCells() { @@ -277,4 +299,16 @@ void InventoryManager::freeInvCells() { _vm->_objectsTable[99] = nullptr; } +int InventoryManager::coordIndexOf() { + const Common::Point pt = _vm->_events->_mousePos; + + for (int i = 0; i < (int)_invCoords.size(); ++i) { + if (_invCoords[i].contains(pt)) + return i; + } + + return -1; +} + + } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 019d7f4215..cf8167d76c 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -53,6 +53,7 @@ class InventoryManager : public Manager { }; private: Common::Array _items; + Common::Array _invCoords; ASurface _savedBuffer1; ASurface _savedScreen; SavedFields _fields; @@ -73,6 +74,8 @@ private: void chooseItem(); void freeInvCells(); + + int coordIndexOf(); public: Common::Array _inv; Common::StringArray _names; -- cgit v1.2.3 From 6774dd42467265e4083fd7f97447d7ce2f437529 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 24 Aug 2014 18:49:34 +0200 Subject: ACCESS: Implement speakText() --- engines/access/access.cpp | 91 +++++++++++++++++++++++++++++++++++++++++++--- engines/access/access.h | 2 + engines/access/scripts.cpp | 2 +- engines/access/scripts.h | 3 +- engines/access/sound.h | 3 +- 5 files changed, 92 insertions(+), 9 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 0db3376697..9cddd1ba46 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -264,6 +264,90 @@ void AccessEngine::loadEstablish(int sub) { _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); } +void AccessEngine::speakText(int idx) { + int curPage = 0; + int soundsLeft = 0; + + Common::String msg; + for (int i = idx; _eseg[i] != 0; ++i) + msg += _eseg[i]; + + while(true) { + soundsLeft = _countTbl[curPage]; + _events->zeroKeys(); + + Common::String line; + int width = 0; + bool lastLine = _fonts._font2.getLine(msg, _bubbleBox->_maxChars * 6, line, width); + // Set font colors + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 28; + _fonts._font2._fontColors[2] = 29; + _fonts._font2._fontColors[3] = 30; + + _fonts._font2.drawString(_screen, line, _fonts._printOrg); + _fonts._printOrg = Common::Point(_fonts._printStart.x, _fonts._printOrg.y + 9); + + if ((_fonts._printOrg.y > _printEnd) && (!lastLine)) { + while (true) { + _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundPriority[0] = 1; + _sound->playSound(1); + _scripts->CMDFREESOUND(); + + _events->pollEvents(); + + if (_events->_leftButton) { + _events->debounceLeft(); + _sndSubFile += soundsLeft; + break; + } else if (_events->_keypresses.size() != 0) { + _sndSubFile += soundsLeft; + break; + } else { + ++_sndSubFile; + --soundsLeft; + if (soundsLeft == 0) + break; + } + } + _buffer2.copyBuffer(_screen); + _fonts._printOrg.y = _fonts._printStart.y; + ++curPage; + soundsLeft = _countTbl[curPage]; + } + + if (lastLine) + break; + } + + if (soundsLeft == 0) + return; + + while(true) { + _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundPriority[0] = 1; + _sound->playSound(1); + _scripts->CMDFREESOUND(); + + _events->pollEvents(); + + if (_events->_leftButton) { + _events->debounceLeft(); + _sndSubFile += soundsLeft; + break; + } else if (_events->_keypresses.size() != 0) { + _sndSubFile += soundsLeft; + break; + } else { + ++_sndSubFile; + --soundsLeft; + if (soundsLeft == 0) + break; + } + } +} + void AccessEngine::doEstablish(int esatabIndex, int sub) { _establishMode = 1; @@ -289,16 +373,13 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { loadEstablish(sub); _et = sub; warning("CHECKME: Use of di"); - Common::String msg; int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2); - for (int i = idx; _eseg[i] != 0; ++i) - msg += _eseg[i]; _printEnd = 155; if (_txtPages == 0) - warning("TODO: printText(%s)", msg.c_str()); + warning("TODO: printText()"); else - warning("TODO: speakText(%s)", msg.c_str()); + speakText(idx); _screen->forceFadeOut(); _screen->clearScreen(); diff --git a/engines/access/access.h b/engines/access/access.h index db969357aa..bd1269f3f9 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -91,6 +91,8 @@ private: void dummyLoop(); + void speakText(int idx); + void doEstablish(int esatabIndex, int sub); protected: const AccessGameDescription *_gameDescription; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 37d1d50899..6ee8eb0da5 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -658,7 +658,7 @@ void Scripts::cmdLoadSound() { _vm->_sound->_soundPriority[0] = 1; } -void Scripts::CMDFREESOUND() { error("TODO CMDFREESOUND"); } +void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); } void Scripts::cmdSetVideoSound() { uint32 startPos = _data->pos(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 93cd495be6..aa5c4063f6 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -113,7 +113,6 @@ protected: void cmdReturnChoice(); void cmdClearBlock(); void cmdLoadSound(); - void CMDFREESOUND(); void cmdSetVideoSound(); void CMDPLAYVIDSND(); void CMDPUSHLOCATION(); @@ -144,6 +143,8 @@ public: int executeScript(); void findNull(); + + void CMDFREESOUND(); }; } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index cb73bae52c..e0992db0e2 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -42,8 +42,6 @@ private: Audio::Mixer *_mixer; Audio::SoundHandle _soundHandle; - byte *loadSound(int fileNum, int subfile); - void playSound(byte *data, uint32 size); public: SoundEntry _soundTable[MAX_SOUNDS]; @@ -61,6 +59,7 @@ public: void playSound(int soundIndex); + byte *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); void midiPlay(); -- cgit v1.2.3 From e53417f91a1305cfb69ef57dd97a5f8fe5311eee Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 14:42:26 -0400 Subject: ACCESS: Fix loading of inventory screen background --- engines/access/files.cpp | 14 +++++++++++++- engines/access/inventory.cpp | 16 ++++++++++++---- engines/access/inventory.h | 4 ++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 5cf467077d..b1d6140e3e 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -111,7 +111,19 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) // Get the data for the screen, and copy it over byte *pSrc = handleFile(); - Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels()); + + if (dest != _vm->_screen) + dest->w = _vm->_screen->w; + + if (dest->w == dest->pitch) { + Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels()); + } else { + byte *pCurr = pSrc; + for (int y = 0; y < dest->h; ++y, pCurr += dest->w) { + byte *pDest = (byte *)dest->getBasePtr(0, y); + Common::copy(pCurr, pCurr + dest->w, pDest); + } + } delete[] pSrc; } diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 80336e4dcc..1bafdf56c3 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -90,8 +90,7 @@ int InventoryManager::newDisplayInv() { _vm->_timers.saveTimers(); if (room._tile && !_invRefreshFlag) { - _vm->_buffer1.copyTo(&_savedBuffer1); - screen.copyTo(&_savedScreen); + saveScreens(); } savedFields(); @@ -144,8 +143,7 @@ int InventoryManager::newDisplayInv() { } if (!room._tile && !_invRefreshFlag) { - _savedBuffer1.copyTo(&_vm->_buffer1); - _savedScreen.copyTo(_vm->_screen); + restoreScreens(); } else { screen.setBufferScan(); room.buildScreen(); @@ -310,5 +308,15 @@ int InventoryManager::coordIndexOf() { return -1; } +void InventoryManager::saveScreens() { + _vm->_buffer1.copyTo(&_savedBuffer1); + _vm->_screen->copyTo(&_savedScreen); +} + +void InventoryManager::restoreScreens() { + _vm->_buffer1.w = _vm->_buffer1.pitch; + _savedBuffer1.copyTo(&_vm->_buffer1); + _savedScreen.copyTo(_vm->_screen); +} } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index cf8167d76c..255b6dce40 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -76,6 +76,10 @@ private: void freeInvCells(); int coordIndexOf(); + + void saveScreens(); + + void restoreScreens(); public: Common::Array _inv; Common::StringArray _names; -- cgit v1.2.3 From ce97ba5587daecd262f44cd240efb23f6bd24e8b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 16:49:57 -0400 Subject: ACCeSS: Fix display of items in inventory screen --- engines/access/inventory.cpp | 43 +++++++++++++++++++++++++++++++++++++------ engines/access/inventory.h | 9 ++++++++- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 1bafdf56c3..f4236cc385 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -36,7 +36,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _invModeFlag = false; _startAboutItem = 0; _startTravelItem = 0; - _iconDisplayFlag = false; + _iconDisplayFlag = true; const char *const *names; switch (vm->getGameID()) { @@ -57,7 +57,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { for (uint i = 0; i < 26; ++i) { const int *r = INVCOORDS[i]; - _invCoords.push_back(Common::Rect(r[0], r[1], r[0] + r[2], r[1] + r[3])); + _invCoords.push_back(Common::Rect(r[0], r[2], r[1], r[3])); } } @@ -99,7 +99,7 @@ int InventoryManager::newDisplayInv() { getList(); initFields(); - _vm->_files->loadScreen(&_vm->_buffer1, 99, 0); + files.loadScreen(&_vm->_buffer1, 99, 0); _vm->_buffer1.copyTo(&_vm->_buffer2); _vm->copyBF2Vid(); @@ -247,9 +247,13 @@ void InventoryManager::initFields() { void InventoryManager::getList() { _items.clear(); + _tempLOff.clear(); + for (uint i = 0; i < _inv.size(); ++i) { - if (_inv[i]) + if (_inv[i]) { _items.push_back(i); + _tempLOff.push_back(_names[i]); + } } } @@ -265,7 +269,7 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) { _vm->_buffer2.plotImage(spr, itemId, pt); if (_iconDisplayFlag) { - _vm->_buffer1.copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35)); + _vm->_screen->copyBlock(&_vm->_buffer2, Common::Rect(pt.x, pt.y, pt.x + 46, pt.y + 35)); } } @@ -287,7 +291,12 @@ void InventoryManager::chooseItem() { _vm->_useItem = -1; break; } else if (selIndex < (int)_items.size()) { - warning("TODO: Combine items"); + _boxNum = selIndex; + _vm->copyBF2Vid(); + combineItems(); + _vm->copyBF2Vid(); + outlineIcon(_boxNum); + _vm->_useItem = _items[_boxNum]; } } } @@ -311,6 +320,8 @@ int InventoryManager::coordIndexOf() { void InventoryManager::saveScreens() { _vm->_buffer1.copyTo(&_savedBuffer1); _vm->_screen->copyTo(&_savedScreen); + _vm->_newRects.push_back(Common::Rect(0, 0, _savedScreen.w, _savedScreen.h)); + } void InventoryManager::restoreScreens() { @@ -319,4 +330,24 @@ void InventoryManager::restoreScreens() { _savedScreen.copyTo(_vm->_screen); } +void InventoryManager::outlineIcon(int itemIndex) { + Screen &screen = *_vm->_screen; + screen.frameRect(_invCoords[itemIndex], 7); + + Common::String s = _tempLOff[itemIndex]; + Font &font = _vm->_fonts._font2; + int strWidth = font.stringWidth(s); + + font._fontColors[0] = 0; + font._fontColors[1] = 10; + font._fontColors[2] = 11; + font._fontColors[3] = 12; + font.drawString(&screen, s, Common::Point((screen.w - strWidth) / 2, 184)); +} + +void InventoryManager::combineItems() { + warning("TODO: combineItems"); +} + + } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 255b6dce40..a95581c2d0 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -58,6 +58,10 @@ private: ASurface _savedScreen; SavedFields _fields; bool _iconDisplayFlag; + Common::StringArray _names; + Common::Array _tempLPtr; + Common::StringArray _tempLOff; + int _boxNum; void savedFields(); @@ -80,9 +84,12 @@ private: void saveScreens(); void restoreScreens(); + + void outlineIcon(int itemIndex); + + void combineItems(); public: Common::Array _inv; - Common::StringArray _names; int _startInvItem; int _startInvBox; bool _invChangeFlag; -- cgit v1.2.3 From 3e14e7b9663130d1a730aaf6821c766b505ebdba Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 17:31:41 -0400 Subject: ACCESS: Fix selection of inventory items --- engines/access/inventory.cpp | 5 +++++ engines/access/room.cpp | 24 +++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index f4236cc385..dbc3cbac89 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -165,6 +165,11 @@ int InventoryManager::newDisplayInv() { if (!_invRefreshFlag) { if (_vm->_useItem == -1) { result = 2; + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); + } else { + events.setCursor(CURSOR_INVENTORY); + events._normalMouse = CURSOR_INVENTORY; } } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a4be02d263..b00b1cf83b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -447,20 +447,24 @@ void Room::handleCommand(int commandId) { } void Room::executeCommand(int commandId) { + EventsManager &events = *_vm->_events; _selectCommand = commandId; switch (commandId) { case 0: - _vm->_events->setCursor(CURSOR_LOOK); + events._normalMouse = CURSOR_LOOK; + events.setCursor(CURSOR_LOOK); break; case 2: - _vm->_events->setCursor(CURSOR_USE); + events._normalMouse = CURSOR_USE; + events.setCursor(CURSOR_USE); break; case 3: - _vm->_events->setCursor(CURSOR_TAKE); + events._normalMouse = CURSOR_TAKE; + events.setCursor(CURSOR_TAKE); break; case 4: - _vm->_events->setCursor(CURSOR_ARROW); + events.setCursor(CURSOR_ARROW); if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; @@ -469,18 +473,20 @@ void Room::executeCommand(int commandId) { } break; case 5: - _vm->_events->setCursor(CURSOR_CLIMB); + events._normalMouse = CURSOR_CLIMB; + events.setCursor(CURSOR_CLIMB); break; case 6: - _vm->_events->setCursor(CURSOR_TALK); + events._normalMouse = CURSOR_TALK; + events.setCursor(CURSOR_TALK); break; case 7: - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); _selectCommand = -1; - _vm->_events->setCursor(CURSOR_CROSSHAIRS); _conFlag = true; while (_conFlag && !_vm->shouldQuit()) { @@ -490,7 +496,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; break; case 8: - _vm->_events->setCursor(CURSOR_HELP); + events.setCursor(CURSOR_HELP); break; default: break; -- cgit v1.2.3 From d97cc677e106c39af278e6175d139d8a8ab0cc3e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 21:05:35 -0400 Subject: ACCESS: Fix mapping of _useItem onto flags array --- engines/access/access.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9cddd1ba46..cea5a73818 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -31,7 +31,7 @@ namespace Access { AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : _gameDescription(gameDesc), Engine(syst), _randomSource("Access"), - _useItem(_flags[100]), _startup(_flags[170]), _manScaleOff(_flags[172]) { + _useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; _bubbleBox = nullptr; _char = nullptr; -- cgit v1.2.3 From b7ea1133b43f3640f44dc3e5f3a3136f72729770 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 21:42:02 -0400 Subject: ACCESS: Set hotspot for inventory item cursors to be their center --- engines/access/events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 15c8f8cff0..7366905b0c 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -56,7 +56,7 @@ void EventsManager::setCursor(CursorType cursorId) { if (cursorId == CURSOR_INVENTORY) { // Set the cursor CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h, - 0, 0, 0); + _invCursor.w / 2, _invCursor.h / 2, 0); } else { // Get a pointer to the mouse data to use, and get the cursor hotspot const byte *srcP = Amazon::CURSORS[cursorId]; -- cgit v1.2.3 From f993c8dd46c240daa7022f359542e743d9c7a888 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 22:42:24 -0400 Subject: ACCESS: Improved right scrolling --- engines/access/player.cpp | 2 +- engines/access/room.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 7df277c3a0..336be0d462 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -819,7 +819,7 @@ bool Player::scrollRight() { _vm->_buffer1.moveBufferRight(); _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); - } while (!_vm->shouldQuit() && (_vm->_screen->_scrollX >= 0)); + } while (!_vm->shouldQuit() && (_vm->_screen->_scrollX < 0)); return false; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b00b1cf83b..29d9eef624 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -468,8 +468,6 @@ void Room::executeCommand(int commandId) { if (_vm->_inventory->newDisplayInv() == 2) { commandOff(); return; - } else { - // TODO: al = _useItem? } break; case 5: -- cgit v1.2.3 From 89993e128fe15efd16fdf89696682f0e24cb8593 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Aug 2014 23:59:37 -0400 Subject: ACCESS: Split font code into a separate file --- engines/access/access.h | 1 + engines/access/data.cpp | 144 ---------------------------------------- engines/access/data.h | 68 ------------------- engines/access/font.cpp | 169 +++++++++++++++++++++++++++++++++++++++++++++++ engines/access/font.h | 104 +++++++++++++++++++++++++++++ engines/access/module.mk | 1 + 6 files changed, 275 insertions(+), 212 deletions(-) create mode 100644 engines/access/font.cpp create mode 100644 engines/access/font.h diff --git a/engines/access/access.h b/engines/access/access.h index bd1269f3f9..2aa41308c3 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -37,6 +37,7 @@ #include "access/debugger.h" #include "access/events.h" #include "access/files.h" +#include "access/font.h" #include "access/inventory.h" #include "access/player.h" #include "access/room.h" diff --git a/engines/access/data.cpp b/engines/access/data.cpp index a13c6d9a67..0279cd5052 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -59,148 +59,4 @@ void TimerList::updateTimers() { } } -/*------------------------------------------------------------------------*/ - -byte Font::_fontColors[4]; - -Font::Font() { -} - -Font::~Font() { - for (uint i = 0; i < _chars.size(); ++i) - _chars[i].free(); -} - -void Font::load(const int *fontIndex, const byte *fontData) { - assert(_chars.size() == 0); - int count = fontIndex[0]; - _bitWidth = fontIndex[1]; - _height = fontIndex[2]; - - _chars.resize(count); - - for (int i = 0; i < count; ++i) { - const byte *pData = fontData + fontIndex[i + 3]; - _chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8()); - - for (int y = 0; y < _height; ++y) { - int bitsLeft = 0; - byte srcByte = 0; - byte pixel; - - byte *pDest = (byte *)_chars[i].getBasePtr(0, y); - for (int x = 0; x < _chars[i].w; ++x, ++pDest) { - // Get the pixel - pixel = 0; - for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) { - // No bits in current byte left, so get next byte - if (bitsLeft == 0) { - bitsLeft = 8; - srcByte = *pData++; - } - - pixel = (pixel << 1) | (srcByte >> 7); - srcByte <<= 1; - } - - // Write out the pixel - *pDest = pixel; - } - } - } -} - -int Font::charWidth(char c) { - return _chars[c - ' '].w; -} - -int Font::stringWidth(const Common::String &msg) { - int total = 0; - - for (const char *c = msg.c_str(); *c != '\0'; ++c) - total += charWidth(*c); - - return total; -} - -bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) { - assert(maxWidth > 0); - width = 0; - const char *src = s.c_str(); - char c; - - while ((c = *src) != '\0') { - if (c == '\r') { - // End of line, so return calculated line - line = Common::String(s.c_str(), src - 1); - s = Common::String(src + 1); - return false; - } - - ++src; - width += charWidth(c); - if (width < maxWidth) - continue; - - // Reached maximum allowed size - // If this was the last character of the string, let it go - if (*src == '\0') - break; - - // Work backwards to find space at the start of the current word - // as a point to split the line on - while (src >= s.c_str() && *src != ' ') { - width -= charWidth(*src); - --src; - } - if (src < s.c_str()) - error("Could not fit line"); - - // Split the line around the space - line = Common::String(s.c_str(), src); - s = Common::String(src + 1); - return false; - } - - // Return entire string - line = s; - s = Common::String(); - return true; -} - -void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) { - Common::Point currPt = pt; - const char *msgP = msg.c_str(); - - while (*msgP) { - currPt.x += drawChar(s, *msgP, currPt); - ++msgP; - } -} - -int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) { - Graphics::Surface &ch = _chars[c - ' ']; - - // Loop through the lines of the character - for (int y = 0; y < ch.h; ++y) { - byte *pSrc = (byte *)ch.getBasePtr(0, y); - byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y); - - // Loop through the horizontal pixels of the line - for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) { - if (*pSrc != 0) - *pDest = _fontColors[*pSrc]; - } - } - - return ch.w; -} - -/*------------------------------------------------------------------------*/ - -FontManager::FontManager() { - _printMaxX = 0; - Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0); -} - } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 3238dafa33..1d64a6ff86 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -82,74 +82,6 @@ public: FileIdent _vidSound; }; -struct FontVal { -public: - int _lo, _hi; - - FontVal() { _lo = _hi = 0; } -}; - -class Font { -private: - int _bitWidth; - int _height; - Common::Array _chars; -public: - static byte _fontColors[4]; -public: - Font(); - - ~Font(); - - /** - * Load the given font data - */ - void load(const int *fontIndex, const byte *fontData); - - /** - * Get the width of a given character - */ - int charWidth(char c); - - /** - * Get the width of a given string - */ - int stringWidth(const Common::String &msg); - - /** - * Get a partial string that will fit in a given width - * @param s Source string. Modified to remove line - * @param maxWidth Maximum width allowed - * @param line Output line - * @param width Calculated width of returned line - * @returns True if last line - */ - bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width); - - /** - * Draw a string on a given surface - */ - void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt); - - /** - * Draw a character on a given surface - */ - int drawChar(Graphics::Surface *s, char c, Common::Point &pt); -}; - -class FontManager { -public: - FontVal _charSet; - FontVal _charFor; - Common::Point _printOrg; - Common::Point _printStart; - int _printMaxX; - Font _font1; - Font _font2; -public: - FontManager(); -}; - } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/font.cpp b/engines/access/font.cpp new file mode 100644 index 0000000000..d5ad3b3d24 --- /dev/null +++ b/engines/access/font.cpp @@ -0,0 +1,169 @@ +/* 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 "access/font.h" + +namespace Access { + +byte Font::_fontColors[4]; + +Font::Font() { +} + +Font::~Font() { + for (uint i = 0; i < _chars.size(); ++i) + _chars[i].free(); +} + +void Font::load(const int *fontIndex, const byte *fontData) { + assert(_chars.size() == 0); + int count = fontIndex[0]; + _bitWidth = fontIndex[1]; + _height = fontIndex[2]; + + _chars.resize(count); + + for (int i = 0; i < count; ++i) { + const byte *pData = fontData + fontIndex[i + 3]; + _chars[i].create(*pData++, _height, Graphics::PixelFormat::createFormatCLUT8()); + + for (int y = 0; y < _height; ++y) { + int bitsLeft = 0; + byte srcByte = 0; + byte pixel; + + byte *pDest = (byte *)_chars[i].getBasePtr(0, y); + for (int x = 0; x < _chars[i].w; ++x, ++pDest) { + // Get the pixel + pixel = 0; + for (int pixelCtr = 0; pixelCtr < _bitWidth; ++pixelCtr, --bitsLeft) { + // No bits in current byte left, so get next byte + if (bitsLeft == 0) { + bitsLeft = 8; + srcByte = *pData++; + } + + pixel = (pixel << 1) | (srcByte >> 7); + srcByte <<= 1; + } + + // Write out the pixel + *pDest = pixel; + } + } + } +} + +int Font::charWidth(char c) { + return _chars[c - ' '].w; +} + +int Font::stringWidth(const Common::String &msg) { + int total = 0; + + for (const char *c = msg.c_str(); *c != '\0'; ++c) + total += charWidth(*c); + + return total; +} + +bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &width) { + assert(maxWidth > 0); + width = 0; + const char *src = s.c_str(); + char c; + + while ((c = *src) != '\0') { + if (c == '\r') { + // End of line, so return calculated line + line = Common::String(s.c_str(), src - 1); + s = Common::String(src + 1); + return false; + } + + ++src; + width += charWidth(c); + if (width < maxWidth) + continue; + + // Reached maximum allowed size + // If this was the last character of the string, let it go + if (*src == '\0') + break; + + // Work backwards to find space at the start of the current word + // as a point to split the line on + while (src >= s.c_str() && *src != ' ') { + width -= charWidth(*src); + --src; + } + if (src < s.c_str()) + error("Could not fit line"); + + // Split the line around the space + line = Common::String(s.c_str(), src); + s = Common::String(src + 1); + return false; + } + + // Return entire string + line = s; + s = Common::String(); + return true; +} + +void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) { + Common::Point currPt = pt; + const char *msgP = msg.c_str(); + + while (*msgP) { + currPt.x += drawChar(s, *msgP, currPt); + ++msgP; + } +} + +int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) { + Graphics::Surface &ch = _chars[c - ' ']; + + // Loop through the lines of the character + for (int y = 0; y < ch.h; ++y) { + byte *pSrc = (byte *)ch.getBasePtr(0, y); + byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y); + + // Loop through the horizontal pixels of the line + for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) { + if (*pSrc != 0) + *pDest = _fontColors[*pSrc]; + } + } + + return ch.w; +} + +/*------------------------------------------------------------------------*/ + +FontManager::FontManager() { + _printMaxX = 0; + Common::fill(&Font::_fontColors[0], &Font::_fontColors[4], 0); +} + +} // End of namespace Access diff --git a/engines/access/font.h b/engines/access/font.h new file mode 100644 index 0000000000..2c9ffd0f34 --- /dev/null +++ b/engines/access/font.h @@ -0,0 +1,104 @@ +/* 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 ACCESS_FONT_H +#define ACCESS_FONT_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/rect.h" +#include "access/asurface.h" +#include "access/data.h" + +namespace Access { + +struct FontVal { +public: + int _lo, _hi; + + FontVal() { _lo = _hi = 0; } +}; + +class Font { +private: + int _bitWidth; + int _height; + Common::Array _chars; +public: + static byte _fontColors[4]; +public: + Font(); + + ~Font(); + + /** + * Load the given font data + */ + void load(const int *fontIndex, const byte *fontData); + + /** + * Get the width of a given character + */ + int charWidth(char c); + + /** + * Get the width of a given string + */ + int stringWidth(const Common::String &msg); + + /** + * Get a partial string that will fit in a given width + * @param s Source string. Modified to remove line + * @param maxWidth Maximum width allowed + * @param line Output line + * @param width Calculated width of returned line + * @returns True if last line + */ + bool getLine(Common::String &s, int maxWidth, Common::String &line, int &width); + + /** + * Draw a string on a given surface + */ + void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt); + + /** + * Draw a character on a given surface + */ + int drawChar(Graphics::Surface *s, char c, Common::Point &pt); +}; + +class FontManager { +public: + FontVal _charSet; + FontVal _charFor; + Common::Point _printOrg; + Common::Point _printStart; + int _printMaxX; + Font _font1; + Font _font2; +public: + FontManager(); +}; + +} // End of namespace Access + +#endif /* ACCESS_FONT_H */ diff --git a/engines/access/module.mk b/engines/access/module.mk index e92c2cc564..b6e73b66bd 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -12,6 +12,7 @@ MODULE_OBJS := \ detection.o \ events.o \ files.o \ + font.o \ inventory.o \ player.o \ resources.o \ -- cgit v1.2.3 From 707a01cb38eb671f2fad29016f11268f8fab9084 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 25 Aug 2014 00:01:18 -0400 Subject: ACCESS: Change font method parameter types --- engines/access/font.cpp | 4 ++-- engines/access/font.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/access/font.cpp b/engines/access/font.cpp index d5ad3b3d24..75add4129c 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -131,7 +131,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w return true; } -void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt) { +void Font::drawString(ASurface *s, const Common::String &msg, const Common::Point &pt) { Common::Point currPt = pt; const char *msgP = msg.c_str(); @@ -141,7 +141,7 @@ void Font::drawString(Graphics::Surface *s, const Common::String &msg, const Com } } -int Font::drawChar(Graphics::Surface *s, char c, Common::Point &pt) { +int Font::drawChar(ASurface *s, char c, Common::Point &pt) { Graphics::Surface &ch = _chars[c - ' ']; // Loop through the lines of the character diff --git a/engines/access/font.h b/engines/access/font.h index 2c9ffd0f34..a32dd6b695 100644 --- a/engines/access/font.h +++ b/engines/access/font.h @@ -78,12 +78,12 @@ public: /** * Draw a string on a given surface */ - void drawString(Graphics::Surface *s, const Common::String &msg, const Common::Point &pt); + void drawString(ASurface *s, const Common::String &msg, const Common::Point &pt); /** * Draw a character on a given surface */ - int drawChar(Graphics::Surface *s, char c, Common::Point &pt); + int drawChar(ASurface *s, char c, Common::Point &pt); }; class FontManager { -- cgit v1.2.3 From 33cdeb7a4005408b92366ae34a29589e3b0fa0cb Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 25 Aug 2014 00:18:32 -0400 Subject: ACCESS: Stub for printText method --- engines/access/access.cpp | 22 ++++++++++++---------- engines/access/asurface.h | 3 +++ engines/access/bubble_box.cpp | 32 ++++++++++++++++---------------- engines/access/font.cpp | 4 ++++ engines/access/font.h | 7 +++++-- engines/access/scripts.cpp | 22 +++++++++++----------- 6 files changed, 51 insertions(+), 39 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cea5a73818..32a4e6cc8f 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -285,10 +285,10 @@ void AccessEngine::speakText(int idx) { _fonts._font2._fontColors[2] = 29; _fonts._font2._fontColors[3] = 30; - _fonts._font2.drawString(_screen, line, _fonts._printOrg); - _fonts._printOrg = Common::Point(_fonts._printStart.x, _fonts._printOrg.y + 9); + _fonts._font2.drawString(_screen, line, _screen->_printOrg); + _screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 9); - if ((_fonts._printOrg.y > _printEnd) && (!lastLine)) { + if ((_screen->_printOrg.y > _printEnd) && (!lastLine)) { while (true) { _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; @@ -312,7 +312,7 @@ void AccessEngine::speakText(int idx) { } } _buffer2.copyBuffer(_screen); - _fonts._printOrg.y = _fonts._printStart.y; + _screen->_printOrg.y = _screen->_printStart.y; ++curPage; soundsLeft = _countTbl[curPage]; } @@ -369,17 +369,19 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { _fonts._charFor._hi = 32; _bubbleBox->_maxChars = 37; - _fonts._printOrg = _fonts._printStart = Common::Point(48, 35); + _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(sub); _et = sub; warning("CHECKME: Use of di"); - int idx = READ_LE_UINT16(_eseg + (sub * 2) + 2); + uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2); + Common::String msg((const char *)_eseg + msgOffset); _printEnd = 155; - if (_txtPages == 0) - warning("TODO: printText()"); - else - speakText(idx); + if (_txtPages == 0) { + _fonts._font2.printText(_screen, msg); + } else { +// speakText(msg); + } _screen->forceFadeOut(); _screen->clearScreen(); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index f5e5f48e7b..262d41400a 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -52,6 +52,9 @@ public: static int _orgX2, _orgY2; static int _lColor; + Common::Point _printOrg; + Common::Point _printStart; + static void init(); public: virtual ~ASurface(); diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index a709fbd92d..56d7157e8d 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -74,8 +74,8 @@ void BubbleBox::placeBubble1(const Common::String &msg) { void BubbleBox::calcBubble(const Common::String &msg) { // Save points - Common::Point printOrg = _vm->_fonts._printOrg; - Common::Point printStart = _vm->_fonts._printStart; + Common::Point printOrg = _vm->_screen->_printOrg; + Common::Point printStart = _vm->_screen->_printStart; // Figure out maximum width allowed if (_type == TYPE_4) { @@ -96,12 +96,12 @@ void BubbleBox::calcBubble(const Common::String &msg) { lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width); _vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX); - _vm->_fonts._printOrg.y += 6; - _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + _vm->_screen->_printOrg.y += 6; + _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x; } while (!lastLine); if (_type == TYPE_4) - ++_vm->_fonts._printOrg.y += 6; + ++_vm->_screen->_printOrg.y += 6; // Determine the width for the area width = (((_vm->_fonts._printMaxX >> 4) + 1) << 4) + 5; @@ -110,7 +110,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { bounds.setWidth(width); // Determine the height for area - int y = _vm->_fonts._printOrg.y + 6; + int y = _vm->_screen->_printOrg.y + 6; if (_type == TYPE_4) y += 6; int height = y - bounds.top; @@ -124,8 +124,8 @@ void BubbleBox::calcBubble(const Common::String &msg) { _bubbles.push_back(bounds); // Restore points - _vm->_fonts._printOrg = printOrg; - _vm->_fonts._printStart = printStart; + _vm->_screen->_printOrg = printOrg; + _vm->_screen->_printStart = printStart; } void BubbleBox::printBubble(const Common::String &msg) { @@ -147,16 +147,16 @@ void BubbleBox::printBubble(const Common::String &msg) { font2._fontColors[2] = 28; font2._fontColors[3] = 29; - int xp = _vm->_fonts._printOrg.x; + int xp = _vm->_screen->_printOrg.x; if (_type == TYPE_4) xp = (_bounds.width() - width) / 2 + _bounds.left - 4; // Draw the text - font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_fonts._printOrg.y)); + font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_screen->_printOrg.y)); // Move print position - _vm->_fonts._printOrg.y += 6; - _vm->_fonts._printOrg.x = _vm->_fonts._printStart.x; + _vm->_screen->_printOrg.y += 6; + _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x; } while (!lastLine); } @@ -175,8 +175,8 @@ void BubbleBox::doBox(int item, int box) { // Save state information FontVal charSet = fonts._charSet; FontVal charFor = fonts._charFor; - Common::Point printOrg = fonts._printOrg; - Common::Point printStart = fonts._printStart; + Common::Point printOrg = screen._printOrg; + Common::Point printStart = screen._printStart; int charCol = _charCol; int rowOff = _rowOff; @@ -260,8 +260,8 @@ void BubbleBox::doBox(int item, int box) { // Restore positional state fonts._charSet = charSet; fonts._charFor = charFor; - fonts._printOrg = printOrg; - fonts._printStart = printStart; + screen._printOrg = printOrg; + screen._printStart = printStart; _charCol = charCol; _rowOff = rowOff; _vm->_screen->restoreScreen(); diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 75add4129c..ba17f19211 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -159,6 +159,10 @@ int Font::drawChar(ASurface *s, char c, Common::Point &pt) { return ch.w; } +void Font::printText(ASurface *s, const Common::String &msg) { + error("TODO: printText"); +} + /*------------------------------------------------------------------------*/ FontManager::FontManager() { diff --git a/engines/access/font.h b/engines/access/font.h index a32dd6b695..9285d323d1 100644 --- a/engines/access/font.h +++ b/engines/access/font.h @@ -84,14 +84,17 @@ public: * Draw a character on a given surface */ int drawChar(ASurface *s, char c, Common::Point &pt); + + /** + * Draw a string on a given surface and update text positioning + */ + void printText(ASurface *s, const Common::String &msg); }; class FontManager { public: FontVal _charSet; FontVal _charFor; - Common::Point _printOrg; - Common::Point _printStart; int _printMaxX; Font _font1; Font _font2; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6ee8eb0da5..d6f65a69c9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -185,8 +185,8 @@ void Scripts::cmdPrint() { } void Scripts::printString(const Common::String &msg) { - _vm->_fonts._printOrg = Common::Point(20, 42); - _vm->_fonts._printStart = Common::Point(20, 42); + _vm->_screen->_printOrg = Common::Point(20, 42); + _vm->_screen->_printStart = Common::Point(20, 42); _vm->_timers[PRINT_TIMER]._timer = 50; _vm->_timers[PRINT_TIMER]._initTm = 50; ++_vm->_timers[PRINT_TIMER]._flag; @@ -488,8 +488,8 @@ void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); } void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); } void Scripts::cmdCharSpeak() { - _vm->_fonts._printOrg = _charsOrg; - _vm->_fonts._printStart = _charsOrg; + _vm->_screen->_printOrg = _charsOrg; + _vm->_screen->_printStart = _charsOrg; byte v; Common::String tmpStr = ""; @@ -501,8 +501,8 @@ void Scripts::cmdCharSpeak() { } void Scripts::cmdTexSpeak() { - _vm->_fonts._printOrg = _texsOrg; - _vm->_fonts._printStart = _texsOrg; + _vm->_screen->_printOrg = _texsOrg; + _vm->_screen->_printStart = _texsOrg; _vm->_bubbleBox->_maxChars = 20; byte v; @@ -542,8 +542,8 @@ void Scripts::cmdTexChoice() { _vm->_fonts._charFor._hi = 255; _vm->_bubbleBox->_maxChars = 20; - _vm->_fonts._printOrg = _texsOrg; - _vm->_fonts._printStart = _texsOrg; + _vm->_screen->_printOrg = _texsOrg; + _vm->_screen->_printStart = _texsOrg; _vm->_bubbleBox->clearBubbles(); _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str(); @@ -559,7 +559,7 @@ void Scripts::cmdTexChoice() { Common::Rect responseCoords[2]; responseCoords[0] = _vm->_bubbleBox->_bounds; responseCoords[1] = Common::Rect(0, 0, 0, 0); - _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; findNull(); @@ -575,7 +575,7 @@ void Scripts::cmdTexChoice() { _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); responseCoords[1] = _vm->_bubbleBox->_bounds; - _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; } findNull(); @@ -590,7 +590,7 @@ void Scripts::cmdTexChoice() { _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); termResponse2 = _vm->_bubbleBox->_bounds; - _vm->_fonts._printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; + _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; } findNull(); -- cgit v1.2.3 From 8c059add8b25cbabd499fe9ef6e69da563a3b913 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Aug 2014 22:46:56 +0200 Subject: ACCESS: Modify speakText so it takes a string array as parameter --- engines/access/access.cpp | 20 ++++++++++---------- engines/access/access.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 32a4e6cc8f..97ffc134be 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -199,7 +199,6 @@ void AccessEngine::dummyLoop() { _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1)); } } - } int AccessEngine::getRandomNumber(int maxNumber) { @@ -264,21 +263,17 @@ void AccessEngine::loadEstablish(int sub) { _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); } -void AccessEngine::speakText(int idx) { +void AccessEngine::speakText(Common::Array msgArr) { int curPage = 0; int soundsLeft = 0; - Common::String msg; - for (int i = idx; _eseg[i] != 0; ++i) - msg += _eseg[i]; - while(true) { soundsLeft = _countTbl[curPage]; _events->zeroKeys(); Common::String line; int width = 0; - bool lastLine = _fonts._font2.getLine(msg, _bubbleBox->_maxChars * 6, line, width); + bool lastLine = _fonts._font2.getLine(msgArr[curPage], _bubbleBox->_maxChars * 6, line, width); // Set font colors _fonts._font2._fontColors[0] = 0; _fonts._font2._fontColors[1] = 28; @@ -372,15 +367,20 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(sub); _et = sub; - warning("CHECKME: Use of di"); uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2); - Common::String msg((const char *)_eseg + msgOffset); _printEnd = 155; if (_txtPages == 0) { + Common::String msg((const char *)_eseg + msgOffset); _fonts._font2.printText(_screen, msg); } else { -// speakText(msg); + Common::Array msgArr; + for (int i = 0; i < _txtPages; ++i) { + Common::String msg((const char *)_eseg + msgOffset); + msgOffset += msg.size() + 1; + msgArr.push_back(msg); + } + speakText(msgArr); } _screen->forceFadeOut(); diff --git a/engines/access/access.h b/engines/access/access.h index 2aa41308c3..70195d1e64 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -92,7 +92,7 @@ private: void dummyLoop(); - void speakText(int idx); + void speakText(Common::ArraymsgArr); void doEstablish(int esatabIndex, int sub); protected: -- cgit v1.2.3 From 7d0392aa83a44b075cedd8d669a61f26dcb82c3b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Aug 2014 23:34:40 +0200 Subject: ACCESS: Move _maxChars to asurface --- engines/access/access.cpp | 4 ++-- engines/access/asurface.h | 1 + engines/access/bubble_box.cpp | 8 +++----- engines/access/bubble_box.h | 1 - engines/access/scripts.cpp | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 97ffc134be..47d77e777c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -273,7 +273,7 @@ void AccessEngine::speakText(Common::Array msgArr) { Common::String line; int width = 0; - bool lastLine = _fonts._font2.getLine(msgArr[curPage], _bubbleBox->_maxChars * 6, line, width); + bool lastLine = _fonts._font2.getLine(msgArr[curPage], _screen->_maxChars * 6, line, width); // Set font colors _fonts._font2._fontColors[0] = 0; _fonts._font2._fontColors[1] = 28; @@ -363,7 +363,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { _fonts._charFor._lo = 29; _fonts._charFor._hi = 32; - _bubbleBox->_maxChars = 37; + _screen->_maxChars = 37; _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(sub); _et = sub; diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 262d41400a..5d1f6fd307 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -54,6 +54,7 @@ public: Common::Point _printOrg; Common::Point _printStart; + int _maxChars; static void init(); public: diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 56d7157e8d..d3782a3125 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -34,8 +34,6 @@ BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) { _fieldE = 0; _fieldF = 0; _field10 = 0; - - _maxChars = 0; } void BubbleBox::load(Common::SeekableReadStream *stream) { @@ -53,7 +51,7 @@ void BubbleBox::clearBubbles() { } void BubbleBox::placeBubble(const Common::String &msg) { - BubbleBox::_maxChars = 27; + _vm->_screen->_maxChars = 27; placeBubble1(msg); } @@ -93,7 +91,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { int width = 0; bool lastLine; do { - lastLine = _vm->_fonts._font2.getLine(s, _maxChars * 6, line, width); + lastLine = _vm->_fonts._font2.getLine(s, _vm->_screen->_maxChars * 6, line, width); _vm->_fonts._printMaxX = MAX(width, _vm->_fonts._printMaxX); _vm->_screen->_printOrg.y += 6; @@ -139,7 +137,7 @@ void BubbleBox::printBubble(const Common::String &msg) { do { // Get next line Font &font2 = _vm->_fonts._font2; - lastLine = font2.getLine(s, _maxChars * 6, line, width); + lastLine = font2.getLine(s, _vm->_screen->_maxChars * 6, line, width); // Set font colors font2._fontColors[0] = 0; diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 3ddb2f72e3..7b25a58183 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -54,7 +54,6 @@ public: int _fieldF; int _field10; - int _maxChars; Common::Array _bubbles; public: BubbleBox(AccessEngine *vm); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d6f65a69c9..833aff337a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -503,7 +503,7 @@ void Scripts::cmdCharSpeak() { void Scripts::cmdTexSpeak() { _vm->_screen->_printOrg = _texsOrg; _vm->_screen->_printStart = _texsOrg; - _vm->_bubbleBox->_maxChars = 20; + _vm->_screen->_maxChars = 20; byte v; Common::String tmpStr = ""; @@ -540,8 +540,8 @@ void Scripts::cmdTexChoice() { _vm->_fonts._charSet._hi = 8; _vm->_fonts._charFor._lo = 55; _vm->_fonts._charFor._hi = 255; - _vm->_bubbleBox->_maxChars = 20; + _vm->_screen->_maxChars = 20; _vm->_screen->_printOrg = _texsOrg; _vm->_screen->_printStart = _texsOrg; -- cgit v1.2.3 From a47b10c1c01d6ff332a11dfb61bef3e0bb8e2672 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 25 Aug 2014 23:44:55 +0200 Subject: ACCESS: Add destination surface in speakText parameters --- engines/access/access.cpp | 16 ++++++++-------- engines/access/access.h | 4 ++-- engines/access/asurface.cpp | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 47d77e777c..361b8b3577 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -263,7 +263,7 @@ void AccessEngine::loadEstablish(int sub) { _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); } -void AccessEngine::speakText(Common::Array msgArr) { +void AccessEngine::speakText(ASurface *s, Common::Array msgArr) { int curPage = 0; int soundsLeft = 0; @@ -273,17 +273,17 @@ void AccessEngine::speakText(Common::Array msgArr) { Common::String line; int width = 0; - bool lastLine = _fonts._font2.getLine(msgArr[curPage], _screen->_maxChars * 6, line, width); + bool lastLine = _fonts._font2.getLine(msgArr[curPage], s->_maxChars * 6, line, width); // Set font colors _fonts._font2._fontColors[0] = 0; _fonts._font2._fontColors[1] = 28; _fonts._font2._fontColors[2] = 29; _fonts._font2._fontColors[3] = 30; - _fonts._font2.drawString(_screen, line, _screen->_printOrg); - _screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 9); + _fonts._font2.drawString(s, line, s->_printOrg); + s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); - if ((_screen->_printOrg.y > _printEnd) && (!lastLine)) { + if ((s->_printOrg.y > _printEnd) && (!lastLine)) { while (true) { _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; @@ -306,8 +306,8 @@ void AccessEngine::speakText(Common::Array msgArr) { break; } } - _buffer2.copyBuffer(_screen); - _screen->_printOrg.y = _screen->_printStart.y; + _buffer2.copyBuffer(s); + s->_printOrg.y = s->_printStart.y; ++curPage; soundsLeft = _countTbl[curPage]; } @@ -380,7 +380,7 @@ void AccessEngine::doEstablish(int esatabIndex, int sub) { msgOffset += msg.size() + 1; msgArr.push_back(msg); } - speakText(msgArr); + speakText(_screen, msgArr); } _screen->forceFadeOut(); diff --git a/engines/access/access.h b/engines/access/access.h index 70195d1e64..fb73b1fb9b 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -81,7 +81,7 @@ private: uint32 _lastTime, _curTime; /** - * Handles basic initialisation + * Handles basic initialization */ void initialize(); @@ -92,7 +92,7 @@ private: void dummyLoop(); - void speakText(Common::ArraymsgArr); + void speakText(ASurface *s, Common::ArraymsgArr); void doEstablish(int esatabIndex, int sub); protected: diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 0db44c4934..cdf8b3dd3f 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -329,7 +329,6 @@ void ASurface::flipHorizontal(ASurface &dest) { } } - void ASurface::moveBufferLeft() { byte *p = (byte *)getPixels(); Common::copy(p + TILE_WIDTH, p + (w * h), p); -- cgit v1.2.3 From 1568b4a433f8efc0b4e670d8e9714885aa8831c0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 26 Aug 2014 23:55:17 +0200 Subject: ACCESS: Move Establish functions to Amazon engine, start implementing init4Quads --- engines/access/access.cpp | 87 ----------------------------------- engines/access/access.h | 14 ++---- engines/access/amazon/amazon_game.cpp | 86 ++++++++++++++++++++++++++++++++++ engines/access/amazon/amazon_game.h | 6 +++ engines/access/amazon/amazon_room.cpp | 12 +++++ engines/access/amazon/amazon_room.h | 3 ++ engines/access/martian/martian_game.h | 2 +- engines/access/martian/martian_room.h | 5 ++ engines/access/room.cpp | 4 -- engines/access/room.h | 2 +- engines/access/screen.cpp | 6 +++ engines/access/screen.h | 2 +- 12 files changed, 126 insertions(+), 103 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 361b8b3577..c19a37cdc3 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -225,44 +225,6 @@ void AccessEngine::freeInactiveData() { _inactive = nullptr; } -void AccessEngine::establish(int esatabIndex, int sub) { - _establishMode = 0; - _establishGroup = 0; - doEstablish(esatabIndex, sub); -} - -void AccessEngine::establishCenter(int esatabIndex, int sub) { - _establishMode = 1; - doEstablish(esatabIndex, sub); -} - -const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" }; - -void AccessEngine::loadEstablish(int sub) { - if (!_files->existFile("ETEXT.DAT")) { - int oldGroup = _establishGroup; - _establishGroup = 0; - - _eseg = _files->loadFile(_estTable[oldGroup]); - } else { - _eseg = _files->loadFile("ETEXT.DAT"); - } - - _establishCtrlTblOfs = READ_LE_UINT16(_eseg); - - int ofs = _establishCtrlTblOfs + (sub * 2); - int idx = READ_LE_UINT16(_eseg + ofs); - _narateFile = READ_LE_UINT16(_eseg + idx); - _txtPages = READ_LE_UINT16(_eseg + idx + 2); - - if (!_txtPages) - return; - - _sndSubFile = READ_LE_UINT16(_eseg + idx + 4); - for (int i = 0; i < _txtPages; ++i) - _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); -} - void AccessEngine::speakText(ASurface *s, Common::Array msgArr) { int curPage = 0; int soundsLeft = 0; @@ -343,55 +305,6 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) } } -void AccessEngine::doEstablish(int esatabIndex, int sub) { - _establishMode = 1; - - _screen->forceFadeOut(); - _screen->clearScreen(); - _screen->setPanel(3); - - if (esatabIndex != -1) { - _files->loadScreen(95, esatabIndex); - _buffer2.copyBuffer(_screen); - } - - _screen->setIconPalette(); - _screen->forceFadeIn(); - - _fonts._charSet._lo = 1; - _fonts._charSet._hi = 10; - _fonts._charFor._lo = 29; - _fonts._charFor._hi = 32; - - _screen->_maxChars = 37; - _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); - loadEstablish(sub); - _et = sub; - uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2); - - _printEnd = 155; - if (_txtPages == 0) { - Common::String msg((const char *)_eseg + msgOffset); - _fonts._font2.printText(_screen, msg); - } else { - Common::Array msgArr; - for (int i = 0; i < _txtPages; ++i) { - Common::String msg((const char *)_eseg + msgOffset); - msgOffset += msg.size() + 1; - msgArr.push_back(msg); - } - speakText(_screen, msgArr); - } - - _screen->forceFadeOut(); - _screen->clearScreen(); - - free(_eseg); - if (_establishMode == 0) { - warning("TODO: init4Quads();"); - } -} - void AccessEngine::plotList() { _player->calcPlayer(); plotList1(); diff --git a/engines/access/access.h b/engines/access/access.h index fb73b1fb9b..f25effef06 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -91,10 +91,6 @@ private: void setVGA(); void dummyLoop(); - - void speakText(ASurface *s, Common::ArraymsgArr); - - void doEstablish(int esatabIndex, int sub); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -104,6 +100,8 @@ protected: */ void doRoom(); + void speakText(ASurface *s, Common::ArraymsgArr); + // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; @@ -198,6 +196,8 @@ public: int _mapOffset; int _screenVirtX; + bool _clearSummaryFlag; + // Fields mapped into the flags array int &_useItem; int &_startup; @@ -229,11 +229,7 @@ public: */ void freeInactiveData(); - void AccessEngine::loadEstablish(int sub); - - void establish(int esatabIndex, int sub); - - void establishCenter(int esatabIndex, int sub); + virtual void establish(int esatabIndex, int sub) = 0; void plotList(); void plotList1(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 286a7126bc..f7ed4146d8 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -184,6 +184,92 @@ void AmazonEngine::setupGame() { _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; } +void AmazonEngine::establish(int esatabIndex, int sub) { + _establishMode = 0; + _establishGroup = 0; + doEstablish(esatabIndex, sub); +} + +void AmazonEngine::establishCenter(int esatabIndex, int sub) { + _establishMode = 1; + doEstablish(esatabIndex, sub); +} + +const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" }; + +void AmazonEngine::loadEstablish(int sub) { + if (!_files->existFile("ETEXT.DAT")) { + int oldGroup = _establishGroup; + _establishGroup = 0; + + _eseg = _files->loadFile(_estTable[oldGroup]); + } else { + _eseg = _files->loadFile("ETEXT.DAT"); + } + + _establishCtrlTblOfs = READ_LE_UINT16(_eseg); + + int ofs = _establishCtrlTblOfs + (sub * 2); + int idx = READ_LE_UINT16(_eseg + ofs); + _narateFile = READ_LE_UINT16(_eseg + idx); + _txtPages = READ_LE_UINT16(_eseg + idx + 2); + + if (!_txtPages) + return; + + _sndSubFile = READ_LE_UINT16(_eseg + idx + 4); + for (int i = 0; i < _txtPages; ++i) + _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); +} + +void AmazonEngine::doEstablish(int esatabIndex, int sub) { + _establishMode = 1; + + _screen->forceFadeOut(); + _screen->clearScreen(); + _screen->setPanel(3); + + if (esatabIndex != -1) { + _files->loadScreen(95, esatabIndex); + _buffer2.copyBuffer(_screen); + } + + _screen->setIconPalette(); + _screen->forceFadeIn(); + + _fonts._charSet._lo = 1; + _fonts._charSet._hi = 10; + _fonts._charFor._lo = 29; + _fonts._charFor._hi = 32; + + _screen->_maxChars = 37; + _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); + loadEstablish(sub); + _et = sub; + uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2); + + _printEnd = 155; + if (_txtPages == 0) { + Common::String msg((const char *)_eseg + msgOffset); + _fonts._font2.printText(_screen, msg); + } else { + Common::Array msgArr; + for (int i = 0; i < _txtPages; ++i) { + Common::String msg((const char *)_eseg + msgOffset); + msgOffset += msg.size() + 1; + msgArr.push_back(msg); + } + speakText(_screen, msgArr); + } + + _screen->forceFadeOut(); + _screen->clearScreen(); + + free(_eseg); + if (_establishMode == 0) + _room->init4Quads(); +} + void AmazonEngine::drawHelp() { error("TODO: drawHelp"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index c331830501..5c4c472fb7 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -73,6 +73,10 @@ private: */ void setupGame(); + void loadEstablish(int sub); + void doEstablish(int esatabIndex, int sub); + void establishCenter(int esatabIndex, int sub); + protected: /** * Play the game @@ -102,6 +106,8 @@ public: virtual ~AmazonEngine(); void drawHelp(); + + virtual void establish(int esatabIndex, int sub); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index c0076fd78a..3666de5e09 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -176,6 +176,18 @@ void AmazonRoom::mainAreaClick() { } } +void AmazonRoom::init4Quads() { + if (!_vm->_screen->_vesaMode) + return; + + warning("TILESCREEN(TILE.BLK);"); + _vm->_inventory->refreshInventory(); + warning("TODO: UPDATESUMMARY(chapter)"); + + _vm->_screen->setPanel(0); + _vm->_screen->clearScreen(); +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index c7d8e0c0ae..122eed991e 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -51,10 +51,13 @@ protected: virtual void roomMenu(); virtual void mainAreaClick(); + public: AmazonRoom(AccessEngine *vm); virtual ~AmazonRoom(); + + virtual void init4Quads(); }; } // End of namespace Amazon diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h index 29fdd1b2ce..a99ece67cf 100644 --- a/engines/access/martian/martian_game.h +++ b/engines/access/martian/martian_game.h @@ -63,13 +63,13 @@ protected: * Play the game */ virtual void playGame(); -public: public: MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~MartianEngine(); void drawHelp(); + virtual void establish(int esatabIndex, int sub) {}; }; } // End of namespace Martian diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h index 526de56240..14744f5311 100644 --- a/engines/access/martian/martian_room.h +++ b/engines/access/martian/martian_room.h @@ -53,6 +53,11 @@ public: MartianRoom(AccessEngine *vm); virtual ~MartianRoom(); + + virtual void loadRoomData(const byte *roomData) { warning("TODO - loadRoomData"); } + + virtual void init4Quads() { } + }; } // End of namespace Martian diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 29d9eef624..10146ff6c3 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -324,10 +324,6 @@ void Room::buildRow(int playY, int screenY) { error("TODO: buildRow"); } -void Room::init4Quads() { - error("TODO: init4Quads"); -} - void Room::loadPlayField(int fileNum, int subfile) { byte *playData = _vm->_files->loadFile(fileNum, subfile); Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); diff --git a/engines/access/room.h b/engines/access/room.h index 6cd3b8cad0..1d540840e3 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -155,7 +155,7 @@ public: */ void buildRow(int playY, int screenY); - void init4Quads(); + virtual void init4Quads() = 0; void setWallCodes(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 57002c0f7c..025172464a 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -58,6 +58,12 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _clipHeight = _vWindowLinesTall - 1; } +void Screen::clearScreen() { + clearBuffer(); + if (_vesaMode) + _vm->_clearSummaryFlag = true; +} + void Screen::setDisplayScan() { _clipWidth = this->w - 1; _clipHeight = this->h - 1; diff --git a/engines/access/screen.h b/engines/access/screen.h index 3935f2c149..a166fded5e 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -107,7 +107,7 @@ public: void fadeOut() { forceFadeOut(); } void fadeIn() { forceFadeIn(); } - void clearScreen() { clearBuffer(); } + void clearScreen(); /** * Set the initial palette -- cgit v1.2.3 From 610644c4a1fd386d6fde2c4c52b5aa9c1bdacc48 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Aug 2014 01:25:18 +0200 Subject: ACCESS: Implement tileScreen --- engines/access/amazon/amazon_game.cpp | 40 ++++++++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 5 +++++ engines/access/amazon/amazon_room.cpp | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f7ed4146d8..608db5d573 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -44,15 +44,18 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _hitCount = 0; _saveRiver = 0; _hitSafe = 0; - _chapter = 0; + _oldTitleChap = _chapter = 0; _topList = 0; _botList = 0; _riverIndex = 0; _rawInactiveX = 0; _rawInactiveY = 0; _inactiveYOff = 0; + _tilePos = Common::Point(0, 0); Common::fill(&_esTabTable[0], &_esTabTable[100], 0); + memset(_tileData, 0, sizeof(_tileData)); + _hintLevel = 0; } @@ -270,6 +273,41 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _room->init4Quads(); } +const char *const _tileFiles[] = { + "GRAY.BLK", "RED.BLK", "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "LITEBLUE.BLK", + "DARKBLUE.BLK", "CYAN.BLK", "GREEN.BLK", "OLIVE.BLK", "GRAY.BLK", "RED.BLK", + "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "OLIVE.BLK" +}; + +void AmazonEngine::tileScreen(Common::String filename) { + if (!_screen->_vesaMode) + return; + + if (!_clearSummaryFlag && (_oldTitleChap == _chapter)) + return; + + _oldTitleChap = _chapter; + int idx = _chapter - 1; + + if (!_files->existFile(_tileFiles[idx])) + return; + + byte *data = _files->loadFile(_tileFiles[idx]); + int x = READ_LE_UINT16(data); + int y = READ_LE_UINT16(data + 2); + int size = ((x + 2) * y) + 10; + + for (int i = 0; i < size; ++i) + _tileData[i] = data[i + 4]; + + // CHECKME: Depending on the Vesa mode during initialization, 400 or 480 + for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) { + for (_tilePos.x = 0; _tilePos.x < 640; _tilePos.x += x) + warning("TODO: DRAWOBJECT"); + } + +} + void AmazonEngine::drawHelp() { error("TODO: drawHelp"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 5c4c472fb7..5192e208d7 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -39,6 +39,7 @@ private: int _hitCount; int _saveRiver; int _hitSafe; + int _oldTitleChap; int _chapter; int _topList; int _botList; @@ -47,6 +48,8 @@ private: int _rawInactiveY; int _inactiveYOff; int _esTabTable[100]; + Common::Point _tilePos; + byte _tileData[1455]; /** * Do the game introduction @@ -108,6 +111,8 @@ public: void drawHelp(); virtual void establish(int esatabIndex, int sub); + + void tileScreen(Common::String filename); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 3666de5e09..f8c8bc45a8 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -180,7 +180,7 @@ void AmazonRoom::init4Quads() { if (!_vm->_screen->_vesaMode) return; - warning("TILESCREEN(TILE.BLK);"); + _game->tileScreen(Common::String("TILE.BLK")); _vm->_inventory->refreshInventory(); warning("TODO: UPDATESUMMARY(chapter)"); -- cgit v1.2.3 From ff05b42e021ba12ce9ca86d118868cfa32d911eb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 27 Aug 2014 08:13:54 +0200 Subject: ACCESS: Implement updateSummary --- engines/access/amazon/amazon_game.cpp | 43 ++++++++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 7 ++++-- engines/access/amazon/amazon_room.cpp | 5 ++-- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 608db5d573..f7f3611440 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -45,6 +45,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _saveRiver = 0; _hitSafe = 0; _oldTitleChap = _chapter = 0; + _updateChapter = -1; _topList = 0; _botList = 0; _riverIndex = 0; @@ -279,7 +280,7 @@ const char *const _tileFiles[] = { "LTBROWN.BLK", "DKBROWN.BLK", "VIOLET.BLK", "OLIVE.BLK" }; -void AmazonEngine::tileScreen(Common::String filename) { +void AmazonEngine::tileScreen() { if (!_screen->_vesaMode) return; @@ -308,6 +309,46 @@ void AmazonEngine::tileScreen(Common::String filename) { } +void AmazonEngine::updateSummary(int chap) { + if (!_screen->_vesaMode) + return; + + int chapter = chap; + if (chapter > 16) + chapter = 16; + + if (!_clearSummaryFlag && (chapter == _updateChapter)) + return; + + _clearSummaryFlag = false; + int celSubFile = 0; + _updateChapter = chapter; + Common::Array summaryCells; + loadCells(summaryCells); + + for (int i = celSubFile; i < 16; ++i) { + if (i > 7) + warning("TODO: DRAWOBJECT"); + else + warning("TODO: DRAWOBJECT"); + } + + delete _objectsTable[93]; + _objectsTable[93] = nullptr; + + for (int i = 1; i <= _updateChapter; ++i) { + celSubFile = i; + loadCells(summaryCells); + if (i > 8) + warning("TODO: DRAWOBJECT"); + else + warning("TODO: DRAWOBJECT"); + + delete _objectsTable[93]; + _objectsTable[93] = nullptr; + } +} + void AmazonEngine::drawHelp() { error("TODO: drawHelp"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 5192e208d7..59511c4546 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -40,7 +40,6 @@ private: int _saveRiver; int _hitSafe; int _oldTitleChap; - int _chapter; int _topList; int _botList; int _riverIndex; @@ -103,6 +102,9 @@ public: // Other game specific fields int _hintLevel; + + int _chapter; + int _updateChapter; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); @@ -112,7 +114,8 @@ public: virtual void establish(int esatabIndex, int sub); - void tileScreen(Common::String filename); + void tileScreen(); + void updateSummary(int chap); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index f8c8bc45a8..f64264f7d7 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -180,9 +180,10 @@ void AmazonRoom::init4Quads() { if (!_vm->_screen->_vesaMode) return; - _game->tileScreen(Common::String("TILE.BLK")); + // CHECKME: in the original, this call of tileScreen uses an useless parameter, "TILES.BLK" + _game->tileScreen(); _vm->_inventory->refreshInventory(); - warning("TODO: UPDATESUMMARY(chapter)"); + _game->updateSummary(_game->_chapter); _vm->_screen->setPanel(0); _vm->_screen->clearScreen(); -- cgit v1.2.3 From 21d6fddab43ff4adbd8c8b3d10b110576c197108 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 27 Aug 2014 14:57:35 +0700 Subject: ZVISION: Added scaled blitter to bkg --- engines/zvision/graphics/render_manager.cpp | 26 ++++++++++++++++++++++++++ engines/zvision/graphics/render_manager.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index c89444df13..5aa0d752d0 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -565,6 +565,32 @@ void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, _bkgDirtyRect.extend(dirty); } +void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect) { + if (src.w == _dstRect.width() && src.h == _dstRect.height()) + blitSurfaceToBkg(src, _dstRect.left, _dstRect.top); + else { + Graphics::Surface *tmp = new Graphics::Surface; + tmp->create(_dstRect.width(), _dstRect.height(), src.format); + scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); + blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top); + tmp->free(); + delete tmp; + } +} + +void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey) { + if (src.w == _dstRect.width() && src.h == _dstRect.height()) + blitSurfaceToBkg(src, _dstRect.left, _dstRect.top, colorkey); + else { + Graphics::Surface *tmp = new Graphics::Surface; + tmp->create(_dstRect.width(), _dstRect.height(), src.format); + scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); + blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top, colorkey); + tmp->free(); + delete tmp; + } +} + void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) { Common::Rect empt; blitSurfaceToSurface(src, empt, _menuWnd, x, y); diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index b4c6c76a6e..24234e28e1 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -229,6 +229,8 @@ public: void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y); void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey); + void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect); + void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey); void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y); void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); -- cgit v1.2.3 From 2b6d65f83bdc26b3d07cfc3061a27882d87df67c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 27 Aug 2014 14:59:18 +0700 Subject: ZVISION: Implemented hotmovie control --- engines/zvision/module.mk | 1 + .../zvision/scripting/controls/hotmov_control.cpp | 201 +++++++++++++++++++++ .../zvision/scripting/controls/hotmov_control.h | 63 +++++++ engines/zvision/scripting/scr_file_handling.cpp | 3 + 4 files changed, 268 insertions(+) create mode 100644 engines/zvision/scripting/controls/hotmov_control.cpp create mode 100644 engines/zvision/scripting/controls/hotmov_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 457444c5e2..0e6f1ce042 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -17,6 +17,7 @@ MODULE_OBJS := \ graphics/render_table.o \ scripting/actions.o \ scripting/control.o \ + scripting/controls/hotmov_control.o \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ scripting/controls/push_toggle_control.o \ diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp new file mode 100644 index 0000000000..1e1886e1a8 --- /dev/null +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -0,0 +1,201 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/hotmov_control.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/animation/meta_animation.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" +#include "common/file.h" +#include "common/system.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_HOTMOV) { + _animation = NULL; + _cycle = 0; + _cur_frame = -1; + _lastRenderedFrame = -1; + _frames.clear(); + _frame_time = 0; + _num_cycles = 0; + _num_frames = 0; + + _engine->getScriptManager()->setStateFlag(_key, 0); + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("hs_frame_list", true)) { + readHsFile(values); + } else if (param.matchString("rectangle", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _rectangle = Common::Rect(x, y, width, height); + } else if (param.matchString("num_frames", true)) { + _num_frames = atoi(values.c_str()); + } else if (param.matchString("num_cycles", true)) { + _num_cycles = atoi(values.c_str()); + } else if (param.matchString("animation", true)) { + char filename[64]; + sscanf(values.c_str(), "%s", filename); + values = Common::String(filename); + if (values.hasSuffix(".avi") || values.hasSuffix(".rlf")) + _animation = new MetaAnimation(values, _engine); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } +} + +HotMovControl::~HotMovControl() { + if (_animation) + delete _animation; + + _frames.clear(); +} + +void HotMovControl::renderFrame(uint frameNumber) { + if ((int)frameNumber == _lastRenderedFrame) + return; + + _lastRenderedFrame = frameNumber; + + const Graphics::Surface *frameData; + + if (_animation) { + frameData = _animation->getFrameData(frameNumber); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle); + } +} + +bool HotMovControl::process(uint32 deltaTimeInMillis) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_cycle < _num_cycles) { + _frame_time -= deltaTimeInMillis; + + if (_frame_time <= 0) { + _cur_frame++; + if (_cur_frame >= _num_frames) { + _cur_frame = 0; + _cycle++; + } + if (_cycle != _num_cycles) + renderFrame(_cur_frame); + else + _engine->getScriptManager()->setStateFlag(_key, 2); + + _frame_time = _animation->frameTime(); + } + } + + return false; +} + +bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_cycle < _num_cycles) { + if (_frames[_cur_frame].contains(backgroundImageSpacePos)) { + _engine->getCursorManager()->changeCursor(CursorIndex_Active); + return true; + } + } + + return false; +} + +bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_cycle < _num_cycles) { + if (_frames[_cur_frame].contains(backgroundImageSpacePos)) { + _engine->getScriptManager()->setStateValue(_key, 1); + return true; + } + } + + return false; +} + +void HotMovControl::readHsFile(const Common::String &fileName) { + if (_num_frames == 0) + return; + + Common::File file; + if (!_engine->getSearchManager()->openFile(file, fileName)) { + warning("HS file %s could could be opened", fileName.c_str()); + return; + } + + Common::String line; + + _frames.resize(_num_frames); + + while (!file.eos()) { + line = file.readLine(); + + int frame; + int x; + int y; + int width; + int height; + + sscanf(line.c_str(), "%d:%d %d %d %d~", &frame, &x, &y, &width, &height); + + if (frame >= 0 && frame < _num_frames) + _frames[frame] = Common::Rect(x, y, width, height); + } + file.close(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h new file mode 100644 index 0000000000..ea12bab82b --- /dev/null +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -0,0 +1,63 @@ +/* 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 ZVISION_HOTMOV_CONTROL_H +#define ZVISION_HOTMOV_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "common/array.h" +#include "common/rect.h" + + +namespace ZVision { + +class MetaAnimation; + +class HotMovControl : public Control { +public: + HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~HotMovControl(); + +private: + int32 _num_frames; + int32 _frame_time; + int32 _cur_frame; + int32 _lastRenderedFrame; + int32 _cycle; + int32 _num_cycles; + MetaAnimation *_animation; + Common::Rect _rectangle; + Common::Array _frames; +public: + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool process(uint32 deltaTimeInMillis); + +private: + void renderFrame(uint frameNumber); + void readHsFile(const Common::String &fileName); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index b8046c0fe8..d6c5aa0cb5 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -34,6 +34,7 @@ #include "zvision/scripting/controls/save_control.h" #include "zvision/scripting/controls/input_control.h" #include "zvision/scripting/controls/safe_control.h" +#include "zvision/scripting/controls/hotmov_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -355,6 +356,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new SaveControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("safe")) { return new SafeControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("hotmovie")) { + return new HotMovControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 1590f29d149df976e27df4a49c21ae4d23ab8663 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Aug 2014 01:59:53 +0200 Subject: ACCESS: Use the hires version in Amazon CD --- engines/access/access.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c19a37cdc3..6058800ddb 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -141,7 +141,11 @@ void AccessEngine::initialize() { if (isCD()) { const Common::FSNode gameDataDir(ConfMan.get("path")); - const Common::FSNode cdromDir = gameDataDir.getChild("cdrom"); + // The CD version contains two versions of the game. + // - The MCGA version, in the CDROM folder + // - The VESA version, in the TDROM folder + // We use the hires version. + const Common::FSNode cdromDir = gameDataDir.getChild("tdrom"); for (int idx = 0; idx < 15; ++idx) { Common::String folder = (idx == 0) ? "game" : -- cgit v1.2.3 From 941b443195006a787f25143559bf793e863b9446 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Aug 2014 02:01:05 +0200 Subject: ACCESS: Fix a crash in the intro --- engines/access/amazon/amazon_game.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f7f3611440..15869a4499 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -90,7 +90,7 @@ void AmazonEngine::doIntroduction() { _events->showCursor(); _screen->setPanel(0); - // TODO: Worry about implementing full intro sequence later + //TODO: Implement the rest of the intro return; doTitle(); @@ -123,6 +123,9 @@ void AmazonEngine::doTitle() { _sound->queueSound(0, 98, 30); _sound->_soundPriority[0] = 1; + _sound->queueSound(1, 98, 8); + _sound->_soundPriority[1] = 1; + _screen->_loadPalFlag = false; _files->loadScreen(0, 3); @@ -146,14 +149,18 @@ void AmazonEngine::doTitle() { _sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (_pCount = 0; _pCount < 3; ++_pCount) { - _buffer2.copyFrom(_buffer1); - int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); - int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); - _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); + for (_pCount = 0; _pCount <= 3; ++_pCount) { + if (_pCount != 3) { + _buffer2.copyFrom(_buffer1); + int id = READ_LE_UINT16(COUNTDOWN + _pCount * 2); + int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 2 + 1); + _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); + //TODO : more intro + } else { + //TODO : more intro + } } - // TODO: More to do - + //TODO : more intro delete _objectsTable[0]; } -- cgit v1.2.3 From a0e54db08155f8cf8d56f66743ffa694c188e33b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Aug 2014 02:01:33 +0200 Subject: ACCESS: Set Vesa mode when using the CD --- engines/access/screen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 025172464a..4f2ee3e3ac 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -41,7 +41,11 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0); Common::fill(&_scaleTable2[0], &_scaleTable2[256], 0); _savedPaletteCount = 0; - _vesaMode = 0; + if (_vm->isCD()) + _vesaMode = 0; + else + _vesaMode = 1; + _vesaCurrentWin = 0; _currentPanel = 0; _hideFlag = true; -- cgit v1.2.3 From 455011c37e20fb2d859e1c3f04650e369844c921 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 28 Aug 2014 02:02:03 +0200 Subject: ACCESS: Fix typo in detection comment --- engines/access/detection_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index 6a281a7e96..95ac8fa47d 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -42,7 +42,7 @@ static const AccessGameDescription gameDescriptions[] = { }, { - // Amazon Guadians of Eden - CD English + // Amazon: Guardians of Eden - CD English { "amazon", "CD", -- cgit v1.2.3 From c0a7852662be724077921bcf9b9bb0bf2da2dfff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:13:43 -0400 Subject: ACCESS: Refactor the file manager to return resource structures --- engines/access/access.cpp | 17 ++-- engines/access/access.h | 8 +- engines/access/amazon/amazon_game.cpp | 15 ++-- engines/access/amazon/amazon_room.cpp | 6 +- engines/access/animation.cpp | 77 ++++++++-------- engines/access/animation.h | 11 +-- engines/access/asurface.cpp | 29 +++--- engines/access/asurface.h | 5 +- engines/access/bubble_box.cpp | 6 +- engines/access/char.cpp | 14 +-- engines/access/files.cpp | 154 +++++++++++++++++--------------- engines/access/files.h | 57 ++++++++---- engines/access/martian/martian_game.cpp | 6 +- engines/access/martian/martian_room.cpp | 6 +- engines/access/player.cpp | 6 +- engines/access/room.cpp | 44 ++++----- engines/access/screen.cpp | 5 +- engines/access/scripts.cpp | 23 +++-- engines/access/scripts.h | 6 +- engines/access/sound.cpp | 9 +- engines/access/sound.h | 12 +-- engines/access/video.cpp | 26 +++++- engines/access/video.h | 13 ++- 23 files changed, 307 insertions(+), 248 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6058800ddb..080cd36032 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -70,6 +70,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleMaxY = 0; _scaleI = 0; _scaleFlag = false; + _eseg = nullptr; _conversation = 0; _currentMan = 0; @@ -124,9 +125,9 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete[] _inactive; - delete[] _music; - delete[] _title; + delete _inactive; + delete _music; + delete _title; } void AccessEngine::setVGA() { @@ -211,9 +212,9 @@ int AccessEngine::getRandomNumber(int maxNumber) { void AccessEngine::loadCells(Common::Array &cells) { for (uint i = 0; i < cells.size(); ++i) { - byte *spriteData = _files->loadFile(cells[i]); - _objectsTable[cells[i]._cell] = new SpriteResource(this, - spriteData, _files->_filesize, DisposeAfterUse::YES); + Resource *spriteData = _files->loadFile(cells[i]); + _objectsTable[cells[i]._cell] = new SpriteResource(this, spriteData); + delete spriteData; } } @@ -251,7 +252,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) if ((s->_printOrg.y > _printEnd) && (!lastLine)) { while (true) { - _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; _sound->playSound(1); _scripts->CMDFREESOUND(); @@ -286,7 +287,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) return; while(true) { - _sound->_soundTable[0]._data = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; _sound->playSound(1); _scripts->CMDFREESOUND(); diff --git a/engines/access/access.h b/engines/access/access.h index f25effef06..55810e8a16 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -148,9 +148,9 @@ public: int _mouseMode; int _currentManOld; - byte *_inactive; - byte *_music; - byte *_title; + Resource *_inactive; + Resource *_music; + Resource *_title; int _converseMode; int _startAboutBox; int _startTravelBox; @@ -164,7 +164,7 @@ public: int _scaleI; bool _scaleFlag; - byte *_eseg; + Resource *_eseg; int _et; int _printEnd; int _txtPages; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 15869a4499..cf383ce45a 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -134,9 +134,9 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); - byte *spriteData = _files->loadFile(0, 2); - _objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize, - DisposeAfterUse::YES); + Resource *spriteData = _files->loadFile(0, 2); + _objectsTable[0] = new SpriteResource(this, spriteData); + delete spriteData; _sound->playSound(1); @@ -300,13 +300,13 @@ void AmazonEngine::tileScreen() { if (!_files->existFile(_tileFiles[idx])) return; - byte *data = _files->loadFile(_tileFiles[idx]); - int x = READ_LE_UINT16(data); - int y = READ_LE_UINT16(data + 2); + Resource *res = _files->loadFile(_tileFiles[idx]); + int x = res->_stream->readSint16LE(); + int y = res->_stream->readSint16LE(); int size = ((x + 2) * y) + 10; for (int i = 0; i < size; ++i) - _tileData[i] = data[i + 4]; + _tileData[i] = res->_stream->readByte(); // CHECKME: Depending on the Vesa mode during initialization, 400 or 480 for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) { @@ -314,6 +314,7 @@ void AmazonEngine::tileScreen() { warning("TODO: DRAWOBJECT"); } + delete res; } void AmazonEngine::updateSummary(int chap) { diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index f64264f7d7..227fc474cf 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -131,9 +131,9 @@ void AmazonRoom::roomSet() { } void AmazonRoom::roomMenu() { - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData); + delete iconData; _vm->_screen->saveScreen(); _vm->_screen->setDisplayScan(); diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index b286237bfb..03f349e34a 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -27,18 +27,17 @@ namespace Access { -AnimationResource::AnimationResource(AccessEngine *vm, const byte *data, int size) { - Common::MemoryReadStream stream(data, size); - int count = stream.readUint16LE(); +AnimationResource::AnimationResource(AccessEngine *vm, Resource *res) { + int count = res->_stream->readUint16LE(); Common::Array offsets; for (int i = 0; i < count; ++i) - offsets.push_back(stream.readUint32LE()); + offsets.push_back(res->_stream->readUint32LE()); _animations.reserve(count); for (int i = 0; i < count; ++i) { - stream.seek(offsets[i]); - Animation *anim = new Animation(vm, stream); + res->_stream->seek(offsets[i]); + Animation *anim = new Animation(vm, res->_stream); _animations.push_back(anim); } } @@ -50,29 +49,29 @@ AnimationResource::~AnimationResource() { /*------------------------------------------------------------------------*/ -Animation::Animation(AccessEngine *vm, Common::MemoryReadStream &stream): +Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Manager(vm) { - uint32 startOfs = stream.pos(); - - _type = stream.readByte(); - _scaling = stream.readSByte(); - stream.readByte(); // unk - _frameNumber = stream.readByte(); - _initialTicks = stream.readUint16LE(); - stream.readUint16LE(); // unk - stream.readUint16LE(); // unk - _loopCount = stream.readSint16LE(); - _countdownTicks = stream.readUint16LE(); - _currentLoopCount = stream.readSint16LE(); - stream.readUint16LE(); // unk + uint32 startOfs = stream->pos(); + + _type = stream->readByte(); + _scaling = stream->readSByte(); + stream->readByte(); // unk + _frameNumber = stream->readByte(); + _initialTicks = stream->readUint16LE(); + stream->readUint16LE(); // unk + stream->readUint16LE(); // unk + _loopCount = stream->readSint16LE(); + _countdownTicks = stream->readUint16LE(); + _currentLoopCount = stream->readSint16LE(); + stream->readUint16LE(); // unk Common::Array frameOffsets; uint16 ofs; - while ((ofs = stream.readUint16LE()) != 0) + while ((ofs = stream->readUint16LE()) != 0) frameOffsets.push_back(ofs); for (int i = 0; i < (int)frameOffsets.size(); i++) { - stream.seek(startOfs + frameOffsets[i]); + stream->seek(startOfs + frameOffsets[i]); AnimationFrame *frame = new AnimationFrame(stream, startOfs); _frames.push_back(frame); @@ -239,22 +238,22 @@ void Animation::setFrame1(AnimationFrame *frame) { /*------------------------------------------------------------------------*/ -AnimationFrame::AnimationFrame(Common::MemoryReadStream &stream, int startOffset) { +AnimationFrame::AnimationFrame(Common::SeekableReadStream *stream, int startOffset) { uint16 nextOffset; - stream.readByte(); // unk - _baseX = stream.readUint16LE(); - _baseY = stream.readUint16LE(); - _frameDelay = stream.readUint16LE(); - nextOffset = stream.readUint16LE(); + stream->readByte(); // unk + _baseX = stream->readUint16LE(); + _baseY = stream->readUint16LE(); + _frameDelay = stream->readUint16LE(); + nextOffset = stream->readUint16LE(); while (nextOffset != 0) { - stream.seek(startOffset + nextOffset); + stream->seek(startOffset + nextOffset); AnimationFramePart *framePart = new AnimationFramePart(stream); _parts.push_back(framePart); - nextOffset = stream.readUint16LE(); + nextOffset = stream->readUint16LE(); } } @@ -265,13 +264,13 @@ AnimationFrame::~AnimationFrame() { /*------------------------------------------------------------------------*/ -AnimationFramePart::AnimationFramePart(Common::MemoryReadStream &stream) { - _flags = stream.readByte(); - _spritesIndex = stream.readByte(); - _frameIndex = stream.readByte(); - _position.x = stream.readUint16LE(); - _position.y = stream.readUint16LE(); - _offsetY = stream.readUint16LE(); +AnimationFramePart::AnimationFramePart(Common::SeekableReadStream *stream) { + _flags = stream->readByte(); + _spritesIndex = stream->readByte(); + _frameIndex = stream->readByte(); + _position.x = stream->readUint16LE(); + _position.y = stream->readUint16LE(); + _offsetY = stream->readUint16LE(); } /*------------------------------------------------------------------------*/ @@ -296,10 +295,10 @@ void AnimationManager::clearTimers() { _animationTimers.clear(); } -void AnimationManager::loadAnimations(const byte *data, int size) { +void AnimationManager::loadAnimations(Resource *res) { _animationTimers.clear(); delete _animation; - _animation = new AnimationResource(_vm, data, size); + _animation = new AnimationResource(_vm, res); } diff --git a/engines/access/animation.h b/engines/access/animation.h index 7e94f58cbd..8a39333764 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -27,6 +27,7 @@ #include "common/array.h" #include "common/memstream.h" #include "access/data.h" +#include "access/files.h" namespace Access { @@ -47,7 +48,7 @@ public: AnimationManager(AccessEngine *vm); ~AnimationManager(); void freeAnimationData(); - void loadAnimations(const byte *data, int size); + void loadAnimations(Resource *res); Animation *findAnimation(int animId); Animation *setAnimation(int animId); @@ -74,7 +75,7 @@ class AnimationResource { private: Common::Array _animations; public: - AnimationResource(AccessEngine *vm, const byte *data, int size); + AnimationResource(AccessEngine *vm, Resource *res); ~AnimationResource(); int getCount() { return _animations.size(); } @@ -107,7 +108,7 @@ public: int _currentLoopCount; int _field10; public: - Animation(AccessEngine *vm, Common::MemoryReadStream &stream); + Animation(AccessEngine *vm, Common::SeekableReadStream *stream); ~Animation(); void animate(); @@ -119,7 +120,7 @@ public: int _frameDelay; Common::Array _parts; public: - AnimationFrame(Common::MemoryReadStream &stream, int startOffset); + AnimationFrame(Common::SeekableReadStream *stream, int startOffset); ~AnimationFrame(); }; @@ -131,7 +132,7 @@ public: Common::Point _position; int _offsetY; public: - AnimationFramePart(Common::MemoryReadStream &stream); + AnimationFramePart(Common::SeekableReadStream *stream); }; } // End of namespace Access diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index cdf8b3dd3f..cf8bf0766f 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -28,27 +28,22 @@ namespace Access { -SpriteResource::SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory) { - Common::MemoryReadStream stream(data, size); +SpriteResource::SpriteResource(AccessEngine *vm, Resource *res) { Common::Array offsets; - int count = stream.readUint16LE(); + int count = res->_stream->readUint16LE(); for (int i = 0; i < count; i++) - offsets.push_back(stream.readUint32LE()); - offsets.push_back(size); // For easier calculations of Noctropolis sizes + offsets.push_back(res->_stream->readUint32LE()); + offsets.push_back(res->_size); // For easier calculations of Noctropolis sizes // Build up the frames for (int i = 0; i < count; ++i) { - stream.seek(offsets[i]); + res->_stream->seek(offsets[i]); int frameSize = offsets[i + 1] - offsets[i]; - SpriteFrame *frame = new SpriteFrame(vm, stream, frameSize); + SpriteFrame *frame = new SpriteFrame(vm, res->_stream, frameSize); _frames.push_back(frame); } - - if (disposeMemory == DisposeAfterUse::YES) - delete[] data; } SpriteResource::~SpriteResource() { @@ -56,9 +51,9 @@ SpriteResource::~SpriteResource() { delete _frames[i]; } -SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) { - int xSize = stream.readUint16LE(); - int ySize = stream.readUint16LE(); +SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize) { + int xSize = stream->readUint16LE(); + int ySize = stream->readUint16LE(); create(xSize, ySize); // Empty surface @@ -67,12 +62,12 @@ SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int // Decode the data for (int y = 0; y < h; ++y) { - int offset = stream.readByte(); - int len = stream.readByte(); + int offset = stream->readByte(); + int len = stream->readByte(); assert((offset + len) <= w); byte *destP = (byte *)getBasePtr(offset, y); - stream.read(destP, len); + stream->read(destP, len); } } diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 5d1f6fd307..5c164f0e59 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -115,7 +115,7 @@ public: class SpriteFrame : public ASurface { public: - SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize); + SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, int frameSize); ~SpriteFrame(); }; @@ -123,8 +123,7 @@ class SpriteResource { public: Common::Array _frames; public: - SpriteResource(AccessEngine *vm, const byte *data, uint32 size, - DisposeAfterUse::Flag disposeMemory = DisposeAfterUse::NO); + SpriteResource(AccessEngine *vm, Resource *res); ~SpriteResource(); int getCount() { return _frames.size(); } diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index d3782a3125..c4272b607a 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -191,9 +191,9 @@ void BubbleBox::doBox(int item, int box) { } // Get icons data - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *icons = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *icons = new SpriteResource(_vm, iconData); + delete iconData; // Set the up boundaries and color to use for the box background _vm->_screen->_orgX1 = _bounds.left - 2; diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 09335fc017..767512f43e 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -121,15 +121,15 @@ void CharManager::loadChar(int charId) { _vm->loadCells(ce._cells); if (ce._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(ce._animFile); - _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + Resource *data = _vm->_files->loadFile(ce._animFile); + _vm->_animation->loadAnimations(data); } // Load script data _vm->_scripts->freeScriptData(); if (ce._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(ce._scriptFile); - _vm->_scripts->setScript(data, _vm->_files->_filesize); + Resource *data = _vm->_files->loadFile(ce._scriptFile); + _vm->_scripts->setScript(data); } // Load extra cells @@ -139,9 +139,9 @@ void CharManager::loadChar(int charId) { } void CharManager::charMenu() { - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData); + delete iconData; Screen &screen = *_vm->_screen; screen.saveScreen(); diff --git a/engines/access/files.cpp b/engines/access/files.cpp index b1d6140e3e..78cb3eff51 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -20,6 +20,7 @@ * */ +#include "common/substream.h" #include "access/files.h" #include "access/amazon/amazon_resources.h" #include "access/martian/martian_resources.h" @@ -47,6 +48,27 @@ CellIdent::CellIdent(int cell, int fileNum, int subfile) { /*------------------------------------------------------------------------*/ +Resource::Resource() { + _stream = nullptr; + _size = 0; +} + +Resource::~Resource() { + delete _stream; +} + +byte *Resource::data() { + if (_data == nullptr) { + _data = new byte[_size]; + _stream->seek(0); + _stream->read(_data, _size); + } + + return _data; +} + +/*------------------------------------------------------------------------*/ + FileManager::FileManager(AccessEngine *vm): _vm(vm) { switch (vm->getGameID()) { case GType_Amazon: @@ -60,71 +82,70 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) { } _fileNumber = -1; - _stream = nullptr; } FileManager::~FileManager() { - delete _stream; - _file.close(); } -byte *FileManager::loadFile(int fileNum, int subfile) { - setAppended(fileNum); - gotoAppended(subfile); +Resource *FileManager::loadFile(int fileNum, int subfile) { + Resource *res = new Resource(); + setAppended(res, fileNum); + gotoAppended(res, subfile); - return handleFile(); + handleFile(res); + return res; } -byte *FileManager::loadFile(FileIdent &fileIdent) { +Resource *FileManager::loadFile(FileIdent &fileIdent) { return loadFile(fileIdent._fileNum, fileIdent._subfile); } -byte *FileManager::loadFile(const Common::String &filename) { +Resource *FileManager::loadFile(const Common::String &filename) { + Resource *res = new Resource(); + // Open the file - openFile(filename); + openFile(res, filename); - // Get a stream for the entire file - delete _stream; - _stream = _file.readStream(_file.size()); + // Set up stream for the entire file + res->_size = res->_file.size(); + res->_stream = res->_file.readStream(res->_size); - return handleFile(); + handleFile(res); + return res; } bool FileManager::existFile(const Common::String &filename) { - return _file.exists(filename); + Common::File f; + return f.exists(filename); } -void FileManager::openFile(const Common::String &filename) { +void FileManager::openFile(Resource *res, const Common::String &filename) { // Open up the file _fileNumber = -1; - _file.close(); - if (!_file.open(filename)) + if (!res->_file.open(filename)) error("Could not open file - %s", filename.c_str()); - - _filesize = _file.size(); } void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) { - setAppended(fileNum); - gotoAppended(subfile); - _vm->_screen->loadPalette(_stream); + Resource *res = loadFile(fileNum, subfile); + handleScreen(dest, res); + delete res; +} - // Get the data for the screen, and copy it over - byte *pSrc = handleFile(); +void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { + _vm->_screen->loadPalette(res->_stream); if (dest != _vm->_screen) dest->w = _vm->_screen->w; if (dest->w == dest->pitch) { - Common::copy(pSrc, pSrc + _filesize, (byte *)dest->getPixels()); + res->_stream->read((byte *)dest->getPixels(), dest->w * dest->h); } else { - byte *pCurr = pSrc; - for (int y = 0; y < dest->h; ++y, pCurr += dest->w) { + for (int y = 0; y < dest->h; ++y) { byte *pDest = (byte *)dest->getBasePtr(0, y); - Common::copy(pCurr, pCurr + dest->w, pDest); + res->_stream->read(pDest, dest->w); } } - delete[] pSrc; } void FileManager::loadScreen(int fileNum, int subfile) { @@ -132,69 +153,62 @@ void FileManager::loadScreen(int fileNum, int subfile) { } void FileManager::loadScreen(const Common::String &filename) { - // Open the file - openFile(filename); - - // Get the palette - _vm->_screen->loadPalette(&_file); - - // Get a stream for the remainder of the file - delete _stream; - _stream = _file.readStream(_file.size() - _file.pos()); - - // Get the data for the screen, and copy it over - byte *pSrc = handleFile(); - Common::copy(pSrc, pSrc + _filesize, (byte *)_vm->_screen->getPixels()); - delete[] pSrc; + Resource *res = loadFile(filename); + handleScreen(_vm->_screen, res); + delete res; } -byte *FileManager::handleFile() { +void FileManager::handleFile(Resource *res) { char header[3]; - _stream->read(&header[0], 3); - _stream->seek(-3, SEEK_CUR); + res->_stream->read(&header[0], 3); + res->_stream->seek(-3, SEEK_CUR); bool isCompressed = !strncmp(header, "DBE", 3); - // Get the data from the file or resource - _filesize = _stream->size() - _stream->pos(); - byte *data = new byte[_filesize]; - _stream->read(data, _filesize); - - // If the data is compressed, uncompress it + // If the data is compressed, uncompress it and replace the stream + // in the resource with the decompressed one if (isCompressed) { - byte *src = data; - _filesize = decompressDBE(src, &data); + // Read in the entire compressed data + byte *src = new byte[res->_size]; + res->_stream->read(src, res->_size); + + // Decompress the data + res->_size = decompressDBE(src, &res->_data); + + // Replace the default resource stream with a stream for the decompressed data + delete res->_stream; + res->_file.close(); + res->_stream = new Common::MemoryReadStream(res->_data, res->_size); + delete[] src; } - - return data; } -void FileManager::setAppended(int fileNum) { +void FileManager::setAppended(Resource *res, int fileNum) { + // Open the file for access + if (!res->_file.open(_filenames[fileNum])) + error("Could not open file %s", _filenames[fileNum]); + + // If a different file has been opened then previously, load it's index if (_fileNumber != fileNum) { _fileNumber = fileNum; - - _file.close(); - if (!_file.open(_filenames[fileNum])) - error("Could not open file %s", _filenames[fileNum]); - + // Read in the file index - int count = _file.readUint16LE(); + int count = res->_file.readUint16LE(); assert(count <= 100); _fileIndex.resize(count); for (int i = 0; i < count; ++i) - _fileIndex[i] = _file.readUint32LE(); + _fileIndex[i] = res->_file.readUint32LE(); } } -void FileManager::gotoAppended(int subfile) { +void FileManager::gotoAppended(Resource *res, int subfile) { uint32 offset = _fileIndex[subfile]; - uint32 size = (subfile == (int)_fileIndex.size() - 1) ? _file.size() - offset : + uint32 size = (subfile == (int)_fileIndex.size() - 1) ? res->_file.size() - offset : _fileIndex[subfile + 1] - offset; - _file.seek(offset); - delete _stream; - _stream = _file.readStream(size); + res->_size = size; + res->_stream = new Common::SeekableSubReadStream(&res->_file, offset, offset + size); } } // End of namespace Access diff --git a/engines/access/files.h b/engines/access/files.h index b13a796925..457cb81f86 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -49,20 +49,51 @@ struct CellIdent : FileIdent { CellIdent(int cell, int fileNum, int subfile); }; +class FileManager; + +class Resource { + friend class FileManager; +private: + Common::File _file; + byte *_data; +public: + Common::SeekableReadStream *_stream; + int _size; + + Resource(); + ~Resource(); + byte *data(); +}; + class FileManager { private: AccessEngine *_vm; const char * const *_filenames; - void openFile(const Common::String &filename); + void openFile(Resource *res, const Common::String &filename); + + /** + * Handles setting up the resource with a stream for the located resource + */ + void handleFile(Resource *res); + + /** + * Handles loading a screen surface and palette with decoded resource + */ + void handleScreen(Graphics::Surface *dest, Resource *res); + + /** + * Open up a sub-file container file + */ + void setAppended(Resource *file, int fileNum); - byte *handleFile(); + /** + * Open up a sub-file resource within an alrady opened container file. + */ + void gotoAppended(Resource *file, int subfile); public: int _fileNumber; - Common::File _file; - Common::SeekableReadStream *_stream; Common::Array _fileIndex; - uint32 _filesize; public: FileManager(AccessEngine *vm); ~FileManager(); @@ -75,17 +106,17 @@ public: /** * Load a given subfile from a container file */ - byte *loadFile(int fileNum, int subfile); + Resource *loadFile(int fileNum, int subfile); /** * Loads a resource specified by a file identifier */ - byte *loadFile(FileIdent &fileIdent); + Resource *loadFile(FileIdent &fileIdent); /** * Load a given file by name */ - byte *loadFile(const Common::String &filename); + Resource *loadFile(const Common::String &filename); /** * Load a given scren from a container file @@ -101,16 +132,6 @@ public: * Load a screen resource onto a designated surface */ void loadScreen(Graphics::Surface *dest, int fileNum, int subfile); - - /** - * Open up a sub-file container file - */ - void setAppended(int fileNum); - - /** - * Open up a sub-file resource within an alrady opened container file. - */ - void gotoAppended(int subfile); }; } // End of namespace Access diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index f087b56ac6..969267f719 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -106,9 +106,9 @@ void MartianEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); - byte *spriteData = _files->loadFile(0, 2); - _objectsTable[0] = new SpriteResource(this, spriteData, _files->_filesize, - DisposeAfterUse::YES); + Resource *spriteData = _files->loadFile(0, 2); + _objectsTable[0] = new SpriteResource(this, spriteData); + delete spriteData; _sound->playSound(1); diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 80eaf59fec..52eead7c0b 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -117,9 +117,9 @@ void MartianRoom::roomSet() { } void MartianRoom::roomMenu() { - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData); + delete iconData; _vm->_screen->saveScreen(); _vm->_screen->setDisplayScan(); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 336be0d462..df2ad67826 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -157,9 +157,9 @@ void Player::load() { void Player::loadSprites(const Common::String &name) { freeSprites(); - const byte *data = _vm->_files->loadFile(name); - _playerSprites1 = new SpriteResource(_vm, data, _vm->_files->_filesize, - DisposeAfterUse::YES); + Resource *data = _vm->_files->loadFile(name); + _playerSprites1 = new SpriteResource(_vm, data); + delete data; } void Player::freeSprites() { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 10146ff6c3..0c60f7b818 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -175,7 +175,6 @@ void Room::loadRoomData(const byte *roomData) { _vm->_sound->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); - _vm->_sound->_midiSize = _vm->_files->_filesize; _vm->_sound->midiPlay(); _vm->_sound->_musicRepeat = true; } @@ -199,15 +198,15 @@ void Room::loadRoomData(const byte *roomData) { // Load script data _vm->_scripts->freeScriptData(); if (roomInfo._scriptFile._fileNum != -1) { - const byte *data = _vm->_files->loadFile(roomInfo._scriptFile); - _vm->_scripts->setScript(data, _vm->_files->_filesize); + Resource *newScript = _vm->_files->loadFile(roomInfo._scriptFile); + _vm->_scripts->setScript(newScript); } // Load animation data _vm->_animation->freeAnimationData(); if (roomInfo._animFile._fileNum != -1) { - byte *data = _vm->_files->loadFile(roomInfo._animFile); - _vm->_animation->loadAnimations(data, _vm->_files->_filesize); + Resource *anim = _vm->_files->loadFile(roomInfo._animFile); + _vm->_animation->loadAnimations(anim); } _vm->_scale = _vm->_scaleI = roomInfo._scaleI; @@ -325,38 +324,39 @@ void Room::buildRow(int playY, int screenY) { } void Room::loadPlayField(int fileNum, int subfile) { - byte *playData = _vm->_files->loadFile(fileNum, subfile); - Common::MemoryReadStream stream(playData + 0x10, _vm->_files->_filesize - 0x10); + Resource *playData = _vm->_files->loadFile(fileNum, subfile); + byte header[16]; + playData->_stream->read(&header[0], 16); Screen &screen = *_vm->_screen; // Copy the new palette - screen.loadRawPalette(&stream); + screen.loadRawPalette(playData->_stream); // Copy off the tile data - _tileSize = playData[2] << 8; + _tileSize = (int)header[2] << 8; _tile = new byte[_tileSize]; - stream.read(_tile, _tileSize); + playData->_stream->read(_tile, _tileSize); // Copy off the playfield data - _matrixSize = playData[0] * playData[1]; + _matrixSize = header[0] * header[1]; _playField = new byte[_matrixSize]; - stream.read(_playField, _matrixSize); + playData->_stream->read(_playField, _matrixSize); // Load the plotter data int numWalls = READ_LE_UINT16(playData + 6); - int numBlocks = playData[8]; - _plotter.load(&stream, numWalls, numBlocks); + int numBlocks = header[8]; + _plotter.load(playData->_stream, numWalls, numBlocks); - _playFieldWidth = playData[0]; - _playFieldHeight = playData[1]; - screen._vWindowWidth = playData[3]; + _playFieldWidth = header[0]; + _playFieldHeight = header[1]; + screen._vWindowWidth = header[3]; screen._vWindowBytesWide = screen._vWindowWidth << 4; screen._bufferBytesWide = screen._vWindowBytesWide + 16; - screen._vWindowHeight = playData[4]; + screen._vWindowHeight = header[4]; screen._vWindowLinesTall = screen._vWindowHeight << 4; _vm->_screen->setBufferScan(); - delete[] playData; + delete playData; } /*------------------------------------------------------------------------*/ @@ -502,9 +502,9 @@ void Room::executeCommand(int commandId) { _vm->_screen->setDisplayScan(); // Get the toolbar icons resource - byte *iconData = _vm->_files->loadFile("ICONS.LZ"); - SpriteResource *spr = new SpriteResource(_vm, iconData, _vm->_files->_filesize); - delete[] iconData; + Resource *iconData = _vm->_files->loadFile("ICONS.LZ"); + SpriteResource *spr = new SpriteResource(_vm, iconData); + delete iconData; // Draw the button as selected _vm->_screen->plotImage(spr, _selectCommand + 2, diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 4f2ee3e3ac..4b1c6d824d 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -104,9 +104,10 @@ void Screen::loadPalette(Common::SeekableReadStream *stream) { } void Screen::loadPalette(int fileNum, int subfile) { - byte *palette = _vm->_files->loadFile(fileNum, subfile); + Resource *res = _vm->_files->loadFile(fileNum, subfile); + byte *palette = res->data(); Common::copy(palette, palette + (_numColors * 3), &_rawPalette[_startColor * 3]); - delete[] palette; + delete res; } void Screen::setPalette() { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 833aff337a..5e0986e379 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -30,7 +30,7 @@ namespace Access { Scripts::Scripts(AccessEngine *vm) : Manager(vm) { - _rawData = nullptr; + _resource = nullptr; _data = nullptr; _sequence = 0; _endFlag = false; @@ -45,16 +45,15 @@ Scripts::~Scripts() { freeScriptData(); } -void Scripts::setScript(const byte *data, int size) { - _rawData = data; - _data = new Common::MemoryReadStream(data, size, DisposeAfterUse::NO); +void Scripts::setScript(Resource *res) { + _resource = res; + _data = res->_stream; } void Scripts::freeScriptData() { - delete[] _rawData; - delete _data; + delete _resource; + _resource = nullptr; _data = nullptr; - _rawData = nullptr; } void Scripts::searchForSequence() { @@ -418,13 +417,13 @@ void Scripts::cmdSetTravel() { } void Scripts::cmdSetVideo() { - FileIdent fi; - fi._fileNum = _data->readSint16LE(); - fi._subfile = _data->readUint16LE(); + Common::Point pt; + pt.x = _data->readSint16LE(); + pt.y = _data->readSint16LE(); int cellIndex = _data->readUint16LE(); int rate = _data->readUint16LE(); - _vm->_video->setVideo(_vm->_extraCells[cellIndex]._vid, fi, rate); + _vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate); } void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); } @@ -654,7 +653,7 @@ void Scripts::cmdClearBlock() { void Scripts::cmdLoadSound() { int idx = _data->readSint16LE(); - _vm->_sound->_soundTable[0]._data = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); + _vm->_sound->_soundTable[0] = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); _vm->_sound->_soundPriority[0] = 1; } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index aa5c4063f6..ec386cf35a 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -34,11 +34,11 @@ class Scripts; class Scripts: public Manager { private: - const byte *_rawData; + Resource *_resource; int _specialFunction; protected: - Common::MemoryReadStream *_data; + Common::SeekableReadStream *_data; virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); @@ -134,7 +134,7 @@ public: virtual ~Scripts(); - void setScript(const byte *data, int size); + void setScript(Resource *data); void freeScriptData(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index aebd76fe84..c032f6cfd2 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -31,10 +31,9 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); for (int i = 0; i < MAX_SOUNDS; ++i) - _soundTable[i]._data = nullptr; + _soundTable[i] = nullptr; _music = nullptr; - _midiSize = 0; _musicRepeat = false; _soundFrame = 0; _soundFlag = false; @@ -42,7 +41,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : SoundManager::~SoundManager() { for (int i = 0; i < MAX_SOUNDS; ++i) - delete _soundTable[i]._data; + delete _soundTable[i]; } void SoundManager::queueSound(int idx, int fileNum, int subfile) { @@ -52,13 +51,13 @@ void SoundManager::queueSound(int idx, int fileNum, int subfile) { */ } -byte *SoundManager::loadSound(int fileNum, int subfile) { +Resource *SoundManager::loadSound(int fileNum, int subfile) { return _vm->_files->loadFile(fileNum, subfile); } void SoundManager::playSound(int soundIndex) { int idx = _soundPriority[soundIndex - 1] - 1; - playSound(_soundTable[idx]._data, _soundTable[idx]._size); + playSound(_soundTable[idx]->data(), _soundTable[idx]->_size); } void SoundManager::playSound(byte *data, uint32 size) { diff --git a/engines/access/sound.h b/engines/access/sound.h index e0992db0e2..284fa845e7 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "audio/mixer.h" +#include "access/files.h" #define MAX_SOUNDS 20 @@ -33,10 +34,6 @@ namespace Access { class AccessEngine; class SoundManager { - struct SoundEntry { - byte *_data; - uint32 _size; - }; private: AccessEngine *_vm; Audio::Mixer *_mixer; @@ -44,10 +41,9 @@ private: void playSound(byte *data, uint32 size); public: - SoundEntry _soundTable[MAX_SOUNDS]; + Resource *_soundTable[MAX_SOUNDS]; int _soundPriority[MAX_SOUNDS]; - byte *_music; - int _midiSize; + Resource *_music; bool _musicRepeat; int _soundFrame; bool _soundFlag; @@ -59,7 +55,7 @@ public: void playSound(int soundIndex); - byte *loadSound(int fileNum, int subfile); + Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); void midiPlay(); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index a025d31022..4774703a03 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -21,15 +21,37 @@ */ #include "access/video.h" +#include "access/access.h" namespace Access { VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { + _vidSurface = nullptr; +} +VideoPlayer::~VideoPlayer() { + freeVideo(); } -void VideoPlayer::setVideo(FileIdent &fi1, FileIdent &fi2, int rate) { - error("TODO: setVideo"); + +void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate) { + _vidSurface = vidSurface; + vidSurface->_orgX1 = pt.x; + vidSurface->_orgY1 = pt.y; + _vm->_timers[31]._timer = rate; + _vm->_timers[31]._initTm = rate; + + // Open up video stream + _videoData = _vm->_files->loadFile(videoFile); + + // Load in header + } +void VideoPlayer::freeVideo() { + delete _videoData; + _videoData = nullptr; +} + + } // End of namespace Access diff --git a/engines/access/video.h b/engines/access/video.h index b21f006a97..a87c90ccb8 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -24,16 +24,27 @@ #define ACCESS_VIDEO_H #include "common/scummsys.h" +#include "common/memstream.h" #include "access/data.h" +#include "access/asurface.h" #include "access/files.h" namespace Access { class VideoPlayer: public Manager { +private: + ASurface *_vidSurface; + Resource *_videoData; + int _frameCount; + int _width, _height; + int _flags; public: VideoPlayer(AccessEngine *vm); + ~VideoPlayer(); - void setVideo(FileIdent &fi1, FileIdent &fi2, int rate); + void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate); + + void freeVideo(); }; } // End of namespace Access -- cgit v1.2.3 From 35923890ccb26d958d33c6c472a1b16659718392 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:22:33 -0400 Subject: ACCESS: Fix incorrect use of delete[] on Resources --- engines/access/access.cpp | 2 +- engines/access/room.cpp | 2 +- engines/access/sound.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 080cd36032..7189ebb799 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -226,7 +226,7 @@ void AccessEngine::freeCells() { } void AccessEngine::freeInactiveData() { - delete[] _inactive; + delete _inactive; _inactive = nullptr; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0c60f7b818..0de6497422 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -143,7 +143,7 @@ void Room::doRoom() { void Room::clearRoom() { if (_vm->_sound->_music) { _vm->_sound->stopSong(); - delete[] _vm->_sound->_music; + delete _vm->_sound->_music; _vm->_sound->_music = nullptr; } diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index c032f6cfd2..bdf8c224e4 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -90,7 +90,7 @@ void SoundManager::freeSounds() { } void SoundManager::freeMusic() { - delete[] _music; + delete _music; _music = nullptr; } -- cgit v1.2.3 From 3bbec487a53243464030fe1946f833971d6e14c0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:34:50 -0400 Subject: ACCESS: Fixes for memory leaks --- engines/access/files.cpp | 2 ++ engines/access/files.h | 2 +- engines/access/room.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 78cb3eff51..233d040745 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -51,9 +51,11 @@ CellIdent::CellIdent(int cell, int fileNum, int subfile) { Resource::Resource() { _stream = nullptr; _size = 0; + _data = nullptr; } Resource::~Resource() { + delete _data; delete _stream; } diff --git a/engines/access/files.h b/engines/access/files.h index 457cb81f86..0a934de8aa 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -101,7 +101,7 @@ public: /** * Check the existence of a given file */ - bool FileManager::existFile(const Common::String &filename); + bool existFile(const Common::String &filename); /** * Load a given subfile from a container file diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 0de6497422..a33bc76e66 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -207,6 +207,7 @@ void Room::loadRoomData(const byte *roomData) { if (roomInfo._animFile._fileNum != -1) { Resource *anim = _vm->_files->loadFile(roomInfo._animFile); _vm->_animation->loadAnimations(anim); + delete anim; } _vm->_scale = _vm->_scaleI = roomInfo._scaleI; -- cgit v1.2.3 From 5abe5b89932adfcc705beb7529d323aa15a85bbd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 27 Aug 2014 22:39:37 -0400 Subject: ACCESS: Fix loading of room playfield data --- engines/access/room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a33bc76e66..b9a07ea2ed 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -344,7 +344,7 @@ void Room::loadPlayField(int fileNum, int subfile) { playData->_stream->read(_playField, _matrixSize); // Load the plotter data - int numWalls = READ_LE_UINT16(playData + 6); + int numWalls = READ_LE_UINT16(&header[6]); int numBlocks = header[8]; _plotter.load(playData->_stream, numWalls, numBlocks); -- cgit v1.2.3 From 819cad3a179260d0b0a973342765a0caff4b13b4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 07:36:11 -0400 Subject: ACCESS: Implemented setVideo --- engines/access/access.cpp | 3 +++ engines/access/access.h | 1 + engines/access/video.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ engines/access/video.h | 20 ++++++++++++++++++-- 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 7189ebb799..92ded4facf 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -71,6 +71,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleI = 0; _scaleFlag = false; _eseg = nullptr; + _plotBuffer = nullptr; _conversation = 0; _currentMan = 0; @@ -128,6 +129,8 @@ AccessEngine::~AccessEngine() { delete _inactive; delete _music; delete _title; + delete _eseg; + delete _plotBuffer; } void AccessEngine::setVGA() { diff --git a/engines/access/access.h b/engines/access/access.h index 55810e8a16..8e05da7104 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -129,6 +129,7 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; + byte *_plotBuffer; Common::Array _charTable; SpriteResource *_objectsTable[100]; bool _establishTable[100]; diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 4774703a03..da397a4359 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -45,7 +45,37 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId _videoData = _vm->_files->loadFile(videoFile); // Load in header + _frameCount = _videoData->_stream->readUint16LE(); + _header._width = _videoData->_stream->readUint16LE(); + _header._height = _videoData->_stream->readUint16LE(); + _videoData->_stream->skip(1); + _header._flags = (VideoFlags)_videoData->_stream->readByte(); + _startCoord = (byte *)vidSurface->getBasePtr(pt.x, pt.y); + _frameCount = _header._frameCount - 2; + _xCount = _header._width; + _scanCount = _header._height; + _vidFrame = 0; + + getFrame(); + + if (_header._flags == VIDEOFLAG_BG) { + // Draw the background + const byte *pSrc = _vm->_plotBuffer; + for (int y = 0; y < _scanCount; ++y) { + byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y); + Common::copy(pSrc, pSrc + _xCount, pDest); + pSrc += _xCount; + } + + if (vidSurface == _vm->_screen) + _vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount)); + + + getFrame(); + } + + _videoEnd = false; } void VideoPlayer::freeVideo() { @@ -53,5 +83,18 @@ void VideoPlayer::freeVideo() { _videoData = nullptr; } +void VideoPlayer::getFrame() { + _frameSize = _videoData->_stream->readUint16LE(); + _videoData->_stream->read(_vm->_plotBuffer, _frameSize); +} + +void VideoPlayer::playVideo() { + if (_vm->_timers[31]._flag) + return; + ++_vm->_timers[31]._flag; + + +} + } // End of namespace Access diff --git a/engines/access/video.h b/engines/access/video.h index a87c90ccb8..7fa1ad2d27 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -31,13 +31,29 @@ namespace Access { +enum VideoFlags { VIDEOFLAG_NONE = 0, VIDEOFLAG_BG = 1 }; + class VideoPlayer: public Manager { + struct VideoHeader { + int _frameCount; + int _width, _height; + VideoFlags _flags; + }; private: ASurface *_vidSurface; Resource *_videoData; + VideoHeader _header; + byte *_startCoord; int _frameCount; - int _width, _height; - int _flags; + int _xCount; + int _scanCount; + int _vidFrame; + int _frameSize; + bool _videoEnd; + + void getFrame(); + + void playVideo(); public: VideoPlayer(AccessEngine *vm); ~VideoPlayer(); -- cgit v1.2.3 From e57d7e8782e1be66a23166b04d6bec658ed2be80 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 20:02:35 -0400 Subject: ACCESS: Implemented playVideo --- engines/access/access.cpp | 2 -- engines/access/access.h | 1 - engines/access/scripts.cpp | 22 +++++++++++++++------ engines/access/scripts.h | 4 ++-- engines/access/sound.cpp | 2 -- engines/access/sound.h | 2 -- engines/access/video.cpp | 49 +++++++++++++++++++++++++++++++++++++--------- engines/access/video.h | 20 +++++++++++++++---- 8 files changed, 74 insertions(+), 28 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 92ded4facf..e02b0c0da8 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -71,7 +71,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleI = 0; _scaleFlag = false; _eseg = nullptr; - _plotBuffer = nullptr; _conversation = 0; _currentMan = 0; @@ -130,7 +129,6 @@ AccessEngine::~AccessEngine() { delete _music; delete _title; delete _eseg; - delete _plotBuffer; } void AccessEngine::setVGA() { diff --git a/engines/access/access.h b/engines/access/access.h index 8e05da7104..55810e8a16 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -129,7 +129,6 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; - byte *_plotBuffer; Common::Array _charTable; SpriteResource *_objectsTable[100]; bool _establishTable[100]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 5e0986e379..2d6fc5040b 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -103,7 +103,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, - &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::CMDPLAYVID, + &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, @@ -112,7 +112,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, - &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::CMDPLAYVIDSND, + &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, @@ -426,7 +426,9 @@ void Scripts::cmdSetVideo() { _vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate); } -void Scripts::CMDPLAYVID() { error("TODO CMDPLAYVID"); } +void Scripts::cmdPlayVideo() { + _vm->_video->playVideo(); +} void Scripts::cmdPlotImage() { _vm->_destIn = _vm->_current; @@ -667,11 +669,19 @@ void Scripts::cmdSetVideoSound() { cmdSetVideo(); _data->skip(2); - _vm->_sound->_soundFrame = _data->readUint16LE(); - _vm->_sound->_soundFlag = false; + _vm->_video->_soundFrame = _data->readUint16LE(); + _vm->_video->_soundFlag = false; +} + +void Scripts::cmdPlayVideoSound() { + _vm->_video->playVideo(); + if (_vm->_video->_soundFrame == _vm->_video->_videoFrame && + !_vm->_video->_soundFlag) { + _vm->_sound->playSound(0); + _vm->_video->_soundFlag = true; + } } -void Scripts::CMDPLAYVIDSND() { error("TODO CMDPLAYVIDSND"); } void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } void Scripts::cmdPlayerOff() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ec386cf35a..414ba46f81 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -91,7 +91,7 @@ protected: void cmdCheckTimer(); void cmdSetTravel(); void cmdSetVideo(); - void CMDPLAYVID(); + void cmdPlayVideo(); void cmdPlotImage(); void cmdSetDisplay(); void cmdSetBuffer(); @@ -114,7 +114,7 @@ protected: void cmdClearBlock(); void cmdLoadSound(); void cmdSetVideoSound(); - void CMDPLAYVIDSND(); + void cmdPlayVideoSound(); void CMDPUSHLOCATION(); void cmdPlayerOff(); void cmdPlayerOn(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index bdf8c224e4..2b8e6a7bf1 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -35,8 +35,6 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _music = nullptr; _musicRepeat = false; - _soundFrame = 0; - _soundFlag = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index 284fa845e7..a534eac79f 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -45,8 +45,6 @@ public: int _soundPriority[MAX_SOUNDS]; Resource *_music; bool _musicRepeat; - int _soundFrame; - bool _soundFlag; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index da397a4359..4c380ff915 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -27,10 +27,13 @@ namespace Access { VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _vidSurface = nullptr; + _videoFrame = 0; + _soundFlag = false; + _soundFrame = 0; } VideoPlayer::~VideoPlayer() { - freeVideo(); + closeVideo(); } @@ -55,37 +58,33 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId _frameCount = _header._frameCount - 2; _xCount = _header._width; _scanCount = _header._height; - _vidFrame = 0; + _videoFrame = 0; getFrame(); if (_header._flags == VIDEOFLAG_BG) { // Draw the background - const byte *pSrc = _vm->_plotBuffer; for (int y = 0; y < _scanCount; ++y) { byte *pDest = (byte *)vidSurface->getBasePtr(pt.x, pt.y + y); - Common::copy(pSrc, pSrc + _xCount, pDest); - pSrc += _xCount; + _videoData->_stream->read(pDest, _xCount); } if (vidSurface == _vm->_screen) _vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount)); - - + getFrame(); } _videoEnd = false; } -void VideoPlayer::freeVideo() { +void VideoPlayer::closeVideo() { delete _videoData; _videoData = nullptr; } void VideoPlayer::getFrame() { _frameSize = _videoData->_stream->readUint16LE(); - _videoData->_stream->read(_vm->_plotBuffer, _frameSize); } void VideoPlayer::playVideo() { @@ -93,7 +92,39 @@ void VideoPlayer::playVideo() { return; ++_vm->_timers[31]._flag; + byte *pDest = _startCoord; + byte *pLine = _startCoord; + uint32 frameEnd = _videoData->_stream->pos() + _frameSize; + + while ((uint32)_videoData->_stream->pos() < frameEnd) { + int count = _videoData->_stream->readByte(); + + if (count & 0x80) { + count &= 0x7f; + + // Skip count number of pixels + // Loop across lines if necessary + while ((pDest - pLine + count) >= _xCount) { + pLine += _vidSurface->pitch; + pDest = pLine; + count -= _xCount; + } + + // Skip any remaining pixels in the new line + pDest += count; + } else { + // Readcount number of pixels + assert(count <= (pDest - pLine)); + _videoData->_stream->read(pDest, count); + pDest += count; + } + } + getFrame(); + if (++_videoFrame == _frameCount) { + closeVideo(); + _videoEnd = true; + } } diff --git a/engines/access/video.h b/engines/access/video.h index 7fa1ad2d27..20e5cfc10e 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -47,20 +47,32 @@ private: int _frameCount; int _xCount; int _scanCount; - int _vidFrame; int _frameSize; bool _videoEnd; void getFrame(); - - void playVideo(); +public: + int _videoFrame; + bool _soundFlag; + int _soundFrame; public: VideoPlayer(AccessEngine *vm); ~VideoPlayer(); + /** + * Start up a video + */ void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate); - void freeVideo(); + /** + * Decodes a frame of the video + */ + void playVideo(); + + /** + * Frees the data for a previously loaded video + */ + void closeVideo(); }; } // End of namespace Access -- cgit v1.2.3 From 1d8f23985aa8eaf718388ba3d6ccae5824a530aa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 20:24:25 -0400 Subject: ACCESS: Implement loadSounds --- engines/access/sound.cpp | 31 ++++++++++++++++++------------- engines/access/sound.h | 8 +++++--- engines/access/video.cpp | 1 + 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2b8e6a7bf1..d932cc6e44 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -29,24 +29,24 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { - Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); - for (int i = 0; i < MAX_SOUNDS; ++i) - _soundTable[i] = nullptr; - _music = nullptr; _musicRepeat = false; } SoundManager::~SoundManager() { - for (int i = 0; i < MAX_SOUNDS; ++i) + clearSounds(); +} + +void SoundManager::clearSounds() { + for (int i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]; + _soundTable.clear(); + _soundPriority.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { - /* - _soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile); - _soundTable[idx]._size = _vm->_files->_filesize; - */ + delete _soundTable[idx]; + _soundTable[idx] = _vm->_files->loadFile(fileNum, subfile); } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -54,11 +54,11 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int idx = _soundPriority[soundIndex - 1] - 1; - playSound(_soundTable[idx]->data(), _soundTable[idx]->_size); + int idx = _soundPriority[soundIndex]; + playSound(_soundTable[idx]); } -void SoundManager::playSound(byte *data, uint32 size) { +void SoundManager::playSound(Resource *res) { /* Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); @@ -68,7 +68,12 @@ void SoundManager::playSound(byte *data, uint32 size) { } void SoundManager::loadSounds(Common::Array &sounds) { - // TODO + clearSounds(); + + for (uint i = 0; i < sounds.size(); ++i) { + _soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile)); + _soundPriority.push_back(sounds[i]._priority); + } } void SoundManager::midiPlay() { diff --git a/engines/access/sound.h b/engines/access/sound.h index a534eac79f..8fef9e35fb 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -39,10 +39,12 @@ private: Audio::Mixer *_mixer; Audio::SoundHandle _soundHandle; - void playSound(byte *data, uint32 size); + void clearSounds(); + + void playSound(Resource *res); public: - Resource *_soundTable[MAX_SOUNDS]; - int _soundPriority[MAX_SOUNDS]; + Common::Array _soundTable; + Common::Array _soundPriority; Resource *_music; bool _musicRepeat; public: diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 4c380ff915..8197b91923 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -30,6 +30,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _videoFrame = 0; _soundFlag = false; _soundFrame = 0; + _videoData = nullptr; } VideoPlayer::~VideoPlayer() { -- cgit v1.2.3 From 729f03f42c88f2caaa6616e530cf4543a6cca536 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 21:36:48 -0400 Subject: ACCESS: Fixes for playVideo --- engines/access/scripts.cpp | 1 - engines/access/video.cpp | 26 +++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2d6fc5040b..f92a6d73a5 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -668,7 +668,6 @@ void Scripts::cmdSetVideoSound() { _data->seek(startPos); cmdSetVideo(); - _data->skip(2); _vm->_video->_soundFrame = _data->readUint16LE(); _vm->_video->_soundFlag = false; } diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 8197b91923..4b9a875931 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -49,7 +49,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileId _videoData = _vm->_files->loadFile(videoFile); // Load in header - _frameCount = _videoData->_stream->readUint16LE(); + _header._frameCount = _videoData->_stream->readUint16LE(); _header._width = _videoData->_stream->readUint16LE(); _header._height = _videoData->_stream->readUint16LE(); _videoData->_stream->skip(1); @@ -105,19 +105,31 @@ void VideoPlayer::playVideo() { // Skip count number of pixels // Loop across lines if necessary - while ((pDest - pLine + count) >= _xCount) { + while (count >= (pLine + _xCount - pDest)) { + count -= (pLine + _xCount - pDest); pLine += _vidSurface->pitch; pDest = pLine; - count -= _xCount; } // Skip any remaining pixels in the new line pDest += count; } else { - // Readcount number of pixels - assert(count <= (pDest - pLine)); - _videoData->_stream->read(pDest, count); - pDest += count; + // Read count number of pixels + + // Load across lines if necessary + while (count >= (pLine + _xCount - pDest)) { + int lineCount = (pLine + _xCount - pDest); + _videoData->_stream->read(pDest, lineCount); + count -= lineCount; + pLine += _vidSurface->pitch; + pDest = pLine; + } + + // Load remainder of pixels on line + if (count > 0) { + _videoData->_stream->read(pDest, count); + pDest += count; + } } } -- cgit v1.2.3 From 661a5694b4bf91e61d62fbabf0294c5815cf85f6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 21:40:59 -0400 Subject: ACCESS: Implemented cmdVideoEnded --- engines/access/scripts.cpp | 10 ++++++++-- engines/access/scripts.h | 2 +- engines/access/video.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index f92a6d73a5..ad806de056 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -105,7 +105,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, - &Scripts::cmdSetScroll, &Scripts::CMDSAVERECT, &Scripts::CMDSAVERECT, + &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, @@ -457,7 +457,13 @@ void Scripts::cmdSetScroll() { _vm->_screen->_scrollY = 0; } -void Scripts::CMDSAVERECT() { error("TODO CMDSAVERECT"); } +void Scripts::cmdVideoEnded() { + if (_vm->_video->_videoEnd) + cmdGoto(); + else + _data->skip(2); +} + void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); } void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 414ba46f81..7568e033c0 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -96,7 +96,7 @@ protected: void cmdSetDisplay(); void cmdSetBuffer(); void cmdSetScroll(); - void CMDSAVERECT(); + void cmdVideoEnded(); void CMDSETBUFVID(); void CMDPLAYBUFVID(); void cmdRemoveLast(); diff --git a/engines/access/video.h b/engines/access/video.h index 20e5cfc10e..bb9656b296 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -48,13 +48,13 @@ private: int _xCount; int _scanCount; int _frameSize; - bool _videoEnd; void getFrame(); public: int _videoFrame; bool _soundFlag; int _soundFrame; + bool _videoEnd; public: VideoPlayer(AccessEngine *vm); ~VideoPlayer(); -- cgit v1.2.3 From a47457084f10faf49f002a0350bc9a832309e11d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 21:55:09 -0400 Subject: ACCESS: Add event polling to cmdVideoEnded to make videos play correctly --- engines/access/scripts.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index ad806de056..c5b7d952da 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -458,10 +458,14 @@ void Scripts::cmdSetScroll() { } void Scripts::cmdVideoEnded() { - if (_vm->_video->_videoEnd) + _vm->_events->pollEvents(); + + if (_vm->_video->_videoEnd) { cmdGoto(); - else + } else { + g_system->delayMillis(10); _data->skip(2); + } } void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); } -- cgit v1.2.3 From d31a0f152ff0a80f382d0e868562867fcf7fe305 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 22:01:38 -0400 Subject: ACCESS: Fix background display during character conversations --- engines/access/char.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 767512f43e..aebf63a131 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -104,7 +104,7 @@ void CharManager::loadChar(int charId) { } _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->copyFrom(_vm->_buffer2); + _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_screen->setDisplayScan(); if (_charFlag != 2 && _charFlag != 3) { -- cgit v1.2.3 From d2cb9d4c4318e9c1895e492539c755fb6e3cf052 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 22:15:39 -0400 Subject: ACCESS: Implemented cmdFreeSound --- engines/access/access.cpp | 4 ++-- engines/access/scripts.cpp | 40 +++++++++++++++++++++++++++++++++++++--- engines/access/scripts.h | 3 ++- engines/access/sound.cpp | 1 + engines/access/sound.h | 1 + 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index e02b0c0da8..3e8eff3614 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -256,7 +256,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; _sound->playSound(1); - _scripts->CMDFREESOUND(); + _scripts->cmdFreeSound(); _events->pollEvents(); @@ -291,7 +291,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; _sound->playSound(1); - _scripts->CMDFREESOUND(); + _scripts->cmdFreeSound(); _events->pollEvents(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index c5b7d952da..a1ede67708 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -67,6 +67,24 @@ void Scripts::searchForSequence() { } while (sequenceId != _sequence); } +void Scripts::charLoop() { + bool endFlag = _endFlag; + int pos = _data->pos(); + + _sequence = 2000; + searchForSequence(); + _vm->_images.clear(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_newRects.clear(); + + executeScript(); + _vm->plotList1(); + _vm->copyBlocks(); + + _data->seek(pos); + _endFlag = endFlag; +} + void Scripts::findNull() { // No implementation required in ScummVM, the strings in the script files are already skipped by the use of readByte() } @@ -112,7 +130,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, - &Scripts::CMDFREESOUND, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, + &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, @@ -608,7 +626,7 @@ void Scripts::cmdTexChoice() { int choice = -1; do { - warning("TODO CHARLOOP"); + charLoop(); _vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str(); if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { @@ -669,7 +687,23 @@ void Scripts::cmdLoadSound() { _vm->_sound->_soundPriority[0] = 1; } -void Scripts::CMDFREESOUND() { warning("TODO CMDFREESOUND"); } +void Scripts::cmdFreeSound() { + SoundManager &sound = *_vm->_sound; + + if (sound._soundTable.size() > 0 && sound._soundTable[0]) { + // Keep doing char display loop if playing sound for it + do { + if (_vm->_flags[236] == 1) + charLoop(); + + _vm->_events->pollEvents(); + } while (!_vm->shouldQuit() && sound._playingSound); + + // Free the sound + delete sound._soundTable[0]; + sound._soundTable[0] = nullptr; + } +} void Scripts::cmdSetVideoSound() { uint32 startPos = _data->pos(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 7568e033c0..733c7f9dd7 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -37,6 +37,7 @@ private: Resource *_resource; int _specialFunction; + void charLoop(); protected: Common::SeekableReadStream *_data; @@ -144,7 +145,7 @@ public: void findNull(); - void CMDFREESOUND(); + void cmdFreeSound(); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index d932cc6e44..52d9d00e08 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -31,6 +31,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _music = nullptr; _musicRepeat = false; + _playingSound = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index 8fef9e35fb..1a94c46773 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -47,6 +47,7 @@ public: Common::Array _soundPriority; Resource *_music; bool _musicRepeat; + bool _playingSound; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); -- cgit v1.2.3 From bbe7616a198b0220a038028337127fecfea842ca Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 29 Aug 2014 07:21:44 -0400 Subject: ACCESS: Add event polling to cmdTexChoice so conversations work --- engines/access/scripts.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index a1ede67708..3b03a7ac41 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -626,7 +626,12 @@ void Scripts::cmdTexChoice() { int choice = -1; do { + _vm->_events->pollEvents(); + if (_vm->shouldQuit()) + return; + charLoop(); + _vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str(); if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { -- cgit v1.2.3 From 0ef365ab025cb77ab40e95e5e9139a5f86168fa6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 29 Aug 2014 07:31:23 -0400 Subject: ACCESS: Fix errors in loadScreen since resource refactoring --- engines/access/files.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 233d040745..4ab98a2060 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -137,6 +137,11 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { _vm->_screen->loadPalette(res->_stream); + // The remainder of the file after the palette may be separately compressed, + // so call handleFile to handle it if it is + res->_size -= res->_stream->pos(); + handleFile(res); + if (dest != _vm->_screen) dest->w = _vm->_screen->w; -- cgit v1.2.3 From 8b9faf7de563b5c3a00cc9935eccb5e60b816632 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 29 Aug 2014 21:03:11 -0400 Subject: ACCESS: Add synchronize method for savegames --- engines/access/access.cpp | 58 +++++++++++++++++++---------------- engines/access/access.h | 9 ++++-- engines/access/amazon/amazon_game.cpp | 40 ++++++++++++++++++++++-- engines/access/amazon/amazon_game.h | 48 +++++++++++++++++++++++++++-- engines/access/data.cpp | 14 +++++++++ engines/access/data.h | 6 ++++ engines/access/inventory.cpp | 10 ++++++ engines/access/inventory.h | 5 +++ engines/access/player.cpp | 8 +++++ engines/access/player.h | 6 ++++ engines/access/sound.cpp | 2 +- 11 files changed, 170 insertions(+), 36 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 3e8eff3614..9525608b2b 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -76,8 +76,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _currentMan = 0; _newTime = 0; _newDate = 0; - _intTim[3] = 0; - _timer[3] = 0; Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); Common::fill(&_establishTable[0], &_establishTable[100], false); Common::fill(&_flags[0], &_flags[256], 0); @@ -180,33 +178,9 @@ Common::Error AccessEngine::run() { playGame(); - dummyLoop(); return Common::kNoError; } -void AccessEngine::dummyLoop() { - // Dummy game loop - while (!shouldQuit()) { - _events->pollEvents(); - - _curTime = g_system->getMillis(); - // Process machine once every tick - while (_curTime - _lastTime < 20) { - g_system->delayMillis(5); - _curTime = g_system->getMillis(); - } - - _lastTime = _curTime; - - g_system->updateScreen(); - - if (_events->_leftButton) { - CursorType cursorId = _events->getCursor(); - _events->setCursor((cursorId == CURSOR_HELP) ? CURSOR_ARROW : (CursorType)(cursorId + 1)); - } - } -} - int AccessEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } @@ -411,4 +385,36 @@ void AccessEngine::freeChar() { _animation->freeAnimationData(); } +void AccessEngine::synchronize(Common::Serializer &s) { + s.syncAsUint16LE(_conversation); + s.syncAsUint16LE(_currentMan); + s.syncAsUint32LE(_newTime); + s.syncAsUint32LE(_newDate); + + for (int i = 0; i < 256; ++i) + s.syncAsUint16LE(_flags[i]); + for (int i = 0; i < 366; ++i) { + s.syncAsByte(_help1[i]); + s.syncAsByte(_help2[i]); + s.syncAsByte(_help3[i]); + } + + s.syncAsUint16LE(_travel); + s.syncAsUint16LE(_ask); + s.syncAsUint16LE(_rScrollRow); + s.syncAsUint16LE(_rScrollCol); + s.syncAsSint16LE(_rScrollX); + s.syncAsSint16LE(_rScrollY); + s.syncAsUint16LE(_rOldRectCount); + s.syncAsUint16LE(_rNewRectCount); + s.syncAsUint16LE(_rKeyFlag); + s.syncAsUint16LE(_mapOffset); + s.syncAsUint16LE(_screenVirtX); + + // Synchronize sub-objects + _timers.synchronize(s); + _inventory->synchronize(s); + _player->synchronize(s); +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 55810e8a16..7d76be9039 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -27,6 +27,7 @@ #include "common/system.h" #include "common/error.h" #include "common/random.h" +#include "common/serializer.h" #include "common/util.h" #include "engines/engine.h" #include "graphics/surface.h" @@ -90,7 +91,6 @@ private: */ void setVGA(); - void dummyLoop(); protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; @@ -110,6 +110,11 @@ protected: * Play the game */ virtual void playGame() = 0; + + /** + * Synchronize savegame data + */ + virtual void synchronize(Common::Serializer &s); public: AnimationManager *_animation; BubbleBox *_bubbleBox; @@ -177,8 +182,6 @@ public: int _currentMan; uint32 _newTime; uint32 _newDate; - int _intTim[3]; - int _timer[3]; int _flags[256]; byte _help1[366]; byte _help2[366]; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index cf383ce45a..0ccaae85dc 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -44,7 +44,7 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _hitCount = 0; _saveRiver = 0; _hitSafe = 0; - _oldTitleChap = _chapter = 0; + _oldTitleChapter = _chapter = 0; _updateChapter = -1; _topList = 0; _botList = 0; @@ -291,10 +291,10 @@ void AmazonEngine::tileScreen() { if (!_screen->_vesaMode) return; - if (!_clearSummaryFlag && (_oldTitleChap == _chapter)) + if (!_clearSummaryFlag && (_oldTitleChapter == _chapter)) return; - _oldTitleChap = _chapter; + _oldTitleChapter = _chapter; int idx = _chapter - 1; if (!_files->existFile(_tileFiles[idx])) @@ -361,6 +361,40 @@ void AmazonEngine::drawHelp() { error("TODO: drawHelp"); } +void AmazonEngine::synchronize(Common::Serializer &s) { + AccessEngine::synchronize(s); + + s.syncAsSint16LE(_canoeLane); + s.syncAsSint16LE(_canoeYPos); + s.syncAsSint16LE(_hitCount); + s.syncAsSint16LE(_saveRiver); + s.syncAsSint16LE(_hitSafe); + s.syncAsSint16LE(_chapter); + s.syncAsSint16LE(_topList); + s.syncAsSint16LE(_botList); + s.syncAsSint16LE(_riverIndex); + s.syncAsSint16LE(_rawInactiveX); + s.syncAsSint16LE(_rawInactiveY); + s.syncAsSint16LE(_inactiveYOff); + for (int i = 0; i < 100; ++i) + s.syncAsSint16LE(_esTabTable[i]); +} + +/*------------------------------------------------------------------------*/ + +Guard::Guard() { + _guardCel = 0; + _gCode1 = _gCode2 = 0; + _xMid = _yMid = 0; +} + +Plane::Plane() { + _pCount = 0; + _planeCount = 0; + _propCount = 0; + _xCount = 0; +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 59511c4546..6511b377ae 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -29,6 +29,29 @@ namespace Access { namespace Amazon { +class Plane { +public: + int _pCount; + Common::Point _position; + int _planeCount; + int _propCount; + int _xCount; +public: + Plane(); +}; + +class Guard { +public: + int _guardCel; + Common::Point _position; + int _gCode1; + int _gCode2; + Common::Rect _bounds; + int _xMid, _yMid; +public: + Guard(); +}; + class AmazonEngine : public AccessEngine { private: bool _skipStart; @@ -39,7 +62,6 @@ private: int _hitCount; int _saveRiver; int _hitSafe; - int _oldTitleChap; int _topList; int _botList; int _riverIndex; @@ -47,6 +69,8 @@ private: int _rawInactiveY; int _inactiveYOff; int _esTabTable[100]; + + // Other fields Common::Point _tilePos; byte _tileData[1455]; @@ -84,6 +108,11 @@ protected: * Play the game */ virtual void playGame(); + + /** + * Synchronize savegame data + */ + virtual void synchronize(Common::Serializer &s); public: // Fields that are mapped to flags int &_guardLocation; @@ -100,11 +129,24 @@ public: int &_allenFlag; int &_noSound; + // Saved fields + int _chapter; + // Other game specific fields + Guard _guard; + Plane _plane; int _hintLevel; - - int _chapter; int _updateChapter; + int _oldTitleChapter; + int _maxHits; + int _oldScrollCol; + bool _deathFlag; + int _deathCount; + int _deathType; + int _mapPtr; + int _canoeVXPos; + int _canoeMoveCount; + int _canoeFrame; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/data.cpp b/engines/access/data.cpp index 0279cd5052..cbc52c0a26 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -59,4 +59,18 @@ void TimerList::updateTimers() { } } +void TimerList::synchronize(Common::Serializer &s) { + int count = size(); + s.syncAsUint16LE(count); + + if (!s.isSaving()) + resize(count); + + for (int i = 0; i < count; ++i) { + s.syncAsUint32LE((*this)[i]._initTm); + s.syncAsUint32LE((*this)[i]._timer); + s.syncAsByte((*this)[i]._flag); + } +} + } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 1d64a6ff86..3b3485e459 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -26,6 +26,7 @@ #include "common/scummsys.h" #include "common/array.h" #include "common/rect.h" +#include "common/serializer.h" #include "common/types.h" #include "graphics/surface.h" #include "access/files.h" @@ -74,6 +75,11 @@ public: * Update the timer list */ void updateTimers(); + + /** + * Synchronize savegame data + */ + void synchronize(Common::Serializer &s); }; class ExtraCell { diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index dbc3cbac89..25c906056f 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -354,5 +354,15 @@ void InventoryManager::combineItems() { warning("TODO: combineItems"); } +void InventoryManager::synchronize(Common::Serializer &s) { + int count = _inv.size(); + s.syncAsUint16LE(count); + + if (!s.isSaving()) + _inv.resize(count); + + for (int i = 0; i < count; ++i) + s.syncAsUint16LE((*this)[i]); +} } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index a95581c2d0..0ff9020250 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -108,6 +108,11 @@ public: void refreshInventory(); int newDisplayInv(); + + /** + * Synchronize savegame data + */ + void synchronize(Common::Serializer &s); }; } // End of namespace Access diff --git a/engines/access/player.cpp b/engines/access/player.cpp index df2ad67826..b8eb08acd8 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -827,4 +827,12 @@ bool Player::scrollRight() { return true; } +void Player::synchronize(Common::Serializer &s) { + s.syncAsUint16LE(_roomNumber); + s.syncAsSint16LE(_rawPlayerLow.x); + s.syncAsSint16LE(_rawPlayer.x); + s.syncAsSint16LE(_rawPlayerLow.y); + s.syncAsSint16LE(_rawPlayer.y); +} + } // End of namespace Access diff --git a/engines/access/player.h b/engines/access/player.h index 7ba0c05b21..c5c9afa087 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/rect.h" +#include "common/serializer.h" #include "access/asurface.h" #include "access/data.h" @@ -127,6 +128,11 @@ public: void calcPlayer(); void checkScroll(); + + /** + * Synchronize savegame data + */ + void synchronize(Common::Serializer &s); }; } // End of namespace Access diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 52d9d00e08..91910f2917 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -39,7 +39,7 @@ SoundManager::~SoundManager() { } void SoundManager::clearSounds() { - for (int i = 0; i < _soundTable.size(); ++i) + for (uint i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]; _soundTable.clear(); _soundPriority.clear(); -- cgit v1.2.3 From 83528083228ea45ec3105b7dbcb720a1ac0dba55 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 08:45:42 -0400 Subject: ACCESS: Added code for reading/writing savegame headers and list saves --- engines/access/access.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++ engines/access/access.h | 16 ++++++++++ engines/access/detection.cpp | 26 +++++++++++++++++ engines/access/events.h | 5 ++++ engines/access/room.cpp | 2 +- engines/access/screen.cpp | 3 ++ engines/access/screen.h | 2 ++ 7 files changed, 122 insertions(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9525608b2b..f6382262fd 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -25,6 +25,8 @@ #include "common/debug-channels.h" #include "common/events.h" #include "engines/util.h" +#include "graphics/scaler.h" +#include "graphics/thumbnail.h" #include "access/access.h" namespace Access { @@ -417,4 +419,71 @@ void AccessEngine::synchronize(Common::Serializer &s) { _player->synchronize(s); } +const char *const SAVEGAME_STR = "ACCESS"; +#define SAVEGAME_STR_SIZE 6 + +bool AccessEngine::readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header) { + char saveIdentBuffer[SAVEGAME_STR_SIZE + 1]; + header._thumbnail = nullptr; + + // Validate the header Id + in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1); + if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE)) + return false; + + header._version = in->readByte(); + if (header._version > ACCESS_SAVEGAME_VERSION) + return false; + + // Read in the string + header._saveName.clear(); + char ch; + while ((ch = (char)in->readByte()) != '\0') header._saveName += ch; + + // Get the thumbnail + header._thumbnail = Graphics::loadThumbnail(*in); + if (!header._thumbnail) + return false; + + // Read in save date/time + header._year = in->readSint16LE(); + header._month = in->readSint16LE(); + header._day = in->readSint16LE(); + header._hour = in->readSint16LE(); + header._minute = in->readSint16LE(); + header._totalFrames = in->readUint32LE(); + + return true; +} + +void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header) { + // Write out a savegame header + out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); + + out->writeByte(ACCESS_SAVEGAME_VERSION); + + // Write savegame name + out->write(header._saveName.c_str(), header._saveName.size()); + out->writeByte('\0'); + + // Write a thumbnail of the screen + uint8 thumbPalette[PALETTE_SIZE]; + _screen->getPalette(thumbPalette); + Graphics::Surface saveThumb; + ::createThumbnail(&saveThumb, (const byte *)_screen->getPixels(), + _screen->w, _screen->h, thumbPalette); + Graphics::saveThumbnail(*out, saveThumb); + saveThumb.free(); + + // Write out the save date/time + TimeDate td; + g_system->getTimeAndDate(td); + out->writeSint16LE(td.tm_year + 1900); + out->writeSint16LE(td.tm_mon + 1); + out->writeSint16LE(td.tm_mday); + out->writeSint16LE(td.tm_hour); + out->writeSint16LE(td.tm_min); + out->writeUint32LE(_events->getFrameCounter()); +} + } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 7d76be9039..a192da3904 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -27,6 +27,7 @@ #include "common/system.h" #include "common/error.h" #include "common/random.h" +#include "common/savefile.h" #include "common/serializer.h" #include "common/util.h" #include "engines/engine.h" @@ -77,6 +78,17 @@ struct AccessGameDescription; extern const char *const _estTable[]; +#define ACCESS_SAVEGAME_VERSION 1 + +struct AccessSavegameHeader { + uint8 _version; + Common::String _saveName; + Graphics::Surface *_thumbnail; + int _year, _month, _day; + int _hour, _minute; + int _totalFrames; +}; + class AccessEngine : public Engine { private: uint32 _lastTime, _curTime; @@ -248,6 +260,10 @@ public: void doLoadSave(); void freeChar(); + + static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header); + + void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header); }; } // End of namespace Access diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index dd75b28177..293cd3dccb 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -136,7 +136,33 @@ bool AccessMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGa } SaveStateList AccessMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = Common::String::format("%s.0??", target); + Access::AccessSavegameHeader header; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + const char *ext = strrchr(file->c_str(), '.'); + int slot = ext ? atoi(ext + 1) : -1; + + if (slot >= 0 && slot < MAX_SAVES) { + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); + + if (in) { + Access::AccessEngine::readSavegameHeader(in, header); + saveList.push_back(SaveStateDescriptor(slot, header._saveName)); + + header._thumbnail->free(); + delete header._thumbnail; + delete in; + } + } + } return saveList; } diff --git a/engines/access/events.h b/engines/access/events.h index fdfb0a5043..014ff239b9 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -70,6 +70,11 @@ public: */ ~EventsManager(); + /** + * Return frame counter + */ + uint32 getFrameCounter() { return _frameCounter; } + /** * Sets the cursor */ diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9a07ea2ed..c9e150f8ea 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -433,7 +433,7 @@ void Room::handleCommand(int commandId) { --commandId; if (commandId == 9) - _vm->doLoadSave(); + _vm->openMainMenuDialog(); else if (commandId == _selectCommand) { _vm->_events->debounceLeft(); commandOff(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 4b1c6d824d..26dd2e93ae 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -141,6 +141,9 @@ void Screen::restorePalette() { &_savedPalettes[_savedPaletteCount][PALETTE_SIZE], &_rawPalette[0]); } +void Screen::getPalette(byte *pal) { + g_system->getPaletteManager()->grabPalette(pal, 0, 256); +} void Screen::forceFadeOut() { const int FADE_AMOUNT = 2; diff --git a/engines/access/screen.h b/engines/access/screen.h index a166fded5e..47e03de2b8 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -131,6 +131,8 @@ public: void restorePalette(); + void getPalette(byte *pal); + /** * Copy a buffer to the screen */ -- cgit v1.2.3 From f12fa2de07694d93a7035875f56f36ed4849275d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 09:57:51 -0400 Subject: ACCESS: Implement saving and loading savegames --- engines/access/access.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++ engines/access/access.h | 33 ++++++++++++++++++++++++ engines/access/detection.cpp | 18 +++++++++++++ engines/access/room.cpp | 9 +++++-- 4 files changed, 119 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f6382262fd..a039139f0a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -72,6 +72,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleMaxY = 0; _scaleI = 0; _scaleFlag = false; + _canSaveLoad = false; _eseg = nullptr; _conversation = 0; @@ -387,6 +388,66 @@ void AccessEngine::freeChar() { _animation->freeAnimationData(); } +Common::Error AccessEngine::saveGameState(int slot, const Common::String &desc) { + Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving( + generateSaveName(slot)); + if (!out) + return Common::kCreatingFileFailed; + + AccessSavegameHeader header; + header._saveName = desc; + writeSavegameHeader(out, header); + + Common::Serializer s(nullptr, out); + synchronize(s); + + out->finalize(); + delete out; + + return Common::kNoError; +} + +Common::Error AccessEngine::loadGameState(int slot) { + Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( + generateSaveName(slot)); + if (!saveFile) + return Common::kReadingFailed; + + Common::Serializer s(saveFile, nullptr); + + // Load the savaegame header + AccessSavegameHeader header; + if (!readSavegameHeader(saveFile, header)) + error("Invalid savegame"); + + if (header._thumbnail) { + header._thumbnail->free(); + delete header._thumbnail; + } + + // Load most of the savegame data + synchronize(s); + delete saveFile; + + // Set extra post-load state + _room->_function = 1; + _timers._timersSavedFlag = false; + + return Common::kNoError; +} + +Common::String AccessEngine::generateSaveName(int slot) { + return Common::String::format("%s.%03d", _targetName.c_str(), slot); +} + +bool AccessEngine::canLoadGameStateCurrently() { + return _canSaveLoad; +} + +bool AccessEngine::canSaveGameStateCurrently() { + return _canSaveLoad; +} + void AccessEngine::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_conversation); s.syncAsUint16LE(_currentMan); diff --git a/engines/access/access.h b/engines/access/access.h index a192da3904..8e7c42f959 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -114,6 +114,12 @@ protected: void speakText(ASurface *s, Common::ArraymsgArr); + /** + * Support method that generates a savegame name + * @param slot Slot number + */ + Common::String AccessEngine::generateSaveName(int slot); + // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; @@ -180,6 +186,7 @@ public: int _scaleMaxY; int _scaleI; bool _scaleFlag; + bool _canSaveLoad; Resource *_eseg; int _et; @@ -261,8 +268,34 @@ public: void freeChar(); + /** + * Load a savegame + */ + virtual Common::Error loadGameState(int slot); + + /** + * Save the game + */ + virtual Common::Error saveGameState(int slot, const Common::String &desc); + + /** + * Returns true if a savegame can currently be loaded + */ + bool canLoadGameStateCurrently(); + + /** + * Returns true if the game can currently be saved + */ + bool canSaveGameStateCurrently(); + + /** + * Read in a savegame header + */ static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header); + /** + * Write out a savegame header + */ void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header); }; diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index 293cd3dccb..59c4bc4738 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -177,6 +177,24 @@ void AccessMetaEngine::removeSaveState(const char *target, int slot) const { } SaveStateDescriptor AccessMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String filename = Common::String::format("%s.%03d", target, slot); + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename); + + if (f) { + Access::AccessSavegameHeader header; + Access::AccessEngine::readSavegameHeader(f, header); + delete f; + + // Create the return descriptor + SaveStateDescriptor desc(slot, header._saveName); + desc.setThumbnail(header._thumbnail); + desc.setSaveDate(header._year, header._month, header._day); + desc.setSaveTime(header._hour, header._minute); + desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME); + + return desc; + } + return SaveStateDescriptor(); } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c9e150f8ea..d4e8886cac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -80,7 +80,10 @@ void Room::doRoom() { } // Handle any events + _vm->_canSaveLoad = true; _vm->_events->pollEvents(); + _vm->_canSaveLoad = false; + g_system->delayMillis(5); _vm->_player->walk(); _vm->_sound->midiRepeat(); @@ -432,9 +435,11 @@ void Room::handleCommand(int commandId) { if (commandId == 1) --commandId; - if (commandId == 9) + if (commandId == 9) { + _vm->_canSaveLoad = true; _vm->openMainMenuDialog(); - else if (commandId == _selectCommand) { + _vm->_canSaveLoad = false; + } else if (commandId == _selectCommand) { _vm->_events->debounceLeft(); commandOff(); } else { -- cgit v1.2.3 From 949033ea9242f8ce0ae7c6906c8c5d6831929056 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 10:57:45 -0400 Subject: ACCESS: Implement loading savegames from launcher --- engines/access/access.cpp | 8 ++++++++ engines/access/access.h | 1 + engines/access/amazon/amazon_game.cpp | 23 +++++++++++++++-------- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a039139f0a..01bb3e3845 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -108,6 +108,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _narateFile = 0; _txtPages = 0; _sndSubFile = 0; + _loadSaveSlot = -1; } AccessEngine::~AccessEngine() { @@ -173,6 +174,13 @@ void AccessEngine::initialize() { _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); _buffer2.create(g_system->getWidth(), g_system->getHeight()); + + // If requested, load a savegame instead of showing the intro + if (ConfMan.hasKey("save_slot")) { + int saveSlot = ConfMan.getInt("save_slot"); + if (saveSlot >= 0 && saveSlot <= 999) + _loadSaveSlot = saveSlot; + } } Common::Error AccessEngine::run() { diff --git a/engines/access/access.h b/engines/access/access.h index 8e7c42f959..2f557df7f8 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -106,6 +106,7 @@ private: protected: const AccessGameDescription *_gameDescription; Common::RandomSource _randomSource; + int _loadSaveSlot; /** * Main handler for showing game rooms diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 0ccaae85dc..ecd9922f78 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -64,10 +64,16 @@ AmazonEngine::~AmazonEngine() { } void AmazonEngine::playGame() { - // Do introduction - doIntroduction(); - if (shouldQuit()) - return; + // Initialise Amazon game-specific objects + _room = new AmazonRoom(this); + _scripts = new AmazonScripts(this); + + if (_loadSaveSlot != -1) { + // Do introduction + doIntroduction(); + if (shouldQuit()) + return; + } // Setup the game setupGame(); @@ -75,12 +81,13 @@ void AmazonEngine::playGame() { _screen->clearScreen(); _screen->setPanel(0); _screen->forceFadeOut(); - _events->showCursor(); - // Setup and execute the room - _room = new AmazonRoom(this); - _scripts = new AmazonScripts(this); + // If there's a pending savegame to load, load it + if (_loadSaveSlot != -1) + loadGameState(_loadSaveSlot); + + // Execute the room _room->doRoom(); } -- cgit v1.2.3 From 2cca520465dd8005aa3ee21b25961afbde227afd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 11:52:48 -0400 Subject: ACCESS: Add new support for mouse wheel for cycling through cursors --- engines/access/events.cpp | 16 ++++++++++++++++ engines/access/events.h | 2 ++ engines/access/room.cpp | 29 ++++++++++++++++++++++++++--- engines/access/room.h | 5 +++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 7366905b0c..0a754305b2 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -40,6 +40,8 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _frameCounter = 10; _priorFrameTime = 0; _leftButton = _rightButton = false; + _middleButton = false; + _wheelUp = _wheelDown = false; _mouseCol = _mouseRow = 0; _cursorExitFlag = false; } @@ -122,6 +124,8 @@ void EventsManager::pollEvents() { nextFrame(); } + _wheelUp = _wheelDown = false; + Common::Event event; while (g_system->getEventManager()->pollEvent(event)) { switch (event.type) { @@ -158,6 +162,18 @@ void EventsManager::pollEvents() { case Common::EVENT_RBUTTONUP: _rightButton = false; return; + case Common::EVENT_MBUTTONDOWN: + _middleButton = true; + return; + case Common::EVENT_MBUTTONUP: + _middleButton = false; + return; + case Common::EVENT_WHEELUP: + _wheelUp = true; + return; + case Common::EVENT_WHEELDOWN: + _wheelDown = true; + return; default: break; } diff --git a/engines/access/events.h b/engines/access/events.h index 014ff239b9..6b46086d9a 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -55,6 +55,8 @@ public: CursorType _cursorId; CursorType _normalMouse; bool _leftButton, _rightButton; + bool _middleButton; + bool _wheelUp, _wheelDown; Common::Point _mousePos; int _mouseCol, _mouseRow; bool _cursorExitFlag; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index d4e8886cac..a7b619c238 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -79,7 +79,7 @@ void Room::doRoom() { _vm->_screen->fadeIn(); } - // Handle any events + // Poll for events _vm->_canSaveLoad = true; _vm->_events->pollEvents(); _vm->_canSaveLoad = false; @@ -408,7 +408,16 @@ void Room::doCommands() { if (_vm->_screen->_screenChangeFlag) { _vm->_screen->_screenChangeFlag = false; _vm->_events->_cursorExitFlag = true; - executeCommand(4); + executeCommand(7); + } + else if (_vm->_events->_wheelUp || _vm->_events->_wheelDown) { + // Handle scrolling mouse wheel + cycleCommand(_vm->_events->_wheelUp ? 1 : -1); + + } else if (_vm->_events->_middleButton) { + // Switch back to walking + handleCommand(7); + } else if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { // Mouse in user interface area @@ -431,6 +440,20 @@ void Room::doCommands() { } } +void Room::cycleCommand(int incr) { + int command = _selectCommand + incr; + if (command < -1) + command = 6; + else if (command == -1) + command = 7; + else if (command == 1) + command = (incr == 1) ? 2 : 0; + else if (command == 4) + command = (incr == 1) ? 5 : 3; + + handleCommand(command); +} + void Room::handleCommand(int commandId) { if (commandId == 1) --commandId; @@ -494,7 +517,7 @@ void Room::executeCommand(int commandId) { _vm->_scripts->executeScript(); } _vm->_boxSelect = true; - break; + return; case 8: events.setCursor(CURSOR_HELP); break; diff --git a/engines/access/room.h b/engines/access/room.h index 1d540840e3..321ace4fd1 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -72,6 +72,11 @@ private: int calcLR(int yp); int calcUD(int xp); + /** + * Cycles forwards or backwards through the list of commands + */ + void cycleCommand(int incr); + bool checkCode(int v1, int v2); protected: void loadRoomData(const byte *roomData); -- cgit v1.2.3 From d38839d64209248e07b5464be8d44fa19ae93b92 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 11:55:02 -0400 Subject: ACCESS: Fix selecting the help cursor --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a7b619c238..c26a811225 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -519,6 +519,7 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; return; case 8: + events._normalMouse = CURSOR_HELP; events.setCursor(CURSOR_HELP); break; default: -- cgit v1.2.3 From 67e52da359e41c350f8d79cfae3453ca70b8e6d3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 14:19:49 -0400 Subject: ACCESS: Fix non-scaled sprites appearing on-screen in scrolling scenes --- engines/access/access.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 01bb3e3845..a0de5c8e7c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -341,9 +341,9 @@ void AccessEngine::plotList1() { } } else { if (ie._flags & 2) { - _buffer2.plotB(frame, Common::Point(bounds.left, bounds.top)); + _buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top)); } else { - _buffer2.plotF(frame, Common::Point(bounds.left, bounds.top)); + _buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top)); } } } -- cgit v1.2.3 From be8d719a1a882792d3a28a2eb0f98f9ce442bbfd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 14:25:07 -0400 Subject: ACCESS: Fix ending game when a conversation is active --- engines/access/scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 3b03a7ac41..e74b1853a0 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -101,7 +101,7 @@ int Scripts::executeScript() { assert(_scriptCommand >= 0x80); executeCommand(_scriptCommand - 0x80); - } while (!_endFlag); + } while (!_endFlag && !_vm->shouldQuit()); return _returnCode; } -- cgit v1.2.3 From f869019d30bbef118abb140d73bbd6ebc3a5be56 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 17:17:19 -0400 Subject: ACCESS: Implemented cmdDead --- engines/access/access.h | 1 + engines/access/amazon/amazon_game.cpp | 14 +++- engines/access/amazon/amazon_resources.cpp | 120 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 6 ++ engines/access/data.h | 10 +++ engines/access/files.cpp | 7 +- engines/access/files.h | 1 + engines/access/martian/martian_game.cpp | 4 +- engines/access/screen.cpp | 3 +- engines/access/screen.h | 1 - engines/access/scripts.cpp | 70 ++++++++++++++++- engines/access/scripts.h | 2 +- engines/access/sound.cpp | 4 + engines/access/sound.h | 2 + 14 files changed, 234 insertions(+), 11 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 2f557df7f8..725e1fc87f 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -162,6 +162,7 @@ public: int _establishCtrlTblOfs; int _numAnimTimers; TimerList _timers; + DeathList _deaths; FontManager _fonts; Common::Array _newRects; Common::Array _oldRects; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index ecd9922f78..712a25289d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -133,7 +133,7 @@ void AmazonEngine::doTitle() { _sound->queueSound(1, 98, 8); _sound->_soundPriority[1] = 1; - _screen->_loadPalFlag = false; + _files->_loadPalFlag = false; _files->loadScreen(0, 3); _buffer2.copyFrom(*_screen); @@ -147,7 +147,7 @@ void AmazonEngine::doTitle() { _sound->playSound(1); - _screen->_loadPalFlag = false; + _files->_loadPalFlag = false; _files->loadScreen(0, 4); _sound->playSound(1); @@ -192,6 +192,16 @@ void AmazonEngine::setupGame() { _timers.push_back(te); } + // Load death list + _deaths.resize(58); + for (int i = 0; i < 58; ++i) { + _deaths[i]._screenId = DEATH_SCREENS[i]; + _deaths[i]._msg = DEATH_TEXT[i]; + } + _deaths._cells.resize(12); + for (int i = 0; i < 12; ++i) + _deaths._cells[i] = CellIdent(DEATH_CELLS[i][0], DEATH_CELLS[i][1], DEATH_CELLS[i][2]); + // Miscellaneous _fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA); _fonts._font2.load(FONT2_INDEX, FONT2_DATA); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 1f666e1abb..a51457522e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1194,6 +1194,126 @@ YOU CAN UNDERSTAND."; const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; + +const byte DEATH_SCREENS[58] = { + 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, + 0, 2, 4, 2, 1, 0, 0, 0, 0, 0, + 0, 2, 7, 7, 4, 6, 7, 10, 4, 2, + 0, 0, 0, 0, 5, 5, 3, 3, 3, 5, + 8, 8, 11, 9, 8, 12, 0, 1, 9, 8, + 8, 0, 5, 8, 0, 12, 12, 11 +}; + +const char *const DEATH_TEXT[58] = { + "SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.", + "WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.", + "THE GUARD FILLS YOU FULL OF HOLES BEFORE TOSSING YOU TO THE PIRANHA.", + "YOU'RE ONLY ABLE TO SWIM HALFWAY ACROSS THE RIVER BEFORE RUNNING OUT OF AIR. " + "YOU MAKE SO MUCH NOISE GASPING FOR BREATH THAT SAM EASILY FINDS YOU AND LEAVES " + "YOU IN THE RIVER PERMANENTLY.", + "SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO. " + "HE TRACKS YOU DOWN AND LETS YOU HAVE IT.", + "THE GUARD COMES AROUND THE CORNER. HE DECIDES THAT THREE LEAD SLUGS WILL " + "TEACH YOU TO BE MORE POLITE.", + "THE CAPTAIN IS WAITING OUTSIDE THE DOOR.", + "THE CAPTAIN'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.", + "THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP. " + "UNFORTUNATELY, YOU'RE STILL ABOARD.", + "THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.", + + "", + "YOU RUN OUT ON DECK, THEN REALIZE THAT MAYA IS STILL TIED UP. " + "AS YOU TURN TO GO BACK THE BOAT BLOWS UP.", + "AFTER YOU FAIL TO PROVE YOUR DIVINITY THE NATIVES EAT YOU FOR LUNCH.", + "THIS IS THE GENERIC DEATH SCENE", + "YOU ONLY MAKE IT HALFWAY ACROSS THE RIVER BEFORE THE PIRANHA STRIKE.", + "WITH NOTHING TO PROTECT HIM FROM THE HAIL OF BULLETS ALLEN IS QUICKLY GUNNED DOWN. " + "JASON AND MAYA SOON FOLLOW...", + "THE COMBINATION OF THE WIND AND GUNFIRE KNOCK THE CORRUGATED IRON OVER, " + "LEAVING YOU WITHOUT PROTECTION.", + "WITHOUT SUFFICIENT AMMUNITION, ALLEN IS UNABLE TO HOLD OFF THE ATTACKERS FOR LONG. " + "THIS RESULTS IN A SERIOUS CASE OF LEAD POISONING. ADDITIONAL AMMUNITION SHOULD " + "HAVE BEEN PURCHASED AT THE RIO BLANCO TRADING POST (CHAPTER 6).", + "ALLEN IS A MARVELOUS SHOT, BUT HIS AMMUNITION IS NOT UNLIMITED. " + "SOON IT IS ALL OVER.", + "THE PILOT FEELS YOU ARE TOO CLOSE AND PULLS THE TRIGGER.", + + "THE PILOT SHOOTS YOU IN THE HEART, THEN TOSSES YOUR LIFELESS BODY OUT THE DOOR.", + "THE PLANE CRASHES INTO THE JUNGLE CANOPY AT 200 MPH.", + "THE CANOE HITS THE ROCKS AND CAPSIZES, AND THE PIRANHA MAKE YOU THEIR LUNCH GUESTS.", + "YOU TAKE THE WRONG BRANCH AND ACCIDENTALLY DISCOVER THE FOURTH TALLEST WATERFALL " + "IN SOUTH AMERICA.", + "YOU TAKE THE WRONG BRANCH AND DISCOVER A VERY HUNGRY TRIBE OF CANNIBALS.", + "YOU TAKE THE WRONG BRANCH AND BECOME LOST IN THE WINDING WATERWAYS. " + "YOU WANDER UNTIL YOU STARVE TO DEATH.", + "YOU TAKE THE WRONG BRANCH AND BECOME TRAPPED IN THE RAPIDS. " + "EVENTUALLY YOU AND MAYA ARE CRUSHED BETWEEN THE ROCKS.", + "YOU WAIT AROUND FOR SOME TIME, BUT HANS STROHEIM NEVER SPEAKS TO YOU AGAIN. " + "FINALLY YOU RETURN HOME KNOWING YOU HAVE FAILED.", + "DECIDING THAT YOU THREATEN HIM AND HIS WORK, HANS STROHEIM HAS THE NATIVES " + "IN THE VILLAGE KILL YOU.", + "YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN " + "INTO A THOUSAND PIECES.", + + "YOU ARE STANDING SO CLOSE TO THE ENTRANCE WHEN SANCEZ AND HIS MEN BREAK THROUGH " + "THE WALL THAT YOU ARE QUICKLY SPOTTED AND SHOT", + "THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.", + "SAM MAY BE UGLY, BUT HE'S NOT DEAF. HE HEARS ALL THE NOISE YOU ARE MAKING AND " + "CANCELS YOUR BOARDING PASS.", + "WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY", + "THE BEAR WANDERS OFF INTO THE WOODS AND DISTURBS THE TWO LOVEBIRDS. " + "WHEN THEY COME OUT THEY FIND YOU AND PUT YOU IN THE BIG HOUSE FOR TWENTY YEARS.", + "WHEN YOU DO NOT LEAVE THE SECURITY AREA QUICKLY ENOUGH YOU ARE ARRESTED AND CONVICTED " + "AS A COMMIE SPY. YOU EMBARK ON A NEW CAREER STAMPING OUT LICENSE PLATES.", + "THE HUNGRY BEAR SPOTS YOU AND DECIDES YOU WILL MAKE A NICE APPETIZER.", + "YOU DISTURB THE BEAR'S LUNCH AND HE EATS YOU FOR DESSERT.", + "AFTER FAILING TO FIND ANY LUNCH AT THE GARBAGE CAN THE BEAR EATS YOU INSTEAD.", + "THE SUSPICIOUS LIBRARIAN CALLS SECURITY AND YOU ARE SENT TO JAIL.", + + "YOU PLUMMET 10,000 FEET TO YOUR DEATH.", + "EL LOCO FLIES INTO AN INSANE RAGE AND BEATS YOU TO A BLOODY PULP.", + "THE WOMAN WALKS OUT THE DOOR AND NEVER RETURNS. YOU SPEND THE REST OF YOUR LIFE " + "IN A FUTILE ATTEMPT TO LOCATE ALLEN.", + "YOU SLIP OFF THE PLATFORM AND FALL TO YOUR DEATH.", + "YOU SLIP OFF THE PLATFORM AND FALL TO YOUR DEATH.", + "YOU COME TOO CLOSE TO THE POWERFUL JAWS OF THE ANT AND HE SNIPS YOU IN TWO BEFORE " + "DEVOURING YOU.", + "B.O.B. HAS A FLAW IN HIS PROGRAMMING THAT DIRECTS HIM TO SHOOT FIRST AND ASK QUESTIONS LATER.", + "THE PLANE SINKS AND THE PIRHANA ATTACK BEFORE YOU EVEN GET OUT THE DOOR.", + "MAYA FALLS OFF THE END OF THE BROKEN BRIDGE.", + "YOUR WEIGHT IS JUST ENOUGH TO CAUSE THE REMAINING SUPPORT CABLE TO SNAP AND YOU " + "FALL TO THE BOTTOM OF THE GORGE.", + + "EVEN WITH REPAIRS THE BRIDGE IS NOT STRONG ENOUGH TO HOLD TWO PEOPLE.", + "SANCHEZ AND HIS MEN FIND YOU AND HOLD FIRING SQUAD PRACTICE.", + "THE TWO GUARDS ARE DISTURBED IN THEIR LOVE NEST AND COME LOOKING FOR ANYONE ACTING SUSPICIOUS. " + "THEY FIND YOU AND SEND YOU UP THE RIVER.", + "THE PARACHUTE IS NOT LARGE ENOUGH TO SUPPORT YOU, AND YOU HIT THE TREES AT 140 M.P.H.", + "SANCHEZ AND HIS MEN FOLLOW YOU ACROSS THE BRIDGE AND CUT YOU DOWN IN A HAIL OF GUNFIRE", + "YOU TRIED TO STAB THE ANT BUT HIS SHELL IS TOO DIFFICULT TO PENETRATE. " + "YOU NOTICE A SLIGHT CUT IN THE SHELL UNDERNEATH BUT YOU CAN'T GET TO IT " + "AND HE SNIPS YOU INTO DELICIOUS MEATY CHUNKS.", + "AFTER THE ANT FINISHES SUCKING ALL OF THE SAP OUT OF THE VINE HE TURNS HIS ATTENTION BACK TO YOU " + "AND BITES YOUR HEAD OFF.", + "THE CANTINA OWNER NOTICES YOU ARE TRYING TO STEAL OBJECTS FROM THE TABLES. " + "TWENTY YEARS LATER YOU ARE RELEASED FROM A SOUTH AMERICAN PRISON." +}; + +const int DEATH_CELLS[12][3] = { + { 0, 94, 3 }, + { 0, 94, 4 }, + { 0, 94, 5 }, + { 0, 94, 6 }, + { 0, 94, 7 }, + { 0, 94, 8 }, + { 0, 94, 9 }, + { 0, 94, 10 }, + { 0, 94, 11 }, + { 0, 94, 12 }, + { 0, 94, 13 }, + { 0, 94, 14 } +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index d618ca54c2..17cca2a0b4 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -52,6 +52,12 @@ extern const byte FONT6x6_DATA[]; extern const char *const NO_HELP_MESSAGE; extern const char *const NO_HINTS_MESSAGE; +extern const byte DEATH_SCREENS[58]; + +extern const char *const DEATH_TEXT[58]; + +extern const int DEATH_CELLS[12][3]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/data.h b/engines/access/data.h index 3b3485e459..08fbb40d68 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -88,6 +88,16 @@ public: FileIdent _vidSound; }; +struct DeathEntry { + int _screenId; + Common::String _msg; +}; + +class DeathList : public Common::Array { +public: + Common::Array _cells; +}; + } // End of namespace Access #endif /* ACCESS_DATA_H */ diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 4ab98a2060..c449d906cd 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -84,6 +84,7 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) { } _fileNumber = -1; + _loadPalFlag = true; } FileManager::~FileManager() { @@ -135,7 +136,11 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) } void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { - _vm->_screen->loadPalette(res->_stream); + if (_loadPalFlag) { + _vm->_screen->loadPalette(res->_stream); + } else { + res->_stream->skip(PALETTE_SIZE); + } // The remainder of the file after the palette may be separately compressed, // so call handleFile to handle it if it is diff --git a/engines/access/files.h b/engines/access/files.h index 0a934de8aa..a32ebbf88c 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -94,6 +94,7 @@ private: public: int _fileNumber; Common::Array _fileIndex; + bool _loadPalFlag; public: FileManager(AccessEngine *vm); ~FileManager(); diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 969267f719..2f11d8b858 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -98,7 +98,7 @@ void MartianEngine::doTitle() { _sound->queueSound(0, 98, 30); _sound->_soundPriority[0] = 1; - _screen->_loadPalFlag = false; + _files->_loadPalFlag = false; _files->loadScreen(0, 3); _buffer2.copyFrom(*_screen); @@ -112,7 +112,7 @@ void MartianEngine::doTitle() { _sound->playSound(1); - _screen->_loadPalFlag = false; + _files->_loadPalFlag = false; _files->loadScreen(0, 4); _sound->playSound(1); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 26dd2e93ae..227d9d7d0c 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -49,7 +49,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _vesaCurrentWin = 0; _currentPanel = 0; _hideFlag = true; - _loadPalFlag = false; _startColor = _numColors = 0; _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; @@ -100,7 +99,7 @@ void Screen::setInitialPalettte() { void Screen::loadPalette(Common::SeekableReadStream *stream) { loadRawPalette(stream); setPalette(); - _loadPalFlag = true; + _vm->_files->_loadPalFlag = true; } void Screen::loadPalette(int fileNum, int subfile) { diff --git a/engines/access/screen.h b/engines/access/screen.h index 47e03de2b8..b278062d13 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -64,7 +64,6 @@ private: void updatePalette(); public: int _vesaMode; - bool _loadPalFlag; int _startColor, _numColors; Common::Point _bufferStart; int _scrollCol, _scrollRow; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index e74b1853a0..8ac0de78fa 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -133,7 +133,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, - &Scripts::cmdPlayerOn, &Scripts::CMDDEAD, &Scripts::cmdFadeOut, + &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut, &Scripts::CMDENDVID }; @@ -740,7 +740,73 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::CMDDEAD() { error("TODO CMDDEAD"); } +void Scripts::cmdDead() { + int deathId = _data->readByte(); + _vm->_events->hideCursor(); + _vm->_screen->forceFadeOut(); + cmdFreeSound(); + + _vm->_sound->_soundTable[0] = _vm->_files->loadFile(98, 44); + _vm->_sound->_soundPriority[1] = 1; + + _vm->_screen->clearScreen(); + _vm->_screen->setPanel(3); + + if (deathId != 10) { + _vm->_sound->newMusic(62, 0); + _vm->_files->_loadPalFlag = false; + _vm->_files->loadScreen(94, 0); + _vm->_files->_loadPalFlag = true; + _vm->_buffer2.copyFrom(*_vm->_screen); + + for (int i = 0; i < 3; ++i) { + _vm->_sound->playSound(0); + _vm->_screen->forceFadeIn(); + _vm->_sound->playSound(0); + _vm->_screen->forceFadeOut(); + } + _vm->freeCells(); + + // Load the cell list for the death screen + DeathEntry &de = _vm->_deaths[deathId]; + Common::Array cells; + cells.push_back(_vm->_deaths._cells[de._screenId]); + _vm->loadCells(cells); + + _vm->_screen->setDisplayScan(); + _vm->_files->_loadPalFlag = false; + _vm->_files->loadScreen(&_vm->_buffer2, 94, 1); + _vm->_screen->setIconPalette(); + + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(105, 25)); + _vm->_buffer2.copyTo(_vm->_screen); + _vm->_screen->forceFadeIn(); + + _vm->_fonts._charSet._hi = 10; + _vm->_fonts._charSet._lo = 1; + _vm->_fonts._charFor._lo = 55; + _vm->_fonts._charFor._hi = 255; + _vm->_screen->_maxChars = 46; + _vm->_screen->_printOrg = Common::Point(20, 155); + _vm->_screen->_printStart = Common::Point(20, 155); + + Common::String &msg = de._msg; + _vm->_printEnd = 180; + _vm->_fonts._font2.printText(_vm->_screen, msg); + _vm->_screen->forceFadeOut(); + + _vm->_sound->newMusic(0, 1); + _vm->_events->showCursor(); + _vm->_room->clearRoom(); + _vm->freeChar(); + + warning("TODO: restart game"); + _vm->quitGame(); + } + else { + _vm->quitGame(); + } +} void Scripts::cmdFadeOut() { _vm->_screen->forceFadeOut(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 733c7f9dd7..003f441234 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -119,7 +119,7 @@ protected: void CMDPUSHLOCATION(); void cmdPlayerOff(); void cmdPlayerOn(); - void CMDDEAD(); + void cmdDead(); void cmdFadeOut(); void CMDENDVID(); public: diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 91910f2917..0cdb380bb9 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -93,6 +93,10 @@ void SoundManager::freeSounds() { // TODO } +void SoundManager::newMusic(int musicId, int mode) { + warning("TODO: newMusic"); +} + void SoundManager::freeMusic() { delete _music; _music = nullptr; diff --git a/engines/access/sound.h b/engines/access/sound.h index 1a94c46773..ad1688a5a9 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -67,6 +67,8 @@ public: void freeSounds(); + void newMusic(int musicId, int mode); + void freeMusic(); }; -- cgit v1.2.3 From adddb1377d927403abc406c09f1d76ac5700188a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 17:44:40 -0400 Subject: ACCESS: Fix loading sound in cmdLoadSound --- engines/access/scripts.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 8ac0de78fa..2fdb91e35b 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -688,8 +688,11 @@ void Scripts::cmdClearBlock() { void Scripts::cmdLoadSound() { int idx = _data->readSint16LE(); - _vm->_sound->_soundTable[0] = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); - _vm->_sound->_soundPriority[0] = 1; + + _vm->_sound->_soundTable.clear(); + _vm->_sound->_soundPriority.clear(); + _vm->_sound->_soundTable.push_back(_vm->_files->loadFile(_vm->_extraCells[idx]._vidSound)); + _vm->_sound->_soundPriority.push_back(1); } void Scripts::cmdFreeSound() { -- cgit v1.2.3 From aa755b9f3ff93e1e0918abe77b2a49b2e203e2a5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Aug 2014 01:05:52 +0200 Subject: ACCESS: Fix loadEstablish for the CD version --- engines/access/amazon/amazon_game.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 712a25289d..8fbc4cf2ff 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -235,19 +235,19 @@ void AmazonEngine::loadEstablish(int sub) { _eseg = _files->loadFile("ETEXT.DAT"); } - _establishCtrlTblOfs = READ_LE_UINT16(_eseg); + _establishCtrlTblOfs = READ_LE_UINT16(_eseg->data()); int ofs = _establishCtrlTblOfs + (sub * 2); - int idx = READ_LE_UINT16(_eseg + ofs); - _narateFile = READ_LE_UINT16(_eseg + idx); - _txtPages = READ_LE_UINT16(_eseg + idx + 2); + int idx = READ_LE_UINT16(_eseg->data() + ofs); + _narateFile = READ_LE_UINT16(_eseg->data() + idx); + _txtPages = READ_LE_UINT16(_eseg->data() + idx + 2); if (!_txtPages) return; - _sndSubFile = READ_LE_UINT16(_eseg + idx + 4); + _sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4); for (int i = 0; i < _txtPages; ++i) - _countTbl[i] = READ_LE_UINT16(_eseg + idx + 6 + (2 * i)); + _countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i)); } void AmazonEngine::doEstablish(int esatabIndex, int sub) { @@ -278,12 +278,12 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _printEnd = 155; if (_txtPages == 0) { - Common::String msg((const char *)_eseg + msgOffset); + Common::String msg((const char *)_eseg->data() + msgOffset); _fonts._font2.printText(_screen, msg); } else { Common::Array msgArr; for (int i = 0; i < _txtPages; ++i) { - Common::String msg((const char *)_eseg + msgOffset); + Common::String msg((const char *)_eseg->data() + msgOffset); msgOffset += msg.size() + 1; msgArr.push_back(msg); } @@ -293,7 +293,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _screen->forceFadeOut(); _screen->clearScreen(); - free(_eseg); + delete _eseg; if (_establishMode == 0) _room->init4Quads(); } -- cgit v1.2.3 From 2cc6d9299ae6a7037704dd72eeebc44ab2c3c1b4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Aug 2014 01:09:29 +0200 Subject: ACCESS: Add a check to work around a difference in hardcoded data between the CD and the floppy version --- engines/access/room.cpp | 18 +++++++++++------- engines/access/room.h | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c26a811225..3696a4cadf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -162,7 +162,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData, _vm->getGameID()); + RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD()); _roomFlag = roomInfo._roomFlag; @@ -734,14 +734,19 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data, int gameType) { +RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); - if (gameType != GType_MartianMemorandum) - _estIndex = stream.readSint16LE(); - else + if (gameType == GType_Amazon) { + if (isCD) + _estIndex = stream.readSint16LE(); + else { + _estIndex = -1; + stream.readSint16LE(); + } + } else _estIndex = -1; _musicFile.load(stream); @@ -779,8 +784,7 @@ RoomInfo::RoomInfo(const byte *data, int gameType) { _extraCells.push_back(ec); } - for (int16 fileNum = stream.readSint16LE(); fileNum != -1; - fileNum = stream.readSint16LE()) { + for (int16 fileNum = stream.readSint16LE(); fileNum != -1; fileNum = stream.readSint16LE()) { SoundIdent fi; fi._fileNum = fileNum; fi._subfile = stream.readUint16LE(); diff --git a/engines/access/room.h b/engines/access/room.h index 321ace4fd1..fdeccc87c8 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -191,7 +191,7 @@ public: Common::Array _extraCells; Common::Array _sounds; public: - RoomInfo(const byte *data, int gameType); + RoomInfo(const byte *data, int gameType, bool isCD); }; } // End of namespace Access -- cgit v1.2.3 From 469e3273608d71964da8b1f492e9c66ba9194752 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Aug 2014 01:11:44 +0200 Subject: ACCESS: Add a safeguard to avoid a potential issue when alternating stream and raw data use --- engines/access/files.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index c449d906cd..d8823c0510 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -62,8 +62,10 @@ Resource::~Resource() { byte *Resource::data() { if (_data == nullptr) { _data = new byte[_size]; + int pos = _stream->pos(); _stream->seek(0); _stream->read(_data, _size); + _stream->seek(pos); } return _data; -- cgit v1.2.3 From 36b87d39cad736f55de62e7c0f6186e234c357e5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 19:15:34 -0400 Subject: ACCESS: Add a missing ->data() on _eseg --- engines/access/amazon/amazon_game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8fbc4cf2ff..ab6fb3f5d9 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -274,7 +274,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(sub); _et = sub; - uint16 msgOffset = READ_LE_UINT16(_eseg + (sub * 2) + 2); + uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (sub * 2) + 2); _printEnd = 155; if (_txtPages == 0) { -- cgit v1.2.3 From b39d7df7cb754b975bcbfdb523f451f021847e72 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 20:12:12 -0400 Subject: ACCESS: Fix background loading in doEstablish --- engines/access/amazon/amazon_game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index ab6fb3f5d9..d18729aa19 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -257,8 +257,8 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _screen->clearScreen(); _screen->setPanel(3); - if (esatabIndex != -1) { - _files->loadScreen(95, esatabIndex); + if (sub != -1) { + _files->loadScreen(95, sub); _buffer2.copyBuffer(_screen); } -- cgit v1.2.3 From 9d3460e9f707b1d53534e45c19e15bbb247eba70 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 31 Aug 2014 02:18:02 +0200 Subject: ACCESS: Implement printText() --- engines/access/access.cpp | 29 +++++++++++++++++++++++++++++ engines/access/access.h | 8 ++++++-- engines/access/amazon/amazon_game.cpp | 33 ++++++++++++++++++--------------- engines/access/font.cpp | 4 ---- engines/access/font.h | 4 ---- engines/access/scripts.cpp | 2 +- 6 files changed, 54 insertions(+), 26 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a0de5c8e7c..360d434670 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -296,6 +296,35 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) } } +void AccessEngine::printText(ASurface *s, Common::String &msg) { + Common::String line; + int width = 0; + while (true) { + bool lastLine = _fonts._font2.getLine(msg, s->_maxChars * 6, line, width); + + // Set font colors + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 28; + _fonts._font2._fontColors[2] = 29; + _fonts._font2._fontColors[3] = 30; + + _fonts._font2.drawString(s, line, s->_printOrg); + s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); + + if (lastLine) + break; + + _events->waitKeyMouse(); + _buffer2.copyBuffer(s); + s->_printOrg.y = s->_printStart.y; + + if (lastLine) + break; + } + _events->waitKeyMouse(); +} + + void AccessEngine::plotList() { _player->calcPlayer(); plotList1(); diff --git a/engines/access/access.h b/engines/access/access.h index 725e1fc87f..42ba49fd5d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -113,8 +113,6 @@ protected: */ void doRoom(); - void speakText(ASurface *s, Common::ArraymsgArr); - /** * Support method that generates a savegame name * @param slot Slot number @@ -270,6 +268,12 @@ public: void freeChar(); + /** + * Draw a string on a given surface and update text positioning + */ + void printText(ASurface *s, Common::String &msg); + void speakText(ASurface *s, Common::ArraymsgArr); + /** * Load a savegame */ diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d18729aa19..f633cd8753 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -231,23 +231,26 @@ void AmazonEngine::loadEstablish(int sub) { _establishGroup = 0; _eseg = _files->loadFile(_estTable[oldGroup]); - } else { - _eseg = _files->loadFile("ETEXT.DAT"); - } + _establishCtrlTblOfs = READ_LE_UINT16(_eseg->data()); - _establishCtrlTblOfs = READ_LE_UINT16(_eseg->data()); + int ofs = _establishCtrlTblOfs + (sub * 2); + int idx = READ_LE_UINT16(_eseg->data() + ofs); + _narateFile = READ_LE_UINT16(_eseg->data() + idx); + _txtPages = READ_LE_UINT16(_eseg->data() + idx + 2); - int ofs = _establishCtrlTblOfs + (sub * 2); - int idx = READ_LE_UINT16(_eseg->data() + ofs); - _narateFile = READ_LE_UINT16(_eseg->data() + idx); - _txtPages = READ_LE_UINT16(_eseg->data() + idx + 2); - - if (!_txtPages) - return; + if (!_txtPages) + return; - _sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4); - for (int i = 0; i < _txtPages; ++i) - _countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i)); + _sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4); + for (int i = 0; i < _txtPages; ++i) + _countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i)); + } else { + _establishGroup = 0; + _narateFile = 0; + _txtPages = 0; + _sndSubFile = 0; + _eseg = _files->loadFile("ETEXT.DAT"); + } } void AmazonEngine::doEstablish(int esatabIndex, int sub) { @@ -279,7 +282,7 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _printEnd = 155; if (_txtPages == 0) { Common::String msg((const char *)_eseg->data() + msgOffset); - _fonts._font2.printText(_screen, msg); + printText(_screen, msg); } else { Common::Array msgArr; for (int i = 0; i < _txtPages; ++i) { diff --git a/engines/access/font.cpp b/engines/access/font.cpp index ba17f19211..75add4129c 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -159,10 +159,6 @@ int Font::drawChar(ASurface *s, char c, Common::Point &pt) { return ch.w; } -void Font::printText(ASurface *s, const Common::String &msg) { - error("TODO: printText"); -} - /*------------------------------------------------------------------------*/ FontManager::FontManager() { diff --git a/engines/access/font.h b/engines/access/font.h index 9285d323d1..d8517e3720 100644 --- a/engines/access/font.h +++ b/engines/access/font.h @@ -85,10 +85,6 @@ public: */ int drawChar(ASurface *s, char c, Common::Point &pt); - /** - * Draw a string on a given surface and update text positioning - */ - void printText(ASurface *s, const Common::String &msg); }; class FontManager { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2fdb91e35b..0b2150a5a6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -795,7 +795,7 @@ void Scripts::cmdDead() { Common::String &msg = de._msg; _vm->_printEnd = 180; - _vm->_fonts._font2.printText(_vm->_screen, msg); + _vm->printText(_vm->_screen, msg); _vm->_screen->forceFadeOut(); _vm->_sound->newMusic(0, 1); -- cgit v1.2.3 From c092e0665271541719d34b40da5d856142c42a8e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 20:31:48 -0400 Subject: ACCESS: Fix parameter usage in doEstablish --- engines/access/amazon/amazon_game.cpp | 8 ++++---- engines/access/amazon/amazon_game.h | 2 +- engines/access/room.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f633cd8753..14ee9bc947 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -253,7 +253,7 @@ void AmazonEngine::loadEstablish(int sub) { } } -void AmazonEngine::doEstablish(int esatabIndex, int sub) { +void AmazonEngine::doEstablish(int estabIndex, int sub) { _establishMode = 1; _screen->forceFadeOut(); @@ -275,9 +275,9 @@ void AmazonEngine::doEstablish(int esatabIndex, int sub) { _screen->_maxChars = 37; _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); - loadEstablish(sub); - _et = sub; - uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (sub * 2) + 2); + loadEstablish(estabIndex); + _et = estabIndex; + uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2); _printEnd = 155; if (_txtPages == 0) { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 6511b377ae..575b3d14b7 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -100,7 +100,7 @@ private: void setupGame(); void loadEstablish(int sub); - void doEstablish(int esatabIndex, int sub); + void doEstablish(int estabIndex, int sub); void establishCenter(int esatabIndex, int sub); protected: diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3696a4cadf..7df7ca9251 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(0, roomInfo._estIndex); + _vm->establish(roomInfo._estIndex, 0); } } -- cgit v1.2.3 From 78bf011a8b5f9eb25c2b231752c30a3ca239cbc7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 20:50:25 -0400 Subject: ACCESS: Fix playSound stub --- engines/access/sound.cpp | 6 +++--- engines/access/sound.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 0cdb380bb9..001d2f325b 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -55,11 +55,11 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int idx = _soundPriority[soundIndex]; - playSound(_soundTable[idx]); + int priority = _soundPriority[soundIndex]; + playSound(_soundTable[soundIndex], priority); } -void SoundManager::playSound(Resource *res) { +void SoundManager::playSound(Resource *res, int priority) { /* Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); diff --git a/engines/access/sound.h b/engines/access/sound.h index ad1688a5a9..3d967c6af4 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -41,7 +41,7 @@ private: void clearSounds(); - void playSound(Resource *res); + void playSound(Resource *res, int priority); public: Common::Array _soundTable; Common::Array _soundPriority; -- cgit v1.2.3 From 2f5fb206d30a77b94aa81feb6b7292c0d3e5e481 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 21:02:22 -0400 Subject: ACCESS: Further cleanup of doEstablish parameters --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_game.cpp | 18 +++++++++--------- engines/access/amazon/amazon_game.h | 6 +++--- engines/access/char.cpp | 2 +- engines/access/room.cpp | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 360d434670..29b7fd6e5c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -240,7 +240,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) while (true) { _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; - _sound->playSound(1); + _sound->playSound(0); _scripts->cmdFreeSound(); _events->pollEvents(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 14ee9bc947..d15587f32f 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -212,20 +212,20 @@ void AmazonEngine::setupGame() { _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; } -void AmazonEngine::establish(int esatabIndex, int sub) { +void AmazonEngine::establish(int screenId, int esatabIndex) { _establishMode = 0; _establishGroup = 0; - doEstablish(esatabIndex, sub); + doEstablish(screenId, esatabIndex); } -void AmazonEngine::establishCenter(int esatabIndex, int sub) { +void AmazonEngine::establishCenter(int screenId, int esatabIndex) { _establishMode = 1; - doEstablish(esatabIndex, sub); + doEstablish(screenId, esatabIndex); } const char *const _estTable[] = { "ETEXT0.DAT", "ETEXT1.DAT", "ETEXT2.DAT", "ETEXT3.DAT" }; -void AmazonEngine::loadEstablish(int sub) { +void AmazonEngine::loadEstablish(int estabIndex) { if (!_files->existFile("ETEXT.DAT")) { int oldGroup = _establishGroup; _establishGroup = 0; @@ -233,7 +233,7 @@ void AmazonEngine::loadEstablish(int sub) { _eseg = _files->loadFile(_estTable[oldGroup]); _establishCtrlTblOfs = READ_LE_UINT16(_eseg->data()); - int ofs = _establishCtrlTblOfs + (sub * 2); + int ofs = _establishCtrlTblOfs + (estabIndex * 2); int idx = READ_LE_UINT16(_eseg->data() + ofs); _narateFile = READ_LE_UINT16(_eseg->data() + idx); _txtPages = READ_LE_UINT16(_eseg->data() + idx + 2); @@ -253,15 +253,15 @@ void AmazonEngine::loadEstablish(int sub) { } } -void AmazonEngine::doEstablish(int estabIndex, int sub) { +void AmazonEngine::doEstablish(int screenId, int estabIndex) { _establishMode = 1; _screen->forceFadeOut(); _screen->clearScreen(); _screen->setPanel(3); - if (sub != -1) { - _files->loadScreen(95, sub); + if (screenId != -1) { + _files->loadScreen(95, screenId); _buffer2.copyBuffer(_screen); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 575b3d14b7..3929eb1485 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -99,9 +99,9 @@ private: */ void setupGame(); - void loadEstablish(int sub); - void doEstablish(int estabIndex, int sub); - void establishCenter(int esatabIndex, int sub); + void loadEstablish(int estabIndex); + void doEstablish(int screenId, int estabIndex); + void establishCenter(int screenId, int esatabIndex); protected: /** diff --git a/engines/access/char.cpp b/engines/access/char.cpp index aebf63a131..8ce43a5730 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -90,7 +90,7 @@ void CharManager::loadChar(int charId) { _vm->_establishFlag = true; if (!_vm->_establishTable[ce._estabIndex]) { _vm->_establishTable[ce._estabIndex] = true; - _vm->establish(ce._estabIndex, 0); + _vm->establish(0, ce._estabIndex); } } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7df7ca9251..3696a4cadf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -171,7 +171,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_establishFlag = true; if (_vm->_establishTable[roomInfo._estIndex] != 1) { _vm->_establishTable[roomInfo._estIndex] = 1; - _vm->establish(roomInfo._estIndex, 0); + _vm->establish(0, roomInfo._estIndex); } } -- cgit v1.2.3 From b5b298a5d5a6cf461d14c6f48bdd301df803da62 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 21:22:11 -0400 Subject: ACCESS: Fix playSound call --- engines/access/access.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 29b7fd6e5c..55af992dbb 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -275,7 +275,7 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) while(true) { _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; - _sound->playSound(1); + _sound->playSound(0); _scripts->cmdFreeSound(); _events->pollEvents(); -- cgit v1.2.3 From f8778a5e04b5cc46a898d9d6c570f506e7d3b58c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 21:43:24 -0400 Subject: ACCESS: Fix getLine when \r occurs just after maximum line width reached --- engines/access/font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 75add4129c..ffc1715c39 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -74,6 +74,9 @@ void Font::load(const int *fontIndex, const byte *fontData) { } int Font::charWidth(char c) { + if (c < ' ') + return 0; + return _chars[c - ' '].w; } @@ -95,7 +98,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w while ((c = *src) != '\0') { if (c == '\r') { // End of line, so return calculated line - line = Common::String(s.c_str(), src - 1); + line = Common::String(s.c_str(), src); s = Common::String(src + 1); return false; } -- cgit v1.2.3 From e854ec1bc98efcddc006fbf0078d15f51ffcb264 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 30 Aug 2014 21:44:28 -0400 Subject: ACCESS: Fix freeing _eseg correctly --- engines/access/amazon/amazon_game.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d15587f32f..0725863444 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -297,6 +297,8 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->clearScreen(); delete _eseg; + _eseg = nullptr; + if (_establishMode == 0) _room->init4Quads(); } -- cgit v1.2.3 From f1fae5373130c2c0986476f53a193f3ba2d760ab Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 1 Sep 2014 19:52:44 +0200 Subject: DEBUGGER: Add "md5" command, to get the MD5 sum of entire files This may make it easier to ask users for the MD5 sum of a file, in case we suspect a bug report is caused by damaged files. --- gui/debugger.cpp | 35 +++++++++++++++++++++++++++++++++++ gui/debugger.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index dcdc18d7b9..ff365b0fad 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -27,6 +27,12 @@ #include "common/debug-channels.h" #include "common/system.h" +#ifndef DISABLE_MD5 +#include "common/md5.h" +#include "common/archive.h" +#include "common/stream.h" +#endif + #include "engines/engine.h" #include "gui/debugger.h" @@ -61,6 +67,9 @@ Debugger::Debugger() { registerCmd("help", WRAP_METHOD(Debugger, cmdHelp)); registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog)); +#ifndef DISABLE_MD5 + registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5)); +#endif registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel)); registerCmd("debugflag_list", WRAP_METHOD(Debugger, cmdDebugFlagsList)); @@ -502,6 +511,32 @@ bool Debugger::cmdOpenLog(int argc, const char **argv) { return true; } +#ifndef DISABLE_MD5 +bool Debugger::cmdMd5(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("md5 \n"); + } else { + // Assume that spaces are part of a single filename. + Common::String filename = argv[1]; + for (int i = 2; i < argc; i++) { + filename = filename + " " + argv[i]; + } + Common::ArchiveMemberList list; + SearchMan.listMatchingMembers(list, filename); + if (list.empty()) { + debugPrintf("File '%s' not found\n", filename.c_str()); + } else { + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::ReadStream *stream = (*iter)->createReadStream(); + Common::String md5 = Common::computeStreamMD5AsString(*stream, 0); + debugPrintf("%s %s\n", md5.c_str(), (*iter)->getDisplayName().c_str()); + delete stream; + } + } + } + return true; +} +#endif bool Debugger::cmdDebugLevel(int argc, const char **argv) { if (argc == 1) { // print level diff --git a/gui/debugger.h b/gui/debugger.h index 8c7481b61f..3a829506d9 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -213,6 +213,9 @@ protected: bool cmdExit(int argc, const char **argv); bool cmdHelp(int argc, const char **argv); bool cmdOpenLog(int argc, const char **argv); +#ifndef DISABLE_MD5 + bool cmdMd5(int argc, const char **argv); +#endif bool cmdDebugLevel(int argc, const char **argv); bool cmdDebugFlagsList(int argc, const char **argv); bool cmdDebugFlagEnable(int argc, const char **argv); -- cgit v1.2.3 From 84548847a13de7366875894243e9e5d5a46a4aec Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 1 Sep 2014 21:19:48 +0200 Subject: DEBUGGER: Add "md5mac" command to get MD5 sum of Mac resource fork. --- gui/debugger.cpp | 27 +++++++++++++++++++++++++++ gui/debugger.h | 1 + 2 files changed, 28 insertions(+) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index ff365b0fad..e0b2db1f50 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -30,6 +30,7 @@ #ifndef DISABLE_MD5 #include "common/md5.h" #include "common/archive.h" +#include "common/macresman.h" #include "common/stream.h" #endif @@ -69,6 +70,7 @@ Debugger::Debugger() { registerCmd("openlog", WRAP_METHOD(Debugger, cmdOpenLog)); #ifndef DISABLE_MD5 registerCmd("md5", WRAP_METHOD(Debugger, cmdMd5)); + registerCmd("md5mac", WRAP_METHOD(Debugger, cmdMd5Mac)); #endif registerCmd("debuglevel", WRAP_METHOD(Debugger, cmdDebugLevel)); @@ -536,6 +538,31 @@ bool Debugger::cmdMd5(int argc, const char **argv) { } return true; } + +bool Debugger::cmdMd5Mac(int argc, const char **argv) { + if (argc < 2) { + debugPrintf("md5mac \n"); + } else { + // Assume that spaces are part of a single filename. + Common::String filename = argv[1]; + for (int i = 2; i < argc; i++) { + filename = filename + " " + argv[i]; + } + Common::MacResManager macResMan; + if (!macResMan.open(filename)) { + debugPrintf("Resource file '%s' not found\n", filename.c_str()); + } else { + Common::String md5 = macResMan.computeResForkMD5AsString(0); + if (md5.empty()) { + debugPrintf("'%s' has no resource fork\n", filename.c_str()); + } else { + debugPrintf("%s %s\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + } + macResMan.close(); + } + } + return true; +} #endif bool Debugger::cmdDebugLevel(int argc, const char **argv) { diff --git a/gui/debugger.h b/gui/debugger.h index 3a829506d9..4539ba9efb 100644 --- a/gui/debugger.h +++ b/gui/debugger.h @@ -215,6 +215,7 @@ protected: bool cmdOpenLog(int argc, const char **argv); #ifndef DISABLE_MD5 bool cmdMd5(int argc, const char **argv); + bool cmdMd5Mac(int argc, const char **argv); #endif bool cmdDebugLevel(int argc, const char **argv); bool cmdDebugFlagsList(int argc, const char **argv); -- cgit v1.2.3 From daceff7b2d08aa57060592b6eb7a60fe960b048c Mon Sep 17 00:00:00 2001 From: Роман Донченко Date: Fri, 5 Sep 2014 23:17:57 +0400 Subject: COMMON: Use true nullptr in Visual Studio 2010+ and true override in VS 2012+ Those compilers support these features despite not being fully C++11-compliant. says that VS 2010 has "partial" support for override. I don't know what that entails and I can't test it, so I err on the side of caution and only enable it in 2012 and up. --- common/c++11-compat.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/c++11-compat.h b/common/c++11-compat.h index 14e0642821..9fd252cc67 100644 --- a/common/c++11-compat.h +++ b/common/c++11-compat.h @@ -32,13 +32,17 @@ // though. // #if !defined(nullptr) // XCode 5.0.1 has __cplusplus=199711 but defines this +#if !defined(_MSC_VER) || _MSC_VER < 1600 #define nullptr 0 #endif +#endif // // Replacement for the override keyword. This allows compilation of code // which uses it, but does not feature any semantic. // +#if !defined(_MSC_VER) || _MSC_VER < 1700 #define override +#endif #endif -- cgit v1.2.3 From ce37e489f83d8f33af36bc09cefa4352e827ec03 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 7 Sep 2014 18:14:50 +0200 Subject: DEBUGGER: Sort "md5" output, when using wildcards. --- gui/debugger.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index e0b2db1f50..5db2b97523 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -514,6 +514,12 @@ bool Debugger::cmdOpenLog(int argc, const char **argv) { } #ifndef DISABLE_MD5 +struct ArchiveMemberLess { + bool operator()(const Common::ArchiveMemberPtr &x, const Common::ArchiveMemberPtr &y) const { + return (*x).getDisplayName().compareToIgnoreCase((*y).getDisplayName()) < 0; + } +}; + bool Debugger::cmdMd5(int argc, const char **argv) { if (argc < 2) { debugPrintf("md5 \n"); @@ -528,6 +534,7 @@ bool Debugger::cmdMd5(int argc, const char **argv) { if (list.empty()) { debugPrintf("File '%s' not found\n", filename.c_str()); } else { + sort(list.begin(), list.end(), ArchiveMemberLess()); for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { Common::ReadStream *stream = (*iter)->createReadStream(); Common::String md5 = Common::computeStreamMD5AsString(*stream, 0); -- cgit v1.2.3 From 37aa4c2d5955f7558bb06e89e50f017d6a87eac6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 7 Sep 2014 18:30:40 +0200 Subject: DEBUGGER: Changed usage output from "md5mac" I don't know of any good way of transforming file names to base file names, so document that "md5mac" expects the base file name. Even though it currently will accept MacBinary file names. --- gui/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 5db2b97523..48acda17ad 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -548,7 +548,7 @@ bool Debugger::cmdMd5(int argc, const char **argv) { bool Debugger::cmdMd5Mac(int argc, const char **argv) { if (argc < 2) { - debugPrintf("md5mac \n"); + debugPrintf("md5mac \n"); } else { // Assume that spaces are part of a single filename. Common::String filename = argv[1]; -- cgit v1.2.3 From 14ce84da9aec30aa89505f40d16e06df0b6725e4 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 7 Sep 2014 18:50:51 +0200 Subject: DEBUGGER: Let "md5mac" print the MD5 sum of both resource and data --- gui/debugger.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 48acda17ad..560e516a94 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -559,11 +559,19 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) { if (!macResMan.open(filename)) { debugPrintf("Resource file '%s' not found\n", filename.c_str()); } else { - Common::String md5 = macResMan.computeResForkMD5AsString(0); - if (md5.empty()) { - debugPrintf("'%s' has no resource fork\n", filename.c_str()); + if (!macResMan.hasResFork() && !macResMan.hasDataFork()) { + debugPrintf("'%s' has neither data not resource fork\n", macResMan.getBaseFileName().c_str()); } else { - debugPrintf("%s %s\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + // The resource fork is probably the most relevant one. + if (macResMan.hasResFork()) { + Common::String md5 = macResMan.computeResForkMD5AsString(0); + debugPrintf("%s %s (resource)\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + } + if (macResMan.hasDataFork()) { + Common::ReadStream *stream = macResMan.getDataFork(); + Common::String md5 = Common::computeStreamMD5AsString(*stream, 0); + debugPrintf("%s %s (data)\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + } } macResMan.close(); } -- cgit v1.2.3 From 78552afdae3b7b27845d7ea4d2c2638fa3182333 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 9 Sep 2014 12:31:11 +0700 Subject: ZVISION: Check .avi and .rlf suffix only in MetaAnimation. --- engines/zvision/animation/meta_animation.cpp | 10 ++++++---- engines/zvision/scripting/controls/hotmov_control.cpp | 3 +-- engines/zvision/scripting/controls/lever_control.cpp | 3 +-- engines/zvision/scripting/controls/safe_control.cpp | 3 +-- engines/zvision/scripting/sidefx/animation_node.cpp | 8 ++------ 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp index 38f56699bb..1ea6df6481 100644 --- a/engines/zvision/animation/meta_animation.cpp +++ b/engines/zvision/animation/meta_animation.cpp @@ -40,14 +40,16 @@ namespace ZVision { MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) : _fileType(RLF), _cur_frame(NULL) { - if (fileName.hasSuffix(".rlf")) { + Common::String tmpFileName = fileName; + tmpFileName.toLowercase(); + if (tmpFileName.hasSuffix(".rlf")) { _fileType = RLF; - Common::File *_file = engine->getSearchManager()->openFile(fileName); + Common::File *_file = engine->getSearchManager()->openFile(tmpFileName); _animation.rlf = new RlfAnimation(_file, false); _frmDelay = _animation.rlf->frameTime(); - } else if (fileName.hasSuffix(".avi")) { + } else if (tmpFileName.hasSuffix(".avi")) { _fileType = AVI; - Common::File *_file = engine->getSearchManager()->openFile(fileName); + Common::File *_file = engine->getSearchManager()->openFile(tmpFileName); _animation.avi = new ZorkAVIDecoder(); _animation.avi->loadStream(_file); _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index 1e1886e1a8..8ffc3392be 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -80,8 +80,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt char filename[64]; sscanf(values.c_str(), "%s", filename); values = Common::String(filename); - if (values.hasSuffix(".avi") || values.hasSuffix(".rlf")) - _animation = new MetaAnimation(values, _engine); + _animation = new MetaAnimation(values, _engine); } else if (param.matchString("venus_id", true)) { _venus_id = atoi(values.c_str()); } diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 87fbb433dd..8072079435 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -104,8 +104,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { Common::String animationFileName(fileNameBuffer); - if (animationFileName.hasSuffix(".avi") || animationFileName.hasSuffix(".rlf")) - _animation = new MetaAnimation(animationFileName, _engine); + _animation = new MetaAnimation(animationFileName, _engine); } else if (line.matchString("*skipcolor*", true)) { // Not used diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index a6be20bce8..d5eff09502 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -66,8 +66,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream while (!stream.eos() && !line.contains('}')) { if (param.matchString("animation", true)) { - if (values.hasSuffix(".avi") || values.hasSuffix(".rlf")) - _animation = new MetaAnimation(values, _engine); + _animation = new MetaAnimation(values, _engine); } else if (param.matchString("rectangle", true)) { int x; int y; diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 4a606adc9e..bd9c543d52 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -40,12 +40,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _mask(mask), _animation(NULL) { - if (fileName.hasSuffix(".rlf") || fileName.hasSuffix(".avi")) { - _animation = new MetaAnimation(fileName, engine); - _frmDelay = _animation->frameTime(); - } else { - warning("Unrecognized animation file type: %s", fileName.c_str()); - } + _animation = new MetaAnimation(fileName, engine); + _frmDelay = _animation->frameTime(); if (frate > 0) _frmDelay = 1000.0 / frate; -- cgit v1.2.3 From bcb1aea0ff3fa45528ebf1dea8c9855cccf1e736 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 9 Sep 2014 12:34:20 +0700 Subject: ZVISION: FistControl implementation. --- engines/zvision/module.mk | 1 + .../zvision/scripting/controls/fist_control.cpp | 294 +++++++++++++++++++++ engines/zvision/scripting/controls/fist_control.h | 86 ++++++ engines/zvision/scripting/scr_file_handling.cpp | 3 + 4 files changed, 384 insertions(+) create mode 100644 engines/zvision/scripting/controls/fist_control.cpp create mode 100644 engines/zvision/scripting/controls/fist_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 0e6f1ce042..4cfb8f3182 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -17,6 +17,7 @@ MODULE_OBJS := \ graphics/render_table.o \ scripting/actions.o \ scripting/control.o \ + scripting/controls/fist_control.o \ scripting/controls/hotmov_control.o \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp new file mode 100644 index 0000000000..46b87ddb79 --- /dev/null +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -0,0 +1,294 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/fist_control.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/animation/meta_animation.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" +#include "common/file.h" +#include "common/system.h" + +#include "graphics/surface.h" + + +namespace ZVision { + +FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_FIST) { + _cursor = CursorIndex_Idle; + _animation = NULL; + _soundKey = 0; + _fiststatus = 0; + _order = 0; + _fistnum = 0; + + _frameCur = -1; + _frameEnd = -1; + _frameTime = 0; + _lastRenderedFrame = -1; + _animationId = 0; + + clearFistArray(_fistsUp); + clearFistArray(_fistsDwn); + + _numEntries = 0; + _entries.clear(); + + _anmRect = Common::Rect(); + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("sound_key", true)) { + _soundKey = atoi(values.c_str()); + } else if (param.matchString("cursor", true)) { + _cursor = _engine->getCursorManager()->getCursorId(values); + } else if (param.matchString("descfile", true)) { + readDescFile(values); + } else if (param.matchString("animation_id", true)) { + _animationId = atoi(values.c_str()); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } +} + +FistControl::~FistControl() { + if (_animation) + delete _animation; + + clearFistArray(_fistsUp); + clearFistArray(_fistsDwn); + _entries.clear(); +} + +void FistControl::renderFrame(uint frameNumber) { + if ((int32)frameNumber == _lastRenderedFrame) + return; + + _lastRenderedFrame = frameNumber; + + const Graphics::Surface *frameData; + + if (_animation) { + frameData = _animation->getFrameData(frameNumber); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect); + } +} + +bool FistControl::process(uint32 deltaTimeInMillis) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_frameCur >= 0 && _frameEnd >= 0) + if (_frameCur <= _frameEnd) { + _frameTime -= deltaTimeInMillis; + + if (_frameTime <= 0) { + _frameTime = _animation->frameTime(); + + renderFrame(_frameCur); + + _frameCur++; + + if (_frameCur > _frameEnd) + _engine->getScriptManager()->setStateValue(_animationId, 2); + } + } + + return false; +} + +bool FistControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (mouseIn(screenSpacePos, backgroundImageSpacePos) >= 0) { + _engine->getCursorManager()->changeCursor(_cursor); + return true; + } + + return false; +} + +bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos); + + if (n_fist >= 0) { + //ctrl_setvenus(ct); + + uint32 oldStatus = _fiststatus; + _fiststatus ^= (1 << n_fist); + + for(int i = 0; i < _numEntries; i++) + if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) { + _frameCur = _entries[i]._anmStrt; + _frameEnd = _entries[i]._anmEnd; + _frameTime = 0; + + _engine->getScriptManager()->setStateValue(_animationId, 1); + _engine->getScriptManager()->setStateValue(_soundKey, _entries[i]._sound); + break; + } + + _engine->getScriptManager()->setStateValue(_key, _fiststatus); + + //_engine->getScriptManager()->FlushMouseBtn(SDL_BUTTON_LEFT); + } + + return false; +} + +void FistControl::readDescFile(const Common::String &fileName) { + Common::File file; + if (!_engine->getSearchManager()->openFile(file, fileName)) { + warning("Desc file %s could could be opened", fileName.c_str()); + return; + } + + Common::String line; + + while (!file.eos()) { + line = file.readLine(); + + for (int i = line.size() - 1; i >= 0; i--) + if (line[i] == '~') + line.deleteChar(i); + + if (line.matchString("*animation_id*", true)) { + // Not used + } else if (line.matchString("*animation*", true)) { + char filename[64]; + sscanf(line.c_str(), "animation:%s", filename); + _animation = new MetaAnimation(Common::String(filename), _engine); + } else if (line.matchString("*anim_rect*", true)) { + int left, top, right, bottom; + sscanf(line.c_str(), "anim_rect:%d %d %d %d", &left, &top, &right, &bottom); + _anmRect = Common::Rect(left, top, right, bottom); + } else if (line.matchString("*num_fingers*", true)) { + sscanf(line.c_str(), "num_fingers:%d", &_fistnum); + _fistsUp.resize(_fistnum); + _fistsDwn.resize(_fistnum); + } else if (line.matchString("*entries*", true)) { + sscanf(line.c_str(), "entries:%d", &_numEntries); + _entries.resize(_numEntries); + } else if (line.matchString("*eval_order_ascending*", true)) { + sscanf(line.c_str(), "eval_order_ascending:%d", &_order); + } else if (line.matchString("*up_hs_num_*", true)) { + int fist, num; + sscanf(line.c_str(), "up_hs_num_%d:%d", &fist, &num); + _fistsUp[fist].resize(num); + } else if (line.matchString("*up_hs_*", true)) { + int16 fist, box, x1, y1, x2, y2; + sscanf(line.c_str(), "up_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2); + (_fistsUp[fist])[box] = Common::Rect(x1, y1, x2, y2); + } else if (line.matchString("*down_hs_num_*", true)) { + int fist, num; + sscanf(line.c_str(), "down_hs_num_%d:%d", &fist, &num); + _fistsDwn[fist].resize(num); + } else if (line.matchString("*down_hs_*", true)) { + int16 fist, box, x1, y1, x2, y2; + sscanf(line.c_str(), "down_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2); + (_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2); + } else { + int entry, start, end, sound; + char bits_start[33]; + char bits_end[33]; + if (sscanf(line.c_str(), "%d:%s %s %d %d (%d)", &entry, bits_start, bits_end, &start, &end, &sound) == 6) { + _entries[entry]._bitsStrt = readBits(bits_start); + _entries[entry]._bitsEnd = readBits(bits_end); + _entries[entry]._anmStrt = start; + _entries[entry]._anmEnd = end; + _entries[entry]._sound = sound; + } + } + } + file.close(); +} + +void FistControl::clearFistArray(Common::Array< Common::Array > &arr) { + for (uint i = 0; i < arr.size(); i++) + arr[i].clear(); + + arr.clear(); +} + +uint32 FistControl::readBits(const char *str) { + uint32 bfield = 0; + int len = strlen(str); + for (int i = 0; i < len; i++) + if (str[i] != '0') + bfield |= (1 << i); + return bfield; +} + +int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_order) { + for(int i = 0; i < _fistnum; i++) { + if (((_fiststatus >> i) & 1) == 1) { + for(uint j = 0; j < _fistsDwn[i].size(); j++) + if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos)) + return i; + } else { + for(uint j = 0; j < _fistsUp[i].size(); j++) + if ((_fistsUp[i])[j].contains(backgroundImageSpacePos)) + return i; + } + } + } else { + for(int i = _fistnum - 1; i >= 0; i--) { + if (((_fiststatus >> i) & 1) == 1) { + for(uint j = 0; j < _fistsDwn[i].size(); j++) + if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos)) + return i; + } else { + for(uint j = 0; j < _fistsUp[i].size(); j++) + if ((_fistsUp[i])[j].contains(backgroundImageSpacePos)) + return i; + } + } + } + return -1; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h new file mode 100644 index 0000000000..940bc96d69 --- /dev/null +++ b/engines/zvision/scripting/controls/fist_control.h @@ -0,0 +1,86 @@ +/* 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 ZVISION_FIST_CONTROL_H +#define ZVISION_FIST_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "common/array.h" +#include "common/rect.h" + + +namespace ZVision { + +class MetaAnimation; + +class FistControl : public Control { +public: + FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~FistControl(); + +private: + uint32 _fiststatus; + int _fistnum; + int16 _cursor; + int _order; + + Common::Array< Common::Array > _fistsUp; + Common::Array< Common::Array > _fistsDwn; + + int32 _numEntries; + + struct entries { + uint32 _bitsStrt; + uint32 _bitsEnd; + int32 _anmStrt; + int32 _anmEnd; + int32 _sound; + }; + + Common::Array _entries; + + MetaAnimation *_animation; + Common::Rect _anmRect; + int32 _soundKey; + int32 _frameCur; + int32 _frameEnd; + int32 _frameTime; + int32 _lastRenderedFrame; + int32 _animationId; + +public: + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + bool process(uint32 deltaTimeInMillis); + +private: + void renderFrame(uint frameNumber); + void readDescFile(const Common::String &fileName); + void clearFistArray(Common::Array< Common::Array > &arr); + uint32 readBits(const char *str); + int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index d6c5aa0cb5..5afa5b2871 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -35,6 +35,7 @@ #include "zvision/scripting/controls/input_control.h" #include "zvision/scripting/controls/safe_control.h" #include "zvision/scripting/controls/hotmov_control.h" +#include "zvision/scripting/controls/fist_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -358,6 +359,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new SafeControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("hotmovie")) { return new HotMovControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("fist")) { + return new FistControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 984858b6382de2e2788fca1469fb380b036989ba Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Sep 2014 23:54:31 +0200 Subject: ACCESS: Fix an issue in checkCode --- engines/access/room.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 3696a4cadf..2c597609e1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -705,9 +705,10 @@ bool Room::codeWalls() { bool Room::checkCode(int v1, int v2) { Player &p = *_vm->_player; - if (!v1) { - } if (!v2 || (v1 == v2)) { - } else if (v1 & 1) { + if (!v1 || !v2 || (v1 == v2)) + return false; + + if (v1 & 1) { if (v2 & 2) { p._collideFlag = true; return true; -- cgit v1.2.3 From 6ae414fbde8421cc66a58a08ac3c8b9ca85f6c73 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 10 Sep 2014 11:42:26 +0700 Subject: ZVISION: PaintControl implemented --- engines/zvision/module.mk | 1 + .../zvision/scripting/controls/paint_control.cpp | 215 +++++++++++++++++++++ engines/zvision/scripting/controls/paint_control.h | 90 +++++++++ engines/zvision/scripting/scr_file_handling.cpp | 3 + 4 files changed, 309 insertions(+) create mode 100644 engines/zvision/scripting/controls/paint_control.cpp create mode 100644 engines/zvision/scripting/controls/paint_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 4cfb8f3182..a7a9523893 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -21,6 +21,7 @@ MODULE_OBJS := \ scripting/controls/hotmov_control.o \ scripting/controls/input_control.o \ scripting/controls/lever_control.o \ + scripting/controls/paint_control.o \ scripting/controls/push_toggle_control.o \ scripting/controls/safe_control.o \ scripting/controls/save_control.o \ diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp new file mode 100644 index 0000000000..a350e9b599 --- /dev/null +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -0,0 +1,215 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/paint_control.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" + +namespace ZVision { + +PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_PAINT) { + + _cursor = CursorIndex_Active; + _paint = NULL; + _bkg = NULL; + _brush = NULL; + _colorKey = 0; + _mouseDown = false; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("rectangle", true)) { + int x; + int y; + int width; + int height; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &width, &height); + + _rectangle = Common::Rect(x, y, width + x, height + y); + } else if (param.matchString("cursor", true)) { + _cursor = _engine->getCursorManager()->getCursorId(values); + } else if (param.matchString("brush_file", true)) { + _brush = _engine->getRenderManager()->loadImage(values, false); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); + } else if (param.matchString("paint_file", true)) { + _paint = _engine->getRenderManager()->loadImage(values, false); + } else if (param.matchString("eligible_objects", true)) { + char buf[256]; + memset(buf, 0, 256); + strcpy(buf, values.c_str()); + + char *curpos = buf; + char *strend = buf + strlen(buf); + while (true) { + char *st = curpos; + + if (st >= strend) + break; + + while (*curpos != ' ' && curpos < strend) + curpos++; + + *curpos = 0; + curpos++; + + int obj = atoi(st); + + _eligible_objects.push_back(obj); + } + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } + + if (_paint) { + _colorKey = _paint->format.RGBToColor(255,0,255); + _bkg = new Graphics::Surface; + _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format); + _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey); + + Graphics::Surface *tmp = new Graphics::Surface; + tmp->create(_rectangle.width(), _rectangle.height(), _paint->format); + _engine->getRenderManager()->blitSurfaceToSurface(*_paint, _rectangle, *tmp, 0, 0); + _paint->free(); + delete _paint; + _paint = tmp; + } + + +} + +PaintControl::~PaintControl() { + // Clear the state value back to 0 + //_engine->getScriptManager()->setStateValue(_key, 0); + if (_paint) + delete _paint; + if (_brush) + delete _brush; + if (_bkg) + delete _bkg; +} + +bool PaintControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + _mouseDown = false; + + return false; +} + +bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_rectangle.contains(backgroundImageSpacePos)) { + int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + + if (eligeblity(mouse_item)) { + _mouseDown = true; + } + } + + return false; +} + +bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { + if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) + return false; + + if (_rectangle.contains(backgroundImageSpacePos)) { + int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + + if (eligeblity(mouse_item)) { + _engine->getCursorManager()->changeCursor(_cursor); + + if (_mouseDown) { + Common::Rect bkgRect = paint(backgroundImageSpacePos); + if (!bkgRect.isEmpty()) { + Common::Rect imgRect = bkgRect; + imgRect.translate(-_rectangle.left, -_rectangle.top); + + Graphics::Surface imgUpdate = _bkg->getSubArea(imgRect); + + _engine->getRenderManager()->blitSurfaceToBkg(imgUpdate, bkgRect.left, bkgRect.top, _colorKey); + } + } + return true; + } + } + + return false; +} + +bool PaintControl::eligeblity(int item_id) { + for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) + if (*it == item_id) + return true; + return false; +} + +Common::Rect PaintControl::paint(const Common::Point &point) { + Common::Rect paint_rect = Common::Rect(_brush->w, _brush->h); + paint_rect.moveTo(point); + paint_rect.clip(_rectangle); + + if (!paint_rect.isEmpty()) { + Common::Rect brush_rect = paint_rect; + brush_rect.translate(-point.x, -point.y); + + Common::Rect bkg_rect = paint_rect; + bkg_rect.translate( -_rectangle.left, -_rectangle.top ); + + for (int yy = 0; yy < brush_rect.height(); yy++) { + uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy); + uint16 *from = (uint16 *)_paint->getBasePtr(bkg_rect.left, bkg_rect.top + yy); + uint16 *to = (uint16 *)_bkg->getBasePtr(bkg_rect.left, bkg_rect.top + yy); + for (int xx = 0; xx < brush_rect.width(); xx++) { + if (*mask != 0) + *(to + xx) = *(from + xx); + + mask++; + } + } + + } + return paint_rect; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h new file mode 100644 index 0000000000..c74431e681 --- /dev/null +++ b/engines/zvision/scripting/controls/paint_control.h @@ -0,0 +1,90 @@ +/* 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 ZVISION_PAINT_CONTROL_H +#define ZVISION_PAINT_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "graphics/surface.h" + +#include "common/rect.h" +#include "common/list.h" + + +namespace ZVision { + +class PaintControl : public Control { +public: + PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~PaintControl(); + + /** + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + + /** + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + */ + bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + /** + * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. + * + * @param engine The base engine + * @param screenSpacePos The position of the mouse in screen space + * @param backgroundImageSpacePos The position of the mouse in background image space + * @return Was the cursor changed? + */ + bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + + bool process(uint32 deltaTimeInMillis) { return false; }; + +private: + /** + * The area that will trigger the event + * This is in image space coordinates, NOT screen space + */ + + uint32 _colorKey; + + Graphics::Surface *_paint; + Graphics::Surface *_bkg; + Graphics::Surface *_brush; + + Common::List _eligible_objects; + + int _cursor; + Common::Rect _rectangle; + + bool _mouseDown; + + bool eligeblity(int item_id); + Common::Rect paint(const Common::Point &point); + +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 5afa5b2871..0e53eec182 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -36,6 +36,7 @@ #include "zvision/scripting/controls/safe_control.h" #include "zvision/scripting/controls/hotmov_control.h" #include "zvision/scripting/controls/fist_control.h" +#include "zvision/scripting/controls/paint_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -361,6 +362,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new HotMovControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("fist")) { return new FistControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("paint")) { + return new PaintControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 39c3a26bfa50aae3b189773a75fe77cbebd17064 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 10 Sep 2014 16:17:30 +0700 Subject: ZVISION: Fix setStateFlag->setStateValue in HotMov control --- engines/zvision/scripting/controls/hotmov_control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index 8ffc3392be..b39292f1c5 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -51,7 +51,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt _num_cycles = 0; _num_frames = 0; - _engine->getScriptManager()->setStateFlag(_key, 0); + _engine->getScriptManager()->setStateValue(_key, 0); // Loop until we find the closing brace Common::String line = stream.readLine(); @@ -129,7 +129,7 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) { if (_cycle != _num_cycles) renderFrame(_cur_frame); else - _engine->getScriptManager()->setStateFlag(_key, 2); + _engine->getScriptManager()->setStateValue(_key, 2); _frame_time = _animation->frameTime(); } -- cgit v1.2.3 From 2a6c2fdf4532e6f5ba3a2a6f8a0e78db4dcdc635 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 10 Sep 2014 16:20:50 +0700 Subject: ZVISION: Titler control and DisplayMessage action implemented --- engines/zvision/module.mk | 1 + engines/zvision/scripting/actions.cpp | 18 ++++ engines/zvision/scripting/actions.h | 2 + .../zvision/scripting/controls/titler_control.cpp | 108 +++++++++++++++++++++ .../zvision/scripting/controls/titler_control.h | 55 +++++++++++ engines/zvision/scripting/scr_file_handling.cpp | 5 +- 6 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/scripting/controls/titler_control.cpp create mode 100644 engines/zvision/scripting/controls/titler_control.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index a7a9523893..6734fde6e2 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -26,6 +26,7 @@ MODULE_OBJS := \ scripting/controls/safe_control.o \ scripting/controls/save_control.o \ scripting/controls/slot_control.o \ + scripting/controls/titler_control.o \ scripting/inventory.o \ scripting/scr_file_handling.o \ scripting/script_manager.o \ diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 22fbd4ff16..399a81d898 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -34,6 +34,7 @@ #include "zvision/scripting/sidefx/syncsound_node.h" #include "zvision/scripting/sidefx/animation_node.h" #include "zvision/scripting/sidefx/ttytext_node.h" +#include "zvision/scripting/controls/titler_control.h" #include "common/file.h" @@ -167,6 +168,23 @@ bool ActionDisableControl::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionDisplayMessage +////////////////////////////////////////////////////////////////////////////// + +ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%hd %hd", &_control, &_msgid); +} + +bool ActionDisplayMessage::execute() { + Control *ctrl = _engine->getScriptManager()->getControl(_control); + if (ctrl && ctrl->getType() == Control::CONTROL_TITLER) { + TitlerControl *titler = (TitlerControl *)ctrl; + titler->setString(_msgid); + } + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionEnableControl diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index c60aedcdf3..de303a7b1b 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -189,6 +189,8 @@ public: bool execute(); private: + int16 _control; + int16 _msgid; }; class ActionDissolve : public ResultAction { diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp new file mode 100644 index 0000000000..b803501033 --- /dev/null +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -0,0 +1,108 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/controls/titler_control.h" + +#include "zvision/zvision.h" +#include "zvision/text/text.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/utility/utility.h" + +#include "common/stream.h" + + +namespace ZVision { + +TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) + : Control(engine, key, CONTROL_TITLER) { + + _surface = NULL; + _curString = -1; + + // Loop until we find the closing brace + Common::String line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + + while (!stream.eos() && !line.contains('}')) { + if (param.matchString("string_resource_file", true)) { + readStringsFile(values); + } else if (param.matchString("rectangle", true)) { + int x; + int y; + int x2; + int y2; + + sscanf(values.c_str(), "%d %d %d %d", &x, &y, &x2, &y2); + + _rectangle = Common::Rect(x, y, x2, y2); + } + + line = stream.readLine(); + trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); + } + + if (!_rectangle.isEmpty()) { + _surface = new Graphics::Surface; + _surface->create(_rectangle.width(), _rectangle.height(), _engine->_pixelFormat); + _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0); + } +} + +TitlerControl::~TitlerControl() { + if (_surface) + delete _surface; +} + +void TitlerControl::setString(int strLine) { + if (strLine != _curString && strLine >= 0 && strLine < (int)_strings.size()) { + _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0); + _engine->getTextRenderer()->drawTxtInOneLine(_strings[strLine], *_surface); + _engine->getRenderManager()->blitSurfaceToBkg(*_surface, _rectangle.left, _rectangle.top); + _curString = strLine; + } +} + +void TitlerControl::readStringsFile(const Common::String &fileName) { + Common::File file; + if (!_engine->getSearchManager()->openFile(file, fileName)) { + warning("String_resource_file %s could could be opened", fileName.c_str()); + return; + } + + _strings.clear(); + + while (!file.eos()) { + + Common::String line = readWideLine(file); + _strings.push_back(line); + } + file.close(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h new file mode 100644 index 0000000000..ee230afa97 --- /dev/null +++ b/engines/zvision/scripting/controls/titler_control.h @@ -0,0 +1,55 @@ +/* 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 ZVISION_TITLER_CONTROL_H +#define ZVISION_TITLER_CONTROL_H + +#include "zvision/scripting/control.h" + +#include "graphics/surface.h" + +#include "common/rect.h" +#include "common/array.h" + + +namespace ZVision { + +class TitlerControl : public Control { +public: + TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); + ~TitlerControl(); + + void setString(int strLine); + +private: + + Common::Array< Common::String > _strings; + Common::Rect _rectangle; + int16 _curString; + Graphics::Surface *_surface; + + void readStringsFile(const Common::String &fileName); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 0e53eec182..04378f856f 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -37,6 +37,7 @@ #include "zvision/scripting/controls/hotmov_control.h" #include "zvision/scripting/controls/fist_control.h" #include "zvision/scripting/controls/paint_control.h" +#include "zvision/scripting/controls/titler_control.h" #include "common/textconsole.h" #include "common/file.h" @@ -237,7 +238,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("disable_venus", true)) { // TODO: Implement ActionDisableVenus } else if (act.matchString("display_message", true)) { - // TODO: Implement ActionDisplayMessage + actionList.push_back(new ActionDisplayMessage(_engine, slot, args)); } else if (act.matchString("dissolve", true)) { // TODO: Implement ActionDissolve } else if (act.matchString("distort", true)) { @@ -364,6 +365,8 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS return new FistControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("paint")) { return new PaintControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("titler")) { + return new TitlerControl(_engine, key, stream); } return NULL; } -- cgit v1.2.3 From 6f03127512a31db27a43e6ca899a909b618fff7f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 11 Sep 2014 23:59:17 +0200 Subject: ACCESS: Implement setInactive and mWhile --- engines/access/amazon/amazon_game.cpp | 2 ++ engines/access/amazon/amazon_game.h | 7 ++++-- engines/access/amazon/amazon_scripts.cpp | 43 ++++++++++++++++++++++++++++++-- engines/access/amazon/amazon_scripts.h | 3 +++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 0725863444..66b77d66d2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -37,7 +37,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), _noSound(_flags[239]) { + _skipStart = false; + _charSegSwitch = false; _canoeLane = 0; _canoeYPos = 0; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 3929eb1485..d0f1b2d043 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -65,8 +65,6 @@ private: int _topList; int _botList; int _riverIndex; - int _rawInactiveX; - int _rawInactiveY; int _inactiveYOff; int _esTabTable[100]; @@ -114,6 +112,11 @@ protected: */ virtual void synchronize(Common::Serializer &s); public: + bool _charSegSwitch; + + int _rawInactiveX; + int _rawInactiveY; + // Fields that are mapped to flags int &_guardLocation; int &_guardFind; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 104473ac7d..24cd8b9ab4 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -34,6 +34,45 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _game = (AmazonEngine *)_vm; } +void AmazonScripts::mWhile(int param1) { + switch(param1) { + case 1: + warning("TODO MWHILE1"); + break; + case 2: + warning("TODO FLY"); + break; + case 3: + warning("TODO FALL"); + break; + case 4: + warning("TODO JWALK"); + break; + case 5: + warning("TODO DOOPEN"); + break; + case 6: + warning("TODO DOWNRIVER"); + break; + case 7: + warning("MWHILE2"); + break; + case 8: + warning("JWALK2"); + break; + default: + break; + } +} + +void AmazonScripts::setInactive() { + _game->_rawInactiveX = _vm->_player->_rawPlayer.x; + _game->_rawInactiveY = _vm->_player->_rawPlayer.y; + _game->_charSegSwitch = false; + + mWhile(_game->_rawInactiveY); +} + void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: @@ -46,10 +85,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO DOCAST"); break; case 4: - warning("TODO SETINACTIVE"); + setInactive(); break; case 6: - warning("TODO MWHILE"); + mWhile(param1); break; case 9: warning("TODO GUARD"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 978ef0105c..45caa5fa6b 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -39,6 +39,9 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); + void mWhile(int param1); + void setInactive(); + void cmdHelp(); void CMDCYCLEBACK(); void CMDCHAPTER(); -- cgit v1.2.3 From 5016b2e768688d449b3fd9c42e243da61b12b1f4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Sep 2014 19:23:06 +0200 Subject: ACCESS: Implement a coupld of special commands --- engines/access/amazon/amazon_scripts.cpp | 22 +++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 24cd8b9ab4..c5b49ab630 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -65,6 +65,17 @@ void AmazonScripts::mWhile(int param1) { } } +void AmazonScripts::loadBackground(int param1, int param2) { + _vm->_files->_loadPalFlag = false; + _vm->_files->loadScreen(param1, param2); + + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + _vm->_screen->forceFadeOut(); + +} + void AmazonScripts::setInactive() { _game->_rawInactiveX = _vm->_player->_rawPlayer.x; _game->_rawInactiveY = _vm->_player->_rawPlayer.y; @@ -73,13 +84,22 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } +void AmazonScripts::boatWalls(int param1, int param2) { + if (param1 == 1) + _vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42); + else { + _vm->_room->_plotter._walls[39].bottom = _vm->_room->_plotter._walls[41].bottom = 106; + _vm->_room->_plotter._walls[40].left = 94; + } +} + void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: _vm->establish(param1, param2); break; case 2: - warning("TODO LOADBACKGROUND"); + loadBackground(param1, param2); break; case 3: warning("TODO DOCAST"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 45caa5fa6b..4845863a21 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -40,7 +40,9 @@ protected: virtual void executeCommand(int commandIndex); void mWhile(int param1); + void loadBackground(int param1, int param2); void setInactive(); + void boatWalls(int param1, int param2); void cmdHelp(); void CMDCYCLEBACK(); -- cgit v1.2.3 From 7a1650b3d35e767a254e2ffb0d3bb84d358c37f1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Sep 2014 19:24:42 +0200 Subject: ACCESS: Add missing call to boatWalls --- engines/access/amazon/amazon_scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index c5b49ab630..7ab4a80063 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -126,7 +126,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO ANT"); break; case 15: - warning("TODO BOATWALLS"); + boatWalls(param1, param2); break; default: warning("Unexpected Special code %d - Skipped", commandIndex); -- cgit v1.2.3 From d37534fa9b5024cf8cb31b7009b1ac75bb660497 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Sep 2014 23:28:36 +0200 Subject: ACCESS: Implement mWhile1 --- engines/access/amazon/amazon_scripts.cpp | 123 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 + 2 files changed, 123 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7ab4a80063..4439a287c3 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -34,6 +34,125 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _game = (AmazonEngine *)_vm; } +void AmazonScripts::cLoop() { + searchForSequence(); + _vm->_images.clear(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_oldRects.clear(); + _vm->_scripts->executeScript(); + _vm->plotList1(); + _vm->copyBlocks(); +} + +void AmazonScripts::mWhile1() { + _vm->_screen->setDisplayScan(); + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 0); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_screen->forceFadeIn(); + + Resource *spriteData = _vm->_files->loadFile(14, 6); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2100; + + do { + cLoop(); + _sequence = 2100; + } while (_vm->_flags[52] == 1); + + _vm->_screen->copyFrom(_vm->_buffer1); + _vm->_buffer1.copyFrom(_vm->_buffer2); + + _game->establish(-1, 14); + + spriteData = _vm->_files->loadFile(14, 7); + _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_sound->playSound(0); + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 1); + _vm->_screen->setPalette(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2200; + + _vm->_sound->queueSound(0, 14, 15); + _vm->_sound->_soundPriority[0] = 1; + + do { + cLoop(); + _sequence = 2200; + } while (_vm->_flags[52] == 2); + + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 2); + _vm->_screen->setPalette(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->freeCells(); + + spriteData = _vm->_files->loadFile(14, 8); + _vm->_objectsTable[2] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2300; + _vm->_sound->playSound(0); + + do { + cLoop(); + _sequence = 2300; + } while (_vm->_flags[52] == 3); + + _vm->freeCells(); + spriteData = _vm->_files->loadFile(14, 9); + _vm->_objectsTable[3] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 3); + _vm->_screen->setPalette(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2400; + + do { + cLoop(); + _sequence = 2400; + } while (_vm->_flags[52] == 4); +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: @@ -55,10 +174,10 @@ void AmazonScripts::mWhile(int param1) { warning("TODO DOWNRIVER"); break; case 7: - warning("MWHILE2"); + warning("TODO MWHILE2"); break; case 8: - warning("JWALK2"); + warning("TODO JWALK2"); break; default: break; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 4845863a21..735606f1da 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -39,6 +39,8 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); + void cLoop(); + void mWhile1(); void mWhile(int param1); void loadBackground(int param1, int param2); void setInactive(); -- cgit v1.2.3 From c58f7146102be3aac2cef5d69bdceb109da3f09f Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 16 Sep 2014 13:49:27 -0500 Subject: COMMON: Add support for endian-safe reading/writing of int64 --- common/endian.h | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/stream.h | 66 +++++++++++++++++++++ 2 files changed, 239 insertions(+) diff --git a/common/endian.h b/common/endian.h index 6d6563f802..a18e6f088b 100644 --- a/common/endian.h +++ b/common/endian.h @@ -49,6 +49,17 @@ # error No endianness defined #endif + +#define SWAP_CONSTANT_64(a) \ + ((uint64)((((a) >> 56) & 0x000000FF) | \ + (((a) >> 40) & 0x0000FF00) | \ + (((a) >> 24) & 0x00FF0000) | \ + (((a) >> 8) & 0xFF000000) | \ + (((a) & 0xFF000000) << 8) | \ + (((a) & 0x00FF0000) << 24) | \ + (((a) & 0x0000FF00) << 40) | \ + (((a) & 0x000000FF) << 56) )) + #define SWAP_CONSTANT_32(a) \ ((uint32)((((a) >> 24) & 0x00FF) | \ (((a) >> 8) & 0xFF00) | \ @@ -59,6 +70,62 @@ ((uint16)((((a) >> 8) & 0x00FF) | \ (((a) << 8) & 0xFF00) )) +/** + * Swap the bytes in a 64 bit word in order to convert LE encoded data to BE + * and vice versa. + */ + +// machine/compiler-specific variants come first, fallback last + +// Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does) +// +// TODO: Fix this #if statement. It isn't changed from 32 bit. Is there a 64 bit swap instruction? +#if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2)) + + FORCEINLINE uint32 SWAP_BYTES_32(const uint32 a) { + if (__builtin_constant_p(a)) { + return SWAP_CONSTANT_32(a); + } else { + uint32 result; +# if defined(__psp__) + // use special allegrex instruction + __asm__ ("wsbw %0,%1" : "=r" (result) : "r" (a)); +# else + __asm__ ("wsbh %0,%1\n" + "rotr %0,%0,16" : "=r" (result) : "r" (a)); +# endif + return result; + } + } + +// Test for GCC >= 4.3.0 as this version added the bswap builtin +#elif GCC_ATLEAST(4, 3) + + FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { + return __builtin_bswap64(a); + } + +#elif defined(_MSC_VER) + + FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { + return _byteswap_uint64(a); + } + +// generic fallback +#else + + inline uint64 SWAP_BYTES_64(uint64 a) { + uint32 low = (uint32)a, high = (uint32)(a >> 32); + uint16 lowLow = (uint16)low, lowHigh = (uint16)(low >> 16), + highLow = (uint16)high, highHigh = (uint16)(high >> 16); + + return ((uint64)(((uint32)(uint16)((lowLow >> 8) | (lowLow << 8)) << 16) | + (uint16)((lowHigh >> 8) | (lowHigh << 8))) << 32) | + (((uint32)(uint16)((highLow >> 8) | (highLow << 8)) << 16) | + (uint16)((highHigh >> 8) | (highHigh << 8))) + } +#endif + /** * Swap the bytes in a 32 bit word in order to convert LE encoded data to BE * and vice versa. @@ -173,6 +240,11 @@ return ((const Unaligned32 *)ptr)->val; } + FORCEINLINE uint64 READ_UINT64(const void *ptr) { + struct Unaligned64 { uint64 val; } __attribute__ ((__packed__, __may_alias__)); + return ((const Unaligned64 *)ptr)->val; + } + FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); ((Unaligned16 *)ptr)->val = value; @@ -183,6 +255,11 @@ ((Unaligned32 *)ptr)->val = value; } + FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) { + struct Unaligned64 { uint64 val; } __attribute__((__packed__, __may_alias__)); + ((Unaligned64 *)ptr)->val = value; + } + #elif !defined(SCUMM_NEED_ALIGNMENT) FORCEINLINE uint16 READ_UINT16(const void *ptr) { @@ -193,6 +270,10 @@ return *(const uint32 *)(ptr); } + FORCEINLINE uint64 READ_UINT64(const void *ptr) { + return *(const uint64 *)(ptr); + } + FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { *(uint16 *)(ptr) = value; } @@ -201,6 +282,10 @@ *(uint32 *)(ptr) = value; } + FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) { + *(uint64 *)(ptr) = value; + } + // use software fallback by loading each byte explicitely #else @@ -215,6 +300,10 @@ const uint8 *b = (const uint8 *)ptr; return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); } + inline uint64 READ_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); + } inline void WRITE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -227,6 +316,17 @@ b[2] = (uint8)(value >> 16); b[3] = (uint8)(value >> 24); } + inline void WRITE_UINT64(void *ptr, uint64 value) { + uint8 *b = (uint8 *)ptr; + b[0] = (uint8)(value >> 0); + b[1] = (uint8)(value >> 8); + b[2] = (uint8)(value >> 16); + b[3] = (uint8)(value >> 24); + b[4] = (uint8)(value >> 32); + b[5] = (uint8)(value >> 40); + b[6] = (uint8)(value >> 48); + b[7] = (uint8)(value >> 56); + } # elif defined(SCUMM_BIG_ENDIAN) @@ -238,6 +338,10 @@ const uint8 *b = (const uint8 *)ptr; return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]); } + inline uint64 READ_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[0] << 56) | (b[1] << 48) | (b[2] << 40) | (b[3] << 32) | (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); + } inline void WRITE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 8); @@ -250,6 +354,17 @@ b[2] = (uint8)(value >> 8); b[3] = (uint8)(value >> 0); } + inline void WRITE_UINT64(void *ptr, uint64 value) { + uint8 *b = (uint8 *)ptr; + b[0] = (uint8)(value >> 56); + b[1] = (uint8)(value >> 48); + b[2] = (uint8)(value >> 40); + b[3] = (uint8)(value >> 32); + b[4] = (uint8)(value >> 24); + b[5] = (uint8)(value >> 16); + b[6] = (uint8)(value >> 8); + b[7] = (uint8)(value >> 0); + } # endif @@ -261,25 +376,33 @@ #define READ_LE_UINT16(a) READ_UINT16(a) #define READ_LE_UINT32(a) READ_UINT32(a) + #define READ_LE_UINT64(a) READ_UINT64(a) #define WRITE_LE_UINT16(a, v) WRITE_UINT16(a, v) #define WRITE_LE_UINT32(a, v) WRITE_UINT32(a, v) + #define WRITE_LE_UINT64(a, v) WRITE_UINT64(a, v) + #define FROM_LE_64(a) ((uint64)(a)) #define FROM_LE_32(a) ((uint32)(a)) #define FROM_LE_16(a) ((uint16)(a)) + #define FROM_BE_64(a) SWAP_BYTES_64(a) #define FROM_BE_32(a) SWAP_BYTES_32(a) #define FROM_BE_16(a) SWAP_BYTES_16(a) + #define TO_LE_64(a) ((uint64)(a)) #define TO_LE_32(a) ((uint32)(a)) #define TO_LE_16(a) ((uint16)(a)) + #define TO_BE_64(a) SWAP_BYTES_64(a) #define TO_BE_32(a) SWAP_BYTES_32(a) #define TO_BE_16(a) SWAP_BYTES_16(a) + #define CONSTANT_LE_64(a) ((uint64)(a)) #define CONSTANT_LE_32(a) ((uint32)(a)) #define CONSTANT_LE_16(a) ((uint16)(a)) + #define CONSTANT_BE_64(a) SWAP_CONSTANT_64(a) #define CONSTANT_BE_32(a) SWAP_CONSTANT_32(a) #define CONSTANT_BE_16(a) SWAP_CONSTANT_16(a) @@ -294,6 +417,10 @@ const uint8 *b = (const uint8 *)ptr; return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]); } + inline uint64 READ_BE_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[0] << 56) | b[1] << 48) | b[2] << 40) | b[3] << 32) | b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); + } inline void WRITE_BE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 8); @@ -306,6 +433,17 @@ b[2] = (uint8)(value >> 8); b[3] = (uint8)(value >> 0); } + inline void WRITE_BE_UINT64(void *ptr, uint64 value) { + uint8 *b = (uint8 *)ptr; + b[0] = (uint8)(value >> 56); + b[1] = (uint8)(value >> 48); + b[2] = (uint8)(value >> 40); + b[3] = (uint8)(value >> 32); + b[4] = (uint8)(value >> 24); + b[5] = (uint8)(value >> 16); + b[6] = (uint8)(value >> 8); + b[7] = (uint8)(value >> 0); + } # else inline uint16 READ_BE_UINT16(const void *ptr) { @@ -314,12 +452,18 @@ inline uint32 READ_BE_UINT32(const void *ptr) { return SWAP_BYTES_32(READ_UINT32(ptr)); } + inline uint32 READ_BE_UINT64(const void *ptr) { + return SWAP_BYTES_64(READ_UINT64(ptr)); + } inline void WRITE_BE_UINT16(void *ptr, uint16 value) { WRITE_UINT16(ptr, SWAP_BYTES_16(value)); } inline void WRITE_BE_UINT32(void *ptr, uint32 value) { WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } + inline void WRITE_BE_UINT64(void *ptr, uint64 value) { + WRITE_UINT64(ptr, SWAP_BYTES_64(value)); + } # endif // if defined(SCUMM_NEED_ALIGNMENT) @@ -327,25 +471,33 @@ #define READ_BE_UINT16(a) READ_UINT16(a) #define READ_BE_UINT32(a) READ_UINT32(a) + #define READ_BE_UINT64(a) READ_UINT64(a) #define WRITE_BE_UINT16(a, v) WRITE_UINT16(a, v) #define WRITE_BE_UINT32(a, v) WRITE_UINT32(a, v) + #define WRITE_BE_UINT64(a, v) WRITE_UINT64(a, v) + #define FROM_LE_64(a) SWAP_BYTES_64(a) #define FROM_LE_32(a) SWAP_BYTES_32(a) #define FROM_LE_16(a) SWAP_BYTES_16(a) + #define FROM_BE_64(a) ((uint64)(a)) #define FROM_BE_32(a) ((uint32)(a)) #define FROM_BE_16(a) ((uint16)(a)) + #define TO_LE_64(a) SWAP_BYTES_64(a) #define TO_LE_32(a) SWAP_BYTES_32(a) #define TO_LE_16(a) SWAP_BYTES_16(a) + #define TO_BE_64(a) ((uint64)(a)) #define TO_BE_32(a) ((uint32)(a)) #define TO_BE_16(a) ((uint16)(a)) + #define CONSTANT_LE_64(a) SWAP_CONSTANT_64(a) #define CONSTANT_LE_32(a) SWAP_CONSTANT_32(a) #define CONSTANT_LE_16(a) SWAP_CONSTANT_16(a) + #define CONSTANT_BE_64(a) ((uint64)(a)) #define CONSTANT_BE_32(a) ((uint32)(a)) #define CONSTANT_BE_16(a) ((uint16)(a)) @@ -360,6 +512,10 @@ const uint8 *b = (const uint8 *)ptr; return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); } + inline uint64 READ_LE_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); + } inline void WRITE_LE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -372,6 +528,17 @@ b[2] = (uint8)(value >> 16); b[3] = (uint8)(value >> 24); } + inline void WRITE_LE_UINT64(void *ptr, uint64 value) { + uint8 *b = (uint8 *)ptr; + b[0] = (uint8)(value >> 0); + b[1] = (uint8)(value >> 8); + b[2] = (uint8)(value >> 16); + b[3] = (uint8)(value >> 24); + b[4] = (uint8)(value >> 32); + b[5] = (uint8)(value >> 40); + b[6] = (uint8)(value >> 48); + b[7] = (uint8)(value >> 56); + } # else inline uint16 READ_LE_UINT16(const void *ptr) { @@ -380,12 +547,18 @@ inline uint32 READ_LE_UINT32(const void *ptr) { return SWAP_BYTES_32(READ_UINT32(ptr)); } + inline uint64 READ_LE_UINT64(const void *ptr) { + return SWAP_BYTES_64(READ_UINT64(ptr)); + } inline void WRITE_LE_UINT16(void *ptr, uint16 value) { WRITE_UINT16(ptr, SWAP_BYTES_16(value)); } inline void WRITE_LE_UINT32(void *ptr, uint32 value) { WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } + inline void WRITE_LE_UINT64(void *ptr, uint64 value) { + WRITE_UINT64(ptr, SWAP_BYTES_64(value)); + } # endif // if defined(SCUMM_NEED_ALIGNMENT) diff --git a/common/stream.h b/common/stream.h index 2702068cf3..5655f0fcb4 100644 --- a/common/stream.h +++ b/common/stream.h @@ -125,6 +125,11 @@ public: write(&value, 4); } + void writeUint64LE(uint64 value) { + value = TO_LE_64(value); + write(&value, 8); + } + void writeUint16BE(uint16 value) { value = TO_BE_16(value); write(&value, 2); @@ -135,6 +140,11 @@ public: write(&value, 4); } + void writeUint64BE(uint64 value) { + value = TO_BE_64(value); + write(&value, 8); + } + FORCEINLINE void writeSint16LE(int16 value) { writeUint16LE((uint16)value); } @@ -143,6 +153,10 @@ public: writeUint32LE((uint32)value); } + FORCEINLINE void writeSint64LE(int64 value) { + writeUint64LE((uint64)value); + } + FORCEINLINE void writeSint16BE(int16 value) { writeUint16BE((uint16)value); } @@ -151,6 +165,10 @@ public: writeUint32BE((uint32)value); } + FORCEINLINE void writeSint64BE(int64 value) { + writeUint64BE((uint64)value); + } + /** * Write the given string to the stream. * This writes str.size() characters, but no terminating zero byte. @@ -241,6 +259,19 @@ public: return FROM_LE_32(val); } + /** + * Read an unsigned 64-bit word stored in little endian (LSB first) order + * from the stream and return it. + * Performs no error checking. The return value is undefined + * if a read error occurred (for which client code can check by + * calling err() and eos() ). + */ + uint32 readUint64LE() { + uint64 val; + read(&val, 8); + return FROM_LE_64(val); + } + /** * Read an unsigned 16-bit word stored in big endian (MSB first) order * from the stream and return it. @@ -267,6 +298,19 @@ public: return FROM_BE_32(val); } + /** + * Read an unsigned 64-bit word stored in big endian (MSB first) order + * from the stream and return it. + * Performs no error checking. The return value is undefined + * if a read error occurred (for which client code can check by + * calling err() and eos() ). + */ + uint32 readUint64BE() { + uint64 val; + read(&val, 8); + return FROM_BE_64(val); + } + /** * Read a signed 16-bit word stored in little endian (LSB first) order * from the stream and return it. @@ -289,6 +333,17 @@ public: return (int32)readUint32LE(); } + /** + * Read a signed 64-bit word stored in little endian (LSB first) order + * from the stream and return it. + * Performs no error checking. The return value is undefined + * if a read error occurred (for which client code can check by + * calling err() and eos() ). + */ + FORCEINLINE int64 readSint64LE() { + return (int64)readUint64LE(); + } + /** * Read a signed 16-bit word stored in big endian (MSB first) order * from the stream and return it. @@ -311,6 +366,17 @@ public: return (int32)readUint32BE(); } + /** + * Read a signed 64-bit word stored in big endian (MSB first) order + * from the stream and return it. + * Performs no error checking. The return value is undefined + * if a read error occurred (for which client code can check by + * calling err() and eos() ). + */ + FORCEINLINE int64 readSint64BE() { + return (int64)readUint64BE(); + } + /** * Read the specified amount of data into a malloc'ed buffer * which then is wrapped into a MemoryReadStream. -- cgit v1.2.3 From 9accfdab6f48daa9dbe47de84f0bda84d4103546 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 16 Sep 2014 22:04:10 +0200 Subject: ACCESS: Implement mWhile2 and plotInactive, change _inactive from Resource* to ImageEntry --- engines/access/access.cpp | 10 ++-- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_room.cpp | 4 +- engines/access/amazon/amazon_scripts.cpp | 96 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 + engines/access/martian/martian_room.cpp | 4 +- 7 files changed, 109 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 55af992dbb..5636654d03 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -55,7 +55,9 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; - _inactive = nullptr; + _inactive._spritesPtr = nullptr; + _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; + _inactive._position = Common::Point(0, 0); _music = nullptr; _title = nullptr; _converseMode = 0; @@ -127,7 +129,7 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete _inactive; + delete _inactive._spritesPtr; delete _music; delete _title; delete _eseg; @@ -212,8 +214,8 @@ void AccessEngine::freeCells() { } void AccessEngine::freeInactiveData() { - delete _inactive; - _inactive = nullptr; + delete _inactive._spritesPtr; + _inactive._spritesPtr = nullptr; } void AccessEngine::speakText(ASurface *s, Common::Array msgArr) { diff --git a/engines/access/access.h b/engines/access/access.h index 42ba49fd5d..157a33c723 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -171,7 +171,7 @@ public: int _mouseMode; int _currentManOld; - Resource *_inactive; + ImageEntry _inactive; Resource *_music; Resource *_title; int _converseMode; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index d0f1b2d043..0275ceec17 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -65,7 +65,6 @@ private: int _topList; int _botList; int _riverIndex; - int _inactiveYOff; int _esTabTable[100]; // Other fields @@ -116,6 +115,7 @@ public: int _rawInactiveX; int _rawInactiveY; + int _inactiveYOff; // Fields that are mapped to flags int &_guardLocation; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 227fc474cf..39cea9ae62 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -77,7 +77,9 @@ void AmazonRoom::reloadRoom() { void AmazonRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { - _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); + _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + delete spriteData; _vm->_currentCharFlag = false; } diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4439a287c3..8c172334a5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -153,10 +153,62 @@ void AmazonScripts::mWhile1() { } while (_vm->_flags[52] == 4); } +void AmazonScripts::mWhile2() { + _vm->_screen->setDisplayScan(); + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 0); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_screen->forceFadeIn(); + + Resource *spriteData = _vm->_files->loadFile(14, 6); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2100; + + do { + cLoop(); + _sequence = 2100; + } while (_vm->_flags[52] == 1); + + _vm->_screen->fadeOut(); + _vm->freeCells(); + spriteData = _vm->_files->loadFile(14, 9); + _vm->_objectsTable[3] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + + _vm->_files->loadScreen(14, 3); + _vm->_screen->setPalette(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_events->showCursor(); + + _vm->_screen->setIconPalette(); + _vm->_images.clear(); + _vm->_oldRects.clear(); + _sequence = 2400; + + do { + cLoop(); + _sequence = 2400; + } while (_vm->_flags[52] == 4); +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: - warning("TODO MWHILE1"); + mWhile1(); break; case 2: warning("TODO FLY"); @@ -174,7 +226,7 @@ void AmazonScripts::mWhile(int param1) { warning("TODO DOWNRIVER"); break; case 7: - warning("TODO MWHILE2"); + mWhile2(); break; case 8: warning("TODO JWALK2"); @@ -212,6 +264,44 @@ void AmazonScripts::boatWalls(int param1, int param2) { } } +void AmazonScripts::plotInactive() { + if (_game->_charSegSwitch) { + _game->_currentCharFlag = true; + SpriteResource *tmp = _vm->_inactive._spritesPtr; + _vm->_inactive._spritesPtr = _vm->_player->_playerSprites; + _vm->_player->_playerSprites = tmp; + _game->_charSegSwitch = false; + } else if (_game->_jasMayaFlag != _game->_currentCharFlag) { + if (_vm->_player->_playerOff) { + _game->_jasMayaFlag = _game->_currentCharFlag; + } else { + _game->_currentCharFlag = _game->_jasMayaFlag; + int tmpX = _game->_rawInactiveX; + int tmpY = _game->_rawInactiveY; + _game->_rawInactiveX = _vm->_player->_rawPlayer.x; + _game->_rawInactiveY = _vm->_player->_rawPlayer.y; + _vm->_player->_rawPlayer.x = tmpX; + _vm->_player->_rawPlayer.y = tmpY; + _game->_inactiveYOff = _vm->_player->_playerOffset.y; + _vm->_player->calcManScale(); + } + } + + if (_vm->_player->_roomNumber == 44) { + warning("CHECKME: Only sets useless(?) flags 155 and 160"); + } + + _vm->_inactive._flags &= 0xFD; + _vm->_inactive._flags &= 0xF7; + _vm->_inactive._position.x = _game->_rawInactiveX; + _vm->_inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff; + _vm->_inactive._offsetY = _game->_inactiveYOff; + _vm->_inactive._frameNumber = 0; + + _vm->_images.addToList(&_vm->_inactive); + +} + void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: @@ -236,7 +326,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO NEWMUSIC"); break; case 11: - warning("TODO PLOTINACTIVE"); + plotInactive(); break; case 13: warning("TODO RIVER"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 735606f1da..7afa0ea577 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -41,8 +41,10 @@ protected: void cLoop(); void mWhile1(); + void mWhile2(); void mWhile(int param1); void loadBackground(int param1, int param2); + void plotInactive(); void setInactive(); void boatWalls(int param1, int param2); diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 52eead7c0b..e624b0abd5 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -75,7 +75,9 @@ void MartianRoom::reloadRoom() { void MartianRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { - _vm->_inactive = _vm->_files->loadFile("MAYA.LZ"); + Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); + _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + delete spriteData; _vm->_currentCharFlag = false; } -- cgit v1.2.3 From 2afca5a06eafff24b2892c7270ab994b04ffb8d4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 16 Sep 2014 22:12:24 +0200 Subject: ACCESS: Fix bool/int comparisons and assignments --- engines/access/amazon/amazon_scripts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 8c172334a5..8d63da2c8f 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -271,11 +271,11 @@ void AmazonScripts::plotInactive() { _vm->_inactive._spritesPtr = _vm->_player->_playerSprites; _vm->_player->_playerSprites = tmp; _game->_charSegSwitch = false; - } else if (_game->_jasMayaFlag != _game->_currentCharFlag) { + } else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) { if (_vm->_player->_playerOff) { - _game->_jasMayaFlag = _game->_currentCharFlag; + _game->_jasMayaFlag = (_game->_currentCharFlag ? 1 : 0); } else { - _game->_currentCharFlag = _game->_jasMayaFlag; + _game->_currentCharFlag = (_game->_jasMayaFlag == 1); int tmpX = _game->_rawInactiveX; int tmpY = _game->_rawInactiveY; _game->_rawInactiveX = _vm->_player->_rawPlayer.x; -- cgit v1.2.3 From a597838490981e89ddefcc79fb21127044802b25 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 18 Sep 2014 08:34:47 +0200 Subject: ACCESS: Implement guard() --- engines/access/amazon/amazon_scripts.cpp | 69 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 3 ++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 8d63da2c8f..a932dad216 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -236,6 +236,73 @@ void AmazonScripts::mWhile(int param1) { } } +void AmazonScripts::guardSee() { + warning("TODO: guardSee()"); +} + +void AmazonScripts::setGuardFrame() { + warning("TODO: setGuardFrame()"); +} + +void AmazonScripts::guard() { + if (_vm->_timers[8]._flag != 0) + return; + + ++_vm->_timers[8]._flag; + ++_game->_guard._guardCel; + int curCel = _game->_guard._guardCel; + + switch (_game->_guardLocation) { + case 1: + if (curCel <= 8 || curCel > 13) + _game->_guard._guardCel = curCel = 8; + + _game->_guard._position.y = _vm->_player->_walkOffDown[curCel - 8]; + guardSee(); + if (_game->_guard._position.y >= 272) { + _game->_guard._position.y = 272; + _game->_guardLocation = 2; + } + break; + case 2: + if (curCel <= 43 || curCel > 48) + _game->_guard._guardCel = curCel = 43; + + _game->_guard._position.x = _vm->_player->_walkOffLeft[curCel - 43]; + guardSee(); + if (_game->_guard._position.x <= 56) { + _game->_guard._position.x = 56; + _game->_guardLocation = 3; + } + break; + case 3: + if (curCel <= 0 || curCel > 5) + _game->_guard._guardCel = curCel = 0; + + _game->_guard._position.y = _vm->_player->_walkOffUp[curCel]; + guardSee(); + if (_game->_guard._position.y <= 89) { + _game->_guard._position.y = 89; + _game->_guardLocation = 4; + warning("CHECME: unused flag121"); + } + break; + default: + if (curCel <= 43 || curCel > 48) + _game->_guard._guardCel = curCel = 43; + + _game->_guard._position.x = _vm->_player->_walkOffRight[curCel - 43]; + guardSee(); + if (_game->_guard._position.x >= 127) { + _game->_guard._position.x = 127; + _game->_guardLocation = 1; + } + break; + } + + setGuardFrame(); +} + void AmazonScripts::loadBackground(int param1, int param2) { _vm->_files->_loadPalFlag = false; _vm->_files->loadScreen(param1, param2); @@ -320,7 +387,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { mWhile(param1); break; case 9: - warning("TODO GUARD"); + guard(); break; case 10: warning("TODO NEWMUSIC"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 7afa0ea577..50bd2ac9b1 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -43,6 +43,9 @@ protected: void mWhile1(); void mWhile2(); void mWhile(int param1); + void guardSee(); + void setGuardFrame(); + void guard(); void loadBackground(int param1, int param2); void plotInactive(); void setInactive(); -- cgit v1.2.3 From cf63da941cf7b7162551f6d660f5dbbda3150239 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 10 Oct 2014 16:40:46 +0700 Subject: ZVISION: Action:region and visual effects implemented. --- engines/zvision/graphics/effect.h | 83 +++++++++ engines/zvision/graphics/effects/fog.cpp | 174 ++++++++++++++++++ engines/zvision/graphics/effects/fog.h | 52 ++++++ engines/zvision/graphics/effects/light.cpp | 110 ++++++++++++ engines/zvision/graphics/effects/light.h | 53 ++++++ engines/zvision/graphics/effects/wave.cpp | 146 +++++++++++++++ engines/zvision/graphics/effects/wave.h | 51 ++++++ engines/zvision/graphics/render_manager.cpp | 218 ++++++++++++++++++++++- engines/zvision/graphics/render_manager.h | 14 ++ engines/zvision/module.mk | 4 + engines/zvision/scripting/actions.cpp | 80 +++++++++ engines/zvision/scripting/actions.h | 16 ++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.h | 4 +- engines/zvision/scripting/sidefx/region_node.cpp | 56 ++++++ engines/zvision/scripting/sidefx/region_node.h | 57 ++++++ 16 files changed, 1115 insertions(+), 5 deletions(-) create mode 100644 engines/zvision/graphics/effect.h create mode 100644 engines/zvision/graphics/effects/fog.cpp create mode 100644 engines/zvision/graphics/effects/fog.h create mode 100644 engines/zvision/graphics/effects/light.cpp create mode 100644 engines/zvision/graphics/effects/light.h create mode 100644 engines/zvision/graphics/effects/wave.cpp create mode 100644 engines/zvision/graphics/effects/wave.h create mode 100644 engines/zvision/scripting/sidefx/region_node.cpp create mode 100644 engines/zvision/scripting/sidefx/region_node.h diff --git a/engines/zvision/graphics/effect.h b/engines/zvision/graphics/effect.h new file mode 100644 index 0000000000..c6653c6037 --- /dev/null +++ b/engines/zvision/graphics/effect.h @@ -0,0 +1,83 @@ +/* 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 EFFECT_H_INCLUDED +#define EFFECT_H_INCLUDED + +#include "common/rect.h" +#include "common/list.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" + +namespace ZVision { + +class ZVision; + +class Effect { +public: + + Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) { + _surface.create(_region.width(), _region.height(), _engine->_pixelFormat); + } + virtual ~Effect() {} + + uint32 getKey() { + return _key; + } + + Common::Rect getRegion() { + return _region; + } + + bool isPort() { + return _ported; + } + + virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) { + return &_surface; + } + + virtual void update() {} + +protected: + ZVision *_engine; + uint32 _key; + Common::Rect _region; + bool _ported; + Graphics::Surface _surface; + +// Static member functions +public: + +}; + +struct EffectMapUnit { + uint32 count; + bool inEffect; +}; + +typedef Common::List EffectMap; + +} // End of namespace ZVision + +#endif // EFFECT_H_INCLUDED diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp new file mode 100644 index 0000000000..b6c5e7b011 --- /dev/null +++ b/engines/zvision/graphics/effects/fog.cpp @@ -0,0 +1,174 @@ +/* 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 "common/scummsys.h" + +#include "zvision/graphics/effects/fog.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" + + +namespace ZVision { + +FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds): + Effect(engine, key, region, ported) { + + _map = Map; + + _r = 0; + _g = 0; + _b = 0; + + _pos = 0; + + if (_engine->getSearchManager()->hasFile(clouds)) + _engine->getRenderManager()->readImageToSurface(clouds, _fog); + else + _engine->getRenderManager()->readImageToSurface("cloud.tga", _fog); + + _mp.resize(_fog.h); + for (int16 i = 0; i < _fog.h; i++) { + _mp[i].resize(_fog.w); + for (int16 j = 0; j < _fog.w; j++) + _mp[i][j] = true; + } + + for (uint8 i = 0; i < 32; i++) + _colorMap[i] = 0; +} + +FogFx::~FogFx() { + if (_map) + delete _map; + + for (uint16 i = 0; i < _mp.size(); i++) + _mp[i].clear(); + _mp.clear(); +} + +const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) { + _surface.copyFrom(srcSubRect); + EffectMap::iterator it = _map->begin(); + + uint32 cnt = 0; + + for (uint16 j = 0; j < _surface.h; j++) { + uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j); + + for (uint16 i = 0; i < _surface.w; i++) { + if (it->inEffect) { + // Not 100% equivalent, but looks nice and not buggy + uint8 sr, sg, sb; + _engine->_pixelFormat.colorToRGB(lineBuf[i], sr, sg, sb); + uint16 fogColor = *(uint16 *)_fog.getBasePtr((i + _pos) % _fog.w, j); + uint8 dr, dg, db; + _engine->_pixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db); + uint16 fr = dr + sr; + if (fr > 255) + fr = 255; + uint16 fg = dg + sg; + if (fg > 255) + fg = 255; + uint16 fb = db + sb; + if (fb > 255) + fb = 255; + lineBuf[i] = _engine->_pixelFormat.RGBToColor(fr, fg, fb); + } + cnt++; + if (cnt >= it->count) { + it++; + cnt = 0; + } + if (it == _map->end()) + break; + } + if (it == _map->end()) + break; + } + + return &_surface; +} + +void FogFx::update() { + _pos += _engine->getScriptManager()->getStateValue(StateKey_EF9_Speed); + _pos %= _fog.w; + + uint8 dr = _engine->getScriptManager()->getStateValue(StateKey_EF9_R); + uint8 dg = _engine->getScriptManager()->getStateValue(StateKey_EF9_G); + uint8 db = _engine->getScriptManager()->getStateValue(StateKey_EF9_B); + dr = CLIP((int)dr, 0, 31); + dg = CLIP((int)dg, 0, 31); + db = CLIP((int)db, 0, 31); + + if (dr != _r || dg != _g || db != _b) { + if (_r > dr) + _r--; + else if (_r < dr) + _r++; + + if (_g > dg) + _g--; + else if (_g < dg) + _g++; + + if (_b > db) + _b--; + else if (_b < db) + _b++; + + // Not 100% equivalent, but looks nice and not buggy + + _colorMap[31] = _engine->_pixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3); + + for (uint8 i = 0; i < 31; i++) { + float perc = (float)i / 31.0; + uint8 cr = (float)_r * perc; + uint8 cg = (float)_g * perc; + uint8 cb = (float)_b * perc; + _colorMap[i] = _engine->_pixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3); + } + } + + for (uint16 j = 0; j < _fog.h; j++) { + uint16 *pix = (uint16 *)_fog.getBasePtr(0, j); + + for (uint16 i = 0; i < _fog.w; i++) { + if (_mp[j][i]) { + if ((pix[i] & 0x1F) == 0x1F) { + pix[i]--; + _mp[j][i] = false; + } else + pix[i]++; + } else { + if ((pix[i] & 0x1F) == 0) { + pix[i]++; + _mp[j][i] = true; + } else + pix[i]--; + } + } + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h new file mode 100644 index 0000000000..62dd1f9473 --- /dev/null +++ b/engines/zvision/graphics/effects/fog.h @@ -0,0 +1,52 @@ +/* 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 FOGFX_H_INCLUDED +#define FOGFX_H_INCLUDED + +#include "zvision/graphics/effect.h" + +namespace ZVision { + +class ZVision; + +class FogFx : public Effect { +public: + + FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds); + ~FogFx(); + + const Graphics::Surface *draw(const Graphics::Surface &srcSubRect); + + void update(); + +private: + EffectMap *_map; + Graphics::Surface _fog; + uint8 _r, _g, _b; + int32 _pos; + Common::Array< Common::Array< bool > > _mp; + uint16 _colorMap[32]; +}; +} // End of namespace ZVision + +#endif // FOGFX_H_INCLUDED diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp new file mode 100644 index 0000000000..9bff077051 --- /dev/null +++ b/engines/zvision/graphics/effects/light.cpp @@ -0,0 +1,110 @@ +/* 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 "common/scummsys.h" + +#include "zvision/graphics/effects/light.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" + + +namespace ZVision { + +LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD): + Effect(engine, key, region, ported) { + _map = Map; + _delta = delta; + _up = true; + _pos = 0; + + _minD = minD; + if (_minD < -delta) + _minD = -delta; + + _maxD = maxD; + if (_maxD > delta) + _maxD = delta; +} + +LightFx::~LightFx() { + if (_map) + delete _map; +} + +const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) { + _surface.copyFrom(srcSubRect); + EffectMap::iterator it = _map->begin(); + uint32 cnt = 0; + + uint32 dcolor = 0; + + if (_pos < 0) { + uint8 cc = ((-_pos) & 0x1F) << 3; + dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc); + } else { + uint8 cc = (_pos & 0x1F) << 3; + dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc); + } + + for (uint16 j = 0; j < _surface.h; j++) { + uint16 *lineBuf = (uint16 *)_surface.getBasePtr(0, j); + + for (uint16 i = 0; i < _surface.w; i++) { + if (it->inEffect) { + if (_pos < 0) { + lineBuf[i] -= dcolor; + } else { + lineBuf[i] += dcolor; + } + } + cnt++; + if (cnt >= it->count) { + it++; + cnt = 0; + } + if (it == _map->end()) + break; + } + if (it == _map->end()) + break; + } + + return &_surface; +} + +void LightFx::update() { + if (_up) + _pos++; + else + _pos--; + + if (_pos <= _minD) { + _up = !_up; + _pos = _minD; + } else if (_pos >= _maxD) { + _up = !_up; + _pos = _maxD; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/effects/light.h b/engines/zvision/graphics/effects/light.h new file mode 100644 index 0000000000..ae87d66cb3 --- /dev/null +++ b/engines/zvision/graphics/effects/light.h @@ -0,0 +1,53 @@ +/* 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 LIGHTFX_H_INCLUDED +#define LIGHTFX_H_INCLUDED + +#include "zvision/graphics/effect.h" + +namespace ZVision { + +class ZVision; + +class LightFx : public Effect { +public: + + LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127); + ~LightFx(); + + const Graphics::Surface *draw(const Graphics::Surface &srcSubRect); + + void update(); + +private: + EffectMap *_map; + int32 _delta; + bool _up; + int32 _pos; + + int8 _minD; + int8 _maxD; +}; +} // End of namespace ZVision + +#endif // LIGHTFX_H_INCLUDED diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp new file mode 100644 index 0000000000..88239f3cad --- /dev/null +++ b/engines/zvision/graphics/effects/wave.cpp @@ -0,0 +1,146 @@ +/* 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 "common/scummsys.h" + +#include "zvision/graphics/effects/wave.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" + + +namespace ZVision { + +WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd): + Effect(engine, key, region, ported) { + + _frame = 0; + _frame_cnt = frames; + + _ampls.resize(_frame_cnt); + _hw = _region.width() / 2; + _hh = _region.height() / 2; + + int32 frmsize = _hw * _hh; + + float phase = 0; + + int16 w_4 = _hw / 2; + int16 h_4 = _hh / 2; + + for (int16 i = 0; i < _frame_cnt; i++) { + _ampls[i].resize(frmsize); + + for (int16 y = 0; y < _hh; y++) + for (int16 x = 0; x < _hw; x++) { + int16 dx = (x - w_4); + int16 dy = (y - h_4); + + _ampls[i][x + y * _hw] = ampl * sin(sqrt(dx * dx / (float)s_x + dy * dy / (float)s_y) / (-waveln * 3.1415926) + phase); + } + phase += spd; + } +} + +WaveFx::~WaveFx() { + for (uint16 i = 0; i < _ampls.size(); i++) + _ampls[i].clear(); + _ampls.clear(); +} + +const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) { + for (int16 y = 0; y < _hh; y++) { + uint16 *abc = (uint16 *)_surface.getBasePtr(0, y); + uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _hh + y); + uint16 *abc3 = (uint16 *)_surface.getBasePtr(_hw, y); + uint16 *abc4 = (uint16 *)_surface.getBasePtr(_hw, _hh + y); + + for (int16 x = 0; x < _hw; x++) { + int8 amnt = _ampls[_frame][x + _hw * y]; + + int16 n_x = x + amnt; + int16 n_y = y + amnt; + + if (n_x < 0) + n_x = 0; + if (n_x >= _region.width()) + n_x = _region.width() - 1; + if (n_y < 0) + n_y = 0; + if (n_y >= _region.height()) + n_y = _region.height() - 1; + *abc = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); + + n_x = x + amnt + _hw; + n_y = y + amnt; + + if (n_x < 0) + n_x = 0; + if (n_x >= _region.width()) + n_x = _region.width() - 1; + if (n_y < 0) + n_y = 0; + if (n_y >= _region.height()) + n_y = _region.height() - 1; + *abc3 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); + + n_x = x + amnt; + n_y = y + amnt + _hh; + + if (n_x < 0) + n_x = 0; + if (n_x >= _region.width()) + n_x = _region.width() - 1; + if (n_y < 0) + n_y = 0; + if (n_y >= _region.height()) + n_y = _region.height() - 1; + *abc2 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); + + n_x = x + amnt + _hw; + n_y = y + amnt + _hh; + + if (n_x < 0) + n_x = 0; + if (n_x >= _region.width()) + n_x = _region.width() - 1; + if (n_y < 0) + n_y = 0; + if (n_y >= _region.height()) + n_y = _region.height() - 1; + *abc4 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); + + abc++; + abc2++; + abc3++; + abc4++; + } + } + + return &_surface; +} + +void WaveFx::update() { + _frame = (_frame + 1) % _frame_cnt; +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h new file mode 100644 index 0000000000..0046dfceec --- /dev/null +++ b/engines/zvision/graphics/effects/wave.h @@ -0,0 +1,51 @@ +/* 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 WAVEFX_H_INCLUDED +#define WAVEFX_H_INCLUDED + +#include "common/array.h" +#include "zvision/graphics/effect.h" + +namespace ZVision { + +class ZVision; + +class WaveFx : public Effect { +public: + + WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd); + ~WaveFx(); + + const Graphics::Surface *draw(const Graphics::Surface &srcSubRect); + + void update(); + +private: + int16 _frame; + int16 _frame_cnt; + int16 _hw, _hh; + Common::Array< Common::Array< int8 > > _ampls; +}; +} // End of namespace ZVision + +#endif // WAVEFX_H_INCLUDED diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 5aa0d752d0..0aa062214f 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -54,6 +54,7 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH _renderTable(_wrkWidth, _wrkHeight) { _wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); + _effectWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); _outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); _menuWnd.create(windowWidth, workingWindow.top, _pixelFormat); _subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); @@ -67,21 +68,55 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH RenderManager::~RenderManager() { _curBkg.free(); _wrkWnd.free(); + _effectWnd.free(); _outWnd.free(); + _menuWnd.free(); + _subWnd.free(); } void RenderManager::renderBackbufferToScreen() { Graphics::Surface *out = &_outWnd; + Graphics::Surface *in = &_wrkWnd; + + if (!_effects.empty()) { + bool copied = false; + Common::Rect windRect(_wrkWidth, _wrkHeight); + for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { + Common::Rect rect = (*it)->getRegion(); + Common::Rect scrPlace = rect; + if ((*it)->isPort()) + scrPlace = bkgRectToScreen(scrPlace); + if (windRect.intersects(scrPlace)) { + if (!copied) { + copied = true; + _effectWnd.copyFrom(_wrkWnd); + in = &_effectWnd; + } + const Graphics::Surface *post; + if ((*it)->isPort()) + post = (*it)->draw(_curBkg.getSubArea(rect)); + else + post = (*it)->draw(_effectWnd.getSubArea(rect)); + blitSurfaceToSurface(*post, _effectWnd, scrPlace.left, scrPlace.top); + scrPlace.clip(windRect); + if (_wrkWndDirtyRect .isEmpty()) { + _wrkWndDirtyRect = scrPlace; + } else { + _wrkWndDirtyRect.extend(scrPlace); + } + } + } + } RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { if (!_wrkWndDirtyRect.isEmpty()) { - _renderTable.mutateImage(&_outWnd, &_wrkWnd); + _renderTable.mutateImage(&_outWnd, in); out = &_outWnd; _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight); } } else { - out = &_wrkWnd; + out = in; _outWndDirtyRect = _wrkWndDirtyRect; } @@ -832,4 +867,183 @@ Common::Point RenderManager::getBkgSize() { return Common::Point(_bkgWidth, _bkgHeight); } +void RenderManager::addEffect(Effect *_effect) { + _effects.push_back(_effect); +} + +void RenderManager::deleteEffect(uint32 ID) { + for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { + if ((*it)->getKey() == ID) { + delete *it; + it = _effects.erase(it); + } + } +} + +Common::Rect RenderManager::bkgRectToScreen(const Common::Rect &src) { + Common::Rect tmp = src; + RenderTable::RenderState state = _renderTable.getRenderState(); + + if (state == RenderTable::PANORAMA) { + if (_bkgOff < _screenCenterX) { + Common::Rect rScreen(_screenCenterX + _bkgOff, _wrkHeight); + Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight); + lScreen.translate(_bkgWidth - lScreen.width(), 0); + lScreen.clip(src); + rScreen.clip(src); + if (rScreen.width() < lScreen.width()) { + tmp.translate(_screenCenterX - _bkgOff - _bkgWidth, 0); + } else { + tmp.translate(_screenCenterX - _bkgOff, 0); + } + } else if (_bkgWidth - _bkgOff < _screenCenterX) { + Common::Rect rScreen(_screenCenterX - (_bkgWidth - _bkgOff), _wrkHeight); + Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight); + lScreen.translate(_bkgWidth - lScreen.width(), 0); + lScreen.clip(src); + rScreen.clip(src); + if (lScreen.width() < rScreen.width()) { + tmp.translate(_screenCenterX + (_bkgWidth - _bkgOff), 0); + } else { + tmp.translate(_screenCenterX - _bkgOff, 0); + } + } else { + tmp.translate(_screenCenterX - _bkgOff, 0); + } + } else if (state == RenderTable::TILT) { + tmp.translate(0, (_screenCenterY - _bkgOff)); + } + + return tmp; +} + +EffectMap *RenderManager::makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *_minComp, int8 *_maxComp) { + Common::Rect bkgRect(_bkgWidth, _bkgHeight); + if (!bkgRect.contains(xy)) + return NULL; + + if (!bkgRect.intersects(rect)) + return NULL; + + uint16 color = *(uint16 *)_curBkg.getBasePtr(xy.x, xy.y); + uint8 stC1, stC2, stC3; + _curBkg.format.colorToRGB(color, stC1, stC2, stC3); + EffectMap *newMap = new EffectMap; + + EffectMapUnit unit; + unit.count = 0; + unit.inEffect = false; + + int16 w = rect.width(); + int16 h = rect.height(); + + bool first = true; + + uint8 minComp = MIN(MIN(stC1, stC2), stC3); + uint8 maxComp = MAX(MAX(stC1, stC2), stC3); + + uint8 depth8 = depth << 3; + + for (int16 j = 0; j < h; j++) { + uint16 *pix = (uint16 *)_curBkg.getBasePtr(rect.left, rect.top + j); + for (int16 i = 0; i < w; i++) { + uint16 curClr = pix[i]; + uint8 cC1, cC2, cC3; + _curBkg.format.colorToRGB(curClr, cC1, cC2, cC3); + + bool use = false; + + if (curClr == color) + use = true; + else if (curClr > color) { + if ((cC1 - stC1 < depth8) && + (cC2 - stC2 < depth8) && + (cC3 - stC3 < depth8)) + use = true; + } else { /* if (curClr < color) */ + if ((stC1 - cC1 < depth8) && + (stC2 - cC2 < depth8) && + (stC3 - cC3 < depth8)) + use = true; + } + + if (first) { + unit.inEffect = use; + first = false; + } + + if (use) { + uint8 cMinComp = MIN(MIN(cC1, cC2), cC3); + uint8 cMaxComp = MAX(MAX(cC1, cC2), cC3); + if (cMinComp < minComp) + minComp = cMinComp; + if (cMaxComp > maxComp) + maxComp = cMaxComp; + } + + if (unit.inEffect == use) + unit.count++; + else { + newMap->push_back(unit); + unit.count = 1; + unit.inEffect = use; + } + } + } + newMap->push_back(unit); + + if (_minComp) { + if (minComp - depth8 < 0) + *_minComp = -(minComp >> 3); + else + *_minComp = -depth; + } + if (_maxComp) { + if ((int16)maxComp + (int16)depth8 > 255) + *_maxComp = (255 - maxComp) >> 3; + else + *_maxComp = depth; + } + + return newMap; +} + +EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 transp) { + EffectMapUnit unit; + unit.count = 0; + unit.inEffect = false; + + int16 w = surf.w; + int16 h = surf.h; + + EffectMap *newMap = new EffectMap; + + bool first = true; + + for (int16 j = 0; j < h; j++) { + const uint16 *pix = (const uint16 *)surf.getBasePtr(0, j); + for (int16 i = 0; i < w; i++) { + bool use = false; + if (pix[i] != transp) + use = true; + + if (first) { + unit.inEffect = use; + first = false; + } + + if (unit.inEffect == use) + unit.count++; + else { + newMap->push_back(unit); + unit.count = 1; + unit.inEffect = use; + } + } + } + newMap->push_back(unit); + + return newMap; +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 24234e28e1..665a27bf64 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -31,6 +31,8 @@ #include "graphics/surface.h" +#include "effect.h" + class OSystem; @@ -68,6 +70,7 @@ private: // }; // typedef Common::HashMap subMap; + typedef Common::List effectsList; private: ZVision *_engine; @@ -93,6 +96,8 @@ private: Common::Rect _menuWndDirtyRect; + Graphics::Surface _effectWnd; + // A buffer the exact same size as the workingWindow // This buffer stores everything un-warped, then does a warp at the end of the frame @@ -151,6 +156,8 @@ private: /** Holds any 'leftover' milliseconds between frames */ //uint _accumulatedVelocityMilliseconds; + effectsList _effects; + public: void initialize(); @@ -267,6 +274,13 @@ public: */ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination); void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed); + + void addEffect(Effect *_effect); + void deleteEffect(uint32 ID); + EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD); + EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp); + + Common::Rect bkgRectToScreen(const Common::Rect &src); }; } // End of namespace ZVision diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 6734fde6e2..872b48f775 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -13,6 +13,9 @@ MODULE_OBJS := \ cursors/cursor.o \ detection.o \ fonts/truetype_font.o \ + graphics/effects/fog.o \ + graphics/effects/light.o \ + graphics/effects/wave.o \ graphics/render_manager.o \ graphics/render_table.o \ scripting/actions.o \ @@ -33,6 +36,7 @@ MODULE_OBJS := \ scripting/sidefx.o \ scripting/sidefx/animation_node.o \ scripting/sidefx/music_node.o \ + scripting/sidefx/region_node.o \ scripting/sidefx/syncsound_node.o \ scripting/sidefx/timer_node.o \ scripting/sidefx/ttytext_node.o \ diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 399a81d898..839eb1f92c 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -34,7 +34,13 @@ #include "zvision/scripting/sidefx/syncsound_node.h" #include "zvision/scripting/sidefx/animation_node.h" #include "zvision/scripting/sidefx/ttytext_node.h" +#include "zvision/scripting/sidefx/region_node.h" #include "zvision/scripting/controls/titler_control.h" +#include "zvision/graphics/render_table.h" +#include "zvision/graphics/effect.h" +#include "zvision/graphics/effects/fog.h" +#include "zvision/graphics/effects/light.h" +#include "zvision/graphics/effects/wave.h" #include "common/file.h" @@ -476,6 +482,80 @@ bool ActionQuit::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionRegion +////////////////////////////////////////////////////////////////////////////// + +ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + + char art[64]; + char custom[64]; + + int32 x1, x2, y1, y2; + + sscanf(line.c_str(), "%s %d %d %d %d %hu %hu %hu %hu %s", art, &x1, &y1, &x2, &y2, &_delay, &_type, &_unk1, &_unk2, custom); + _art = Common::String(art); + _custom = Common::String(custom); + _rect = Common::Rect(x1, y1, x2 + 1, y2 + 1); +} + +ActionRegion::~ActionRegion() { + _engine->getScriptManager()->killSideFx(_slotkey); +} + +bool ActionRegion::execute() { + if (_engine->getScriptManager()->getSideFX(_slotkey)) + return true; + + Effect *effct = NULL; + switch (_type) { + case 0: { + uint16 s_x, s_y, frames; + double amplitude, waveln, speed; + sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &s_x, &s_y, &frames, &litude, &waveln, &speed); + effct = new WaveFx(_engine, _slotkey, _rect, _unk1, frames, s_x, s_y, amplitude, waveln, speed); + } + break; + case 1: { + uint16 aX, aY, aD; + if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aY, &aX, &aD); + else + sscanf(_art.c_str(), "useart[%hu,%hu,%hu]", &aX, &aY, &aD); + int8 minD; + int8 maxD; + EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD); + effct = new LightFx(_engine, _slotkey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD); + } + break; + case 9: { + int16 dum1; + int32 dum2; + char buf[64]; + sscanf(_custom.c_str(), "%hd,%d,%s", &dum1, &dum2, buf); + Graphics::Surface tempMask; + _engine->getRenderManager()->readImageToSurface(_art, tempMask); + if (_rect.width() != tempMask.w) + _rect.setWidth(tempMask.w); + if (_rect.height() != tempMask.h) + _rect.setHeight(tempMask.h); + + EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0); + effct = new FogFx(_engine, _slotkey, _rect, _unk1, _map, Common::String(buf)); + } + break; + default: + break; + } + + if (effct) { + _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotkey, effct, _delay)); + _engine->getRenderManager()->addEffect(effct); + } + + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionRandom diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index de303a7b1b..5e34f6eaf0 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -317,6 +317,22 @@ public: bool execute(); }; +class ActionRegion : public ResultAction { +public: + ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line); + ~ActionRegion(); + bool execute(); + +private: + Common::String _art; + Common::String _custom; + Common::Rect _rect; + uint16 _delay; + uint16 _type; + uint16 _unk1; + uint16 _unk2; +}; + // TODO: See if this exists in ZGI. It doesn't in ZNem class ActionUnloadAnimation : public ResultAction { public: diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 04378f856f..8140d09a6a 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -266,7 +266,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("random", true)) { actionList.push_back(new ActionRandom(_engine, slot, args)); } else if (act.matchString("region", true)) { - // TODO: Implement ActionRegion + actionList.push_back(new ActionRegion(_engine, slot, args)); } else if (act.matchString("restore_game", true)) { // TODO: Implement ActionRestoreGame } else if (act.matchString("rotate_to", true)) { diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 4d82f36aea..219cff9f45 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -87,9 +87,9 @@ enum StateKey { StateKey_DebugCheats = 74, StateKey_JapanFonts = 75, StateKey_Brightness = 77, - StateKey_EF9_B = 91, + StateKey_EF9_R = 91, StateKey_EF9_G = 92, - StateKey_EF9_R = 93, + StateKey_EF9_B = 93, StateKey_EF9_Speed = 94, StateKey_Inv_Cnt_Slot = 100, StateKey_Inv_1_Slot = 101, diff --git a/engines/zvision/scripting/sidefx/region_node.cpp b/engines/zvision/scripting/sidefx/region_node.cpp new file mode 100644 index 0000000000..de613d8af2 --- /dev/null +++ b/engines/zvision/scripting/sidefx/region_node.cpp @@ -0,0 +1,56 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/region_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" + +namespace ZVision { + +RegionNode::RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay) + : SideFX(engine, key, SIDEFX_REGION) { + _effect = effect; + _delay = delay; + _timeLeft = 0; +} + +RegionNode::~RegionNode() { + _engine->getRenderManager()->deleteEffect(_key); +} + +bool RegionNode::process(uint32 deltaTimeInMillis) { + _timeLeft -= deltaTimeInMillis; + + if (_timeLeft <= 0) { + _timeLeft = _delay; + if (_effect) + _effect->update(); + } + + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/region_node.h b/engines/zvision/scripting/sidefx/region_node.h new file mode 100644 index 0000000000..ec716b6e3e --- /dev/null +++ b/engines/zvision/scripting/sidefx/region_node.h @@ -0,0 +1,57 @@ +/* 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 ZVISION_REGION_NODE_H +#define ZVISION_REGION_NODE_H + +#include "graphics/surface.h" + +#include "zvision/scripting/sidefx.h" +#include "zvision/graphics/effect.h" + +namespace ZVision { + +class ZVision; + +class RegionNode : public SideFX { +public: + RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay); + ~RegionNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + +private: + int32 _timeLeft; + uint32 _delay; + Effect *_effect; +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 002b8e692a9488ac91e043df2fe7dce34d52a771 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 10 Oct 2014 16:46:48 +0700 Subject: ZVISION: Fix default Tilt linScale --- engines/zvision/graphics/render_table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 942420c700..2fc21b7566 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -55,7 +55,7 @@ void RenderTable::setRenderState(RenderState newState) { break; case TILT: _tiltOptions.fieldOfView = 27.0f; - _tiltOptions.linearScale = 0.55f; + _tiltOptions.linearScale = 0.65f; _tiltOptions.reverse = false; break; case FLAT: -- cgit v1.2.3 From 7c9d8f22de461528ac5e3fbe9c1c69dcdaa1a908 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 10 Oct 2014 16:48:28 +0700 Subject: ZVISION: Implement dynamic tilt up/down border --- engines/zvision/graphics/render_table.cpp | 5 +++++ engines/zvision/graphics/render_table.h | 3 +++ engines/zvision/zvision.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 2fc21b7566..9bf40d3745 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -199,6 +199,7 @@ void RenderTable::generateTiltLookupTable() { float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f); float cylinderRadius = halfWidth / tan(fovInRadians); + _tiltOptions.gap = cylinderRadius * atan2(halfHeight / cylinderRadius, 1.0) * _tiltOptions.linearScale; for (uint y = 0; y < _numRows; ++y) { @@ -259,4 +260,8 @@ void RenderTable::setTiltReverse(bool reverse) { _tiltOptions.reverse = reverse; } +float RenderTable::getTiltGap() { + return _tiltOptions.gap; +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h index 0b4d6e3919..a268ee615f 100644 --- a/engines/zvision/graphics/render_table.h +++ b/engines/zvision/graphics/render_table.h @@ -57,6 +57,7 @@ private: float fieldOfView; float linearScale; bool reverse; + float gap; } _tiltOptions; public: @@ -79,6 +80,8 @@ public: void setTiltScale(float scale); void setTiltReverse(bool reverse); + float getTiltGap(); + private: void generatePanoramaLookupTable(); void generateTiltLookupTable(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 24e15e0c86..a534e49c25 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -332,7 +332,7 @@ void ZVision::updateRotation() { int16 new_pos = st_pos + _velocity * (1 - 2 * 0); int16 scr_height = _renderManager->getBkgSize().y; - int16 tilt_gap = _workingWindow.height() / 2; + int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); if (new_pos >= (scr_height - tilt_gap)) new_pos = scr_height - tilt_gap; -- cgit v1.2.3 From ac74070af1d09cb9eb319b50716d2c3ee272c2a9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 10 Oct 2014 16:49:38 +0700 Subject: ZVISION: Lever blitter must scale image to rect --- engines/zvision/scripting/controls/lever_control.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 8072079435..84cd6fa598 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -370,12 +370,10 @@ void LeverControl::renderFrame(uint frameNumber) { } const Graphics::Surface *frameData; - int x = _animationCoords.left; - int y = _animationCoords.top; frameData = _animation->getFrameData(frameNumber); if (frameData) - _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); + _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords); } } // End of namespace ZVision -- cgit v1.2.3 From a65ec38f8ddfb2a856619880d005ccd1a766623a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 10 Oct 2014 16:50:59 +0700 Subject: ZVISION: Fix code style --- engines/zvision/scripting/control.h | 14 ++++++--- .../zvision/scripting/controls/fist_control.cpp | 30 +++++++++--------- .../zvision/scripting/controls/paint_control.cpp | 4 +-- engines/zvision/scripting/controls/paint_control.h | 4 ++- .../zvision/scripting/controls/safe_control.cpp | 4 +-- engines/zvision/scripting/script_manager.cpp | 36 +++++++++++----------- 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 7c8a273419..8708f033af 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -40,7 +40,7 @@ class ZVision; class Control { public: - enum ControlType { + enum ControlType { CONTROL_UNKNOW, CONTROL_INPUT, CONTROL_PUSHTGL, @@ -63,7 +63,7 @@ public: } ControlType getType() { - return _type; + return _type; } virtual void focus() {} @@ -101,13 +101,17 @@ public: * * @param keycode The key that was pressed */ - virtual bool onKeyDown(Common::KeyState keyState) {return false;} + virtual bool onKeyDown(Common::KeyState keyState) { + return false; + } /** * Called when a key is released. Default is NOP. * * @param keycode The key that was pressed */ - virtual bool onKeyUp(Common::KeyState keyState) {return false;} + virtual bool onKeyUp(Common::KeyState keyState) { + return false; + } /** * Processes the node given the deltaTime since last frame. Default is NOP. * @@ -130,7 +134,7 @@ public: static void parsePanoramaControl(ZVision *engine, Common::SeekableReadStream &stream); static void parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream); private: - ControlType _type; + ControlType _type; }; // TODO: Implement InputControl diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 46b87ddb79..89aeb53be6 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -121,17 +121,17 @@ bool FistControl::process(uint32 deltaTimeInMillis) { if (_frameCur <= _frameEnd) { _frameTime -= deltaTimeInMillis; - if (_frameTime <= 0) { - _frameTime = _animation->frameTime(); + if (_frameTime <= 0) { + _frameTime = _animation->frameTime(); - renderFrame(_frameCur); + renderFrame(_frameCur); - _frameCur++; + _frameCur++; - if (_frameCur > _frameEnd) - _engine->getScriptManager()->setStateValue(_animationId, 2); + if (_frameCur > _frameEnd) + _engine->getScriptManager()->setStateValue(_animationId, 2); + } } - } return false; } @@ -142,7 +142,7 @@ bool FistControl::onMouseMove(const Common::Point &screenSpacePos, const Common: if (mouseIn(screenSpacePos, backgroundImageSpacePos) >= 0) { _engine->getCursorManager()->changeCursor(_cursor); - return true; + return true; } return false; @@ -160,7 +160,7 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P uint32 oldStatus = _fiststatus; _fiststatus ^= (1 << n_fist); - for(int i = 0; i < _numEntries; i++) + for (int i = 0; i < _numEntries; i++) if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) { _frameCur = _entries[i]._anmStrt; _frameEnd = _entries[i]._anmEnd; @@ -264,25 +264,25 @@ uint32 FistControl::readBits(const char *str) { int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { if (_order) { - for(int i = 0; i < _fistnum; i++) { + for (int i = 0; i < _fistnum; i++) { if (((_fiststatus >> i) & 1) == 1) { - for(uint j = 0; j < _fistsDwn[i].size(); j++) + for (uint j = 0; j < _fistsDwn[i].size(); j++) if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos)) return i; } else { - for(uint j = 0; j < _fistsUp[i].size(); j++) + for (uint j = 0; j < _fistsUp[i].size(); j++) if ((_fistsUp[i])[j].contains(backgroundImageSpacePos)) return i; } } } else { - for(int i = _fistnum - 1; i >= 0; i--) { + for (int i = _fistnum - 1; i >= 0; i--) { if (((_fiststatus >> i) & 1) == 1) { - for(uint j = 0; j < _fistsDwn[i].size(); j++) + for (uint j = 0; j < _fistsDwn[i].size(); j++) if ((_fistsDwn[i])[j].contains(backgroundImageSpacePos)) return i; } else { - for(uint j = 0; j < _fistsUp[i].size(); j++) + for (uint j = 0; j < _fistsUp[i].size(); j++) if ((_fistsUp[i])[j].contains(backgroundImageSpacePos)) return i; } diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index a350e9b599..2891f1b1f9 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -98,7 +98,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre } if (_paint) { - _colorKey = _paint->format.RGBToColor(255,0,255); + _colorKey = _paint->format.RGBToColor(255, 0, 255); _bkg = new Graphics::Surface; _bkg->create(_rectangle.width(), _rectangle.height(), _paint->format); _bkg->fillRect(Common::Rect(_rectangle.width(), _rectangle.height()), _colorKey); @@ -194,7 +194,7 @@ Common::Rect PaintControl::paint(const Common::Point &point) { brush_rect.translate(-point.x, -point.y); Common::Rect bkg_rect = paint_rect; - bkg_rect.translate( -_rectangle.left, -_rectangle.top ); + bkg_rect.translate(-_rectangle.left, -_rectangle.top); for (int yy = 0; yy < brush_rect.height(); yy++) { uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy); diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h index c74431e681..54b96e8e4e 100644 --- a/engines/zvision/scripting/controls/paint_control.h +++ b/engines/zvision/scripting/controls/paint_control.h @@ -59,7 +59,9 @@ public: */ bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - bool process(uint32 deltaTimeInMillis) { return false; }; + bool process(uint32 deltaTimeInMillis) { + return false; + }; private: /** diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index d5eff09502..ba809148a3 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -83,7 +83,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream int y; sscanf(values.c_str(), "%d %d", &x, &y); - _center = Common::Point(x,y); + _center = Common::Point(x, y); } else if (param.matchString("dial_inner_radius", true)) { _radius_inner = atoi(values.c_str()); _radius_inner_sq = _radius_inner * _radius_inner; @@ -188,7 +188,7 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states; - int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1 ) % _num_states; + int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1) % _num_states; _cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states; diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 7a2854d230..fea3c2e199 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -160,28 +160,28 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { Common::Event _event = _controlEvents.front(); Common::Point imageCoord; switch (_event.type) { - case Common::EVENT_LBUTTONDOWN: - imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); - onMouseDown(_event.mouse, imageCoord); - break; - case Common::EVENT_LBUTTONUP: - imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); - onMouseUp(_event.mouse, imageCoord); - break; - case Common::EVENT_KEYDOWN: - onKeyDown(_event.kbd); - break; - case Common::EVENT_KEYUP: - onKeyUp(_event.kbd); - break; - default: - break; + case Common::EVENT_LBUTTONDOWN: + imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); + onMouseDown(_event.mouse, imageCoord); + break; + case Common::EVENT_LBUTTONUP: + imageCoord = _engine->getRenderManager()->screenSpaceToImageSpace(_event.mouse); + onMouseUp(_event.mouse, imageCoord); + break; + case Common::EVENT_KEYDOWN: + onKeyDown(_event.kbd); + break; + case Common::EVENT_KEYUP: + onKeyUp(_event.kbd); + break; + default: + break; } _controlEvents.pop_front(); } for (ControlList::iterator iter = _activeControls->begin(); iter != _activeControls->end(); iter++) - if ( (*iter)->process(deltaTimeMillis) ) + if ((*iter)->process(deltaTimeMillis)) break; } @@ -540,7 +540,7 @@ void ScriptManager::do_changeLocation() { if (_nextLocation.world == 'g' && _nextLocation.room == 'j') { if (_nextLocation.node == 's' && _nextLocation.view == 'e' && - _currentLocation.world != 'g' && _currentLocation.room != 'j') + _currentLocation.world != 'g' && _currentLocation.room != 'j') _engine->getSaveManager()->prepareSaveBuffer(); } else { if (_currentLocation.world == 'g' && _currentLocation.room == 'j') -- cgit v1.2.3 From b58f6f397da29454e359384f6908b403f48d990e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 13 Oct 2014 20:28:34 -0400 Subject: MADS: New conversation message logic for cutscene animations --- engines/mads/animation.cpp | 53 +++++++++++++++++++++++---------- engines/mads/animation.h | 6 +++- engines/mads/nebular/menu_nebular.cpp | 4 +-- engines/mads/palette.cpp | 56 +++++++++++++++++++++++++++++++++++ engines/mads/palette.h | 2 ++ 5 files changed, 102 insertions(+), 19 deletions(-) diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 0807d8e409..bc3708b5f5 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -159,6 +159,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) { } Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { + _flags = 0; _font = nullptr; _resetFlag = false; _messageCtr = 0; @@ -174,6 +175,8 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) { _actionDetails._indirectObjectId = -1; _currentFrame = 0; _oldFrameEntry = 0; + _rgbResult = -1; + _palIndex1 = _palIndex2 = -1; } Animation::~Animation() { @@ -204,6 +207,7 @@ void Animation::load(MSurface &backSurface, DepthSurface &depthSurface, if (_header._bgType == ANIMBG_INTERFACE) flags |= PALFLAG_RESERVED; + _flags = flags; if (flags & ANIMFLAG_LOAD_BACKGROUND) { loadBackground(backSurface, depthSurface, _header, flags, palCycles, sceneInfo); @@ -414,6 +418,7 @@ bool Animation::hasScroll() const { void Animation::update() { Scene &scene = _vm->_game->_scene; + Palette &palette = *_vm->_palette; if (_header._manualFlag) { int spriteListIndex = _spriteListIndexes[_header._spritesIndex]; @@ -532,26 +537,42 @@ void Animation::update() { } else if ((_currentFrame >= _messages[idx]._startFrame) && (_currentFrame <= _messages[idx]._endFrame)) { // Start displaying the message AnimMessage &me = _messages[idx]; + uint8 colIndex1, colIndex2; + + if (_flags & ANIMFLAG_ANIMVIEW) { + _rgbResult = palette._paletteUsage.checkRGB(me._rgb1, -1, true, &_palIndex1); + _rgbResult = palette._paletteUsage.checkRGB(me._rgb2, _rgbResult, true, &_palIndex2); + + // Update the palette with the two needed colors + int palCount = _palIndex2 - _palIndex1; + if (palCount < 0) + palCount = _palIndex1 - _palIndex2 + 1; + palette.setPalette(palette._mainPalette, MIN(_palIndex1, _palIndex2), palCount); + + colIndex1 = _palIndex1; + colIndex2 = _palIndex2; + } else { + // The color index to use is dependant on how many messages are currently on-screen + switch (_messageCtr) { + case 1: + colIndex1 = 252; + break; + case 2: + colIndex1 = 16; + break; + default: + colIndex1 = 250; + break; + } + colIndex2 = colIndex1 + 1; - // The color index to use is dependant on how many messages are currently on-screen - uint8 colIndex; - switch (_messageCtr) { - case 1: - colIndex = 252; - break; - case 2: - colIndex = 16; - break; - default: - colIndex = 250; - break; + _vm->_palette->setEntry(colIndex1, me._rgb1[0], me._rgb1[1], me._rgb1[2]); + _vm->_palette->setEntry(colIndex2, me._rgb2[0], me._rgb2[1], me._rgb2[2]); } - _vm->_palette->setEntry(colIndex, me._rgb1[0], me._rgb1[1], me._rgb1[2]); - _vm->_palette->setEntry(colIndex + 1, me._rgb2[0], me._rgb2[1], me._rgb2[2]); - // Add a kernel message to display the given text - me._kernelMsgIndex = scene._kernelMessages.add(me._pos, colIndex * 0x101 + 0x100, + me._kernelMsgIndex = scene._kernelMessages.add(me._pos, + colIndex1 | (colIndex2 << 8), 0, 0, INDEFINITE_TIMEOUT, me._msg); assert(me._kernelMsgIndex >= 0); ++_messageCtr; diff --git a/engines/mads/animation.h b/engines/mads/animation.h index 917d899ec5..b7e98e72e4 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -37,7 +37,8 @@ enum AnimFlag { ANIMFLAG_DITHER = 0x1000, // Dither to 16 colors ANIMFLAG_CUSTOM_FONT = 0x2000, // Load ccustom font ANIMFLAG_LOAD_BACKGROUND = 0x0100, // Load background - ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200 // Load background only + ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200, // Load background only + ANIMFLAG_ANIMVIEW = 0x8000 // Cutscene animation }; enum AnimBgType { @@ -155,6 +156,9 @@ private: uint32 _nextScrollTimer; int _messageCtr; int _trigger; + int _flags; + int _rgbResult; + int _palIndex1, _palIndex2; TriggerMode _triggerMode; ActionDetails _actionDetails; diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 3919e70a09..0d7b11cf4b 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -890,9 +890,9 @@ void AnimationView::loadNextResource() { // Load the new animation delete _currentAnimation; _currentAnimation = Animation::init(_vm, &scene); + int flags = ANIMFLAG_ANIMVIEW | (resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0); _currentAnimation->load(scene._backgroundSurface, scene._depthSurface, - resEntry._resourceName, resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0, - &paletteCycles, _sceneInfo); + resEntry._resourceName, flags, &paletteCycles, _sceneInfo); // Signal for a screen refresh scene._spriteSlots.fullRefresh(); diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index c098e23bf9..1787b3c298 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -317,6 +317,62 @@ int PaletteUsage::rgbFactor(byte *palEntry, RGB6 &pal6) { return total; } +int PaletteUsage::checkRGB(const byte *rgb, int palStart, bool flag, int *palIndex) { + Palette &palette = *_vm->_palette; + bool match = false; + int result; + if (palStart >= 0) { + result = palStart; + } else { + result = -1; + for (int i = 0; i < palette._highRange; ++i) { + if (!palette._rgbList[i]) { + result = i; + break; + } + } + } + + if (result >= 0) { + int mask = 1 << result; + byte *palP = &palette._mainPalette[0]; + uint32 *flagsP = &palette._palFlags[0]; + + for (; flagsP < &palette._palFlags[PALETTE_COUNT]; ++flagsP, ++result) { + if ((!(*flagsP & 1) || flag) && !(*flagsP & 2)) { + if (!memcmp(palP, rgb, 3)) { + *flagsP |= mask; + + if (palIndex) + *palIndex = result; + match = true; + break; + } + } + } + + if (!match) { + palP = &palette._mainPalette[0]; + flagsP = &palette._palFlags[0]; + + for (int i = 0; i < PALETTE_COUNT; ++i, palP += 3, ++flagsP) { + if (!*flagsP) { + Common::copy(rgb, rgb + 3, palP); + *flagsP |= mask; + + if (palIndex) + *palIndex = i; + match = true; + break; + } + } + } + } + + assert(match); + return result; +} + /*------------------------------------------------------------------------*/ void RGBList::clear() { diff --git a/engines/mads/palette.h b/engines/mads/palette.h index 9b8b7146db..27d25f266b 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -136,6 +136,8 @@ public: void updateUsage(Common::Array &usageList, int sceneUsageIndex); void resetPalFlags(int idx); + + int checkRGB(const byte *rgb, int palStart, bool flag, int *palIndex); }; class RGBList { -- cgit v1.2.3 From d175d58ce1e534c77a1d8f4f4abd1fd17f26faff Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 14 Oct 2014 17:57:02 +0200 Subject: TSAGE: R2R - Fix a bug when trying to exit the ship console after playing Outpost Alpha --- engines/tsage/ringworld2/ringworld2_scenes0.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp index b82565332a..573cbbb29a 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes0.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -627,7 +627,7 @@ void Scene125::postInit(SceneObjectList *OwnerList) { SceneExt::postInit(); _palette.loadPalette(0); - if (R2_GLOBALS._sceneManager._previousScene != 125) + if ((R2_GLOBALS._sceneManager._previousScene != 125) && (R2_GLOBALS._sceneManager._previousScene != 1337) && (R2_GLOBALS._sceneManager._previousScene != 1330)) // Save the prior scene to return to when the console is turned off R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = R2_GLOBALS._sceneManager._previousScene; -- cgit v1.2.3 From c4a829a7c61e55b98f926a079f4c06ba029f02fa Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Tue, 14 Oct 2014 21:43:41 +0100 Subject: CGE2: Add detection for English v1.0 version of the game --- engines/cge2/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp index c05ce70c3d..6e1b93d0b8 100644 --- a/engines/cge2/detection.cpp +++ b/engines/cge2/detection.cpp @@ -71,6 +71,16 @@ static const ADGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) }, + { + "sfinx", "Freeware v1.0", + { + {"vol.cat", 0, "f158e469dccbebc5a632eb848df89779", 129024}, + {"vol.dat", 0, "d40a6b4ae173d6930be54ba56bee15d5", 34183443}, + AD_LISTEND + }, + Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) + }, + AD_TABLE_END_MARKER }; -- cgit v1.2.3 From b5fb32de5ea2a4f3dd4133c423d666d00f37744f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 14 Oct 2014 21:26:00 -0400 Subject: MADS: Fix to exit game safely when sound driver hasn't been created --- engines/mads/sound.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp index 9d0d9c8d20..d0aa770a4d 100644 --- a/engines/mads/sound.cpp +++ b/engines/mads/sound.cpp @@ -42,9 +42,11 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) { } SoundManager::~SoundManager() { - _driver->stop(); + if (_driver) { + _driver->stop(); + delete _driver; + } - delete _driver; delete _opl; } -- cgit v1.2.3 From ea9599b763e0e8aef55282d621828ebfc7b1a9f6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 14 Oct 2014 21:37:00 -0400 Subject: MADS: Implement subtitles for animation cutscenes --- engines/mads/animation.cpp | 27 +++++++++++---------------- engines/mads/animation.h | 2 +- engines/mads/nebular/menu_nebular.cpp | 2 ++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index bc3708b5f5..9f0e0adb6d 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -537,49 +537,44 @@ void Animation::update() { } else if ((_currentFrame >= _messages[idx]._startFrame) && (_currentFrame <= _messages[idx]._endFrame)) { // Start displaying the message AnimMessage &me = _messages[idx]; - uint8 colIndex1, colIndex2; if (_flags & ANIMFLAG_ANIMVIEW) { _rgbResult = palette._paletteUsage.checkRGB(me._rgb1, -1, true, &_palIndex1); _rgbResult = palette._paletteUsage.checkRGB(me._rgb2, _rgbResult, true, &_palIndex2); // Update the palette with the two needed colors - int palCount = _palIndex2 - _palIndex1; - if (palCount < 0) - palCount = _palIndex1 - _palIndex2 + 1; - palette.setPalette(palette._mainPalette, MIN(_palIndex1, _palIndex2), palCount); - - colIndex1 = _palIndex1; - colIndex2 = _palIndex2; + int palStart = MIN(_palIndex1, _palIndex2); + int palCount = ABS(_palIndex2 - _palIndex1) + 1; + palette.setPalette(&palette._mainPalette[palStart * 3], palStart, palCount); } else { // The color index to use is dependant on how many messages are currently on-screen switch (_messageCtr) { case 1: - colIndex1 = 252; + _palIndex1 = 252; break; case 2: - colIndex1 = 16; + _palIndex1 = 16; break; default: - colIndex1 = 250; + _palIndex1 = 250; break; } - colIndex2 = colIndex1 + 1; + _palIndex2 = _palIndex1 + 1; - _vm->_palette->setEntry(colIndex1, me._rgb1[0], me._rgb1[1], me._rgb1[2]); - _vm->_palette->setEntry(colIndex2, me._rgb2[0], me._rgb2[1], me._rgb2[2]); + _vm->_palette->setEntry(_palIndex1, me._rgb1[0], me._rgb1[1], me._rgb1[2]); + _vm->_palette->setEntry(_palIndex2, me._rgb2[0], me._rgb2[1], me._rgb2[2]); } // Add a kernel message to display the given text me._kernelMsgIndex = scene._kernelMessages.add(me._pos, - colIndex1 | (colIndex2 << 8), + _palIndex1 | (_palIndex2 << 8), 0, 0, INDEFINITE_TIMEOUT, me._msg); assert(me._kernelMsgIndex >= 0); ++_messageCtr; // If there's an accompanying sound, also play it if (me._soundId > 0) - _vm->_audio->playSound(me._soundId); + _vm->_audio->playSound(me._soundId - 1); } } diff --git a/engines/mads/animation.h b/engines/mads/animation.h index b7e98e72e4..8b85a5370d 100644 --- a/engines/mads/animation.h +++ b/engines/mads/animation.h @@ -38,7 +38,7 @@ enum AnimFlag { ANIMFLAG_CUSTOM_FONT = 0x2000, // Load ccustom font ANIMFLAG_LOAD_BACKGROUND = 0x0100, // Load background ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200, // Load background only - ANIMFLAG_ANIMVIEW = 0x8000 // Cutscene animation + ANIMFLAG_ANIMVIEW = 0x4000 // Cutscene animation }; enum AnimBgType { diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 0d7b11cf4b..64c91d5f1b 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -55,6 +55,8 @@ void MenuView::show() { while (!_breakFlag && !_vm->shouldQuit()) { if (_redrawFlag) { + scene._kernelMessages.update(); + _vm->_game->_scene.drawElements(_vm->_game->_fx, _vm->_game->_fx); _redrawFlag = false; } -- cgit v1.2.3 From 2048fe68d233cfff8523b1b2ee818088cb0fc939 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 14 Oct 2014 21:49:14 -0400 Subject: MADS: Fix clearing on-screen messages when the cutscene animation changes --- engines/mads/nebular/menu_nebular.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 64c91d5f1b..6d014191e9 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -889,6 +889,9 @@ void AnimationView::loadNextResource() { if (resEntry._bgFlag) palette.resetGamePalette(1, 8); + // Free any previous messages + scene._kernelMessages.reset(); + // Load the new animation delete _currentAnimation; _currentAnimation = Animation::init(_vm, &scene); -- cgit v1.2.3 From 1658a34ef5e6e6d48e45c4f38d7d507eb0f4d5ff Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 14 Oct 2014 22:29:29 -0400 Subject: MADS: Correct the color for the top/bottom line bounding the cutscene --- engines/mads/nebular/menu_nebular.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 6d014191e9..a9ed6d3495 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -889,9 +889,24 @@ void AnimationView::loadNextResource() { if (resEntry._bgFlag) palette.resetGamePalette(1, 8); + palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1] + = palette._mainPalette[253 * 3 + 2] = 0xb4; + palette.setPalette(&palette._mainPalette[253 * 3], 253, 1); + // Free any previous messages scene._kernelMessages.reset(); + // Handle the bars at the top/bottom + if (resEntry._showWhiteBars) { + // For animations the screen has been clipped to the middle 156 rows. + // So although it's slightly messy, bypass our screen class entirely, + // and draw the horizontal lines directly on the physiacl screen surface + Graphics::Surface *s = g_system->lockScreen(); + s->hLine(0, 20, MADS_SCREEN_WIDTH, 253); + s->hLine(0, 179, MADS_SCREEN_WIDTH, 253); + g_system->unlockScreen(); + } + // Load the new animation delete _currentAnimation; _currentAnimation = Animation::init(_vm, &scene); -- cgit v1.2.3 From 331488cae0909084a1e8800706cf102741e3043b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 15 Oct 2014 10:35:49 +0300 Subject: MADS: Bugfix for the text view debugger command --- engines/mads/debugger.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index ee967cb17e..3b77d5332b 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -381,7 +381,7 @@ bool Debugger::Cmd_PlayText(int argc, const char **argv) { resName.deleteChar(0); Common::File f; - if (f.exists(resName) || f.exists(resName + ".res")) { + if (f.exists(resName) || f.exists(resName + ".txr")) { Nebular::TextView::execute(_vm, resName); return false; } else { -- cgit v1.2.3 From 701d43b5c208a605465c59e9caf8767df18c3e04 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 14 Oct 2014 01:59:53 +0300 Subject: MADS: Initial implementation of sound driver handling for V2 games --- engines/mads/nebular/menu_nebular.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index a9ed6d3495..6a13cea195 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -922,7 +922,11 @@ void AnimationView::loadNextResource() { const char *chP = strchr(_currentAnimation->_header._soundName.c_str(), '.'); assert(chP); - int driverNum = atoi(chP + 1); + // Handle both Rex naming (xxx.009) and naming in later games (e.g. xxx.ph9) + int driverNum = atoi(chP + 3); + // HACK for Dragon + if (_currentAnimation->_header._soundName == "#SOUND.DRG") + driverNum = 9; _vm->_sound->init(driverNum); } -- cgit v1.2.3 From 33b770ac60354b3a8bea89bc5babe3f5c0ebf4dc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 15 Oct 2014 11:33:14 +0300 Subject: MADS: Move all the anim and text view code into a common class The animation and text players are more or less common among all MADS games --- engines/mads/debugger.cpp | 4 +- engines/mads/dialogs.cpp | 73 +++ engines/mads/dialogs.h | 32 ++ engines/mads/menu_views.cpp | 782 +++++++++++++++++++++++++++++++ engines/mads/menu_views.h | 226 +++++++++ engines/mads/module.mk | 1 + engines/mads/nebular/dialogs_nebular.cpp | 61 --- engines/mads/nebular/dialogs_nebular.h | 32 -- engines/mads/nebular/menu_nebular.cpp | 753 +---------------------------- engines/mads/nebular/menu_nebular.h | 190 +------- 10 files changed, 1118 insertions(+), 1036 deletions(-) create mode 100644 engines/mads/menu_views.cpp create mode 100644 engines/mads/menu_views.h diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp index 3b77d5332b..99251f9fbb 100644 --- a/engines/mads/debugger.cpp +++ b/engines/mads/debugger.cpp @@ -362,7 +362,7 @@ bool Debugger::Cmd_PlayAnim(int argc, const char **argv) { Common::File f; if (f.exists(resName) || f.exists(resName + ".res")) { - Nebular::AnimationView::execute(_vm, resName); + AnimationView::execute(_vm, resName); return false; } else { debugPrintf("Could not find resource file\n"); @@ -382,7 +382,7 @@ bool Debugger::Cmd_PlayText(int argc, const char **argv) { Common::File f; if (f.exists(resName) || f.exists(resName + ".txr")) { - Nebular::TextView::execute(_vm, resName); + TextView::execute(_vm, resName); return false; } else { debugPrintf("Could not find resource file\n"); diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 7e6909d113..5ea8fb115c 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -395,4 +395,77 @@ Dialogs::Dialogs(MADSEngine *vm) _pendingDialog = DIALOG_NONE; } +/*------------------------------------------------------------------------*/ + +FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) { + switch (_vm->getGameID()) { + case GType_RexNebular: + _screenId = 990; + break; + case GType_Phantom: + _screenId = 920; + break; + case GType_Dragonsphere: + _screenId = 922; + break; + default: + error("FullScreenDialog:Unknown game"); + } + _palFlag = true; +} + +FullScreenDialog::~FullScreenDialog() { + _vm->_screen.resetClipBounds(); + _vm->_game->_scene.restrictScene(); +} + +void FullScreenDialog::display() { + Game &game = *_vm->_game; + Scene &scene = game._scene; + + int nextSceneId = scene._nextSceneId; + int currentSceneId = scene._currentSceneId; + int priorSceneId = scene._priorSceneId; + + if (_screenId > 0) { + SceneInfo *sceneInfo = SceneInfo::init(_vm); + sceneInfo->load(_screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface); + } + + scene._priorSceneId = priorSceneId; + scene._currentSceneId = currentSceneId; + scene._nextSceneId = nextSceneId; + + _vm->_events->initVars(); + game._kernelMode = KERNEL_ROOM_INIT; + + byte pal[768]; + if (_vm->_screenFade) { + Common::fill(&pal[0], &pal[PALETTE_SIZE], 0); + _vm->_palette->setFullPalette(pal); + } else { + _vm->_palette->getFullPalette(pal); + _vm->_palette->fadeOut(pal, nullptr, 0, PALETTE_COUNT, 0, 1, 1, 16); + } + + // Set Fx state and palette entries + game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition; + game._trigger = 0; + + // Clear the screen and draw the upper and lower horizontal lines + _vm->_screen.empty(); + _vm->_palette->setLowRange(); + _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2); + _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2); + _vm->_screen.copyRectToScreen(Common::Rect(0, 0, MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT)); + + // Restrict the screen to the area between the two lines + _vm->_screen.setClipBounds(Common::Rect(0, DIALOG_TOP, MADS_SCREEN_WIDTH, + DIALOG_TOP + MADS_SCENE_HEIGHT)); + _vm->_game->_scene.restrictScene(); + + if (_screenId > 0) + scene._spriteSlots.fullRefresh(); +} + } // End of namespace MADS diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h index c586a6f1fe..317c7bd792 100644 --- a/engines/mads/dialogs.h +++ b/engines/mads/dialogs.h @@ -30,6 +30,8 @@ namespace MADS { +#define DIALOG_TOP 22 + class Dialog { private: void setDialogPalette(); @@ -226,6 +228,36 @@ public: virtual bool show(int messageId, int objectId = -1) = 0; }; +class FullScreenDialog: public EventTarget { +protected: + /** + * Engine reference + */ + MADSEngine *_vm; + + /** + * Screen/scene to show background from + */ + int _screenId; + + /** + * Flag for palette initialization + */ + bool _palFlag; + + /** + * Handles displaying the screen background and dialog + */ + virtual void display(); +public: + /** + * Constructor + */ + FullScreenDialog(MADSEngine *vm); + + virtual ~FullScreenDialog(); +}; + } // End of namespace MADS #endif /* MADS_DIALOGS_H */ diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp new file mode 100644 index 0000000000..6acf6cdf9f --- /dev/null +++ b/engines/mads/menu_views.cpp @@ -0,0 +1,782 @@ +/* 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 "common/scummsys.h" +#include "mads/game.h" +#include "mads/mads.h" +#include "mads/menu_views.h" +#include "mads/resources.h" +#include "mads/scene.h" +#include "mads/screen.h" + +namespace MADS { + +MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) { + _breakFlag = false; + _redrawFlag = true; + _palFlag = false; +} + +void MenuView::show() { + Scene &scene = _vm->_game->_scene; + EventsManager &events = *_vm->_events; + _vm->_screenFade = SCREEN_FADE_FAST; + + scene._spriteSlots.reset(true); + display(); + + events.setEventTarget(this); + events.hideCursor(); + + while (!_breakFlag && !_vm->shouldQuit()) { + if (_redrawFlag) { + scene._kernelMessages.update(); + + _vm->_game->_scene.drawElements(_vm->_game->_fx, _vm->_game->_fx); + _redrawFlag = false; + } + + _vm->_events->waitForNextFrame(); + _vm->_game->_fx = kTransitionNone; + doFrame(); + } + + events.setEventTarget(nullptr); + _vm->_sound->stop(); +} + +void MenuView::display() { + _vm->_palette->resetGamePalette(4, 8); + + FullScreenDialog::display(); +} + +bool MenuView::onEvent(Common::Event &event) { + if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_LBUTTONDOWN) { + _breakFlag = true; + _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; + return true; + } + + return false; +} + +/*------------------------------------------------------------------------*/ + +char TextView::_resourceName[100]; +#define TEXTVIEW_LINE_SPACING 2 +#define TEXT_ANIMATION_DELAY 100 +#define TV_NUM_FADE_STEPS 40 +#define TV_FADE_DELAY_MILLI 50 + +void TextView::execute(MADSEngine *vm, const Common::String &resName) { + assert(resName.size() < 100); + Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName)); + vm->_dialogs->_pendingDialog = DIALOG_TEXTVIEW; +} + +TextView::TextView(MADSEngine *vm) : MenuView(vm) { + _animating = false; + _panSpeed = 0; + _spareScreen = nullptr; + _scrollCount = 0; + _lineY = -1; + _scrollTimeout = 0; + _panCountdown = 0; + _translationX = 0; + _screenId = -1; + + _font = _vm->_font->getFont(FONT_CONVERSATION); + _vm->_palette->resetGamePalette(4, 0); + + load(); +} + +TextView::~TextView() { +} + +void TextView::load() { + Common::String scriptName(_resourceName); + scriptName += ".txr"; + + if (!_script.open(scriptName)) + error("Could not open resource %s", _resourceName); + + processLines(); +} + +void TextView::processLines() { + if (_script.eos()) + error("Attempted to read past end of response file"); + + while (!_script.eos()) { + // Read in the next line + _script.readLine(_currentLine, 79); + char *p = _currentLine + strlen(_currentLine) - 1; + if (*p == '\n') + *p = '\0'; + + // Commented out line, so go loop for another + if (_currentLine[0] == '#') + continue; + + // Process the line + char *cStart = strchr(_currentLine, '['); + if (cStart) { + while (cStart) { + // Loop for possible multiple commands on one line + char *cEnd = strchr(_currentLine, ']'); + if (!cEnd) + error("Unterminated command '%s' in response file", _currentLine); + + *cEnd = '\0'; + processCommand(); + + // Copy rest of line (if any) to start of buffer + Common::strlcpy(_currentLine, cEnd + 1, sizeof(_currentLine)); + + cStart = strchr(_currentLine, '['); + } + + if (_currentLine[0]) { + processText(); + break; + } + + } else { + processText(); + break; + } + } +} + +void TextView::processCommand() { + Scene &scene = _vm->_game->_scene; + Common::String scriptLine(_currentLine + 1); + scriptLine.toUppercase(); + const char *paramP; + const char *commandStr = scriptLine.c_str(); + + if (!strncmp(commandStr, "BACKGROUND", 10)) { + // Set the background + paramP = commandStr + 10; + resetPalette(); + int screenId = getParameter(¶mP); + + SceneInfo *sceneInfo = SceneInfo::init(_vm); + sceneInfo->load(screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface); + scene._spriteSlots.fullRefresh(); + _redrawFlag = true; + + } else if (!strncmp(commandStr, "GO", 2)) { + _animating = true; + + } else if (!strncmp(commandStr, "PAN", 3)) { + // Set panning values + paramP = commandStr + 3; + int panX = getParameter(¶mP); + int panY = getParameter(¶mP); + int panSpeed = getParameter(¶mP); + + if ((panX != 0) || (panY != 0)) { + _pan = Common::Point(panX, panY); + _panSpeed = panSpeed; + } + + } else if (!strncmp(commandStr, "DRIVER", 6)) { + // Set the driver to use + paramP = commandStr + 7; + + if (!strncmp(paramP, "#SOUND.00", 9)) { + int driverNum = paramP[9] - '0'; + _vm->_sound->init(driverNum); + } + } else if (!strncmp(commandStr, "SOUND", 5)) { + // Set sound number + paramP = commandStr + 5; + int soundId = getParameter(¶mP); + _vm->_sound->command(soundId); + + } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') || + (commandStr[5] == '1'))) { + // Set the text colors + int index = commandStr[5] - '0'; + paramP = commandStr + 6; + + byte r = getParameter(¶mP); + byte g = getParameter(¶mP); + byte b = getParameter(¶mP); + + _vm->_palette->setEntry(5 + index, r, g, b); + + } else if (!strncmp(commandStr, "SPARE", 5)) { + // Sets a secondary background number that can be later switched in with a PAGE command + paramP = commandStr + 6; + int spareIndex = commandStr[5] - '0'; + assert(spareIndex < 4); + int screenId = getParameter(¶mP); + + // Load the spare background + SceneInfo *sceneInfo = SceneInfo::init(_vm); + sceneInfo->_width = MADS_SCREEN_WIDTH; + sceneInfo->_height = MADS_SCENE_HEIGHT; + _spareScreens[spareIndex].setSize(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); + sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE, + _spareScreens[spareIndex]); + delete sceneInfo; + + } else if (!strncmp(commandStr, "PAGE", 4)) { + // Signals to change to a previous specified secondary background + paramP = commandStr + 4; + int spareIndex = getParameter(¶mP); + + // Only allow background switches if one isn't currently in progress + if (!_spareScreen && _spareScreens[spareIndex].getPixels() != nullptr) { + _spareScreen = &_spareScreens[spareIndex]; + _translationX = 0; + } + + } else { + error("Unknown response command: '%s'", commandStr); + } +} + +int TextView::getParameter(const char **paramP) { + if ((**paramP != '=') && (**paramP != ',')) + return 0; + + int result = 0; + ++*paramP; + while ((**paramP >= '0') && (**paramP <= '9')) { + result = result * 10 + (**paramP - '0'); + ++*paramP; + } + + return result; +} + +void TextView::processText() { + int xStart; + + if (!strcmp(_currentLine, "***")) { + // Special signifier for end of script + _scrollCount = _font->getHeight() * 13; + _lineY = -1; + return; + } + + _lineY = 0; + + // Lines are always centered, except if line contains a '@', in which case the + // '@' marks the position that must be horizontally centered + char *centerP = strchr(_currentLine, '@'); + if (centerP) { + *centerP = '\0'; + xStart = (MADS_SCREEN_WIDTH / 2) - _font->getWidth(_currentLine); + + // Delete the @ character and shift back the remainder of the string + char *p = centerP + 1; + if (*p == ' ') ++p; + strcpy(centerP, p); + + } else { + int lineWidth = _font->getWidth(_currentLine); + xStart = (MADS_SCREEN_WIDTH - lineWidth) / 2; + } + + // Add the new line to the list of pending lines + TextLine tl; + tl._pos = Common::Point(xStart, MADS_SCENE_HEIGHT); + tl._line = _currentLine; + tl._textDisplayIndex = -1; + _textLines.push_back(tl); +} + +void TextView::display() { + FullScreenDialog::display(); +} + +void TextView::resetPalette() { + _vm->_palette->resetGamePalette(8, 8); + _vm->_palette->setEntry(5, 0, 63, 63); + _vm->_palette->setEntry(6, 0, 45, 45); +} + +void TextView::doFrame() { + Scene &scene = _vm->_game->_scene; + if (!_animating) + return; + + // Only update state if wait period has expired + uint32 currTime = g_system->getMillis(); + + // If a screen transition is in progress and it's time for another column, handle it + if (_spareScreen) { + byte *srcP = _spareScreen->getBasePtr(_translationX, 0); + byte *bgP = scene._backgroundSurface.getBasePtr(_translationX, 0); + byte *screenP = (byte *)_vm->_screen.getBasePtr(_translationX, 0); + + for (int y = 0; y < MADS_SCENE_HEIGHT; ++y, srcP += MADS_SCREEN_WIDTH, + bgP += MADS_SCREEN_WIDTH, screenP += MADS_SCREEN_WIDTH) { + *bgP = *srcP; + *screenP = *srcP; + } + + // Flag the column of the screen is modified + _vm->_screen.copyRectToScreen(Common::Rect(_translationX, 0, + _translationX + 1, MADS_SCENE_HEIGHT)); + + // Keep moving the column to copy to the right + if (++_translationX == MADS_SCREEN_WIDTH) { + // Surface transition is complete + _spareScreen = nullptr; + } + } + + // Make sure it's time for an update + if (currTime < _scrollTimeout) + return; + _scrollTimeout = g_system->getMillis() + TEXT_ANIMATION_DELAY; + _redrawFlag = true; + + // If any panning values are set, pan the background surface + if ((_pan.x != 0) || (_pan.y != 0)) { + if (_panCountdown > 0) { + --_panCountdown; + return; + } + + // Handle horizontal panning + if (_pan.x != 0) { + byte *lineTemp = new byte[_pan.x]; + for (int y = 0; y < MADS_SCENE_HEIGHT; ++y) { + byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, y); + + // Copy the first X pixels into temp buffer, move the rest of the line + // to the start of the line, and then move temp buffer pixels to end of line + Common::copy(pixelsP, pixelsP + _pan.x, lineTemp); + Common::copy(pixelsP + _pan.x, pixelsP + MADS_SCREEN_WIDTH, pixelsP); + Common::copy(lineTemp, lineTemp + _pan.x, pixelsP + MADS_SCREEN_WIDTH - _pan.x); + } + + delete[] lineTemp; + } + + // Handle vertical panning + if (_pan.y != 0) { + // Store the bottom Y lines into a temp buffer, move the rest of the lines down, + // and then copy the stored lines back to the top of the screen + byte *linesTemp = new byte[_pan.y * MADS_SCREEN_WIDTH]; + byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, MADS_SCENE_HEIGHT - _pan.y); + Common::copy(pixelsP, pixelsP + MADS_SCREEN_WIDTH * _pan.y, linesTemp); + + for (int y = MADS_SCENE_HEIGHT - 1; y >= _pan.y; --y) { + byte *destP = (byte *)scene._backgroundSurface.getBasePtr(0, y); + byte *srcP = (byte *)scene._backgroundSurface.getBasePtr(0, y - _pan.y); + Common::copy(srcP, srcP + MADS_SCREEN_WIDTH, destP); + } + + Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH, + (byte *)scene._backgroundSurface.getPixels()); + delete[] linesTemp; + } + + // Flag for a full screen refresh + scene._spriteSlots.fullRefresh(); + } + + // Scroll all active text lines up + for (int i = _textLines.size() - 1; i >= 0; --i) { + TextLine &tl = _textLines[i]; + if (tl._textDisplayIndex != -1) + // Expire the text line that's already on-screen + scene._textDisplay.expire(tl._textDisplayIndex); + + tl._pos.y--; + if (tl._pos.y < 0) { + _textLines.remove_at(i); + } else { + tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y, + 0x605, -1, tl._line, _font); + } + } + + if (_scrollCount > 0) { + // Handling final scrolling of text off of screen + if (--_scrollCount == 0) { + scriptDone(); + return; + } + } else { + // Handling a text row + if (++_lineY == (_font->getHeight() + TEXTVIEW_LINE_SPACING)) + processLines(); + } +} + +void TextView::scriptDone() { + _breakFlag = true; + _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; +} + +/*------------------------------------------------------------------------*/ + +char AnimationView::_resourceName[100]; + +void AnimationView::execute(MADSEngine *vm, const Common::String &resName) { + assert(resName.size() < 100); + Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName)); + vm->_dialogs->_pendingDialog = DIALOG_ANIMVIEW; +} + +AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) { + _redrawFlag = false; + + _soundDriverLoaded = false; + _previousUpdate = 0; + _screenId = -1; + _resetPalette = false; + _resyncMode = NEVER; + _v1 = 0; + _v2 = -1; + _resourceIndex = -1; + _currentAnimation = nullptr; + _sfx = 0; + _soundFlag = _bgLoadFlag = true; + _showWhiteBars = true; + _manualFrameNumber = 0; + _manualSpriteSet = nullptr; + _manualStartFrame = _manualEndFrame = 0; + _manualFrame2 = 0; + _animFrameNumber = 0; + _nextCyclingActive = false; + _sceneInfo = SceneInfo::init(_vm); + + load(); +} + +AnimationView::~AnimationView() { + delete _currentAnimation; + delete _sceneInfo; +} + +void AnimationView::load() { + Common::String resName(_resourceName); + if (!resName.hasSuffix(".")) + resName += ".res"; + + if (!_script.open(resName)) + error("Could not open resource %s", resName.c_str()); + + processLines(); +} + +void AnimationView::display() { + Scene &scene = _vm->_game->_scene; + _vm->_palette->initPalette(); + Common::fill(&_vm->_palette->_cyclingPalette[0], &_vm->_palette->_cyclingPalette[PALETTE_SIZE], 0); + + _vm->_palette->resetGamePalette(1, 8); + scene._spriteSlots.reset(); + scene._paletteCycles.clear(); + + MenuView::display(); +} + +bool AnimationView::onEvent(Common::Event &event) { + // Wait for the Escape key or a mouse press + if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) || + (event.type == Common::EVENT_RBUTTONUP)) { + scriptDone(); + return true; + } + + return false; +} + +void AnimationView::doFrame() { + Scene &scene = _vm->_game->_scene; + + if (_resourceIndex == -1 || _currentAnimation->freeFlag()) { + if (++_resourceIndex == (int)_resources.size()) { + scriptDone(); + } else { + scene._frameStartTime = 0; + loadNextResource(); + } + } else if (_currentAnimation->getCurrentFrame() == 1) { + scene._cyclingActive = _nextCyclingActive; + } + + if (_currentAnimation) { + ++scene._frameStartTime; + _currentAnimation->update(); + _redrawFlag = true; + } +} + +void AnimationView::loadNextResource() { + Scene &scene = _vm->_game->_scene; + Palette &palette = *_vm->_palette; + ResourceEntry &resEntry = _resources[_resourceIndex]; + Common::Array paletteCycles; + + if (resEntry._bgFlag) + palette.resetGamePalette(1, 8); + + palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1] + = palette._mainPalette[253 * 3 + 2] = 0xb4; + palette.setPalette(&palette._mainPalette[253 * 3], 253, 1); + + // Free any previous messages + scene._kernelMessages.reset(); + + // Handle the bars at the top/bottom + if (resEntry._showWhiteBars) { + // For animations the screen has been clipped to the middle 156 rows. + // So although it's slightly messy, bypass our screen class entirely, + // and draw the horizontal lines directly on the physiacl screen surface + Graphics::Surface *s = g_system->lockScreen(); + s->hLine(0, 20, MADS_SCREEN_WIDTH, 253); + s->hLine(0, 179, MADS_SCREEN_WIDTH, 253); + g_system->unlockScreen(); + } + + // Load the new animation + delete _currentAnimation; + _currentAnimation = Animation::init(_vm, &scene); + int flags = ANIMFLAG_ANIMVIEW | (resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0); + _currentAnimation->load(scene._backgroundSurface, scene._depthSurface, + resEntry._resourceName, flags, &paletteCycles, _sceneInfo); + + // Signal for a screen refresh + scene._spriteSlots.fullRefresh(); + + // If a sound driver has been specified, then load the correct one + if (!_currentAnimation->_header._soundName.empty()) { + const char *chP = strchr(_currentAnimation->_header._soundName.c_str(), '.'); + assert(chP); + + // Handle both Rex naming (xxx.009) and naming in later games (e.g. xxx.ph9) + int driverNum = atoi(chP + 3); + // HACK for Dragon + if (_currentAnimation->_header._soundName == "#SOUND.DRG") + driverNum = 9; + _vm->_sound->init(driverNum); + } + + // Handle any manual setup + if (_currentAnimation->_header._manualFlag) { + _manualFrameNumber = _currentAnimation->_header._spritesIndex; + _manualSpriteSet = _currentAnimation->getSpriteSet(_manualFrameNumber); + } + + // Set the sound data for the animation + _vm->_sound->setEnabled(resEntry._soundFlag); + + Common::String dsrName = _currentAnimation->_header._dsrName; + if (!dsrName.empty()) + _vm->_audio->setSoundGroup(dsrName); + + // Start the new animation + _currentAnimation->startAnimation(0); + + // Handle the palette and cycling palette + scene._cyclingActive = false; + Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE], + &palette._cyclingPalette[0]); + + _vm->_game->_fx = (ScreenTransition)resEntry._fx; + _nextCyclingActive = paletteCycles.size() > 0; + if (!_vm->_game->_fx) { + palette.setFullPalette(palette._mainPalette); + } + + scene.initPaletteAnimation(paletteCycles, _nextCyclingActive && !_vm->_game->_fx); +} + +void AnimationView::scriptDone() { + _breakFlag = true; + _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; +} + +void AnimationView::processLines() { + if (_script.eos()) { + // end of script, end animation + scriptDone(); + return; + } + + while (!_script.eos()) { + // Get in next line + _currentLine.clear(); + char c; + while (!_script.eos() && (c = _script.readByte()) != '\n') { + if (c != '\r' && c != '\0') + _currentLine += c; + } + + // Process the line + while (!_currentLine.empty()) { + if (_currentLine.hasPrefix("-")) { + _currentLine.deleteChar(0); + + processCommand(); + } else { + // Get resource name + Common::String resName; + while (!_currentLine.empty() && (c = _currentLine[0]) != ' ') { + _currentLine.deleteChar(0); + resName += c; + } + + // Add resource into list along with any set state information + _resources.push_back(ResourceEntry(resName, _sfx, _soundFlag, + _bgLoadFlag, _showWhiteBars)); + + // Fx resets between resource entries + _sfx = 0; + } + + // Skip any spaces + while (_currentLine.hasPrefix(" ")) + _currentLine.deleteChar(0); + } + } +} + +void AnimationView::processCommand() { + // Get the command character + char commandChar = toupper(_currentLine[0]); + _currentLine.deleteChar(0); + + // Handle the command + switch (commandChar) { + case 'B': + _soundFlag = !_soundFlag; + break; + case 'H': + // -h[:ex] Disable EMS / XMS high memory support + if (_currentLine.hasPrefix(":")) + _currentLine.deleteChar(0); + while (_currentLine.hasPrefix("e") || _currentLine.hasPrefix("x")) + _currentLine.deleteChar(0); + break; + case 'O': + // -o:xxx Specify opening special effect + assert(_currentLine[0] == ':'); + _currentLine.deleteChar(0); + _sfx = getParameter(); + break; + case 'P': + // Switch to CONCAT mode, which is ignored anyway + break; + case 'R': { + // Resynch timer (always, beginning, never) + assert(_currentLine[0] == ':'); + _currentLine.deleteChar(0); + + char v = toupper(_currentLine[0]); + _currentLine.deleteChar(0); + if (v == 'N') + _resyncMode = NEVER; + else if (v == 'A') + _resyncMode = ALWAYS; + else if (v == 'B') + _resyncMode = BEGINNING; + else + error("Unknown parameter"); + break; + } + case 'W': + // Switch white bars being visible + _showWhiteBars = !_showWhiteBars; + break; + case 'X': + // Exit after animation finishes. Ignore + break; + case 'D': + // Unimplemented and ignored in the original. Ignore as well + break; + case 'Y': + // Reset palette on startup + _resetPalette = true; + break; + default: + error("Unknown command char: '%c'", commandChar); + } +} + +int AnimationView::getParameter() { + int result = 0; + + while (!_currentLine.empty()) { + char c = _currentLine[0]; + + if (c >= '0' && c <= '9') { + _currentLine.deleteChar(0); + result = result * 10 + (c - '0'); + } else { + break; + } + } + + return result; +} + +void AnimationView::checkResource(const Common::String &resourceName) { + //bool hasSuffix = false; + +} + +int AnimationView::scanResourceIndex(const Common::String &resourceName) { + int foundIndex = -1; + + if (_v1) { + const char *chP = strchr(resourceName.c_str(), '\\'); + if (!chP) { + chP = strchr(resourceName.c_str(), '*'); + } + + Common::String resName = chP ? Common::String(chP + 1) : resourceName; + + if (_v2 != 3) { + assert(_resIndex.size() == 0); + } + + // Scan for the resource name + for (uint resIndex = 0; resIndex < _resIndex.size(); ++resIndex) { + ResIndexEntry &resEntry = _resIndex[resIndex]; + if (resEntry._resourceName.compareToIgnoreCase(resourceName)) { + foundIndex = resIndex; + break; + } + } + } + + if (foundIndex >= 0) { + // TODO + } + return -1; +} + +} // End of namespace MADS diff --git a/engines/mads/menu_views.h b/engines/mads/menu_views.h new file mode 100644 index 0000000000..6faa665bff --- /dev/null +++ b/engines/mads/menu_views.h @@ -0,0 +1,226 @@ +/* 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 MADS_MENU_VIEWS_H +#define MADS_MENU_VIEWS_H + +#include "common/scummsys.h" +#include "mads/dialogs.h" +#include "mads/game.h" +#include "mads/msurface.h" + +namespace MADS { + +class MADSEngine; + +class MenuView: public FullScreenDialog { +protected: + bool _breakFlag; + bool _redrawFlag; + + virtual void doFrame() = 0; + + virtual void display(); + + /** + * Event handler + */ + virtual bool onEvent(Common::Event &event); +public: + MenuView(MADSEngine *vm); + + virtual ~MenuView() {} + + virtual void show(); +}; + +struct TextLine { + Common::Point _pos; + Common::String _line; + int _textDisplayIndex; +}; + +/** + * Scrolling text view + */ +class TextView : public MenuView { +private: + static char _resourceName[100]; + + bool _animating; + Common::Array _textLines; + Common::Point _pan; + int _panSpeed; + MSurface _spareScreens[4]; + int _scrollCount; + int _lineY; + uint32 _scrollTimeout; + int _panCountdown; + int _translationX; + Common::File _script; + char _currentLine[80]; + MSurface *_spareScreen; + Font *_font; +private: + /** + * Load the text resource + */ + void load(); + + /** + * Process the lines + */ + void processLines(); + + /** + * Process a command from the script file + */ + void processCommand(); + + /** + * Process text from the script file + */ + void processText(); + + /** + * Get a parameter from line + */ + int getParameter(const char **paramP); + + /** + * Called when the script is finished + */ + void scriptDone(); + + /** + * Reset the game palette + */ + void resetPalette(); +protected: + virtual void display(); + + virtual void doFrame(); +public: + /** + * Queue the given text resource for display + */ + static void execute(MADSEngine *vm, const Common::String &resName); + + TextView(MADSEngine *vm); + + virtual ~TextView(); +}; + +enum ResyncMode { NEVER, ALWAYS, BEGINNING }; + +struct ResourceEntry { + Common::String _resourceName; + int _fx; + bool _soundFlag; + bool _bgFlag; + bool _showWhiteBars; + + ResourceEntry() {} + ResourceEntry(const Common::String &resName, int fx, bool soundFlag, + bool bgFlag, bool showWhiteBars) { + _resourceName = resName; + _fx = fx; + _soundFlag = soundFlag; + _bgFlag = bgFlag; + _showWhiteBars = showWhiteBars; + } +}; + +struct ResIndexEntry { + int _id; + int _v; + Common::String _resourceName; + + ResIndexEntry() {} +}; + +/** +* Animation cutscene view +*/ +class AnimationView : public MenuView { +private: + static char _resourceName[100]; + + Common::File _script; + uint32 _previousUpdate; + Common::String _currentLine; + bool _soundDriverLoaded; + bool _resetPalette; + ResyncMode _resyncMode; + int _sfx; + bool _soundFlag; + bool _bgLoadFlag; + bool _showWhiteBars; + Common::Array _resources; + Common::Array _resIndex; + int _v1; + int _v2; + int _resourceIndex; + SceneInfo *_sceneInfo; + Animation *_currentAnimation; + int _manualFrameNumber; + SpriteAsset *_manualSpriteSet; + int _manualStartFrame, _manualEndFrame; + int _manualFrame2; + int _animFrameNumber; + bool _nextCyclingActive; +private: + void checkResource(const Common::String &resourceName); + + int scanResourceIndex(const Common::String &resourceName); + + void load(); + + void processLines(); + + void processCommand(); + + int getParameter(); + + void scriptDone(); + + void loadNextResource(); +protected: + virtual void display(); + + virtual void doFrame(); + + virtual bool onEvent(Common::Event &event); +public: + /** + * Queue the given text resource for display + */ + static void execute(MADSEngine *vm, const Common::String &resName); + + AnimationView(MADSEngine *vm); + + virtual ~AnimationView(); +}; + +} // End of namespace MADS + +#endif /* MADS_MENU_VIEWS_H */ diff --git a/engines/mads/module.mk b/engines/mads/module.mk index 96353e9ae5..fc04a2f8ba 100644 --- a/engines/mads/module.mk +++ b/engines/mads/module.mk @@ -35,6 +35,7 @@ MODULE_OBJS := \ hotspots.o \ inventory.o \ mads.o \ + menu_views.o \ messages.o \ msurface.o \ palette.o \ diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 35a7d3bdc6..86244bd3bb 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -553,67 +553,6 @@ void PictureDialog::restore() { /*------------------------------------------------------------------------*/ -FullScreenDialog::FullScreenDialog(MADSEngine *vm) : _vm(vm) { - _screenId = 990; - _palFlag = true; -} - -FullScreenDialog::~FullScreenDialog() { - _vm->_screen.resetClipBounds(); - _vm->_game->_scene.restrictScene(); -} - -void FullScreenDialog::display() { - Game &game = *_vm->_game; - Scene &scene = game._scene; - - int nextSceneId = scene._nextSceneId; - int currentSceneId = scene._currentSceneId; - int priorSceneId = scene._priorSceneId; - - if (_screenId > 0) { - SceneInfo *sceneInfo = SceneInfo::init(_vm); - sceneInfo->load(_screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface); - } - - scene._priorSceneId = priorSceneId; - scene._currentSceneId = currentSceneId; - scene._nextSceneId = nextSceneId; - - _vm->_events->initVars(); - game._kernelMode = KERNEL_ROOM_INIT; - - byte pal[768]; - if (_vm->_screenFade) { - Common::fill(&pal[0], &pal[PALETTE_SIZE], 0); - _vm->_palette->setFullPalette(pal); - } else { - _vm->_palette->getFullPalette(pal); - _vm->_palette->fadeOut(pal, nullptr, 0, PALETTE_COUNT, 0, 1, 1, 16); - } - - // Set Fx state and palette entries - game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? kTransitionFadeIn : kCenterVertTransition; - game._trigger = 0; - - // Clear the screen and draw the upper and lower horizontal lines - _vm->_screen.empty(); - _vm->_palette->setLowRange(); - _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2); - _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2); - _vm->_screen.copyRectToScreen(Common::Rect(0, 0, MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT)); - - // Restrict the screen to the area between the two lines - _vm->_screen.setClipBounds(Common::Rect(0, DIALOG_TOP, MADS_SCREEN_WIDTH, - DIALOG_TOP + MADS_SCENE_HEIGHT)); - _vm->_game->_scene.restrictScene(); - - if (_screenId > 0) - scene._spriteSlots.fullRefresh(); -} - -/*------------------------------------------------------------------------*/ - GameDialog::DialogLine::DialogLine() { _active = true; _state = DLGSTATE_UNSELECTED; diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h index f64f992611..d00cd87ead 100644 --- a/engines/mads/nebular/dialogs_nebular.h +++ b/engines/mads/nebular/dialogs_nebular.h @@ -31,8 +31,6 @@ namespace MADS { namespace Nebular { -#define DIALOG_TOP 22 - enum CapitalizationMode { kUppercase = 0, kLowercase = 1, kUpperAndLower = 2 }; class DialogsNebular : public Dialogs { @@ -109,36 +107,6 @@ enum DialogTextAlign { ALIGN_NONE = 0, ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, enum DialogState { DLGSTATE_UNSELECTED = 0, DLGSTATE_SELECTED = 1, DLGSTATE_FOCUSED = 2 }; -class FullScreenDialog: public EventTarget { -protected: - /** - * Engine reference - */ - MADSEngine *_vm; - - /** - * Screen/scene to show background from - */ - int _screenId; - - /** - * Flag for palette initialization - */ - bool _palFlag; - - /** - * Handles displaying the screen background and dialog - */ - virtual void display(); -public: - /** - * Constructor - */ - FullScreenDialog(MADSEngine *vm); - - virtual ~FullScreenDialog(); -}; - class GameDialog: public FullScreenDialog { struct DialogLine { bool _active; diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 6a13cea195..717e3f6cf9 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "mads/game.h" #include "mads/mads.h" +#include "mads/menu_views.h" #include "mads/resources.h" #include "mads/scene.h" #include "mads/screen.h" @@ -36,58 +37,6 @@ namespace Nebular { #define MADS_MENU_Y ((MADS_SCREEN_HEIGHT - MADS_SCENE_HEIGHT) / 2) #define MADS_MENU_ANIM_DELAY 70 -MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) { - _breakFlag = false; - _redrawFlag = true; - _palFlag = false; -} - -void MenuView::show() { - Scene &scene = _vm->_game->_scene; - EventsManager &events = *_vm->_events; - _vm->_screenFade = SCREEN_FADE_FAST; - - scene._spriteSlots.reset(true); - display(); - - events.setEventTarget(this); - events.hideCursor(); - - while (!_breakFlag && !_vm->shouldQuit()) { - if (_redrawFlag) { - scene._kernelMessages.update(); - - _vm->_game->_scene.drawElements(_vm->_game->_fx, _vm->_game->_fx); - _redrawFlag = false; - } - - _vm->_events->waitForNextFrame(); - _vm->_game->_fx = kTransitionNone; - doFrame(); - } - - events.setEventTarget(nullptr); - _vm->_sound->stop(); -} - -void MenuView::display() { - _vm->_palette->resetGamePalette(4, 8); - - FullScreenDialog::display(); -} - -bool MenuView::onEvent(Common::Event &event) { - if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_LBUTTONDOWN) { - _breakFlag = true; - _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; - return true; - } - - return false; -} - -/*------------------------------------------------------------------------*/ - MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) { Common::fill(&_menuItems[0], &_menuItems[7], (SpriteAsset *)nullptr); Common::fill(&_menuItemIndexes[0], &_menuItemIndexes[7], -1); @@ -426,706 +375,6 @@ bool AdvertView::onEvent(Common::Event &event) { return false; } -/*------------------------------------------------------------------------*/ - -char TextView::_resourceName[100]; -#define TEXTVIEW_LINE_SPACING 2 -#define TEXT_ANIMATION_DELAY 100 -#define TV_NUM_FADE_STEPS 40 -#define TV_FADE_DELAY_MILLI 50 - -void TextView::execute(MADSEngine *vm, const Common::String &resName) { - assert(resName.size() < 100); - Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName)); - vm->_dialogs->_pendingDialog = DIALOG_TEXTVIEW; -} - -TextView::TextView(MADSEngine *vm) : MenuView(vm) { - _animating = false; - _panSpeed = 0; - _spareScreen = nullptr; - _scrollCount = 0; - _lineY = -1; - _scrollTimeout = 0; - _panCountdown = 0; - _translationX = 0; - _screenId = -1; - - _font = _vm->_font->getFont(FONT_CONVERSATION); - _vm->_palette->resetGamePalette(4, 0); - - load(); -} - -TextView::~TextView() { -} - -void TextView::load() { - Common::String scriptName(_resourceName); - scriptName += ".txr"; - - if (!_script.open(scriptName)) - error("Could not open resource %s", _resourceName); - - processLines(); -} - -void TextView::processLines() { - if (_script.eos()) - error("Attempted to read past end of response file"); - - while (!_script.eos()) { - // Read in the next line - _script.readLine(_currentLine, 79); - char *p = _currentLine + strlen(_currentLine) - 1; - if (*p == '\n') - *p = '\0'; - - // Commented out line, so go loop for another - if (_currentLine[0] == '#') - continue; - - // Process the line - char *cStart = strchr(_currentLine, '['); - if (cStart) { - while (cStart) { - // Loop for possible multiple commands on one line - char *cEnd = strchr(_currentLine, ']'); - if (!cEnd) - error("Unterminated command '%s' in response file", _currentLine); - - *cEnd = '\0'; - processCommand(); - - // Copy rest of line (if any) to start of buffer - Common::strlcpy(_currentLine, cEnd + 1, sizeof(_currentLine)); - - cStart = strchr(_currentLine, '['); - } - - if (_currentLine[0]) { - processText(); - break; - } - - } else { - processText(); - break; - } - } -} - -void TextView::processCommand() { - Scene &scene = _vm->_game->_scene; - Common::String scriptLine(_currentLine + 1); - scriptLine.toUppercase(); - const char *paramP; - const char *commandStr = scriptLine.c_str(); - - if (!strncmp(commandStr, "BACKGROUND", 10)) { - // Set the background - paramP = commandStr + 10; - resetPalette(); - int screenId = getParameter(¶mP); - - SceneInfo *sceneInfo = SceneInfo::init(_vm); - sceneInfo->load(screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface); - scene._spriteSlots.fullRefresh(); - _redrawFlag = true; - - } else if (!strncmp(commandStr, "GO", 2)) { - _animating = true; - - } else if (!strncmp(commandStr, "PAN", 3)) { - // Set panning values - paramP = commandStr + 3; - int panX = getParameter(¶mP); - int panY = getParameter(¶mP); - int panSpeed = getParameter(¶mP); - - if ((panX != 0) || (panY != 0)) { - _pan = Common::Point(panX, panY); - _panSpeed = panSpeed; - } - - } else if (!strncmp(commandStr, "DRIVER", 6)) { - // Set the driver to use - paramP = commandStr + 7; - - if (!strncmp(paramP, "#SOUND.00", 9)) { - int driverNum = paramP[9] - '0'; - _vm->_sound->init(driverNum); - } - } else if (!strncmp(commandStr, "SOUND", 5)) { - // Set sound number - paramP = commandStr + 5; - int soundId = getParameter(¶mP); - _vm->_sound->command(soundId); - - } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') || - (commandStr[5] == '1'))) { - // Set the text colors - int index = commandStr[5] - '0'; - paramP = commandStr + 6; - - byte r = getParameter(¶mP); - byte g = getParameter(¶mP); - byte b = getParameter(¶mP); - - _vm->_palette->setEntry(5 + index, r, g, b); - - } else if (!strncmp(commandStr, "SPARE", 5)) { - // Sets a secondary background number that can be later switched in with a PAGE command - paramP = commandStr + 6; - int spareIndex = commandStr[5] - '0'; - assert(spareIndex < 4); - int screenId = getParameter(¶mP); - - // Load the spare background - SceneInfo *sceneInfo = SceneInfo::init(_vm); - sceneInfo->_width = MADS_SCREEN_WIDTH; - sceneInfo->_height = MADS_SCENE_HEIGHT; - _spareScreens[spareIndex].setSize(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); - sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE, - _spareScreens[spareIndex]); - delete sceneInfo; - - } else if (!strncmp(commandStr, "PAGE", 4)) { - // Signals to change to a previous specified secondary background - paramP = commandStr + 4; - int spareIndex = getParameter(¶mP); - - // Only allow background switches if one isn't currently in progress - if (!_spareScreen && _spareScreens[spareIndex].getPixels() != nullptr) { - _spareScreen = &_spareScreens[spareIndex]; - _translationX = 0; - } - - } else { - error("Unknown response command: '%s'", commandStr); - } -} - -int TextView::getParameter(const char **paramP) { - if ((**paramP != '=') && (**paramP != ',')) - return 0; - - int result = 0; - ++*paramP; - while ((**paramP >= '0') && (**paramP <= '9')) { - result = result * 10 + (**paramP - '0'); - ++*paramP; - } - - return result; -} - -void TextView::processText() { - int xStart; - - if (!strcmp(_currentLine, "***")) { - // Special signifier for end of script - _scrollCount = _font->getHeight() * 13; - _lineY = -1; - return; - } - - _lineY = 0; - - // Lines are always centered, except if line contains a '@', in which case the - // '@' marks the position that must be horizontally centered - char *centerP = strchr(_currentLine, '@'); - if (centerP) { - *centerP = '\0'; - xStart = (MADS_SCREEN_WIDTH / 2) - _font->getWidth(_currentLine); - - // Delete the @ character and shift back the remainder of the string - char *p = centerP + 1; - if (*p == ' ') ++p; - strcpy(centerP, p); - - } else { - int lineWidth = _font->getWidth(_currentLine); - xStart = (MADS_SCREEN_WIDTH - lineWidth) / 2; - } - - // Add the new line to the list of pending lines - TextLine tl; - tl._pos = Common::Point(xStart, MADS_SCENE_HEIGHT); - tl._line = _currentLine; - tl._textDisplayIndex = -1; - _textLines.push_back(tl); -} - -void TextView::display() { - FullScreenDialog::display(); -} - -void TextView::resetPalette() { - _vm->_palette->resetGamePalette(8, 8); - _vm->_palette->setEntry(5, 0, 63, 63); - _vm->_palette->setEntry(6, 0, 45, 45); -} - -void TextView::doFrame() { - Scene &scene = _vm->_game->_scene; - if (!_animating) - return; - - // Only update state if wait period has expired - uint32 currTime = g_system->getMillis(); - - // If a screen transition is in progress and it's time for another column, handle it - if (_spareScreen) { - byte *srcP = _spareScreen->getBasePtr(_translationX, 0); - byte *bgP = scene._backgroundSurface.getBasePtr(_translationX, 0); - byte *screenP = (byte *)_vm->_screen.getBasePtr(_translationX, 0); - - for (int y = 0; y < MADS_SCENE_HEIGHT; ++y, srcP += MADS_SCREEN_WIDTH, - bgP += MADS_SCREEN_WIDTH, screenP += MADS_SCREEN_WIDTH) { - *bgP = *srcP; - *screenP = *srcP; - } - - // Flag the column of the screen is modified - _vm->_screen.copyRectToScreen(Common::Rect(_translationX, 0, - _translationX + 1, MADS_SCENE_HEIGHT)); - - // Keep moving the column to copy to the right - if (++_translationX == MADS_SCREEN_WIDTH) { - // Surface transition is complete - _spareScreen = nullptr; - } - } - - // Make sure it's time for an update - if (currTime < _scrollTimeout) - return; - _scrollTimeout = g_system->getMillis() + TEXT_ANIMATION_DELAY; - _redrawFlag = true; - - // If any panning values are set, pan the background surface - if ((_pan.x != 0) || (_pan.y != 0)) { - if (_panCountdown > 0) { - --_panCountdown; - return; - } - - // Handle horizontal panning - if (_pan.x != 0) { - byte *lineTemp = new byte[_pan.x]; - for (int y = 0; y < MADS_SCENE_HEIGHT; ++y) { - byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, y); - - // Copy the first X pixels into temp buffer, move the rest of the line - // to the start of the line, and then move temp buffer pixels to end of line - Common::copy(pixelsP, pixelsP + _pan.x, lineTemp); - Common::copy(pixelsP + _pan.x, pixelsP + MADS_SCREEN_WIDTH, pixelsP); - Common::copy(lineTemp, lineTemp + _pan.x, pixelsP + MADS_SCREEN_WIDTH - _pan.x); - } - - delete[] lineTemp; - } - - // Handle vertical panning - if (_pan.y != 0) { - // Store the bottom Y lines into a temp buffer, move the rest of the lines down, - // and then copy the stored lines back to the top of the screen - byte *linesTemp = new byte[_pan.y * MADS_SCREEN_WIDTH]; - byte *pixelsP = (byte *)scene._backgroundSurface.getBasePtr(0, MADS_SCENE_HEIGHT - _pan.y); - Common::copy(pixelsP, pixelsP + MADS_SCREEN_WIDTH * _pan.y, linesTemp); - - for (int y = MADS_SCENE_HEIGHT - 1; y >= _pan.y; --y) { - byte *destP = (byte *)scene._backgroundSurface.getBasePtr(0, y); - byte *srcP = (byte *)scene._backgroundSurface.getBasePtr(0, y - _pan.y); - Common::copy(srcP, srcP + MADS_SCREEN_WIDTH, destP); - } - - Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH, - (byte *)scene._backgroundSurface.getPixels()); - delete[] linesTemp; - } - - // Flag for a full screen refresh - scene._spriteSlots.fullRefresh(); - } - - // Scroll all active text lines up - for (int i = _textLines.size() - 1; i >= 0; --i) { - TextLine &tl = _textLines[i]; - if (tl._textDisplayIndex != -1) - // Expire the text line that's already on-screen - scene._textDisplay.expire(tl._textDisplayIndex); - - tl._pos.y--; - if (tl._pos.y < 0) { - _textLines.remove_at(i); - } else { - tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y, - 0x605, -1, tl._line, _font); - } - } - - if (_scrollCount > 0) { - // Handling final scrolling of text off of screen - if (--_scrollCount == 0) { - scriptDone(); - return; - } - } else { - // Handling a text row - if (++_lineY == (_font->getHeight() + TEXTVIEW_LINE_SPACING)) - processLines(); - } -} - -void TextView::scriptDone() { - _breakFlag = true; - _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; -} - -/*------------------------------------------------------------------------*/ - -char AnimationView::_resourceName[100]; - -void AnimationView::execute(MADSEngine *vm, const Common::String &resName) { - assert(resName.size() < 100); - Common::strlcpy(_resourceName, resName.c_str(), sizeof(_resourceName)); - vm->_dialogs->_pendingDialog = DIALOG_ANIMVIEW; -} - -AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) { - _redrawFlag = false; - - _soundDriverLoaded = false; - _previousUpdate = 0; - _screenId = -1; - _resetPalette = false; - _resyncMode = NEVER; - _v1 = 0; - _v2 = -1; - _resourceIndex = -1; - _currentAnimation = nullptr; - _sfx = 0; - _soundFlag = _bgLoadFlag = true; - _showWhiteBars = true; - _manualFrameNumber = 0; - _manualSpriteSet = nullptr; - _manualStartFrame = _manualEndFrame = 0; - _manualFrame2 = 0; - _animFrameNumber = 0; - _nextCyclingActive = false; - _sceneInfo = SceneInfo::init(_vm); - - load(); -} - -AnimationView::~AnimationView() { - delete _currentAnimation; - delete _sceneInfo; -} - -void AnimationView::load() { - Common::String resName(_resourceName); - if (!resName.hasSuffix(".")) - resName += ".res"; - - if (!_script.open(resName)) - error("Could not open resource %s", resName.c_str()); - - processLines(); -} - -void AnimationView::display() { - Scene &scene = _vm->_game->_scene; - _vm->_palette->initPalette(); - Common::fill(&_vm->_palette->_cyclingPalette[0], &_vm->_palette->_cyclingPalette[PALETTE_SIZE], 0); - - _vm->_palette->resetGamePalette(1, 8); - scene._spriteSlots.reset(); - scene._paletteCycles.clear(); - - MenuView::display(); -} - -bool AnimationView::onEvent(Common::Event &event) { - // Wait for the Escape key or a mouse press - if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) || - (event.type == Common::EVENT_RBUTTONUP)) { - scriptDone(); - return true; - } - - return false; -} - -void AnimationView::doFrame() { - Scene &scene = _vm->_game->_scene; - - if (_resourceIndex == -1 || _currentAnimation->freeFlag()) { - if (++_resourceIndex == (int)_resources.size()) { - scriptDone(); - } else { - scene._frameStartTime = 0; - loadNextResource(); - } - } else if (_currentAnimation->getCurrentFrame() == 1) { - scene._cyclingActive = _nextCyclingActive; - } - - if (_currentAnimation) { - ++scene._frameStartTime; - _currentAnimation->update(); - _redrawFlag = true; - } -} - -void AnimationView::loadNextResource() { - Scene &scene = _vm->_game->_scene; - Palette &palette = *_vm->_palette; - ResourceEntry &resEntry = _resources[_resourceIndex]; - Common::Array paletteCycles; - - if (resEntry._bgFlag) - palette.resetGamePalette(1, 8); - - palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1] - = palette._mainPalette[253 * 3 + 2] = 0xb4; - palette.setPalette(&palette._mainPalette[253 * 3], 253, 1); - - // Free any previous messages - scene._kernelMessages.reset(); - - // Handle the bars at the top/bottom - if (resEntry._showWhiteBars) { - // For animations the screen has been clipped to the middle 156 rows. - // So although it's slightly messy, bypass our screen class entirely, - // and draw the horizontal lines directly on the physiacl screen surface - Graphics::Surface *s = g_system->lockScreen(); - s->hLine(0, 20, MADS_SCREEN_WIDTH, 253); - s->hLine(0, 179, MADS_SCREEN_WIDTH, 253); - g_system->unlockScreen(); - } - - // Load the new animation - delete _currentAnimation; - _currentAnimation = Animation::init(_vm, &scene); - int flags = ANIMFLAG_ANIMVIEW | (resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0); - _currentAnimation->load(scene._backgroundSurface, scene._depthSurface, - resEntry._resourceName, flags, &paletteCycles, _sceneInfo); - - // Signal for a screen refresh - scene._spriteSlots.fullRefresh(); - - // If a sound driver has been specified, then load the correct one - if (!_currentAnimation->_header._soundName.empty()) { - const char *chP = strchr(_currentAnimation->_header._soundName.c_str(), '.'); - assert(chP); - - // Handle both Rex naming (xxx.009) and naming in later games (e.g. xxx.ph9) - int driverNum = atoi(chP + 3); - // HACK for Dragon - if (_currentAnimation->_header._soundName == "#SOUND.DRG") - driverNum = 9; - _vm->_sound->init(driverNum); - } - - // Handle any manual setup - if (_currentAnimation->_header._manualFlag) { - _manualFrameNumber = _currentAnimation->_header._spritesIndex; - _manualSpriteSet = _currentAnimation->getSpriteSet(_manualFrameNumber); - } - - // Set the sound data for the animation - _vm->_sound->setEnabled(resEntry._soundFlag); - - Common::String dsrName = _currentAnimation->_header._dsrName; - if (!dsrName.empty()) - _vm->_audio->setSoundGroup(dsrName); - - // Start the new animation - _currentAnimation->startAnimation(0); - - // Handle the palette and cycling palette - scene._cyclingActive = false; - Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE], - &palette._cyclingPalette[0]); - - _vm->_game->_fx = (ScreenTransition)resEntry._fx; - _nextCyclingActive = paletteCycles.size() > 0; - if (!_vm->_game->_fx) { - palette.setFullPalette(palette._mainPalette); - } - - scene.initPaletteAnimation(paletteCycles, _nextCyclingActive && !_vm->_game->_fx); -} - -void AnimationView::scriptDone() { - _breakFlag = true; - _vm->_dialogs->_pendingDialog = DIALOG_MAIN_MENU; -} - -void AnimationView::processLines() { - if (_script.eos()) { - // end of script, end animation - scriptDone(); - return; - } - - while (!_script.eos()) { - // Get in next line - _currentLine.clear(); - char c; - while (!_script.eos() && (c = _script.readByte()) != '\n') { - if (c != '\r' && c != '\0') - _currentLine += c; - } - - // Process the line - while (!_currentLine.empty()) { - if (_currentLine.hasPrefix("-")) { - _currentLine.deleteChar(0); - - processCommand(); - } else { - // Get resource name - Common::String resName; - while (!_currentLine.empty() && (c = _currentLine[0]) != ' ') { - _currentLine.deleteChar(0); - resName += c; - } - - // Add resource into list along with any set state information - _resources.push_back(ResourceEntry(resName, _sfx, _soundFlag, - _bgLoadFlag, _showWhiteBars)); - - // Fx resets between resource entries - _sfx = 0; - } - - // Skip any spaces - while (_currentLine.hasPrefix(" ")) - _currentLine.deleteChar(0); - } - } -} - -void AnimationView::processCommand() { - // Get the command character - char commandChar = toupper(_currentLine[0]); - _currentLine.deleteChar(0); - - // Handle the command - switch (commandChar) { - case 'B': - _soundFlag = !_soundFlag; - break; - case 'H': - // -h[:ex] Disable EMS / XMS high memory support - if (_currentLine.hasPrefix(":")) - _currentLine.deleteChar(0); - while (_currentLine.hasPrefix("e") || _currentLine.hasPrefix("x")) - _currentLine.deleteChar(0); - break; - case 'O': - // -o:xxx Specify opening special effect - assert(_currentLine[0] == ':'); - _currentLine.deleteChar(0); - _sfx = getParameter(); - break; - case 'P': - // Switch to CONCAT mode, which is ignored anyway - break; - case 'R': { - // Resynch timer (always, beginning, never) - assert(_currentLine[0] == ':'); - _currentLine.deleteChar(0); - - char v = toupper(_currentLine[0]); - _currentLine.deleteChar(0); - if (v == 'N') - _resyncMode = NEVER; - else if (v == 'A') - _resyncMode = ALWAYS; - else if (v == 'B') - _resyncMode = BEGINNING; - else - error("Unknown parameter"); - break; - } - case 'W': - // Switch white bars being visible - _showWhiteBars = !_showWhiteBars; - break; - case 'X': - // Exit after animation finishes. Ignore - break; - case 'D': - // Unimplemented and ignored in the original. Ignore as well - break; - case 'Y': - // Reset palette on startup - _resetPalette = true; - break; - default: - error("Unknown command char: '%c'", commandChar); - } -} - -int AnimationView::getParameter() { - int result = 0; - - while (!_currentLine.empty()) { - char c = _currentLine[0]; - - if (c >= '0' && c <= '9') { - _currentLine.deleteChar(0); - result = result * 10 + (c - '0'); - } else { - break; - } - } - - return result; -} - -void AnimationView::checkResource(const Common::String &resourceName) { - //bool hasSuffix = false; - -} - -int AnimationView::scanResourceIndex(const Common::String &resourceName) { - int foundIndex = -1; - - if (_v1) { - const char *chP = strchr(resourceName.c_str(), '\\'); - if (!chP) { - chP = strchr(resourceName.c_str(), '*'); - } - - Common::String resName = chP ? Common::String(chP + 1) : resourceName; - - if (_v2 != 3) { - assert(_resIndex.size() == 0); - } - - // Scan for the resource name - for (uint resIndex = 0; resIndex < _resIndex.size(); ++resIndex) { - ResIndexEntry &resEntry = _resIndex[resIndex]; - if (resEntry._resourceName.compareToIgnoreCase(resourceName)) { - foundIndex = resIndex; - break; - } - } - } - - if (foundIndex >= 0) { - // TODO - } - return -1; -} - - } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index c05c87258e..29777a7a7c 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "mads/game.h" +#include "mads/menu_views.h" #include "mads/msurface.h" #include "mads/nebular/dialogs_nebular.h" @@ -36,27 +37,6 @@ namespace Nebular { enum MADSGameAction { START_GAME, RESUME_GAME, SHOW_INTRO, CREDITS, QUOTES, EXIT }; -class MenuView: public FullScreenDialog { -protected: - bool _breakFlag; - bool _redrawFlag; - - virtual void doFrame() = 0; - - virtual void display(); - - /** - * Event handler - */ - virtual bool onEvent(Common::Event &event); -public: - MenuView(MADSEngine *vm); - - virtual ~MenuView() {} - - virtual void show(); -}; - class MainMenu: public MenuView { private: SpriteAsset *_menuItems[7]; @@ -148,174 +128,6 @@ public: void show(); }; -struct TextLine { - Common::Point _pos; - Common::String _line; - int _textDisplayIndex; -}; - -/** - * Scrolling text view - */ -class TextView : public MenuView { -private: - static char _resourceName[100]; - - bool _animating; - Common::Array _textLines; - Common::Point _pan; - int _panSpeed; - MSurface _spareScreens[4]; - int _scrollCount; - int _lineY; - uint32 _scrollTimeout; - int _panCountdown; - int _translationX; - Common::File _script; - char _currentLine[80]; - MSurface *_spareScreen; - Font *_font; -private: - /** - * Load the text resource - */ - void load(); - - /** - * Process the lines - */ - void processLines(); - - /** - * Process a command from the script file - */ - void processCommand(); - - /** - * Process text from the script file - */ - void processText(); - - /** - * Get a parameter from line - */ - int getParameter(const char **paramP); - - /** - * Called when the script is finished - */ - void scriptDone(); - - /** - * Reset the game palette - */ - void resetPalette(); -protected: - virtual void display(); - - virtual void doFrame(); -public: - /** - * Queue the given text resource for display - */ - static void execute(MADSEngine *vm, const Common::String &resName); - - TextView(MADSEngine *vm); - - virtual ~TextView(); -}; - -enum ResyncMode { NEVER, ALWAYS, BEGINNING }; - -struct ResourceEntry { - Common::String _resourceName; - int _fx; - bool _soundFlag; - bool _bgFlag; - bool _showWhiteBars; - - ResourceEntry() {} - ResourceEntry(const Common::String &resName, int fx, bool soundFlag, - bool bgFlag, bool showWhiteBars) { - _resourceName = resName; - _fx = fx; - _soundFlag = soundFlag; - _bgFlag = bgFlag; - _showWhiteBars = showWhiteBars; - } -}; - -struct ResIndexEntry { - int _id; - int _v; - Common::String _resourceName; - - ResIndexEntry() {} -}; - -/** -* Animation cutscene view -*/ -class AnimationView : public MenuView { -private: - static char _resourceName[100]; - - Common::File _script; - uint32 _previousUpdate; - Common::String _currentLine; - bool _soundDriverLoaded; - bool _resetPalette; - ResyncMode _resyncMode; - int _sfx; - bool _soundFlag; - bool _bgLoadFlag; - bool _showWhiteBars; - Common::Array _resources; - Common::Array _resIndex; - int _v1; - int _v2; - int _resourceIndex; - SceneInfo *_sceneInfo; - Animation *_currentAnimation; - int _manualFrameNumber; - SpriteAsset *_manualSpriteSet; - int _manualStartFrame, _manualEndFrame; - int _manualFrame2; - int _animFrameNumber; - bool _nextCyclingActive; -private: - void checkResource(const Common::String &resourceName); - - int scanResourceIndex(const Common::String &resourceName); - - void load(); - - void processLines(); - - void processCommand(); - - int getParameter(); - - void scriptDone(); - - void loadNextResource(); -protected: - virtual void display(); - - virtual void doFrame(); - - virtual bool onEvent(Common::Event &event); -public: - /** - * Queue the given text resource for display - */ - static void execute(MADSEngine *vm, const Common::String &resName); - - AnimationView(MADSEngine *vm); - - virtual ~AnimationView(); -}; - } // End of namespace Nebular } // End of namespace MADS -- cgit v1.2.3 From e6d1337e115d4a49d9103e33b1e75133d237e090 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 15 Oct 2014 18:51:14 +0300 Subject: SCI: Ignore most of the non-alphanumeric characters in the parser This is a more proper handling of non-alphanumeric characters (e.g. apostrophes) in SCI games with a parser - bug #6608 --- engines/sci/parser/vocabulary.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index 3344b79e26..7fc02dc9a0 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -535,9 +535,9 @@ bool Vocabulary::tokenizeString(ResultWordListList &retval, const char *sentence if (Common::isAlnum(c) || (c == '-' && wordLen) || (c >= 0x80)) { currentWord[wordLen] = lowerCaseMap[c]; ++wordLen; - } else if (c == '\'' && wordLen && (sentence[pos_in_sentence] == 's' || sentence[pos_in_sentence] == 'S')) { - // Skip apostrophe-s at the end of the word, if it exists - pos_in_sentence++; // skip the 's' + } else if (!Common::isAlpha(c) && c != '-' && c != ' ' && c != '\0' && (g_sci->getLanguage() != Common::JA_JPN)) { + // Skip non-alphanumeric characters in the string. + // Note: hyphens ('-'), spaces and string terminators are handled in the other branches. } else { // Continue on this word. Words may contain a '-', but may not start with // one. -- cgit v1.2.3 From 740d1620f20511449c492190fa6432bb85439cc9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 15 Oct 2014 19:44:03 +0300 Subject: SCI: Simplify check for non-alphanumeric characters in the parser This is also for bug #6608. Many thanks to wjp for his help with this --- engines/sci/parser/vocabulary.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index 7fc02dc9a0..000b037b44 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -535,10 +535,7 @@ bool Vocabulary::tokenizeString(ResultWordListList &retval, const char *sentence if (Common::isAlnum(c) || (c == '-' && wordLen) || (c >= 0x80)) { currentWord[wordLen] = lowerCaseMap[c]; ++wordLen; - } else if (!Common::isAlpha(c) && c != '-' && c != ' ' && c != '\0' && (g_sci->getLanguage() != Common::JA_JPN)) { - // Skip non-alphanumeric characters in the string. - // Note: hyphens ('-'), spaces and string terminators are handled in the other branches. - } else { + } else if (c == ' ' || c == '\0') { // Continue on this word. Words may contain a '-', but may not start with // one. -- cgit v1.2.3 From cc175b5af4e2e9117f1313e38304fa9343b0d095 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sun, 2 Feb 2014 22:26:29 +0100 Subject: WINTERMUTE: Import subtitle code from WME1 --- engines/wintermute/module.mk | 2 + engines/wintermute/video/video_subtitle.cpp | 59 +++++++ engines/wintermute/video/video_subtitle.h | 49 ++++++ engines/wintermute/video/video_subtitler.cpp | 213 +++++++++++++++++++++++ engines/wintermute/video/video_subtitler.h | 54 ++++++ engines/wintermute/video/video_theora_player.cpp | 3 +- engines/wintermute/video/video_theora_player.h | 3 +- 7 files changed, 380 insertions(+), 3 deletions(-) create mode 100644 engines/wintermute/video/video_subtitle.cpp create mode 100644 engines/wintermute/video/video_subtitle.h create mode 100644 engines/wintermute/video/video_subtitler.cpp create mode 100644 engines/wintermute/video/video_subtitler.h diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index 1b6c52e0b7..b4845b0552 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -109,6 +109,8 @@ MODULE_OBJS := \ utils/string_util.o \ utils/utils.o \ video/video_player.o \ + video/video_subtitle.o \ + video/video_subtitler.o \ video/video_theora_player.o \ debugger.o \ wintermute.o \ diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp new file mode 100644 index 0000000000..45b0ee65cf --- /dev/null +++ b/engines/wintermute/video/video_subtitle.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + +// #include "dcgf.h" +#include "engines/wintermute/video/video_subtitle.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +CVidSubtitle::CVidSubtitle(BaseGame* inGame):BaseClass(inGame) +{ + m_Text = NULL; + m_StartFrame = m_EndFrame = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame):BaseClass(inGame) +{ + m_Text = new char[strlen(Text)+1]; + strcpy(m_Text, Text); +// _gameRef->m_StringTable->Expand(&m_Text); + + m_StartFrame = StartFrame; + m_EndFrame = EndFrame; +} + + +////////////////////////////////////////////////////////////////////////// +CVidSubtitle::~CVidSubtitle() +{ + // SAFE_DELETE_ARRAY(m_Text); +} +} diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h new file mode 100644 index 0000000000..0b3d591f6d --- /dev/null +++ b/engines/wintermute/video/video_subtitle.h @@ -0,0 +1,49 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDSUBTITLE_H +#define WINTERMUTE_VIDSUBTITLE_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class CVidSubtitle : public BaseClass +{ +public: + long m_EndFrame; + long m_StartFrame; + char* m_Text; + CVidSubtitle(BaseGame* inGame); + CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame); + virtual ~CVidSubtitle(); + +}; +} + +#endif diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp new file mode 100644 index 0000000000..ca812c57a1 --- /dev/null +++ b/engines/wintermute/video/video_subtitler.cpp @@ -0,0 +1,213 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + + +// #include "dcgf.h" +#include "engines/wintermute/video/video_subtitler.h" +#define S_OK 0 +#define BYTE byte +#define LONG long +#define MAX_PATH 127 +#define _MAX_DRIVE 127 +#define _MAX_DIR 127 +#define _MAX_FNAME 127 +#define DWORD byte + +namespace Wintermute { +////////////////////////////////////////////////////////////////////////// +CVidSubtitler::CVidSubtitler(BaseGame *inGame):BaseClass(inGame) +{ + m_LastSample = -1; + m_CurrentSubtitle = 0; + m_ShowSubtitle = false; +} + +////////////////////////////////////////////////////////////////////////// +CVidSubtitler::~CVidSubtitler(void) +{ + for(int i=0; im_FileManager->ReadWholeFile(NewFile, &Size, false); + + if(Buffer==NULL) return S_OK; // no subtitles + + + LONG Start, End; + bool InToken; + char* TokenStart; + int TokenLength; + int TokenPos; + int TextLength; + + int Pos = 0; + int LineLength = 0; + while(Pos=Size?0:1); + char* Text = new char[RealLength+1]; + char* line = (char*)&Buffer[Pos]; + + for(int i=0; i0 && (Start!=1 || End!=1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + + delete [] Text; + + Pos+=LineLength+1; + } + + delete [] Buffer; +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidSubtitler::Display() +{ +#if 0 + if(m_ShowSubtitle) + { + CBFont* font = Game->m_VideoFont?Game->m_VideoFont:Game->m_SystemFont; + int Height = font->GetTextHeight((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); + font->DrawText((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height-Height-5, Game->m_Renderer->m_Width, TAL_CENTER); + } +#endif + return S_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CVidSubtitler::Update(LONG Frame) +{ + if(Frame != m_LastSample) + { + m_LastSample = Frame; + + // process subtitles + m_ShowSubtitle = false; + while(m_CurrentSubtitlem_EndFrame; + + bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size()-1 && m_Subtitles[m_CurrentSubtitle+1]->m_StartFrame <= Frame); + + if(Frame > End){ + if(NextFrameOK){ + m_CurrentSubtitle++; + } + else{ + m_ShowSubtitle = (End==0); + break; + } + } + else{ + m_ShowSubtitle = true; + break; + } + } + } + return S_OK; +} +} diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h new file mode 100644 index 0000000000..144e90f228 --- /dev/null +++ b/engines/wintermute/video/video_subtitler.h @@ -0,0 +1,54 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_VIDSUBTITLER_H +#define WINTERMUTE_VIDSUBTITLER_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/video/video_subtitle.h" + +namespace Wintermute { + +class CVidSubtitler : + public BaseClass +{ +public: + CVidSubtitler(BaseGame *inGame); + virtual ~CVidSubtitler(void); + + bool m_ShowSubtitle; + int m_CurrentSubtitle; + bool LoadSubtitles(char* Filename, char* SubtitleFile); + bool Display(); + bool Update(long Frame); + long m_LastSample; + Common::Array m_Subtitles; +}; +} + +#endif diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index e1553580ec..fc1571054c 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -85,8 +85,7 @@ void VideoTheoraPlayer::SetDefaults() { _volume = 100; _theoraDecoder = nullptr; - // TODO: Add subtitles-support - //_subtitler = nullptr; + _subtitler = new CVidSubtitler(_gameRef); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 8274a1444f..2d79c5404b 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -31,6 +31,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/persistent.h" +#include "engines/wintermute/video/video_subtitler.h" #include "video/video_decoder.h" #include "common/stream.h" #include "graphics/surface.h" @@ -59,7 +60,7 @@ public: Common::String _filename; BaseSurface *_texture; - //CVidSubtitler *_subtitler; + CVidSubtitler *_subtitler; // control methods bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String()); -- cgit v1.2.3 From 5ee11d6c21ad991ed30a043dd94656a9da0d6256 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 19:29:12 +0200 Subject: WINTERMUTE: Astyle imported WME subtitle code --- engines/wintermute/video/video_subtitle.cpp | 11 +-- engines/wintermute/video/video_subtitle.h | 9 +-- engines/wintermute/video/video_subtitler.cpp | 110 ++++++++++++--------------- engines/wintermute/video/video_subtitler.h | 7 +- 4 files changed, 58 insertions(+), 79 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 45b0ee65cf..74b3119503 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -32,17 +32,15 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame* inGame):BaseClass(inGame) -{ +CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) { m_Text = NULL; m_StartFrame = m_EndFrame = 0; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame):BaseClass(inGame) -{ - m_Text = new char[strlen(Text)+1]; +CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) { + m_Text = new char[strlen(Text) + 1]; strcpy(m_Text, Text); // _gameRef->m_StringTable->Expand(&m_Text); @@ -52,8 +50,7 @@ CVidSubtitle::CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long E ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::~CVidSubtitle() -{ +CVidSubtitle::~CVidSubtitle() { // SAFE_DELETE_ARRAY(m_Text); } } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 0b3d591f6d..e93007bd3b 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -33,14 +33,13 @@ namespace Wintermute { -class CVidSubtitle : public BaseClass -{ +class CVidSubtitle : public BaseClass { public: long m_EndFrame; long m_StartFrame; - char* m_Text; - CVidSubtitle(BaseGame* inGame); - CVidSubtitle(BaseGame* inGame, char* Text, long StartFrame, long EndFrame); + char *m_Text; + CVidSubtitle(BaseGame *inGame); + CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame); virtual ~CVidSubtitle(); }; diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index ca812c57a1..8c6d222cd3 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -40,27 +40,24 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::CVidSubtitler(BaseGame *inGame):BaseClass(inGame) -{ +CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) { m_LastSample = -1; m_CurrentSubtitle = 0; m_ShowSubtitle = false; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::~CVidSubtitler(void) -{ - for(int i=0; im_FileManager->ReadWholeFile(NewFile, &Size, false); + BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false); - if(Buffer==NULL) return S_OK; // no subtitles + if (Buffer == NULL) return S_OK; // no subtitles LONG Start, End; bool InToken; - char* TokenStart; + char *TokenStart; int TokenLength; int TokenPos; int TextLength; int Pos = 0; int LineLength = 0; - while(Pos=Size?0:1); - char* Text = new char[RealLength+1]; - char* line = (char*)&Buffer[Pos]; + int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); + char *Text = new char[RealLength + 1]; + char *line = (char *)&Buffer[Pos]; - for(int i=0; i0 && (Start!=1 || End!=1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); delete [] Text; - Pos+=LineLength+1; + Pos += LineLength + 1; } delete [] Buffer; @@ -166,43 +156,37 @@ bool CVidSubtitler::LoadSubtitles(char* Filename, char* SubtitleFile) } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Display() -{ +bool CVidSubtitler::Display() { #if 0 - if(m_ShowSubtitle) - { - CBFont* font = Game->m_VideoFont?Game->m_VideoFont:Game->m_SystemFont; - int Height = font->GetTextHeight((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); - font->DrawText((BYTE*)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height-Height-5, Game->m_Renderer->m_Width, TAL_CENTER); + if (m_ShowSubtitle) { + CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont; + int Height = font->GetTextHeight((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); + font->DrawText((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER); } #endif return S_OK; } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Update(LONG Frame) -{ - if(Frame != m_LastSample) - { +bool CVidSubtitler::Update(LONG Frame) { + if (Frame != m_LastSample) { m_LastSample = Frame; // process subtitles m_ShowSubtitle = false; - while(m_CurrentSubtitlem_EndFrame; - bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size()-1 && m_Subtitles[m_CurrentSubtitle+1]->m_StartFrame <= Frame); + bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size() - 1 && m_Subtitles[m_CurrentSubtitle + 1]->m_StartFrame <= Frame); - if(Frame > End){ - if(NextFrameOK){ + if (Frame > End) { + if (NextFrameOK) { m_CurrentSubtitle++; - } - else{ - m_ShowSubtitle = (End==0); + } else { + m_ShowSubtitle = (End == 0); break; } - } - else{ + } else { m_ShowSubtitle = true; break; } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 144e90f228..fb3da8dc91 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -35,19 +35,18 @@ namespace Wintermute { class CVidSubtitler : - public BaseClass -{ + public BaseClass { public: CVidSubtitler(BaseGame *inGame); virtual ~CVidSubtitler(void); bool m_ShowSubtitle; int m_CurrentSubtitle; - bool LoadSubtitles(char* Filename, char* SubtitleFile); + bool LoadSubtitles(char *Filename, char *SubtitleFile); bool Display(); bool Update(long Frame); long m_LastSample; - Common::Array m_Subtitles; + Common::Array m_Subtitles; }; } -- cgit v1.2.3 From ec3b8fdde24324fd4a2ad5c37735644a79f1e574 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 19:40:48 +0200 Subject: WINTERMUTE: Use long-style braces around blocks in imported subtitle code --- engines/wintermute/video/video_subtitler.cpp | 41 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 8c6d222cd3..537378963e 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -48,16 +48,23 @@ CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// CVidSubtitler::~CVidSubtitler(void) { - for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i]; + for (int i = 0; i < m_Subtitles.size(); i++) { + delete m_Subtitles[i]; + } m_Subtitles.clear(); } ////////////////////////////////////////////////////////////////////////// bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { - if (!Filename) return S_OK; + if (!Filename) { + return S_OK; + } + + for (int i = 0; i < m_Subtitles.size(); i++) { + delete m_Subtitles[i]; + } - for (int i = 0; i < m_Subtitles.size(); i++) delete m_Subtitles[i]; m_Subtitles.clear(); m_LastSample = -1; @@ -84,7 +91,9 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { #if 0 BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false); - if (Buffer == NULL) return S_OK; // no subtitles + if (Buffer == NULL) { + return S_OK; // no subtitles + } LONG Start, End; @@ -103,7 +112,9 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { TextLength = 0; LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') LineLength++; + while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { + LineLength++; + } int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); char *Text = new char[RealLength + 1]; @@ -116,16 +127,20 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { TokenStart = line + i + 1; TokenLength = 0; TokenPos++; - } else TokenLength++; + } else { + TokenLength++; + } } else if (line[i] == '}') { if (InToken) { InToken = false; char *Token = new char[TokenLength + 1]; strncpy(Token, TokenStart, TokenLength); Token[TokenLength] = '\0'; - if (TokenPos == 0) Start = atoi(Token); - else if (TokenPos == 1) End = atoi(Token); - + if (TokenPos == 0) { + Start = atoi(Token); + } else if (TokenPos == 1) { + End = atoi(Token); + } delete [] Token; } else { Text[TextLength] = line[i]; @@ -136,14 +151,18 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { TokenLength++; } else { Text[TextLength] = line[i]; - if (Text[TextLength] == '|') Text[TextLength] = '\n'; + if (Text[TextLength] == '|') { + Text[TextLength] = '\n'; + } TextLength++; } } } Text[TextLength] = '\0'; - if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) { + m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + } delete [] Text; -- cgit v1.2.3 From ba1862ecb8bb80751c58e70f233449dd05e4245c Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 19:43:26 +0200 Subject: WINTERMUTE: Use BaseFileManager to load SUB file Conflicts: engines/wintermute/video/video_subtitler.cpp --- engines/wintermute/video/video_subtitler.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 537378963e..072d1e1c99 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -29,6 +29,8 @@ // #include "dcgf.h" #include "engines/wintermute/video/video_subtitler.h" +#include "engines/wintermute/base/base_file_manager.h" + #define S_OK 0 #define BYTE byte #define LONG long @@ -73,9 +75,6 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { char NewFile[MAX_PATH]; - char drive[_MAX_DRIVE]; - char dir[_MAX_DIR]; - char fname[_MAX_FNAME]; if (SubtitleFile) { strcpy(NewFile, SubtitleFile); @@ -88,13 +87,14 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { #endif DWORD Size; -#if 0 - BYTE *Buffer = _gameRef->m_FileManager->ReadWholeFile(NewFile, &Size, false); - - if (Buffer == NULL) { + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false); + if (file == nullptr) { return S_OK; // no subtitles } + Size = file->size(); + BYTE *Buffer = new BYTE[Size]; + file->read(Buffer, Size); LONG Start, End; bool InToken; @@ -105,6 +105,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { int Pos = 0; int LineLength = 0; + while (Pos < Size) { Start = End = -1; InToken = false; @@ -161,7 +162,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { Text[TextLength] = '\0'; if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) { - m_Subtitles.Add(new CVidSubtitle(Game, Text, Start, End)); + m_Subtitles.push_back(new CVidSubtitle(_gameRef, Text, Start, End)); } delete [] Text; @@ -170,7 +171,7 @@ bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { } delete [] Buffer; -#endif + return S_OK; } -- cgit v1.2.3 From d9d80db869b21e4625d445e4f00af6b03b09e6c8 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 14 Oct 2014 22:58:17 +0200 Subject: WINTERMUTE: Take const char in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 2 +- engines/wintermute/video/video_subtitler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 072d1e1c99..6d65adea74 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -58,7 +58,7 @@ CVidSubtitler::~CVidSubtitler(void) { ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::LoadSubtitles(char *Filename, char *SubtitleFile) { +bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) { if (!Filename) { return S_OK; } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index fb3da8dc91..25641bc574 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -42,7 +42,7 @@ public: bool m_ShowSubtitle; int m_CurrentSubtitle; - bool LoadSubtitles(char *Filename, char *SubtitleFile); + bool LoadSubtitles(const char *Filename, const char *SubtitleFile); bool Display(); bool Update(long Frame); long m_LastSample; -- cgit v1.2.3 From 532217bcee6ee33a189f71e6c37323442299c4e2 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 14 Oct 2014 23:00:11 +0200 Subject: WINTERMUTE: Reinstate subtitle loading --- engines/wintermute/video/video_theora_player.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index fc1571054c..205ebe5035 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -129,6 +129,10 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: warning("VideoTheoraPlayer::initialize - Theora support not compiled in, video will be skipped: %s", filename.c_str()); return STATUS_FAILED; #endif + + + _subtitler->LoadSubtitles(_filename.c_str(), subtitleFile.c_str()); + _theoraDecoder->loadStream(_file); if (!_theoraDecoder->isVideoLoaded()) { -- cgit v1.2.3 From 6f6e49f4cf183d9cbdf75060f4c271a538c6d1d1 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 14 Oct 2014 23:00:34 +0200 Subject: WINTERMUTE: Display subtitles in console --- engines/wintermute/video/video_subtitler.cpp | 1 + engines/wintermute/video/video_theora_player.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 6d65adea74..965f7f1979 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -177,6 +177,7 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile ////////////////////////////////////////////////////////////////////////// bool CVidSubtitler::Display() { + warning((const char *)m_Subtitles[m_CurrentSubtitle]->m_Text); #if 0 if (m_ShowSubtitle) { CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 205ebe5035..232c4847b1 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -217,7 +217,8 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _state = THEORA_STATE_PLAYING; _looping = looping; _playbackType = type; - + _subtitler->Update(_theoraDecoder->getFrameCount()); + _subtitler->Display(); _startTime = startTime; _volume = volume; _posX = x; @@ -292,6 +293,9 @@ bool VideoTheoraPlayer::update() { } if (_theoraDecoder) { + + _subtitler->Update(_theoraDecoder->getCurFrame()); + if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie %s, hacked for now", _filename.c_str()); _theoraDecoder->rewind(); @@ -419,6 +423,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) { /* if (m_Subtitler && _gameRef->m_VideoSubtitles) { m_Subtitler->display(); }*/ + _subtitler->Display(); return res; } -- cgit v1.2.3 From 1715196325c5b5867fd9bc684ca5204655fc9573 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 14 Oct 2014 23:14:14 +0200 Subject: WINTERMUTE: Re-enable and use PathUtils for auto SRT detection --- engines/wintermute/video/video_subtitler.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 965f7f1979..facc7076ee 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -30,6 +30,7 @@ // #include "dcgf.h" #include "engines/wintermute/video/video_subtitler.h" #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/path_util.h" #define S_OK 0 #define BYTE byte @@ -74,17 +75,17 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile m_ShowSubtitle = false; - char NewFile[MAX_PATH]; + Common::String NewFile; if (SubtitleFile) { - strcpy(NewFile, SubtitleFile); + NewFile = Common::String(SubtitleFile); + } else { + Common::String path = PathUtil::getDirectoryName(Filename); + Common::String name = PathUtil::getFileNameWithoutExtension(Filename); + Common::String ext = ".SUB"; + NewFile = PathUtil::combine(path, name + ext); } -#if 0 - else { - _splitpath(Filename, drive, dir, fname, NULL); - _makepath(NewFile, drive, dir, fname, ".SUB"); - } -#endif + DWORD Size; Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false); -- cgit v1.2.3 From d8b432fe51d93edaff631792868489eb2bc3ec4a Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 14 Oct 2014 23:13:46 +0200 Subject: WINTERMUTE: Use native C types instead of macros --- engines/wintermute/video/video_subtitler.cpp | 39 ++++++++++------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index facc7076ee..24eda703ca 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -26,21 +26,10 @@ * Copyright (c) 2011 Jan Nedoma */ - -// #include "dcgf.h" #include "engines/wintermute/video/video_subtitler.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/path_util.h" -#define S_OK 0 -#define BYTE byte -#define LONG long -#define MAX_PATH 127 -#define _MAX_DRIVE 127 -#define _MAX_DIR 127 -#define _MAX_FNAME 127 -#define DWORD byte - namespace Wintermute { ////////////////////////////////////////////////////////////////////////// CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) { @@ -61,11 +50,7 @@ CVidSubtitler::~CVidSubtitler(void) { ////////////////////////////////////////////////////////////////////////// bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) { if (!Filename) { - return S_OK; - } - - for (int i = 0; i < m_Subtitles.size(); i++) { - delete m_Subtitles[i]; + return false; } m_Subtitles.clear(); @@ -86,18 +71,20 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile NewFile = PathUtil::combine(path, name + ext); } - DWORD Size; + long Size; Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false); + if (file == nullptr) { - return S_OK; // no subtitles + return false; // no subtitles } Size = file->size(); - BYTE *Buffer = new BYTE[Size]; + char *Buffer = new char[Size]; + file->read(Buffer, Size); - LONG Start, End; + long Start, End; bool InToken; char *TokenStart; int TokenLength; @@ -173,7 +160,7 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile delete [] Buffer; - return S_OK; + return false; } ////////////////////////////////////////////////////////////////////////// @@ -182,15 +169,15 @@ bool CVidSubtitler::Display() { #if 0 if (m_ShowSubtitle) { CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont; - int Height = font->GetTextHeight((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); - font->DrawText((BYTE *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER); + int Height = font->GetTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); + font->DrawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER); } #endif - return S_OK; + return false; } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Update(LONG Frame) { +bool CVidSubtitler::Update(long Frame) { if (Frame != m_LastSample) { m_LastSample = Frame; @@ -214,6 +201,6 @@ bool CVidSubtitler::Update(LONG Frame) { } } } - return S_OK; + return false; } } -- cgit v1.2.3 From 472d3e3231ac0677cef6edd6417686800f167d29 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Mon, 3 Feb 2014 16:45:12 +0100 Subject: WINTERMUTE: Add getter for _videoFont --- engines/wintermute/base/base_game.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index cdbbff6c93..f62416ee1b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -123,6 +123,7 @@ public: inline BaseObject *getMainObject() { return _mainObject; } inline BaseFont *getSystemFont() { return _systemFont; } + inline BaseFont *getVideoFont() { return _videoFont; } bool initInput(); bool initLoop(); -- cgit v1.2.3 From 389e06bdfcecab07c2a48c8092b22b423e529ac4 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Mon, 3 Feb 2014 16:45:24 +0100 Subject: WINTERMUTE: Port actual subtitle display code. --- engines/wintermute/video/video_subtitler.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 24eda703ca..dd657876ba 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -29,6 +29,9 @@ #include "engines/wintermute/video/video_subtitler.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/gfx/base_renderer.h" namespace Wintermute { ////////////////////////////////////////////////////////////////////////// @@ -165,14 +168,14 @@ bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile ////////////////////////////////////////////////////////////////////////// bool CVidSubtitler::Display() { - warning((const char *)m_Subtitles[m_CurrentSubtitle]->m_Text); -#if 0 if (m_ShowSubtitle) { - CBFont *font = Game->m_VideoFont ? Game->m_VideoFont : Game->m_SystemFont; - int Height = font->GetTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, Game->m_Renderer->m_Width); - font->DrawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, 0, Game->m_Renderer->m_Height - Height - 5, Game->m_Renderer->m_Width, TAL_CENTER); + BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); + int textHeight = font->getTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, _gameRef->_renderer->getWidth()); + font->drawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, + 0, + (_gameRef->_renderer->getHeight() - textHeight - 5), + (_gameRef->_renderer->getWidth(), TAL_CENTER)); } -#endif return false; } -- cgit v1.2.3 From ad5fde9db3767bee7af4e8c23277a07cad705de7 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Feb 2014 14:35:23 +0100 Subject: WINTERMUTE: Reinstate CVidSubtitle destructor --- engines/wintermute/video/video_subtitle.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 74b3119503..3d0688d975 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -// #include "dcgf.h" #include "engines/wintermute/video/video_subtitle.h" namespace Wintermute { @@ -42,8 +41,7 @@ CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) { CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) { m_Text = new char[strlen(Text) + 1]; strcpy(m_Text, Text); -// _gameRef->m_StringTable->Expand(&m_Text); - + // _gameRef->m_StringTable->Expand(&m_Text); m_StartFrame = StartFrame; m_EndFrame = EndFrame; } @@ -51,6 +49,9 @@ CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long E ////////////////////////////////////////////////////////////////////////// CVidSubtitle::~CVidSubtitle() { - // SAFE_DELETE_ARRAY(m_Text); + if (m_Text) { + delete [] m_Text; + m_Text = NULL; + } } } -- cgit v1.2.3 From 621a068c0065783bba0430f57b71112d7e42a5a9 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 20:29:41 +0200 Subject: WINTERMUTE: Mass ScummVM-style renaming in subtitles code --- engines/wintermute/video/video_subtitle.cpp | 27 ++-- engines/wintermute/video/video_subtitle.h | 15 +- engines/wintermute/video/video_subtitler.cpp | 180 ++++++++++++----------- engines/wintermute/video/video_subtitler.h | 23 ++- engines/wintermute/video/video_theora_player.cpp | 19 ++- engines/wintermute/video/video_theora_player.h | 2 +- 6 files changed, 134 insertions(+), 132 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 3d0688d975..0fab6fb2b7 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -31,27 +31,26 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame *inGame): BaseClass(inGame) { - m_Text = NULL; - m_StartFrame = m_EndFrame = 0; +VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { + _text = NULL; + _startFrame = _endFrame = 0; } - ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame): BaseClass(inGame) { - m_Text = new char[strlen(Text) + 1]; - strcpy(m_Text, Text); - // _gameRef->m_StringTable->Expand(&m_Text); - m_StartFrame = StartFrame; - m_EndFrame = EndFrame; +VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) { + _text = new char[strlen(text) + 1]; + strcpy(_text, text); + // _gameRef->m_StringTable->Expand(&this->text); + _startFrame = startFrame; + _endFrame = endFrame; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitle::~CVidSubtitle() { - if (m_Text) { - delete [] m_Text; - m_Text = NULL; +VideoSubtitle::~VideoSubtitle() { + if (_text) { + delete [] _text; + _text = NULL; } } } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index e93007bd3b..6d629b34d0 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -33,15 +33,14 @@ namespace Wintermute { -class CVidSubtitle : public BaseClass { +class VideoSubtitle : public BaseClass { public: - long m_EndFrame; - long m_StartFrame; - char *m_Text; - CVidSubtitle(BaseGame *inGame); - CVidSubtitle(BaseGame *inGame, char *Text, long StartFrame, long EndFrame); - virtual ~CVidSubtitle(); - + long _endFrame; + long _startFrame; + char *_text; + VideoSubtitle(BaseGame *inGame); + VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame); + virtual ~VideoSubtitle(); }; } diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index dd657876ba..9d0a066c20 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -35,143 +35,145 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::CVidSubtitler(BaseGame *inGame): BaseClass(inGame) { - m_LastSample = -1; - m_CurrentSubtitle = 0; - m_ShowSubtitle = false; +VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) { + _lastSample = -1; + _currentSubtitle = 0; + _showSubtitle = false; } ////////////////////////////////////////////////////////////////////////// -CVidSubtitler::~CVidSubtitler(void) { - for (int i = 0; i < m_Subtitles.size(); i++) { - delete m_Subtitles[i]; +VideoSubtitler::~VideoSubtitler(void) { + for (int i = 0; i < _subtitles.size(); i++) { + delete _subtitles[i]; } - m_Subtitles.clear(); + _subtitles.clear(); } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::LoadSubtitles(const char *Filename, const char *SubtitleFile) { +bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFile) { if (!Filename) { return false; } - m_Subtitles.clear(); + for (int i = 0; i < _subtitles.size(); i++) { + delete _subtitles[i]; + } + + _subtitles.clear(); - m_LastSample = -1; - m_CurrentSubtitle = 0; - m_ShowSubtitle = false; + _lastSample = -1; + _currentSubtitle = 0; + _showSubtitle = false; - Common::String NewFile; + Common::String newFile; - if (SubtitleFile) { - NewFile = Common::String(SubtitleFile); + if (subtitleFile) { + newFile = Common::String(subtitleFile); } else { Common::String path = PathUtil::getDirectoryName(Filename); Common::String name = PathUtil::getFileNameWithoutExtension(Filename); Common::String ext = ".SUB"; - NewFile = PathUtil::combine(path, name + ext); + newFile = PathUtil::combine(path, name + ext); } - long Size; + long size; - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(NewFile, true, false); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false); if (file == nullptr) { return false; // no subtitles } - Size = file->size(); - char *Buffer = new char[Size]; + size = file->size(); + char *buffer = new char[size]; + file->read(buffer, size); - file->read(Buffer, Size); + long start, end; + bool inToken; + char *tokenStart; + int tokenLength; + int tokenPos; + int textLength; - long Start, End; - bool InToken; - char *TokenStart; - int TokenLength; - int TokenPos; - int TextLength; + int pos = 0; + int lineLength = 0; - int Pos = 0; - int LineLength = 0; + while (pos < size) { + start = end = -1; + inToken = false; + tokenPos = -1; + textLength = 0; - while (Pos < Size) { - Start = End = -1; - InToken = false; - TokenPos = -1; - TextLength = 0; + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - LineLength = 0; - while (Pos + LineLength < Size && Buffer[Pos + LineLength] != '\n' && Buffer[Pos + LineLength] != '\0') { - LineLength++; - } + int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *Text = new char[realLength + 1]; + char *line = (char *)&buffer[pos]; - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *Text = new char[RealLength + 1]; - char *line = (char *)&Buffer[Pos]; - - for (int i = 0; i < RealLength; i++) { + for (int i = 0; i < realLength; i++) { if (line[i] == '{') { - if (!InToken) { - InToken = true; - TokenStart = line + i + 1; - TokenLength = 0; - TokenPos++; + if (!inToken) { + inToken = true; + tokenStart = line + i + 1; + tokenLength = 0; + tokenPos++; } else { - TokenLength++; + tokenLength++; } } else if (line[i] == '}') { - if (InToken) { - InToken = false; - char *Token = new char[TokenLength + 1]; - strncpy(Token, TokenStart, TokenLength); - Token[TokenLength] = '\0'; - if (TokenPos == 0) { - Start = atoi(Token); - } else if (TokenPos == 1) { - End = atoi(Token); + if (inToken) { + inToken = false; + char *token = new char[tokenLength + 1]; + strncpy(token, tokenStart, tokenLength); + token[tokenLength] = '\0'; + if (tokenPos == 0) { + start = atoi(token); + } else if (tokenPos == 1) { + end = atoi(token); } - delete [] Token; + + delete[] token; } else { - Text[TextLength] = line[i]; - TextLength++; + Text[textLength] = line[i]; + textLength++; } } else { - if (InToken) { - TokenLength++; + if (inToken) { + tokenLength++; } else { - Text[TextLength] = line[i]; - if (Text[TextLength] == '|') { - Text[TextLength] = '\n'; + Text[textLength] = line[i]; + if (Text[textLength] == '|') { + Text[textLength] = '\n'; } - TextLength++; + textLength++; } } } - Text[TextLength] = '\0'; + Text[textLength] = '\0'; - if (Start != -1 && TextLength > 0 && (Start != 1 || End != 1)) { - m_Subtitles.push_back(new CVidSubtitle(_gameRef, Text, Start, End)); + if (start != -1 && textLength > 0 && (start != 1 || end != 1)) { + _subtitles.push_back(new VideoSubtitle(_gameRef, Text, start, end)); } delete [] Text; - Pos += LineLength + 1; + pos += lineLength + 1; } - delete [] Buffer; + delete[] buffer; return false; } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Display() { - if (m_ShowSubtitle) { +bool VideoSubtitler::display() { + if (_showSubtitle) { BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); - int textHeight = font->getTextHeight((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, _gameRef->_renderer->getWidth()); - font->drawText((byte *)m_Subtitles[m_CurrentSubtitle]->m_Text, + int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth()); + font->drawText((byte *)_subtitles[_currentSubtitle]->_text, 0, (_gameRef->_renderer->getHeight() - textHeight - 5), (_gameRef->_renderer->getWidth(), TAL_CENTER)); @@ -180,26 +182,26 @@ bool CVidSubtitler::Display() { } ////////////////////////////////////////////////////////////////////////// -bool CVidSubtitler::Update(long Frame) { - if (Frame != m_LastSample) { - m_LastSample = Frame; +bool VideoSubtitler::update(long frame) { + if (frame != _lastSample) { + _lastSample = frame; // process subtitles - m_ShowSubtitle = false; - while (m_CurrentSubtitle < m_Subtitles.size()) { - int End = m_Subtitles[m_CurrentSubtitle]->m_EndFrame; + _showSubtitle = false; + while (_currentSubtitle < _subtitles.size()) { + int end = _subtitles[_currentSubtitle]->_endFrame; - bool NextFrameOK = (m_CurrentSubtitle < m_Subtitles.size() - 1 && m_Subtitles[m_CurrentSubtitle + 1]->m_StartFrame <= Frame); + bool nextFrameOK = (_currentSubtitle < _subtitles.size() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= frame); - if (Frame > End) { - if (NextFrameOK) { - m_CurrentSubtitle++; + if (frame > end) { + if (nextFrameOK) { + _currentSubtitle++; } else { - m_ShowSubtitle = (End == 0); + _showSubtitle = (end == 0); break; } } else { - m_ShowSubtitle = true; + _showSubtitle = true; break; } } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 25641bc574..e42fbeb505 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -34,19 +34,18 @@ namespace Wintermute { -class CVidSubtitler : - public BaseClass { +class VideoSubtitler : public BaseClass { public: - CVidSubtitler(BaseGame *inGame); - virtual ~CVidSubtitler(void); - - bool m_ShowSubtitle; - int m_CurrentSubtitle; - bool LoadSubtitles(const char *Filename, const char *SubtitleFile); - bool Display(); - bool Update(long Frame); - long m_LastSample; - Common::Array m_Subtitles; + VideoSubtitler(BaseGame *inGame); + virtual ~VideoSubtitler(void); + + bool _showSubtitle; + int _currentSubtitle; + bool loadSubtitles(const char *filename, const char *subtitleFile); + bool display(); + bool update(long frame); + long _lastSample; + Common::Array _subtitles; }; } diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 232c4847b1..a90fb02033 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -85,13 +85,16 @@ void VideoTheoraPlayer::SetDefaults() { _volume = 100; _theoraDecoder = nullptr; - _subtitler = new CVidSubtitler(_gameRef); + _subtitler = new VideoSubtitler(_gameRef); } ////////////////////////////////////////////////////////////////////////// VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); -// SAFE_DELETE(_subtitler); + if(_subtitler) { + delete [] _subtitler; + _subtitler = NULL; + } } ////////////////////////////////////////////////////////////////////////// @@ -131,7 +134,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif - _subtitler->LoadSubtitles(_filename.c_str(), subtitleFile.c_str()); + _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str()); _theoraDecoder->loadStream(_file); @@ -217,8 +220,8 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _state = THEORA_STATE_PLAYING; _looping = looping; _playbackType = type; - _subtitler->Update(_theoraDecoder->getFrameCount()); - _subtitler->Display(); + _subtitler->update(_theoraDecoder->getFrameCount()); + _subtitler->display(); _startTime = startTime; _volume = volume; _posX = x; @@ -260,7 +263,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, #if 0 // Stubbed for now as theora isn't seekable if (StartTime) SeekToTime(StartTime); - Update(); + update(); #endif return STATUS_FAILED; } @@ -294,7 +297,7 @@ bool VideoTheoraPlayer::update() { if (_theoraDecoder) { - _subtitler->Update(_theoraDecoder->getCurFrame()); + _subtitler->update(_theoraDecoder->getCurFrame()); if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie %s, hacked for now", _filename.c_str()); @@ -423,7 +426,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) { /* if (m_Subtitler && _gameRef->m_VideoSubtitles) { m_Subtitler->display(); }*/ - _subtitler->Display(); + _subtitler->display(); return res; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 2d79c5404b..698326c29c 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -60,7 +60,7 @@ public: Common::String _filename; BaseSurface *_texture; - CVidSubtitler *_subtitler; + VideoSubtitler *_subtitler; // control methods bool initialize(const Common::String &filename, const Common::String &subtitleFile = Common::String()); -- cgit v1.2.3 From 0475fd1a5c845fe785184bafa42b9302c814b654 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 20:35:46 +0200 Subject: WINTERMUTE: Declare counters as uint to match Array::size() --- engines/wintermute/video/video_subtitler.cpp | 4 ++-- engines/wintermute/video/video_subtitler.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 9d0a066c20..3c607ce20d 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -43,7 +43,7 @@ VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// VideoSubtitler::~VideoSubtitler(void) { - for (int i = 0; i < _subtitles.size(); i++) { + for (uint i = 0; i < _subtitles.size(); i++) { delete _subtitles[i]; } _subtitles.clear(); @@ -56,7 +56,7 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil return false; } - for (int i = 0; i < _subtitles.size(); i++) { + for (uint i = 0; i < _subtitles.size(); i++) { delete _subtitles[i]; } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index e42fbeb505..0025f19e84 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -40,7 +40,7 @@ public: virtual ~VideoSubtitler(void); bool _showSubtitle; - int _currentSubtitle; + uint _currentSubtitle; bool loadSubtitles(const char *filename, const char *subtitleFile); bool display(); bool update(long frame); -- cgit v1.2.3 From 113e837d557d4316efc83b771480199a5cc023c8 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Feb 2014 16:22:21 +0100 Subject: WINTERMUTE: Correctly delete _subtitler (which is not an array) --- engines/wintermute/video/video_theora_player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index a90fb02033..600eae8349 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -92,7 +92,7 @@ void VideoTheoraPlayer::SetDefaults() { VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); if(_subtitler) { - delete [] _subtitler; + delete _subtitler; _subtitler = NULL; } } -- cgit v1.2.3 From 647b7217444fbe88f21a99073cb2377092bef9ab Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Feb 2014 16:38:10 +0100 Subject: WINTERMUTE: Refactor/Reformat VideoSubtitler::update --- engines/wintermute/video/video_subtitler.cpp | 99 ++++++++++++++++++++-------- engines/wintermute/video/video_subtitler.h | 3 +- 2 files changed, 73 insertions(+), 29 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 3c607ce20d..e4c55feb03 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -46,13 +46,14 @@ VideoSubtitler::~VideoSubtitler(void) { for (uint i = 0; i < _subtitles.size(); i++) { delete _subtitles[i]; } + _subtitles.clear(); } ////////////////////////////////////////////////////////////////////////// -bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFile) { - if (!Filename) { +bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) { + if (!filename) { return false; } @@ -72,8 +73,8 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil if (subtitleFile) { newFile = Common::String(subtitleFile); } else { - Common::String path = PathUtil::getDirectoryName(Filename); - Common::String name = PathUtil::getFileNameWithoutExtension(Filename); + Common::String path = PathUtil::getDirectoryName(filename); + Common::String name = PathUtil::getFileNameWithoutExtension(filename); Common::String ext = ".SUB"; newFile = PathUtil::combine(path, name + ext); } @@ -107,10 +108,22 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil textLength = 0; lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); - char *Text = new char[realLength + 1]; + while (pos + lineLength < size && + buffer[pos + lineLength] != '\n' && + buffer[pos + lineLength] != '\0') { + lineLength++; + } + + int realLength; + + if (pos + lineLength >= size) { + realLength = lineLength - 0; + } else { + realLength = lineLength - 1; + } + + char *text = new char[realLength + 1]; char *line = (char *)&buffer[pos]; for (int i = 0; i < realLength; i++) { @@ -134,31 +147,31 @@ bool VideoSubtitler::loadSubtitles(const char *Filename, const char *subtitleFil } else if (tokenPos == 1) { end = atoi(token); } - delete[] token; } else { - Text[textLength] = line[i]; + text[textLength] = line[i]; textLength++; } } else { if (inToken) { tokenLength++; } else { - Text[textLength] = line[i]; - if (Text[textLength] == '|') { - Text[textLength] = '\n'; + text[textLength] = line[i]; + if (text[textLength] == '|') { + text[textLength] = '\n'; } textLength++; } } } - Text[textLength] = '\0'; + + text[textLength] = '\0'; if (start != -1 && textLength > 0 && (start != 1 || end != 1)) { - _subtitles.push_back(new VideoSubtitle(_gameRef, Text, start, end)); + _subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end)); } - delete [] Text; + delete [] text; pos += lineLength + 1; } @@ -184,27 +197,57 @@ bool VideoSubtitler::display() { ////////////////////////////////////////////////////////////////////////// bool VideoSubtitler::update(long frame) { if (frame != _lastSample) { + /* + * If the frame count hasn't advanced the previous state still matches + * the current frame (obviously). + */ + _lastSample = frame; + // Otherwise, we update _lastSample; see above. - // process subtitles _showSubtitle = false; - while (_currentSubtitle < _subtitles.size()) { - int end = _subtitles[_currentSubtitle]->_endFrame; - bool nextFrameOK = (_currentSubtitle < _subtitles.size() - 1 && _subtitles[_currentSubtitle + 1]->_startFrame <= frame); + bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame); + bool hasNext = (_currentSubtitle + 1 < _subtitles.size()); + bool nextStarted = false; + if (hasNext) { + nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame); + } - if (frame > end) { - if (nextFrameOK) { - _currentSubtitle++; - } else { - _showSubtitle = (end == 0); - break; - } + while (_currentSubtitle < _subtitles.size() && + overdue && hasNext && nextStarted) { + /* + * We advance until we get past all overdue subtitles. + * We should exit the cycle when we either reach the first + * subtitle which is not overdue whose subsequent subtitle + * has not started yet (aka the one we must display now or + * the one which WILL be displayed when its time comes) + * and / or when we reach the last one. + */ + + _currentSubtitle++; + + overdue = (frame > _subtitles[_currentSubtitle]->_endFrame); + hasNext = (_currentSubtitle + 1 < _subtitles.size()); + if (hasNext) { + nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame); } else { - _showSubtitle = true; - break; + nextStarted = false; } } + + bool currentValid = (_subtitles[_currentSubtitle]->_endFrame != 0); + /* + * No idea why we do this check, carried over from Mnemonic's code. + * Possibly a workaround for buggy subtitles or some kind of sentinel? :-\ + */ + + bool currentStarted = frame >= _subtitles[_currentSubtitle]->_startFrame; + + if (currentStarted && !overdue && currentValid) { + _showSubtitle = true; + } + } return false; } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 0025f19e84..68964a4084 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -34,7 +34,8 @@ namespace Wintermute { -class VideoSubtitler : public BaseClass { +class VideoSubtitler : + public BaseClass { public: VideoSubtitler(BaseGame *inGame); virtual ~VideoSubtitler(void); -- cgit v1.2.3 From 6d16fdbf4ab9139d368ab7585f9ad1fae5c8a523 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 6 Feb 2014 00:42:22 +0100 Subject: WINTERMUTE: Expand subtitles by string table --- engines/wintermute/video/video_subtitle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 0fab6fb2b7..5be22de592 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/video/video_subtitle.h" - +#include "engines/wintermute/base/base_game.h" namespace Wintermute { ////////////////////////////////////////////////////////////////////////// @@ -40,7 +40,7 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) { _text = new char[strlen(text) + 1]; strcpy(_text, text); - // _gameRef->m_StringTable->Expand(&this->text); + _gameRef->expandStringByStringTable(&_text); _startFrame = startFrame; _endFrame = endFrame; } -- cgit v1.2.3 From f2441da3da9ce4802ce12dc5c815095098e57ee2 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 6 Feb 2014 01:00:19 +0100 Subject: WINTERMUTE: Make sure subtitle files could be found before anything else --- engines/wintermute/video/video_subtitler.cpp | 3 ++- engines/wintermute/video/video_theora_player.cpp | 28 +++++++++++++++--------- engines/wintermute/video/video_theora_player.h | 3 ++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index e4c55feb03..06b8bab1f4 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -177,8 +177,9 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil } delete[] buffer; + // Succeeded loading subtitles! - return false; + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 600eae8349..2af3ac1638 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -86,6 +86,7 @@ void VideoTheoraPlayer::SetDefaults() { _theoraDecoder = nullptr; _subtitler = new VideoSubtitler(_gameRef); + _subtitles = false; } ////////////////////////////////////////////////////////////////////////// @@ -134,7 +135,13 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif - _subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str()); + if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) { + // We have subtitles + _subtitles = true; + } else { + // We couldn't load subtitles... + _subtitles = false; + } _theoraDecoder->loadStream(_file); @@ -220,8 +227,10 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _state = THEORA_STATE_PLAYING; _looping = looping; _playbackType = type; - _subtitler->update(_theoraDecoder->getFrameCount()); - _subtitler->display(); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->update(_theoraDecoder->getFrameCount()); + _subtitler->display(); + } _startTime = startTime; _volume = volume; _posX = x; @@ -296,8 +305,9 @@ bool VideoTheoraPlayer::update() { } if (_theoraDecoder) { - - _subtitler->update(_theoraDecoder->getCurFrame()); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->update(_theoraDecoder->getCurFrame()); + } if (_theoraDecoder->endOfVideo() && _looping) { warning("Should loop movie %s, hacked for now", _filename.c_str()); @@ -422,12 +432,10 @@ bool VideoTheoraPlayer::display(uint32 alpha) { } else { res = STATUS_FAILED; } - // TODO: Add subtitles-support -/* if (m_Subtitler && _gameRef->m_VideoSubtitles) { - m_Subtitler->display(); - }*/ - _subtitler->display(); + if (_subtitler && _subtitles && _gameRef->_subtitles) { + _subtitler->display(); + } return res; } diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 698326c29c..48f75efd20 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -138,9 +138,10 @@ private: bool _playbackStarted; + bool _subtitles; + // helpers void SetDefaults(); - }; } // End of namespace Wintermute -- cgit v1.2.3 From 2eee488e364460772dcb8a85962f6c210810587b Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 20:49:59 +0200 Subject: WINTERMUTE: Do some refactoring over a bunch of attrs in VideoSubtitle Conflicts: engines/wintermute/video/video_subtitler.cpp --- engines/wintermute/video/video_subtitle.cpp | 23 ++++++++++++----------- engines/wintermute/video/video_subtitle.h | 11 +++++++---- engines/wintermute/video/video_subtitler.cpp | 16 ++++++++-------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 5be22de592..bcaa293124 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -32,25 +32,26 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////////// VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { - _text = NULL; _startFrame = _endFrame = 0; } ////////////////////////////////////////////////////////////////////////// -VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame): BaseClass(inGame) { - _text = new char[strlen(text) + 1]; - strcpy(_text, text); - _gameRef->expandStringByStringTable(&_text); +VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) { + _gameRef->expandStringByStringTable(&text); + _text = Common::String(text); _startFrame = startFrame; _endFrame = endFrame; } +long VideoSubtitle::getStartFrame() { + return _startFrame; +} -////////////////////////////////////////////////////////////////////////// -VideoSubtitle::~VideoSubtitle() { - if (_text) { - delete [] _text; - _text = NULL; - } +long VideoSubtitle::getEndFrame() { + return _endFrame; +} + +Common::String VideoSubtitle::getText() { + return _text; } } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 6d629b34d0..5df1348465 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -35,12 +35,15 @@ namespace Wintermute { class VideoSubtitle : public BaseClass { public: + VideoSubtitle(BaseGame *inGame); + VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame); + long getEndFrame(); + long getStartFrame(); + Common::String getText(); +private: long _endFrame; long _startFrame; - char *_text; - VideoSubtitle(BaseGame *inGame); - VideoSubtitle(BaseGame *inGame, char *text, long startFrame, long endFrame); - virtual ~VideoSubtitle(); + Common::String _text; }; } diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 06b8bab1f4..a1294dd3d4 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -186,8 +186,8 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil bool VideoSubtitler::display() { if (_showSubtitle) { BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); - int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->_text, _gameRef->_renderer->getWidth()); - font->drawText((byte *)_subtitles[_currentSubtitle]->_text, + int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth()); + font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(), 0, (_gameRef->_renderer->getHeight() - textHeight - 5), (_gameRef->_renderer->getWidth(), TAL_CENTER)); @@ -208,11 +208,11 @@ bool VideoSubtitler::update(long frame) { _showSubtitle = false; - bool overdue = (frame > _subtitles[_currentSubtitle]->_endFrame); + bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame()); bool hasNext = (_currentSubtitle + 1 < _subtitles.size()); bool nextStarted = false; if (hasNext) { - nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame); + nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame); } while (_currentSubtitle < _subtitles.size() && @@ -228,22 +228,22 @@ bool VideoSubtitler::update(long frame) { _currentSubtitle++; - overdue = (frame > _subtitles[_currentSubtitle]->_endFrame); + overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame()); hasNext = (_currentSubtitle + 1 < _subtitles.size()); if (hasNext) { - nextStarted = (_subtitles[_currentSubtitle + 1]->_startFrame <= frame); + nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame); } else { nextStarted = false; } } - bool currentValid = (_subtitles[_currentSubtitle]->_endFrame != 0); + bool currentValid = (_subtitles[_currentSubtitle]->getEndFrame() != 0); /* * No idea why we do this check, carried over from Mnemonic's code. * Possibly a workaround for buggy subtitles or some kind of sentinel? :-\ */ - bool currentStarted = frame >= _subtitles[_currentSubtitle]->_startFrame; + bool currentStarted = frame >= _subtitles[_currentSubtitle]->getStartFrame(); if (currentStarted && !overdue && currentValid) { _showSubtitle = true; -- cgit v1.2.3 From 8decf3d7424c8cb8eeae99d0aede78c445f18e9f Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 7 Feb 2014 12:14:23 +0100 Subject: WINTERMUTE: Remove ////-style separators from imported subtitle code --- engines/wintermute/video/video_subtitle.cpp | 5 ++--- engines/wintermute/video/video_subtitle.h | 3 ++- engines/wintermute/video/video_subtitler.cpp | 10 +++------- engines/wintermute/video/video_subtitler.h | 3 ++- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index bcaa293124..21fb5ec105 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -30,12 +30,10 @@ #include "engines/wintermute/base/base_game.h" namespace Wintermute { -////////////////////////////////////////////////////////////////////////// VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { _startFrame = _endFrame = 0; } -////////////////////////////////////////////////////////////////////////// VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) { _gameRef->expandStringByStringTable(&text); _text = Common::String(text); @@ -54,4 +52,5 @@ long VideoSubtitle::getEndFrame() { Common::String VideoSubtitle::getText() { return _text; } -} + +} // End of namespace Wintermute diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 5df1348465..3af0d06fa5 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -45,6 +45,7 @@ private: long _startFrame; Common::String _text; }; -} + +} // End of namespace Wintermute #endif diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index a1294dd3d4..b85e179b7c 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -34,14 +34,13 @@ #include "engines/wintermute/base/gfx/base_renderer.h" namespace Wintermute { -////////////////////////////////////////////////////////////////////////// + VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) { _lastSample = -1; _currentSubtitle = 0; _showSubtitle = false; } -////////////////////////////////////////////////////////////////////////// VideoSubtitler::~VideoSubtitler(void) { for (uint i = 0; i < _subtitles.size(); i++) { delete _subtitles[i]; @@ -50,8 +49,6 @@ VideoSubtitler::~VideoSubtitler(void) { _subtitles.clear(); } - -////////////////////////////////////////////////////////////////////////// bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) { if (!filename) { return false; @@ -182,7 +179,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil return true; } -////////////////////////////////////////////////////////////////////////// bool VideoSubtitler::display() { if (_showSubtitle) { BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); @@ -195,7 +191,6 @@ bool VideoSubtitler::display() { return false; } -////////////////////////////////////////////////////////////////////////// bool VideoSubtitler::update(long frame) { if (frame != _lastSample) { /* @@ -252,4 +247,5 @@ bool VideoSubtitler::update(long frame) { } return false; } -} + +} // End of namespace Wintermute diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 68964a4084..977fc10066 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -48,6 +48,7 @@ public: long _lastSample; Common::Array _subtitles; }; -} + +} // End of namespace Wintermute #endif -- cgit v1.2.3 From a78a4d40dd1be6649f83a9411311d9210f1ddeea Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 20:51:55 +0200 Subject: WINTERMUTE: Use Common::String in place of char *text in loadSubtitles --- engines/wintermute/video/video_subtitle.cpp | 9 +++++--- engines/wintermute/video/video_subtitle.h | 2 +- engines/wintermute/video/video_subtitler.cpp | 27 +++++++++--------------- engines/wintermute/video/video_subtitler.h | 2 +- engines/wintermute/video/video_theora_player.cpp | 2 +- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index 21fb5ec105..c9892b59a4 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -34,9 +34,12 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { _startFrame = _endFrame = 0; } -VideoSubtitle::VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame): BaseClass(inGame) { - _gameRef->expandStringByStringTable(&text); - _text = Common::String(text); +VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame): BaseClass(inGame) { + // TODO: Fix expandStringByStringTable instead of this ugly hack + char *tmp = new char[text.size()]; + strcpy(tmp, text.c_str()); + _gameRef->expandStringByStringTable(&tmp); + _text = Common::String(tmp); _startFrame = startFrame; _endFrame = endFrame; } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 3af0d06fa5..03d4b6bc05 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -36,7 +36,7 @@ namespace Wintermute { class VideoSubtitle : public BaseClass { public: VideoSubtitle(BaseGame *inGame); - VideoSubtitle(BaseGame *inGame, char *text, const long &startFrame, const long &endFrame); + VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame); long getEndFrame(); long getStartFrame(); Common::String getText(); diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index b85e179b7c..f1becb00b3 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -49,8 +49,8 @@ VideoSubtitler::~VideoSubtitler(void) { _subtitles.clear(); } -bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFile) { - if (!filename) { +bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common::String &subtitleFile) { + if (filename.size() == 0) { return false; } @@ -67,7 +67,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil Common::String newFile; - if (subtitleFile) { + if (subtitleFile.size() != 0) { newFile = Common::String(subtitleFile); } else { Common::String path = PathUtil::getDirectoryName(filename); @@ -93,7 +93,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil char *tokenStart; int tokenLength; int tokenPos; - int textLength; int pos = 0; int lineLength = 0; @@ -102,7 +101,6 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil start = end = -1; inToken = false; tokenPos = -1; - textLength = 0; lineLength = 0; @@ -120,7 +118,7 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil realLength = lineLength - 1; } - char *text = new char[realLength + 1]; + Common::String text; char *line = (char *)&buffer[pos]; for (int i = 0; i < realLength; i++) { @@ -146,30 +144,25 @@ bool VideoSubtitler::loadSubtitles(const char *filename, const char *subtitleFil } delete[] token; } else { - text[textLength] = line[i]; - textLength++; + text += line[i]; } } else { if (inToken) { tokenLength++; } else { - text[textLength] = line[i]; - if (text[textLength] == '|') { - text[textLength] = '\n'; + if (line[i] == '|') { + text += '\n'; + } else { + text += line[i]; } - textLength++; } } } - text[textLength] = '\0'; - - if (start != -1 && textLength > 0 && (start != 1 || end != 1)) { + if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) { _subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end)); } - delete [] text; - pos += lineLength + 1; } diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 977fc10066..38fdf89508 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -42,7 +42,7 @@ public: bool _showSubtitle; uint _currentSubtitle; - bool loadSubtitles(const char *filename, const char *subtitleFile); + bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); bool display(); bool update(long frame); long _lastSample; diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 2af3ac1638..36d012ccb7 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -135,7 +135,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: #endif - if (_subtitler->loadSubtitles(_filename.c_str(), subtitleFile.c_str())) { + if (_subtitler->loadSubtitles(_filename, subtitleFile)) { // We have subtitles _subtitles = true; } else { -- cgit v1.2.3 From 581aff7f8f0938e71c3c7b8f197269e9a7146f93 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 7 Feb 2014 12:35:50 +0100 Subject: WINTERMUTE: Keep a bunch of attrs private in VideoSubtitler --- engines/wintermute/video/video_subtitler.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 38fdf89508..b369d0bff8 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -45,8 +45,9 @@ public: bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); bool display(); bool update(long frame); - long _lastSample; +private: Common::Array _subtitles; + long _lastSample; }; } // End of namespace Wintermute -- cgit v1.2.3 From afb3ae303461668d4807eaa047a5585a7c870adc Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Fri, 7 Feb 2014 12:40:59 +0100 Subject: WINTERMUTE: Treat edge case - prevents crash if SRT file is blank. --- engines/wintermute/video/video_subtitler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index f1becb00b3..0ade366fb5 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -185,6 +185,12 @@ bool VideoSubtitler::display() { } bool VideoSubtitler::update(long frame) { + + if (_subtitles.size() == 0) { + // Edge case: we have loaded subtitles early on... from a blank file. + return false; + } + if (frame != _lastSample) { /* * If the frame count hasn't advanced the previous state still matches -- cgit v1.2.3 From 7c6f9772d37e3ab7724d20c838883ee8abc2c2b3 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 8 Feb 2014 00:39:59 +0100 Subject: WINTERMUTE: Save frames as uint rather than long It's just as good: at 30 FPS, this allows for 2 ^ 32 / 30 / 60 = 2386093 mins, which is, I guess, a reasonable limit. --- engines/wintermute/video/video_subtitle.cpp | 6 +++--- engines/wintermute/video/video_subtitle.h | 10 +++++----- engines/wintermute/video/video_subtitler.cpp | 6 +++--- engines/wintermute/video/video_subtitler.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index c9892b59a4..eb95f25944 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -34,7 +34,7 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { _startFrame = _endFrame = 0; } -VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame): BaseClass(inGame) { +VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) { // TODO: Fix expandStringByStringTable instead of this ugly hack char *tmp = new char[text.size()]; strcpy(tmp, text.c_str()); @@ -44,11 +44,11 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const _endFrame = endFrame; } -long VideoSubtitle::getStartFrame() { +uint VideoSubtitle::getStartFrame() { return _startFrame; } -long VideoSubtitle::getEndFrame() { +uint VideoSubtitle::getEndFrame() { return _endFrame; } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 03d4b6bc05..4c80c0cdfd 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -36,13 +36,13 @@ namespace Wintermute { class VideoSubtitle : public BaseClass { public: VideoSubtitle(BaseGame *inGame); - VideoSubtitle(BaseGame *inGame, const Common::String &text, const long &startFrame, const long &endFrame); - long getEndFrame(); - long getStartFrame(); + VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); + uint getEndFrame(); + uint getStartFrame(); Common::String getText(); private: - long _endFrame; - long _startFrame; + uint _endFrame; + uint _startFrame; Common::String _text; }; diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 0ade366fb5..8f3032a95a 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -76,7 +76,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: newFile = PathUtil::combine(path, name + ext); } - long size; + int size; Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false); @@ -88,7 +88,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: char *buffer = new char[size]; file->read(buffer, size); - long start, end; + int start, end; bool inToken; char *tokenStart; int tokenLength; @@ -184,7 +184,7 @@ bool VideoSubtitler::display() { return false; } -bool VideoSubtitler::update(long frame) { +bool VideoSubtitler::update(uint frame) { if (_subtitles.size() == 0) { // Edge case: we have loaded subtitles early on... from a blank file. diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index b369d0bff8..2940d69785 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -44,7 +44,7 @@ public: uint _currentSubtitle; bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); bool display(); - bool update(long frame); + bool update(uint frame); private: Common::Array _subtitles; long _lastSample; -- cgit v1.2.3 From 40c5b01aad085f1cf69792f1ef945f54d5e844e1 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 8 Feb 2014 13:53:14 +0100 Subject: WINTERMUTE: Preserve const when handing chars over to drawText --- engines/wintermute/video/video_subtitler.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 8f3032a95a..a8ce86853a 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -64,7 +64,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: _currentSubtitle = 0; _showSubtitle = false; - Common::String newFile; if (subtitleFile.size() != 0) { @@ -174,18 +173,28 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: bool VideoSubtitler::display() { if (_showSubtitle) { - BaseFont *font = _gameRef->getVideoFont() ? _gameRef->getVideoFont() : _gameRef->getSystemFont(); - int textHeight = font->getTextHeight((byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth()); - font->drawText((byte *)_subtitles[_currentSubtitle]->getText().c_str(), + + BaseFont *font; + + if (_gameRef->getVideoFont() == nullptr) { + font = _gameRef->getSystemFont(); + } else { + font = _gameRef->getVideoFont(); + } + + int textHeight = font->getTextHeight( + (const byte *)_subtitles[_currentSubtitle]->getText().c_str(), + _gameRef->_renderer->getWidth()); + font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(), 0, (_gameRef->_renderer->getHeight() - textHeight - 5), - (_gameRef->_renderer->getWidth(), TAL_CENTER)); + (_gameRef->_renderer->getWidth()), + TAL_CENTER); } return false; } bool VideoSubtitler::update(uint frame) { - if (_subtitles.size() == 0) { // Edge case: we have loaded subtitles early on... from a blank file. return false; @@ -242,7 +251,6 @@ bool VideoSubtitler::update(uint frame) { if (currentStarted && !overdue && currentValid) { _showSubtitle = true; } - } return false; } -- cgit v1.2.3 From 2acb2f558c4ee018ad30ce6fb6e8412d175b6c46 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 8 Feb 2014 13:59:37 +0100 Subject: WINTERMUTE: Add clarification comment in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index a8ce86853a..cc46ddf526 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -66,6 +66,13 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: Common::String newFile; + /* + * Okay, the expected behaviour is this: either we are + * provided with a subtitle file to use by the script when + * calling PlayTheora(), or we try to autodetect a suitable + * one which, for /some/path/movie/ogg is to be called + * /some/path/movie.sub + */ if (subtitleFile.size() != 0) { newFile = Common::String(subtitleFile); } else { -- cgit v1.2.3 From a4d5d1458102959bdc26fc73184e2cfc5f918894 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:15:07 +0200 Subject: WINTERMUTE: Turn display() and update() into void functions. No idea why they were bools in the first place. --- engines/wintermute/video/video_subtitler.cpp | 9 ++++----- engines/wintermute/video/video_subtitler.h | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index cc46ddf526..05c7b6c563 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -178,7 +178,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: return true; } -bool VideoSubtitler::display() { +void VideoSubtitler::display() { if (_showSubtitle) { BaseFont *font; @@ -192,19 +192,19 @@ bool VideoSubtitler::display() { int textHeight = font->getTextHeight( (const byte *)_subtitles[_currentSubtitle]->getText().c_str(), _gameRef->_renderer->getWidth()); + font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(), 0, (_gameRef->_renderer->getHeight() - textHeight - 5), (_gameRef->_renderer->getWidth()), TAL_CENTER); } - return false; } -bool VideoSubtitler::update(uint frame) { +void VideoSubtitler::update(uint frame) { if (_subtitles.size() == 0) { // Edge case: we have loaded subtitles early on... from a blank file. - return false; + return; } if (frame != _lastSample) { @@ -259,7 +259,6 @@ bool VideoSubtitler::update(uint frame) { _showSubtitle = true; } } - return false; } } // End of namespace Wintermute diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 2940d69785..8c57fd290f 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -43,8 +43,8 @@ public: bool _showSubtitle; uint _currentSubtitle; bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); - bool display(); - bool update(uint frame); + void display(); + void update(uint frame); private: Common::Array _subtitles; long _lastSample; -- cgit v1.2.3 From 7b4084b7e0273b37f1fb0583431540d977c424ae Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 18 Feb 2014 22:10:06 +0100 Subject: WINTERMUTE: s/uint32 _lastSample/long _lastSample/ --- engines/wintermute/video/video_subtitler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 8c57fd290f..3f62c05134 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -47,7 +47,7 @@ public: void update(uint frame); private: Common::Array _subtitles; - long _lastSample; + uint32 _lastSample; }; } // End of namespace Wintermute -- cgit v1.2.3 From dd820a7a1e9adcb7c46d2cb2fe178c895e40b8c3 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 18 Feb 2014 22:23:42 +0100 Subject: WINTERMUTE: Turn a bunch of uint into uint32 in VideoSubtitle --- engines/wintermute/video/video_subtitle.cpp | 4 ++-- engines/wintermute/video/video_subtitle.h | 8 ++++---- engines/wintermute/video/video_subtitler.cpp | 2 +- engines/wintermute/video/video_subtitler.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp index eb95f25944..b02a3ec50f 100644 --- a/engines/wintermute/video/video_subtitle.cpp +++ b/engines/wintermute/video/video_subtitle.cpp @@ -44,11 +44,11 @@ VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const _endFrame = endFrame; } -uint VideoSubtitle::getStartFrame() { +uint32 VideoSubtitle::getStartFrame() { return _startFrame; } -uint VideoSubtitle::getEndFrame() { +uint32 VideoSubtitle::getEndFrame() { return _endFrame; } diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h index 4c80c0cdfd..fb80a58a72 100644 --- a/engines/wintermute/video/video_subtitle.h +++ b/engines/wintermute/video/video_subtitle.h @@ -37,12 +37,12 @@ class VideoSubtitle : public BaseClass { public: VideoSubtitle(BaseGame *inGame); VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); - uint getEndFrame(); - uint getStartFrame(); + uint32 getEndFrame(); + uint32 getStartFrame(); Common::String getText(); private: - uint _endFrame; - uint _startFrame; + uint32 _endFrame; + uint32 _startFrame; Common::String _text; }; diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 05c7b6c563..c8acbeb98b 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -201,7 +201,7 @@ void VideoSubtitler::display() { } } -void VideoSubtitler::update(uint frame) { +void VideoSubtitler::update(uint32 frame) { if (_subtitles.size() == 0) { // Edge case: we have loaded subtitles early on... from a blank file. return; diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 3f62c05134..655b1a5969 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -41,10 +41,10 @@ public: virtual ~VideoSubtitler(void); bool _showSubtitle; - uint _currentSubtitle; + uint32 _currentSubtitle; bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); void display(); - void update(uint frame); + void update(uint32 frame); private: Common::Array _subtitles; uint32 _lastSample; -- cgit v1.2.3 From 388fbdb6eb8df910c2fff2dc34954f34759c5b16 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:16:04 +0200 Subject: WINTERMUTE: Rename VideoSubtitle to SubtitleCard --- engines/wintermute/module.mk | 2 +- engines/wintermute/video/subtitle_card.cpp | 59 ++++++++++++++++++++++++++++ engines/wintermute/video/subtitle_card.h | 51 ++++++++++++++++++++++++ engines/wintermute/video/video_subtitle.cpp | 59 ---------------------------- engines/wintermute/video/video_subtitle.h | 51 ------------------------ engines/wintermute/video/video_subtitler.cpp | 2 +- engines/wintermute/video/video_subtitler.h | 4 +- 7 files changed, 114 insertions(+), 114 deletions(-) create mode 100644 engines/wintermute/video/subtitle_card.cpp create mode 100644 engines/wintermute/video/subtitle_card.h delete mode 100644 engines/wintermute/video/video_subtitle.cpp delete mode 100644 engines/wintermute/video/video_subtitle.h diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk index b4845b0552..4c95314a02 100644 --- a/engines/wintermute/module.mk +++ b/engines/wintermute/module.mk @@ -108,8 +108,8 @@ MODULE_OBJS := \ utils/path_util.o \ utils/string_util.o \ utils/utils.o \ + video/subtitle_card.o \ video/video_player.o \ - video/video_subtitle.o \ video/video_subtitler.o \ video/video_theora_player.o \ debugger.o \ diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp new file mode 100644 index 0000000000..971b2c019c --- /dev/null +++ b/engines/wintermute/video/subtitle_card.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/video/subtitle_card.h" +#include "engines/wintermute/base/base_game.h" +namespace Wintermute { + +SubtitleCard::SubtitleCard(BaseGame *inGame): BaseClass(inGame) { + _startFrame = _endFrame = 0; +} + +SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) { + // TODO: Fix expandStringByStringTable instead of this ugly hack + char *tmp = new char[text.size()]; + strcpy(tmp, text.c_str()); + _gameRef->expandStringByStringTable(&tmp); + _text = Common::String(tmp); + _startFrame = startFrame; + _endFrame = endFrame; +} + +uint32 SubtitleCard::getStartFrame() { + return _startFrame; +} + +uint32 SubtitleCard::getEndFrame() { + return _endFrame; +} + +Common::String SubtitleCard::getText() { + return _text; +} + +} // End of namespace Wintermute diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h new file mode 100644 index 0000000000..5390d64fcb --- /dev/null +++ b/engines/wintermute/video/subtitle_card.h @@ -0,0 +1,51 @@ +/* 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. + * + */ + +/* + * This file is based on Wintermute Engine + * http://dead-code.org/redir.php?target=wme + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SUBTITLECARD_H +#define WINTERMUTE_SUBTITLECARD_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class SubtitleCard : public BaseClass { +public: + SubtitleCard(BaseGame *inGame); + SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); + uint32 getEndFrame(); + uint32 getStartFrame(); + Common::String getText(); +private: + uint32 _endFrame; + uint32 _startFrame; + Common::String _text; +}; + +} // End of namespace Wintermute + +#endif diff --git a/engines/wintermute/video/video_subtitle.cpp b/engines/wintermute/video/video_subtitle.cpp deleted file mode 100644 index b02a3ec50f..0000000000 --- a/engines/wintermute/video/video_subtitle.cpp +++ /dev/null @@ -1,59 +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. - * - */ - -/* - * This file is based on Wintermute Engine - * http://dead-code.org/redir.php?target=wme - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/video/video_subtitle.h" -#include "engines/wintermute/base/base_game.h" -namespace Wintermute { - -VideoSubtitle::VideoSubtitle(BaseGame *inGame): BaseClass(inGame) { - _startFrame = _endFrame = 0; -} - -VideoSubtitle::VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) { - // TODO: Fix expandStringByStringTable instead of this ugly hack - char *tmp = new char[text.size()]; - strcpy(tmp, text.c_str()); - _gameRef->expandStringByStringTable(&tmp); - _text = Common::String(tmp); - _startFrame = startFrame; - _endFrame = endFrame; -} - -uint32 VideoSubtitle::getStartFrame() { - return _startFrame; -} - -uint32 VideoSubtitle::getEndFrame() { - return _endFrame; -} - -Common::String VideoSubtitle::getText() { - return _text; -} - -} // End of namespace Wintermute diff --git a/engines/wintermute/video/video_subtitle.h b/engines/wintermute/video/video_subtitle.h deleted file mode 100644 index fb80a58a72..0000000000 --- a/engines/wintermute/video/video_subtitle.h +++ /dev/null @@ -1,51 +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. - * - */ - -/* - * This file is based on Wintermute Engine - * http://dead-code.org/redir.php?target=wme - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_VIDSUBTITLE_H -#define WINTERMUTE_VIDSUBTITLE_H - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class VideoSubtitle : public BaseClass { -public: - VideoSubtitle(BaseGame *inGame); - VideoSubtitle(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); - uint32 getEndFrame(); - uint32 getStartFrame(); - Common::String getText(); -private: - uint32 _endFrame; - uint32 _startFrame; - Common::String _text; -}; - -} // End of namespace Wintermute - -#endif diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index c8acbeb98b..c57a70ec3b 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -166,7 +166,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: } if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) { - _subtitles.push_back(new VideoSubtitle(_gameRef, text, start, end)); + _subtitles.push_back(new SubtitleCard(_gameRef, text, start, end)); } pos += lineLength + 1; diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 655b1a5969..32e4368daf 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -30,7 +30,7 @@ #define WINTERMUTE_VIDSUBTITLER_H #include "engines/wintermute/base/base.h" -#include "engines/wintermute/video/video_subtitle.h" +#include "engines/wintermute/video/subtitle_card.h" namespace Wintermute { @@ -46,7 +46,7 @@ public: void display(); void update(uint32 frame); private: - Common::Array _subtitles; + Common::Array _subtitles; uint32 _lastSample; }; -- cgit v1.2.3 From 1a571d9611ea21040f7b5ff971fcd7b70580a025 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 20 Feb 2014 19:50:51 +0100 Subject: WINTERMUTE: Avoid doing check before delete (deleting 0-pointer is safe) --- engines/wintermute/video/video_theora_player.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 36d012ccb7..d16b2edb8c 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -92,10 +92,7 @@ void VideoTheoraPlayer::SetDefaults() { ////////////////////////////////////////////////////////////////////////// VideoTheoraPlayer::~VideoTheoraPlayer(void) { cleanup(); - if(_subtitler) { - delete _subtitler; - _subtitler = NULL; - } + delete _subtitler; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 4742acf9395d069d8e9ee1752c3f8f09c1034b08 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Thu, 20 Feb 2014 20:00:14 +0100 Subject: WINTERMUTE: Rename VideoTheoraPlayer->_subtitles to _foundSubtitles for clarity --- engines/wintermute/video/video_theora_player.cpp | 12 ++++++------ engines/wintermute/video/video_theora_player.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index d16b2edb8c..99fce7b6ad 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -86,7 +86,7 @@ void VideoTheoraPlayer::SetDefaults() { _theoraDecoder = nullptr; _subtitler = new VideoSubtitler(_gameRef); - _subtitles = false; + _foundSubtitles = false; } ////////////////////////////////////////////////////////////////////////// @@ -134,10 +134,10 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: if (_subtitler->loadSubtitles(_filename, subtitleFile)) { // We have subtitles - _subtitles = true; + _foundSubtitles = true; } else { // We couldn't load subtitles... - _subtitles = false; + _foundSubtitles = false; } _theoraDecoder->loadStream(_file); @@ -224,7 +224,7 @@ bool VideoTheoraPlayer::play(TVideoPlayback type, int x, int y, bool freezeGame, _state = THEORA_STATE_PLAYING; _looping = looping; _playbackType = type; - if (_subtitler && _subtitles && _gameRef->_subtitles) { + if (_subtitler && _foundSubtitles && _gameRef->_subtitles) { _subtitler->update(_theoraDecoder->getFrameCount()); _subtitler->display(); } @@ -302,7 +302,7 @@ bool VideoTheoraPlayer::update() { } if (_theoraDecoder) { - if (_subtitler && _subtitles && _gameRef->_subtitles) { + if (_subtitler && _foundSubtitles && _gameRef->_subtitles) { _subtitler->update(_theoraDecoder->getCurFrame()); } @@ -430,7 +430,7 @@ bool VideoTheoraPlayer::display(uint32 alpha) { res = STATUS_FAILED; } - if (_subtitler && _subtitles && _gameRef->_subtitles) { + if (_subtitler && _foundSubtitles && _gameRef->_subtitles) { _subtitler->display(); } return res; diff --git a/engines/wintermute/video/video_theora_player.h b/engines/wintermute/video/video_theora_player.h index 48f75efd20..0b9b3d487a 100644 --- a/engines/wintermute/video/video_theora_player.h +++ b/engines/wintermute/video/video_theora_player.h @@ -138,7 +138,7 @@ private: bool _playbackStarted; - bool _subtitles; + bool _foundSubtitles; // helpers void SetDefaults(); -- cgit v1.2.3 From 599390a5ad5b0df7a480230a97b51b9ccb41a177 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 9 Sep 2014 19:26:02 +0200 Subject: WINTERMUTE: Lose unnecessary if() in VideoTheoraPlayer --- engines/wintermute/video/video_theora_player.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/engines/wintermute/video/video_theora_player.cpp b/engines/wintermute/video/video_theora_player.cpp index 99fce7b6ad..22c235c848 100644 --- a/engines/wintermute/video/video_theora_player.cpp +++ b/engines/wintermute/video/video_theora_player.cpp @@ -131,14 +131,7 @@ bool VideoTheoraPlayer::initialize(const Common::String &filename, const Common: return STATUS_FAILED; #endif - - if (_subtitler->loadSubtitles(_filename, subtitleFile)) { - // We have subtitles - _foundSubtitles = true; - } else { - // We couldn't load subtitles... - _foundSubtitles = false; - } + _foundSubtitles = _subtitler->loadSubtitles(_filename, subtitleFile); _theoraDecoder->loadStream(_file); -- cgit v1.2.3 From f1ae8e6e8d89f53e8fcd6ffb7eb3faf1e5ab8993 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 22 Feb 2014 12:10:27 +0100 Subject: WINTERMUTE: Introduce BaseGame->expandStringByStringTable(&Common::String) --- engines/wintermute/base/base_game.cpp | 5 +++++ engines/wintermute/base/base_game.h | 1 + engines/wintermute/base/base_game_settings.cpp | 5 +++++ engines/wintermute/base/base_game_settings.h | 1 + engines/wintermute/base/base_string_table.cpp | 9 +++++++++ engines/wintermute/base/base_string_table.h | 1 + 6 files changed, 22 insertions(+) diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8df39c825a..668053bb3a 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3896,6 +3896,11 @@ void BaseGame::expandStringByStringTable(char **str) const { _settings->expandStringByStringTable(str); } +////////////////////////////////////////////////////////////////////////// +void BaseGame::expandStringByStringTable(Common::String &str) const { + _settings->expandStringByStringTable(str); +} + char *BaseGame::getKeyFromStringTable(const char *str) const { return _settings->getKeyFromStringTable(str); } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index f62416ee1b..e535cc9618 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -141,6 +141,7 @@ public: // String Table void expandStringByStringTable(char **str) const; + void expandStringByStringTable(Common::String &str) const; char *getKeyFromStringTable(const char *str) const; void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp index 61c5894be3..996bada997 100644 --- a/engines/wintermute/base/base_game_settings.cpp +++ b/engines/wintermute/base/base_game_settings.cpp @@ -215,6 +215,11 @@ void BaseGameSettings::expandStringByStringTable(char **str) const { _stringTable->expand(str); } +////////////////////////////////////////////////////////////////////////// +void BaseGameSettings::expandStringByStringTable(Common::String &str) const { + _stringTable->expand(str); +} + char *BaseGameSettings::getKeyFromStringTable(const char *str) const { return _stringTable->getKey(str); } diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h index 2059cb075e..15afb06450 100644 --- a/engines/wintermute/base/base_game_settings.h +++ b/engines/wintermute/base/base_game_settings.h @@ -46,6 +46,7 @@ public: bool loadSettings(const char *filename); bool loadStringTable(const char *filename, bool clearOld); void expandStringByStringTable(char **str) const; + void expandStringByStringTable(Common::String &str) const; char *getKeyFromStringTable(const char *str) const; bool persist(BasePersistenceManager *persistMgr); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 89407a7b0e..8a9edbe198 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -147,6 +147,15 @@ void BaseStringTable::expand(char **str) const { } } +////////////////////////////////////////////////////////////////////////// +void BaseStringTable::expand(Common::String &str) const { + char *tmp = new char[str.size()]; + strcpy(tmp, str.c_str()); + expand(&tmp); + str = tmp; + delete tmp; +} + ////////////////////////////////////////////////////////////////////////// const char *BaseStringTable::expandStatic(const char *string) const { diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index cdcf11917d..cfa3eeb226 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -41,6 +41,7 @@ class BaseStringTable : public BaseClass { public: bool loadFile(const char *filename, bool deleteAll = true); void expand(char **str) const; + void expand(Common::String &str) const; const char *expandStatic(const char *string) const; bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); -- cgit v1.2.3 From 5f25cf1bd731ed2bae852610c74a9917942ab883 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 22 Feb 2014 11:18:05 +0100 Subject: WINTERMUTE: Don't bother inheriting BaseGame in SubtitleCard --- engines/wintermute/video/subtitle_card.cpp | 7 +++++-- engines/wintermute/video/subtitle_card.h | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index 971b2c019c..c0ad8cc1d7 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -28,16 +28,19 @@ #include "engines/wintermute/video/subtitle_card.h" #include "engines/wintermute/base/base_game.h" + namespace Wintermute { -SubtitleCard::SubtitleCard(BaseGame *inGame): BaseClass(inGame) { +SubtitleCard::SubtitleCard(BaseGame *inGame) { + _gameRef = inGame; _startFrame = _endFrame = 0; } -SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame): BaseClass(inGame) { +SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) { // TODO: Fix expandStringByStringTable instead of this ugly hack char *tmp = new char[text.size()]; strcpy(tmp, text.c_str()); + _gameRef = inGame; _gameRef->expandStringByStringTable(&tmp); _text = Common::String(tmp); _startFrame = startFrame; diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h index 5390d64fcb..94543d93fa 100644 --- a/engines/wintermute/video/subtitle_card.h +++ b/engines/wintermute/video/subtitle_card.h @@ -29,11 +29,13 @@ #ifndef WINTERMUTE_SUBTITLECARD_H #define WINTERMUTE_SUBTITLECARD_H -#include "engines/wintermute/base/base.h" +#include "common/str.h" namespace Wintermute { -class SubtitleCard : public BaseClass { +class BaseGame; + +class SubtitleCard { public: SubtitleCard(BaseGame *inGame); SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); @@ -41,6 +43,7 @@ public: uint32 getStartFrame(); Common::String getText(); private: + BaseGame* _gameRef; uint32 _endFrame; uint32 _startFrame; Common::String _text; -- cgit v1.2.3 From 856e281bf17a7adca88ded8bc93fd2e892bfa973 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 22 Feb 2014 11:35:34 +0100 Subject: WINTERMUTE: Remove useless constructor from SubtitleCard. --- engines/wintermute/video/subtitle_card.cpp | 4 ---- engines/wintermute/video/subtitle_card.h | 1 - 2 files changed, 5 deletions(-) diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index c0ad8cc1d7..a0a88b12be 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -31,10 +31,6 @@ namespace Wintermute { -SubtitleCard::SubtitleCard(BaseGame *inGame) { - _gameRef = inGame; - _startFrame = _endFrame = 0; -} SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) { // TODO: Fix expandStringByStringTable instead of this ugly hack diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h index 94543d93fa..6f2e47fe2b 100644 --- a/engines/wintermute/video/subtitle_card.h +++ b/engines/wintermute/video/subtitle_card.h @@ -37,7 +37,6 @@ class BaseGame; class SubtitleCard { public: - SubtitleCard(BaseGame *inGame); SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); uint32 getEndFrame(); uint32 getStartFrame(); -- cgit v1.2.3 From 578edde66fc87eb1d4f630cbd1a9e402172440fa Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 22 Feb 2014 11:37:56 +0100 Subject: WINTERMUTE: Const'fy members of class SubtitleCard --- engines/wintermute/video/subtitle_card.cpp | 17 +++++++++-------- engines/wintermute/video/subtitle_card.h | 12 ++++++------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index a0a88b12be..fb2ac06a84 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -31,27 +31,28 @@ namespace Wintermute { - -SubtitleCard::SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame) { +SubtitleCard::SubtitleCard(BaseGame *inGame, + const Common::String &text, + const uint &startFrame, + const uint &endFrame) : _gameRef(inGame), + _startFrame(startFrame), + _endFrame(endFrame) { // TODO: Fix expandStringByStringTable instead of this ugly hack char *tmp = new char[text.size()]; strcpy(tmp, text.c_str()); - _gameRef = inGame; _gameRef->expandStringByStringTable(&tmp); _text = Common::String(tmp); - _startFrame = startFrame; - _endFrame = endFrame; } -uint32 SubtitleCard::getStartFrame() { +uint32 SubtitleCard::getStartFrame() const { return _startFrame; } -uint32 SubtitleCard::getEndFrame() { +uint32 SubtitleCard::getEndFrame() const { return _endFrame; } -Common::String SubtitleCard::getText() { +Common::String SubtitleCard::getText() const { return _text; } diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h index 6f2e47fe2b..7b372c76ad 100644 --- a/engines/wintermute/video/subtitle_card.h +++ b/engines/wintermute/video/subtitle_card.h @@ -38,13 +38,13 @@ class BaseGame; class SubtitleCard { public: SubtitleCard(BaseGame *inGame, const Common::String &text, const uint &startFrame, const uint &endFrame); - uint32 getEndFrame(); - uint32 getStartFrame(); - Common::String getText(); + uint32 getEndFrame() const; + uint32 getStartFrame() const; + Common::String getText() const; private: - BaseGame* _gameRef; - uint32 _endFrame; - uint32 _startFrame; + const BaseGame* _gameRef; + const uint32 _endFrame; + const uint32 _startFrame; Common::String _text; }; -- cgit v1.2.3 From f525514da576be7f5c645c38ff121b764378349e Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sat, 22 Feb 2014 12:10:51 +0100 Subject: WINTERMUTE: Use BaseGame->expandStringByStringTable(&Common::String) in SubtitleCard --- engines/wintermute/video/subtitle_card.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index fb2ac06a84..28fb6544f2 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -31,17 +31,14 @@ namespace Wintermute { -SubtitleCard::SubtitleCard(BaseGame *inGame, - const Common::String &text, - const uint &startFrame, - const uint &endFrame) : _gameRef(inGame), - _startFrame(startFrame), +SubtitleCard::SubtitleCard(BaseGame *inGame, + const Common::String &text, + const uint &startFrame, + const uint &endFrame) : _gameRef(inGame), + _startFrame(startFrame), _endFrame(endFrame) { - // TODO: Fix expandStringByStringTable instead of this ugly hack - char *tmp = new char[text.size()]; - strcpy(tmp, text.c_str()); - _gameRef->expandStringByStringTable(&tmp); - _text = Common::String(tmp); + _text = text; + _gameRef->expandStringByStringTable(_text); } uint32 SubtitleCard::getStartFrame() const { -- cgit v1.2.3 From ebb48a1704b236d986539dbc716aae2d73921bb7 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Mon, 8 Sep 2014 16:27:40 +0200 Subject: WINTERMUTE: s/delete array/delete[] array/ --- engines/wintermute/base/base_string_table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8a9edbe198..bcdd7cb861 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -153,7 +153,7 @@ void BaseStringTable::expand(Common::String &str) const { strcpy(tmp, str.c_str()); expand(&tmp); str = tmp; - delete tmp; + delete[] tmp; } -- cgit v1.2.3 From c6930d9a64d6d61ece2f0b531ad93459d2730150 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 9 Sep 2014 15:30:47 +0200 Subject: WINTERMUTE: Use int32 for _lastSample in VideoSubtitler We are thus making room for the sentinel == -1 --- engines/wintermute/video/video_subtitler.cpp | 2 +- engines/wintermute/video/video_subtitler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index c57a70ec3b..2117832fad 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -207,7 +207,7 @@ void VideoSubtitler::update(uint32 frame) { return; } - if (frame != _lastSample) { + if ((int32)frame != _lastSample) { /* * If the frame count hasn't advanced the previous state still matches * the current frame (obviously). diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index 32e4368daf..f2dcdf161e 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -47,7 +47,7 @@ public: void update(uint32 frame); private: Common::Array _subtitles; - uint32 _lastSample; + int32 _lastSample; }; } // End of namespace Wintermute -- cgit v1.2.3 From 2fc69d770c7f80b0f6027dd66a8cf4be401b2853 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 9 Sep 2014 15:33:12 +0200 Subject: WINTERMUTE: Initialize tokenSomething vars in VideoSubtitler MSVC complains otherwise. --- engines/wintermute/video/video_subtitler.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 2117832fad..2bd728c797 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -96,9 +96,9 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: int start, end; bool inToken; - char *tokenStart; - int tokenLength; - int tokenPos; + char *tokenStart = 0; + int tokenLength = 0; + int tokenPos = 0; int pos = 0; int lineLength = 0; -- cgit v1.2.3 From d5ed8c29f1f97519bd72aec8585edf04ac46181f Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:18:00 +0200 Subject: WINTERMUTE: Turn _subtitles into Common::Array in VideoSubtitler This necessarily loses const in SubtitleCard's attributes --- engines/wintermute/video/subtitle_card.cpp | 10 ++++---- engines/wintermute/video/subtitle_card.h | 6 ++--- engines/wintermute/video/video_subtitler.cpp | 35 +++++++++++----------------- engines/wintermute/video/video_subtitler.h | 2 +- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/engines/wintermute/video/subtitle_card.cpp b/engines/wintermute/video/subtitle_card.cpp index 28fb6544f2..5d882502fd 100644 --- a/engines/wintermute/video/subtitle_card.cpp +++ b/engines/wintermute/video/subtitle_card.cpp @@ -32,11 +32,11 @@ namespace Wintermute { SubtitleCard::SubtitleCard(BaseGame *inGame, - const Common::String &text, - const uint &startFrame, - const uint &endFrame) : _gameRef(inGame), - _startFrame(startFrame), - _endFrame(endFrame) { + const Common::String &text, + const uint &startFrame, + const uint &endFrame) : _gameRef(inGame), + _startFrame(startFrame), + _endFrame(endFrame) { _text = text; _gameRef->expandStringByStringTable(_text); } diff --git a/engines/wintermute/video/subtitle_card.h b/engines/wintermute/video/subtitle_card.h index 7b372c76ad..629df77287 100644 --- a/engines/wintermute/video/subtitle_card.h +++ b/engines/wintermute/video/subtitle_card.h @@ -42,9 +42,9 @@ public: uint32 getStartFrame() const; Common::String getText() const; private: - const BaseGame* _gameRef; - const uint32 _endFrame; - const uint32 _startFrame; + BaseGame *_gameRef; + uint32 _endFrame; + uint32 _startFrame; Common::String _text; }; diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 2bd728c797..2123991c03 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -42,10 +42,6 @@ VideoSubtitler::VideoSubtitler(BaseGame *inGame): BaseClass(inGame) { } VideoSubtitler::~VideoSubtitler(void) { - for (uint i = 0; i < _subtitles.size(); i++) { - delete _subtitles[i]; - } - _subtitles.clear(); } @@ -54,10 +50,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: return false; } - for (uint i = 0; i < _subtitles.size(); i++) { - delete _subtitles[i]; - } - _subtitles.clear(); _lastSample = -1; @@ -166,7 +158,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: } if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) { - _subtitles.push_back(new SubtitleCard(_gameRef, text, start, end)); + _subtitles.push_back(SubtitleCard(_gameRef, text, start, end)); } pos += lineLength + 1; @@ -190,14 +182,15 @@ void VideoSubtitler::display() { } int textHeight = font->getTextHeight( - (const byte *)_subtitles[_currentSubtitle]->getText().c_str(), + (const byte *)_subtitles[_currentSubtitle].getText().c_str(), _gameRef->_renderer->getWidth()); - font->drawText((const byte *)_subtitles[_currentSubtitle]->getText().c_str(), - 0, - (_gameRef->_renderer->getHeight() - textHeight - 5), - (_gameRef->_renderer->getWidth()), - TAL_CENTER); + font->drawText( + (const byte *)_subtitles[_currentSubtitle].getText().c_str(), + 0, + (_gameRef->_renderer->getHeight() - textHeight - 5), + (_gameRef->_renderer->getWidth()), + TAL_CENTER); } } @@ -218,11 +211,11 @@ void VideoSubtitler::update(uint32 frame) { _showSubtitle = false; - bool overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame()); + bool overdue = (frame > _subtitles[_currentSubtitle].getEndFrame()); bool hasNext = (_currentSubtitle + 1 < _subtitles.size()); bool nextStarted = false; if (hasNext) { - nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame); + nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame); } while (_currentSubtitle < _subtitles.size() && @@ -238,22 +231,22 @@ void VideoSubtitler::update(uint32 frame) { _currentSubtitle++; - overdue = (frame > _subtitles[_currentSubtitle]->getEndFrame()); + overdue = (frame > _subtitles[_currentSubtitle].getEndFrame()); hasNext = (_currentSubtitle + 1 < _subtitles.size()); if (hasNext) { - nextStarted = (_subtitles[_currentSubtitle + 1]->getStartFrame() <= frame); + nextStarted = (_subtitles[_currentSubtitle + 1].getStartFrame() <= frame); } else { nextStarted = false; } } - bool currentValid = (_subtitles[_currentSubtitle]->getEndFrame() != 0); + bool currentValid = (_subtitles[_currentSubtitle].getEndFrame() != 0); /* * No idea why we do this check, carried over from Mnemonic's code. * Possibly a workaround for buggy subtitles or some kind of sentinel? :-\ */ - bool currentStarted = frame >= _subtitles[_currentSubtitle]->getStartFrame(); + bool currentStarted = frame >= _subtitles[_currentSubtitle].getStartFrame(); if (currentStarted && !overdue && currentValid) { _showSubtitle = true; diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index f2dcdf161e..c1730c84fd 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -46,7 +46,7 @@ public: void display(); void update(uint32 frame); private: - Common::Array _subtitles; + Common::Array _subtitles; int32 _lastSample; }; -- cgit v1.2.3 From 3cef639f911264547b08428110e33a3d5a595fee Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Tue, 9 Sep 2014 17:33:21 +0200 Subject: WINTERMUTE: new char[str.size()+1] in BaseStringTable::expand This makes room for the EOS char. --- engines/wintermute/base/base_string_table.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index bcdd7cb861..4c750ebc93 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -149,7 +149,7 @@ void BaseStringTable::expand(char **str) const { ////////////////////////////////////////////////////////////////////////// void BaseStringTable::expand(Common::String &str) const { - char *tmp = new char[str.size()]; + char *tmp = new char[str.size()+1]; strcpy(tmp, str.c_str()); expand(&tmp); str = tmp; -- cgit v1.2.3 From e9b722278e5c893bd488bdb7d430598ba711d5ee Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:22:28 +0200 Subject: WINTERMUTE: Declare and init size in one place in VideoSubtitler --- engines/wintermute/video/video_subtitler.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 2123991c03..ed4677fffd 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -74,16 +74,15 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: newFile = PathUtil::combine(path, name + ext); } - int size; - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(newFile, true, false); if (file == nullptr) { return false; // no subtitles } - size = file->size(); + int size = file->size(); char *buffer = new char[size]; + file->read(buffer, size); int start, end; -- cgit v1.2.3 From a4b9bc58775d6a0f2e6fbce8ac2eff872892830e Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:32:34 +0200 Subject: WINTERMUTE: Rename a bunch of variabiles in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index ed4677fffd..f540fddb5f 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -80,10 +80,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: return false; // no subtitles } - int size = file->size(); - char *buffer = new char[size]; + int fileSize = file->size(); + char *buffer = new char[fileSize]; - file->read(buffer, size); + file->read(buffer, fileSize); int start, end; bool inToken; @@ -93,42 +93,42 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: int pos = 0; int lineLength = 0; - - while (pos < size) { + while (pos < fileSize) { start = end = -1; inToken = false; tokenPos = -1; lineLength = 0; - while (pos + lineLength < size && - buffer[pos + lineLength] != '\n' && - buffer[pos + lineLength] != '\0') { + while (pos + lineLength < fileSize && + buffer[pos + lineLength] != '\n' && + buffer[pos + lineLength] != '\0') { + // Measure the line until we hit EOL, EOS or just hit the boundary lineLength++; } int realLength; - if (pos + lineLength >= size) { + if (pos + lineLength >= fileSize) { realLength = lineLength - 0; } else { realLength = lineLength - 1; } - Common::String text; - char *line = (char *)&buffer[pos]; + Common::String cardText; + char *fileLine = (char *)&buffer[pos]; for (int i = 0; i < realLength; i++) { - if (line[i] == '{') { + if (fileLine[i] == '{') { if (!inToken) { inToken = true; - tokenStart = line + i + 1; + tokenStart = fileLine + i + 1; tokenLength = 0; tokenPos++; } else { tokenLength++; } - } else if (line[i] == '}') { + } else if (fileLine[i] == '}') { if (inToken) { inToken = false; char *token = new char[tokenLength + 1]; @@ -141,23 +141,23 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: } delete[] token; } else { - text += line[i]; + cardText += fileLine[i]; } } else { if (inToken) { tokenLength++; } else { - if (line[i] == '|') { - text += '\n'; + if (fileLine[i] == '|') { + cardText += '\n'; } else { - text += line[i]; + cardText += fileLine[i]; } } } } - if (start != -1 && text.size() > 0 && (start != 1 || end != 1)) { - _subtitles.push_back(SubtitleCard(_gameRef, text, start, end)); + if (start != -1 && cardText.size() > 0 && (start != 1 || end != 1)){ + _subtitles.push_back(SubtitleCard(_gameRef, cardText, start, end)); } pos += lineLength + 1; -- cgit v1.2.3 From e12f30ed030fc719b56e2be8418707f258af05d5 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 15 Oct 2014 21:32:48 +0200 Subject: WINTERMUTE: Add a bunch of comments in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index f540fddb5f..52bae27d2d 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -93,6 +93,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: int pos = 0; int lineLength = 0; + /* This is where we parse .sub files. + * Subtitles cards are in the form + * {StartFrame}{EndFrame} FirstLine | SecondLine \n + */ while (pos < fileSize) { start = end = -1; inToken = false; @@ -112,6 +116,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: if (pos + lineLength >= fileSize) { realLength = lineLength - 0; } else { + // If we got here the above loop exited after hitting "\0" "\n" realLength = lineLength - 1; } @@ -121,26 +126,32 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: for (int i = 0; i < realLength; i++) { if (fileLine[i] == '{') { if (!inToken) { + // We've hit the start of a Start/EndFrame token inToken = true; tokenStart = fileLine + i + 1; tokenLength = 0; tokenPos++; } else { + // Actually, we were already inside an (invalid) one. tokenLength++; } } else if (fileLine[i] == '}') { if (inToken) { + // we were /inside/ a {.*} token, so this is the end of the block inToken = false; char *token = new char[tokenLength + 1]; strncpy(token, tokenStart, tokenLength); token[tokenLength] = '\0'; if (tokenPos == 0) { + // Was this StartFrame... start = atoi(token); } else if (tokenPos == 1) { + // Or the EndFrame? end = atoi(token); } delete[] token; } else { + // This char is part of the plain text, just append it cardText += fileLine[i]; } } else { @@ -148,8 +159,10 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: tokenLength++; } else { if (fileLine[i] == '|') { + // The pipe character signals a linebreak in the text cardText += '\n'; } else { + // This char is part of the plain text, just append it cardText += fileLine[i]; } } @@ -157,6 +170,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: } if (start != -1 && cardText.size() > 0 && (start != 1 || end != 1)){ + // Add a subtitlecard based on the line we have just parsed _subtitles.push_back(SubtitleCard(_gameRef, cardText, start, end)); } -- cgit v1.2.3 From 8ee1a85f3589bc5da2ad6d0b75a550f8df5d62dd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 15 Oct 2014 21:18:17 -0400 Subject: MADS: Save redundant reloads of digital audio when switching animations --- engines/mads/audio.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp index 1c61e13957..9d62c3f615 100644 --- a/engines/mads/audio.cpp +++ b/engines/mads/audio.cpp @@ -37,6 +37,7 @@ AudioPlayer::AudioPlayer(Audio::Mixer *mixer, uint32 gameID) : _mixer(mixer), _g AudioPlayer::~AudioPlayer() { _dsrEntries.clear(); + _filename = ""; } bool AudioPlayer::isPlaying() const { @@ -65,25 +66,27 @@ void AudioPlayer::setDefaultSoundGroup() { } void AudioPlayer::setSoundGroup(const Common::String &filename) { - _dsrEntries.clear(); - - _filename = filename; - _dsrFile.open(filename); - - // Read header - uint16 entryCount = _dsrFile.readUint16LE(); - - for (uint16 i = 0; i < entryCount; i++) { - DSREntry newEntry; - newEntry.frequency = _dsrFile.readUint16LE(); - newEntry.channels = _dsrFile.readUint32LE(); - newEntry.compSize = _dsrFile.readUint32LE(); - newEntry.uncompSize = _dsrFile.readUint32LE(); - newEntry.offset = _dsrFile.readUint32LE(); - _dsrEntries.push_back(newEntry); + if (_filename != filename) { + _dsrEntries.clear(); + + _filename = filename; + _dsrFile.open(filename); + + // Read header + uint16 entryCount = _dsrFile.readUint16LE(); + + for (uint16 i = 0; i < entryCount; i++) { + DSREntry newEntry; + newEntry.frequency = _dsrFile.readUint16LE(); + newEntry.channels = _dsrFile.readUint32LE(); + newEntry.compSize = _dsrFile.readUint32LE(); + newEntry.uncompSize = _dsrFile.readUint32LE(); + newEntry.offset = _dsrFile.readUint32LE(); + _dsrEntries.push_back(newEntry); + } + + _dsrFile.close(); } - - _dsrFile.close(); } void AudioPlayer::playSound(int soundIndex, bool loop) { -- cgit v1.2.3 From c878731937a39f56cc63ef56d2190d2e02caa2d7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 16 Oct 2014 07:55:54 +0200 Subject: TSAGE: Move Air Duct and Vampire lair mazes in separate source files --- engines/tsage/module.mk | 4 +- engines/tsage/ringworld2/ringworld2_airduct.cpp | 914 ++ engines/tsage/ringworld2/ringworld2_airduct.h | 90 + engines/tsage/ringworld2/ringworld2_logic.cpp | 2 + engines/tsage/ringworld2/ringworld2_scenes1.cpp | 13520 +++++++++------------- engines/tsage/ringworld2/ringworld2_scenes1.h | 184 - engines/tsage/ringworld2/ringworld2_vampire.cpp | 1821 +++ engines/tsage/ringworld2/ringworld2_vampire.h | 180 + 8 files changed, 8435 insertions(+), 8280 deletions(-) create mode 100644 engines/tsage/ringworld2/ringworld2_airduct.cpp create mode 100644 engines/tsage/ringworld2/ringworld2_airduct.h create mode 100644 engines/tsage/ringworld2/ringworld2_vampire.cpp create mode 100644 engines/tsage/ringworld2/ringworld2_vampire.h diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk index 3fc30f9f8f..d62f398c20 100644 --- a/engines/tsage/module.mk +++ b/engines/tsage/module.mk @@ -35,14 +35,16 @@ MODULE_OBJS := \ ringworld/ringworld_scenes8.o \ ringworld/ringworld_scenes10.o \ ringworld/ringworld_speakers.o \ + ringworld2/ringworld2_airduct.o \ ringworld2/ringworld2_dialogs.o \ ringworld2/ringworld2_logic.o \ + ringworld2/ringworld2_outpost.o \ ringworld2/ringworld2_scenes0.o \ ringworld2/ringworld2_scenes1.o \ ringworld2/ringworld2_scenes2.o \ ringworld2/ringworld2_scenes3.o \ - ringworld2/ringworld2_outpost.o \ ringworld2/ringworld2_speakers.o \ + ringworld2/ringworld2_vampire.o \ saveload.o \ scenes.o \ sound.o \ diff --git a/engines/tsage/ringworld2/ringworld2_airduct.cpp b/engines/tsage/ringworld2/ringworld2_airduct.cpp new file mode 100644 index 0000000000..dc43dba1ae --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_airduct.cpp @@ -0,0 +1,914 @@ +/* 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 "graphics/cursorman.h" + +#include "tsage/scenes.h" +#include "tsage/tsage.h" +#include "tsage/staticres.h" +#include "tsage/ringworld2/ringworld2_airduct.h" + +namespace TsAGE { + +namespace Ringworld2 { + +/*-------------------------------------------------------------------------- + * Scene 1200 - Air Ducts Maze + * + *--------------------------------------------------------------------------*/ + +Scene1200::Scene1200() { + _nextCrawlDirection = 0; + _field414 = 0; + _field416 = 0; + _field418 = 0; + _field41A = 0; + _fixupMaze = false; +} + +void Scene1200::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_nextCrawlDirection); + s.syncAsSint16LE(_field414); + s.syncAsSint16LE(_field416); + s.syncAsSint16LE(_field418); + s.syncAsSint16LE(_field41A); + s.syncAsSint16LE(_fixupMaze); +} + +Scene1200::LaserPanel::LaserPanel() { +} + +void Scene1200::LaserPanel::Jumper::init(int state) { + _state = state; + + SceneActor::postInit(); + setup(1003, 1, 1); + fixPriority(255); + + switch (_state) { + case 1: + switch (R2_GLOBALS._ductMazePanel1State) { + case 1: + setFrame2(2); + setPosition(Common::Point(129, 101)); + break; + case 2: + setFrame2(3); + setPosition(Common::Point(135, 95)); + break; + default: + break; + } + break; + case 2: + switch (R2_GLOBALS._ductMazePanel2State) { + case 1: + setFrame2(2); + setPosition(Common::Point(152, 101)); + break; + case 2: + setFrame2(3); + setPosition(Common::Point(158, 122)); + break; + case 3: + setFrame2(3); + setPosition(Common::Point(135, 122)); + break; + default: + break; + } + break; + case 3: + switch (R2_GLOBALS._ductMazePanel3State) { + case 1: + setFrame2(3); + setPosition(Common::Point(158, 95)); + break; + case 2: + setFrame2(2); + setPosition(Common::Point(175, 101)); + break; + default: + break; + } + break; + default: + break; + } + + setDetails(1200, 12, -1, -1, 2, (SceneItem *) NULL); +} + +bool Scene1200::LaserPanel::Jumper::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._sound2.play(260); + switch (_state) { + case 1: + if (R2_GLOBALS._ductMazePanel1State == 1) { + R2_GLOBALS._ductMazePanel1State = 2; + setFrame2(3); + setPosition(Common::Point(135, 95)); + } else { + R2_GLOBALS._ductMazePanel1State = 1; + setFrame2(2); + setPosition(Common::Point(129, 101)); + } + break; + case 2: + ++R2_GLOBALS._ductMazePanel2State; + if (R2_GLOBALS._ductMazePanel2State == 4) + R2_GLOBALS._ductMazePanel2State = 1; + + switch (R2_GLOBALS._ductMazePanel2State) { + case 1: + setFrame2(2); + setPosition(Common::Point(152, 101)); + break; + case 2: + setFrame2(3); + setPosition(Common::Point(158, 122)); + break; + case 3: + setFrame2(3); + setPosition(Common::Point(135, 122)); + break; + default: + break; + } + break; + case 3: + if (R2_GLOBALS._ductMazePanel3State == 1) { + R2_GLOBALS._ductMazePanel3State = 2; + setFrame2(2); + setPosition(Common::Point(175, 101)); + } else { + R2_GLOBALS._ductMazePanel3State = 1; + setFrame2(3); + setPosition(Common::Point(158, 95)); + } + break; + default: + break; + } + + Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; + scene->_field418 = 0; + + if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) + scene->_field418 = 1; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) + scene->_field418 = 2; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2)) + scene->_field418 = 3; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1)) + scene->_field418 = 4; + + return true; +} + +void Scene1200::LaserPanel::postInit(SceneObjectList *OwnerList) { + Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; + + scene->_field41A = 1; + R2_GLOBALS._events.setCursor(CURSOR_USE); + setup2(1003, 1, 1, 100, 40); + setup3(1200, 11, -1, -1); + R2_GLOBALS._sound2.play(259); + _jumper1.init(1); + _jumper2.init(2); + _jumper3.init(3); + + R2_GLOBALS._player._canWalk = false; +} + +void Scene1200::LaserPanel::remove() { + Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; + + scene->_field41A = 0; + scene->_sceneAreas.remove(&_jumper1); + scene->_sceneAreas.remove(&_jumper2); + scene->_sceneAreas.remove(&_jumper3); + _jumper1.remove(); + _jumper2.remove(); + _jumper3.remove(); + + ModalWindow::remove(); + R2_GLOBALS._player._canWalk = true; +} + +void Scene1200::postInit(SceneObjectList *OwnerList) { + loadScene(1200); + SceneExt::postInit(); + + if (R2_GLOBALS._sceneManager._previousScene < 3200) + R2_GLOBALS._sound1.play(257); + + _nextCrawlDirection = CRAWL_EAST; + _field414 = 0; + _field416 = 0; + _field418 = 0; + _field41A = 0; + + if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) + _field418 = 1; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) + _field418 = 2; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2)) + _field418 = 3; + else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1)) + _field418 = 4; + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.setup(3156, 1, 6); + R2_GLOBALS._player.setPosition(Common::Point(160, 70)); + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1200; + + _actor1.postInit(); + _actor1.hide(); + + _mazeUI.setDisplayBounds(Rect(110, 20, 210, 120)); + + _mazeUI.postInit(); + _mazeUI.load(1); + _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); + + R2_GLOBALS._player.enableControl(); + _item1.setDetails(Rect(0, 0, 320, 200), 1200, 0, 1, 2, 1, NULL); +} + +void Scene1200::signal() { + switch (_sceneMode++) { + case 1: + // No break on purpose + case 1200: + // No break on purpose + case 1201: + // No break on purpose + case 1202: + // No break on purpose + case 1203: + R2_GLOBALS._player.enableControl(); + // CHECKME: The original is calling _eventManager.waitEvent(); + _sceneMode = 2; + break; + case 10: + _field416 = 1; + _field414 = 6; + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.setStrip(1); + R2_GLOBALS._player.setFrame(5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 11: + // No break on purpose + case 21: + // No break on purpose + case 31: + // No break on purpose + case 41: + _field416 = 0; + break; + case 12: + _field414 = 14; + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player.setup(3155, 1, 4); + R2_GLOBALS._player.setPosition(Common::Point(160, 70)); + R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); + break; + case 13: + // No break on purpose + case 16: + // No break on purpose + case 23: + // No break on purpose + case 26: + // No break on purpose + case 33: + // No break on purpose + case 36: + // No break on purpose + case 43: + // No break on purpose + case 46: + R2_GLOBALS._player.setFrame(4); + _sceneMode = 1; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 15: + // No break on purpose + case 25: + // No break on purpose + case 35: + // No break on purpose + case 45: + _field414 = 20; + R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); + break; + case 20: + _field416 = 1; + _field414 = 6; + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.setStrip(2); + R2_GLOBALS._player.setFrame(5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 22: + _field414 = 14; + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player.setup(3155, 2, 4); + R2_GLOBALS._player.setPosition(Common::Point(160, 70)); + R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); + break; + case 30: + _field416 = 1; + _field414 = 6; + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.setStrip(3); + R2_GLOBALS._player.setFrame(5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 32: + _field414 = 14; + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player.setup(3155, 3, 4); + R2_GLOBALS._player.setPosition(Common::Point(160, 70)); + R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); + break; + case 40: + _field416 = 1; + _field414 = 6; + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.setStrip(4); + R2_GLOBALS._player.setFrame(5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 42: + _field414 = 14; + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player.setup(3155, 4, 4); + R2_GLOBALS._player.setPosition(Common::Point(160, 70)); + R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); + break; + case 50: + // No break on purpose + case 55: + // No break on purpose + case 60: + R2_GLOBALS._player.setup(3156, 5, 1); + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 51: + // No break on purpose + case 56: + // No break on purpose + case 117: + R2_GLOBALS._player.setup(3157, 1, 1); + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 52: + // No break on purpose + case 82: + // No break on purpose + case 118: + R2_GLOBALS._player.setup(3156, 3, 6); + _sceneMode = 1; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 57: + // No break on purpose + case 91: + // No break on purpose + case 96: + R2_GLOBALS._player.setup(3157, 2, 1); + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 58: + // No break on purpose + case 92: + // No break on purpose + case 122: + R2_GLOBALS._player.setup(3156, 2, 6); + _sceneMode = 1; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 61: + R2_GLOBALS._player.setup(3157, 4, 5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 62: + // No break on purpose + case 72: + // No break on purpose + case 98: + R2_GLOBALS._player.setup(3156, 4, 6); + _sceneMode = 1; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 70: + // No break on purpose + case 75: + // No break on purpose + case 80: + R2_GLOBALS._player.setup(3156, 6, 1); + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 71: + // No break on purpose + case 76: + // No break on purpose + case 97: + R2_GLOBALS._player.setup(3157, 3, 1); + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 77: + // No break on purpose + case 111: + // No break on purpose + case 116: + R2_GLOBALS._player.setup(3157, 4, 1); + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 78: + // No break on purpose + case 102: + // No break on purpose + case 112: + R2_GLOBALS._player.setup(3156, 1, 6); + _sceneMode = 1; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 81: + R2_GLOBALS._player.setup(3157, 2, 5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 90: + // No break on purpose + case 95: + // No break on purpose + case 100: + R2_GLOBALS._player.setup(3156, 7, 1); + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 101: + R2_GLOBALS._player.setup(3157, 1, 5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + case 110: + // No break on purpose + case 115: + // No break on purpose + case 120: + R2_GLOBALS._player.setup(3156, 8, 1); + R2_GLOBALS._player._numFrames = 5; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 121: + R2_GLOBALS._player.setup(3157, 3, 5); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; + default: + // CHECKME: The original is walling _eventManager.waitEvent(); + _sceneMode = 2; + break; + } +} + +void Scene1200::process(Event &event) { + if (_field414 != 0) + return; + + Scene::process(event); + + if (!R2_GLOBALS._player._canWalk) + return; + + if (event.eventType == EVENT_BUTTON_DOWN) { + Common::Point cellPos = R2_GLOBALS._ventCellPos; + _mazeUI.pixelToCellXY(cellPos); + + int cellId = _mazeUI.getCellFromPixelXY(event.mousePos); + switch (R2_GLOBALS._events.getCursor()) { + case CURSOR_WALK: + event.handled = true; + if ((event.mousePos.x > 179) && (event.mousePos.x < 210) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) + startCrawling(CRAWL_EAST); + + if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) + startCrawling(CRAWL_WEST); + + if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120)) + startCrawling(CRAWL_SOUTH); + + if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50)) + startCrawling(CRAWL_NORTH); + break; + case CURSOR_USE: + if (cellId > 36) { + if ( ((cellPos.x == 3) && (cellPos.y == 33)) + || ((cellPos.x == 7) && (cellPos.y == 33)) + || ((cellPos.x == 33) && (cellPos.y == 41)) + || ((cellPos.x == 5) && (cellPos.y == 5)) + || ((cellPos.x == 13) && (cellPos.y == 21)) + || ((cellPos.x == 17) && (cellPos.y == 21)) + || ((cellPos.x == 17) && (cellPos.y == 5)) + || ((cellPos.x == 17) && (cellPos.y == 9)) + || ((cellPos.x == 29) && (cellPos.y == 17)) + || ((cellPos.x == 33) && (cellPos.y == 17)) + || ((cellPos.x == 35) && (cellPos.y == 17)) + || ((cellPos.x == 41) && (cellPos.y == 21)) ) { + _laserPanel.postInit(); + event.handled = true; + } + } + + if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { + if ( ((cellPos.x == 3) && (cellPos.y == 9)) + || ((cellPos.x == 11) && (cellPos.y == 27)) + || ((cellPos.x == 17) && (cellPos.y == 7)) + || ((cellPos.x == 17) && (cellPos.y == 27)) + || ((cellPos.x == 17) && (cellPos.y == 33)) + || (cellPos.x == 33) ) { + switch (cellPos.x) { + case 3: + R2_GLOBALS._sceneManager.changeScene(3150); + break; + case 33: + if (R2_GLOBALS._scientistConvIndex >= 4) + R2_GLOBALS._sceneManager.changeScene(3250); + else + SceneItem::display(1200, 6, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END); + break; + default: + SceneItem::display(1200, 5, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END); + break; + } + event.handled = true; + } + } + break; + case CURSOR_LOOK: + if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { + event.handled = true; + switch (cellPos.x) { + case 3: + // It was your cell. + SceneItem::display(1200, 8, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + break; + case 9: + R2_GLOBALS._sceneManager.changeScene(3240); + break; + case 11: + if (cellPos.y == 27) + R2_GLOBALS._sceneManager.changeScene(3210); + else + // A vent grill + SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + break; + case 17: + switch (cellPos.y) { + case 5: + R2_GLOBALS._sceneManager.changeScene(3230); + break; + case 21: + R2_GLOBALS._sceneManager.changeScene(3220); + break; + case 33: + R2_GLOBALS._sceneManager.changeScene(3200); + break; + default: + // A vent grill + SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + break; + } + break; + case 33: + R2_GLOBALS._sceneManager.changeScene(3245); + break; + default: + SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + break; + } + } + if (cellId > 36) { + // "An anti-pest laser" + event.handled = true; + SceneItem::display(1200, 9, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + } + break; + case CURSOR_TALK: + event.handled = true; + break; + default: + return; + } + } else if (event.eventType == EVENT_KEYPRESS) { + if (_field414) { + event.handled = false; + return; + } + + switch (event.kbd.keycode) { + case Common::KEYCODE_KP8: + case Common::KEYCODE_UP: + startCrawling(CRAWL_NORTH); + break; + case Common::KEYCODE_KP4: + case Common::KEYCODE_LEFT: + startCrawling(CRAWL_WEST); + break; + case Common::KEYCODE_KP6: + case Common::KEYCODE_RIGHT: + startCrawling(CRAWL_EAST); + break; + case Common::KEYCODE_KP2: + case Common::KEYCODE_DOWN: + startCrawling(CRAWL_SOUTH); + break; + default: + event.handled = false; + return; + break; + } + } else + return; +} + +void Scene1200::dispatch() { + Rect tmpRect; + Scene::dispatch(); + + if (_fixupMaze) { + _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); + //_mazeUI.draw(); + _fixupMaze = false; + } + + if (_field414 != 0) { + tmpRect.set(110, 20, 210, 120); + _field414--; + + switch (_nextCrawlDirection) { + case CRAWL_EAST: + R2_GLOBALS._ventCellPos.x += 2; + break; + case CRAWL_WEST: + R2_GLOBALS._ventCellPos.x -= 2; + break; + case CRAWL_SOUTH: + R2_GLOBALS._ventCellPos.y += 2; + break; + case CRAWL_NORTH: + R2_GLOBALS._ventCellPos.y -= 2; + break; + default: + break; + } + + _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); + //_mazeUI.draw(); + + if (_field416 != 0) { + switch(_nextCrawlDirection) { + case CRAWL_EAST: + R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x - 2, R2_GLOBALS._player._position.y)); + break; + case CRAWL_WEST: + R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x + 2, R2_GLOBALS._player._position.y)); + break; + case CRAWL_SOUTH: + R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 2)); + break; + case CRAWL_NORTH: + R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 2)); + break; + default: + break; + } + } + if (_field414 == 0) { + if (_field416 == 0) + R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); + signal(); + } + } +} + +void Scene1200::saveCharacter(int characterIndex) { + R2_GLOBALS._sound1.fadeOut2(NULL); + SceneExt::saveCharacter(characterIndex); +} + +void Scene1200::startCrawling(CrawlDirection dir) { + Common::Point cellPos = R2_GLOBALS._ventCellPos; + _mazeUI.pixelToCellXY(cellPos); + + switch (dir) { + case CRAWL_EAST: + if ( ((_mazeUI.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(200, 88)) > 36)) + && ( ((cellPos.x == 3) && (cellPos.y == 33) && (_field418 != 4)) + || ((cellPos.x == 13) && (cellPos.y == 21) && (_field418 != 2)) + || ((cellPos.x == 29) && (cellPos.y == 17) && (_field418 != 1)) + || ((cellPos.x == 33) && (cellPos.y == 41)) ) + ) { + R2_GLOBALS._player.disableControl(); + _sceneMode = 1200; + setAction(&_sequenceManager, this, 1200, &_actor1, NULL); + } else if (_mazeUI.getCellFromPixelXY(Common::Point(200, 69)) == 36) { + switch (_nextCrawlDirection) { + case CRAWL_EAST: + if (R2_GLOBALS._player._visage == 3155) + _sceneMode = 15; + else + _sceneMode = 10; + break; + case CRAWL_WEST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 76; + else + _sceneMode = 75; + break; + case CRAWL_SOUTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 101; + else + _sceneMode = 100; + break; + case CRAWL_NORTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 111; + else + _sceneMode = 110; + break; + default: + break; + } + R2_GLOBALS._player.disableControl(); + _nextCrawlDirection = 1; + signal(); + } + break; + case CRAWL_WEST: + if ( ((_mazeUI.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(120, 88)) > 36)) + && ( ((cellPos.x == 7) && (cellPos.y == 33) && (_field418 != 4)) + || ((cellPos.x == 17) && (cellPos.y == 21) && (_field418 != 2)) + || ((cellPos.x == 33) && (cellPos.y == 17) && (_field418 != 1)) + || ((cellPos.x == 5) && (cellPos.y == 5)) ) + ) { + R2_GLOBALS._player.disableControl(); + _sceneMode = 1201; + setAction(&_sequenceManager, this, 1201, &_actor1, NULL); + } else if (_mazeUI.getCellFromPixelXY(Common::Point(120, 69)) == 36) { + switch (_nextCrawlDirection) { + case CRAWL_EAST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 56; + else + _sceneMode = 55; + break; + case CRAWL_WEST: + if (R2_GLOBALS._player._visage == 3155) + _sceneMode = 25; + else + _sceneMode = 20; + break; + case CRAWL_SOUTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 91; + else + _sceneMode = 90; + break; + case CRAWL_NORTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 121; + else + _sceneMode = 120; + break; + default: + break; + } + R2_GLOBALS._player.disableControl(); + _nextCrawlDirection = 2; + signal(); + } + break; + case CRAWL_SOUTH: + if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 110)) > 36)) + && ( ((cellPos.x == 17) && (cellPos.y == 5) && (_field418 != 3)) + || ((cellPos.x == 41) && (cellPos.y == 21)) ) + ) { + R2_GLOBALS._player.disableControl(); + _sceneMode = 1203; + setAction(&_sequenceManager, this, 1203, &_actor1, NULL); + } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 110)) == 36) { + switch (_nextCrawlDirection) { + case CRAWL_EAST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 51; + else + _sceneMode = 50; + break; + case CRAWL_WEST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 81; + else + _sceneMode = 80; + break; + case CRAWL_SOUTH: + if (R2_GLOBALS._player._visage == 3155) + _sceneMode = 35; + else + _sceneMode = 30; + break; + case CRAWL_NORTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 116; + else + _sceneMode = 115; + break; + default: + break; + } + R2_GLOBALS._player.disableControl(); + _nextCrawlDirection = 3; + signal(); + } + break; + case CRAWL_NORTH: + if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 30)) > 36)) + && ( ((cellPos.x == 17) && (cellPos.y == 9) && (_field418 != 3)) + || ((cellPos.x == 35) && (cellPos.y == 17)) ) + ) { + R2_GLOBALS._player.disableControl(); + _sceneMode = 1202; + setAction(&_sequenceManager, this, 1202, &_actor1, NULL); + } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 30)) == 36) { + switch (_nextCrawlDirection) { + case CRAWL_EAST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 61; + else + _sceneMode = 60; + break; + case CRAWL_WEST: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 71; + else + _sceneMode = 70; + break; + case CRAWL_SOUTH: + if (R2_GLOBALS._player._visage == 3156) + _sceneMode = 96; + else + _sceneMode = 95; + break; + case CRAWL_NORTH: + if (R2_GLOBALS._player._visage == 3155) + _sceneMode = 45; + else + _sceneMode = 40; + break; + default: + _sceneMode = 1; + R2_GLOBALS._player.setup(3156, 4, 6); + break; + } + R2_GLOBALS._player.disableControl(); + _nextCrawlDirection = 4; + signal(); + } + break; + default: + break; + } +} + +} // End of namespace Ringworld2 +} // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_airduct.h b/engines/tsage/ringworld2/ringworld2_airduct.h new file mode 100644 index 0000000000..4a89f58c96 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_airduct.h @@ -0,0 +1,90 @@ +/* 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 TSAGE_RINGWORLD2_AIRDUCT_H +#define TSAGE_RINGWORLD2_AIRDUCT_H + +#include "tsage/converse.h" +#include "tsage/events.h" +#include "tsage/core.h" +#include "tsage/scenes.h" +#include "tsage/globals.h" +#include "tsage/sound.h" +#include "tsage/ringworld2/ringworld2_logic.h" + +namespace TsAGE { + +namespace Ringworld2 { + +using namespace TsAGE; + +class Scene1200 : public SceneExt { + enum CrawlDirection { CRAWL_EAST = 1, CRAWL_WEST = 2, CRAWL_SOUTH = 3, CRAWL_NORTH = 4 }; + + class LaserPanel: public ModalWindow { + public: + class Jumper : public SceneActorExt { + public: + void init(int state); + virtual bool startAction(CursorType action, Event &event); + }; + + Jumper _jumper1; + Jumper _jumper2; + Jumper _jumper3; + + LaserPanel(); + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + }; + +public: + NamedHotspot _item1; + SceneActor _actor1; + LaserPanel _laserPanel; + MazeUI _mazeUI; + SequenceManager _sequenceManager; + + int _nextCrawlDirection; + int _field414; + int _field416; + int _field418; + int _field41A; + bool _fixupMaze; + + Scene1200(); + void synchronize(Serializer &s); + + void startCrawling(CrawlDirection dir); + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void signal(); + virtual void process(Event &event); + virtual void dispatch(); + virtual void saveCharacter(int characterIndex); +}; + +} // End of namespace Ringworld2 +} // End of namespace TsAGE + +#endif diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index a04fd56917..d24541932f 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -32,7 +32,9 @@ #include "tsage/ringworld2/ringworld2_scenes1.h" #include "tsage/ringworld2/ringworld2_scenes2.h" #include "tsage/ringworld2/ringworld2_scenes3.h" +#include "tsage/ringworld2/ringworld2_airduct.h" #include "tsage/ringworld2/ringworld2_outpost.h" +#include "tsage/ringworld2/ringworld2_vampire.h" namespace TsAGE { diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 51879f1eed..81dc05e2a4 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -1321,1249 +1321,827 @@ void Scene1100::saveCharacter(int characterIndex) { } /*-------------------------------------------------------------------------- - * Scene 1200 - Air Ducts Maze + * Scene 1500 - Cutscene: Ship landing * *--------------------------------------------------------------------------*/ -Scene1200::Scene1200() { - _nextCrawlDirection = 0; - _field414 = 0; - _field416 = 0; - _field418 = 0; - _field41A = 0; - _fixupMaze = false; -} +void Scene1500::postInit(SceneObjectList *OwnerList) { + loadScene(1500); + R2_GLOBALS._uiElements._active = false; + setZoomPercents(170, 13, 240, 100); + SceneExt::postInit(); + R2_GLOBALS._interfaceY = SCREEN_HEIGHT; -void Scene1200::synchronize(Serializer &s) { - SceneExt::synchronize(s); + scalePalette(65, 65, 65); - s.syncAsSint16LE(_nextCrawlDirection); - s.syncAsSint16LE(_field414); - s.syncAsSint16LE(_field416); - s.syncAsSint16LE(_field418); - s.syncAsSint16LE(_field41A); - s.syncAsSint16LE(_fixupMaze); -} + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); + + _starshipShadow.postInit(); + _starshipShadow.setup(1401, 1, 1); + _starshipShadow._effect = EFFECT_SHADOW_MAP; + _starshipShadow.fixPriority(10); + _starshipShadow._shadowMap = _shadowPaletteMap; + + _starship.postInit(); + _starship.setup(1400, 1, 1); + _starship._moveDiff = Common::Point(1, 1); + _starship._linkedActor = &_starshipShadow; + + if (R2_GLOBALS._sceneManager._previousScene != 1010) { + _smallShipShadow.postInit(); + _smallShipShadow.setup(1401, 2, 1); + _smallShipShadow._effect = EFFECT_SHADOW_MAP; + _smallShipShadow.fixPriority(10); + _smallShipShadow._shadowMap = _shadowPaletteMap; + + _smallShip.postInit(); + _smallShip._moveRate = 30; + _smallShip._moveDiff = Common::Point(1, 1); + _smallShip._linkedActor = &_smallShipShadow; + } + + if (R2_GLOBALS._sceneManager._previousScene == 300) { + _starship.setPosition(Common::Point(189, 139), 5); + + _smallShip.setup(1400, 1, 2); + _smallShip.setPosition(Common::Point(148, 108), 0); + + _sceneMode = 20; + R2_GLOBALS._sound1.play(110); + } else if (R2_GLOBALS._sceneManager._previousScene == 1550) { + _starship.setPosition(Common::Point(189, 139), 5); + + _smallShip.setup(1400, 2, 1); + _smallShip.changeZoom(-1); + _smallShip.setPosition(Common::Point(298, 258), 5); + + _sceneMode = 10; + R2_GLOBALS._sound1.play(106); + } else { + _starship.setPosition(Common::Point(289, 239), -30); + _sceneMode = 0; + R2_GLOBALS._sound1.play(102); + } -Scene1200::LaserPanel::LaserPanel() { + signal(); } -void Scene1200::LaserPanel::Jumper::init(int state) { - _state = state; +void Scene1500::remove() { + R2_GLOBALS._uiElements._active = true; + R2_GLOBALS._uiElements._visible = true; - SceneActor::postInit(); - setup(1003, 1, 1); - fixPriority(255); + SceneExt::remove(); +} - switch (_state) { +void Scene1500::signal() { + switch(_sceneMode++) { + case 0: + R2_GLOBALS.setFlag(25); + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + // No break on purpose case 1: - switch (R2_GLOBALS._ductMazePanel1State) { - case 1: - setFrame2(2); - setPosition(Common::Point(129, 101)); - break; - case 2: - setFrame2(3); - setPosition(Common::Point(135, 95)); - break; - default: - break; + if (_starship._yDiff < 50) { + _starship.setPosition(Common::Point(289, 239), _starship._yDiff + 1); + _sceneMode = 1; } + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); break; - case 2: - switch (R2_GLOBALS._ductMazePanel2State) { - case 1: - setFrame2(2); - setPosition(Common::Point(152, 101)); - break; - case 2: - setFrame2(3); - setPosition(Common::Point(158, 122)); - break; - case 3: - setFrame2(3); - setPosition(Common::Point(135, 122)); - break; - default: - break; + case 2: { + Common::Point pt(189, 139); + NpcMover *mover = new NpcMover(); + _starship.addMover(mover, &pt, this); } break; case 3: - switch (R2_GLOBALS._ductMazePanel3State) { - case 1: - setFrame2(3); - setPosition(Common::Point(158, 95)); - break; - case 2: - setFrame2(2); - setPosition(Common::Point(175, 101)); - break; - default: - break; + if (_starship._yDiff > 5) { + _starship.setPosition(Common::Point(189, 139), _starship._yDiff - 1); + _sceneMode = 3; } + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); break; - default: + case 13: + R2_GLOBALS._player._characterIndex = R2_MIRANDA; + // No break on purpose + case 4: + R2_GLOBALS._sceneManager.changeScene(300); break; - } - - setDetails(1200, 12, -1, -1, 2, (SceneItem *) NULL); -} - -bool Scene1200::LaserPanel::Jumper::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - R2_GLOBALS._sound2.play(260); - switch (_state) { - case 1: - if (R2_GLOBALS._ductMazePanel1State == 1) { - R2_GLOBALS._ductMazePanel1State = 2; - setFrame2(3); - setPosition(Common::Point(135, 95)); - } else { - R2_GLOBALS._ductMazePanel1State = 1; - setFrame2(2); - setPosition(Common::Point(129, 101)); + case 10: + // No break on purpose + case 20: + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 11: { + Common::Point pt(148, 108); + NpcMover *mover = new NpcMover(); + _smallShip.addMover(mover, &pt, this); } break; - case 2: - ++R2_GLOBALS._ductMazePanel2State; - if (R2_GLOBALS._ductMazePanel2State == 4) - R2_GLOBALS._ductMazePanel2State = 1; - - switch (R2_GLOBALS._ductMazePanel2State) { - case 1: - setFrame2(2); - setPosition(Common::Point(152, 101)); - break; - case 2: - setFrame2(3); - setPosition(Common::Point(158, 122)); - break; - case 3: - setFrame2(3); - setPosition(Common::Point(135, 122)); - break; - default: - break; + case 12: + setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); + break; + case 21: { + Common::Point pt(-2, -42); + NpcMover *mover = new NpcMover(); + _smallShip.addMover(mover, &pt, NULL); + signal(); } break; - case 3: - if (R2_GLOBALS._ductMazePanel3State == 1) { - R2_GLOBALS._ductMazePanel3State = 2; - setFrame2(2); - setPosition(Common::Point(175, 101)); - } else { - R2_GLOBALS._ductMazePanel3State = 1; - setFrame2(3); - setPosition(Common::Point(158, 95)); + case 22: + if (_starship._yDiff < 50) { + _starship.setPosition(Common::Point(189, 139), _starship._yDiff + 1); + _sceneMode = 22; + } + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; + case 23: { + Common::Point pt(-13, -61); + NpcMover *mover = new NpcMover(); + _starship.addMover(mover, &pt, this); } break; + case 24: + R2_GLOBALS._sceneManager.changeScene(1550); + break; default: break; } - - Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; - scene->_field418 = 0; - - if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) - scene->_field418 = 1; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) - scene->_field418 = 2; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2)) - scene->_field418 = 3; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1)) - scene->_field418 = 4; - - return true; } -void Scene1200::LaserPanel::postInit(SceneObjectList *OwnerList) { - Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; - - scene->_field41A = 1; - R2_GLOBALS._events.setCursor(CURSOR_USE); - setup2(1003, 1, 1, 100, 40); - setup3(1200, 11, -1, -1); - R2_GLOBALS._sound2.play(259); - _jumper1.init(1); - _jumper2.init(2); - _jumper3.init(3); +void Scene1500::dispatch() { + if (_sceneMode > 10) { + float yDiff = sqrt((float) (_smallShip._position.x * _smallShip._position.x) + (_smallShip._position.y * _smallShip._position.y)); + if (yDiff > 6) + _smallShip.setPosition(_smallShip._position, (int) yDiff); + } - R2_GLOBALS._player._canWalk = false; + Scene::dispatch(); } -void Scene1200::LaserPanel::remove() { - Scene1200 *scene = (Scene1200 *)R2_GLOBALS._sceneManager._scene; - - scene->_field41A = 0; - scene->_sceneAreas.remove(&_jumper1); - scene->_sceneAreas.remove(&_jumper2); - scene->_sceneAreas.remove(&_jumper3); - _jumper1.remove(); - _jumper2.remove(); - _jumper3.remove(); - - ModalWindow::remove(); - R2_GLOBALS._player._canWalk = true; -} +/*-------------------------------------------------------------------------- + * Scene 1525 - Cutscene - Ship + * + *--------------------------------------------------------------------------*/ -void Scene1200::postInit(SceneObjectList *OwnerList) { - loadScene(1200); +void Scene1525::postInit(SceneObjectList *OwnerList) { + loadScene(1525); + R2_GLOBALS._uiElements._active = false; SceneExt::postInit(); - if (R2_GLOBALS._sceneManager._previousScene < 3200) - R2_GLOBALS._sound1.play(257); - - _nextCrawlDirection = CRAWL_EAST; - _field414 = 0; - _field416 = 0; - _field418 = 0; - _field41A = 0; - - if ((R2_GLOBALS._ductMazePanel1State == 1) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) - _field418 = 1; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 1)) - _field418 = 2; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 1) && (R2_GLOBALS._ductMazePanel3State == 2)) - _field418 = 3; - else if ((R2_GLOBALS._ductMazePanel1State == 2) && (R2_GLOBALS._ductMazePanel2State == 3) && (R2_GLOBALS._ductMazePanel3State == 1)) - _field418 = 4; - R2_GLOBALS._player.postInit(); + if (R2_GLOBALS._sceneManager._previousScene == 525) + R2_GLOBALS._player.setup(1525, 1, 1); + else + R2_GLOBALS._player.setup(1525, 1, 16); + R2_GLOBALS._player.setPosition(Common::Point(244, 148)); R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.setup(3156, 1, 6); - R2_GLOBALS._player.setPosition(Common::Point(160, 70)); - R2_GLOBALS._player._numFrames = 10; - R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1200; - - _actor1.postInit(); - _actor1.hide(); - - _mazeUI.setDisplayBounds(Rect(110, 20, 210, 120)); - _mazeUI.postInit(); - _mazeUI.load(1); - _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); - - R2_GLOBALS._player.enableControl(); - _item1.setDetails(Rect(0, 0, 320, 200), 1200, 0, 1, 2, 1, NULL); + _sceneMode = 0; + setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); } -void Scene1200::signal() { +void Scene1525::signal() { switch (_sceneMode++) { - case 1: - // No break on purpose - case 1200: - // No break on purpose - case 1201: - // No break on purpose - case 1202: - // No break on purpose - case 1203: - R2_GLOBALS._player.enableControl(); - // CHECKME: The original is calling _eventManager.waitEvent(); - _sceneMode = 2; - break; - case 10: - _field416 = 1; - _field414 = 6; - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.setStrip(1); - R2_GLOBALS._player.setFrame(5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); + case 0: + if (R2_GLOBALS._sceneManager._previousScene == 525) + setAction(&_sequenceManager, this, 1525, &R2_GLOBALS._player, NULL); + else + setAction(&_sequenceManager, this, 1526, &R2_GLOBALS._player, NULL); break; - case 11: - // No break on purpose - case 21: - // No break on purpose - case 31: - // No break on purpose - case 41: - _field416 = 0; + case 1: + setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); break; - case 12: - _field414 = 14; - R2_GLOBALS._player._numFrames = 10; - R2_GLOBALS._player.setup(3155, 1, 4); - R2_GLOBALS._player.setPosition(Common::Point(160, 70)); - R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); - break; - case 13: - // No break on purpose - case 16: - // No break on purpose - case 23: - // No break on purpose - case 26: - // No break on purpose - case 33: - // No break on purpose - case 36: - // No break on purpose - case 43: - // No break on purpose - case 46: - R2_GLOBALS._player.setFrame(4); - _sceneMode = 1; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 15: - // No break on purpose - case 25: - // No break on purpose - case 35: - // No break on purpose - case 45: - _field414 = 20; - R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); - break; - case 20: - _field416 = 1; - _field414 = 6; - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.setStrip(2); - R2_GLOBALS._player.setFrame(5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 22: - _field414 = 14; - R2_GLOBALS._player._numFrames = 10; - R2_GLOBALS._player.setup(3155, 2, 4); - R2_GLOBALS._player.setPosition(Common::Point(160, 70)); - R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); - break; - case 30: - _field416 = 1; - _field414 = 6; - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.setStrip(3); - R2_GLOBALS._player.setFrame(5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 32: - _field414 = 14; - R2_GLOBALS._player._numFrames = 10; - R2_GLOBALS._player.setup(3155, 3, 4); - R2_GLOBALS._player.setPosition(Common::Point(160, 70)); - R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); - break; - case 40: - _field416 = 1; - _field414 = 6; - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.setStrip(4); - R2_GLOBALS._player.setFrame(5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 42: - _field414 = 14; - R2_GLOBALS._player._numFrames = 10; - R2_GLOBALS._player.setup(3155, 4, 4); - R2_GLOBALS._player.setPosition(Common::Point(160, 70)); - R2_GLOBALS._player.animate(ANIM_MODE_2, NULL); - break; - case 50: - // No break on purpose - case 55: - // No break on purpose - case 60: - R2_GLOBALS._player.setup(3156, 5, 1); - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 51: - // No break on purpose - case 56: - // No break on purpose - case 117: - R2_GLOBALS._player.setup(3157, 1, 1); - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 52: - // No break on purpose - case 82: - // No break on purpose - case 118: - R2_GLOBALS._player.setup(3156, 3, 6); - _sceneMode = 1; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 57: - // No break on purpose - case 91: - // No break on purpose - case 96: - R2_GLOBALS._player.setup(3157, 2, 1); - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 58: - // No break on purpose - case 92: - // No break on purpose - case 122: - R2_GLOBALS._player.setup(3156, 2, 6); - _sceneMode = 1; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 61: - R2_GLOBALS._player.setup(3157, 4, 5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 62: - // No break on purpose - case 72: - // No break on purpose - case 98: - R2_GLOBALS._player.setup(3156, 4, 6); - _sceneMode = 1; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 70: - // No break on purpose - case 75: - // No break on purpose - case 80: - R2_GLOBALS._player.setup(3156, 6, 1); - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 71: - // No break on purpose - case 76: - // No break on purpose - case 97: - R2_GLOBALS._player.setup(3157, 3, 1); - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 77: - // No break on purpose - case 111: - // No break on purpose - case 116: - R2_GLOBALS._player.setup(3157, 4, 1); - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 78: - // No break on purpose - case 102: - // No break on purpose - case 112: - R2_GLOBALS._player.setup(3156, 1, 6); - _sceneMode = 1; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 81: - R2_GLOBALS._player.setup(3157, 2, 5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 90: - // No break on purpose - case 95: - // No break on purpose - case 100: - R2_GLOBALS._player.setup(3156, 7, 1); - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 101: - R2_GLOBALS._player.setup(3157, 1, 5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 110: - // No break on purpose - case 115: - // No break on purpose - case 120: - R2_GLOBALS._player.setup(3156, 8, 1); - R2_GLOBALS._player._numFrames = 5; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 121: - R2_GLOBALS._player.setup(3157, 3, 5); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - default: - // CHECKME: The original is walling _eventManager.waitEvent(); - _sceneMode = 2; + case 2: + if (R2_GLOBALS._sceneManager._previousScene == 1530) + R2_GLOBALS._sceneManager.changeScene(1550); + else + R2_GLOBALS._sceneManager.changeScene(1530); + default: break; } } -void Scene1200::process(Event &event) { - if (_field414 != 0) - return; +/*-------------------------------------------------------------------------- + * Scene 1530 - Cutscene - Crashing on Rimwall + * + *--------------------------------------------------------------------------*/ - Scene::process(event); +void Scene1530::postInit(SceneObjectList *OwnerList) { + if (R2_GLOBALS._sceneManager._previousScene == 1000) + loadScene(1650); + else if (R2_GLOBALS._sceneManager._previousScene == 1580) + loadScene(1550); + else + loadScene(1530); - if (!R2_GLOBALS._player._canWalk) - return; + R2_GLOBALS._uiElements._active = false; + SceneExt::postInit(); + R2_GLOBALS._interfaceY = SCREEN_HEIGHT; - if (event.eventType == EVENT_BUTTON_DOWN) { - Common::Point cellPos = R2_GLOBALS._ventCellPos; - _mazeUI.pixelToCellXY(cellPos); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - int cellId = _mazeUI.getCellFromPixelXY(event.mousePos); - switch (R2_GLOBALS._events.getCursor()) { - case CURSOR_WALK: - event.handled = true; - if ((event.mousePos.x > 179) && (event.mousePos.x < 210) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) - startCrawling(CRAWL_EAST); + if (R2_GLOBALS._sceneManager._previousScene == 1000) { + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.disableControl(); - if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) - startCrawling(CRAWL_WEST); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(538, this); + R2_GLOBALS._sound1.play(114); - if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120)) - startCrawling(CRAWL_SOUTH); + _sceneMode = 3; + } else if (R2_GLOBALS._sceneManager._previousScene == 1580) { + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player._characterIndex = R2_QUINN; + R2_GLOBALS._player.setObjectWrapper(NULL); + R2_GLOBALS._player.setup(1516, 6, 1); + R2_GLOBALS._player.setPosition(Common::Point(160, 125)); + R2_GLOBALS._player._moveRate = 30; + R2_GLOBALS._player._moveDiff = Common::Point(4, 1); - if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50)) - startCrawling(CRAWL_NORTH); - break; - case CURSOR_USE: - if (cellId > 36) { - if ( ((cellPos.x == 3) && (cellPos.y == 33)) - || ((cellPos.x == 7) && (cellPos.y == 33)) - || ((cellPos.x == 33) && (cellPos.y == 41)) - || ((cellPos.x == 5) && (cellPos.y == 5)) - || ((cellPos.x == 13) && (cellPos.y == 21)) - || ((cellPos.x == 17) && (cellPos.y == 21)) - || ((cellPos.x == 17) && (cellPos.y == 5)) - || ((cellPos.x == 17) && (cellPos.y == 9)) - || ((cellPos.x == 29) && (cellPos.y == 17)) - || ((cellPos.x == 33) && (cellPos.y == 17)) - || ((cellPos.x == 35) && (cellPos.y == 17)) - || ((cellPos.x == 41) && (cellPos.y == 21)) ) { - _laserPanel.postInit(); - event.handled = true; - } - } + _leftReactor.postInit(); + _leftReactor.setup(1516, 7, 1); + _leftReactor.setPosition(Common::Point(121, 41)); + _leftReactor.animate(ANIM_MODE_2, NULL); - if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { - if ( ((cellPos.x == 3) && (cellPos.y == 9)) - || ((cellPos.x == 11) && (cellPos.y == 27)) - || ((cellPos.x == 17) && (cellPos.y == 7)) - || ((cellPos.x == 17) && (cellPos.y == 27)) - || ((cellPos.x == 17) && (cellPos.y == 33)) - || (cellPos.x == 33) ) { - switch (cellPos.x) { - case 3: - R2_GLOBALS._sceneManager.changeScene(3150); - break; - case 33: - if (R2_GLOBALS._scientistConvIndex >= 4) - R2_GLOBALS._sceneManager.changeScene(3250); - else - SceneItem::display(1200, 6, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END); - break; - default: - SceneItem::display(1200, 5, 0, 280, 1, 160, 9, 1, 2, 20, 7, 154, LIST_END); - break; - } - event.handled = true; - } - } - break; - case CURSOR_LOOK: - if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { - event.handled = true; - switch (cellPos.x) { - case 3: - // It was your cell. - SceneItem::display(1200, 8, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 9: - R2_GLOBALS._sceneManager.changeScene(3240); - break; - case 11: - if (cellPos.y == 27) - R2_GLOBALS._sceneManager.changeScene(3210); - else - // A vent grill - SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 17: - switch (cellPos.y) { - case 5: - R2_GLOBALS._sceneManager.changeScene(3230); - break; - case 21: - R2_GLOBALS._sceneManager.changeScene(3220); - break; - case 33: - R2_GLOBALS._sceneManager.changeScene(3200); - break; - default: - // A vent grill - SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - } - break; - case 33: - R2_GLOBALS._sceneManager.changeScene(3245); - break; - default: - SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - } - } - if (cellId > 36) { - // "An anti-pest laser" - event.handled = true; - SceneItem::display(1200, 9, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - } - break; - case CURSOR_TALK: - event.handled = true; - break; - default: - return; - } - } else if (event.eventType == EVENT_KEYPRESS) { - if (_field414) { - event.handled = false; - return; - } + _rightReactor.postInit(); + _rightReactor.setup(1516, 8, 1); + _rightReactor.setPosition(Common::Point(107, 116)); + _rightReactor.animate(ANIM_MODE_2, NULL); - switch (event.kbd.keycode) { - case Common::KEYCODE_KP8: - case Common::KEYCODE_UP: - startCrawling(CRAWL_NORTH); - break; - case Common::KEYCODE_KP4: - case Common::KEYCODE_LEFT: - startCrawling(CRAWL_WEST); - break; - case Common::KEYCODE_KP6: - case Common::KEYCODE_RIGHT: - startCrawling(CRAWL_EAST); - break; - case Common::KEYCODE_KP2: - case Common::KEYCODE_DOWN: - startCrawling(CRAWL_SOUTH); - break; - default: - event.handled = false; - return; - break; - } - } else - return; -} + R2_GLOBALS._player.disableControl(); + Common::Point pt(480, 75); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + R2_GLOBALS._sound1.play(111); -void Scene1200::dispatch() { - Rect tmpRect; - Scene::dispatch(); + _sceneMode = 1; + } else { + _seeker.postInit(); + _seeker._effect = EFFECT_SHADED; - if (_fixupMaze) { - _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); - //_mazeUI.draw(); - _fixupMaze = false; - } + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.disableControl(); - if (_field414 != 0) { - tmpRect.set(110, 20, 210, 120); - _field414--; + setAction(&_sequenceManager, this, 1530, &R2_GLOBALS._player, &_seeker, NULL); - switch (_nextCrawlDirection) { - case CRAWL_EAST: - R2_GLOBALS._ventCellPos.x += 2; - break; - case CRAWL_WEST: - R2_GLOBALS._ventCellPos.x -= 2; - break; - case CRAWL_SOUTH: - R2_GLOBALS._ventCellPos.y += 2; - break; - case CRAWL_NORTH: - R2_GLOBALS._ventCellPos.y -= 2; - break; - default: - break; - } + _sceneMode = 2; + } - _mazeUI.setMazePosition(R2_GLOBALS._ventCellPos); - //_mazeUI.draw(); +} - if (_field416 != 0) { - switch(_nextCrawlDirection) { - case CRAWL_EAST: - R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x - 2, R2_GLOBALS._player._position.y)); - break; - case CRAWL_WEST: - R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x + 2, R2_GLOBALS._player._position.y)); - break; - case CRAWL_SOUTH: - R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 2)); - break; - case CRAWL_NORTH: - R2_GLOBALS._player.setPosition(Common::Point(R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 2)); - break; - default: - break; - } - } - if (_field414 == 0) { - if (_field416 == 0) - R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); - signal(); - } +void Scene1530::signal() { + switch (_sceneMode - 1) { + case 0: + R2_GLOBALS._sceneManager.changeScene(1000); + break; + case 1: + R2_GLOBALS._sceneManager.changeScene(1525); + break; + case 2: + R2_GLOBALS._player.disableControl(); + _sceneMode = 4; + R2_GLOBALS._player.show(); + setAction(&_sequenceManager, this, 1650, &R2_GLOBALS._player, NULL); + break; + case 3: + R2_GLOBALS._sceneManager.changeScene(1700); + break; + default: + break; } } -void Scene1200::saveCharacter(int characterIndex) { - R2_GLOBALS._sound1.fadeOut2(NULL); - SceneExt::saveCharacter(characterIndex); +void Scene1530::dispatch() { + int16 x = R2_GLOBALS._player._position.x; + int16 y = R2_GLOBALS._player._position.y; + + _leftReactor.setPosition(Common::Point(x - 39, y - 85)); + _rightReactor.setPosition(Common::Point(x - 53, y - 9)); + + Scene::dispatch(); } -void Scene1200::startCrawling(CrawlDirection dir) { - Common::Point cellPos = R2_GLOBALS._ventCellPos; - _mazeUI.pixelToCellXY(cellPos); +/*-------------------------------------------------------------------------- + * Scene 1550 - Spaceport + * + *--------------------------------------------------------------------------*/ - switch (dir) { - case CRAWL_EAST: - if ( ((_mazeUI.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(200, 88)) > 36)) - && ( ((cellPos.x == 3) && (cellPos.y == 33) && (_field418 != 4)) - || ((cellPos.x == 13) && (cellPos.y == 21) && (_field418 != 2)) - || ((cellPos.x == 29) && (cellPos.y == 17) && (_field418 != 1)) - || ((cellPos.x == 33) && (cellPos.y == 41)) ) - ) { - R2_GLOBALS._player.disableControl(); - _sceneMode = 1200; - setAction(&_sequenceManager, this, 1200, &_actor1, NULL); - } else if (_mazeUI.getCellFromPixelXY(Common::Point(200, 69)) == 36) { - switch (_nextCrawlDirection) { - case CRAWL_EAST: - if (R2_GLOBALS._player._visage == 3155) - _sceneMode = 15; - else - _sceneMode = 10; - break; - case CRAWL_WEST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 76; - else - _sceneMode = 75; - break; - case CRAWL_SOUTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 101; - else - _sceneMode = 100; - break; - case CRAWL_NORTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 111; - else - _sceneMode = 110; - break; - default: - break; - } - R2_GLOBALS._player.disableControl(); - _nextCrawlDirection = 1; - signal(); - } - break; - case CRAWL_WEST: - if ( ((_mazeUI.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(120, 88)) > 36)) - && ( ((cellPos.x == 7) && (cellPos.y == 33) && (_field418 != 4)) - || ((cellPos.x == 17) && (cellPos.y == 21) && (_field418 != 2)) - || ((cellPos.x == 33) && (cellPos.y == 17) && (_field418 != 1)) - || ((cellPos.x == 5) && (cellPos.y == 5)) ) - ) { - R2_GLOBALS._player.disableControl(); - _sceneMode = 1201; - setAction(&_sequenceManager, this, 1201, &_actor1, NULL); - } else if (_mazeUI.getCellFromPixelXY(Common::Point(120, 69)) == 36) { - switch (_nextCrawlDirection) { - case CRAWL_EAST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 56; - else - _sceneMode = 55; - break; - case CRAWL_WEST: - if (R2_GLOBALS._player._visage == 3155) - _sceneMode = 25; - else - _sceneMode = 20; - break; - case CRAWL_SOUTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 91; - else - _sceneMode = 90; - break; - case CRAWL_NORTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 121; - else - _sceneMode = 120; - break; - default: - break; - } +Scene1550::Junk::Junk() { + _junkNumber = 0; +} + +void Scene1550::Junk::synchronize(Serializer &s) { + SceneActor::synchronize(s); + + s.syncAsSint16LE(_junkNumber); +} + +bool Scene1550::Junk::startAction(CursorType action, Event &event) { + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + if (_visage == 1561) { R2_GLOBALS._player.disableControl(); - _nextCrawlDirection = 2; - signal(); + scene->_sceneMode = 40; + Common::Point pt(_position.x + 5, _position.y + 20); + PlayerMover *mover = new PlayerMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); + return true; } + return SceneActor::startAction(action, event); break; - case CRAWL_SOUTH: - if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 110)) > 36)) - && ( ((cellPos.x == 17) && (cellPos.y == 5) && (_field418 != 3)) - || ((cellPos.x == 41) && (cellPos.y == 21)) ) - ) { - R2_GLOBALS._player.disableControl(); - _sceneMode = 1203; - setAction(&_sequenceManager, this, 1203, &_actor1, NULL); - } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 110)) == 36) { - switch (_nextCrawlDirection) { - case CRAWL_EAST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 51; - else - _sceneMode = 50; - break; - case CRAWL_WEST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 81; - else - _sceneMode = 80; + case CURSOR_LOOK: + if (_visage == 1561) { + switch (_frame) { + case 2: + SceneItem::display(1550, 23, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; - case CRAWL_SOUTH: - if (R2_GLOBALS._player._visage == 3155) - _sceneMode = 35; - else - _sceneMode = 30; + case 3: + SceneItem::display(1550, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; - case CRAWL_NORTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 116; - else - _sceneMode = 115; + case 4: + SceneItem::display(1550, 35, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; default: break; } - R2_GLOBALS._player.disableControl(); - _nextCrawlDirection = 3; - signal(); - } - break; - case CRAWL_NORTH: - if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 30)) > 36)) - && ( ((cellPos.x == 17) && (cellPos.y == 9) && (_field418 != 3)) - || ((cellPos.x == 35) && (cellPos.y == 17)) ) - ) { - R2_GLOBALS._player.disableControl(); - _sceneMode = 1202; - setAction(&_sequenceManager, this, 1202, &_actor1, NULL); - } else if (_mazeUI.getCellFromPixelXY(Common::Point(160, 30)) == 36) { - switch (_nextCrawlDirection) { - case CRAWL_EAST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 61; - else - _sceneMode = 60; - break; - case CRAWL_WEST: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 71; - else - _sceneMode = 70; + } else { + switch ((((_strip - 1) * 5) + _frame) % 3) { + case 0: + SceneItem::display(1550, 62, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; - case CRAWL_SOUTH: - if (R2_GLOBALS._player._visage == 3156) - _sceneMode = 96; - else - _sceneMode = 95; + case 1: + SceneItem::display(1550, 53, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; - case CRAWL_NORTH: - if (R2_GLOBALS._player._visage == 3155) - _sceneMode = 45; - else - _sceneMode = 40; + case 2: + SceneItem::display(1550, 76, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); break; default: - _sceneMode = 1; - R2_GLOBALS._player.setup(3156, 4, 6); break; } - R2_GLOBALS._player.disableControl(); - _nextCrawlDirection = 4; - signal(); } + return true; break; default: + return SceneActor::startAction(action, event); break; } } -/*-------------------------------------------------------------------------- - * Scene 1500 - Cutscene: Ship landing - * - *--------------------------------------------------------------------------*/ - -void Scene1500::postInit(SceneObjectList *OwnerList) { - loadScene(1500); - R2_GLOBALS._uiElements._active = false; - setZoomPercents(170, 13, 240, 100); - SceneExt::postInit(); - R2_GLOBALS._interfaceY = SCREEN_HEIGHT; - - scalePalette(65, 65, 65); - - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); - R2_GLOBALS._player.disableControl(); - - _starshipShadow.postInit(); - _starshipShadow.setup(1401, 1, 1); - _starshipShadow._effect = EFFECT_SHADOW_MAP; - _starshipShadow.fixPriority(10); - _starshipShadow._shadowMap = _shadowPaletteMap; - - _starship.postInit(); - _starship.setup(1400, 1, 1); - _starship._moveDiff = Common::Point(1, 1); - _starship._linkedActor = &_starshipShadow; - - if (R2_GLOBALS._sceneManager._previousScene != 1010) { - _smallShipShadow.postInit(); - _smallShipShadow.setup(1401, 2, 1); - _smallShipShadow._effect = EFFECT_SHADOW_MAP; - _smallShipShadow.fixPriority(10); - _smallShipShadow._shadowMap = _shadowPaletteMap; - - _smallShip.postInit(); - _smallShip._moveRate = 30; - _smallShip._moveDiff = Common::Point(1, 1); - _smallShip._linkedActor = &_smallShipShadow; - } - - if (R2_GLOBALS._sceneManager._previousScene == 300) { - _starship.setPosition(Common::Point(189, 139), 5); - - _smallShip.setup(1400, 1, 2); - _smallShip.setPosition(Common::Point(148, 108), 0); - - _sceneMode = 20; - R2_GLOBALS._sound1.play(110); - } else if (R2_GLOBALS._sceneManager._previousScene == 1550) { - _starship.setPosition(Common::Point(189, 139), 5); - - _smallShip.setup(1400, 2, 1); - _smallShip.changeZoom(-1); - _smallShip.setPosition(Common::Point(298, 258), 5); - - _sceneMode = 10; - R2_GLOBALS._sound1.play(106); - } else { - _starship.setPosition(Common::Point(289, 239), -30); - _sceneMode = 0; - R2_GLOBALS._sound1.play(102); - } - - signal(); +Scene1550::ShipComponent::ShipComponent() { + _componentId = 0; } -void Scene1500::remove() { - R2_GLOBALS._uiElements._active = true; - R2_GLOBALS._uiElements._visible = true; +void Scene1550::ShipComponent::synchronize(Serializer &s) { + SceneActor::synchronize(s); - SceneExt::remove(); + s.syncAsSint16LE(_componentId); } -void Scene1500::signal() { - switch(_sceneMode++) { - case 0: - R2_GLOBALS.setFlag(25); - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - // No break on purpose - case 1: - if (_starship._yDiff < 50) { - _starship.setPosition(Common::Point(289, 239), _starship._yDiff + 1); - _sceneMode = 1; - } - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 2: { - Common::Point pt(189, 139); - NpcMover *mover = new NpcMover(); - _starship.addMover(mover, &pt, this); - } - break; - case 3: - if (_starship._yDiff > 5) { - _starship.setPosition(Common::Point(189, 139), _starship._yDiff - 1); - _sceneMode = 3; +bool Scene1550::ShipComponent::startAction(CursorType action, Event &event) { + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + if (_componentId == 8) { + scene->_dontExit = true; + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1576; + else + scene->_sceneMode = 1584; + // strcpy(scene->_shipComponents[7]._actorName, 'hatch'); + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[7], NULL); + return true; } - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; - case 13: - R2_GLOBALS._player._characterIndex = R2_MIRANDA; - // No break on purpose - case 4: - R2_GLOBALS._sceneManager.changeScene(300); + return SceneActor::startAction(action, event); break; - case 10: - // No break on purpose - case 20: - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + case CURSOR_LOOK: + if (_componentId == 8) + SceneItem::display(1550, 75, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + else if (_frame == 1) + SceneItem::display(1550, 70, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + else + SceneItem::display(1550, 71, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + return true; break; - case 11: { - Common::Point pt(148, 108); - NpcMover *mover = new NpcMover(); - _smallShip.addMover(mover, &pt, this); + case R2_FUEL_CELL: + scene->_dontExit = true; + if (_componentId == 6) { + R2_GLOBALS._player.disableControl(); + scene->_wreckage2.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1574; + else + scene->_sceneMode = 1582; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[5], &scene->_wreckage2, NULL); + return true; } + return SceneActor::startAction(action, event); break; - case 12: - setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); - break; - case 21: { - Common::Point pt(-2, -42); - NpcMover *mover = new NpcMover(); - _smallShip.addMover(mover, &pt, NULL); - signal(); + case R2_GYROSCOPE: + scene->_dontExit = true; + if (_componentId == 3) { + R2_GLOBALS._player.disableControl(); + scene->_wreckage2.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1571; + else + scene->_sceneMode = 1581; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[2], &scene->_wreckage2, NULL); + return true; } + return SceneActor::startAction(action, event); break; - case 22: - if (_starship._yDiff < 50) { - _starship.setPosition(Common::Point(189, 139), _starship._yDiff + 1); - _sceneMode = 22; + case R2_GUIDANCE_MODULE: + scene->_dontExit = true; + if (_componentId == 1) { + R2_GLOBALS._player.disableControl(); + scene->_wreckage2.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1569; + else + scene->_sceneMode = 1579; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[0], &scene->_wreckage2, NULL); + return true; } - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + return SceneActor::startAction(action, event); break; - case 23: { - Common::Point pt(-13, -61); - NpcMover *mover = new NpcMover(); - _starship.addMover(mover, &pt, this); + case R2_THRUSTER_VALVE: + scene->_dontExit = true; + if (_componentId == 4) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1572; + scene->_wreckage2.postInit(); + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[3], &scene->_wreckage2, NULL); + return true; } + return SceneActor::startAction(action, event); break; - case 24: - R2_GLOBALS._sceneManager.changeScene(1550); + case R2_RADAR_MECHANISM: + scene->_dontExit = true; + if (_componentId == 2) { + R2_GLOBALS._player.disableControl(); + scene->_wreckage2.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1570; + else + scene->_sceneMode = 1580; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[1], &scene->_wreckage2, NULL); + return true; + } + return SceneActor::startAction(action, event); + break; + case R2_IGNITOR: + scene->_dontExit = true; + if (_componentId == 5) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1573; + scene->_wreckage2.postInit(); + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[4], &scene->_wreckage2, NULL); + return true; + } + return SceneActor::startAction(action, event); + break; + case R2_BATTERY: + scene->_dontExit = true; + if (_componentId == 7) { + R2_GLOBALS._player.disableControl(); + scene->_wreckage2.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1575; + else + scene->_sceneMode = 1583; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[6], &scene->_wreckage2, NULL); + return true; + } + return SceneActor::startAction(action, event); break; default: + return SceneActor::startAction(action, event); break; } } -void Scene1500::dispatch() { - if (_sceneMode > 10) { - float yDiff = sqrt((float) (_smallShip._position.x * _smallShip._position.x) + (_smallShip._position.y * _smallShip._position.y)); - if (yDiff > 6) - _smallShip.setPosition(_smallShip._position, (int) yDiff); +void Scene1550::ShipComponent::setupShipComponent(int componentId) { + _componentId = componentId; + postInit(); + setup(1517, _componentId, 1); + + switch (_componentId) { + case 1: + if (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) == 0) + setFrame(5); + setPosition(Common::Point(287, 85)); + break; + case 2: + if (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) == 0) + setFrame(5); + setPosition(Common::Point(248, 100)); + break; + case 3: + if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 0) + setFrame(5); + setPosition(Common::Point(217, 85)); + break; + case 4: + if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 0) + setFrame(5); + setPosition(Common::Point(161, 121)); + break; + case 5: + if (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 0) + setFrame(5); + setPosition(Common::Point(117, 121)); + break; + case 6: + if (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) == 0) + setFrame(5); + setPosition(Common::Point(111, 85)); + break; + case 7: + if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 0) + setFrame(5); + setPosition(Common::Point(95, 84)); + break; + case 8: { + setup(1516, 1, 1); + setPosition(Common::Point(201, 45)); + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + if ((scene->_sceneMode == 1577) || (scene->_sceneMode == 1578)) + hide(); + fixPriority(92); + setDetails(1550, 70, -1, -1, 2, (SceneItem *) NULL); + } + break; + default: + break; } - Scene::dispatch(); + fixPriority(92); + setDetails(1550, 70, -1, -1, 2, (SceneItem *)NULL); } -/*-------------------------------------------------------------------------- - * Scene 1525 - Cutscene - Ship - * - *--------------------------------------------------------------------------*/ - -void Scene1525::postInit(SceneObjectList *OwnerList) { - loadScene(1525); - R2_GLOBALS._uiElements._active = false; - SceneExt::postInit(); +Scene1550::DishControlsWindow::DishControl::DishControl() { + _controlId = 0; +} - R2_GLOBALS._player.postInit(); - if (R2_GLOBALS._sceneManager._previousScene == 525) - R2_GLOBALS._player.setup(1525, 1, 1); - else - R2_GLOBALS._player.setup(1525, 1, 16); - R2_GLOBALS._player.setPosition(Common::Point(244, 148)); - R2_GLOBALS._player.disableControl(); +void Scene1550::DishControlsWindow::DishControl::synchronize(Serializer &s) { + SceneActor::synchronize(s); - _sceneMode = 0; - setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); + s.syncAsSint16LE(_controlId); } -void Scene1525::signal() { - switch (_sceneMode++) { - case 0: - if (R2_GLOBALS._sceneManager._previousScene == 525) - setAction(&_sequenceManager, this, 1525, &R2_GLOBALS._player, NULL); - else - setAction(&_sequenceManager, this, 1526, &R2_GLOBALS._player, NULL); - break; +bool Scene1550::DishControlsWindow::DishControl::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + + switch (_controlId) { case 1: - setAction(&_sequenceManager, this, 2, &R2_GLOBALS._player, NULL); + // Button control + if (scene->_dish._frame == 5) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 25; + if (scene->_walkway._frame == 1) { + scene->setAction(&scene->_sequenceManager1, scene, 1560, &scene->_walkway, NULL); + R2_GLOBALS.setFlag(20); + setFrame(2); + } else { + scene->setAction(&scene->_sequenceManager1, scene, 1561, &scene->_walkway, NULL); + R2_GLOBALS.clearFlag(20); + setFrame(1); + } + scene->_dishControlsWindow.remove(); + } break; case 2: - if (R2_GLOBALS._sceneManager._previousScene == 1530) - R2_GLOBALS._sceneManager.changeScene(1550); - else - R2_GLOBALS._sceneManager.changeScene(1530); + // Lever control + R2_GLOBALS._player.disableControl(); + if (scene->_dish._frame == 1) { + scene->_sceneMode = 23; + scene->setAction(&scene->_sequenceManager1, scene, 1560, this, NULL); + } else { + if (scene->_walkway._frame == 1) + scene->_sceneMode = 24; + else + scene->_sceneMode = 22; + scene->setAction(&scene->_sequenceManager1, scene, 1561, this, NULL); + } + break; default: break; } + return true; } -/*-------------------------------------------------------------------------- - * Scene 1530 - Cutscene - Crashing on Rimwall - * - *--------------------------------------------------------------------------*/ +void Scene1550::DishControlsWindow::remove() { + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; -void Scene1530::postInit(SceneObjectList *OwnerList) { - if (R2_GLOBALS._sceneManager._previousScene == 1000) - loadScene(1650); - else if (R2_GLOBALS._sceneManager._previousScene == 1580) - loadScene(1550); - else - loadScene(1530); + _button.remove(); + _lever.remove(); - R2_GLOBALS._uiElements._active = false; - SceneExt::postInit(); - R2_GLOBALS._interfaceY = SCREEN_HEIGHT; + ModalWindow::remove(); - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); + if ((scene->_sceneMode >= 20) && (scene->_sceneMode <= 29)) + return; - if (R2_GLOBALS._sceneManager._previousScene == 1000) { - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); - R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.disableControl(); + if (scene->_walkway._frame == 1) { + scene->_sceneMode = 1559; + scene->setAction(&scene->_sequenceManager1, scene, 1559, &R2_GLOBALS._player, NULL); + } else { + scene->_sceneMode = 1562; + scene->setAction(&scene->_sequenceManager1, scene, 1562, &R2_GLOBALS._player, NULL); + } +} - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(538, this); - R2_GLOBALS._sound1.play(114); +void Scene1550::DishControlsWindow::setup2(int visage, int stripFrameNum, int frameNum, + int posX, int posY) { + // Call inherited setup + ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY); - _sceneMode = 3; - } else if (R2_GLOBALS._sceneManager._previousScene == 1580) { - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player._characterIndex = R2_QUINN; - R2_GLOBALS._player.setObjectWrapper(NULL); - R2_GLOBALS._player.setup(1516, 6, 1); - R2_GLOBALS._player.setPosition(Common::Point(160, 125)); - R2_GLOBALS._player._moveRate = 30; - R2_GLOBALS._player._moveDiff = Common::Point(4, 1); + // Further setup + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + setup3(1550, 67, -1, -1); + _button.postInit(); + _button._controlId = 1; + if (scene->_walkway._frame == 1) + _button.setup(1559, 3, 1); + else + _button.setup(1559, 3, 2); + _button.setPosition(Common::Point(142, 79)); + _button.fixPriority(251); + _button.setDetails(1550, 68, -1, -1, 2, (SceneItem *) NULL); - _leftReactor.postInit(); - _leftReactor.setup(1516, 7, 1); - _leftReactor.setPosition(Common::Point(121, 41)); - _leftReactor.animate(ANIM_MODE_2, NULL); + _lever.postInit(); + _lever._numFrames = 5; + _lever._controlId = 2; + if (scene->_dish._frame == 1) + _lever.setup(1559, 2, 1); + else + _lever.setup(1559, 2, 5); + _lever.setPosition(Common::Point(156, 103)); + _lever.fixPriority(251); + _lever.setDetails(1550, 69, -1, -1, 2, (SceneItem *) NULL); +} - _rightReactor.postInit(); - _rightReactor.setup(1516, 8, 1); - _rightReactor.setPosition(Common::Point(107, 116)); - _rightReactor.animate(ANIM_MODE_2, NULL); +bool Scene1550::WorkingShip::startAction(CursorType action, Event &event) { + return SceneHotspot::startAction(action, event); +} - R2_GLOBALS._player.disableControl(); - Common::Point pt(480, 75); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - R2_GLOBALS._sound1.play(111); +bool Scene1550::Wreckage::startAction(CursorType action, Event &event) { + return SceneActor::startAction(action, event); +} - _sceneMode = 1; - } else { - _seeker.postInit(); - _seeker._effect = EFFECT_SHADED; +bool Scene1550::Companion::startAction(CursorType action, Event &event) { + if (action != CURSOR_TALK) + return SceneActor::startAction(action, event); - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.disableControl(); + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + scene->_sceneMode = 80; + scene->signal(); - setAction(&_sequenceManager, this, 1530, &R2_GLOBALS._player, &_seeker, NULL); + return true; +} - _sceneMode = 2; - } +bool Scene1550::AirBag::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + scene->_dontExit = true; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1552; + else + scene->_sceneMode = 1588; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_airbag, NULL); + return true; } -void Scene1530::signal() { - switch (_sceneMode - 1) { - case 0: - R2_GLOBALS._sceneManager.changeScene(1000); - break; - case 1: - R2_GLOBALS._sceneManager.changeScene(1525); - break; - case 2: +bool Scene1550::Joystick::startAction(CursorType action, Event &event) { + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + scene->_sceneMode = 50; R2_GLOBALS._player.disableControl(); - _sceneMode = 4; - R2_GLOBALS._player.show(); - setAction(&_sequenceManager, this, 1650, &R2_GLOBALS._player, NULL); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_stripManager.start(518, scene); + else + scene->_stripManager.start(520, scene); + return true; break; - case 3: - R2_GLOBALS._sceneManager.changeScene(1700); + case CURSOR_LOOK: + SceneItem::display(1550, 41, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + return true; break; default: - break; + return SceneActor::startAction(action, event); } } -void Scene1530::dispatch() { - int16 x = R2_GLOBALS._player._position.x; - int16 y = R2_GLOBALS._player._position.y; +bool Scene1550::Gyroscope::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); - _leftReactor.setPosition(Common::Point(x - 39, y - 85)); - _rightReactor.setPosition(Common::Point(x - 53, y - 9)); + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1555; + else + scene->_sceneMode = 1589; - Scene::dispatch(); + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, + &scene->_gyroscope, NULL); + return true; } -/*-------------------------------------------------------------------------- - * Scene 1550 - Spaceport - * - *--------------------------------------------------------------------------*/ +bool Scene1550::DiagnosticsDisplay::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); -Scene1550::Junk::Junk() { - _junkNumber = 0; + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.disableControl(); + scene->_dontExit = true; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_sceneMode = 1586; + else + scene->_sceneMode = 1587; + + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, + &scene->_diagnosticsDisplay, NULL); + return true; } -void Scene1550::Junk::synchronize(Serializer &s) { - SceneActor::synchronize(s); +bool Scene1550::DishTower::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; + + if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1585; + scene->setAction(&scene->_sequenceManager1, scene, 1585, &R2_GLOBALS._player, NULL); + } else { + R2_GLOBALS._player.disableControl(); + switch(scene->_dishMode) { + case 0: + scene->_dish.fixPriority(168); + scene->_walkway.fixPriority(125); + scene->_sceneMode = 1558; + scene->setAction(&scene->_sequenceManager1, scene, 1558, &R2_GLOBALS._player, NULL); + break; + case 1: + return SceneActor::startAction(action, event); + break; + case 2: + scene->_dishMode = 1; + scene->_sceneMode = 1563; + scene->setAction(&scene->_sequenceManager1, scene, 1563, &R2_GLOBALS._player, &scene->_walkway, NULL); + break; + default: + break; + } + } + return true; - s.syncAsSint16LE(_junkNumber); } -bool Scene1550::Junk::startAction(CursorType action, Event &event) { +bool Scene1550::Dish::startAction(CursorType action, Event &event) { Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; switch (action) { case CURSOR_USE: - if (_visage == 1561) { + if (scene->_dishMode != 2) + return SceneActor::startAction(action, event); + + if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 1550) { R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 40; - Common::Point pt(_position.x + 5, _position.y + 20); - PlayerMover *mover = new PlayerMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - return true; - } - return SceneActor::startAction(action, event); + scene->_sceneMode = 1564; + scene->setAction(&scene->_sequenceManager1, scene, 1564, &R2_GLOBALS._player, NULL); + } else + SceneItem::display(1550, 64, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + return true; break; case CURSOR_LOOK: - if (_visage == 1561) { - switch (_frame) { - case 2: - SceneItem::display(1550, 23, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 3: - SceneItem::display(1550, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 4: - SceneItem::display(1550, 35, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - default: - break; - } - } else { - switch ((((_strip - 1) * 5) + _frame) % 3) { - case 0: - SceneItem::display(1550, 62, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 1: - SceneItem::display(1550, 53, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - case 2: - SceneItem::display(1550, 76, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - break; - default: - break; - } - } + if (scene->_dishMode != 2) + return SceneActor::startAction(action, event); + + if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 1550) { + SceneItem::display(1550, 74, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + } else + SceneItem::display(1550, 64, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); return true; break; default: @@ -2572,758 +2150,301 @@ bool Scene1550::Junk::startAction(CursorType action, Event &event) { } } -Scene1550::ShipComponent::ShipComponent() { - _componentId = 0; +/*--------------------------------------------------------------------------*/ + +Scene1550::Scene1550() { + _dontExit = false; + _wallType = 0; + _dishMode = 0; + _sceneResourceId = 0; + _walkRegionsId = 0; } -void Scene1550::ShipComponent::synchronize(Serializer &s) { - SceneActor::synchronize(s); +void Scene1550::synchronize(Serializer &s) { + SceneExt::synchronize(s); - s.syncAsSint16LE(_componentId); + s.syncAsSint16LE(_dontExit); + s.syncAsByte(_wallType); + s.syncAsSint16LE(_dishMode); + s.syncAsSint16LE(_sceneResourceId); + s.syncAsSint16LE(_walkRegionsId); } -bool Scene1550::ShipComponent::startAction(CursorType action, Event &event) { - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - switch (action) { - case CURSOR_USE: - if (_componentId == 8) { - scene->_dontExit = true; - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1576; - else - scene->_sceneMode = 1584; - // strcpy(scene->_shipComponents[7]._actorName, 'hatch'); - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[7], NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case CURSOR_LOOK: - if (_componentId == 8) - SceneItem::display(1550, 75, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - else if (_frame == 1) - SceneItem::display(1550, 70, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - else - SceneItem::display(1550, 71, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - return true; - break; - case R2_FUEL_CELL: - scene->_dontExit = true; - if (_componentId == 6) { - R2_GLOBALS._player.disableControl(); - scene->_wreckage2.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1574; - else - scene->_sceneMode = 1582; - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[5], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case R2_GYROSCOPE: - scene->_dontExit = true; - if (_componentId == 3) { - R2_GLOBALS._player.disableControl(); - scene->_wreckage2.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1571; - else - scene->_sceneMode = 1581; - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[2], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case R2_GUIDANCE_MODULE: - scene->_dontExit = true; - if (_componentId == 1) { - R2_GLOBALS._player.disableControl(); - scene->_wreckage2.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1569; - else - scene->_sceneMode = 1579; - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[0], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case R2_THRUSTER_VALVE: - scene->_dontExit = true; - if (_componentId == 4) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1572; - scene->_wreckage2.postInit(); - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[3], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case R2_RADAR_MECHANISM: - scene->_dontExit = true; - if (_componentId == 2) { - R2_GLOBALS._player.disableControl(); - scene->_wreckage2.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1570; - else - scene->_sceneMode = 1580; - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[1], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); - break; - case R2_IGNITOR: - scene->_dontExit = true; - if (_componentId == 5) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1573; - scene->_wreckage2.postInit(); - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[4], &scene->_wreckage2, NULL); - return true; - } - return SceneActor::startAction(action, event); +void Scene1550::postInit(SceneObjectList *OwnerList) { + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) + // Exiting the intact spaceship + loadScene(1234); + else + // Normal scene entry + loadScene(1550); + SceneExt::postInit(); + + scalePalette(65, 65, 65); + setZoomPercents(30, 75, 170, 100); + _sceneResourceId = 1550; + _walkRegionsId = 0; + + if (R2_GLOBALS._sceneManager._previousScene == -1) + R2_GLOBALS.setFlag(16); + + if ((R2_GLOBALS._player._characterScene[R2_QUINN] != 1550) && (R2_GLOBALS._player._characterScene[R2_QUINN] != 1580)) { + R2_GLOBALS._player._characterScene[R2_QUINN] = 1550; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1550; + } + + _stripManager.setColors(60, 255); + _stripManager.setFontNumber(3); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player._effect = EFFECT_SHADED2; + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + R2_GLOBALS._player.setup(1500, 3, 1); + else + R2_GLOBALS._player.setup(1505, 3, 1); + + R2_GLOBALS._player._moveDiff = Common::Point(5, 3); + + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) + R2_GLOBALS._player.setPosition(Common::Point(157, 135)); + else + R2_GLOBALS._player.setPosition(Common::Point(160, 100)); + + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.disableControl(); + + _wallType = 0; + _companion.changeZoom(-1); + R2_GLOBALS._player.changeZoom(-1); + + switch (R2_GLOBALS._sceneManager._previousScene) { + case 1530: + R2_GLOBALS._stripModifier = 0; + // No break on purpose + case 300: + // No break on purpose + case 1500: + // No break on purpose + case 3150: + R2_GLOBALS._sound1.play(105); break; - case R2_BATTERY: - scene->_dontExit = true; - if (_componentId == 7) { + case 1580: + // Leaving intact ship + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1580) { R2_GLOBALS._player.disableControl(); - scene->_wreckage2.postInit(); + R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); + + _dontExit = true; + + _wreckage2.postInit(); + _shipComponents[7].setupShipComponent(8); + _shipComponents[7].hide(); if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1575; + _sceneMode = 1577; else - scene->_sceneMode = 1583; - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_shipComponents[6], &scene->_wreckage2, NULL); - return true; + _sceneMode = 1578; + + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_wreckage2, &_shipComponents[7], NULL); + R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1550; + } else { + R2_GLOBALS._player.enableControl(); } - return SceneActor::startAction(action, event); break; default: - return SceneActor::startAction(action, event); break; } -} -void Scene1550::ShipComponent::setupShipComponent(int componentId) { - _componentId = componentId; - postInit(); - setup(1517, _componentId, 1); + enterArea(); - switch (_componentId) { + _intactHull1.setDetails(16, 1550, 10, -1, -1); + _intactHull2.setDetails(24, 1550, 10, -1, -1); + _background.setDetails(Rect(0, 0, 320, 200), 1550, 0, 1, -1, 1, NULL); + + if ((R2_GLOBALS._sceneManager._previousScene == 1500) && (R2_GLOBALS.getFlag(16))) { + _sceneMode = 70; + if (!R2_GLOBALS._sceneObjects->contains(&_companion)) + _companion.postInit(); + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _companion.setVisage(1505); + else + _companion.setVisage(1500); + + _companion.changeZoom(77); + _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); + + assert(_walkRegionsId >= 1550); + R2_GLOBALS._walkRegions.disableRegion(k5A750[_walkRegionsId - 1550]); + + setAction(&_sequenceManager1, this, 1590, &_companion, NULL); + } else if ((_sceneMode != 1577) && (_sceneMode != 1578)) + R2_GLOBALS._player.enableControl(); +} + +void Scene1550::signal() { + switch (_sceneMode) { case 1: - if (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) == 0) - setFrame(5); - setPosition(Common::Point(287, 85)); - break; - case 2: - if (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) == 0) - setFrame(5); - setPosition(Common::Point(248, 100)); - break; + // No break on purpose case 3: - if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 0) - setFrame(5); - setPosition(Common::Point(217, 85)); - break; - case 4: - if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 0) - setFrame(5); - setPosition(Common::Point(161, 121)); - break; + // No break on purpose case 5: - if (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 0) - setFrame(5); - setPosition(Common::Point(117, 121)); - break; - case 6: - if (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) == 0) - setFrame(5); - setPosition(Common::Point(111, 85)); - break; + // No break on purpose case 7: - if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 0) - setFrame(5); - setPosition(Common::Point(95, 84)); - break; - case 8: { - setup(1516, 1, 1); - setPosition(Common::Point(201, 45)); - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - if ((scene->_sceneMode == 1577) || (scene->_sceneMode == 1578)) - hide(); - fixPriority(92); - setDetails(1550, 70, -1, -1, 2, (SceneItem *) NULL); - } + _dontExit = false; + R2_GLOBALS._player.enableControl(CURSOR_WALK); break; - default: + case 20: + // No break on purpose + case 21: + // No break on purpose + case 25: + // No break on purpose + case 1563: + // Show the communication dish controls window + R2_GLOBALS.clearFlag(20); + _dishControlsWindow.setup2(1559, 1, 1, 160, 125); + R2_GLOBALS._player.enableControl(); + _sceneMode = 0; break; - } - - fixPriority(92); - setDetails(1550, 70, -1, -1, 2, (SceneItem *)NULL); -} - -Scene1550::DishControlsWindow::DishControl::DishControl() { - _controlId = 0; -} - -void Scene1550::DishControlsWindow::DishControl::synchronize(Serializer &s) { - SceneActor::synchronize(s); - - s.syncAsSint16LE(_controlId); -} - -bool Scene1550::DishControlsWindow::DishControl::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - switch (_controlId) { - case 1: - // Button control - if (scene->_dish._frame == 5) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 25; - if (scene->_walkway._frame == 1) { - scene->setAction(&scene->_sequenceManager1, scene, 1560, &scene->_walkway, NULL); - R2_GLOBALS.setFlag(20); - setFrame(2); - } else { - scene->setAction(&scene->_sequenceManager1, scene, 1561, &scene->_walkway, NULL); - R2_GLOBALS.clearFlag(20); - setFrame(1); - } - scene->_dishControlsWindow.remove(); + case 22: + _dishControlsWindow.remove(); + _sceneMode = 24; + setAction(&_sequenceManager1, this, 1561, &_walkway, NULL); + R2_GLOBALS.clearFlag(20); + break; + case 23: + _dishControlsWindow.remove(); + _sceneMode = 20; + setAction(&_sequenceManager1, this, 1566, &_dish, &_dishTowerShadow, NULL); + R2_GLOBALS.setFlag(19); + break; + case 24: + _dishControlsWindow.remove(); + _sceneMode = 21; + setAction(&_sequenceManager1, this, 1567, &_dish, &_dishTowerShadow, NULL); + R2_GLOBALS.clearFlag(19); + break; + case 30: + // No break on purpose + case 1556: + // No break on purpose + case 1557: + // Nothing on purpose + break; + case 40: { + _sceneMode = 41; + Common::Point pt(_junk[0]._position.x, _junk[0]._position.y + 20); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); } break; - case 2: - // Lever control - R2_GLOBALS._player.disableControl(); - if (scene->_dish._frame == 1) { - scene->_sceneMode = 23; - scene->setAction(&scene->_sequenceManager1, scene, 1560, this, NULL); + case 41: + _sceneMode = 42; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player.setup(1502, 8, 1); } else { - if (scene->_walkway._frame == 1) - scene->_sceneMode = 24; - else - scene->_sceneMode = 22; - scene->setAction(&scene->_sequenceManager1, scene, 1561, this, NULL); + R2_GLOBALS._player.changeZoom(R2_GLOBALS._player._percent + 14); + R2_GLOBALS._player.setup(1516, 4, 1); } - break; - default: + R2_GLOBALS._player.animate(ANIM_MODE_5, this); break; - } - return true; -} - -void Scene1550::DishControlsWindow::remove() { - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - _button.remove(); - _lever.remove(); - ModalWindow::remove(); + case 42: { + _sceneMode = 43; + int junkRegionIndex = R2_GLOBALS._scene1550JunkLocations[_junk[0]._junkNumber + 3]; + R2_GLOBALS._walkRegions.enableRegion(scene1550JunkRegions[junkRegionIndex]); - if ((scene->_sceneMode >= 20) && (scene->_sceneMode <= 29)) - return; + switch (_junk[0]._frame) { + case 1: + R2_INVENTORY.setObjectScene(R2_JOYSTICK, R2_GLOBALS._player._characterIndex); + break; + case 2: + R2_INVENTORY.setObjectScene(R2_FUEL_CELL, R2_GLOBALS._player._characterIndex); + break; + case 3: + R2_INVENTORY.setObjectScene(R2_GUIDANCE_MODULE, R2_GLOBALS._player._characterIndex); + break; + case 4: + R2_INVENTORY.setObjectScene(R2_RADAR_MECHANISM, R2_GLOBALS._player._characterIndex); + break; + case 5: + R2_INVENTORY.setObjectScene(R2_BATTERY, R2_GLOBALS._player._characterIndex); + break; + case 6: + R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, R2_GLOBALS._player._characterIndex); + break; + default: + break; + } - R2_GLOBALS._player.disableControl(); - if (scene->_walkway._frame == 1) { - scene->_sceneMode = 1559; - scene->setAction(&scene->_sequenceManager1, scene, 1559, &R2_GLOBALS._player, NULL); - } else { - scene->_sceneMode = 1562; - scene->setAction(&scene->_sequenceManager1, scene, 1562, &R2_GLOBALS._player, NULL); + _junk[0].remove(); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); + break; } -} - -void Scene1550::DishControlsWindow::setup2(int visage, int stripFrameNum, int frameNum, - int posX, int posY) { - // Call inherited setup - ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY); - - // Further setup - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - setup3(1550, 67, -1, -1); - _button.postInit(); - _button._controlId = 1; - if (scene->_walkway._frame == 1) - _button.setup(1559, 3, 1); - else - _button.setup(1559, 3, 2); - _button.setPosition(Common::Point(142, 79)); - _button.fixPriority(251); - _button.setDetails(1550, 68, -1, -1, 2, (SceneItem *) NULL); - - _lever.postInit(); - _lever._numFrames = 5; - _lever._controlId = 2; - if (scene->_dish._frame == 1) - _lever.setup(1559, 2, 1); - else - _lever.setup(1559, 2, 5); - _lever.setPosition(Common::Point(156, 103)); - _lever.fixPriority(251); - _lever.setDetails(1550, 69, -1, -1, 2, (SceneItem *) NULL); -} - -bool Scene1550::WorkingShip::startAction(CursorType action, Event &event) { - return SceneHotspot::startAction(action, event); -} - -bool Scene1550::Wreckage::startAction(CursorType action, Event &event) { - return SceneActor::startAction(action, event); -} - -bool Scene1550::Companion::startAction(CursorType action, Event &event) { - if (action != CURSOR_TALK) - return SceneActor::startAction(action, event); - - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - scene->_sceneMode = 80; - scene->signal(); - - return true; -} - -bool Scene1550::AirBag::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - R2_GLOBALS._player.disableControl(); - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - scene->_dontExit = true; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1552; - else - scene->_sceneMode = 1588; - - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_airbag, NULL); - return true; -} - -bool Scene1550::Joystick::startAction(CursorType action, Event &event) { - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - switch (action) { - case CURSOR_USE: - scene->_sceneMode = 50; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + case 43: + R2_GLOBALS._scene1550JunkLocations[_junk[0]._junkNumber + 2] = 0; if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_stripManager.start(518, scene); - else - scene->_stripManager.start(520, scene); - return true; - break; - case CURSOR_LOOK: - SceneItem::display(1550, 41, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - return true; + R2_GLOBALS._player.setVisage(1500); + else { + R2_GLOBALS._player.changeZoom(-1); + R2_GLOBALS._player.setVisage(1505); + } + R2_GLOBALS._player.animate(ANIM_MODE_1, this); + R2_GLOBALS._player.setStrip(8); + R2_GLOBALS._player.enableControl(); break; - default: - return SceneActor::startAction(action, event); - } -} - -bool Scene1550::Gyroscope::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1555; - else - scene->_sceneMode = 1589; - - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, - &scene->_gyroscope, NULL); - return true; -} - -bool Scene1550::DiagnosticsDisplay::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - scene->_dontExit = true; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_sceneMode = 1586; - else - scene->_sceneMode = 1587; - - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, - &scene->_diagnosticsDisplay, NULL); - return true; -} - -bool Scene1550::DishTower::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1585; - scene->setAction(&scene->_sequenceManager1, scene, 1585, &R2_GLOBALS._player, NULL); - } else { - R2_GLOBALS._player.disableControl(); - switch(scene->_dishMode) { - case 0: - scene->_dish.fixPriority(168); - scene->_walkway.fixPriority(125); - scene->_sceneMode = 1558; - scene->setAction(&scene->_sequenceManager1, scene, 1558, &R2_GLOBALS._player, NULL); - break; - case 1: - return SceneActor::startAction(action, event); - break; - case 2: - scene->_dishMode = 1; - scene->_sceneMode = 1563; - scene->setAction(&scene->_sequenceManager1, scene, 1563, &R2_GLOBALS._player, &scene->_walkway, NULL); - break; - default: - break; + case 50: + // Removed (useless ?) call to sub_1D227 + ++_sceneMode; + setAction(&_sequenceManager1, this, 1591, &R2_GLOBALS._player, NULL); + if (g_globals->_sceneObjects->contains(&_companion)) + signal(); + else { + _companion.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _companion.setVisage(1505); + else + _companion.setVisage(1500); + _companion.changeZoom(77); + _companion.setAction(&_sequenceManager2, this, 1590, &_companion, NULL); + _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); } - } - return true; - -} - -bool Scene1550::Dish::startAction(CursorType action, Event &event) { - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - switch (action) { - case CURSOR_USE: - if (scene->_dishMode != 2) - return SceneActor::startAction(action, event); - - if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 1550) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1564; - scene->setAction(&scene->_sequenceManager1, scene, 1564, &R2_GLOBALS._player, NULL); - } else - SceneItem::display(1550, 64, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - return true; break; - case CURSOR_LOOK: - if (scene->_dishMode != 2) - return SceneActor::startAction(action, event); - - if (R2_INVENTORY.getObjectScene(R2_BATTERY) == 1550) { - SceneItem::display(1550, 74, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - } else - SceneItem::display(1550, 64, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - return true; + case 51: + ++_sceneMode; break; - default: - return SceneActor::startAction(action, event); + case 52: + _companion.changeZoom(-1); + _sceneMode = 1592; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + setAction(&_sequenceManager1, this, 1592, &R2_GLOBALS._player, &_companion, + &_junk[0], &_joystick, NULL); + else + setAction(&_sequenceManager1, this, 1593, &R2_GLOBALS._player, &_companion, + &_junk[0], &_joystick, NULL); break; - } -} - -/*--------------------------------------------------------------------------*/ - -Scene1550::Scene1550() { - _dontExit = false; - _wallType = 0; - _dishMode = 0; - _sceneResourceId = 0; - _walkRegionsId = 0; -} - -void Scene1550::synchronize(Serializer &s) { - SceneExt::synchronize(s); - - s.syncAsSint16LE(_dontExit); - s.syncAsByte(_wallType); - s.syncAsSint16LE(_dishMode); - s.syncAsSint16LE(_sceneResourceId); - s.syncAsSint16LE(_walkRegionsId); -} - -void Scene1550::postInit(SceneObjectList *OwnerList) { - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) - // Exiting the intact spaceship - loadScene(1234); - else - // Normal scene entry - loadScene(1550); - SceneExt::postInit(); - - scalePalette(65, 65, 65); - setZoomPercents(30, 75, 170, 100); - _sceneResourceId = 1550; - _walkRegionsId = 0; - - if (R2_GLOBALS._sceneManager._previousScene == -1) - R2_GLOBALS.setFlag(16); - - if ((R2_GLOBALS._player._characterScene[R2_QUINN] != 1550) && (R2_GLOBALS._player._characterScene[R2_QUINN] != 1580)) { - R2_GLOBALS._player._characterScene[R2_QUINN] = 1550; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1550; - } - - _stripManager.setColors(60, 255); - _stripManager.setFontNumber(3); - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); - - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player._effect = EFFECT_SHADED2; - - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - R2_GLOBALS._player.setup(1500, 3, 1); - else - R2_GLOBALS._player.setup(1505, 3, 1); - - R2_GLOBALS._player._moveDiff = Common::Point(5, 3); - - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) - R2_GLOBALS._player.setPosition(Common::Point(157, 135)); - else - R2_GLOBALS._player.setPosition(Common::Point(160, 100)); - - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.disableControl(); - - _wallType = 0; - _companion.changeZoom(-1); - R2_GLOBALS._player.changeZoom(-1); - - switch (R2_GLOBALS._sceneManager._previousScene) { - case 1530: - R2_GLOBALS._stripModifier = 0; - // No break on purpose - case 300: - // No break on purpose - case 1500: - // No break on purpose - case 3150: - R2_GLOBALS._sound1.play(105); + case 61: + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + _dishMode = 2; break; - case 1580: - // Leaving intact ship - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1580) { - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); - - _dontExit = true; - - _wreckage2.postInit(); - _shipComponents[7].setupShipComponent(8); - _shipComponents[7].hide(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _sceneMode = 1577; - else - _sceneMode = 1578; - - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_wreckage2, &_shipComponents[7], NULL); - R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1550; - } else { - R2_GLOBALS._player.enableControl(); + case 62: + R2_GLOBALS._player.enableControl(CURSOR_TALK); + if (_dishMode == 2) { + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; } break; - default: - break; - } - - enterArea(); - - _intactHull1.setDetails(16, 1550, 10, -1, -1); - _intactHull2.setDetails(24, 1550, 10, -1, -1); - _background.setDetails(Rect(0, 0, 320, 200), 1550, 0, 1, -1, 1, NULL); - - if ((R2_GLOBALS._sceneManager._previousScene == 1500) && (R2_GLOBALS.getFlag(16))) { - _sceneMode = 70; - if (!R2_GLOBALS._sceneObjects->contains(&_companion)) - _companion.postInit(); - - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _companion.setVisage(1505); - else - _companion.setVisage(1500); - - _companion.changeZoom(77); - _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); - - assert(_walkRegionsId >= 1550); - R2_GLOBALS._walkRegions.disableRegion(k5A750[_walkRegionsId - 1550]); - - setAction(&_sequenceManager1, this, 1590, &_companion, NULL); - } else if ((_sceneMode != 1577) && (_sceneMode != 1578)) - R2_GLOBALS._player.enableControl(); -} - -void Scene1550::signal() { - switch (_sceneMode) { - case 1: - // No break on purpose - case 3: - // No break on purpose - case 5: - // No break on purpose - case 7: - _dontExit = false; - R2_GLOBALS._player.enableControl(CURSOR_WALK); - break; - case 20: - // No break on purpose - case 21: - // No break on purpose - case 25: - // No break on purpose - case 1563: - // Show the communication dish controls window - R2_GLOBALS.clearFlag(20); - _dishControlsWindow.setup2(1559, 1, 1, 160, 125); - R2_GLOBALS._player.enableControl(); - _sceneMode = 0; - break; - case 22: - _dishControlsWindow.remove(); - _sceneMode = 24; - setAction(&_sequenceManager1, this, 1561, &_walkway, NULL); - R2_GLOBALS.clearFlag(20); - break; - case 23: - _dishControlsWindow.remove(); - _sceneMode = 20; - setAction(&_sequenceManager1, this, 1566, &_dish, &_dishTowerShadow, NULL); - R2_GLOBALS.setFlag(19); - break; - case 24: - _dishControlsWindow.remove(); - _sceneMode = 21; - setAction(&_sequenceManager1, this, 1567, &_dish, &_dishTowerShadow, NULL); - R2_GLOBALS.clearFlag(19); - break; - case 30: - // No break on purpose - case 1556: - // No break on purpose - case 1557: - // Nothing on purpose - break; - case 40: { - _sceneMode = 41; - Common::Point pt(_junk[0]._position.x, _junk[0]._position.y + 20); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - break; - case 41: - _sceneMode = 42; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setup(1502, 8, 1); - } else { - R2_GLOBALS._player.changeZoom(R2_GLOBALS._player._percent + 14); - R2_GLOBALS._player.setup(1516, 4, 1); - } - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - - case 42: { - _sceneMode = 43; - int junkRegionIndex = R2_GLOBALS._scene1550JunkLocations[_junk[0]._junkNumber + 3]; - R2_GLOBALS._walkRegions.enableRegion(scene1550JunkRegions[junkRegionIndex]); - - switch (_junk[0]._frame) { - case 1: - R2_INVENTORY.setObjectScene(R2_JOYSTICK, R2_GLOBALS._player._characterIndex); - break; - case 2: - R2_INVENTORY.setObjectScene(R2_FUEL_CELL, R2_GLOBALS._player._characterIndex); - break; - case 3: - R2_INVENTORY.setObjectScene(R2_GUIDANCE_MODULE, R2_GLOBALS._player._characterIndex); - break; - case 4: - R2_INVENTORY.setObjectScene(R2_RADAR_MECHANISM, R2_GLOBALS._player._characterIndex); - break; - case 5: - R2_INVENTORY.setObjectScene(R2_BATTERY, R2_GLOBALS._player._characterIndex); - break; - case 6: - R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, R2_GLOBALS._player._characterIndex); - break; - default: - break; - } - - _junk[0].remove(); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - } - case 43: - R2_GLOBALS._scene1550JunkLocations[_junk[0]._junkNumber + 2] = 0; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - R2_GLOBALS._player.setVisage(1500); - else { - R2_GLOBALS._player.changeZoom(-1); - R2_GLOBALS._player.setVisage(1505); - } - R2_GLOBALS._player.animate(ANIM_MODE_1, this); - R2_GLOBALS._player.setStrip(8); - R2_GLOBALS._player.enableControl(); - break; - case 50: - // Removed (useless ?) call to sub_1D227 - ++_sceneMode; - setAction(&_sequenceManager1, this, 1591, &R2_GLOBALS._player, NULL); - if (g_globals->_sceneObjects->contains(&_companion)) - signal(); - else { - _companion.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _companion.setVisage(1505); - else - _companion.setVisage(1500); - _companion.changeZoom(77); - _companion.setAction(&_sequenceManager2, this, 1590, &_companion, NULL); - _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); - } - break; - case 51: - ++_sceneMode; - break; - case 52: - _companion.changeZoom(-1); - _sceneMode = 1592; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - setAction(&_sequenceManager1, this, 1592, &R2_GLOBALS._player, &_companion, - &_junk[0], &_joystick, NULL); - else - setAction(&_sequenceManager1, this, 1593, &R2_GLOBALS._player, &_companion, - &_junk[0], &_joystick, NULL); - break; - case 61: - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - _dishMode = 2; - break; - case 62: - R2_GLOBALS._player.enableControl(CURSOR_TALK); - if (_dishMode == 2) { - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - } - break; - case 70: - R2_GLOBALS._s1550PlayerArea[R2_SEEKER] = R2_GLOBALS._s1550PlayerArea[R2_QUINN]; - //R2_GLOBALS._s1550PlayerAreas[0] = 1; - _sceneMode = 60; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(500, this); + case 70: + R2_GLOBALS._s1550PlayerArea[R2_SEEKER] = R2_GLOBALS._s1550PlayerArea[R2_QUINN]; + //R2_GLOBALS._s1550PlayerAreas[0] = 1; + _sceneMode = 60; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(500, this); break; case 80: if (R2_GLOBALS.getFlag(16)) { @@ -3453,7191 +2574,5400 @@ void Scene1550::signal() { // No break on purpose case 1582: _dontExit = false; - _wreckage2.remove(); - R2_INVENTORY.setObjectScene(R2_FUEL_CELL, 0); - R2_GLOBALS._player.enableControl(); - break; - case 1575: - // No break on purpose - case 1583: - _dontExit = false; - _wreckage2.remove(); - R2_INVENTORY.setObjectScene(R2_BATTERY, 0); - R2_GLOBALS._player.enableControl(); - break; - case 1576: - // No break on purpose - case 1584: - R2_GLOBALS._sceneManager.changeScene(1580); - R2_GLOBALS._player.enableControl(); - break; - case 1577: - // No break on purpose - case 1578: - _sceneMode = 0; - _wreckage2.remove(); - _dontExit = false; - R2_GLOBALS._player.fixPriority(-1); - R2_GLOBALS._player.enableControl(); - break; - case 1585: - SceneItem::display(1550, 66, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - R2_GLOBALS._player.enableControl(); - break; - case 1586: - // No break on purpose - case 1587: - R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, R2_GLOBALS._player._characterIndex); - _diagnosticsDisplay.remove(); - _dontExit = false; - R2_GLOBALS._player.enableControl(); - break; - case 1592: - _joystick.remove(); - R2_INVENTORY.setObjectScene(R2_JOYSTICK, 1); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._s1550PlayerArea[R2_SEEKER] = R2_GLOBALS._s1550PlayerArea[R2_QUINN]; - } else { - R2_GLOBALS._s1550PlayerArea[R2_QUINN] = R2_GLOBALS._s1550PlayerArea[R2_SEEKER]; - } - R2_GLOBALS._player.enableControl(CURSOR_WALK); - break; - default: - _sceneMode = 62; - setAction(&_sequenceManager1, this, 1, &R2_GLOBALS._player, NULL); - break; - } -} - -void Scene1550::process(Event &event) { - if ((!R2_GLOBALS._player._canWalk) && (R2_GLOBALS._events.getCursor() == R2_NEGATOR_GUN) && (event.eventType == EVENT_BUTTON_DOWN) && (this->_screenNumber == 1234)) { - int curReg = R2_GLOBALS._sceneRegions.indexOf(event.mousePos); - if (curReg == 0) - _dontExit = true; - else if (((R2_GLOBALS._player._position.y < 90) && (event.mousePos.y > 90)) || ((R2_GLOBALS._player._position.y > 90) && (event.mousePos.y < 90))) - _dontExit = true; - else - _dontExit = false; - - if ((curReg == 13) || (curReg == 14)) - _dontExit = false; - } - - Scene::process(event); -} - -void Scene1550::dispatch() { - Scene::dispatch(); - - // Arrays related to this scene are all hacky in the origina: they are based on the impossibility to use Miranda - assert ((R2_GLOBALS._player._characterIndex == R2_QUINN) || (R2_GLOBALS._player._characterIndex == R2_SEEKER)); - - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 15) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 16)) { - R2_GLOBALS._player._shade = 0; - - // NOTE: Original game contains a switch based on an uninitialized variable. - // We're leaving this code here, but ifdef'ed out, in case we can ever figure out - // what the original programmers intended the value to come from -#if 0 - int missingVariable = 0; - switch (missingVariable) { - case 144: - // No break on purpose - case 146: - _dish._frame = 5; - R2_GLOBALS._player._shade = 3; - break; - case 148: - // No break on purpose - case 149: - _dish._frame = 1; - // No break on purpose - case 147: - // No break on purpose - case 150: - R2_GLOBALS._player._shade = 3; - break; - default: - break; - } -#endif - } - - if (_dontExit) - return; - - switch (R2_GLOBALS._player.getRegionIndex() - 11) { - case 0: - // No break on purpose - case 5: - // Exiting the top of the screen - R2_GLOBALS._player.disableControl(); - _sceneMode = 1; - _dontExit = true; - --R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y; - - enterArea(); - - R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 108) * 172) / 100), 145)); - if (R2_GLOBALS._player._position.x < 160) { - Common::Point pt(R2_GLOBALS._player._position.x + 5, 135); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else if (R2_GLOBALS._player._position.x <= 160) { // the check is really in the original... - Common::Point pt(R2_GLOBALS._player._position.x, 135); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else { - Common::Point pt(R2_GLOBALS._player._position.x - 5, 135); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - break; - case 1: - // Exiting the bottom of the screen - R2_GLOBALS._player.disableControl(); - _sceneMode = 3; - _dontExit = true; - ++R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y; - - enterArea(); - - R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 172) * 108) / 100), 19)); - if (R2_GLOBALS._player._position.x < 160) { - Common::Point pt(R2_GLOBALS._player._position.x + 5, 29); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else if (R2_GLOBALS._player._position.x <= 160) { // the check is really in the original... - Common::Point pt(R2_GLOBALS._player._position.x, 29); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else { - Common::Point pt(R2_GLOBALS._player._position.x - 5, 29); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - break; - case 2: - // Exiting the right of the screen - R2_GLOBALS._player.disableControl(); - _sceneMode = 5; - _dontExit = true; - ++R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x; - - enterArea(); - - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11) && (R2_GLOBALS._player._position.y > 50) && (R2_GLOBALS._player._position.y < 135)) { - if (R2_GLOBALS._player._position.y >= 85) { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 10)); - Common::Point pt(R2_GLOBALS._player._position.x + 30, R2_GLOBALS._player._position.y + 20); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 10)); - Common::Point pt(R2_GLOBALS._player._position.x + 30, R2_GLOBALS._player._position.y - 20); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - } else { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y)); - Common::Point pt(R2_GLOBALS._player._position.x + 10, R2_GLOBALS._player._position.y); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - break; - case 3: - // Exiting to the left of the screen - R2_GLOBALS._player.disableControl(); - _sceneMode = 7; - _dontExit = true; - --R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x; - - enterArea(); - - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 24) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y / 2)); - Common::Point pt(265, 29); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11) && (R2_GLOBALS._player._position.y > 50) && (R2_GLOBALS._player._position.y < 135)) { - if (R2_GLOBALS._player._position.y >= 85) { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 10)); - Common::Point pt(R2_GLOBALS._player._position.x - 30, R2_GLOBALS._player._position.y + 20); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 10)); - Common::Point pt(R2_GLOBALS._player._position.x - 30, R2_GLOBALS._player._position.y - 20); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - } else { - R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y)); - Common::Point pt(R2_GLOBALS._player._position.x - 10, R2_GLOBALS._player._position.y); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - break; - default: - break; - } -} - -void Scene1550::saveCharacter(int characterIndex) { - if (R2_GLOBALS._player._characterIndex == R2_MIRANDA) - R2_GLOBALS._sound1.fadeOut2(NULL); - - SceneExt::saveCharacter(characterIndex); -} - -void Scene1550::Wall::setupWall(int frameNumber, int strip) { - Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - - postInit(); - if (scene->_wallType == 2) - setup(1551, strip, frameNumber); - else - setup(1554, strip, frameNumber); - - switch (strip) { - case 0: - switch (frameNumber - 1) { - case 0: - setup(1551, 1, 1); - setPosition(Common::Point(30, 67)); - break; - case 1: - setup(1560, 1, 5); - setPosition(Common::Point(141, 54)); - break; - case 2: - setup(1560, 2, 5); - setPosition(Common::Point(178, 54)); - break; - case 3: - setup(1560, 2, 1); - setPosition(Common::Point(289, 67)); - break; - case 4: - setup(1560, 2, 2); - setPosition(Common::Point(298, 132)); - break; - case 5: - setup(1560, 1, 2); - setPosition(Common::Point(21, 132)); - break; - case 6: - setup(1560, 2, 4); - setPosition(Common::Point(285, 123)); - break; - case 7: - setup(1560, 1, 3); - setPosition(Common::Point(30, 111)); - break; - case 8: - setup(1560, 2, 3); - setPosition(Common::Point(289, 111)); - break; - case 9: - setup(1560, 1, 4); - setPosition(Common::Point(34, 123)); - break; - default: - break; - } - fixPriority(1); - break; - case 1: - if (frameNumber == 3) { - setup(1553, 3, 1); - setPosition(Common::Point(48, 44)); - fixPriority(2); - } else { - fixPriority(1); - setPosition(Common::Point(32, 17)); - } - - switch (frameNumber) { - case 2: - setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); - break; - case 3: - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - break; - default: - setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); - break; - } - break; - case 2: - fixPriority(1); - switch (frameNumber) { - case 4: - setup(1553, 4, 1); - setPosition(Common::Point(48, 168)); - break; - case 5: - setup(1553, 3, 2); - setPosition(Common::Point(20, 168)); - fixPriority(250); - break; - default: - setPosition(Common::Point(28, 116)); - break; - } - - switch (frameNumber) { - case 2: - setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); - break; - case 4: - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - break; - case 5: - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - break; - default: - setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); - break; - } - break; - case 3: - switch (frameNumber) { - case 2: - fixPriority(2); - if (scene->_wallType == 2) - setup(1553, 2, 1); - else - setup(1556, 2, 1); - setPosition(Common::Point(160, 44)); - break; - case 3: - fixPriority(2); - setup(1553, 5, 1); - setPosition(Common::Point(178, 44)); - break; - default: - fixPriority(1); - setPosition(Common::Point(160, 17)); - break; - } - - if (frameNumber == 1) - setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); - else - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - break; - case 4: - if (frameNumber == 2) { - fixPriority(250); - if (scene->_wallType == 2) - setup(1553, 1, 1); - else - setup(1556, 1, 1); - } else { - fixPriority(2); - } - - if (frameNumber != 1) - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - - setPosition(Common::Point(160, 168)); - break; - case 5: - fixPriority(1); - setPosition(Common::Point(287, 17)); - - switch (frameNumber) { - case 2: - setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); - break; - case 3: - setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - break; - default: - setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); - break; - } - break; - case 6: - fixPriority(1); - setPosition(Common::Point(291, 116)); - - if (frameNumber == 2) - setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); - else - setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); - break; - default: - break; - } - -} - -void Scene1550::enterArea() { - _walkRegionsId = 0; - _dishMode = 0; - - _wallCorner1.remove(); - _westWall.remove(); - _northWall.remove(); - _southWall.remove(); - _wallCorner2.remove(); - _eastWall.remove(); - - for (int i = 0; i < 8; ++i) - _junk[i].remove(); - - _wreckage.remove(); - - for (int i = 0; i < 8; ++i) - _shipComponents[i].remove(); - - _airbag.remove(); - _joystick.remove(); - _gyroscope.remove(); - _wreckage4.remove(); - _diagnosticsDisplay.remove(); - - if ((_sceneMode != 1577) && (_sceneMode != 1578)) - _wreckage2.remove(); - - _wreckage3.remove(); - _companion.remove(); - _dish.remove(); - _dishTowerShadow.remove(); - _dishTower.remove(); - _walkway.remove(); - - // Set up of special walk regions for certain areas - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y) { - case 0: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { - case 3: - R2_GLOBALS._walkRegions.load(1554); - _walkRegionsId = 1554; - break; - case 4: - R2_GLOBALS._walkRegions.load(1553); - _walkRegionsId = 1553; - break; - default: - break; - } - break; - case 3: - // No break on purpose - case 4: - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 23) || (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x)) { - if (!R2_GLOBALS.getFlag(16)) { - R2_GLOBALS._walkRegions.load(1559); - _walkRegionsId = 1559; - } - } - break; - case 7: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { - case 10: - R2_GLOBALS._walkRegions.load(1555); - _walkRegionsId = 1555; - break; - case 11: - R2_GLOBALS._walkRegions.load(1556); - _walkRegionsId = 1556; - break; - default: - break; - } - break; - case 11: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { - case 24: - R2_GLOBALS._walkRegions.load(1558); - _walkRegionsId = 1558; - break; - case 25: - R2_GLOBALS._walkRegions.load(1557); - _walkRegionsId = 1557; - break; - default: - break; - } - break; - case 16: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { - case 2: - R2_GLOBALS._walkRegions.load(1552); - _walkRegionsId = 1552; - break; - case 3: - R2_GLOBALS._walkRegions.load(1551); - _walkRegionsId = 1551; - break; - case 15: - R2_GLOBALS._walkRegions.load(1575); - _walkRegionsId = 1575; - default: - break; - } - break; - default: - break; - } - - int varA = 0; - - // This section handles checks if the ARM spacecraft have not yet seized - // control of Lance of Truth. - if (!R2_GLOBALS.getFlag(16)) { - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y - 2) { - case 0: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 22) { - case 0: - varA = 1553; - _northWall.setupWall(6, 0); - break; - case 1: - // No break on purpose - case 2: - // No break on purpose - case 3: - // No break on purpose - case 4: - varA = 1553; - break; - case 5: - varA = 1553; - _northWall.setupWall(6, 0); - break; - default: - break; - } - break; - case 1: - // No break on purpose - case 2: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 21) { - case 0: - varA = 1550; - _northWall.setupWall(9, 0); - break; - case 1: - varA = 1552; - _northWall.setupWall(10, 0); - break; - case 2: - // No break on purpose - case 3: - // No break on purpose - case 4: - // No break on purpose - case 5: - varA = 1552; - break; - case 6: - varA = 1552; - _northWall.setupWall(7, 0); - break; - case 7: - varA = 1550; - _northWall.setupWall(8, 0); - break; - default: - break; - } - break; - case 3: - switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 21) { - case 0: - varA = 1550; - _northWall.setupWall(4, 0); - break; - case 1: - varA = 1550; - _northWall.setupWall(3, 0); - break; - case 2: - // No break on purpose - case 3: - // No break on purpose - case 4: - // No break on purpose - case 5: - varA = 1551; - break; - case 6: - varA = 1550; - _northWall.setupWall(2, 0); - break; - case 7: - varA = 1550; - _northWall.setupWall(1, 0); - break; - default: - break; - } - break; - default: - break; - } - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y > 0) && - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x <= 29) && - ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x < 20) || - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y > 7))) { - // In an area where the cutscene can be triggered, so start it - R2_GLOBALS.setFlag(16); - R2_GLOBALS._sceneManager.changeScene(1500); - } - } - - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) { - if (_screenNumber != 1234) { - R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; - loadScene(1234); - R2_GLOBALS._sceneManager._hasPalette = false; - _wallType = 0; - } - } else if (_screenNumber == 1234) { - R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; - loadScene(1550); - R2_GLOBALS._sceneManager._hasPalette = false; - } - - if (_screenNumber == 1234) - _walkRegionsId = 1576; - - if (_wallType == 0) { - _wallType = 1; - } else { - if (_wallType == 2) { - _wallType = 3; - } else { - _wallType = 2; - } - - if (R2_GLOBALS._sceneManager._sceneNumber == 1550){ -#if 0 - warning("Mouse_hideIfNeeded()"); - warning("gfx_set_pane_p"); - for (int i = 3; i != 168; ++i) { - warning("sub294D2(4, i, 312, var14C)"); - warning("missing for loop, to be implemented"); - warning("gfx_draw_slice"); - } - warning("gfx_flip_screen()"); - warning("gfx_set_pane_p()"); -#endif - R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; - - if (varA == 0) { - if (_sceneResourceId != 1550) { - g_globals->_scenePalette.loadPalette(1550); - R2_GLOBALS._sceneManager._hasPalette = true; - } - } else { - g_globals->_scenePalette.loadPalette(varA); - R2_GLOBALS._sceneManager._hasPalette = true; - } - - if (R2_GLOBALS._sceneManager._hasPalette) - _sceneResourceId = varA; - -// warning("sub_2C429()"); - } - } - - // Scene setup dependent on the type of cell specified in the scene map - switch (scene1550AreaMap[(R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y * 30) + - R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x]) { - case 0: - // Standard cell - if (_walkRegionsId == 0) { - R2_GLOBALS._walkRegions.load(1550); - _walkRegionsId = 1550; - } - break; - case 1: - // North end of the spaceport - if (_walkRegionsId == 0) { - R2_GLOBALS._walkRegions.load(1560); - _walkRegionsId = 1560; - } - _wallCorner1.setupWall(2, 1); - _northWall.setupWall(1, 3); - _wallCorner2.setupWall(2, 5); - break; - case 2: - R2_GLOBALS._walkRegions.load(1561); - _walkRegionsId = 1561; - _wallCorner1.setupWall(2, 1); - _westWall.setupWall(2, 2); - _northWall.setupWall(1, 3); - _wallCorner2.setupWall(2, 5); - break; - case 3: - R2_GLOBALS._walkRegions.load(1562); - _walkRegionsId = 1562; - _wallCorner1.setupWall(2, 1); - _northWall.setupWall(1, 3); - _wallCorner2.setupWall(2, 5); - _eastWall.setupWall(2, 6); - break; - case 4: - R2_GLOBALS._walkRegions.load(1563); - _walkRegionsId = 1563; - _northWall.setupWall(2, 3); - break; - case 5: - R2_GLOBALS._walkRegions.load(1564); - _walkRegionsId = 1564; - _southWall.setupWall(2, 4); - break; - case 6: - R2_GLOBALS._walkRegions.load(1565); - _walkRegionsId = 1565; - _wallCorner1.setupWall(1, 1); - _westWall.setupWall(1, 2); - _northWall.setupWall(3, 3); - break; - case 7: - R2_GLOBALS._walkRegions.load(1566); - _walkRegionsId = 1566; - _wallCorner1.setupWall(1, 1); - _westWall.setupWall(1, 2); - _northWall.setupWall(2, 4); - break; - case 8: - R2_GLOBALS._walkRegions.load(1567); - _walkRegionsId = 1567; - _westWall.setupWall(5, 2); - break; - case 9: - R2_GLOBALS._walkRegions.load(1568); - _walkRegionsId = 1568; - _westWall.setupWall(4, 2); - break; - case 10: - R2_GLOBALS._walkRegions.load(1569); - _walkRegionsId = 1569; - _wallCorner1.setupWall(3, 1); - break; - case 11: - R2_GLOBALS._walkRegions.load(1570); - _walkRegionsId = 1570; - _wallCorner1.setupWall(1, 1); - _westWall.setupWall(1, 2); - break; - case 12: - R2_GLOBALS._walkRegions.load(1571); - _walkRegionsId = 1571; - _wallCorner2.setupWall(1, 5); - _eastWall.setupWall(1, 6); - break; - case 13: - R2_GLOBALS._walkRegions.load(1572); - _walkRegionsId = 1572; - _wallCorner1.setupWall(1, 1); - _westWall.setupWall(1, 2); - _southWall.setupWall(1, 4); - break; - case 14: - R2_GLOBALS._walkRegions.load(1573); - _walkRegionsId = 1573; - _southWall.setupWall(1, 4); - _wallCorner2.setupWall(1, 5); - _eastWall.setupWall(1, 6); - break; - case 15: - // South wall - R2_GLOBALS._walkRegions.load(1574); - _walkRegionsId = 1574; - _southWall.setupWall(1, 4); - break; - case 16: - R2_GLOBALS._walkRegions.load(1570); - _walkRegionsId = 1570; - _wallCorner1.setupWall(2, 1); - _westWall.setupWall(2, 2); - break; - case 17: - R2_GLOBALS._walkRegions.load(1570); - _walkRegionsId = 1570; - _wallCorner1.setupWall(2, 1); - _westWall.setupWall(3, 2); - break; - case 18: - R2_GLOBALS._walkRegions.load(1571); - _walkRegionsId = 1571; - _wallCorner2.setupWall(2, 5); - _eastWall.setupWall(2, 6); - break; - case 19: - R2_GLOBALS._walkRegions.load(1571); - _walkRegionsId = 1571; - _wallCorner2.setupWall(2, 5); - _eastWall.setupWall(3, 6); - break; - default: - break; - } - - int di = 0; - int tmpIdx = 0; - for (int i = 0; i < 127 * 4; i += 4) { - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == R2_GLOBALS._scene1550JunkLocations[i]) && - (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == R2_GLOBALS._scene1550JunkLocations[i + 1]) && - (R2_GLOBALS._scene1550JunkLocations[i + 2] != 0)) { - tmpIdx = R2_GLOBALS._scene1550JunkLocations[i + 3]; - _junk[di].postInit(); - _junk[di]._effect = EFFECT_SHADED2; - _junk[di]._shade = 0; - //_junk[di]._junkState = tmpIdx; - _junk[di]._junkNumber = i; - _junk[di].setDetails(1550, 62, -1, 63, 2, (SceneItem *) NULL); - if (R2_GLOBALS._scene1550JunkLocations[i + 2] == 41) { - _junk[di].changeZoom(-1); - _junk[di].setPosition(Common::Point(150, 70)); - _junk[di].setup(1562, 1, 1); - - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[2]); - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[3]); - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[6]); - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[7]); - - if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1550) { - _joystick.postInit(); - _joystick.setup(1562, 3, 1); - _joystick.setPosition(Common::Point(150, 70)); - _joystick.fixPriority(10); - _joystick.setDetails(1550, 41, -1, 42, 2, (SceneItem *) NULL); - } - } else { - if (R2_GLOBALS._scene1550JunkLocations[i + 2] > 40) { - _junk[di].changeZoom(100); - _junk[di].setup(1561, 1, R2_GLOBALS._scene1550JunkLocations[i + 2] - 40); - } else { - _junk[di].changeZoom(-1); - _junk[di].setup(1552, ((R2_GLOBALS._scene1550JunkLocations[i + 2] - 1) / 5) + 1, ((R2_GLOBALS._scene1550JunkLocations[i + 2] - 1) % 5) + 1); - } - _junk[di].setPosition(Common::Point(scene1550JunkX[tmpIdx], scene1550JunkY[tmpIdx])); - if (scene1550JunkRegions[tmpIdx] != 0) - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[tmpIdx]); - di++; - } - } - } - - // Loop for detecting and setting up certain special areas within the map - for (int i = 0; i < 15 * 3; i += 3) { - if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == scene1550SpecialAreas[i]) - && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == scene1550SpecialAreas[i + 1])) { - int areaType = scene1550SpecialAreas[i + 2]; - switch (areaType) { - case 1: - if (!R2_GLOBALS.getFlag(16)) { - _wreckage2.postInit(); - if (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 3) - _wreckage2.setup(1555, 2, 1); - else - _wreckage2.setup(1555, 1, 1); - _wreckage2.setPosition(Common::Point(150, 100)); - _wreckage2.fixPriority(92); - _wreckage2.setDetails(1550, 73, -1, -1, 2, (SceneItem *) NULL); - } - break; - case 2: - _dish.postInit(); - if (R2_GLOBALS.getFlag(19)) - _dish.setup(1556, 3, 5); - else - _dish.setup(1556, 3, 1); - _dish.changeZoom(95); - _dish.setPosition(Common::Point(165, 83)); - _dish.fixPriority(168); - _dish.setDetails(1550, 17, -1, 19, 2, (SceneItem *) NULL); - - _dishTower.postInit(); - _dishTower.setup(1556, 4, 1); - _dishTower.setPosition(Common::Point(191, 123)); - _dishTower.changeZoom(95); - _dishTower.setDetails(1550, 65, -1, 66, 2, (SceneItem *) NULL); - - _dishTowerShadow.postInit(); - _dishTowerShadow._numFrames = 5; - if (R2_GLOBALS.getFlag(19)) - _dishTowerShadow.setup(1556, 8, 5); - else - _dishTowerShadow.setup(1556, 8, 1); - - _dishTowerShadow.setPosition(Common::Point(156, 151)); - _dishTowerShadow.fixPriority(10); - - _walkway.postInit(); - if (R2_GLOBALS.getFlag(20)) - _walkway.setup(1558, 3, 10); - else - _walkway.setup(1558, 3, 1); - - _walkway.setPosition(Common::Point(172, 48)); - _walkway.fixPriority(169); - R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[15]); - break; - case 3: - _wreckage.postInit(); - _wreckage.setup(1550, 1, 1); - _wreckage.setPosition(Common::Point(259, 55)); - _wreckage.fixPriority(133); - _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 1, 2); - _wreckage2.setPosition(Common::Point(259, 133)); - _wreckage2.fixPriority(105); - _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 1550) { - _gyroscope.postInit(); - _gyroscope.setup(1550, 7, 2); - _gyroscope.setPosition(Common::Point(227, 30)); - _gyroscope.fixPriority(130); - _gyroscope.setDetails(1550, 29, -1, 63, 2, (SceneItem *) NULL); - } - break; - case 4: - _wreckage.postInit(); - _wreckage.setup(1550, 1, 4); - _wreckage.setPosition(Common::Point(76, 131)); - _wreckage.fixPriority(10); - _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 1, 3); - _wreckage2.setPosition(Common::Point(76, 64)); - _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - if (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1550) { - _diagnosticsDisplay.postInit(); - _diagnosticsDisplay.setup(1504, 4, 1); - _diagnosticsDisplay.setPosition(Common::Point(49, 35)); - _diagnosticsDisplay.animate(ANIM_MODE_2, NULL); - _diagnosticsDisplay._numFrames = 4; - _diagnosticsDisplay.fixPriority(65); - _diagnosticsDisplay.setDetails(1550, 14, 15, 63, 2, (SceneItem *) NULL); - } - if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1550) { - _airbag.postInit(); - _airbag.setup(1550, 7, 1); - _airbag.setPosition(Common::Point(45, 44)); - _airbag.fixPriority(150); - _airbag.setDetails(1550, 44, -1, 63, 2, (SceneItem *) NULL); - } - break; - case 5: - _wreckage.postInit(); - _wreckage.setup(1550, 2, 4); - _wreckage.setPosition(Common::Point(243, 131)); - _wreckage.fixPriority(10); - _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 2, 3); - _wreckage2.setPosition(Common::Point(243, 64)); - _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - break; - case 6: - _wreckage.postInit(); - _wreckage.setup(1550, 2, 1); - _wreckage.setPosition(Common::Point(60, 55)); - _wreckage.fixPriority(133); - _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 2, 2); - _wreckage2.setPosition(Common::Point(60, 133)); - _wreckage2.fixPriority(106); - _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - break; - case 7: - _wreckage.postInit(); - _wreckage.setup(1550, 3, 1); - _wreckage.setPosition(Common::Point(281, 132)); - _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - break; - case 8: - _wreckage.postInit(); - _wreckage.setup(1550, 3, 2); - _wreckage.setPosition(Common::Point(57, 96)); - _wreckage.fixPriority(70); - _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 3, 3); - _wreckage2.setPosition(Common::Point(145, 88)); - _wreckage2.fixPriority(55); - _wreckage2.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage3.postInit(); - _wreckage3.setup(1550, 3, 4); - _wreckage3.setPosition(Common::Point(64, 137)); - _wreckage3.fixPriority(115); - _wreckage3.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage4.postInit(); - _wreckage4.setup(1550, 5, 1); - _wreckage4.setPosition(Common::Point(60, 90)); - _wreckage4.fixPriority(45); - break; - case 9: - _wreckage.postInit(); - _wreckage.setup(1550, 4, 2); - _wreckage.setPosition(Common::Point(262, 96)); - _wreckage.fixPriority(70); - _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage2.postInit(); - _wreckage2.setup(1550, 4, 3); - _wreckage2.setPosition(Common::Point(174, 88)); - _wreckage2.fixPriority(55); - _wreckage2.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage3.postInit(); - _wreckage3.setup(1550, 4, 4); - _wreckage3.setPosition(Common::Point(255, 137)); - _wreckage3.fixPriority(115); - _wreckage3.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - - _wreckage4.postInit(); - _wreckage4.setup(1550, 6, 1); - _wreckage4.setPosition(Common::Point(259, 90)); - _wreckage4.fixPriority(45); - break; - case 10: - _wreckage.postInit(); - _wreckage.setup(1550, 4, 1); - _wreckage.setPosition(Common::Point(38, 132)); - _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - break; - case 12: - // Intact ship - _shipComponents[7].setupShipComponent(8); - _shipComponents[0].setupShipComponent(1); - _shipComponents[1].setupShipComponent(2); - _shipComponents[2].setupShipComponent(3); - _shipComponents[3].setupShipComponent(4); - _shipComponents[4].setupShipComponent(5); - _shipComponents[5].setupShipComponent(6); - _shipComponents[6].setupShipComponent(7); - break; - default: - break; - } - } - } - - if (R2_GLOBALS._s1550PlayerArea[R2_QUINN] == R2_GLOBALS._s1550PlayerArea[R2_SEEKER]) { - _companion.postInit(); - _companion._effect = EFFECT_SHADED2; - _companion.changeZoom(-1); - - assert((_walkRegionsId >= 1550) && (_walkRegionsId <= 2008)); - R2_GLOBALS._walkRegions.disableRegion(k5A750[_walkRegionsId - 1550]); - _companion.setPosition(Common::Point(scene1550JunkX[k5A76D[_walkRegionsId - 1550]], scene1550JunkY[k5A76D[_walkRegionsId - 1550]] + 8)); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS._player._characterScene[R2_SEEKER] == 1580) { - _companion.setup(1516, 3, 17); - _companion.setPosition(Common::Point(272, 94)); - _companion.fixPriority(91); - _companion.changeZoom(100); - _companion.setDetails(1550, -1, -1, -1, 5, &_shipComponents[7]); - } else { - _companion.setup(1505, 6, 1); - _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); - } - } else { - if (R2_GLOBALS._player._characterScene[R2_QUINN] == 1580) { - _companion.setup(1516, 2, 14); - _companion.setPosition(Common::Point(276, 97)); - _companion.fixPriority(91); - _companion.changeZoom(100); - _companion.setDetails(1550, -1, -1, -1, 5, &_shipComponents[7]); - } else { - _companion.setup(1500, 6, 1); - _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); - } - } - } - R2_GLOBALS._uiElements.updateInventory(); -} - -/*-------------------------------------------------------------------------- - * Scene 1575 - Spaceport - unused ship scene - * - *--------------------------------------------------------------------------*/ - -Scene1575::Button::Button() { - _buttonId = 0; - _pressed = false; -} - -void Scene1575::Button::synchronize(Serializer &s) { - NamedHotspot::synchronize(s); - - s.syncAsSint16LE(_buttonId); - s.syncAsSint16LE(_pressed); -} - -void Scene1575::Button::process(Event &event) { - Scene1575 *scene = (Scene1575 *)R2_GLOBALS._sceneManager._scene; - bool isInBounds = _bounds.contains(event.mousePos); - CursorType cursor = R2_GLOBALS._events.getCursor(); - - if ((event.eventType == EVENT_BUTTON_DOWN && cursor == CURSOR_USE && isInBounds) || - (_pressed && _buttonId != 1 && event.eventType == EVENT_BUTTON_UP && isInBounds)) { - // Button pressed - _pressed = true; - Common::Point pos = scene->_actor1._position; - event.handled = true; - - if (!R2_GLOBALS.getFlag(18) || _buttonId <= 1 || _buttonId >= 6) { - switch (_buttonId) { - case 1: - if (R2_GLOBALS.getFlag(18)) { - scene->_actor14.hide(); - scene->_actor15.hide(); - R2_GLOBALS.clearFlag(18); - } else if ((scene->_actor12._position.x == 85) && (scene->_actor12._position.y == 123)) { - scene->_actor14.show(); - scene->_actor15.show(); - R2_GLOBALS.setFlag(18); - } else { - SceneItem::display("That's probably not a good thing, ya know!"); - } - break; - case 2: - if (scene->_field41A < 780) { - if (pos.x > 54) - pos.x -= 65; - pos.x += 2; - scene->_field41A += 2; - - for (int i = 0; i < 17; i++) - scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x + 2, scene->_arrActor[i]._position.y)); - - scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x + 2, scene->_actor13._position.y)); - scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x + 2, scene->_actor12._position.y)); - scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); - scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); - scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); - } - break; - case 3: - if (scene->_field41A > 0) { - if (pos.x < -8) - pos.x += 65; - - pos.x -= 2; - scene->_field41A -= 2; - for (int i = 0; i < 17; i++) - scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x - 2, scene->_arrActor[i]._position.y)); - - scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x - 2, scene->_actor13._position.y)); - scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x - 2, scene->_actor12._position.y)); - scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); - scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); - scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); - } - break; - case 4: { - if (pos.y < 176) { - ++pos.y; - for (int i = 0; i < 17; ++i) - scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x, scene->_arrActor[i]._position.y + 1)); - - scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x, scene->_actor13._position.y + 1)); - scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x, scene->_actor12._position.y + 1)); - scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); - scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); - scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); - } - } - break; - case 5: { - if (pos.y > 145) { - --pos.y; - for (int i = 0; i < 17; ++i) - scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x, scene->_arrActor[i]._position.y - 1)); - - scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x, scene->_actor13._position.y - 1)); - scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x, scene->_actor12._position.y - 1)); - scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); - scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); - scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); - } - } - break; - case 6: - R2_GLOBALS._sceneManager.changeScene(1550); - break; - default: - break; - } - - int j = 0; - for (int i = 0; i < 17; i++) { - if (scene->_arrActor[i]._bounds.contains(85, 116)) - j = i; - } - - if (scene->_actor13._bounds.contains(85, 116)) - j = 18; - - if (scene->_actor12._bounds.contains(85, 116)) - j = 19; - - if (j) - scene->_actor11.show(); - else - scene->_actor11.hide(); - } else { - SceneItem::display("Better not move the laser while it's firing!"); - } - } else { - _pressed = false; - } -} - -bool Scene1575::Button::startAction(CursorType action, Event &event) { - if (action == CURSOR_USE) - return false; - return SceneHotspot::startAction(action, event); -} - -void Scene1575::Button::initButton(int buttonId) { - _buttonId = buttonId; - _pressed = false; - EventHandler::postInit(); - - switch (_buttonId) { - case 1: - setDetails(Rect(53, 165, 117, 190), -1, -1, -1, 2, 1, NULL); - break; - case 2: - setDetails(Rect(151, 142, 189, 161), -1, -1, -1, 2, 1, NULL); - break; - case 3: - setDetails(Rect(225, 142, 263, 161), -1, -1, -1, 2, 1, NULL); - break; - case 4: - setDetails(Rect(188, 122, 226, 140), -1, -1, -1, 2, 1, NULL); - break; - case 5: - setDetails(Rect(188, 162, 226, 180), -1, -1, -1, 2, 1, NULL); - break; - case 6: - setDetails(Rect(269, 169, 301, 185), -1, -1, -1, 2, 1, NULL); - break; - default: - break; - } -} - -/*--------------------------------------------------------------------------*/ - -Scene1575::Scene1575() { - _field412 = 0; - _field414 = 390; - _field416 = 0; - _field418 = 0; - _field41A = 0; -} - -void Scene1575::synchronize(Serializer &s) { - SceneExt::synchronize(s); - - s.syncAsSint16LE(_field412); - s.syncAsSint16LE(_field414); - s.syncAsSint16LE(_field416); - s.syncAsSint16LE(_field418); - s.syncAsSint16LE(_field41A); -} - -double hypotenuse(double v1, double v2) { - return sqrt(v1 * v1 + v2 * v2); -} - -void Scene1575::postInit(SceneObjectList *OwnerList) { - loadScene(1575); - R2_GLOBALS._uiElements._active = false; - SceneExt::postInit(); - R2_GLOBALS._interfaceY = SCREEN_HEIGHT; - - _actor1.postInit(); - _actor1.setup(1575, 1, 1); - _actor1.setPosition(Common::Point(54, 161)); - _actor1.fixPriority(5); - - _actor2.postInit(); - _actor2.setup(1575, 1, 1); - _actor2.setPosition(Common::Point(119, 161)); - _actor2.fixPriority(5); - - _actor3.postInit(); - _actor3.setup(1575, 1, 1); - _actor3.setPosition(Common::Point(184, 161)); - _actor3.fixPriority(5); - - for (int i = 0; i < 17; i++) { - _arrActor[i].postInit(); - _arrActor[i].setup(1575, 2, k5A7F6[3 * i + 2]); - - double v1 = hypotenuse(2.0, 3 - k5A7F6[3 * i]); - v1 += hypotenuse(2.0, 3 - k5A7F6[3 * i + 1]); - int yp = (int)(sqrt(v1) * 75.0 / 17.0 - 161.0); - - int angle = R2_GLOBALS._gfxManagerInstance.getAngle( - Common::Point(3, 16), Common::Point(k5A7F6[3 * i], k5A7F6[3 * i + 1])); - int xp = angle * 78 / 9 - 319; - - _arrActor[i].setPosition(Common::Point(xp, yp)); - _arrActor[i].fixPriority(6); - } - - _actor4.postInit(); - _actor4.setup(1575, 3, 1); - _actor4.setPosition(Common::Point(48, 81)); - - _actor5.postInit(); - _actor5.setup(1575, 3,1); - _actor5.setPosition(Common::Point(121, 81)); - - _actor6.postInit(); - _actor6.setup(1575, 3, 2); - _actor6.setPosition(Common::Point(203, 80)); - - _actor7.postInit(); - _actor7.setup(1575, 3, 2); - _actor7.setPosition(Common::Point(217, 80)); - - _actor8.postInit(); - _actor8.setup(1575, 3, 2); - _actor8.setPosition(Common::Point(231, 80)); - - _actor9.postInit(); - _actor9.setup(1575, 3, 2); - _actor9.setPosition(Common::Point(273, 91)); - - _actor10.postInit(); - _actor10.setup(1575, 3, 2); - _actor10.setPosition(Common::Point(287, 91)); - - // Initialize buttons - _button1.initButton(1); - _button2.initButton(2); - _button3.initButton(3); - _button4.initButton(4); - _button5.initButton(5); - _button6.initButton(6); - - _actor11.postInit(); - _actor11.setup(1575, 4, 2); - _actor11.setPosition(Common::Point(84, 116)); - _actor11.hide(); - - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); - R2_GLOBALS._player.enableControl(); - - do { - _field412 = R2_GLOBALS._randomSource.getRandomNumber(20) - 10; - _field414 = R2_GLOBALS._randomSource.getRandomNumber(20) - 10; - } while ((_field412) && (_field414)); - - if (_field412 < 0) - _actor4.hide(); - - if (_field414 < 0) - _actor5.hide(); - - _field416 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; - _field418 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; - - _actor13.postInit(); - _actor13.setup(1575, 2, 4); - - // TODO - warning("TODO: another immense pile of floating operations"); - - _actor12.postInit(); - _actor12.fixPriority(12); - - if (R2_GLOBALS.getFlag(17)) { - _actor13.setPosition(Common::Point(_actor13._position.x + 5, _actor13._position.y)); - _actor12.setPosition(Common::Point(_actor12._position.x + 5, _actor12._position.y)); - } - - _actor14.postInit(); - _actor14.setup(1575, 5, 1); - _actor14.setPosition(Common::Point(85, 176)); - _actor14.fixPriority(7); - _actor14.hide(); - - _actor15.postInit(); - _actor15.setup(1575, 5, 2); - _actor15.setPosition(Common::Point(85, 147)); - _actor15.fixPriority(7); - _actor15.hide(); -} - -void Scene1575::remove() { - SceneExt::remove(); - R2_GLOBALS._uiElements._active = true; -} - -void Scene1575::signal() { - R2_GLOBALS._player.enableControl(); -} - -void Scene1575::process(Event &event) { - Scene::process(event); - - g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject); -} - -void Scene1575::dispatch() { - if (_field412 <= 0) { - ++_field412; - if (_field412 == 0) { - _actor4.show(); - _field412 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; - } - } else { - _field412--; - if (_field412 ==0) { - _actor4.hide(); - _field412 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; - } - } - - if (_field414 <= 0) { - ++_field414; - if (_field414 == 0) { - _actor5.show(); - _field414 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; - } - } else { - _field414--; - if (_field414 == 0) { - _actor5.hide(); - _field414 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; - } - } - - if (_field416 == 0) { - switch(R2_GLOBALS._randomSource.getRandomNumber(3)) { - case 0: - _actor6.hide(); - _actor7.hide(); - _actor8.hide(); - break; - case 1: - _actor6.show(); - _actor7.hide(); - _actor8.hide(); - break; - case 2: - _actor6.show(); - _actor7.show(); - _actor8.hide(); - break; - case 3: - _actor6.show(); - _actor7.show(); - _actor8.show(); - break; - default: - break; - } - _field416 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; - } else { - --_field416; - } - - if (_field418 == 0) { - switch(R2_GLOBALS._randomSource.getRandomNumber(2)) { - case 0: - _actor9.hide(); - _actor10.hide(); - break; - case 1: - _actor9.show(); - _actor10.hide(); - break; - case 2: - _actor9.show(); - _actor10.show(); - break; - default: - break; + _wreckage2.remove(); + R2_INVENTORY.setObjectScene(R2_FUEL_CELL, 0); + R2_GLOBALS._player.enableControl(); + break; + case 1575: + // No break on purpose + case 1583: + _dontExit = false; + _wreckage2.remove(); + R2_INVENTORY.setObjectScene(R2_BATTERY, 0); + R2_GLOBALS._player.enableControl(); + break; + case 1576: + // No break on purpose + case 1584: + R2_GLOBALS._sceneManager.changeScene(1580); + R2_GLOBALS._player.enableControl(); + break; + case 1577: + // No break on purpose + case 1578: + _sceneMode = 0; + _wreckage2.remove(); + _dontExit = false; + R2_GLOBALS._player.fixPriority(-1); + R2_GLOBALS._player.enableControl(); + break; + case 1585: + SceneItem::display(1550, 66, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + R2_GLOBALS._player.enableControl(); + break; + case 1586: + // No break on purpose + case 1587: + R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, R2_GLOBALS._player._characterIndex); + _diagnosticsDisplay.remove(); + _dontExit = false; + R2_GLOBALS._player.enableControl(); + break; + case 1592: + _joystick.remove(); + R2_INVENTORY.setObjectScene(R2_JOYSTICK, 1); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._s1550PlayerArea[R2_SEEKER] = R2_GLOBALS._s1550PlayerArea[R2_QUINN]; + } else { + R2_GLOBALS._s1550PlayerArea[R2_QUINN] = R2_GLOBALS._s1550PlayerArea[R2_SEEKER]; } - _field418 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; - } else { - _field418--; - } - Scene::dispatch(); -} - -/*-------------------------------------------------------------------------- - * Scene 1580 - Inside wreck - * - *--------------------------------------------------------------------------*/ - -Scene1580::Scene1580() { -} - -void Scene1580::synchronize(Serializer &s) { - SceneExt::synchronize(s); -} - -bool Scene1580::JoystickPlug::startAction(CursorType action, Event &event) { - if (action == R2_JOYSTICK) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - - R2_INVENTORY.setObjectScene(R2_JOYSTICK, 1580); - R2_GLOBALS._sceneItems.remove(&scene->_joystickPlug); - scene->_joystick.postInit(); - scene->_joystick.setup(1580, 1, 4); - scene->_joystick.setPosition(Common::Point(159, 163)); - scene->_joystick.setDetails(1550, 78, -1, -1, 2, (SceneItem *) NULL); - - scene->_arrActor[5].remove(); - - return true; + R2_GLOBALS._player.enableControl(CURSOR_WALK); + break; + default: + _sceneMode = 62; + setAction(&_sequenceManager1, this, 1, &R2_GLOBALS._player, NULL); + break; } - - return SceneHotspot::startAction(action, event); } -bool Scene1580::ScreenSlot::startAction(CursorType action, Event &event) { - if (action == R2_DIAGNOSTICS_DISPLAY) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - - R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, 1580); - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._sceneItems.remove(&scene->_screenSlot); - - scene->_screen.postInit(); - scene->_screen.setup(1580, 1, 1); - scene->_screen.setPosition(Common::Point(124, 108)); - scene->_screen.fixPriority(10); - - if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1580) - scene->_screen.setDetails(1550, 14, -1, -1, 5, &scene->_joystick); +void Scene1550::process(Event &event) { + if ((!R2_GLOBALS._player._canWalk) && (R2_GLOBALS._events.getCursor() == R2_NEGATOR_GUN) && (event.eventType == EVENT_BUTTON_DOWN) && (this->_screenNumber == 1234)) { + int curReg = R2_GLOBALS._sceneRegions.indexOf(event.mousePos); + if (curReg == 0) + _dontExit = true; + else if (((R2_GLOBALS._player._position.y < 90) && (event.mousePos.y > 90)) || ((R2_GLOBALS._player._position.y > 90) && (event.mousePos.y < 90))) + _dontExit = true; else - scene->_screen.setDetails(1550, 14, -1, -1, 2, (SceneItem *)NULL); - - scene->_screenDisplay.postInit(); - scene->_screenDisplay.setup(1580, 3, 1); - scene->_screenDisplay.setPosition(Common::Point(124, 109)); - scene->_screenDisplay.fixPriority(20); - //scene->_field412 = 1; - scene->_sceneMode = 10; - scene->setAction(&scene->_sequenceManager, scene, 1, &R2_GLOBALS._player, NULL); + _dontExit = false; - return true; + if ((curReg == 13) || (curReg == 14)) + _dontExit = false; } - return SceneHotspot::startAction(action, event); + Scene::process(event); } -bool Scene1580::Joystick::startAction(CursorType action, Event &event) { - if ( (action == CURSOR_USE) && (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1580) - && (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) == 0) && (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) == 0) - && (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) == 0) && (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 0) - && (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 0) && (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 0)) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - scene->_sceneMode = 31; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->_stripManager.start(536, scene); - else - scene->_stripManager.start(537, scene); - - return true; - } +void Scene1550::dispatch() { + Scene::dispatch(); - return SceneActor::startAction(action, event); -} + // Arrays related to this scene are all hacky in the origina: they are based on the impossibility to use Miranda + assert ((R2_GLOBALS._player._characterIndex == R2_QUINN) || (R2_GLOBALS._player._characterIndex == R2_SEEKER)); -bool Scene1580::Screen::startAction(CursorType action, Event &event) { - if ((action == CURSOR_USE) && (R2_INVENTORY.getObjectScene(R2_BROKEN_DISPLAY) == 1580)) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 15) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 16)) { + R2_GLOBALS._player._shade = 0; - R2_INVENTORY.setObjectScene(R2_BROKEN_DISPLAY, R2_GLOBALS._player._characterIndex); - scene->_screenSlot.setDetails(Rect(69, 29, 177, 108), 1550, 82, -1, -1, 2, NULL); - scene->_screenDisplay.remove(); - remove(); - return true; + // NOTE: Original game contains a switch based on an uninitialized variable. + // We're leaving this code here, but ifdef'ed out, in case we can ever figure out + // what the original programmers intended the value to come from +#if 0 + int missingVariable = 0; + switch (missingVariable) { + case 144: + // No break on purpose + case 146: + _dish._frame = 5; + R2_GLOBALS._player._shade = 3; + break; + case 148: + // No break on purpose + case 149: + _dish._frame = 1; + // No break on purpose + case 147: + // No break on purpose + case 150: + R2_GLOBALS._player._shade = 3; + break; + default: + break; + } +#endif } - return SceneActor::startAction(action, event); -} - -bool Scene1580::StorageCompartment::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._sceneItems.remove(&scene->_storageCompartment); - scene->_sceneMode = 0; - animate(ANIM_MODE_5, scene); - - return true; -} - -bool Scene1580::HatchButton::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - setFrame(2); - scene->_sceneMode = 20; - scene->setAction(&scene->_sequenceManager, scene, 2, &R2_GLOBALS._player, NULL); + if (_dontExit) + return; - return true; -} + switch (R2_GLOBALS._player.getRegionIndex() - 11) { + case 0: + // No break on purpose + case 5: + // Exiting the top of the screen + R2_GLOBALS._player.disableControl(); + _sceneMode = 1; + _dontExit = true; + --R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y; -bool Scene1580::ThrusterValve::startAction(CursorType action, Event &event) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; + enterArea(); - switch (action) { - case CURSOR_USE: - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_INVENTORY.setObjectScene(R2_THRUSTER_VALVE, 1); - remove(); - return true; - } - break; - case R2_COM_SCANNER: - scene->_sceneMode = 30; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - scene->_stripManager.start(529, scene); - return true; - break; - case R2_COM_SCANNER_2: - scene->_sceneMode = 30; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - scene->_stripManager.start(527, scene); - return true; - break; - default: + R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 108) * 172) / 100), 145)); + if (R2_GLOBALS._player._position.x < 160) { + Common::Point pt(R2_GLOBALS._player._position.x + 5, 135); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else if (R2_GLOBALS._player._position.x <= 160) { // the check is really in the original... + Common::Point pt(R2_GLOBALS._player._position.x, 135); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + Common::Point pt(R2_GLOBALS._player._position.x - 5, 135); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } break; - } - - return SceneActor::startAction(action, event); -} + case 1: + // Exiting the bottom of the screen + R2_GLOBALS._player.disableControl(); + _sceneMode = 3; + _dontExit = true; + ++R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y; -bool Scene1580::Ignitor::startAction(CursorType action, Event &event) { - Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; + enterArea(); - switch (action) { - case CURSOR_USE: - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_INVENTORY.setObjectScene(R2_IGNITOR, 1); - remove(); - return true; + R2_GLOBALS._player.setPosition(Common::Point( 160 - (((((160 - R2_GLOBALS._player._position.x) * 100) / 172) * 108) / 100), 19)); + if (R2_GLOBALS._player._position.x < 160) { + Common::Point pt(R2_GLOBALS._player._position.x + 5, 29); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else if (R2_GLOBALS._player._position.x <= 160) { // the check is really in the original... + Common::Point pt(R2_GLOBALS._player._position.x, 29); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + Common::Point pt(R2_GLOBALS._player._position.x - 5, 29); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); } break; - case R2_COM_SCANNER: - scene->_sceneMode = 30; + case 2: + // Exiting the right of the screen R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - scene->_stripManager.start(529, scene); - return true; + _sceneMode = 5; + _dontExit = true; + ++R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x; + + enterArea(); + + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11) && (R2_GLOBALS._player._position.y > 50) && (R2_GLOBALS._player._position.y < 135)) { + if (R2_GLOBALS._player._position.y >= 85) { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 10)); + Common::Point pt(R2_GLOBALS._player._position.x + 30, R2_GLOBALS._player._position.y + 20); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 10)); + Common::Point pt(R2_GLOBALS._player._position.x + 30, R2_GLOBALS._player._position.y - 20); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + } else { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y)); + Common::Point pt(R2_GLOBALS._player._position.x + 10, R2_GLOBALS._player._position.y); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } break; - case R2_COM_SCANNER_2: - scene->_sceneMode = 30; + case 3: + // Exiting to the left of the screen R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - scene->_stripManager.start(527, scene); - return true; + _sceneMode = 7; + _dontExit = true; + --R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x; + + enterArea(); + + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 24) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y / 2)); + Common::Point pt(265, 29); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11) && (R2_GLOBALS._player._position.y > 50) && (R2_GLOBALS._player._position.y < 135)) { + if (R2_GLOBALS._player._position.y >= 85) { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y + 10)); + Common::Point pt(R2_GLOBALS._player._position.x - 30, R2_GLOBALS._player._position.y + 20); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y - 10)); + Common::Point pt(R2_GLOBALS._player._position.x - 30, R2_GLOBALS._player._position.y - 20); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + } else { + R2_GLOBALS._player.setPosition(Common::Point(320 - R2_GLOBALS._player._position.x, R2_GLOBALS._player._position.y)); + Common::Point pt(R2_GLOBALS._player._position.x - 10, R2_GLOBALS._player._position.y); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } break; default: break; } - - return SceneActor::startAction(action, event); } -void Scene1580::postInit(SceneObjectList *OwnerList) { - loadScene(1580); - R2_GLOBALS._sceneManager._fadeMode = FADEMODE_GRADUAL; - SceneExt::postInit(); - - _stripManager.setColors(60, 255); - _stripManager.setFontNumber(3); - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); - - _sceneMode = 0; - - R2_GLOBALS._player.disableControl(); - if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1580) { - _joystick.postInit(); - _joystick.setup(1580, 1, 4); - _joystick.setPosition(Common::Point(159, 163)); - _joystick.setDetails(1550, 78, -1, -1, 1, (SceneItem *) NULL); - } else { - _joystickPlug.setDetails(Rect(141, 148, 179, 167), 1550, 79, -1, -1, 1, NULL); - } - - if (R2_INVENTORY.getObjectScene(R2_BROKEN_DISPLAY) == 1580) { - _screen.postInit(); - _screen.setup(1580, 1, 1); - _screen.setPosition(Common::Point(124, 108)); - _screen.fixPriority(10); - _screen.setDetails(1550, 13, -1, -1, 1, (SceneItem *) NULL); - - _screenDisplay.postInit(); - _screenDisplay.setup(1580, 1, 3); - _screenDisplay.setPosition(Common::Point(124, 96)); - _screenDisplay.fixPriority(20); - } else if (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1580) { - _screen.postInit(); - _screen.setup(1580, 1, 1); - _screen.setPosition(Common::Point(124, 108)); - _screen.fixPriority(10); - _screen.setDetails(1550, 14, -1, -1, 1, (SceneItem *) NULL); - - _screenDisplay.postInit(); - _screenDisplay.setup(1580, 3, 1); - _screenDisplay.setPosition(Common::Point(124, 109)); - _screenDisplay.fixPriority(20); - - _sceneMode = 10; - } else { - _screenSlot.setDetails(Rect(69, 29, 177, 108), 1550, 82, -1, -1, 1, NULL); - } - - _storageCompartment.postInit(); - if (R2_GLOBALS.getFlag(58) == 0) { - _storageCompartment.setup(1580, 5, 1); - _storageCompartment.setDetails(1550, 80, -1, -1, 1, (SceneItem *) NULL); - } else { - _storageCompartment.setup(1580, 5, 6); - } - - _storageCompartment.setPosition(Common::Point(216, 108)); - _storageCompartment.fixPriority(100); - - _hatchButton.postInit(); - _hatchButton.setup(1580, 4, 1); - _hatchButton.setPosition(Common::Point(291, 147)); - _hatchButton.fixPriority(100); - _hatchButton.setDetails(1550, 81, -1, -1, 1, (SceneItem *) NULL); - - if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 1580) { - _thrusterValve.postInit(); - _thrusterValve.setup(1580, 6, 2); - _thrusterValve.setPosition(Common::Point(222, 108)); - _thrusterValve.fixPriority(50); - _thrusterValve.setDetails(1550, 32, -1, 34, 1, (SceneItem *) NULL); - } - - if (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 1580) { - _ignitor.postInit(); - _ignitor.setup(1580, 6, 1); - _ignitor.setPosition(Common::Point(195, 108)); - _ignitor.fixPriority(50); - _ignitor.setDetails(1550, 38, -1, 34, 1, (SceneItem *) NULL); - } +void Scene1550::saveCharacter(int characterIndex) { + if (R2_GLOBALS._player._characterIndex == R2_MIRANDA) + R2_GLOBALS._sound1.fadeOut2(NULL); - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - _background.setDetails(Rect(0, 0, 320, 200), 1550, 50, -1, -1, 1, NULL); + SceneExt::saveCharacter(characterIndex); } -void Scene1580::signal() { - switch (_sceneMode++) { - case 10: - _screenDisplay.animate(ANIM_MODE_5, this); - break; - case 11: - _screenDisplay.setup(1580, 1, 2); - _screenDisplay.setPosition(Common::Point(124, 94)); +void Scene1550::Wall::setupWall(int frameNumber, int strip) { + Scene1550 *scene = (Scene1550 *)R2_GLOBALS._sceneManager._scene; - if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) != 0) { - _arrActor[0].postInit(); - _arrActor[0].setup(1580, 2, 1); - _arrActor[0].setPosition(Common::Point(138, 56)); + postInit(); + if (scene->_wallType == 2) + setup(1551, strip, frameNumber); + else + setup(1554, strip, frameNumber); + + switch (strip) { + case 0: + switch (frameNumber - 1) { + case 0: + setup(1551, 1, 1); + setPosition(Common::Point(30, 67)); + break; + case 1: + setup(1560, 1, 5); + setPosition(Common::Point(141, 54)); + break; + case 2: + setup(1560, 2, 5); + setPosition(Common::Point(178, 54)); + break; + case 3: + setup(1560, 2, 1); + setPosition(Common::Point(289, 67)); + break; + case 4: + setup(1560, 2, 2); + setPosition(Common::Point(298, 132)); + break; + case 5: + setup(1560, 1, 2); + setPosition(Common::Point(21, 132)); + break; + case 6: + setup(1560, 2, 4); + setPosition(Common::Point(285, 123)); + break; + case 7: + setup(1560, 1, 3); + setPosition(Common::Point(30, 111)); + break; + case 8: + setup(1560, 2, 3); + setPosition(Common::Point(289, 111)); + break; + case 9: + setup(1560, 1, 4); + setPosition(Common::Point(34, 123)); + break; + default: + break; } - - if (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) != 0) { - _arrActor[1].postInit(); - _arrActor[1].setup(1580, 2, 2); - _arrActor[1].setPosition(Common::Point(140, 66)); + fixPriority(1); + break; + case 1: + if (frameNumber == 3) { + setup(1553, 3, 1); + setPosition(Common::Point(48, 44)); + fixPriority(2); + } else { + fixPriority(1); + setPosition(Common::Point(32, 17)); } - if (R2_INVENTORY.getObjectScene(R2_IGNITOR) != 0) { - _arrActor[2].postInit(); - _arrActor[2].setup(1580, 2, 3); - _arrActor[2].setPosition(Common::Point(142, 85)); + switch (frameNumber) { + case 2: + setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); + break; + case 3: + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); + break; + default: + setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); + break; } - - if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) != 0) { - _arrActor[3].postInit(); - _arrActor[3].setup(1580, 2, 4); - _arrActor[3].setPosition(Common::Point(142, 92)); + break; + case 2: + fixPriority(1); + switch (frameNumber) { + case 4: + setup(1553, 4, 1); + setPosition(Common::Point(48, 168)); + break; + case 5: + setup(1553, 3, 2); + setPosition(Common::Point(20, 168)); + fixPriority(250); + break; + default: + setPosition(Common::Point(28, 116)); + break; } - if (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) != 0) { - _arrActor[4].postInit(); - _arrActor[4].setup(1580, 2, 5); - _arrActor[4].setPosition(Common::Point(108, 54)); + switch (frameNumber) { + case 2: + setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); + break; + case 4: + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); + break; + case 5: + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); + break; + default: + setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); + break; } - - if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) != 1580) { - _arrActor[5].postInit(); - _arrActor[5].setup(1580, 2, 6); - _arrActor[5].setPosition(Common::Point(110, 64)); + break; + case 3: + switch (frameNumber) { + case 2: + fixPriority(2); + if (scene->_wallType == 2) + setup(1553, 2, 1); + else + setup(1556, 2, 1); + setPosition(Common::Point(160, 44)); + break; + case 3: + fixPriority(2); + setup(1553, 5, 1); + setPosition(Common::Point(178, 44)); + break; + default: + fixPriority(1); + setPosition(Common::Point(160, 17)); + break; } - if (R2_INVENTORY.getObjectScene(R2_BATTERY) != 0) { - _arrActor[6].postInit(); - _arrActor[6].setup(1580, 2, 7); - _arrActor[6].setPosition(Common::Point(108, 80)); + if (frameNumber == 1) + setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); + else + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); + break; + case 4: + if (frameNumber == 2) { + fixPriority(250); + if (scene->_wallType == 2) + setup(1553, 1, 1); + else + setup(1556, 1, 1); + } else { + fixPriority(2); } - if (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) != 0) { - _arrActor[7].postInit(); - _arrActor[7].setup(1580, 2, 8); - _arrActor[7].setPosition(Common::Point(111, 92)); - } + if (frameNumber != 1) + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; + setPosition(Common::Point(160, 168)); break; - case 20: - R2_GLOBALS._sceneManager.changeScene(1550); + case 5: + fixPriority(1); + setPosition(Common::Point(287, 17)); + + switch (frameNumber) { + case 2: + setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); + break; + case 3: + setDetails(1550, 6, -1, -1, 2, (SceneItem *) NULL); + break; + default: + setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); + break; + } break; - case 31: - R2_GLOBALS._sceneManager.changeScene(1530); + case 6: + fixPriority(1); + setPosition(Common::Point(291, 116)); + + if (frameNumber == 2) + setDetails(1550, 3, -1, -1, 2, (SceneItem *) NULL); + else + setDetails(1550, 72, -1, -1, 2, (SceneItem *) NULL); break; default: - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; break; } -} - -/*-------------------------------------------------------------------------- - * Scene 1625 - Miranda being questioned - * - *--------------------------------------------------------------------------*/ - -bool Scene1625::Wire::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1625 *scene = (Scene1625 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - - scene->_sceneMode = 1631; - scene->_mirandaMouth.postInit(); - scene->setAction(&scene->_sequenceManager, scene, 1631, &scene->_mirandaMouth, &scene->_wire, NULL); - return true; -} - -Scene1625::Scene1625() { -} -void Scene1625::synchronize(Serializer &s) { - SceneExt::synchronize(s); } -void Scene1625::postInit(SceneObjectList *OwnerList) { - loadScene(1625); - R2_GLOBALS._player._characterIndex = R2_MIRANDA; - SceneExt::postInit(); - - _stripManager.addSpeaker(&_mirandaSpeaker); - _stripManager.addSpeaker(&_tealSpeaker); - _stripManager.addSpeaker(&_soldierSpeaker); - - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); - - _wire.postInit(); - _wire.setup(1626, 2, 1); - _wire.setPosition(Common::Point(206, 133)); - _wire.setDetails(1625, 0, -1, -1, 1, (SceneItem *) NULL); - - _wristRestraints.postInit(); - _wristRestraints.setup(1625, 8, 1); - _wristRestraints.setPosition(Common::Point(190, 131)); - _wristRestraints.setDetails(1625, 6, -1, 2, 1, (SceneItem *) NULL); +void Scene1550::enterArea() { + _walkRegionsId = 0; + _dishMode = 0; - if (R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] == 1625) { - if (!R2_GLOBALS.getFlag(83)) { - _glass.postInit(); - _glass.setup(1626, 4, 1); - _glass.setPosition(Common::Point(96, 166)); - _glass.setDetails(1625, -1, -1, -1, 1, (SceneItem *) NULL); - } - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; - } else { - _teal.postInit(); - _teal.fixPriority(10); + _wallCorner1.remove(); + _westWall.remove(); + _northWall.remove(); + _southWall.remove(); + _wallCorner2.remove(); + _eastWall.remove(); - _tealRightArm.postInit(); + for (int i = 0; i < 8; ++i) + _junk[i].remove(); - R2_GLOBALS._player.disableControl(); - _sceneMode = 1625; - setAction(&_sequenceManager, this, 1625, &_teal, &_tealRightArm, NULL); - } + _wreckage.remove(); - R2_GLOBALS._sound1.play(245); - _background.setDetails(Rect(0, 0, 320, 200), 1625, 12, -1, -1, 1, NULL); - R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1625; - R2_GLOBALS._player._characterScene[R2_MIRANDA] = 1625; -} + for (int i = 0; i < 8; ++i) + _shipComponents[i].remove(); -void Scene1625::remove() { - R2_GLOBALS._sound1.fadeOut2(NULL); - SceneExt::remove(); -} + _airbag.remove(); + _joystick.remove(); + _gyroscope.remove(); + _wreckage4.remove(); + _diagnosticsDisplay.remove(); -void Scene1625::signal() { - switch (_sceneMode) { - case 10: - R2_GLOBALS._player.disableControl(); - _glass.postInit(); - _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); - _sceneMode = 1626; - setAction(&_sequenceManager, this, 1626, &_tealHead, &_glass, NULL); - break; - case 12: - MessageDialog::show(DONE_MSG, OK_BTN_STRING); + if ((_sceneMode != 1577) && (_sceneMode != 1578)) + _wreckage2.remove(); + + _wreckage3.remove(); + _companion.remove(); + _dish.remove(); + _dishTowerShadow.remove(); + _dishTower.remove(); + _walkway.remove(); + + // Set up of special walk regions for certain areas + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y) { + case 0: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { + case 3: + R2_GLOBALS._walkRegions.load(1554); + _walkRegionsId = 1554; + break; + case 4: + R2_GLOBALS._walkRegions.load(1553); + _walkRegionsId = 1553; + break; + default: + break; + } break; - case 14: - _tealHead.postInit(); - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(831, this); + case 3: + // No break on purpose + case 4: + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 23) || (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x)) { + if (!R2_GLOBALS.getFlag(16)) { + R2_GLOBALS._walkRegions.load(1559); + _walkRegionsId = 1559; + } + } break; - case 99: - R2_GLOBALS._player.disableControl(); - switch (_stripManager._exitMode) { - case 1: - _sceneMode = 1627; - setAction(&_sequenceManager, this, 1627, &_mirandaMouth, &_glass, NULL); - break; - case 2: - _sceneMode = 1629; - setAction(&_sequenceManager, this, 1629, &_tealHead, &_wristRestraints, NULL); + case 7: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { + case 10: + R2_GLOBALS._walkRegions.load(1555); + _walkRegionsId = 1555; break; - case 4: - R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 3150; - R2_GLOBALS._player._characterScene[R2_MIRANDA] = 3150; - R2_GLOBALS._player._characterIndex = R2_QUINN; - R2_GLOBALS._sceneManager.changeScene(R2_GLOBALS._player._characterScene[R2_QUINN]); + case 11: + R2_GLOBALS._walkRegions.load(1556); + _walkRegionsId = 1556; break; - case 5: - _sceneMode = 1628; - _tealHead.remove(); - setAction(&_sequenceManager, this, 1628, &_mirandaMouth, &_glass, NULL); + default: break; - case 6: - _glass.postInit(); - _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); - _sceneMode = 1632; - setAction(&_sequenceManager, this, 1632, &_glass, NULL); + } + break; + case 11: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { + case 24: + R2_GLOBALS._walkRegions.load(1558); + _walkRegionsId = 1558; break; - case 7: - _sceneMode = 1633; - setAction(&_sequenceManager, this, 1633, &_glass, NULL); + case 25: + R2_GLOBALS._walkRegions.load(1557); + _walkRegionsId = 1557; break; - case 8: - _sceneMode = 1635; - setAction(&_sequenceManager, this, 1635, &_mirandaMouth, &_wristRestraints, NULL); + default: break; - case 9: - _glass.postInit(); - _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); - _sceneMode = 1634; - setAction(&_sequenceManager, this, 1634, &_mirandaMouth, &_wristRestraints, NULL); + } + break; + case 16: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x) { + case 2: + R2_GLOBALS._walkRegions.load(1552); + _walkRegionsId = 1552; break; case 3: - // No break on purpose + R2_GLOBALS._walkRegions.load(1551); + _walkRegionsId = 1551; + break; + case 15: + R2_GLOBALS._walkRegions.load(1575); + _walkRegionsId = 1575; default: - _sceneMode = 1630; - _tealHead.remove(); - setAction(&_sequenceManager, this, 1630, &_teal, &_tealRightArm, NULL); break; } - //_field412 = _stripManager._field2E8; - _stripManager._currObj44Id = 0; - break; - case 1625: - _tealHead.postInit(); - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); - _sceneMode = 10; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(800, this); break; - case 1626: - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); - _tealHead.show(); - - _mirandaMouth.postInit(); - _mirandaMouth.setup(1627, 3, 1); - _mirandaMouth.setPosition(Common::Point(196, 65)); - - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(832, this); + default: break; - case 1627: - _mirandaMouth.setup(1627, 3, 1); - _mirandaMouth.setPosition(Common::Point(196, 65)); - _mirandaMouth.show(); + } - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(833, this); - break; - case 1628: - R2_GLOBALS.setFlag(83); - _tealHead.postInit(); - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); + int varA = 0; - _mirandaMouth.setup(1627, 3, 1); - _mirandaMouth.setPosition(Common::Point(196, 65)); - _mirandaMouth.show(); + // This section handles checks if the ARM spacecraft have not yet seized + // control of Lance of Truth. + if (!R2_GLOBALS.getFlag(16)) { + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y - 2) { + case 0: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 22) { + case 0: + varA = 1553; + _northWall.setupWall(6, 0); + break; + case 1: + // No break on purpose + case 2: + // No break on purpose + case 3: + // No break on purpose + case 4: + varA = 1553; + break; + case 5: + varA = 1553; + _northWall.setupWall(6, 0); + break; + default: + break; + } + break; + case 1: + // No break on purpose + case 2: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 21) { + case 0: + varA = 1550; + _northWall.setupWall(9, 0); + break; + case 1: + varA = 1552; + _northWall.setupWall(10, 0); + break; + case 2: + // No break on purpose + case 3: + // No break on purpose + case 4: + // No break on purpose + case 5: + varA = 1552; + break; + case 6: + varA = 1552; + _northWall.setupWall(7, 0); + break; + case 7: + varA = 1550; + _northWall.setupWall(8, 0); + break; + default: + break; + } + break; + case 3: + switch (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x - 21) { + case 0: + varA = 1550; + _northWall.setupWall(4, 0); + break; + case 1: + varA = 1550; + _northWall.setupWall(3, 0); + break; + case 2: + // No break on purpose + case 3: + // No break on purpose + case 4: + // No break on purpose + case 5: + varA = 1551; + break; + case 6: + varA = 1550; + _northWall.setupWall(2, 0); + break; + case 7: + varA = 1550; + _northWall.setupWall(1, 0); + break; + default: + break; + } + break; + default: + break; + } + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y > 0) && + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x <= 29) && + ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x < 20) || + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y > 7))) { + // In an area where the cutscene can be triggered, so start it + R2_GLOBALS.setFlag(16); + R2_GLOBALS._sceneManager.changeScene(1500); + } + } - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(834, this); - break; - case 1629: - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); - _tealHead.show(); + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == 9) && + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 11)) { + if (_screenNumber != 1234) { + R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; + loadScene(1234); + R2_GLOBALS._sceneManager._hasPalette = false; + _wallType = 0; + } + } else if (_screenNumber == 1234) { + R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; + loadScene(1550); + R2_GLOBALS._sceneManager._hasPalette = false; + } - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(805, this); - break; - case 1630: - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = true; - break; - case 1631: - _mirandaMouth.setup(1627, 3, 1); - _mirandaMouth.setPosition(Common::Point(196, 65)); - _mirandaMouth.show(); + if (_screenNumber == 1234) + _walkRegionsId = 1576; - _wire.remove(); + if (_wallType == 0) { + _wallType = 1; + } else { + if (_wallType == 2) { + _wallType = 3; + } else { + _wallType = 2; + } - _teal.postInit(); - _teal.fixPriority(10); + if (R2_GLOBALS._sceneManager._sceneNumber == 1550){ +#if 0 + warning("Mouse_hideIfNeeded()"); + warning("gfx_set_pane_p"); + for (int i = 3; i != 168; ++i) { + warning("sub294D2(4, i, 312, var14C)"); + warning("missing for loop, to be implemented"); + warning("gfx_draw_slice"); + } + warning("gfx_flip_screen()"); + warning("gfx_set_pane_p()"); +#endif + R2_GLOBALS._sceneManager._fadeMode = FADEMODE_IMMEDIATE; - _tealRightArm.postInit(); + if (varA == 0) { + if (_sceneResourceId != 1550) { + g_globals->_scenePalette.loadPalette(1550); + R2_GLOBALS._sceneManager._hasPalette = true; + } + } else { + g_globals->_scenePalette.loadPalette(varA); + R2_GLOBALS._sceneManager._hasPalette = true; + } - R2_INVENTORY.setObjectScene(R2_SUPERCONDUCTOR_WIRE, 3); - _sceneMode = 14; + if (R2_GLOBALS._sceneManager._hasPalette) + _sceneResourceId = varA; - setAction(&_sequenceManager, this, 1625, &_teal, &_tealRightArm, NULL); - break; - case 1632: - _tealHead.setup(1627, 1, 1); - _tealHead.setPosition(Common::Point(68, 68)); - _tealHead.show(); +// warning("sub_2C429()"); + } + } - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(835, this); - break; - case 1633: - _glass.remove(); - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(818, this); + // Scene setup dependent on the type of cell specified in the scene map + switch (scene1550AreaMap[(R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y * 30) + + R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x]) { + case 0: + // Standard cell + if (_walkRegionsId == 0) { + R2_GLOBALS._walkRegions.load(1550); + _walkRegionsId = 1550; + } break; - case 1634: - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(836, this); + case 1: + // North end of the spaceport + if (_walkRegionsId == 0) { + R2_GLOBALS._walkRegions.load(1560); + _walkRegionsId = 1560; + } + _wallCorner1.setupWall(2, 1); + _northWall.setupWall(1, 3); + _wallCorner2.setupWall(2, 5); break; - case 1635: - _mirandaMouth.setup(1627, 3, 1); - _mirandaMouth.setPosition(Common::Point(196, 65)); - _mirandaMouth.show(); - - _sceneMode = 99; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(818, this); + case 2: + R2_GLOBALS._walkRegions.load(1561); + _walkRegionsId = 1561; + _wallCorner1.setupWall(2, 1); + _westWall.setupWall(2, 2); + _northWall.setupWall(1, 3); + _wallCorner2.setupWall(2, 5); break; - default: + case 3: + R2_GLOBALS._walkRegions.load(1562); + _walkRegionsId = 1562; + _wallCorner1.setupWall(2, 1); + _northWall.setupWall(1, 3); + _wallCorner2.setupWall(2, 5); + _eastWall.setupWall(2, 6); + break; + case 4: + R2_GLOBALS._walkRegions.load(1563); + _walkRegionsId = 1563; + _northWall.setupWall(2, 3); + break; + case 5: + R2_GLOBALS._walkRegions.load(1564); + _walkRegionsId = 1564; + _southWall.setupWall(2, 4); + break; + case 6: + R2_GLOBALS._walkRegions.load(1565); + _walkRegionsId = 1565; + _wallCorner1.setupWall(1, 1); + _westWall.setupWall(1, 2); + _northWall.setupWall(3, 3); + break; + case 7: + R2_GLOBALS._walkRegions.load(1566); + _walkRegionsId = 1566; + _wallCorner1.setupWall(1, 1); + _westWall.setupWall(1, 2); + _northWall.setupWall(2, 4); + break; + case 8: + R2_GLOBALS._walkRegions.load(1567); + _walkRegionsId = 1567; + _westWall.setupWall(5, 2); + break; + case 9: + R2_GLOBALS._walkRegions.load(1568); + _walkRegionsId = 1568; + _westWall.setupWall(4, 2); + break; + case 10: + R2_GLOBALS._walkRegions.load(1569); + _walkRegionsId = 1569; + _wallCorner1.setupWall(3, 1); + break; + case 11: + R2_GLOBALS._walkRegions.load(1570); + _walkRegionsId = 1570; + _wallCorner1.setupWall(1, 1); + _westWall.setupWall(1, 2); + break; + case 12: + R2_GLOBALS._walkRegions.load(1571); + _walkRegionsId = 1571; + _wallCorner2.setupWall(1, 5); + _eastWall.setupWall(1, 6); + break; + case 13: + R2_GLOBALS._walkRegions.load(1572); + _walkRegionsId = 1572; + _wallCorner1.setupWall(1, 1); + _westWall.setupWall(1, 2); + _southWall.setupWall(1, 4); + break; + case 14: + R2_GLOBALS._walkRegions.load(1573); + _walkRegionsId = 1573; + _southWall.setupWall(1, 4); + _wallCorner2.setupWall(1, 5); + _eastWall.setupWall(1, 6); + break; + case 15: + // South wall + R2_GLOBALS._walkRegions.load(1574); + _walkRegionsId = 1574; + _southWall.setupWall(1, 4); + break; + case 16: + R2_GLOBALS._walkRegions.load(1570); + _walkRegionsId = 1570; + _wallCorner1.setupWall(2, 1); + _westWall.setupWall(2, 2); + break; + case 17: + R2_GLOBALS._walkRegions.load(1570); + _walkRegionsId = 1570; + _wallCorner1.setupWall(2, 1); + _westWall.setupWall(3, 2); + break; + case 18: + R2_GLOBALS._walkRegions.load(1571); + _walkRegionsId = 1571; + _wallCorner2.setupWall(2, 5); + _eastWall.setupWall(2, 6); + break; + case 19: + R2_GLOBALS._walkRegions.load(1571); + _walkRegionsId = 1571; + _wallCorner2.setupWall(2, 5); + _eastWall.setupWall(3, 6); + break; + default: break; } -} - -void Scene1625::process(Event &event) { - if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) - event.handled = true; - else - Scene::process(event); -} - -/*-------------------------------------------------------------------------- - * Scene 1700 - Rim - * - *--------------------------------------------------------------------------*/ - -Scene1700::Scene1700() { - _walkFlag = 0; -} - -void Scene1700::synchronize(Serializer &s) { - SceneExt::synchronize(s); - - s.syncAsSint16LE(_walkFlag); -} - -bool Scene1700::RimTransport::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); - - Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 4; - - Common::Point pt(271, 90); - PlayerMover *mover = new PlayerMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - - return true; -} - -bool Scene1700::Companion::startAction(CursorType action, Event &event) { - if (action != CURSOR_TALK) - return SceneActor::startAction(action, event); - - Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - scene->_sceneMode = 30; - scene->signal(); - - return true; -} - -void Scene1700::NorthExit::changeScene() { - Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - _moving = false; - scene->_sceneMode = 1; - - Common::Point pt(R2_GLOBALS._player._position.x, 0); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} - -void Scene1700::SouthExit::changeScene() { - Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - _moving = false; - scene->_sceneMode = 2; - - Common::Point pt(R2_GLOBALS._player._position.x, 170); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} - -void Scene1700::WestExit::changeScene() { - Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - _moving = false; - scene->_sceneMode = 6; - - Common::Point pt(0, R2_GLOBALS._player._position.y); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} - -void Scene1700::enterArea() { - Rect tmpRect; - R2_GLOBALS._walkRegions.load(1700); - - _slabWest.remove(); - _slabEast.remove(); - _slabShadowWest.remove(); - _slabShadowEast.remove(); - _westPlatform.remove(); - _rimTransportDoor.remove(); - _rimTransport.remove(); - - if (_sceneMode != 40) { - _ledgeHopper.remove(); - _hatch.remove(); - } - - // The original had manual code here to redraw the background manually when - // changing areas within the scene. Which seems to be totally redundant. - - if (_sceneMode != 40 && R2_GLOBALS._rimLocation == 0) { - // Crashed ledge hopper - _ledgeHopper.postInit(); - _ledgeHopper.setup(1701, 1, 1); - _ledgeHopper.setPosition(Common::Point(220, 137)); - _ledgeHopper.setDetails(1700, 6, -1, -1, 2, (SceneItem *) NULL); - R2_GLOBALS._walkRegions.disableRegion(2); - R2_GLOBALS._walkRegions.disableRegion(12); - } - - if ((R2_GLOBALS._rimLocation + 2) % 4 == 0) { - // The slabs forming the bottom of the regular rings the rim transport travels through - _slabWest.postInit(); - _slabWest.setup(1700, 1, 1); - _slabWest.setPosition(Common::Point(222, 82)); - _slabWest.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); - - _slabShadowWest.postInit(); - _slabShadowWest.setup(1700, 2, 1); - _slabShadowWest.setPosition(Common::Point(177, 82)); - _slabShadowWest.fixPriority(0); - - _slabShadowEast.postInit(); - _slabShadowEast.setup(1700, 2, 2); - _slabShadowEast.setPosition(Common::Point(332, 96)); - _slabShadowEast.fixPriority(0); - - _slabEast.postInit(); - _slabEast.setup(1700, 1, 2); - _slabEast.setPosition(Common::Point(424, 84)); - R2_GLOBALS._walkRegions.disableRegion(11); - } + int di = 0; + int tmpIdx = 0; + for (int i = 0; i < 127 * 4; i += 4) { + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == R2_GLOBALS._scene1550JunkLocations[i]) && + (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == R2_GLOBALS._scene1550JunkLocations[i + 1]) && + (R2_GLOBALS._scene1550JunkLocations[i + 2] != 0)) { + tmpIdx = R2_GLOBALS._scene1550JunkLocations[i + 3]; + _junk[di].postInit(); + _junk[di]._effect = EFFECT_SHADED2; + _junk[di]._shade = 0; + //_junk[di]._junkState = tmpIdx; + _junk[di]._junkNumber = i; + _junk[di].setDetails(1550, 62, -1, 63, 2, (SceneItem *) NULL); + if (R2_GLOBALS._scene1550JunkLocations[i + 2] == 41) { + _junk[di].changeZoom(-1); + _junk[di].setPosition(Common::Point(150, 70)); + _junk[di].setup(1562, 1, 1); - if ((R2_GLOBALS._rimLocation + 399) % 800 == 0) { - // Enable west exit to lift - _westPlatform.postInit(); - _westPlatform.setup(1700, 3, 2); - _westPlatform.setPosition(Common::Point(51, 141)); - _westPlatform.fixPriority(0); - _westPlatform.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[2]); + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[3]); + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[6]); + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[7]); - _westExit._enabled = true; - } else { - R2_GLOBALS._walkRegions.disableRegion(1); - _westExit._enabled = false; + if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1550) { + _joystick.postInit(); + _joystick.setup(1562, 3, 1); + _joystick.setPosition(Common::Point(150, 70)); + _joystick.fixPriority(10); + _joystick.setDetails(1550, 41, -1, 42, 2, (SceneItem *) NULL); + } + } else { + if (R2_GLOBALS._scene1550JunkLocations[i + 2] > 40) { + _junk[di].changeZoom(100); + _junk[di].setup(1561, 1, R2_GLOBALS._scene1550JunkLocations[i + 2] - 40); + } else { + _junk[di].changeZoom(-1); + _junk[di].setup(1552, ((R2_GLOBALS._scene1550JunkLocations[i + 2] - 1) / 5) + 1, ((R2_GLOBALS._scene1550JunkLocations[i + 2] - 1) % 5) + 1); + } + _junk[di].setPosition(Common::Point(scene1550JunkX[tmpIdx], scene1550JunkY[tmpIdx])); + if (scene1550JunkRegions[tmpIdx] != 0) + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[tmpIdx]); + di++; + } + } } - if ( ((!R2_GLOBALS.getFlag(15)) && ((R2_GLOBALS._rimLocation == 25) || (R2_GLOBALS._rimLocation == -3))) - || ((R2_GLOBALS.getFlag(15)) && (R2_GLOBALS._rimLocation == R2_GLOBALS._rimTransportLocation)) - ) { - // Rim transport vechile located - R2_GLOBALS._rimTransportLocation = R2_GLOBALS._rimLocation; - if (!R2_GLOBALS.getFlag(15)) - _walkFlag = true; - - _rimTransport.postInit(); - _rimTransport.setup(1700, 3, 1); - _rimTransport.setPosition(Common::Point(338, 150)); - _rimTransport.setDetails(1700, 9, -1, -1, 2, (SceneItem *) NULL); - _rimTransport.fixPriority(15); - - _rimTransportDoor.postInit(); - _rimTransportDoor.setup(1700, 4, 1); - _rimTransportDoor.setPosition(Common::Point(312, 106)); - _rimTransportDoor.fixPriority(130); - } -} + // Loop for detecting and setting up certain special areas within the map + for (int i = 0; i < 15 * 3; i += 3) { + if ((R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].x == scene1550SpecialAreas[i]) + && (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == scene1550SpecialAreas[i + 1])) { + int areaType = scene1550SpecialAreas[i + 2]; + switch (areaType) { + case 1: + if (!R2_GLOBALS.getFlag(16)) { + _wreckage2.postInit(); + if (R2_GLOBALS._s1550PlayerArea[R2_GLOBALS._player._characterIndex].y == 3) + _wreckage2.setup(1555, 2, 1); + else + _wreckage2.setup(1555, 1, 1); + _wreckage2.setPosition(Common::Point(150, 100)); + _wreckage2.fixPriority(92); + _wreckage2.setDetails(1550, 73, -1, -1, 2, (SceneItem *) NULL); + } + break; + case 2: + _dish.postInit(); + if (R2_GLOBALS.getFlag(19)) + _dish.setup(1556, 3, 5); + else + _dish.setup(1556, 3, 1); + _dish.changeZoom(95); + _dish.setPosition(Common::Point(165, 83)); + _dish.fixPriority(168); + _dish.setDetails(1550, 17, -1, 19, 2, (SceneItem *) NULL); -void Scene1700::postInit(SceneObjectList *OwnerList) { - loadScene(1700); - SceneExt::postInit(); - if (R2_GLOBALS._sceneManager._previousScene == -1) - R2_GLOBALS._sceneManager._previousScene = 1530; + _dishTower.postInit(); + _dishTower.setup(1556, 4, 1); + _dishTower.setPosition(Common::Point(191, 123)); + _dishTower.changeZoom(95); + _dishTower.setDetails(1550, 65, -1, 66, 2, (SceneItem *) NULL); - scalePalette(65, 65, 65); - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); + _dishTowerShadow.postInit(); + _dishTowerShadow._numFrames = 5; + if (R2_GLOBALS.getFlag(19)) + _dishTowerShadow.setup(1556, 8, 5); + else + _dishTowerShadow.setup(1556, 8, 1); - _northExit.setDetails(Rect(94, 0, 319, 12), EXITCURSOR_N, 1700); - _southExit.setDetails(Rect(0, 161, 319, 168), EXITCURSOR_S, 1700); - _westExit.setDetails(Rect(0, 0, 12, 138), EXITCURSOR_W, 1800); + _dishTowerShadow.setPosition(Common::Point(156, 151)); + _dishTowerShadow.fixPriority(10); - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.setPosition(Common::Point(0, 0)); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setVisage(1501); - R2_GLOBALS._player._moveDiff = Common::Point(2, 1); - } else { - R2_GLOBALS._player.setVisage(1506); - R2_GLOBALS._player._moveDiff = Common::Point(3, 1); - } + _walkway.postInit(); + if (R2_GLOBALS.getFlag(20)) + _walkway.setup(1558, 3, 10); + else + _walkway.setup(1558, 3, 1); - _companion.postInit(); - _companion.animate(ANIM_MODE_1, NULL); - _companion.setObjectWrapper(new SceneObjectWrapper()); + _walkway.setPosition(Common::Point(172, 48)); + _walkway.fixPriority(169); + R2_GLOBALS._walkRegions.disableRegion(scene1550JunkRegions[15]); + break; + case 3: + _wreckage.postInit(); + _wreckage.setup(1550, 1, 1); + _wreckage.setPosition(Common::Point(259, 55)); + _wreckage.fixPriority(133); + _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _companion.setVisage(1506); - _companion._moveDiff = Common::Point(3, 1); - _companion.setDetails(9002, 1, -1, -1, 1, (SceneItem *) NULL); - } else { - _companion.setVisage(1501); - _companion._moveDiff = Common::Point(2, 1); - _companion.setDetails(9001, 1, -1, -1, 1, (SceneItem *) NULL); - } + _wreckage2.postInit(); + _wreckage2.setup(1550, 1, 2); + _wreckage2.setPosition(Common::Point(259, 133)); + _wreckage2.fixPriority(105); + _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); + if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 1550) { + _gyroscope.postInit(); + _gyroscope.setup(1550, 7, 2); + _gyroscope.setPosition(Common::Point(227, 30)); + _gyroscope.fixPriority(130); + _gyroscope.setDetails(1550, 29, -1, 63, 2, (SceneItem *) NULL); + } + break; + case 4: + _wreckage.postInit(); + _wreckage.setup(1550, 1, 4); + _wreckage.setPosition(Common::Point(76, 131)); + _wreckage.fixPriority(10); + _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - R2_GLOBALS._sound1.play(134); + _wreckage2.postInit(); + _wreckage2.setup(1550, 1, 3); + _wreckage2.setPosition(Common::Point(76, 64)); + _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); + if (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1550) { + _diagnosticsDisplay.postInit(); + _diagnosticsDisplay.setup(1504, 4, 1); + _diagnosticsDisplay.setPosition(Common::Point(49, 35)); + _diagnosticsDisplay.animate(ANIM_MODE_2, NULL); + _diagnosticsDisplay._numFrames = 4; + _diagnosticsDisplay.fixPriority(65); + _diagnosticsDisplay.setDetails(1550, 14, 15, 63, 2, (SceneItem *) NULL); + } + if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1550) { + _airbag.postInit(); + _airbag.setup(1550, 7, 1); + _airbag.setPosition(Common::Point(45, 44)); + _airbag.fixPriority(150); + _airbag.setDetails(1550, 44, -1, 63, 2, (SceneItem *) NULL); + } + break; + case 5: + _wreckage.postInit(); + _wreckage.setup(1550, 2, 4); + _wreckage.setPosition(Common::Point(243, 131)); + _wreckage.fixPriority(10); + _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - _playerShadow.postInit(); - _playerShadow.fixPriority(10); + _wreckage2.postInit(); + _wreckage2.setup(1550, 2, 3); + _wreckage2.setPosition(Common::Point(243, 64)); + _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); + break; + case 6: + _wreckage.postInit(); + _wreckage.setup(1550, 2, 1); + _wreckage.setPosition(Common::Point(60, 55)); + _wreckage.fixPriority(133); + _wreckage.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _playerShadow.setVisage(1112); - else - _playerShadow.setVisage(1111); + _wreckage2.postInit(); + _wreckage2.setup(1550, 2, 2); + _wreckage2.setPosition(Common::Point(60, 133)); + _wreckage2.fixPriority(106); + _wreckage2.setDetails(1550, 9, -1, -1, 2, (SceneItem *) NULL); + break; + case 7: + _wreckage.postInit(); + _wreckage.setup(1550, 3, 1); + _wreckage.setPosition(Common::Point(281, 132)); + _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); + break; + case 8: + _wreckage.postInit(); + _wreckage.setup(1550, 3, 2); + _wreckage.setPosition(Common::Point(57, 96)); + _wreckage.fixPriority(70); + _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - _playerShadow._effect = EFFECT_SHADOW_MAP; - _playerShadow._shadowMap = _shadowPaletteMap; - R2_GLOBALS._player._linkedActor = &_playerShadow; + _wreckage2.postInit(); + _wreckage2.setup(1550, 3, 3); + _wreckage2.setPosition(Common::Point(145, 88)); + _wreckage2.fixPriority(55); + _wreckage2.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - _companionShadow.postInit(); - _companionShadow.fixPriority(10); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _companionShadow.setVisage(1111); - else - _companionShadow.setVisage(1112); + _wreckage3.postInit(); + _wreckage3.setup(1550, 3, 4); + _wreckage3.setPosition(Common::Point(64, 137)); + _wreckage3.fixPriority(115); + _wreckage3.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - _companionShadow._effect = EFFECT_SHADOW_MAP; - _companionShadow._shadowMap = _shadowPaletteMap; - _companion._linkedActor = &_companionShadow; + _wreckage4.postInit(); + _wreckage4.setup(1550, 5, 1); + _wreckage4.setPosition(Common::Point(60, 90)); + _wreckage4.fixPriority(45); + break; + case 9: + _wreckage.postInit(); + _wreckage.setup(1550, 4, 2); + _wreckage.setPosition(Common::Point(262, 96)); + _wreckage.fixPriority(70); + _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - R2_GLOBALS._sound1.play(134); + _wreckage2.postInit(); + _wreckage2.setup(1550, 4, 3); + _wreckage2.setPosition(Common::Point(174, 88)); + _wreckage2.fixPriority(55); + _wreckage2.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - switch (R2_GLOBALS._sceneManager._previousScene) { - case 1530: - R2_GLOBALS._player._characterIndex = R2_QUINN; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.hide(); - _companion.hide(); + _wreckage3.postInit(); + _wreckage3.setup(1550, 4, 4); + _wreckage3.setPosition(Common::Point(255, 137)); + _wreckage3.fixPriority(115); + _wreckage3.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); - _hatch.postInit(); - _hatch.hide(); + _wreckage4.postInit(); + _wreckage4.setup(1550, 6, 1); + _wreckage4.setPosition(Common::Point(259, 90)); + _wreckage4.fixPriority(45); + break; + case 10: + _wreckage.postInit(); + _wreckage.setup(1550, 4, 1); + _wreckage.setPosition(Common::Point(38, 132)); + _wreckage.setDetails(1550, 56, -1, -1, 2, (SceneItem *) NULL); + break; + case 12: + // Intact ship + _shipComponents[7].setupShipComponent(8); + _shipComponents[0].setupShipComponent(1); + _shipComponents[1].setupShipComponent(2); + _shipComponents[2].setupShipComponent(3); + _shipComponents[3].setupShipComponent(4); + _shipComponents[4].setupShipComponent(5); + _shipComponents[5].setupShipComponent(6); + _shipComponents[6].setupShipComponent(7); + break; + default: + break; + } + } + } - _ledgeHopper.postInit(); - _ledgeHopper.setup(1701, 1, 1); - _ledgeHopper.setPosition(Common::Point(220, 137)); - _ledgeHopper.setDetails(1700, 6, -1, -1, 1, (SceneItem *) NULL); + if (R2_GLOBALS._s1550PlayerArea[R2_QUINN] == R2_GLOBALS._s1550PlayerArea[R2_SEEKER]) { + _companion.postInit(); + _companion._effect = EFFECT_SHADED2; + _companion.changeZoom(-1); - _playerShadow.hide(); - _companionShadow.hide(); - R2_GLOBALS._events.setCursor(CURSOR_WALK); - _stripManager.start(539, this); - _sceneMode = 40; - break; - case 1750: { - R2_GLOBALS._player.setPosition(Common::Point(282, 121)); - _companion.setPosition(Common::Point(282, 139)); - _sceneMode = 8; - Common::Point pt(262, 101); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - Common::Point pt2(262, 119); - NpcMover *mover2 = new NpcMover(); - _companion.addMover(mover2, &pt2, this); - } - break; - case 1800: { - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.setPosition(Common::Point(0, 86)); - _companion.setPosition(Common::Point(0, 64)); - _sceneMode = 7; - R2_GLOBALS._player.setObjectWrapper(NULL); - R2_GLOBALS._player._strip = 1; - Common::Point pt(64, 86); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - _companion.setObjectWrapper(NULL); - _companion._strip = 1; - Common::Point pt2(77, 64); - NpcMover *mover2 = new NpcMover(); - _companion.addMover(mover2, &pt2, NULL); - } - break; - default: + assert((_walkRegionsId >= 1550) && (_walkRegionsId <= 2008)); + R2_GLOBALS._walkRegions.disableRegion(k5A750[_walkRegionsId - 1550]); + _companion.setPosition(Common::Point(scene1550JunkX[k5A76D[_walkRegionsId - 1550]], scene1550JunkY[k5A76D[_walkRegionsId - 1550]] + 8)); if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setPosition(Common::Point(109, 160)); - _companion.setPosition(Common::Point(156, 160)); - R2_GLOBALS._walkRegions.disableRegion(15); + if (R2_GLOBALS._player._characterScene[R2_SEEKER] == 1580) { + _companion.setup(1516, 3, 17); + _companion.setPosition(Common::Point(272, 94)); + _companion.fixPriority(91); + _companion.changeZoom(100); + _companion.setDetails(1550, -1, -1, -1, 5, &_shipComponents[7]); + } else { + _companion.setup(1505, 6, 1); + _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); + } } else { - R2_GLOBALS._player.setPosition(Common::Point(156, 160)); - _companion.setPosition(Common::Point(109, 160)); - R2_GLOBALS._walkRegions.disableRegion(17); + if (R2_GLOBALS._player._characterScene[R2_QUINN] == 1580) { + _companion.setup(1516, 2, 14); + _companion.setPosition(Common::Point(276, 97)); + _companion.fixPriority(91); + _companion.changeZoom(100); + _companion.setDetails(1550, -1, -1, -1, 5, &_shipComponents[7]); + } else { + _companion.setup(1500, 6, 1); + _companion.setDetails(1550, -1, -1, -1, 2, (SceneItem *) NULL); + } } - _sceneMode = 50; - setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); - break; } - R2_GLOBALS._player._characterScene[R2_QUINN] = 1700; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1700; - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1700; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1700; + R2_GLOBALS._uiElements.updateInventory(); +} - enterArea(); +/*-------------------------------------------------------------------------- + * Scene 1575 - Spaceport - unused ship scene + * + *--------------------------------------------------------------------------*/ - _surface.setDetails(1, 1700, 3, -1, -1); - _background.setDetails(Rect(0, 0, 480, 200), 1700, 0, -1, -1, 1, NULL); +Scene1575::Button::Button() { + _buttonId = 0; + _pressed = false; } -void Scene1700::remove() { - R2_GLOBALS._sound1.fadeOut2(NULL); - SceneExt::remove(); +void Scene1575::Button::synchronize(Serializer &s) { + NamedHotspot::synchronize(s); + + s.syncAsSint16LE(_buttonId); + s.syncAsSint16LE(_pressed); } -void Scene1700::signal() { - switch (_sceneMode) { - case 1: { - _sceneMode = 3; - if (R2_GLOBALS._rimLocation < 2400) - ++R2_GLOBALS._rimLocation; - enterArea(); - R2_GLOBALS._player.setPosition(Common::Point(235 - (((((235 - R2_GLOBALS._player._position.x) * 100) / 103) * 167) / 100), 170)); - Common::Point pt(R2_GLOBALS._player._position.x, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); +void Scene1575::Button::process(Event &event) { + Scene1575 *scene = (Scene1575 *)R2_GLOBALS._sceneManager._scene; + bool isInBounds = _bounds.contains(event.mousePos); + CursorType cursor = R2_GLOBALS._events.getCursor(); - if (R2_GLOBALS._player._position.x < 132) { - _companion.setPosition(Common::Point(156, 170)); - Common::Point pt2(156, 160); - NpcMover *mover2 = new NpcMover(); - _companion.addMover(mover2, &pt2, NULL); - R2_GLOBALS._walkRegions.disableRegion(15); - } else { - _companion.setPosition(Common::Point(109, 170)); - Common::Point pt3(109, 160); - NpcMover *mover3 = new NpcMover(); - _companion.addMover(mover3, &pt3, NULL); - R2_GLOBALS._walkRegions.disableRegion(17); - } - } - break; - case 2: { - _sceneMode = 3; - if (R2_GLOBALS._rimLocation > -2400) - --R2_GLOBALS._rimLocation; - enterArea(); - R2_GLOBALS._player.setPosition(Common::Point(235 - (((((235 - R2_GLOBALS._player._position.x) * 100) / 167) * 103) / 100), 0)); - Common::Point pt(R2_GLOBALS._player._position.x, 10); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); + if ((event.eventType == EVENT_BUTTON_DOWN && cursor == CURSOR_USE && isInBounds) || + (_pressed && _buttonId != 1 && event.eventType == EVENT_BUTTON_UP && isInBounds)) { + // Button pressed + _pressed = true; + Common::Point pos = scene->_actor1._position; + event.handled = true; - if (R2_GLOBALS._player._position.x >= 171) { - _companion.setPosition(Common::Point(155, 0)); - Common::Point pt2(155, 10); - NpcMover *mover2 = new NpcMover(); - _companion.addMover(mover2, &pt2, NULL); - R2_GLOBALS._walkRegions.disableRegion(15); - } else { - _companion.setPosition(Common::Point(188, 0)); - Common::Point pt3(188, 10); - NpcMover *mover3 = new NpcMover(); - _companion.addMover(mover3, &pt3, NULL); - R2_GLOBALS._walkRegions.disableRegion(17); - } - } - break; - case 3: - if (!_walkFlag) { - R2_GLOBALS._player.enableControl(CURSOR_WALK); - } else { - R2_GLOBALS.setFlag(15); - _walkFlag = false; - _sceneMode = 31; - R2_GLOBALS._events.setCursor(CURSOR_WALK); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _stripManager.start(542, this); - else - _stripManager.start(543, this); - } - break; - case 4: { - _sceneMode = 5; - Common::Point pt(271, 90); - PlayerMover *mover = new PlayerMover(); - _companion.addMover(mover, &pt, NULL); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - setAction(&_sequenceManager, this, 1700, &R2_GLOBALS._player, &_rimTransportDoor, NULL); - else - setAction(&_sequenceManager, this, 1701, &R2_GLOBALS._player, &_rimTransportDoor, NULL); - } - break; - case 5: - R2_GLOBALS._sceneManager.changeScene(1750); - break; - case 6: - R2_GLOBALS._sceneManager.changeScene(1800); - break; - case 7: - R2_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper()); - R2_GLOBALS._player._strip = 1; - _companion.setObjectWrapper(new SceneObjectWrapper()); - _companion._strip = 1; - R2_GLOBALS._player.enableControl(CURSOR_WALK); - R2_GLOBALS._walkRegions.disableRegion(14); - break; - case 8: - R2_GLOBALS._player._strip = 2; - _companion._strip = 1; - R2_GLOBALS._player.enableControl(CURSOR_WALK); - R2_GLOBALS._walkRegions.disableRegion(12); - break; - case 30: - _sceneMode = 31; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _stripManager.start(540, this); - else - _stripManager.start(541, this); - break; - case 31: - R2_GLOBALS._player.enableControl(CURSOR_TALK); - break; - case 40: - R2_GLOBALS._player.disableControl(); - _sceneMode = 1704; - setAction(&_sequenceManager, this, 1704, &R2_GLOBALS._player, &_companion, - &_hatch, &_ledgeHopper, &_playerShadow, &_companionShadow, NULL); - break; - case 50: - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - R2_GLOBALS._walkRegions.disableRegion(15); - else - R2_GLOBALS._walkRegions.disableRegion(17); + if (!R2_GLOBALS.getFlag(18) || _buttonId <= 1 || _buttonId >= 6) { + switch (_buttonId) { + case 1: + if (R2_GLOBALS.getFlag(18)) { + scene->_actor14.hide(); + scene->_actor15.hide(); + R2_GLOBALS.clearFlag(18); + } else if ((scene->_actor12._position.x == 85) && (scene->_actor12._position.y == 123)) { + scene->_actor14.show(); + scene->_actor15.show(); + R2_GLOBALS.setFlag(18); + } else { + SceneItem::display("That's probably not a good thing, ya know!"); + } + break; + case 2: + if (scene->_field41A < 780) { + if (pos.x > 54) + pos.x -= 65; + pos.x += 2; + scene->_field41A += 2; - R2_GLOBALS._player.enableControl(); - break; - case 1704: - R2_GLOBALS._sound1.play(134); - R2_GLOBALS._walkRegions.disableRegion(15); - R2_GLOBALS._walkRegions.disableRegion(2); - R2_GLOBALS._walkRegions.disableRegion(12); - R2_GLOBALS._player.fixPriority(-1); - R2_GLOBALS._player.enableControl(CURSOR_WALK); - break; - default: - R2_GLOBALS._player.enableControl(); - break; - } -} + for (int i = 0; i < 17; i++) + scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x + 2, scene->_arrActor[i]._position.y)); -/*-------------------------------------------------------------------------- - * Scene 1750 - Maintaiance Vechile - * - *--------------------------------------------------------------------------*/ + scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x + 2, scene->_actor13._position.y)); + scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x + 2, scene->_actor12._position.y)); + scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); + scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); + scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); + } + break; + case 3: + if (scene->_field41A > 0) { + if (pos.x < -8) + pos.x += 65; + + pos.x -= 2; + scene->_field41A -= 2; + for (int i = 0; i < 17; i++) + scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x - 2, scene->_arrActor[i]._position.y)); + + scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x - 2, scene->_actor13._position.y)); + scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x - 2, scene->_actor12._position.y)); + scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); + scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); + scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); + } + break; + case 4: { + if (pos.y < 176) { + ++pos.y; + for (int i = 0; i < 17; ++i) + scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x, scene->_arrActor[i]._position.y + 1)); + + scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x, scene->_actor13._position.y + 1)); + scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x, scene->_actor12._position.y + 1)); + scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); + scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); + scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); + } + } + break; + case 5: { + if (pos.y > 145) { + --pos.y; + for (int i = 0; i < 17; ++i) + scene->_arrActor[i].setPosition(Common::Point(scene->_arrActor[i]._position.x, scene->_arrActor[i]._position.y - 1)); + + scene->_actor13.setPosition(Common::Point(scene->_actor13._position.x, scene->_actor13._position.y - 1)); + scene->_actor12.setPosition(Common::Point(scene->_actor12._position.x, scene->_actor12._position.y - 1)); + scene->_actor1.setPosition(Common::Point(pos.x, pos.y)); + scene->_actor2.setPosition(Common::Point(pos.x + 65, pos.y)); + scene->_actor3.setPosition(Common::Point(pos.x + 130, pos.y)); + } + } + break; + case 6: + R2_GLOBALS._sceneManager.changeScene(1550); + break; + default: + break; + } -Scene1750::Button::Button() { - _buttonId = 0; -} + int j = 0; + for (int i = 0; i < 17; i++) { + if (scene->_arrActor[i]._bounds.contains(85, 116)) + j = i; + } -void Scene1750::Button::synchronize(Serializer &s) { - SceneActor::synchronize(s); + if (scene->_actor13._bounds.contains(85, 116)) + j = 18; - s.syncAsSint16LE(_buttonId); + if (scene->_actor12._bounds.contains(85, 116)) + j = 19; + + if (j) + scene->_actor11.show(); + else + scene->_actor11.hide(); + } else { + SceneItem::display("Better not move the laser while it's firing!"); + } + } else { + _pressed = false; + } } -bool Scene1750::Button::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); +bool Scene1575::Button::startAction(CursorType action, Event &event) { + if (action == CURSOR_USE) + return false; + return SceneHotspot::startAction(action, event); +} - Scene1750 *scene = (Scene1750 *)R2_GLOBALS._sceneManager._scene; +void Scene1575::Button::initButton(int buttonId) { + _buttonId = buttonId; + _pressed = false; + EventHandler::postInit(); switch (_buttonId) { case 1: - // Forward button - show(); - scene->_backwardButton.hide(); - if (scene->_speed < 0) - scene->_speed = -scene->_speed; - scene->_direction = 1; + setDetails(Rect(53, 165, 117, 190), -1, -1, -1, 2, 1, NULL); break; case 2: - // Backwards button - show(); - scene->_forwardButton.hide(); - if (scene->_speed > 0) - scene->_speed = -scene->_speed; - scene->_direction = -1; + setDetails(Rect(151, 142, 189, 161), -1, -1, -1, 2, 1, NULL); break; case 3: - // Exit button - if (scene->_rotation->_idxChange == 0) { - show(); - R2_GLOBALS._sceneManager.changeScene(1700); - } else { - scene->_speed = 0; - scene->_speedSlider._moveRate = 20; - scene->_forwardButton._moveDiff.y = 1; - Common::Point pt(286, 143); - NpcMover *mover = new NpcMover(); - scene->_speedSlider.addMover(mover, &pt, NULL); - } + setDetails(Rect(225, 142, 263, 161), -1, -1, -1, 2, 1, NULL); + break; + case 4: + setDetails(Rect(188, 122, 226, 140), -1, -1, -1, 2, 1, NULL); + break; + case 5: + setDetails(Rect(188, 162, 226, 180), -1, -1, -1, 2, 1, NULL); + break; + case 6: + setDetails(Rect(269, 169, 301, 185), -1, -1, -1, 2, 1, NULL); + break; default: break; } - - return true; -} - -/*------------------------------------------------------------------------*/ - -Scene1750::SpeedSlider::SpeedSlider() { - _incrAmount = 0; - _xp = 0; - _ys = 0; - _height = 0; - _thumbHeight = 0; - _mouseDown = false; } -void Scene1750::SpeedSlider::synchronize(Serializer &s) { - SceneActor::synchronize(s); +/*--------------------------------------------------------------------------*/ - s.syncAsSint16LE(_incrAmount); - s.syncAsSint16LE(_xp); - s.syncAsSint16LE(_ys); - s.syncAsSint16LE(_height); - s.syncAsSint16LE(_thumbHeight); - s.syncAsSint16LE(_mouseDown); +Scene1575::Scene1575() { + _field412 = 0; + _field414 = 390; + _field416 = 0; + _field418 = 0; + _field41A = 0; } -void Scene1750::SpeedSlider::setupSlider(int incrAmount, int xp, int ys, int height, int thumbHeight) { - _mouseDown = false; - _incrAmount = incrAmount; - _xp = xp; - _ys = ys; - _height = height; - _thumbHeight = thumbHeight; +void Scene1575::synchronize(Serializer &s) { + SceneExt::synchronize(s); - postInit(); - setup(1750, 1, 1); - fixPriority(255); - setPosition(Common::Point(_xp, _ys + ((_height * (incrAmount - 1)) / (_thumbHeight - 1)))); + s.syncAsSint16LE(_field412); + s.syncAsSint16LE(_field414); + s.syncAsSint16LE(_field416); + s.syncAsSint16LE(_field418); + s.syncAsSint16LE(_field41A); } -void Scene1750::SpeedSlider::calculateSlider() { - Scene1750 *scene = (Scene1750 *)R2_GLOBALS._sceneManager._scene; - - int tmpVar = (_height / (_thumbHeight - 1)) / 2; - int tmpVar2 = ((_position.y - _ys + tmpVar) * _thumbHeight) / (_height + 2 * tmpVar); - - setPosition(Common::Point(_xp, _ys + ((_height * tmpVar2) / (_thumbHeight - 1)))); - scene->_speed = scene->_direction * tmpVar2; +double hypotenuse(double v1, double v2) { + return sqrt(v1 * v1 + v2 * v2); } -void Scene1750::SpeedSlider::process(Event &event) { - if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) && - (_bounds.contains(event.mousePos))) { - _mouseDown = true; - event.eventType = EVENT_NONE; - } - - if ((event.eventType == EVENT_BUTTON_UP) && _mouseDown) { - _mouseDown = false; - event.handled = true; - addMover(NULL); - calculateSlider(); - } - - if (_mouseDown) { - event.handled = true; - if (event.mousePos.y >= _ys) { - if (_ys + _height >= event.mousePos.y) - setPosition(Common::Point(_xp, event.mousePos.y)); - else - setPosition(Common::Point(_xp, _ys + _height)); - } else { - setPosition(Common::Point(_xp, _ys)); - } - } -} +void Scene1575::postInit(SceneObjectList *OwnerList) { + loadScene(1575); + R2_GLOBALS._uiElements._active = false; + SceneExt::postInit(); + R2_GLOBALS._interfaceY = SCREEN_HEIGHT; -bool Scene1750::SpeedSlider::startAction(CursorType action, Event &event) { - if (action == CURSOR_USE) - return SceneActor::startAction(action, event); + _actor1.postInit(); + _actor1.setup(1575, 1, 1); + _actor1.setPosition(Common::Point(54, 161)); + _actor1.fixPriority(5); - return false; -} + _actor2.postInit(); + _actor2.setup(1575, 1, 1); + _actor2.setPosition(Common::Point(119, 161)); + _actor2.fixPriority(5); -/*------------------------------------------------------------------------*/ + _actor3.postInit(); + _actor3.setup(1575, 1, 1); + _actor3.setPosition(Common::Point(184, 161)); + _actor3.fixPriority(5); -Scene1750::Scene1750() { - _direction = 0; - _speedCurrent = 0; - _speed = 0; - _speedDelta = 0; - _rotationSegment = 0; - _rotationSegCurrent = 0; - _newRotation = 0; + for (int i = 0; i < 17; i++) { + _arrActor[i].postInit(); + _arrActor[i].setup(1575, 2, k5A7F6[3 * i + 2]); - _rotation = nullptr; -} + double v1 = hypotenuse(2.0, 3 - k5A7F6[3 * i]); + v1 += hypotenuse(2.0, 3 - k5A7F6[3 * i + 1]); + int yp = (int)(sqrt(v1) * 75.0 / 17.0 - 161.0); -void Scene1750::synchronize(Serializer &s) { - SceneExt::synchronize(s); - SYNC_POINTER(_rotation); + int angle = R2_GLOBALS._gfxManagerInstance.getAngle( + Common::Point(3, 16), Common::Point(k5A7F6[3 * i], k5A7F6[3 * i + 1])); + int xp = angle * 78 / 9 - 319; - s.syncAsSint16LE(_direction); - s.syncAsSint16LE(_speedCurrent); - s.syncAsSint16LE(_speed); - s.syncAsSint16LE(_speedDelta); - s.syncAsSint16LE(_rotationSegment); - s.syncAsSint16LE(_rotationSegCurrent); - s.syncAsSint16LE(_newRotation); -} + _arrActor[i].setPosition(Common::Point(xp, yp)); + _arrActor[i].fixPriority(6); + } -void Scene1750::postInit(SceneObjectList *OwnerList) { - loadScene(1750); - R2_GLOBALS._sound1.play(115); - R2_GLOBALS._uiElements._active = false; + _actor4.postInit(); + _actor4.setup(1575, 3, 1); + _actor4.setPosition(Common::Point(48, 81)); - SceneExt::postInit(); - R2_GLOBALS._interfaceY = SCREEN_HEIGHT; + _actor5.postInit(); + _actor5.setup(1575, 3,1); + _actor5.setPosition(Common::Point(121, 81)); - R2_GLOBALS._player._characterScene[R2_QUINN] = 1750; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1750; - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1750; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1750; + _actor6.postInit(); + _actor6.setup(1575, 3, 2); + _actor6.setPosition(Common::Point(203, 80)); - _rotation = R2_GLOBALS._scenePalette.addRotation(224, 254, 1); - _rotation->setDelay(0); - _rotation->_idxChange = 0; - _rotation->_countdown = 2; + _actor7.postInit(); + _actor7.setup(1575, 3, 2); + _actor7.setPosition(Common::Point(217, 80)); - switch ((R2_GLOBALS._rimLocation + 2) % 4) { - case 0: - _rotation->_currIndex = 247; - break; - case 1: - _rotation->_currIndex = 235; - break; - case 2: - _rotation->_currIndex = 239; - break; - case 3: - _rotation->_currIndex = 243; - break; - default: - break; - } + _actor8.postInit(); + _actor8.setup(1575, 3, 2); + _actor8.setPosition(Common::Point(231, 80)); - byte tmpPal[768]; + _actor9.postInit(); + _actor9.setup(1575, 3, 2); + _actor9.setPosition(Common::Point(273, 91)); - for (int i = 224; i < 255; i++) { - int tmpIndex = _rotation->_currIndex - 224; - if (tmpIndex > 254) - tmpIndex -= 31; - tmpPal[3 * i] = R2_GLOBALS._scenePalette._palette[3 * tmpIndex]; - tmpPal[(3 * i) + 1] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 1]; - tmpPal[(3 * i) + 2] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 2]; - } + _actor10.postInit(); + _actor10.setup(1575, 3, 2); + _actor10.setPosition(Common::Point(287, 91)); - for (int i = 224; i < 255; i++) { - R2_GLOBALS._scenePalette._palette[3 * i] = tmpPal[3 * i]; - R2_GLOBALS._scenePalette._palette[(3 * i) + 1] = tmpPal[(3 * i) + 1]; - R2_GLOBALS._scenePalette._palette[(3 * i) + 2] = tmpPal[(3 * i) + 2]; - } + // Initialize buttons + _button1.initButton(1); + _button2.initButton(2); + _button3.initButton(3); + _button4.initButton(4); + _button5.initButton(5); + _button6.initButton(6); + + _actor11.postInit(); + _actor11.setup(1575, 4, 2); + _actor11.setPosition(Common::Point(84, 116)); + _actor11.hide(); R2_GLOBALS._player.postInit(); R2_GLOBALS._player.hide(); R2_GLOBALS._player.enableControl(); - _radarSweep.postInit(); - _radarSweep.setup(1750, 3, 1); - _radarSweep.setPosition(Common::Point(49, 185)); - _radarSweep.fixPriority(7); - _radarSweep.setDetails(1750, 30, -1, -1, 1, (SceneItem *) NULL); - - _scannerIcon.postInit(); - _scannerIcon.setup(1750, 2, 1); - _scannerIcon.setPosition(Common::Point(35, ((_rotation->_currIndex - 218) % 4) + ((R2_GLOBALS._rimLocation % 800) * 4) - 1440)); - _scannerIcon.fixPriority(8); + do { + _field412 = R2_GLOBALS._randomSource.getRandomNumber(20) - 10; + _field414 = R2_GLOBALS._randomSource.getRandomNumber(20) - 10; + } while ((_field412) && (_field414)); - _redLights.postInit(); - _redLights.setup(1750, 1, 4); + if (_field412 < 0) + _actor4.hide(); - int tmpVar = ABS(_scannerIcon._position.y - 158) / 100; + if (_field414 < 0) + _actor5.hide(); - if (tmpVar >= 8) - _redLights.hide(); - else if (_scannerIcon._position.y <= 158) - _redLights.setPosition(Common::Point(137, (tmpVar * 7) + 122)); - else - _redLights.setPosition(Common::Point(148, (tmpVar * 7) + 122)); + _field416 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; + _field418 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; - _speedSlider.setupSlider(1, 286, 143, 41, 15); - _speedSlider.setDetails(1750, 24, 1, -1, 1, (SceneItem *) NULL); + _actor13.postInit(); + _actor13.setup(1575, 2, 4); - _forwardButton.postInit(); - _forwardButton._buttonId = 1; - _forwardButton.setup(1750, 1, 2); - _forwardButton.setPosition(Common::Point(192, 140)); - _forwardButton.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL); + // TODO + warning("TODO: another immense pile of floating operations"); - _backwardButton.postInit(); - _backwardButton._buttonId = 2; - _backwardButton.setup(1750, 1, 3); - _backwardButton.setPosition(Common::Point(192, 163)); - _backwardButton.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL); - _backwardButton.hide(); + _actor12.postInit(); + _actor12.fixPriority(12); - _exitButton.postInit(); - _exitButton._buttonId = 3; - _exitButton.setup(1750, 1, 5); - _exitButton.setPosition(Common::Point(230, 183)); - _exitButton.setDetails(1750, 27, 1, -1, 1, (SceneItem *) NULL); + if (R2_GLOBALS.getFlag(17)) { + _actor13.setPosition(Common::Point(_actor13._position.x + 5, _actor13._position.y)); + _actor12.setPosition(Common::Point(_actor12._position.x + 5, _actor12._position.y)); + } - _direction = 1; // Forward by default - _speedDelta = 0; - _speedCurrent = 0; - _speed = 0; - _rotationSegment = ((_rotation->_currIndex - 218) / 4) % 4; + _actor14.postInit(); + _actor14.setup(1575, 5, 1); + _actor14.setPosition(Common::Point(85, 176)); + _actor14.fixPriority(7); + _actor14.hide(); - _redLightsDescr.setDetails(Rect(129, 112, 155, 175), 1750, 21, -1, -1, 1, NULL); - _greenLights.setDetails(Rect(93, 122, 126, 172), 1750, 15, -1, -1, 1, NULL); - _frontView.setDetails(Rect(3, 3, 157, 99), 1750, 9, -1, -1, 1, NULL); - _rearView.setDetails(Rect(162, 3, 316, 99), 1750, 12, -1, -1, 1, NULL); - _background.setDetails(Rect(0, 0, 320, 200), 1750, 6, 1, -1, 1, NULL); + _actor15.postInit(); + _actor15.setup(1575, 5, 2); + _actor15.setPosition(Common::Point(85, 147)); + _actor15.fixPriority(7); + _actor15.hide(); } -void Scene1750::remove() { - if (R2_GLOBALS._rimLocation == 2400) - R2_GLOBALS._rimLocation = 2399; - - if (R2_GLOBALS._rimLocation == -2400) - R2_GLOBALS._rimLocation = -2399; - - R2_GLOBALS._rimTransportLocation = R2_GLOBALS._rimLocation; - +void Scene1575::remove() { SceneExt::remove(); - R2_GLOBALS._sound1.fadeOut2(NULL); R2_GLOBALS._uiElements._active = true; } -void Scene1750::signal() { +void Scene1575::signal() { R2_GLOBALS._player.enableControl(); } -void Scene1750::process(Event &event) { +void Scene1575::process(Event &event) { Scene::process(event); - if (!event.handled) - _speedSlider.process(event); -} -void Scene1750::dispatch() { - if (_rotation) { - if (!_speedDelta && (_speed != _speedCurrent)) { - if (_speedCurrent >= _speed) - --_speedCurrent; - else - ++_speedCurrent; + g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject); +} - _speedDelta = 21 - ABS(_speedCurrent); +void Scene1575::dispatch() { + if (_field412 <= 0) { + ++_field412; + if (_field412 == 0) { + _actor4.show(); + _field412 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; } - - if (_speedDelta == 1) { - if (_speedCurrent == 0) { - _radarSweep.show(); - _rotation->_idxChange = 0; - } else { - if (_rotation->_idxChange == 0) - _radarSweep.hide(); - - if (_speedCurrent < -12) { - _rotation->setDelay(15 - ABS(_speedCurrent)); - _rotation->_idxChange = -2; - } else if (_speedCurrent < 0) { - _rotation->setDelay(10 - ABS(_speedCurrent)); - _rotation->_idxChange = -1; - } else if (_speedCurrent < 11) { - _rotation->setDelay(10 - _speedCurrent); - _rotation->_idxChange = 1; - } else { - _rotation->setDelay(15 - _speedCurrent); - _rotation->_idxChange = 2; - } - } + } else { + _field412--; + if (_field412 ==0) { + _actor4.hide(); + _field412 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; } + } - if (_speedDelta) - --_speedDelta; - - _rotationSegCurrent = _rotationSegment; - _rotationSegment = ((_rotation->_currIndex - 218) / 4) % 4; - - if ((_rotationSegCurrent + 1) == _rotationSegment || (_rotationSegCurrent - 3) == _rotationSegment) { - if (R2_GLOBALS._rimLocation < 2400) { - ++R2_GLOBALS._rimLocation; - } + if (_field414 <= 0) { + ++_field414; + if (_field414 == 0) { + _actor5.show(); + _field414 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; } - - if ((_rotationSegCurrent - 1) == _rotationSegment || (_rotationSegCurrent + 3) == _rotationSegment) { - if (R2_GLOBALS._rimLocation > -2400) { - --R2_GLOBALS._rimLocation; - } + } else { + _field414--; + if (_field414 == 0) { + _actor5.hide(); + _field414 = R2_GLOBALS._randomSource.getRandomNumber(9) + 1; } + } - if (_rotation->_currIndex != _newRotation) { - // Handle setting the position of the lift icon in the scanner display - _newRotation = _rotation->_currIndex; - _scannerIcon.setPosition(Common::Point(35, ((_rotation->_currIndex - 218) % 4) + - ((R2_GLOBALS._rimLocation % 800) * 4) - 1440)); + if (_field416 == 0) { + switch(R2_GLOBALS._randomSource.getRandomNumber(3)) { + case 0: + _actor6.hide(); + _actor7.hide(); + _actor8.hide(); + break; + case 1: + _actor6.show(); + _actor7.hide(); + _actor8.hide(); + break; + case 2: + _actor6.show(); + _actor7.show(); + _actor8.hide(); + break; + case 3: + _actor6.show(); + _actor7.show(); + _actor8.show(); + break; + default: + break; } + _field416 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; + } else { + --_field416; } - int v = ABS(_scannerIcon._position.y - 158) / 100; - if (v < 8) { - // Show how close the user is to the lift on the second column of lights - _redLights.show(); - _redLights.setPosition(Common::Point((_scannerIcon._position.y <= 158) ? 137 : 148, - v * 7 + 122)); + if (_field418 == 0) { + switch(R2_GLOBALS._randomSource.getRandomNumber(2)) { + case 0: + _actor9.hide(); + _actor10.hide(); + break; + case 1: + _actor9.show(); + _actor10.hide(); + break; + case 2: + _actor9.show(); + _actor10.show(); + break; + default: + break; + } + _field418 = R2_GLOBALS._randomSource.getRandomNumber(4) + 1; } else { - _redLights.hide(); + _field418--; } + Scene::dispatch(); } /*-------------------------------------------------------------------------- - * Scene 1800 - Rim Lift Exterior + * Scene 1580 - Inside wreck * *--------------------------------------------------------------------------*/ -Scene1800::Scene1800() { - _locationMode = 0; +Scene1580::Scene1580() { } -void Scene1800::synchronize(Serializer &s) { +void Scene1580::synchronize(Serializer &s) { SceneExt::synchronize(s); +} - s.syncAsSint16LE(_locationMode); +bool Scene1580::JoystickPlug::startAction(CursorType action, Event &event) { + if (action == R2_JOYSTICK) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; + + R2_INVENTORY.setObjectScene(R2_JOYSTICK, 1580); + R2_GLOBALS._sceneItems.remove(&scene->_joystickPlug); + scene->_joystick.postInit(); + scene->_joystick.setup(1580, 1, 4); + scene->_joystick.setPosition(Common::Point(159, 163)); + scene->_joystick.setDetails(1550, 78, -1, -1, 2, (SceneItem *) NULL); + + scene->_arrActor[5].remove(); + + return true; + } + + return SceneHotspot::startAction(action, event); } -bool Scene1800::Background::startAction(CursorType action, Event &event) { - if ((action != R2_COM_SCANNER) && (action != R2_COM_SCANNER_2)) - return false; +bool Scene1580::ScreenSlot::startAction(CursorType action, Event &event) { + if (action == R2_DIAGNOSTICS_DISPLAY) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + R2_INVENTORY.setObjectScene(R2_DIAGNOSTICS_DISPLAY, 1580); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._sceneItems.remove(&scene->_screenSlot); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_screen.postInit(); + scene->_screen.setup(1580, 1, 1); + scene->_screen.setPosition(Common::Point(124, 108)); + scene->_screen.fixPriority(10); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS._rimLocation == 1201) { - scene->_stripManager.start(548, this); - } else if (R2_GLOBALS.getFlag(66)) { - return false; - } else { - scene->_stripManager.start(546, this); - } - } else { - if (R2_GLOBALS._rimLocation == 1201) { - scene->_stripManager.start(549, this); - } else if (R2_GLOBALS.getFlag(66)) { - return false; - } else { - scene->_stripManager.start(547, this); - } + if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1580) + scene->_screen.setDetails(1550, 14, -1, -1, 5, &scene->_joystick); + else + scene->_screen.setDetails(1550, 14, -1, -1, 2, (SceneItem *)NULL); + + scene->_screenDisplay.postInit(); + scene->_screenDisplay.setup(1580, 3, 1); + scene->_screenDisplay.setPosition(Common::Point(124, 109)); + scene->_screenDisplay.fixPriority(20); + //scene->_field412 = 1; + scene->_sceneMode = 10; + scene->setAction(&scene->_sequenceManager, scene, 1, &R2_GLOBALS._player, NULL); + + return true; } - R2_GLOBALS.setFlag(66); - return true; + return SceneHotspot::startAction(action, event); } -bool Scene1800::Lever::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); +bool Scene1580::Joystick::startAction(CursorType action, Event &event) { + if ( (action == CURSOR_USE) && (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1580) + && (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) == 0) && (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) == 0) + && (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) == 0) && (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) == 0) + && (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 0) && (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 0)) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; + scene->_sceneMode = 31; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->_stripManager.start(536, scene); + else + scene->_stripManager.start(537, scene); - if (!R2_GLOBALS.getFlag(14)) - return false; + return true; + } - if (R2_GLOBALS._player._characterIndex != R2_QUINN) - return SceneActor::startAction(action, event); + return SceneActor::startAction(action, event); +} - Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); +bool Scene1580::Screen::startAction(CursorType action, Event &event) { + if ((action == CURSOR_USE) && (R2_INVENTORY.getObjectScene(R2_BROKEN_DISPLAY) == 1580)) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - if (_frame == 1) { - R2_GLOBALS.setFlag(64); - scene->_sceneMode = 1810; - scene->setAction(&scene->_sequenceManager, scene, 1810, &R2_GLOBALS._player, &scene->_lever, &scene->_leftStaircase, &scene->_rightStaircase, NULL); - } else { - R2_GLOBALS.clearFlag(64); - scene->_sceneMode = 1811; - scene->setAction(&scene->_sequenceManager, scene, 1811, &R2_GLOBALS._player, &scene->_lever, &scene->_leftStaircase, &scene->_rightStaircase, NULL); + R2_INVENTORY.setObjectScene(R2_BROKEN_DISPLAY, R2_GLOBALS._player._characterIndex); + scene->_screenSlot.setDetails(Rect(69, 29, 177, 108), 1550, 82, -1, -1, 2, NULL); + scene->_screenDisplay.remove(); + remove(); + return true; } - return true; + + return SceneActor::startAction(action, event); } -bool Scene1800::Doors::startAction(CursorType action, Event &event) { +bool Scene1580::StorageCompartment::startAction(CursorType action, Event &event) { if (action != CURSOR_USE) return SceneActor::startAction(action, event); - Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { - // Seeker trying to force open the door - R2_GLOBALS._player.disableControl(); - if (scene->_locationMode >= 2) { - if (R2_GLOBALS.getFlag(14)) { - // Allow door to close - scene->_sceneMode = 1809; - scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - // Force open door - scene->_sceneMode = 1808; - scene->setAction(&scene->_sequenceManager, scene, 1808, &R2_GLOBALS._player, &scene->_doors, NULL); - R2_GLOBALS.setFlag(14); - } - } else { - // Seeker failing to force open doors - scene->_sceneMode = 1813; - // Original was using 1813 in setAction too, but it somewhat broken. - // Seeker goes 2 pixels to high, hiding behind the door - scene->setAction(&scene->_sequenceManager, scene, 1808, &R2_GLOBALS._player, &scene->_doors, NULL); - } - } else if (R2_GLOBALS.getFlag(14)) { - return SceneActor::startAction(action, event); - } else { - // Quinn trying to force open doors - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1812; - scene->setAction(&scene->_sequenceManager, scene, 1812, &R2_GLOBALS._player, NULL); - } + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._sceneItems.remove(&scene->_storageCompartment); + scene->_sceneMode = 0; + animate(ANIM_MODE_5, scene); return true; } -bool Scene1800::PassengerDoor::startAction(CursorType action, Event &event) { +bool Scene1580::HatchButton::startAction(CursorType action, Event &event) { if (action != CURSOR_USE) return SceneActor::startAction(action, event); - Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - if (_position.x < 160) { - if (scene->_leftStaircase._frame == 1) { - return SceneActor::startAction(action, event); - } else { - R2_GLOBALS.setFlag(29); - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 1; - scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1804; - scene->setAction(&scene->_sequenceManager, scene, 1804, &R2_GLOBALS._player, &scene->_companion, &scene->_leftDoor, NULL); - } - } else { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 1; - scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1805; - scene->setAction(&scene->_sequenceManager, scene, 1805, &R2_GLOBALS._player, &scene->_companion, &scene->_leftDoor, NULL); - } - } - } - } else if (scene->_leftStaircase._frame == 1) { - return SceneActor::startAction(action, event); - } else { - R2_GLOBALS.clearFlag(29); - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 2; - scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1806; - scene->setAction(&scene->_sequenceManager, scene, 1806, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); - } - } else { - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 2; - scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1807; - scene->setAction(&scene->_sequenceManager, scene, 1807, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); - } - } - } + R2_GLOBALS._player.disableControl(); + setFrame(2); + scene->_sceneMode = 20; + scene->setAction(&scene->_sequenceManager, scene, 2, &R2_GLOBALS._player, NULL); return true; } -void Scene1800::SouthExit::changeScene() { - Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; +bool Scene1580::ThrusterValve::startAction(CursorType action, Event &event) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - _enabled = false; - R2_GLOBALS._events.setCursor(CURSOR_WALK); - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS.getFlag(14)) { - scene->_sceneMode = 3; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); - else - scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); - R2_GLOBALS.clearFlag(14); - } else { - scene->_sceneMode = 1802; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - scene->setAction(&scene->_sequenceManager, scene, 1802, &R2_GLOBALS._player, &scene->_companion, NULL); - else - scene->setAction(&scene->_sequenceManager, scene, 1803, &R2_GLOBALS._player, &scene->_companion, NULL); + switch (action) { + case CURSOR_USE: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_INVENTORY.setObjectScene(R2_THRUSTER_VALVE, 1); + remove(); + return true; + } + break; + case R2_COM_SCANNER: + scene->_sceneMode = 30; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_stripManager.start(529, scene); + return true; + break; + case R2_COM_SCANNER_2: + scene->_sceneMode = 30; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_stripManager.start(527, scene); + return true; + break; + default: + break; } -} - -void Scene1800::postInit(SceneObjectList *OwnerList) { - loadScene(1800); - SceneExt::postInit(); - R2_GLOBALS._sound1.play(116); - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); - if (R2_GLOBALS._sceneManager._previousScene == -1) - R2_GLOBALS._rimLocation = 1201; - - // Set the mode based on whether this is the "correct" lift or not - if (R2_GLOBALS._rimLocation == 1201) - _locationMode = 2; - else - _locationMode = 0; - - scalePalette(65, 65, 65); - _southExit.setDetails(Rect(0, 160, 319, 168), EXITCURSOR_S, 1800); - _background.setDetails(Rect(0, 0, 320, 200), -1, -1, -1, -1, 1, NULL); + return SceneActor::startAction(action, event); +} - _lever.postInit(); - _lever.setup(1801, 4, 1); - _lever.setPosition(Common::Point(170, 124)); - _lever.setDetails(1800, 13, 14, 15, 1, (SceneItem *) NULL); +bool Scene1580::Ignitor::startAction(CursorType action, Event &event) { + Scene1580 *scene = (Scene1580 *)R2_GLOBALS._sceneManager._scene; - _doors.postInit(); - _doors.setup(1801, 3, 1); - _doors.setPosition(Common::Point(160, 139)); - _doors.setDetails(1800, 6, -1, -1, 1, (SceneItem *) NULL); + switch (action) { + case CURSOR_USE: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_INVENTORY.setObjectScene(R2_IGNITOR, 1); + remove(); + return true; + } + break; + case R2_COM_SCANNER: + scene->_sceneMode = 30; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_stripManager.start(529, scene); + return true; + break; + case R2_COM_SCANNER_2: + scene->_sceneMode = 30; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_stripManager.start(527, scene); + return true; + break; + default: + break; + } - _leftDoor.postInit(); - _leftDoor.setup(1800, 1, 1); - _leftDoor.setPosition(Common::Point(110, 78)); - _leftDoor.fixPriority(135); - _leftDoor.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); + return SceneActor::startAction(action, event); +} - _rightDoor.postInit(); - _rightDoor.setup(1800, 2, 1); - _rightDoor.setPosition(Common::Point(209, 78)); - _rightDoor.fixPriority(135); - _rightDoor.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); +void Scene1580::postInit(SceneObjectList *OwnerList) { + loadScene(1580); + R2_GLOBALS._sceneManager._fadeMode = FADEMODE_GRADUAL; + SceneExt::postInit(); - _leftStaircase.postInit(); - if ((_locationMode != 1) && (_locationMode != 3) && (!R2_GLOBALS.getFlag(64))) - _leftStaircase.setup(1801, 2, 1); - else - _leftStaircase.setup(1801, 2, 10); - _leftStaircase.setPosition(Common::Point(76, 142)); - _leftStaircase.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); + _stripManager.setColors(60, 255); + _stripManager.setFontNumber(3); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - _rightStaircase.postInit(); - if ((_locationMode != 1) && (_locationMode != 3) && (!R2_GLOBALS.getFlag(64))) - _rightStaircase.setup(1801, 1, 1); - else - _rightStaircase.setup(1801, 1, 10); - _rightStaircase.setPosition(Common::Point(243, 142)); - _rightStaircase.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); + _sceneMode = 0; - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - // Standard Quinn setup - R2_GLOBALS._player.setVisage(1503); - R2_GLOBALS._player._moveDiff = Common::Point(2, 2); + R2_GLOBALS._player.disableControl(); + if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) == 1580) { + _joystick.postInit(); + _joystick.setup(1580, 1, 4); + _joystick.setPosition(Common::Point(159, 163)); + _joystick.setDetails(1550, 78, -1, -1, 1, (SceneItem *) NULL); } else { - // Seeker setup dependent on whether he's holding the doors or not - if (R2_GLOBALS.getFlag(14)) { - R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); - R2_GLOBALS._player.setObjectWrapper(NULL); - R2_GLOBALS._player.setup(1801, 5, 12); - R2_GLOBALS._player.setPosition(Common::Point(160, 139)); - R2_GLOBALS._walkRegions.disableRegion(9); - _doors.hide(); - } else { - R2_GLOBALS._player.setVisage(1507); - } - R2_GLOBALS._player._moveDiff = Common::Point(4, 2); + _joystickPlug.setDetails(Rect(141, 148, 179, 167), 1550, 79, -1, -1, 1, NULL); } - _companion.postInit(); - _companion.animate(ANIM_MODE_1, NULL); - _companion.setObjectWrapper(new SceneObjectWrapper()); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(14)) { - _companion.animate(ANIM_MODE_NONE, NULL); - _companion.setObjectWrapper(NULL); - _companion.setup(1801, 5, 12); + if (R2_INVENTORY.getObjectScene(R2_BROKEN_DISPLAY) == 1580) { + _screen.postInit(); + _screen.setup(1580, 1, 1); + _screen.setPosition(Common::Point(124, 108)); + _screen.fixPriority(10); + _screen.setDetails(1550, 13, -1, -1, 1, (SceneItem *) NULL); - R2_GLOBALS._walkRegions.disableRegion(9); - _doors.hide(); - } else { - _companion.setup(1507, 1, 1); - _companion.setPosition(Common::Point(180, 160)); - } - _companion.setDetails(9002, 0, 4, 3, 1, (SceneItem *) NULL); - _companion._moveDiff = Common::Point(4, 2); + _screenDisplay.postInit(); + _screenDisplay.setup(1580, 1, 3); + _screenDisplay.setPosition(Common::Point(124, 96)); + _screenDisplay.fixPriority(20); + } else if (R2_INVENTORY.getObjectScene(R2_DIAGNOSTICS_DISPLAY) == 1580) { + _screen.postInit(); + _screen.setup(1580, 1, 1); + _screen.setPosition(Common::Point(124, 108)); + _screen.fixPriority(10); + _screen.setDetails(1550, 14, -1, -1, 1, (SceneItem *) NULL); + + _screenDisplay.postInit(); + _screenDisplay.setup(1580, 3, 1); + _screenDisplay.setPosition(Common::Point(124, 109)); + _screenDisplay.fixPriority(20); + + _sceneMode = 10; } else { - _companion.setDetails(9001, 0, 5, 3, 1, (SceneItem *) NULL); - _companion.setVisage(1503); - _companion._moveDiff = Common::Point(2, 2); + _screenSlot.setDetails(Rect(69, 29, 177, 108), 1550, 82, -1, -1, 1, NULL); } - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setPosition(Common::Point(114, 150)); - R2_GLOBALS._player.setStrip(5); - if (R2_GLOBALS.getFlag(14)) { - _companion.setPosition(Common::Point(160, 139)); - R2_GLOBALS._walkRegions.disableRegion(8); - } else { - _companion.setPosition(Common::Point(209, 150)); - _companion.setStrip(6); - R2_GLOBALS._walkRegions.disableRegion(8); - } - } else { - if (R2_GLOBALS.getFlag(14)) { - R2_GLOBALS._player.setup(1801, 5, 12); - R2_GLOBALS._player.setPosition(Common::Point(160, 139)); - } else { - R2_GLOBALS._player.setPosition(Common::Point(209, 150)); - R2_GLOBALS._player.setStrip(6); - } - _companion.setPosition(Common::Point(114, 150)); - _companion.setStrip(5); - R2_GLOBALS._walkRegions.disableRegion(10); - R2_GLOBALS._walkRegions.disableRegion(11); - } - } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player.setPosition(Common::Point(140, 160)); - _companion.setPosition(Common::Point(180, 160)); + _storageCompartment.postInit(); + if (R2_GLOBALS.getFlag(58) == 0) { + _storageCompartment.setup(1580, 5, 1); + _storageCompartment.setDetails(1550, 80, -1, -1, 1, (SceneItem *) NULL); } else { - R2_GLOBALS._player.setPosition(Common::Point(180, 160)); - _companion.setPosition(Common::Point(140, 160)); + _storageCompartment.setup(1580, 5, 6); } - _playerShadow.postInit(); - _playerShadow.fixPriority(10); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _playerShadow.setVisage(1111); - else - _playerShadow.setVisage(1110); - - _playerShadow._effect = EFFECT_SHADOW_MAP; - _playerShadow._shadowMap = _shadowPaletteMap; - - R2_GLOBALS._player._linkedActor = &_playerShadow; + _storageCompartment.setPosition(Common::Point(216, 108)); + _storageCompartment.fixPriority(100); - _companionShadow.postInit(); - _companionShadow.fixPriority(10); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _companionShadow.setVisage(1110); - else - _companionShadow.setVisage(1111); + _hatchButton.postInit(); + _hatchButton.setup(1580, 4, 1); + _hatchButton.setPosition(Common::Point(291, 147)); + _hatchButton.fixPriority(100); + _hatchButton.setDetails(1550, 81, -1, -1, 1, (SceneItem *) NULL); - _companionShadow._effect = EFFECT_SHADOW_MAP; - _companionShadow._shadowMap = _shadowPaletteMap; + if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) == 1580) { + _thrusterValve.postInit(); + _thrusterValve.setup(1580, 6, 2); + _thrusterValve.setPosition(Common::Point(222, 108)); + _thrusterValve.fixPriority(50); + _thrusterValve.setDetails(1550, 32, -1, 34, 1, (SceneItem *) NULL); + } - _companion._linkedActor = &_companionShadow; + if (R2_INVENTORY.getObjectScene(R2_IGNITOR) == 1580) { + _ignitor.postInit(); + _ignitor.setup(1580, 6, 1); + _ignitor.setPosition(Common::Point(195, 108)); + _ignitor.fixPriority(50); + _ignitor.setDetails(1550, 38, -1, 34, 1, (SceneItem *) NULL); + } - R2_GLOBALS._player._characterScene[R2_QUINN] = 1800; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1800; + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + _background.setDetails(Rect(0, 0, 320, 200), 1550, 50, -1, -1, 1, NULL); +} - _elevatorContents.setDetails(Rect(128, 95, 190, 135), 1800, 10, -1, -1, 1, NULL); - _elevator.setDetails(Rect(95, 3, 223, 135), 1800, 0, -1, -1, 1, NULL); +void Scene1580::signal() { + switch (_sceneMode++) { + case 10: + _screenDisplay.animate(ANIM_MODE_5, this); + break; + case 11: + _screenDisplay.setup(1580, 1, 2); + _screenDisplay.setPosition(Common::Point(124, 94)); - // Original was calling _item3.setDetails(Rect(1800, 11, 24, 23), 25, -1, -1, -1, 1, NULL); - // This is *wrong*. The following statement is a wild guess based on good common sense - _surface.setDetails(11, 1800, 23, 24, 25); - _secBackground.setDetails(Rect(0, 0, 320, 200), 1800, 17, -1, 19, 1, NULL); + if (R2_INVENTORY.getObjectScene(R2_GYROSCOPE) != 0) { + _arrActor[0].postInit(); + _arrActor[0].setup(1580, 2, 1); + _arrActor[0].setPosition(Common::Point(138, 56)); + } - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) { - if ((R2_GLOBALS.getFlag(14)) && (R2_GLOBALS._player._characterIndex == R2_SEEKER)) { - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - } else { - R2_GLOBALS._player.enableControl(CURSOR_WALK); + if (R2_INVENTORY.getObjectScene(R2_RADAR_MECHANISM) != 0) { + _arrActor[1].postInit(); + _arrActor[1].setup(1580, 2, 2); + _arrActor[1].setPosition(Common::Point(140, 66)); } - } else if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1850) { - if (R2_GLOBALS.getFlag(29)) { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1814; - setAction(&_sequenceManager, this, 1814, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); - } else { - _sceneMode = 1815; - setAction(&_sequenceManager, this, 1815, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); - } - } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1816; - setAction(&_sequenceManager, this, 1816, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } else { - _sceneMode = 1817; - setAction(&_sequenceManager, this, 1817, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + + if (R2_INVENTORY.getObjectScene(R2_IGNITOR) != 0) { + _arrActor[2].postInit(); + _arrActor[2].setup(1580, 2, 3); + _arrActor[2].setPosition(Common::Point(142, 85)); } - } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1800; - setAction(&_sequenceManager, this, 1800, &R2_GLOBALS._player, &_companion, NULL); - } else { - _sceneMode = 1801; - setAction(&_sequenceManager, this, 1801, &R2_GLOBALS._player, &_companion, NULL); - } - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1800; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1800; -} + if (R2_INVENTORY.getObjectScene(R2_THRUSTER_VALVE) != 0) { + _arrActor[3].postInit(); + _arrActor[3].setup(1580, 2, 4); + _arrActor[3].setPosition(Common::Point(142, 92)); + } -void Scene1800::signal() { - switch (_sceneMode) { - case 1: - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1804; - setAction(&_sequenceManager, this, 1804, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); - } else { - _sceneMode = 1805; - setAction(&_sequenceManager, this, 1805, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); + if (R2_INVENTORY.getObjectScene(R2_GUIDANCE_MODULE) != 0) { + _arrActor[4].postInit(); + _arrActor[4].setup(1580, 2, 5); + _arrActor[4].setPosition(Common::Point(108, 54)); } - break; - case 2: - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _sceneMode = 1806; - setAction(&_sequenceManager, this, 1806, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } else { - _sceneMode = 1807; - setAction(&_sequenceManager, this, 1807, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + + if (R2_INVENTORY.getObjectScene(R2_JOYSTICK) != 1580) { + _arrActor[5].postInit(); + _arrActor[5].setup(1580, 2, 6); + _arrActor[5].setPosition(Common::Point(110, 64)); } - break; - case 3: - _sceneMode = 1802; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - setAction(&_sequenceManager, this, 1802, &R2_GLOBALS._player, &_companion, NULL); - else - setAction(&_sequenceManager, this, 1803, &R2_GLOBALS._player, &_companion, NULL); - break; - case 10: - // No break on purpose - case 11: - R2_GLOBALS._player.enableControl(CURSOR_TALK); - break; - case 12: - R2_GLOBALS._player.enableControl(CURSOR_TALK); - R2_GLOBALS._player._canWalk = false; - break; - case 13: - _sceneMode = 14; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - R2_GLOBALS._player.setup(1801, 7, 1); - R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); - _stripManager.start(550, this); - break; - case 14: - _sceneMode = 15; - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.setup(1801, 6, 1); - R2_GLOBALS._player.animate(ANIM_MODE_6, this); - break; - case 15: - R2_GLOBALS._player.setup(1503, 4, 1); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.enableControl(CURSOR_USE); - break; - // Cases 23 and 24 have been added to fix missing hardcoded logic in the original, - // when Seeker tries to open the door - case 23: - _sceneMode = 24; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - R2_GLOBALS._player.setup(1801, 5, 1); - R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); - _stripManager.start(550, this); - break; - case 24: - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.setup(1507, 4, 1); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.enableControl(CURSOR_USE); - _doors.setup(1801, 3, 1); - _doors.setPosition(Common::Point(160, 139)); - _doors.setDetails(1800, 6, -1, -1, 1, (SceneItem *) NULL); - _doors.show(); + if (R2_INVENTORY.getObjectScene(R2_BATTERY) != 0) { + _arrActor[6].postInit(); + _arrActor[6].setup(1580, 2, 7); + _arrActor[6].setPosition(Common::Point(108, 80)); + } - R2_GLOBALS._player._position.y += 2; - R2_GLOBALS._player.show(); - break; - case 1800: - R2_GLOBALS._walkRegions.disableRegion(8); - if (R2_GLOBALS.getFlag(63)) - R2_GLOBALS._player.enableControl(CURSOR_USE); - else { - _sceneMode = 10; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(544, this); + if (R2_INVENTORY.getObjectScene(R2_FUEL_CELL) != 0) { + _arrActor[7].postInit(); + _arrActor[7].setup(1580, 2, 8); + _arrActor[7].setPosition(Common::Point(111, 92)); } + + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; break; - case 1801: - R2_GLOBALS._walkRegions.disableRegion(10); - R2_GLOBALS._walkRegions.disableRegion(11); - R2_GLOBALS.setFlag(63); - R2_GLOBALS._player.enableControl(CURSOR_WALK); - break; - case 1802: - R2_GLOBALS.clearFlag(14); - R2_GLOBALS._sceneManager.changeScene(1700); - break; - case 1804: - // No break on purpose - case 1805: - // No break on purpose - case 1806: - // No break on purpose - case 1807: - R2_GLOBALS.clearFlag(14); - R2_GLOBALS._sceneManager.changeScene(1850); - break; - case 1808: - _sceneMode = 12; - R2_GLOBALS._events.setCursor(CURSOR_WALK); - _stripManager.start(553, this); - break; - case 1812: - _sceneMode = 13; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - // Case 1813 has been added to fix Seeker missing animation in the original game - case 1813: - _sceneMode = 23; - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - break; - case 1814: - // No break on purpose - case 1815: - R2_GLOBALS._walkRegions.disableRegion(10); - R2_GLOBALS._walkRegions.disableRegion(11); - R2_GLOBALS._player.enableControl(); + case 20: + R2_GLOBALS._sceneManager.changeScene(1550); break; - case 1816: - // No break on purpose - case 1817: - R2_GLOBALS._walkRegions.disableRegion(8); - R2_GLOBALS._player.enableControl(); + case 31: + R2_GLOBALS._sceneManager.changeScene(1530); break; default: - R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; break; } } -void Scene1800::saveCharacter(int characterIndex) { - if (R2_GLOBALS._player._characterIndex == R2_MIRANDA) - R2_GLOBALS._sound1.fadeOut2(NULL); - - SceneExt::saveCharacter(characterIndex); -} - /*-------------------------------------------------------------------------- - * Scene 1850 - Rim Lift Interior + * Scene 1625 - Miranda being questioned * *--------------------------------------------------------------------------*/ -bool Scene1850::Button::startAction(CursorType action, Event &event) { +bool Scene1625::Wire::startAction(CursorType action, Event &event) { if (action != CURSOR_USE) - return SceneHotspot::startAction(action, event); - - Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; + return SceneActor::startAction(action, event); + Scene1625 *scene = (Scene1625 *)R2_GLOBALS._sceneManager._scene; R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - scene->_sceneMode = 1852; - if (R2_GLOBALS.getFlag(32)) - scene->setAction(&scene->_sequenceManager1, scene, 1871, &R2_GLOBALS._player, NULL); - else - scene->setAction(&scene->_sequenceManager1, scene, 1852, &R2_GLOBALS._player, NULL); - } else if (R2_GLOBALS.getFlag(30)) { - scene->_seqNumber = 1; - scene->_sceneMode = 1860; - if (R2_GLOBALS.getFlag(32)) - scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_robot, NULL); - else - scene->setAction(&scene->_sequenceManager1, scene, 1859, &R2_GLOBALS._player, &scene->_robot, NULL); + scene->_sceneMode = 1631; + scene->_mirandaMouth.postInit(); + scene->setAction(&scene->_sequenceManager, scene, 1631, &scene->_mirandaMouth, &scene->_wire, NULL); + return true; +} + +Scene1625::Scene1625() { +} + +void Scene1625::synchronize(Serializer &s) { + SceneExt::synchronize(s); +} + +void Scene1625::postInit(SceneObjectList *OwnerList) { + loadScene(1625); + R2_GLOBALS._player._characterIndex = R2_MIRANDA; + SceneExt::postInit(); + + _stripManager.addSpeaker(&_mirandaSpeaker); + _stripManager.addSpeaker(&_tealSpeaker); + _stripManager.addSpeaker(&_soldierSpeaker); - R2_GLOBALS.clearFlag(30); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + + _wire.postInit(); + _wire.setup(1626, 2, 1); + _wire.setPosition(Common::Point(206, 133)); + _wire.setDetails(1625, 0, -1, -1, 1, (SceneItem *) NULL); + + _wristRestraints.postInit(); + _wristRestraints.setup(1625, 8, 1); + _wristRestraints.setPosition(Common::Point(190, 131)); + _wristRestraints.setDetails(1625, 6, -1, 2, 1, (SceneItem *) NULL); + + if (R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] == 1625) { + if (!R2_GLOBALS.getFlag(83)) { + _glass.postInit(); + _glass.setup(1626, 4, 1); + _glass.setPosition(Common::Point(96, 166)); + _glass.setDetails(1625, -1, -1, -1, 1, (SceneItem *) NULL); + } + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; } else { - scene->_sceneMode = 1853; + _teal.postInit(); + _teal.fixPriority(10); - if (R2_GLOBALS.getFlag(32)) - scene->setAction(&scene->_sequenceManager1, scene, 1872, &R2_GLOBALS._player, NULL); - else - scene->setAction(&scene->_sequenceManager1, scene, 1853, &R2_GLOBALS._player, NULL); + _tealRightArm.postInit(); + + R2_GLOBALS._player.disableControl(); + _sceneMode = 1625; + setAction(&_sequenceManager, this, 1625, &_teal, &_tealRightArm, NULL); } - return true; + R2_GLOBALS._sound1.play(245); + _background.setDetails(Rect(0, 0, 320, 200), 1625, 12, -1, -1, 1, NULL); + R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 1625; + R2_GLOBALS._player._characterScene[R2_MIRANDA] = 1625; } -bool Scene1850::Robot::startAction(CursorType action, Event &event) { - Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; - - switch (action) { - case CURSOR_USE: - if ((R2_GLOBALS._player._characterIndex != R2_SEEKER) || R2_GLOBALS.getFlag(33) || R2_GLOBALS.getFlag(30)) - return SceneActor::startAction(action, event); +void Scene1625::remove() { + R2_GLOBALS._sound1.fadeOut2(NULL); + SceneExt::remove(); +} +void Scene1625::signal() { + switch (_sceneMode) { + case 10: R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1857; + _glass.postInit(); + _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); + _sceneMode = 1626; + setAction(&_sequenceManager, this, 1626, &_tealHead, &_glass, NULL); + break; + case 12: + MessageDialog::show(DONE_MSG, OK_BTN_STRING); + break; + case 14: + _tealHead.postInit(); + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(831, this); + break; + case 99: + R2_GLOBALS._player.disableControl(); + switch (_stripManager._exitMode) { + case 1: + _sceneMode = 1627; + setAction(&_sequenceManager, this, 1627, &_mirandaMouth, &_glass, NULL); + break; + case 2: + _sceneMode = 1629; + setAction(&_sequenceManager, this, 1629, &_tealHead, &_wristRestraints, NULL); + break; + case 4: + R2_GLOBALS._player._oldCharacterScene[R2_MIRANDA] = 3150; + R2_GLOBALS._player._characterScene[R2_MIRANDA] = 3150; + R2_GLOBALS._player._characterIndex = R2_QUINN; + R2_GLOBALS._sceneManager.changeScene(R2_GLOBALS._player._characterScene[R2_QUINN]); + break; + case 5: + _sceneMode = 1628; + _tealHead.remove(); + setAction(&_sequenceManager, this, 1628, &_mirandaMouth, &_glass, NULL); + break; + case 6: + _glass.postInit(); + _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); + _sceneMode = 1632; + setAction(&_sequenceManager, this, 1632, &_glass, NULL); + break; + case 7: + _sceneMode = 1633; + setAction(&_sequenceManager, this, 1633, &_glass, NULL); + break; + case 8: + _sceneMode = 1635; + setAction(&_sequenceManager, this, 1635, &_mirandaMouth, &_wristRestraints, NULL); + break; + case 9: + _glass.postInit(); + _glass.setDetails(1625, -1, -1, -1, 2, (SceneItem *) NULL); + _sceneMode = 1634; + setAction(&_sequenceManager, this, 1634, &_mirandaMouth, &_wristRestraints, NULL); + break; + case 3: + // No break on purpose + default: + _sceneMode = 1630; + _tealHead.remove(); + setAction(&_sequenceManager, this, 1630, &_teal, &_tealRightArm, NULL); + break; + } + //_field412 = _stripManager._field2E8; + _stripManager._currObj44Id = 0; + break; + case 1625: + _tealHead.postInit(); + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); + _sceneMode = 10; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(800, this); + break; + case 1626: + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); + _tealHead.show(); - if (R2_GLOBALS.getFlag(32)) - scene->setAction(&scene->_sequenceManager1, scene, 1858, &R2_GLOBALS._player, &scene->_robot, NULL); - else - scene->setAction(&scene->_sequenceManager1, scene, 1857, &R2_GLOBALS._player, &scene->_robot, NULL); + _mirandaMouth.postInit(); + _mirandaMouth.setup(1627, 3, 1); + _mirandaMouth.setPosition(Common::Point(196, 65)); - R2_GLOBALS.setFlag(30); - return true; + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(832, this); break; - case CURSOR_LOOK: - if (R2_GLOBALS.getFlag(34)) - SceneItem::display(1850, 2, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - else - SceneItem::display(1850, 1, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + case 1627: + _mirandaMouth.setup(1627, 3, 1); + _mirandaMouth.setPosition(Common::Point(196, 65)); + _mirandaMouth.show(); - return true; + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(833, this); break; - case R2_AIRBAG: - if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { - if (R2_GLOBALS.getFlag(70)) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 30; + case 1628: + R2_GLOBALS.setFlag(83); + _tealHead.postInit(); + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); - R2_GLOBALS._events.setCursor(CURSOR_WALK); - scene->_stripManager.start(558, scene); + _mirandaMouth.setup(1627, 3, 1); + _mirandaMouth.setPosition(Common::Point(196, 65)); + _mirandaMouth.show(); - return true; - } else { - return SceneActor::startAction(action, event); - } - } else if (R2_GLOBALS.getFlag(30)) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1875; - scene->_airbag.postInit(); + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(834, this); + break; + case 1629: + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); + _tealHead.show(); - if (R2_GLOBALS.getFlag(32)) - scene->setAction(&scene->_sequenceManager1, scene, 1876, - &R2_GLOBALS._player, &scene->_airbag, NULL); - else - scene->setAction(&scene->_sequenceManager1, scene, 1875, - &R2_GLOBALS._player, &scene->_airbag, NULL); + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(805, this); + break; + case 1630: + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = true; + break; + case 1631: + _mirandaMouth.setup(1627, 3, 1); + _mirandaMouth.setPosition(Common::Point(196, 65)); + _mirandaMouth.show(); - return true; - } else if (R2_GLOBALS.getFlag(70)) { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 20; - R2_GLOBALS._events.setCursor(CURSOR_WALK); - scene->_stripManager.start(557, scene); - R2_GLOBALS.setFlag(69); + _wire.remove(); - return true; - } else { - return SceneActor::startAction(action, event); - } + _teal.postInit(); + _teal.fixPriority(10); + + _tealRightArm.postInit(); + + R2_INVENTORY.setObjectScene(R2_SUPERCONDUCTOR_WIRE, 3); + _sceneMode = 14; + + setAction(&_sequenceManager, this, 1625, &_teal, &_tealRightArm, NULL); + break; + case 1632: + _tealHead.setup(1627, 1, 1); + _tealHead.setPosition(Common::Point(68, 68)); + _tealHead.show(); + + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(835, this); + break; + case 1633: + _glass.remove(); + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(818, this); + break; + case 1634: + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(836, this); break; - case R2_REBREATHER_TANK: - if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { - if (R2_GLOBALS.getFlag(30)) - return SceneActor::startAction(action, event); - - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1878; - scene->setAction(&scene->_sequenceManager1, scene, 1878, &R2_GLOBALS._player, - &scene->_robot, &scene->_airbag, NULL); - } + case 1635: + _mirandaMouth.setup(1627, 3, 1); + _mirandaMouth.setPosition(Common::Point(196, 65)); + _mirandaMouth.show(); - return true; + _sceneMode = 99; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(818, this); break; default: - return SceneActor::startAction(action, event); break; } } -bool Scene1850::Door::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneHotspot::startAction(action, event); - - if (R2_GLOBALS.getFlag(32)) { - SceneItem::display(3240, 4, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - return true; - } - - Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - if (scene->_sceneMode == 1851) - R2_GLOBALS._player._effect = EFFECT_SHADED; - - if (_position.x >= 160) - R2_GLOBALS.setFlag(29); +void Scene1625::process(Event &event) { + if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) + event.handled = true; else - R2_GLOBALS.clearFlag(29); + Scene::process(event); +} - if ((R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) { - if (_position.x >= 160) - scene->_seqNumber = 3; - else - scene->_seqNumber = 2; +/*-------------------------------------------------------------------------- + * Scene 1700 - Rim + * + *--------------------------------------------------------------------------*/ - scene->_sceneMode = 1860; +Scene1700::Scene1700() { + _walkFlag = 0; +} - if (R2_GLOBALS.getFlag(32)) { - scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_robot, NULL); - } else { - scene->setAction(&scene->_sequenceManager1, scene, 1859, &R2_GLOBALS._player, &scene->_robot, NULL); - } - } else { - scene->_sceneMode = 11; - if (_position.x >= 160) { - scene->setAction(&scene->_sequenceManager1, scene, 1866, &R2_GLOBALS._player, &scene->_rightDoor, NULL); - } else { - scene->setAction(&scene->_sequenceManager1, scene, 1865, &R2_GLOBALS._player, &scene->_leftDoor, NULL); - } - } +void Scene1700::synchronize(Serializer &s) { + SceneExt::synchronize(s); - return true; + s.syncAsSint16LE(_walkFlag); } -bool Scene1850::DisplayScreen::startAction(CursorType action, Event &event) { - if ((action != CURSOR_USE) || (_position.y != 120)) - return SceneHotspot::startAction(action, event); +bool Scene1700::RimTransport::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); - Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; + Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1881; + scene->_sceneMode = 4; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - scene->setAction(&scene->_sequenceManager1, scene, 1881, &R2_GLOBALS._player, NULL); - } else { - scene->setAction(&scene->_sequenceManager1, scene, 1880, &R2_GLOBALS._player, NULL); - } + Common::Point pt(271, 90); + PlayerMover *mover = new PlayerMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); return true; } -/*------------------------------------------------------------------------*/ - -Scene1850::Scene1850() { - _sceneMode = 0; - _shadeCountdown = 0; - _shadeDirection = 0; - _shadeChanging = false; - _seqNumber = 0; -} +bool Scene1700::Companion::startAction(CursorType action, Event &event) { + if (action != CURSOR_TALK) + return SceneActor::startAction(action, event); -void Scene1850::synchronize(Serializer &s) { - SceneExt::synchronize(s); + Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; + scene->_sceneMode = 30; + scene->signal(); - s.syncAsSint16LE(_sceneMode); - s.syncAsSint16LE(_shadeCountdown); - s.syncAsSint16LE(_shadeDirection); - s.syncAsSint16LE(_shadeChanging); - s.syncAsSint16LE(_seqNumber); - s.syncAsSint16LE(_playerDest.x); - s.syncAsSint16LE(_playerDest.y); + return true; } -void Scene1850::postInit(SceneObjectList *OwnerList) { - loadScene(1850); - - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] != 1850) - R2_GLOBALS.clearFlag(31); - - _palette1.loadPalette(0); - - if (R2_GLOBALS.getFlag(31)) { - _sceneMode = 1850; - g_globals->_scenePalette.loadPalette(1850); - } else { - _sceneMode = 1851; - g_globals->_scenePalette.loadPalette(1851); - } +void Scene1700::NorthExit::changeScene() { + Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - SceneExt::postInit(); + R2_GLOBALS._player.disableControl(); + _moving = false; + scene->_sceneMode = 1; - if (R2_GLOBALS._sceneManager._previousScene == 3150) - R2_GLOBALS._sound1.play(116); + Common::Point pt(R2_GLOBALS._player._position.x, 0); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); +void Scene1700::SouthExit::changeScene() { + Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - _shadeChanging = false; - _seqNumber = 0; - _playerDest = Common::Point(0, 0); + R2_GLOBALS._player.disableControl(); + _moving = false; + scene->_sceneMode = 2; - R2_GLOBALS._player._characterScene[R2_QUINN] = 1850; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1850; + Common::Point pt(R2_GLOBALS._player._position.x, 170); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} - _button.setDetails(Rect(101, 56, 111, 63), 1850, 19, -1, -1, 1, NULL); +void Scene1700::WestExit::changeScene() { + Scene1700 *scene = (Scene1700 *)R2_GLOBALS._sceneManager._scene; - _leftDoor.postInit(); - _leftDoor.setup(1850, 3, 1); - _leftDoor.setPosition(Common::Point(66, 102)); - _leftDoor.setDetails(1850, 22, -1, -1, 1, (SceneItem *) NULL); + R2_GLOBALS._player.disableControl(); + _moving = false; + scene->_sceneMode = 6; - _rightDoor.postInit(); - _rightDoor.setup(1850, 2, 1); - _rightDoor.setPosition(Common::Point(253, 102)); - _rightDoor.setDetails(1850, 22, -1, -1, 1, (SceneItem *) NULL); + Common::Point pt(0, R2_GLOBALS._player._position.y); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} - R2_GLOBALS._walkRegions.disableRegion(1); +void Scene1700::enterArea() { + Rect tmpRect; + R2_GLOBALS._walkRegions.load(1700); - _robot.postInit(); + _slabWest.remove(); + _slabEast.remove(); + _slabShadowWest.remove(); + _slabShadowEast.remove(); + _westPlatform.remove(); + _rimTransportDoor.remove(); + _rimTransport.remove(); - if (R2_GLOBALS.getFlag(34)) { - R2_GLOBALS._walkRegions.disableRegion(2); - _robot.setup(1851, 4, 3); - } else if (R2_GLOBALS.getFlag(30)) { - _robot.setup(1851, 2, 2); - } else { - R2_GLOBALS._walkRegions.disableRegion(5); - if (R2_GLOBALS.getFlag(33)) { - R2_GLOBALS._walkRegions.disableRegion(2); - _robot.setup(1851, 1, 3); - } else { - _robot.setup(1851, 2, 1); - } + if (_sceneMode != 40) { + _ledgeHopper.remove(); + _hatch.remove(); } - _robot.setPosition(Common::Point(219, 130)); - _robot.fixPriority(114); - _robot.setDetails(1850, -1, -1, -1, 1, (SceneItem *) NULL); - - R2_GLOBALS._player.postInit(); + // The original had manual code here to redraw the background manually when + // changing areas within the scene. Which seems to be totally redundant. - _companion.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _companion.setDetails(9002, 0, 4, 3, 1, (SceneItem *) NULL); - } else { - _companion.setDetails(9001, 0, 5, 3, 1, (SceneItem *) NULL); + if (_sceneMode != 40 && R2_GLOBALS._rimLocation == 0) { + // Crashed ledge hopper + _ledgeHopper.postInit(); + _ledgeHopper.setup(1701, 1, 1); + _ledgeHopper.setPosition(Common::Point(220, 137)); + _ledgeHopper.setDetails(1700, 6, -1, -1, 2, (SceneItem *) NULL); + R2_GLOBALS._walkRegions.disableRegion(2); + R2_GLOBALS._walkRegions.disableRegion(12); } - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1850) { - R2_GLOBALS._player._effect = EFFECT_SHADED2; - _companion._effect = EFFECT_SHADED2; - if (R2_GLOBALS.getFlag(31)) { - R2_GLOBALS._player._shade = 0; - _companion._shade = 0; - } else { - R2_GLOBALS._player._shade = 6; - _companion._shade = 6; - } - - if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { - _airbag.postInit(); - if (R2_GLOBALS.getFlag(34)) { - _airbag.setup(1851, 4, 2); - _airbag.fixPriority(114); - } else { - _airbag.setup(1851, 4, 1); - } - - _airbag.setPosition(Common::Point(179, 113)); - - if ((_robot._strip == 1) && (_robot._frame == 3)){ - _airbag.hide(); - } - - _airbag.setDetails(1850, 6, -1, -1, 1, (SceneItem *) NULL); - } - - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(32)) { - R2_GLOBALS._player.setVisage(1511); - _companion.setVisage(1508); + if ((R2_GLOBALS._rimLocation + 2) % 4 == 0) { + // The slabs forming the bottom of the regular rings the rim transport travels through + _slabWest.postInit(); + _slabWest.setup(1700, 1, 1); + _slabWest.setPosition(Common::Point(222, 82)); + _slabWest.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); - _screen.postInit(); - _screen.setup(1853, 3, 1); - _screen.setPosition(Common::Point(122, 113)); - _screen.fixPriority(114); - _screen._effect = EFFECT_SHADED2; - _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); + _slabShadowWest.postInit(); + _slabShadowWest.setup(1700, 2, 1); + _slabShadowWest.setPosition(Common::Point(177, 82)); + _slabShadowWest.fixPriority(0); - _helmet.postInit(); - _helmet.setup(1853, 3, 2); - _helmet.setPosition(Common::Point(139, 111)); - _helmet.fixPriority(114); - _helmet._effect = EFFECT_SHADED2; - _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *) NULL); + _slabShadowEast.postInit(); + _slabShadowEast.setup(1700, 2, 2); + _slabShadowEast.setPosition(Common::Point(332, 96)); + _slabShadowEast.fixPriority(0); - if (R2_GLOBALS.getFlag(31)) { - _screen._shade = 0; - _helmet._shade = 0; - } else { - _screen._shade = 6; - _helmet._shade = 6; - } - } else { - R2_GLOBALS._player.setVisage(1500); - _companion.setVisage(1505); - } - } else if (R2_GLOBALS.getFlag(32)) { - // Not Quinn, flag 32 - R2_GLOBALS._player.setVisage(1508); - _companion.setVisage(1511); + _slabEast.postInit(); + _slabEast.setup(1700, 1, 2); + _slabEast.setPosition(Common::Point(424, 84)); - _screen.postInit(); - _screen.setup(1853, 3, 1); - _screen.setPosition(Common::Point(122, 113)); - _screen.fixPriority(114); - _screen._effect = EFFECT_SHADED2; - _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *) NULL); + R2_GLOBALS._walkRegions.disableRegion(11); + } - _helmet.postInit(); - _helmet.setup(1853, 3, 2); - _helmet.setPosition(Common::Point(139, 111)); - _helmet.fixPriority(114); - _helmet._effect = EFFECT_SHADED2; - _helmet.setDetails(1850, 28, -1, -1, 1, (SceneItem *) NULL); + if ((R2_GLOBALS._rimLocation + 399) % 800 == 0) { + // Enable west exit to lift + _westPlatform.postInit(); + _westPlatform.setup(1700, 3, 2); + _westPlatform.setPosition(Common::Point(51, 141)); + _westPlatform.fixPriority(0); + _westPlatform.setDetails(100, -1, -1, -1, 2, (SceneItem *) NULL); - if (R2_GLOBALS.getFlag(31)) { - _screen._shade = 0; - _helmet._shade = 0; - } else { - _screen._shade = 6; - _helmet._shade = 6; - } - } else { - // Not Quinn, nor flag 32 - R2_GLOBALS._player.setVisage(1505); - _companion.setVisage(1500); - } + _westExit._enabled = true; + } else { + R2_GLOBALS._walkRegions.disableRegion(1); + _westExit._enabled = false; + } - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.setStrip(3); - R2_GLOBALS._player.setPosition(Common::Point(80, 114)); + if ( ((!R2_GLOBALS.getFlag(15)) && ((R2_GLOBALS._rimLocation == 25) || (R2_GLOBALS._rimLocation == -3))) + || ((R2_GLOBALS.getFlag(15)) && (R2_GLOBALS._rimLocation == R2_GLOBALS._rimTransportLocation)) + ) { + // Rim transport vechile located + R2_GLOBALS._rimTransportLocation = R2_GLOBALS._rimLocation; + if (!R2_GLOBALS.getFlag(15)) + _walkFlag = true; - _companion.animate(ANIM_MODE_1, NULL); - _companion.setObjectWrapper(new SceneObjectWrapper()); - _companion.setStrip(3); - _companion.setPosition(Common::Point(180, 96)); + _rimTransport.postInit(); + _rimTransport.setup(1700, 3, 1); + _rimTransport.setPosition(Common::Point(338, 150)); + _rimTransport.setDetails(1700, 9, -1, -1, 2, (SceneItem *) NULL); + _rimTransport.fixPriority(15); - if (R2_GLOBALS.getFlag(30)) { - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _companion.animate(ANIM_MODE_NONE, NULL); - _companion.setObjectWrapper(NULL); - if (R2_GLOBALS.getFlag(32)) { - _companion.setup(1854, 1, 3); - } else { - _companion.setup(1854, 2, 3); - } + _rimTransportDoor.postInit(); + _rimTransportDoor.setup(1700, 4, 1); + _rimTransportDoor.setPosition(Common::Point(312, 106)); + _rimTransportDoor.fixPriority(130); + } +} - _companion.setPosition(Common::Point(164, 106)); - } else { - _companion.animate(ANIM_MODE_NONE, NULL); - _companion.setObjectWrapper(NULL); - if (R2_GLOBALS.getFlag(32)) { - R2_GLOBALS._player.setup(1854, 1, 3); - } else { - R2_GLOBALS._player.setup(1854, 2, 3); - } +void Scene1700::postInit(SceneObjectList *OwnerList) { + loadScene(1700); + SceneExt::postInit(); + if (R2_GLOBALS._sceneManager._previousScene == -1) + R2_GLOBALS._sceneManager._previousScene = 1530; - R2_GLOBALS._player.setPosition(Common::Point(164, 106)); - } - } + scalePalette(65, 65, 65); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - R2_GLOBALS._player.enableControl(); - } else { // R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] != 1850 - R2_GLOBALS._player._effect = EFFECT_SHADED; - _companion._effect = EFFECT_SHADED; - R2_GLOBALS._player.disableControl(); - _sceneMode = 10; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS.getFlag(29)) { - setAction(&_sequenceManager1, this, 1863, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } else { - setAction(&_sequenceManager1, this, 1861, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); - } - } else { - if (R2_GLOBALS.getFlag(29)) { - setAction(&_sequenceManager1, this, 1864, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); - } else { - setAction(&_sequenceManager1, this, 1862, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); - } - } - } + _northExit.setDetails(Rect(94, 0, 319, 12), EXITCURSOR_N, 1700); + _southExit.setDetails(Rect(0, 161, 319, 168), EXITCURSOR_S, 1700); + _westExit.setDetails(Rect(0, 0, 12, 138), EXITCURSOR_W, 1800); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.setPosition(Common::Point(0, 0)); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - R2_GLOBALS._player._moveDiff = Common::Point(3, 2); - _companion._moveDiff = Common::Point(5, 3); + R2_GLOBALS._player.setVisage(1501); + R2_GLOBALS._player._moveDiff = Common::Point(2, 1); } else { - R2_GLOBALS._player._moveDiff = Common::Point(5, 3); - _companion._moveDiff = Common::Point(3, 2); + R2_GLOBALS._player.setVisage(1506); + R2_GLOBALS._player._moveDiff = Common::Point(3, 1); } - _displayScreen.postInit(); - _displayScreen.setup(1850, 1, 1); + _companion.postInit(); + _companion.animate(ANIM_MODE_1, NULL); + _companion.setObjectWrapper(new SceneObjectWrapper()); - if (R2_GLOBALS.getFlag(62)) { - _displayScreen.setPosition(Common::Point(159, 120)); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _companion.setVisage(1506); + _companion._moveDiff = Common::Point(3, 1); + _companion.setDetails(9002, 1, -1, -1, 1, (SceneItem *) NULL); } else { - _displayScreen.setPosition(Common::Point(159, 184)); + _companion.setVisage(1501); + _companion._moveDiff = Common::Point(2, 1); + _companion.setDetails(9001, 1, -1, -1, 1, (SceneItem *) NULL); } - _displayScreen.fixPriority(113); + R2_GLOBALS._sound1.play(134); - if (R2_GLOBALS.getFlag(34)) { - _displayScreen.setDetails(1850, 25, -1, -1, 4, &_robot); - } else { - _displayScreen.setDetails(1850, 25, -1, -1, 2, (SceneItem *) NULL); - } + _playerShadow.postInit(); + _playerShadow.fixPriority(10); - if (!R2_GLOBALS.getFlag(62)) { - _displayScreen.hide(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _playerShadow.setVisage(1112); + else + _playerShadow.setVisage(1111); + + _playerShadow._effect = EFFECT_SHADOW_MAP; + _playerShadow._shadowMap = _shadowPaletteMap; + R2_GLOBALS._player._linkedActor = &_playerShadow; + + _companionShadow.postInit(); + _companionShadow.fixPriority(10); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _companionShadow.setVisage(1111); + else + _companionShadow.setVisage(1112); + + _companionShadow._effect = EFFECT_SHADOW_MAP; + _companionShadow._shadowMap = _shadowPaletteMap; + _companion._linkedActor = &_companionShadow; + + R2_GLOBALS._sound1.play(134); + + switch (R2_GLOBALS._sceneManager._previousScene) { + case 1530: + R2_GLOBALS._player._characterIndex = R2_QUINN; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.hide(); + _companion.hide(); + + _hatch.postInit(); + _hatch.hide(); + + _ledgeHopper.postInit(); + _ledgeHopper.setup(1701, 1, 1); + _ledgeHopper.setPosition(Common::Point(220, 137)); + _ledgeHopper.setDetails(1700, 6, -1, -1, 1, (SceneItem *) NULL); + + _playerShadow.hide(); + _companionShadow.hide(); + R2_GLOBALS._events.setCursor(CURSOR_WALK); + _stripManager.start(539, this); + _sceneMode = 40; + break; + case 1750: { + R2_GLOBALS._player.setPosition(Common::Point(282, 121)); + _companion.setPosition(Common::Point(282, 139)); + _sceneMode = 8; + Common::Point pt(262, 101); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + Common::Point pt2(262, 119); + NpcMover *mover2 = new NpcMover(); + _companion.addMover(mover2, &pt2, this); + } + break; + case 1800: { + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.setPosition(Common::Point(0, 86)); + _companion.setPosition(Common::Point(0, 64)); + _sceneMode = 7; + R2_GLOBALS._player.setObjectWrapper(NULL); + R2_GLOBALS._player._strip = 1; + Common::Point pt(64, 86); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + _companion.setObjectWrapper(NULL); + _companion._strip = 1; + Common::Point pt2(77, 64); + NpcMover *mover2 = new NpcMover(); + _companion.addMover(mover2, &pt2, NULL); + } + break; + default: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player.setPosition(Common::Point(109, 160)); + _companion.setPosition(Common::Point(156, 160)); + R2_GLOBALS._walkRegions.disableRegion(15); + } else { + R2_GLOBALS._player.setPosition(Common::Point(156, 160)); + _companion.setPosition(Common::Point(109, 160)); + R2_GLOBALS._walkRegions.disableRegion(17); + } + _sceneMode = 50; + setAction(&_sequenceManager, this, 1, &R2_GLOBALS._player, NULL); + break; } + R2_GLOBALS._player._characterScene[R2_QUINN] = 1700; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1700; + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1700; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1700; - _background.setDetails(Rect(0, 0, 320, 200), 1850, 16, -1, -1, 1, NULL); + enterArea(); - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1850; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1850; + _surface.setDetails(1, 1700, 3, -1, -1); + _background.setDetails(Rect(0, 0, 480, 200), 1700, 0, -1, -1, 1, NULL); } -void Scene1850::remove() { - g_globals->_scenePalette.loadPalette(0); - - R2_GLOBALS._scenePalette._palette[765] = 255; - R2_GLOBALS._scenePalette._palette[766] = 255; - R2_GLOBALS._scenePalette._palette[767] = 255; - +void Scene1700::remove() { + R2_GLOBALS._sound1.fadeOut2(NULL); SceneExt::remove(); } -void Scene1850::signal() { +void Scene1700::signal() { switch (_sceneMode) { - case 10: - R2_GLOBALS._player._effect = EFFECT_SHADED2; - R2_GLOBALS._player._shade = 6; - - _companion._effect = EFFECT_SHADED2; - _companion._shade = 6; + case 1: { + _sceneMode = 3; + if (R2_GLOBALS._rimLocation < 2400) + ++R2_GLOBALS._rimLocation; + enterArea(); + R2_GLOBALS._player.setPosition(Common::Point(235 - (((((235 - R2_GLOBALS._player._position.x) * 100) / 103) * 167) / 100), 170)); + Common::Point pt(R2_GLOBALS._player._position.x, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); - R2_GLOBALS._walkRegions.disableRegion(5); + if (R2_GLOBALS._player._position.x < 132) { + _companion.setPosition(Common::Point(156, 170)); + Common::Point pt2(156, 160); + NpcMover *mover2 = new NpcMover(); + _companion.addMover(mover2, &pt2, NULL); + R2_GLOBALS._walkRegions.disableRegion(15); + } else { + _companion.setPosition(Common::Point(109, 170)); + Common::Point pt3(109, 160); + NpcMover *mover3 = new NpcMover(); + _companion.addMover(mover3, &pt3, NULL); + R2_GLOBALS._walkRegions.disableRegion(17); + } + } + break; + case 2: { + _sceneMode = 3; + if (R2_GLOBALS._rimLocation > -2400) + --R2_GLOBALS._rimLocation; + enterArea(); + R2_GLOBALS._player.setPosition(Common::Point(235 - (((((235 - R2_GLOBALS._player._position.x) * 100) / 167) * 103) / 100), 0)); + Common::Point pt(R2_GLOBALS._player._position.x, 10); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); - if (R2_GLOBALS.getFlag(68)) { - R2_GLOBALS._player.enableControl(); + if (R2_GLOBALS._player._position.x >= 171) { + _companion.setPosition(Common::Point(155, 0)); + Common::Point pt2(155, 10); + NpcMover *mover2 = new NpcMover(); + _companion.addMover(mover2, &pt2, NULL); + R2_GLOBALS._walkRegions.disableRegion(15); } else { - R2_GLOBALS.setFlag(68); - _sceneMode = 20; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(554, this); + _companion.setPosition(Common::Point(188, 0)); + Common::Point pt3(188, 10); + NpcMover *mover3 = new NpcMover(); + _companion.addMover(mover3, &pt3, NULL); + R2_GLOBALS._walkRegions.disableRegion(17); + } } break; - case 11: - R2_GLOBALS.clearFlag(30); + case 3: + if (!_walkFlag) { + R2_GLOBALS._player.enableControl(CURSOR_WALK); + } else { + R2_GLOBALS.setFlag(15); + _walkFlag = false; + _sceneMode = 31; + R2_GLOBALS._events.setCursor(CURSOR_WALK); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _stripManager.start(542, this); + else + _stripManager.start(543, this); + } + break; + case 4: { + _sceneMode = 5; + Common::Point pt(271, 90); + PlayerMover *mover = new PlayerMover(); + _companion.addMover(mover, &pt, NULL); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + setAction(&_sequenceManager, this, 1700, &R2_GLOBALS._player, &_rimTransportDoor, NULL); + else + setAction(&_sequenceManager, this, 1701, &R2_GLOBALS._player, &_rimTransportDoor, NULL); + } + break; + case 5: + R2_GLOBALS._sceneManager.changeScene(1750); + break; + case 6: R2_GLOBALS._sceneManager.changeScene(1800); break; - case 15: - _sceneMode = 16; + case 7: + R2_GLOBALS._player.setObjectWrapper(new SceneObjectWrapper()); + R2_GLOBALS._player._strip = 1; + _companion.setObjectWrapper(new SceneObjectWrapper()); + _companion._strip = 1; + R2_GLOBALS._player.enableControl(CURSOR_WALK); + R2_GLOBALS._walkRegions.disableRegion(14); break; - case 16: - _sceneMode = 1870; - setAction(&_sequenceManager1, this, 1870, &R2_GLOBALS._player, &_companion, - &_screen, &_helmet, NULL); + case 8: + R2_GLOBALS._player._strip = 2; + _companion._strip = 1; + R2_GLOBALS._player.enableControl(CURSOR_WALK); + R2_GLOBALS._walkRegions.disableRegion(12); break; - case 20: + case 30: + _sceneMode = 31; + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _stripManager.start(540, this); + else + _stripManager.start(541, this); + break; + case 31: R2_GLOBALS._player.enableControl(CURSOR_TALK); break; - case 21: + case 40: R2_GLOBALS._player.disableControl(); - _sceneMode = 1877; - setAction(&_sequenceManager1, this, 1877, &R2_GLOBALS._player, &_companion, - &_robot, NULL); + _sceneMode = 1704; + setAction(&_sequenceManager, this, 1704, &R2_GLOBALS._player, &_companion, + &_hatch, &_ledgeHopper, &_playerShadow, &_companionShadow, NULL); break; - case 30: - R2_GLOBALS._player.disableControl(); - _sceneMode = 1882; - setAction(&_sequenceManager1, this, 1882, &R2_GLOBALS._player, NULL); + case 50: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + R2_GLOBALS._walkRegions.disableRegion(15); + else + R2_GLOBALS._walkRegions.disableRegion(17); + + R2_GLOBALS._player.enableControl(); break; - case 1852: - // No break on purpose: - case 1853: - if (_sceneMode == 1851) { // At this point, SceneMode can't be equal to 1851 => dead code - R2_GLOBALS.setFlag(31); - _palette1.loadPalette(1850); - _sceneMode = 1850; + case 1704: + R2_GLOBALS._sound1.play(134); + R2_GLOBALS._walkRegions.disableRegion(15); + R2_GLOBALS._walkRegions.disableRegion(2); + R2_GLOBALS._walkRegions.disableRegion(12); + R2_GLOBALS._player.fixPriority(-1); + R2_GLOBALS._player.enableControl(CURSOR_WALK); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +/*-------------------------------------------------------------------------- + * Scene 1750 - Maintaiance Vechile + * + *--------------------------------------------------------------------------*/ + +Scene1750::Button::Button() { + _buttonId = 0; +} + +void Scene1750::Button::synchronize(Serializer &s) { + SceneActor::synchronize(s); + + s.syncAsSint16LE(_buttonId); +} + +bool Scene1750::Button::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + Scene1750 *scene = (Scene1750 *)R2_GLOBALS._sceneManager._scene; + + switch (_buttonId) { + case 1: + // Forward button + show(); + scene->_backwardButton.hide(); + if (scene->_speed < 0) + scene->_speed = -scene->_speed; + scene->_direction = 1; + break; + case 2: + // Backwards button + show(); + scene->_forwardButton.hide(); + if (scene->_speed > 0) + scene->_speed = -scene->_speed; + scene->_direction = -1; + break; + case 3: + // Exit button + if (scene->_rotation->_idxChange == 0) { + show(); + R2_GLOBALS._sceneManager.changeScene(1700); } else { - R2_GLOBALS.clearFlag(31); - _palette1.loadPalette(1851); - _sceneMode = 1851; + scene->_speed = 0; + scene->_speedSlider._moveRate = 20; + scene->_forwardButton._moveDiff.y = 1; + Common::Point pt(286, 143); + NpcMover *mover = new NpcMover(); + scene->_speedSlider.addMover(mover, &pt, NULL); } + default: + break; + } - _shadeChanging = true; - if (R2_GLOBALS.getFlag(30)) { - _displayScreen.setAction(&_sequenceManager2, NULL, 1867, &_displayScreen, NULL); - } else if (R2_GLOBALS.getFlag(34)) { - if (R2_GLOBALS.getFlag(62)) { - R2_GLOBALS.clearFlag(62); - _displayScreen.setAction(&_sequenceManager2, this, 1851, &_displayScreen, NULL); - } else { - R2_GLOBALS.setFlag(62); - _displayScreen.setAction(&_sequenceManager2, this, 1850, &_displayScreen, NULL); - } - } else if (R2_GLOBALS.getFlag(33)) { - R2_GLOBALS.setFlag(62); - R2_GLOBALS.setFlag(34); - R2_GLOBALS._walkRegions.disableRegion(2); + return true; +} - _airbag.postInit(); - _airbag.setDetails(1850, 6, -1, -1, 5, &_robot); +/*------------------------------------------------------------------------*/ - _sceneMode = 1879; +Scene1750::SpeedSlider::SpeedSlider() { + _incrAmount = 0; + _xp = 0; + _ys = 0; + _height = 0; + _thumbHeight = 0; + _mouseDown = false; +} - _displayScreen.setAction(&_sequenceManager2, this, 1879, &_robot, - &_displayScreen, &_airbag, NULL); - } else { - _displayScreen.setAction(&_sequenceManager2, NULL, 1867, &_displayScreen, NULL); - } +void Scene1750::SpeedSlider::synchronize(Serializer &s) { + SceneActor::synchronize(s); - if (R2_GLOBALS.getFlag(34)) - R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, NULL); - else - R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, this); + s.syncAsSint16LE(_incrAmount); + s.syncAsSint16LE(_xp); + s.syncAsSint16LE(_ys); + s.syncAsSint16LE(_height); + s.syncAsSint16LE(_thumbHeight); + s.syncAsSint16LE(_mouseDown); +} - if (_sceneMode == 1851) - _shadeDirection = -20; - else - _shadeDirection = 20; +void Scene1750::SpeedSlider::setupSlider(int incrAmount, int xp, int ys, int height, int thumbHeight) { + _mouseDown = false; + _incrAmount = incrAmount; + _xp = xp; + _ys = ys; + _height = height; + _thumbHeight = thumbHeight; - _shadeCountdown = 20; + postInit(); + setup(1750, 1, 1); + fixPriority(255); + setPosition(Common::Point(_xp, _ys + ((_height * (incrAmount - 1)) / (_thumbHeight - 1)))); +} - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (_sceneMode == 1879) - _sceneMode = 1854; +void Scene1750::SpeedSlider::calculateSlider() { + Scene1750 *scene = (Scene1750 *)R2_GLOBALS._sceneManager._scene; - if (R2_GLOBALS.getFlag(32)) { - setAction(&_sequenceManager1, NULL, 1873, &R2_GLOBALS._player, NULL); - } else { - setAction(&_sequenceManager1, NULL, 1854, &R2_GLOBALS._player, NULL); - } - } else { - if (_sceneMode == 1879) - _sceneMode = 1855; + int tmpVar = (_height / (_thumbHeight - 1)) / 2; + int tmpVar2 = ((_position.y - _ys + tmpVar) * _thumbHeight) / (_height + 2 * tmpVar); - if (R2_GLOBALS.getFlag(32)) { - setAction(&_sequenceManager1, NULL, 1874, &R2_GLOBALS._player, NULL); - } else { - setAction(&_sequenceManager1, NULL, 1855, &R2_GLOBALS._player, NULL); - } - } - break; - case 1857: - if (R2_GLOBALS.getFlag(69)) { - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; + setPosition(Common::Point(_xp, _ys + ((_height * tmpVar2) / (_thumbHeight - 1)))); + scene->_speed = scene->_direction * tmpVar2; +} + +void Scene1750::SpeedSlider::process(Event &event) { + if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) && + (_bounds.contains(event.mousePos))) { + _mouseDown = true; + event.eventType = EVENT_NONE; + } + + if ((event.eventType == EVENT_BUTTON_UP) && _mouseDown) { + _mouseDown = false; + event.handled = true; + addMover(NULL); + calculateSlider(); + } + + if (_mouseDown) { + event.handled = true; + if (event.mousePos.y >= _ys) { + if (_ys + _height >= event.mousePos.y) + setPosition(Common::Point(_xp, event.mousePos.y)); + else + setPosition(Common::Point(_xp, _ys + _height)); } else { - _sceneMode = 1858; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(555, this); - R2_GLOBALS.setFlag(69); + setPosition(Common::Point(_xp, _ys)); } - break; - case 1858: - R2_GLOBALS._player.disableControl(); - _sceneMode = 1859; - setAction(&_sequenceManager1, this, 1859, &R2_GLOBALS._player, &_robot, NULL); - R2_GLOBALS.clearFlag(30); - break; - case 1859: - R2_GLOBALS.setFlag(70); - _sceneMode = 20; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(575, this); - break; - case 1860: - if (_playerDest.x != 0) { - R2_GLOBALS._player.enableControl(); + } +} - PlayerMover *mover = new PlayerMover(); - R2_GLOBALS._player.addMover(mover, &_playerDest, this); +bool Scene1750::SpeedSlider::startAction(CursorType action, Event &event) { + if (action == CURSOR_USE) + return SceneActor::startAction(action, event); - _playerDest = Common::Point(0, 0); - } + return false; +} - switch (_seqNumber) { - case 1: - _sceneMode = 1853; - if (R2_GLOBALS.getFlag(32)) { - setAction(&_sequenceManager1, this, 1872, &R2_GLOBALS._player, NULL); - } else { - setAction(&_sequenceManager1, this, 1853, &R2_GLOBALS._player, NULL); - } - break; - case 2: - _sceneMode = 11; - setAction(&_sequenceManager1, this, 1865, &R2_GLOBALS._player, &_leftDoor, NULL); - break; - case 3: - _sceneMode = 11; - setAction(&_sequenceManager1, this, 1866, &R2_GLOBALS._player, &_rightDoor, NULL); - break; - default: - break; - } +/*------------------------------------------------------------------------*/ - _seqNumber = 0; - break; - case 1870: - R2_GLOBALS._walkRegions.disableRegion(5); - R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 1); - R2_GLOBALS.setFlag(32); - R2_GLOBALS._player.enableControl(CURSOR_WALK); - break; - case 1875: - R2_INVENTORY.setObjectScene(R2_AIRBAG, 1850); - _sceneMode = 21; - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _stripManager.start(561, this); - break; - case 1877: - _screen.postInit(); - _screen._effect = EFFECT_SHADED2; +Scene1750::Scene1750() { + _direction = 0; + _speedCurrent = 0; + _speed = 0; + _speedDelta = 0; + _rotationSegment = 0; + _rotationSegCurrent = 0; + _newRotation = 0; - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *)NULL); - } else { - _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *)NULL); - } + _rotation = nullptr; +} - _helmet.postInit(); - _helmet._effect = EFFECT_SHADED2; +void Scene1750::synchronize(Serializer &s) { + SceneExt::synchronize(s); + SYNC_POINTER(_rotation); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *)NULL); - } else { - _helmet.setDetails(1850, 28, -1, -1, 2, (SceneItem *)NULL); - } + s.syncAsSint16LE(_direction); + s.syncAsSint16LE(_speedCurrent); + s.syncAsSint16LE(_speed); + s.syncAsSint16LE(_speedDelta); + s.syncAsSint16LE(_rotationSegment); + s.syncAsSint16LE(_rotationSegCurrent); + s.syncAsSint16LE(_newRotation); +} - if (R2_GLOBALS.getFlag(31)) { - _screen._shade = 0; - _helmet._shade = 0; - } else { - _screen._shade = 6; - _helmet._shade = 6; - } +void Scene1750::postInit(SceneObjectList *OwnerList) { + loadScene(1750); + R2_GLOBALS._sound1.play(115); + R2_GLOBALS._uiElements._active = false; - R2_GLOBALS.clearFlag(30); - _sceneMode = 15; - setAction(&_sequenceManager1, this, 1869, &R2_GLOBALS._player, &_screen, NULL); - _companion.setAction(&_sequenceManager2, this, 1868, &_companion, &_helmet, NULL); - break; - case 1878: - R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 1850); - R2_GLOBALS.setFlag(33); - R2_GLOBALS._walkRegions.disableRegion(2); - R2_GLOBALS._player.enableControl(); + SceneExt::postInit(); + R2_GLOBALS._interfaceY = SCREEN_HEIGHT; + + R2_GLOBALS._player._characterScene[R2_QUINN] = 1750; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1750; + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1750; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1750; + + _rotation = R2_GLOBALS._scenePalette.addRotation(224, 254, 1); + _rotation->setDelay(0); + _rotation->_idxChange = 0; + _rotation->_countdown = 2; + + switch ((R2_GLOBALS._rimLocation + 2) % 4) { + case 0: + _rotation->_currIndex = 247; break; - case 1879: - R2_GLOBALS._player.enableControl(); + case 1: + _rotation->_currIndex = 235; break; - case 1881: - R2_GLOBALS._sceneManager.changeScene(1875); + case 2: + _rotation->_currIndex = 239; break; - case 1882: - R2_INVENTORY.setObjectScene(R2_AIRBAG, 1); - R2_GLOBALS._player.enableControl(); + case 3: + _rotation->_currIndex = 243; break; default: - R2_GLOBALS._player.enableControl(); break; } -} -void Scene1850::process(Event &event) { - if ( (event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_WALK) - && (R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) { - _playerDest = event.mousePos; - R2_GLOBALS._player.disableControl(); - _sceneMode = 1860; - if (R2_GLOBALS.getFlag(32)) { - setAction(&_sequenceManager1, this, 1860, &R2_GLOBALS._player, &_robot, NULL); - } else { - setAction(&_sequenceManager1, this, 1859, &R2_GLOBALS._player, &_robot, NULL); - } - R2_GLOBALS.clearFlag(30); - event.handled = true; + byte tmpPal[768]; + + for (int i = 224; i < 255; i++) { + int tmpIndex = _rotation->_currIndex - 224; + if (tmpIndex > 254) + tmpIndex -= 31; + tmpPal[3 * i] = R2_GLOBALS._scenePalette._palette[3 * tmpIndex]; + tmpPal[(3 * i) + 1] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 1]; + tmpPal[(3 * i) + 2] = R2_GLOBALS._scenePalette._palette[(3 * tmpIndex) + 2]; } - Scene::process(event); -} + for (int i = 224; i < 255; i++) { + R2_GLOBALS._scenePalette._palette[3 * i] = tmpPal[3 * i]; + R2_GLOBALS._scenePalette._palette[(3 * i) + 1] = tmpPal[(3 * i) + 1]; + R2_GLOBALS._scenePalette._palette[(3 * i) + 2] = tmpPal[(3 * i) + 2]; + } -void Scene1850::dispatch() { - if (_shadeChanging) { - _shadeCountdown--; - if (_shadeCountdown == 0) - _shadeChanging = false; + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); + R2_GLOBALS._player.enableControl(); - if (_shadeDirection >= 0) { - R2_GLOBALS._player._shade = (_shadeCountdown * 6) / _shadeDirection; - } else { - R2_GLOBALS._player._shade = ((_shadeCountdown * 6) / _shadeDirection) + 6; - } - R2_GLOBALS._player._flags |= OBJFLAG_PANES; + _radarSweep.postInit(); + _radarSweep.setup(1750, 3, 1); + _radarSweep.setPosition(Common::Point(49, 185)); + _radarSweep.fixPriority(7); + _radarSweep.setDetails(1750, 30, -1, -1, 1, (SceneItem *) NULL); - _companion._shade = R2_GLOBALS._player._shade; - _companion._flags |= OBJFLAG_PANES; + _scannerIcon.postInit(); + _scannerIcon.setup(1750, 2, 1); + _scannerIcon.setPosition(Common::Point(35, ((_rotation->_currIndex - 218) % 4) + ((R2_GLOBALS._rimLocation % 800) * 4) - 1440)); + _scannerIcon.fixPriority(8); - _screen._shade = R2_GLOBALS._player._shade; - _screen._flags |= OBJFLAG_PANES; + _redLights.postInit(); + _redLights.setup(1750, 1, 4); - _helmet._shade = R2_GLOBALS._player._shade; - _helmet._flags |= OBJFLAG_PANES; - } + int tmpVar = ABS(_scannerIcon._position.y - 158) / 100; - if (R2_GLOBALS.getFlag(32)) { - _screen.setPosition(Common::Point(_displayScreen._position.x - 37, _displayScreen._position.y - 71)); - _helmet.setPosition(Common::Point(_displayScreen._position.x - 20, _displayScreen._position.y - 73)); - } + if (tmpVar >= 8) + _redLights.hide(); + else if (_scannerIcon._position.y <= 158) + _redLights.setPosition(Common::Point(137, (tmpVar * 7) + 122)); + else + _redLights.setPosition(Common::Point(148, (tmpVar * 7) + 122)); - if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { - _airbag.setPosition(Common::Point(_displayScreen._position.x + 20, _displayScreen._position.y - 71)); - } + _speedSlider.setupSlider(1, 286, 143, 41, 15); + _speedSlider.setDetails(1750, 24, 1, -1, 1, (SceneItem *) NULL); - Scene::dispatch(); -} + _forwardButton.postInit(); + _forwardButton._buttonId = 1; + _forwardButton.setup(1750, 1, 2); + _forwardButton.setPosition(Common::Point(192, 140)); + _forwardButton.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL); -/*-------------------------------------------------------------------------- - * Scene 1875 - Rim Lift Computer - * - *--------------------------------------------------------------------------*/ + _backwardButton.postInit(); + _backwardButton._buttonId = 2; + _backwardButton.setup(1750, 1, 3); + _backwardButton.setPosition(Common::Point(192, 163)); + _backwardButton.setDetails(1750, 18, 1, -1, 1, (SceneItem *) NULL); + _backwardButton.hide(); -Scene1875::Button::Button() { - _buttonId = 0; - _buttonDown = false; + _exitButton.postInit(); + _exitButton._buttonId = 3; + _exitButton.setup(1750, 1, 5); + _exitButton.setPosition(Common::Point(230, 183)); + _exitButton.setDetails(1750, 27, 1, -1, 1, (SceneItem *) NULL); + + _direction = 1; // Forward by default + _speedDelta = 0; + _speedCurrent = 0; + _speed = 0; + _rotationSegment = ((_rotation->_currIndex - 218) / 4) % 4; + + _redLightsDescr.setDetails(Rect(129, 112, 155, 175), 1750, 21, -1, -1, 1, NULL); + _greenLights.setDetails(Rect(93, 122, 126, 172), 1750, 15, -1, -1, 1, NULL); + _frontView.setDetails(Rect(3, 3, 157, 99), 1750, 9, -1, -1, 1, NULL); + _rearView.setDetails(Rect(162, 3, 316, 99), 1750, 12, -1, -1, 1, NULL); + _background.setDetails(Rect(0, 0, 320, 200), 1750, 6, 1, -1, 1, NULL); } -void Scene1875::Button::synchronize(Serializer &s) { - SceneActor::synchronize(s); +void Scene1750::remove() { + if (R2_GLOBALS._rimLocation == 2400) + R2_GLOBALS._rimLocation = 2399; - s.syncAsSint16LE(_buttonId); - s.syncAsSint16LE(_buttonDown); + if (R2_GLOBALS._rimLocation == -2400) + R2_GLOBALS._rimLocation = -2399; + + R2_GLOBALS._rimTransportLocation = R2_GLOBALS._rimLocation; + + SceneExt::remove(); + R2_GLOBALS._sound1.fadeOut2(NULL); + R2_GLOBALS._uiElements._active = true; } -void Scene1875::Button::doButtonPress() { - Scene1875 *scene = (Scene1875 *)R2_GLOBALS._sceneManager._scene; +void Scene1750::signal() { + R2_GLOBALS._player.enableControl(); +} - R2_GLOBALS._sound1.play(227); +void Scene1750::process(Event &event) { + Scene::process(event); + if (!event.handled) + _speedSlider.process(event); +} - int newFrameNumber; - switch (_buttonId) { - case 3: - if ((scene->_map._frame == 1) && (scene->_button1._strip == 2)) { - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - scene->_sceneMode = 10; - scene->_stripManager.start(576, scene); - } else { - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1890; - scene->_rimPosition.postInit(); - scene->setAction(&scene->_sequenceManager, scene, 1890, &scene->_rimPosition, NULL); +void Scene1750::dispatch() { + if (_rotation) { + if (!_speedDelta && (_speed != _speedCurrent)) { + if (_speedCurrent >= _speed) + --_speedCurrent; + else + ++_speedCurrent; + + _speedDelta = 21 - ABS(_speedCurrent); } - break; - case 4: - newFrameNumber = scene->_map._frame + 1; - if (newFrameNumber > 6) - newFrameNumber = 1; - scene->_map.setFrame(newFrameNumber); - break; - case 5: - newFrameNumber = scene->_map._frame - 1; - if (newFrameNumber < 1) - newFrameNumber = 6; - scene->_map.setFrame(newFrameNumber); - break; - default: - break; - } -} -void Scene1875::Button::initButton(int buttonId) { - postInit(); - _buttonId = buttonId; - _buttonDown = false; - setVisage(1855); + if (_speedDelta == 1) { + if (_speedCurrent == 0) { + _radarSweep.show(); + _rotation->_idxChange = 0; + } else { + if (_rotation->_idxChange == 0) + _radarSweep.hide(); - if (_buttonId == 1) - setStrip(2); - else - setStrip(1); + if (_speedCurrent < -12) { + _rotation->setDelay(15 - ABS(_speedCurrent)); + _rotation->_idxChange = -2; + } else if (_speedCurrent < 0) { + _rotation->setDelay(10 - ABS(_speedCurrent)); + _rotation->_idxChange = -1; + } else if (_speedCurrent < 11) { + _rotation->setDelay(10 - _speedCurrent); + _rotation->_idxChange = 1; + } else { + _rotation->setDelay(15 - _speedCurrent); + _rotation->_idxChange = 2; + } + } + } - setFrame(_buttonId); - switch (_buttonId) { - case 1: - setPosition(Common::Point(20, 144)); - break; - case 2: - setPosition(Common::Point(82, 144)); - break; - case 3: - setPosition(Common::Point(136, 144)); - break; - case 4: - setPosition(Common::Point(237, 144)); - break; - case 5: - setPosition(Common::Point(299, 144)); - break; - default: - break; - } + if (_speedDelta) + --_speedDelta; - setDetails(1875, 6, 1, -1, 2, (SceneItem *) NULL); -} + _rotationSegCurrent = _rotationSegment; + _rotationSegment = ((_rotation->_currIndex - 218) / 4) % 4; -void Scene1875::Button::process(Event &event) { - if (!R2_GLOBALS._player._uiEnabled || event.handled) - return; + if ((_rotationSegCurrent + 1) == _rotationSegment || (_rotationSegCurrent - 3) == _rotationSegment) { + if (R2_GLOBALS._rimLocation < 2400) { + ++R2_GLOBALS._rimLocation; + } + } - Scene1875 *scene = (Scene1875 *)R2_GLOBALS._sceneManager._scene; + if ((_rotationSegCurrent - 1) == _rotationSegment || (_rotationSegCurrent + 3) == _rotationSegment) { + if (R2_GLOBALS._rimLocation > -2400) { + --R2_GLOBALS._rimLocation; + } + } - if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) - && (_bounds.contains(event.mousePos)) && !_buttonDown) { - setStrip(2); - switch (_buttonId) { - case 1: - R2_GLOBALS._sound2.play(227); - scene->_button2.setStrip(1); - break; - case 2: - R2_GLOBALS._sound2.play(227); - scene->_button1.setStrip(1); - break; - default: - break; + if (_rotation->_currIndex != _newRotation) { + // Handle setting the position of the lift icon in the scanner display + _newRotation = _rotation->_currIndex; + _scannerIcon.setPosition(Common::Point(35, ((_rotation->_currIndex - 218) % 4) + + ((R2_GLOBALS._rimLocation % 800) * 4) - 1440)); } - _buttonDown = true; - event.handled = true; } - if ((event.eventType == EVENT_BUTTON_UP) && _buttonDown) { - if ((_buttonId == 3) || (_buttonId == 4) || (_buttonId == 5)) { - setStrip(1); - doButtonPress(); - } - _buttonDown = false; - event.handled = true; + int v = ABS(_scannerIcon._position.y - 158) / 100; + if (v < 8) { + // Show how close the user is to the lift on the second column of lights + _redLights.show(); + _redLights.setPosition(Common::Point((_scannerIcon._position.y <= 158) ? 137 : 148, + v * 7 + 122)); + } else { + _redLights.hide(); } } -void Scene1875::postInit(SceneObjectList *OwnerList) { - loadScene(1875); - SceneExt::postInit(); +/*-------------------------------------------------------------------------- + * Scene 1800 - Rim Lift Exterior + * + *--------------------------------------------------------------------------*/ - R2_GLOBALS._player._characterScene[R2_QUINN] = 1875; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1875; +Scene1800::Scene1800() { + _locationMode = 0; +} - _stripManager.addSpeaker(&_quinnSpeaker); - _stripManager.addSpeaker(&_seekerSpeaker); +void Scene1800::synchronize(Serializer &s) { + SceneExt::synchronize(s); - _button1.initButton(1); - _button2.initButton(2); - _button3.initButton(3); - _button4.initButton(4); - _button5.initButton(5); + s.syncAsSint16LE(_locationMode); +} - _map.postInit(); - _map.setup(1855, 4, 1); - _map.setPosition(Common::Point(160, 116)); +bool Scene1800::Background::startAction(CursorType action, Event &event) { + if ((action != R2_COM_SCANNER) && (action != R2_COM_SCANNER_2)) + return false; - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.hide(); + Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; - if (R2_GLOBALS._sceneManager._previousScene == 1625) { - R2_GLOBALS._sound1.play(122); - R2_GLOBALS._player.disableControl(); - _sceneMode = 11; - _rimPosition.postInit(); - setAction(&_sequenceManager, this, 1892, &_rimPosition, NULL); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS._rimLocation == 1201) { + scene->_stripManager.start(548, this); + } else if (R2_GLOBALS.getFlag(66)) { + return false; + } else { + scene->_stripManager.start(546, this); + } } else { - if (R2_GLOBALS._sceneManager._previousScene == 3150) { - R2_GLOBALS._sound1.play(116); + if (R2_GLOBALS._rimLocation == 1201) { + scene->_stripManager.start(549, this); + } else if (R2_GLOBALS.getFlag(66)) { + return false; + } else { + scene->_stripManager.start(547, this); } - - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; } - _screen.setDetails(Rect(43, 14, 275, 122), 1875, 9, 1, -1, 1, NULL); - _background.setDetails(Rect(0, 0, 320, 200), 1875, 3, -1, -1, 1, NULL); + R2_GLOBALS.setFlag(66); + return true; +} - R2_GLOBALS._player._characterScene[R2_QUINN] = 1875; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1875; - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1875; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1875; +bool Scene1800::Lever::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + if (!R2_GLOBALS.getFlag(14)) + return false; + + if (R2_GLOBALS._player._characterIndex != R2_QUINN) + return SceneActor::startAction(action, event); + + Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.disableControl(); + + if (_frame == 1) { + R2_GLOBALS.setFlag(64); + scene->_sceneMode = 1810; + scene->setAction(&scene->_sequenceManager, scene, 1810, &R2_GLOBALS._player, &scene->_lever, &scene->_leftStaircase, &scene->_rightStaircase, NULL); + } else { + R2_GLOBALS.clearFlag(64); + scene->_sceneMode = 1811; + scene->setAction(&scene->_sequenceManager, scene, 1811, &R2_GLOBALS._player, &scene->_lever, &scene->_leftStaircase, &scene->_rightStaircase, NULL); + } + return true; } -void Scene1875::signal() { - switch (_sceneMode) { - case 10: +bool Scene1800::Doors::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + + if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { + // Seeker trying to force open the door R2_GLOBALS._player.disableControl(); - _sceneMode = 1891; - _rimPosition.postInit(); - setAction(&_sequenceManager, this, 1891, &_rimPosition, NULL); - break; - case 11: - R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); - _sceneMode = 1892; - _stripManager.start(577, this); - break; - case 1890: - _rimPosition.remove(); - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; - break; - case 1891: + if (scene->_locationMode >= 2) { + if (R2_GLOBALS.getFlag(14)) { + // Allow door to close + scene->_sceneMode = 1809; + scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + // Force open door + scene->_sceneMode = 1808; + scene->setAction(&scene->_sequenceManager, scene, 1808, &R2_GLOBALS._player, &scene->_doors, NULL); + R2_GLOBALS.setFlag(14); + } + } else { + // Seeker failing to force open doors + scene->_sceneMode = 1813; + // Original was using 1813 in setAction too, but it somewhat broken. + // Seeker goes 2 pixels to high, hiding behind the door + scene->setAction(&scene->_sequenceManager, scene, 1808, &R2_GLOBALS._player, &scene->_doors, NULL); + } + } else if (R2_GLOBALS.getFlag(14)) { + return SceneActor::startAction(action, event); + } else { + // Quinn trying to force open doors R2_GLOBALS._player.disableControl(); - R2_GLOBALS._sceneManager.changeScene(1625); - break; - case 1892: + scene->_sceneMode = 1812; + scene->setAction(&scene->_sequenceManager, scene, 1812, &R2_GLOBALS._player, NULL); + } + + return true; +} + +bool Scene1800::PassengerDoor::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); + + Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; + + if (_position.x < 160) { + if (scene->_leftStaircase._frame == 1) { + return SceneActor::startAction(action, event); + } else { + R2_GLOBALS.setFlag(29); + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 1; + scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + scene->_sceneMode = 1804; + scene->setAction(&scene->_sequenceManager, scene, 1804, &R2_GLOBALS._player, &scene->_companion, &scene->_leftDoor, NULL); + } + } else { + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 1; + scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + scene->_sceneMode = 1805; + scene->setAction(&scene->_sequenceManager, scene, 1805, &R2_GLOBALS._player, &scene->_companion, &scene->_leftDoor, NULL); + } + } + } + } else if (scene->_leftStaircase._frame == 1) { + return SceneActor::startAction(action, event); + } else { + R2_GLOBALS.clearFlag(29); R2_GLOBALS._player.disableControl(); - R2_GLOBALS._sceneManager.changeScene(1900); - break; - default: - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; - break; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 2; + scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + scene->_sceneMode = 1806; + scene->setAction(&scene->_sequenceManager, scene, 1806, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); + } + } else { + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 2; + scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); + } else { + scene->_sceneMode = 1807; + scene->setAction(&scene->_sequenceManager, scene, 1807, &R2_GLOBALS._player, &scene->_companion, &scene->_rightDoor, NULL); + } + } } -} - -void Scene1875::process(Event &event) { - Scene::process(event); - _button1.process(event); - _button2.process(event); - _button3.process(event); - _button4.process(event); - _button5.process(event); + return true; } -/*-------------------------------------------------------------------------- - * Scene 1900 - Spill Mountains Elevator Exit - * - *--------------------------------------------------------------------------*/ - -bool Scene1900::LiftDoor::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneActor::startAction(action, event); +void Scene1800::SouthExit::changeScene() { + Scene1800 *scene = (Scene1800 *)R2_GLOBALS._sceneManager._scene; - if ((_frame != 1) || (R2_GLOBALS._player._characterIndex != R2_SEEKER)) { + _enabled = false; + R2_GLOBALS._events.setCursor(CURSOR_WALK); + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS.getFlag(14)) { + scene->_sceneMode = 3; if (R2_GLOBALS._player._characterIndex == R2_QUINN) - return SceneActor::startAction(action, event); + scene->setAction(&scene->_sequenceManager, scene, 1809, &scene->_companion, &scene->_doors, NULL); else - return true; - } - - Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.enableControl(CURSOR_USE); - - if (_position.x >= 160) { - scene->_sceneMode = 1905; - scene->setAction(&scene->_sequenceManager1, scene, 1905, &R2_GLOBALS._player, &scene->_rightDoor, NULL); + scene->setAction(&scene->_sequenceManager, scene, 1809, &R2_GLOBALS._player, &scene->_doors, NULL); + R2_GLOBALS.clearFlag(14); } else { - R2_GLOBALS.setFlag(29); - scene->_sceneMode = 1904; - scene->setAction(&scene->_sequenceManager1, scene, 1904, &R2_GLOBALS._player, &scene->_leftDoor, NULL); + scene->_sceneMode = 1802; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + scene->setAction(&scene->_sequenceManager, scene, 1802, &R2_GLOBALS._player, &scene->_companion, NULL); + else + scene->setAction(&scene->_sequenceManager, scene, 1803, &R2_GLOBALS._player, &scene->_companion, NULL); } - - return true; } -void Scene1900::WestExit::changeScene() { - Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; +void Scene1800::postInit(SceneObjectList *OwnerList) { + loadScene(1800); + SceneExt::postInit(); + R2_GLOBALS._sound1.play(116); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->_sceneMode = 10; + if (R2_GLOBALS._sceneManager._previousScene == -1) + R2_GLOBALS._rimLocation = 1201; - Common::Point pt(-10, 135); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} + // Set the mode based on whether this is the "correct" lift or not + if (R2_GLOBALS._rimLocation == 1201) + _locationMode = 2; + else + _locationMode = 0; -void Scene1900::EastExit::changeScene() { - Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; + scalePalette(65, 65, 65); + _southExit.setDetails(Rect(0, 160, 319, 168), EXITCURSOR_S, 1800); + _background.setDetails(Rect(0, 0, 320, 200), -1, -1, -1, -1, 1, NULL); - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->_sceneMode = 11; + _lever.postInit(); + _lever.setup(1801, 4, 1); + _lever.setPosition(Common::Point(170, 124)); + _lever.setDetails(1800, 13, 14, 15, 1, (SceneItem *) NULL); - Common::Point pt(330, 135); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} + _doors.postInit(); + _doors.setup(1801, 3, 1); + _doors.setPosition(Common::Point(160, 139)); + _doors.setDetails(1800, 6, -1, -1, 1, (SceneItem *) NULL); -void Scene1900::postInit(SceneObjectList *OwnerList) { - loadScene(1900); - SceneExt::postInit(); + _leftDoor.postInit(); + _leftDoor.setup(1800, 1, 1); + _leftDoor.setPosition(Common::Point(110, 78)); + _leftDoor.fixPriority(135); + _leftDoor.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); - // Debug message, skipped + _rightDoor.postInit(); + _rightDoor.setup(1800, 2, 1); + _rightDoor.setPosition(Common::Point(209, 78)); + _rightDoor.fixPriority(135); + _rightDoor.setDetails(1800, 20, -1, -1, 1, (SceneItem *) NULL); - if (R2_GLOBALS._sceneManager._previousScene == -1) { - R2_GLOBALS._sceneManager._previousScene = 1925; - R2_GLOBALS._player._characterIndex = R2_SEEKER; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1925; - } + _leftStaircase.postInit(); + if ((_locationMode != 1) && (_locationMode != 3) && (!R2_GLOBALS.getFlag(64))) + _leftStaircase.setup(1801, 2, 1); + else + _leftStaircase.setup(1801, 2, 10); + _leftStaircase.setPosition(Common::Point(76, 142)); + _leftStaircase.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); - if (R2_GLOBALS._sceneManager._previousScene != 1875) - R2_GLOBALS._sound1.play(200); + _rightStaircase.postInit(); + if ((_locationMode != 1) && (_locationMode != 3) && (!R2_GLOBALS.getFlag(64))) + _rightStaircase.setup(1801, 1, 1); + else + _rightStaircase.setup(1801, 1, 10); + _rightStaircase.setPosition(Common::Point(243, 142)); + _rightStaircase.setDetails(1800, 3, -1, -1, 1, (SceneItem *) NULL); - _stripManager.setColors(60, 255); - _stripManager.setFontNumber(3); - _stripManager.addSpeaker(&_seekerSpeaker); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + // Standard Quinn setup + R2_GLOBALS._player.setVisage(1503); + R2_GLOBALS._player._moveDiff = Common::Point(2, 2); + } else { + // Seeker setup dependent on whether he's holding the doors or not + if (R2_GLOBALS.getFlag(14)) { + R2_GLOBALS._player.animate(ANIM_MODE_NONE, NULL); + R2_GLOBALS._player.setObjectWrapper(NULL); + R2_GLOBALS._player.setup(1801, 5, 12); + R2_GLOBALS._player.setPosition(Common::Point(160, 139)); + R2_GLOBALS._walkRegions.disableRegion(9); + _doors.hide(); + } else { + R2_GLOBALS._player.setVisage(1507); + } + R2_GLOBALS._player._moveDiff = Common::Point(4, 2); + } - _westExit.setDetails(Rect(0, 105, 14, 145), EXITCURSOR_W, 2000); - _westExit.setDest(Common::Point(14, 135)); + _companion.postInit(); + _companion.animate(ANIM_MODE_1, NULL); + _companion.setObjectWrapper(new SceneObjectWrapper()); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(14)) { + _companion.animate(ANIM_MODE_NONE, NULL); + _companion.setObjectWrapper(NULL); + _companion.setup(1801, 5, 12); - _eastExit.setDetails(Rect(305, 105, 320, 145), EXITCURSOR_E, 2000); - _eastExit.setDest(Common::Point(315, 135)); + R2_GLOBALS._walkRegions.disableRegion(9); + _doors.hide(); + } else { + _companion.setup(1507, 1, 1); + _companion.setPosition(Common::Point(180, 160)); + } + _companion.setDetails(9002, 0, 4, 3, 1, (SceneItem *) NULL); + _companion._moveDiff = Common::Point(4, 2); + } else { + _companion.setDetails(9001, 0, 5, 3, 1, (SceneItem *) NULL); + _companion.setVisage(1503); + _companion._moveDiff = Common::Point(2, 2); + } - R2_GLOBALS._player.postInit(); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - R2_GLOBALS._player.setup(2008, 3, 1); - else - R2_GLOBALS._player.setup(20, 3, 1); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) { + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player.setPosition(Common::Point(114, 150)); + R2_GLOBALS._player.setStrip(5); + if (R2_GLOBALS.getFlag(14)) { + _companion.setPosition(Common::Point(160, 139)); + R2_GLOBALS._walkRegions.disableRegion(8); + } else { + _companion.setPosition(Common::Point(209, 150)); + _companion.setStrip(6); + R2_GLOBALS._walkRegions.disableRegion(8); + } + } else { + if (R2_GLOBALS.getFlag(14)) { + R2_GLOBALS._player.setup(1801, 5, 12); + R2_GLOBALS._player.setPosition(Common::Point(160, 139)); + } else { + R2_GLOBALS._player.setPosition(Common::Point(209, 150)); + R2_GLOBALS._player.setStrip(6); + } + _companion.setPosition(Common::Point(114, 150)); + _companion.setStrip(5); + R2_GLOBALS._walkRegions.disableRegion(10); + R2_GLOBALS._walkRegions.disableRegion(11); + } + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player.setPosition(Common::Point(140, 160)); + _companion.setPosition(Common::Point(180, 160)); + } else { + R2_GLOBALS._player.setPosition(Common::Point(180, 160)); + _companion.setPosition(Common::Point(140, 160)); + } + + _playerShadow.postInit(); + _playerShadow.fixPriority(10); if (R2_GLOBALS._player._characterIndex == R2_QUINN) - R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + _playerShadow.setVisage(1111); else - R2_GLOBALS._player._moveDiff = Common::Point(5, 3); - R2_GLOBALS._player.disableControl(); + _playerShadow.setVisage(1110); - if (R2_GLOBALS._sceneManager._previousScene != 1925) - R2_GLOBALS.clearFlag(29); + _playerShadow._effect = EFFECT_SHADOW_MAP; + _playerShadow._shadowMap = _shadowPaletteMap; - _leftDoor.postInit(); - _leftDoor.setup(1901, 1, 1); - _leftDoor.setPosition(Common::Point(95, 109)); - _leftDoor.fixPriority(100); + R2_GLOBALS._player._linkedActor = &_playerShadow; + _companionShadow.postInit(); + _companionShadow.fixPriority(10); if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _leftDoor.setDetails(1900, 0, 1, 2, 1, (SceneItem *) NULL); + _companionShadow.setVisage(1110); else - _leftDoor.setDetails(1900, 0, 1, -1, 1, (SceneItem *) NULL); + _companionShadow.setVisage(1111); - _rightDoor.postInit(); - _rightDoor.setup(1901, 2, 1); - _rightDoor.setPosition(Common::Point(225, 109)); - _rightDoor.fixPriority(100); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) - _rightDoor.setDetails(1900, 0, 1, 2, 1, (SceneItem *) NULL); - else - _rightDoor.setDetails(1900, 0, 1, -1, 1, (SceneItem *) NULL); + _companionShadow._effect = EFFECT_SHADOW_MAP; + _companionShadow._shadowMap = _shadowPaletteMap; - if (R2_GLOBALS._sceneManager._previousScene != 1875) { - _leftDoorFrame.postInit(); - _leftDoorFrame.setup(1945, 6, 1); - _leftDoorFrame.setPosition(Common::Point(96, 109)); - _leftDoorFrame.fixPriority(80); + _companion._linkedActor = &_companionShadow; - _rightDoorFrame.postInit(); - _rightDoorFrame.setup(1945, 6, 2); - _rightDoorFrame.setPosition(Common::Point(223, 109)); - _rightDoorFrame.fixPriority(80); - } + R2_GLOBALS._player._characterScene[R2_QUINN] = 1800; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1800; - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1875) { - R2_GLOBALS._player._characterIndex = R2_QUINN; - _companion.postInit(); - _sceneMode = 20; - R2_GLOBALS._player.setAction(&_sequenceManager1, NULL, 1901, &R2_GLOBALS._player, &_leftDoor, NULL); - _companion.setAction(&_sequenceManager2, this, 1900, &_companion, &_rightDoor, NULL); - } else if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1925) { - if (R2_GLOBALS.getFlag(29)) { - R2_GLOBALS.clearFlag(29); - _leftDoor.hide(); + _elevatorContents.setDetails(Rect(128, 95, 190, 135), 1800, 10, -1, -1, 1, NULL); + _elevator.setDetails(Rect(95, 3, 223, 135), 1800, 0, -1, -1, 1, NULL); - R2_GLOBALS._player.setStrip(6); - R2_GLOBALS._player.setPosition(Common::Point(90, 106)); - _sceneMode = 1906; - setAction(&_sequenceManager1, this, 1906, &R2_GLOBALS._player, &_leftDoor, NULL); - } else { - _rightDoor.hide(); - R2_GLOBALS._player.setStrip(5); - R2_GLOBALS._player.setPosition(Common::Point(230, 106)); - _sceneMode = 1907; - setAction(&_sequenceManager1, this, 1907, &R2_GLOBALS._player, &_rightDoor, NULL); - } + // Original was calling _item3.setDetails(Rect(1800, 11, 24, 23), 25, -1, -1, -1, 1, NULL); + // This is *wrong*. The following statement is a wild guess based on good common sense + _surface.setDetails(11, 1800, 23, 24, 25); + _secBackground.setDetails(Rect(0, 0, 320, 200), 1800, 17, -1, 19, 1, NULL); - if (R2_GLOBALS._player._characterScene[R2_QUINN] == R2_GLOBALS._player._characterScene[R2_SEEKER]) { - _companion.postInit(); - _companion.setPosition(Common::Point(30, 110)); - R2_GLOBALS._walkRegions.disableRegion(1); - _companion.setup(2008, 3, 1); - _companion.setDetails(9001, 0, -1, -1, 1, (SceneItem *) NULL); - } - R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1900; - } else { - if (R2_GLOBALS._player._characterScene[R2_QUINN] == R2_GLOBALS._player._characterScene[R2_SEEKER]) { - _companion.postInit(); - _companion.setPosition(Common::Point(30, 110)); - R2_GLOBALS._walkRegions.disableRegion(1); - if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - _companion.setup(20, 3, 1); - _companion.setDetails(9002, 1, -1, -1, 1, (SceneItem *) NULL); - } else { - _companion.setup(2008, 3, 1); - _companion.setDetails(9001, 0, -1, -1, 1, (SceneItem *) NULL); - } + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1800) { + if ((R2_GLOBALS.getFlag(14)) && (R2_GLOBALS._player._characterIndex == R2_SEEKER)) { + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + } else { + R2_GLOBALS._player.enableControl(CURSOR_WALK); } - - if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 2000) { + } else if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1850) { + if (R2_GLOBALS.getFlag(29)) { if (R2_GLOBALS._player._characterIndex == R2_QUINN) { - if (R2_GLOBALS._spillLocation[R2_QUINN] == 5) { - _sceneMode = 1902; - setAction(&_sequenceManager1, this, 1902, &R2_GLOBALS._player, NULL); - } else { - _sceneMode = 1903; - setAction(&_sequenceManager1, this, 1903, &R2_GLOBALS._player, NULL); - } + _sceneMode = 1814; + setAction(&_sequenceManager, this, 1814, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); } else { - if (R2_GLOBALS._spillLocation[R2_SEEKER] == 5) { - _sceneMode = 1908; - setAction(&_sequenceManager1, this, 1908, &R2_GLOBALS._player, NULL); - } else { - _sceneMode = 1909; - setAction(&_sequenceManager1, this, 1909, &R2_GLOBALS._player, NULL); - } + _sceneMode = 1815; + setAction(&_sequenceManager, this, 1815, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); } + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1816; + setAction(&_sequenceManager, this, 1816, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); } else { - R2_GLOBALS._player.setPosition(Common::Point(160, 135)); - R2_GLOBALS._player.enableControl(); + _sceneMode = 1817; + setAction(&_sequenceManager, this, 1817, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); } - R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1900; + } else if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1800; + setAction(&_sequenceManager, this, 1800, &R2_GLOBALS._player, &_companion, NULL); + } else { + _sceneMode = 1801; + setAction(&_sequenceManager, this, 1801, &R2_GLOBALS._player, &_companion, NULL); } - _elevator.setDetails(Rect(77, 2, 240, 103), 1900, 6, -1, -1, 1, NULL); - _background.setDetails(Rect(0, 0, 320, 200), 1900, 3, -1, -1, 1, NULL); -} - -void Scene1900::remove() { - R2_GLOBALS._sound1.fadeOut(NULL); - SceneExt::remove(); + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1800; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1800; } -void Scene1900::signal() { +void Scene1800::signal() { switch (_sceneMode) { - case 10: - R2_GLOBALS._spillLocation[R2_GLOBALS._player._characterIndex] = 5; - R2_GLOBALS._sceneManager.changeScene(2000); + case 1: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1804; + setAction(&_sequenceManager, this, 1804, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); + } else { + _sceneMode = 1805; + setAction(&_sequenceManager, this, 1805, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); + } + break; + case 2: + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _sceneMode = 1806; + setAction(&_sequenceManager, this, 1806, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + } else { + _sceneMode = 1807; + setAction(&_sequenceManager, this, 1807, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + } break; + case 3: + _sceneMode = 1802; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + setAction(&_sequenceManager, this, 1802, &R2_GLOBALS._player, &_companion, NULL); + else + setAction(&_sequenceManager, this, 1803, &R2_GLOBALS._player, &_companion, NULL); + break; + case 10: + // No break on purpose case 11: - R2_GLOBALS._spillLocation[R2_GLOBALS._player._characterIndex] = 6; - R2_GLOBALS._sceneManager.changeScene(2000); + R2_GLOBALS._player.enableControl(CURSOR_TALK); break; - case 20: - ++_sceneMode; - R2_GLOBALS._events.setCursor(CURSOR_WALK); - _stripManager.start(1300, this); + case 12: + R2_GLOBALS._player.enableControl(CURSOR_TALK); + R2_GLOBALS._player._canWalk = false; break; - case 21: - ++_sceneMode; + case 13: + _sceneMode = 14; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + R2_GLOBALS._player.setup(1801, 7, 1); + R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); + _stripManager.start(550, this); + break; + case 14: + _sceneMode = 15; R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._player._action) - R2_GLOBALS._player._action->_endHandler = this; - else - signal(); + R2_GLOBALS._player.setup(1801, 6, 1); + R2_GLOBALS._player.animate(ANIM_MODE_6, this); break; - case 22: - _sceneMode = 1910; - _companion.setAction(&_sequenceManager2, this, 1910, &_companion, NULL); + case 15: + R2_GLOBALS._player.setup(1503, 4, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.enableControl(CURSOR_USE); break; - case 1904: - R2_GLOBALS._scene1925CurrLevel = -3; + // Cases 23 and 24 have been added to fix missing hardcoded logic in the original, + // when Seeker tries to open the door + case 23: + _sceneMode = 24; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + R2_GLOBALS._player.setup(1801, 5, 1); + R2_GLOBALS._player.animate(ANIM_MODE_8, 0, NULL); + _stripManager.start(550, this); + break; + case 24: + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.setup(1507, 4, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.enableControl(CURSOR_USE); + + _doors.setup(1801, 3, 1); + _doors.setPosition(Common::Point(160, 139)); + _doors.setDetails(1800, 6, -1, -1, 1, (SceneItem *) NULL); + _doors.show(); + + R2_GLOBALS._player._position.y += 2; + R2_GLOBALS._player.show(); + break; + case 1800: + R2_GLOBALS._walkRegions.disableRegion(8); + if (R2_GLOBALS.getFlag(63)) + R2_GLOBALS._player.enableControl(CURSOR_USE); + else { + _sceneMode = 10; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(544, this); + } + break; + case 1801: + R2_GLOBALS._walkRegions.disableRegion(10); + R2_GLOBALS._walkRegions.disableRegion(11); + R2_GLOBALS.setFlag(63); + R2_GLOBALS._player.enableControl(CURSOR_WALK); + break; + case 1802: + R2_GLOBALS.clearFlag(14); + R2_GLOBALS._sceneManager.changeScene(1700); + break; + case 1804: // No break on purpose - case 1905: - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._sceneManager.changeScene(1925); + case 1805: + // No break on purpose + case 1806: + // No break on purpose + case 1807: + R2_GLOBALS.clearFlag(14); + R2_GLOBALS._sceneManager.changeScene(1850); break; - case 1910: - R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 2535); - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1900; - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1900; - R2_GLOBALS._sceneManager.changeScene(2450); + case 1808: + _sceneMode = 12; + R2_GLOBALS._events.setCursor(CURSOR_WALK); + _stripManager.start(553, this); break; - case 1906: - R2_GLOBALS._scene1925CurrLevel = -3; + case 1812: + _sceneMode = 13; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + // Case 1813 has been added to fix Seeker missing animation in the original game + case 1813: + _sceneMode = 23; + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + break; + case 1814: + // No break on purpose + case 1815: + R2_GLOBALS._walkRegions.disableRegion(10); + R2_GLOBALS._walkRegions.disableRegion(11); + R2_GLOBALS._player.enableControl(); + break; + case 1816: // No break on purpose + case 1817: + R2_GLOBALS._walkRegions.disableRegion(8); + R2_GLOBALS._player.enableControl(); + break; default: R2_GLOBALS._player.enableControl(); break; } } -/*-------------------------------------------------------------------------- - * Scene 1925 - Spill Mountains Elevator Shaft - * - *--------------------------------------------------------------------------*/ +void Scene1800::saveCharacter(int characterIndex) { + if (R2_GLOBALS._player._characterIndex == R2_MIRANDA) + R2_GLOBALS._sound1.fadeOut2(NULL); -Scene1925::Scene1925() { - _newSceneMode = 0; - for (int i = 0; i < 5; i++) - _levelResNum[i] = 0; + SceneExt::saveCharacter(characterIndex); } -void Scene1925::synchronize(Serializer &s) { - SceneExt::synchronize(s); - - s.syncAsSint16LE(_newSceneMode); - for (int i = 0; i < 5; i++) - s.syncAsSint16LE(_levelResNum[i]); -} +/*-------------------------------------------------------------------------- + * Scene 1850 - Rim Lift Interior + * + *--------------------------------------------------------------------------*/ -bool Scene1925::Button::startAction(CursorType action, Event &event) { +bool Scene1850::Button::startAction(CursorType action, Event &event) { if (action != CURSOR_USE) return SceneHotspot::startAction(action, event); - if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) - return SceneHotspot::startAction(action, event); + Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + scene->_sceneMode = 1852; + if (R2_GLOBALS.getFlag(32)) + scene->setAction(&scene->_sequenceManager1, scene, 1871, &R2_GLOBALS._player, NULL); + else + scene->setAction(&scene->_sequenceManager1, scene, 1852, &R2_GLOBALS._player, NULL); + } else if (R2_GLOBALS.getFlag(30)) { + scene->_seqNumber = 1; + scene->_sceneMode = 1860; - if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20)) - scene->_sceneMode = 1928; - else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200)) - scene->_sceneMode = 1929; - else - scene->_sceneMode = 1930; + if (R2_GLOBALS.getFlag(32)) + scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_robot, NULL); + else + scene->setAction(&scene->_sequenceManager1, scene, 1859, &R2_GLOBALS._player, &scene->_robot, NULL); + + R2_GLOBALS.clearFlag(30); + } else { + scene->_sceneMode = 1853; + + if (R2_GLOBALS.getFlag(32)) + scene->setAction(&scene->_sequenceManager1, scene, 1872, &R2_GLOBALS._player, NULL); + else + scene->setAction(&scene->_sequenceManager1, scene, 1853, &R2_GLOBALS._player, NULL); + } - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, - &scene->_door, NULL); return true; } -bool Scene1925::Ladder::startAction(CursorType action, Event &event) { - if ((!R2_GLOBALS.getFlag(29)) || (action != CURSOR_USE)) - return SceneHotspot::startAction(action, event); +bool Scene1850::Robot::startAction(CursorType action, Event &event) { + Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + switch (action) { + case CURSOR_USE: + if ((R2_GLOBALS._player._characterIndex != R2_SEEKER) || R2_GLOBALS.getFlag(33) || R2_GLOBALS.getFlag(30)) + return SceneActor::startAction(action, event); - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1857; - if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { - scene->_westExit._enabled = false; - scene->_sceneMode = 1925; - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, - &R2_GLOBALS._player, &scene->_door, NULL); + if (R2_GLOBALS.getFlag(32)) + scene->setAction(&scene->_sequenceManager1, scene, 1858, &R2_GLOBALS._player, &scene->_robot, NULL); + else + scene->setAction(&scene->_sequenceManager1, scene, 1857, &R2_GLOBALS._player, &scene->_robot, NULL); + + R2_GLOBALS.setFlag(30); return true; - } + break; + case CURSOR_LOOK: + if (R2_GLOBALS.getFlag(34)) + SceneItem::display(1850, 2, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + else + SceneItem::display(1850, 1, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20) && (event.mousePos.y >= 30)) { - scene->_sceneMode = 1931; - } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200) && (event.mousePos.y < 140)) { - scene->_sceneMode = 1932; - } else if ( ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) - || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110)) - ) && (event.mousePos.y >= 100)) { - scene->_sceneMode = 1926; - } else if ( ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) - || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110)) - ) && (event.mousePos.y < 60)) { - scene->_sceneMode = 1927; - } else { - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - } + return true; + break; + case R2_AIRBAG: + if (R2_GLOBALS._player._characterIndex == R2_SEEKER) { + if (R2_GLOBALS.getFlag(70)) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 30; - if (scene->_sceneMode != 0) - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + R2_GLOBALS._events.setCursor(CURSOR_WALK); + scene->_stripManager.start(558, scene); - return true; -} + return true; + } else { + return SceneActor::startAction(action, event); + } + } else if (R2_GLOBALS.getFlag(30)) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1875; + scene->_airbag.postInit(); -void Scene1925::ExitUp::changeScene() { - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + if (R2_GLOBALS.getFlag(32)) + scene->setAction(&scene->_sequenceManager1, scene, 1876, + &R2_GLOBALS._player, &scene->_airbag, NULL); + else + scene->setAction(&scene->_sequenceManager1, scene, 1875, + &R2_GLOBALS._player, &scene->_airbag, NULL); - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; + return true; + } else if (R2_GLOBALS.getFlag(70)) { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 20; + R2_GLOBALS._events.setCursor(CURSOR_WALK); + scene->_stripManager.start(557, scene); + R2_GLOBALS.setFlag(69); - if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { - scene->_westExit._enabled = false; - scene->_newSceneMode = 1927; - scene->_sceneMode = 1925; - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, - &R2_GLOBALS._player, &scene->_door, NULL); - return; + return true; + } else { + return SceneActor::startAction(action, event); + } + break; + case R2_REBREATHER_TANK: + if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { + if (R2_GLOBALS.getFlag(30)) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1878; + scene->setAction(&scene->_sequenceManager1, scene, 1878, &R2_GLOBALS._player, + &scene->_robot, &scene->_airbag, NULL); + } + + return true; + break; + default: + return SceneActor::startAction(action, event); + break; } +} - if ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) - || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))) { - scene->_sceneMode = 1927; - } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200)) { - scene->_sceneMode = 1932; +bool Scene1850::Door::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneHotspot::startAction(action, event); + + if (R2_GLOBALS.getFlag(32)) { + SceneItem::display(3240, 4, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + return true; } - if (scene->_sceneMode != 0) - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); - else { - scene->_sceneMode = 1932; - scene->signal(); + Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(); + if (scene->_sceneMode == 1851) + R2_GLOBALS._player._effect = EFFECT_SHADED; + + if (_position.x >= 160) + R2_GLOBALS.setFlag(29); + else + R2_GLOBALS.clearFlag(29); + + if ((R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) { + if (_position.x >= 160) + scene->_seqNumber = 3; + else + scene->_seqNumber = 2; + + scene->_sceneMode = 1860; + + if (R2_GLOBALS.getFlag(32)) { + scene->setAction(&scene->_sequenceManager1, scene, 1860, &R2_GLOBALS._player, &scene->_robot, NULL); + } else { + scene->setAction(&scene->_sequenceManager1, scene, 1859, &R2_GLOBALS._player, &scene->_robot, NULL); + } + } else { + scene->_sceneMode = 11; + if (_position.x >= 160) { + scene->setAction(&scene->_sequenceManager1, scene, 1866, &R2_GLOBALS._player, &scene->_rightDoor, NULL); + } else { + scene->setAction(&scene->_sequenceManager1, scene, 1865, &R2_GLOBALS._player, &scene->_leftDoor, NULL); + } } + + return true; } -void Scene1925::ExitDown::changeScene() { - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; +bool Scene1850::DisplayScreen::startAction(CursorType action, Event &event) { + if ((action != CURSOR_USE) || (_position.y != 120)) + return SceneHotspot::startAction(action, event); - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; + Scene1850 *scene = (Scene1850 *)R2_GLOBALS._sceneManager._scene; - if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { - scene->_westExit._enabled = false; - scene->_newSceneMode = 1926; - scene->_sceneMode = 1925; - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, - &R2_GLOBALS._player, &scene->_door, NULL); - return; - } + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1881; - if ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) - || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))) { - scene->_sceneMode = 1926; - } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20)) { - scene->_sceneMode = 1931; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + scene->setAction(&scene->_sequenceManager1, scene, 1881, &R2_GLOBALS._player, NULL); + } else { + scene->setAction(&scene->_sequenceManager1, scene, 1880, &R2_GLOBALS._player, NULL); } - if (scene->_sceneMode == 0) { - scene->_sceneMode = 1931; - scene->signal(); - } else - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + return true; } -void Scene1925::WestExit::changeScene() { - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; +/*------------------------------------------------------------------------*/ - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->_sceneMode = 1921; - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); +Scene1850::Scene1850() { + _sceneMode = 0; + _shadeCountdown = 0; + _shadeDirection = 0; + _shadeChanging = false; + _seqNumber = 0; } -void Scene1925::EastExit::changeScene() { - Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; +void Scene1850::synchronize(Serializer &s) { + SceneExt::synchronize(s); - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->_sceneMode = 1920; - scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + s.syncAsSint16LE(_sceneMode); + s.syncAsSint16LE(_shadeCountdown); + s.syncAsSint16LE(_shadeDirection); + s.syncAsSint16LE(_shadeChanging); + s.syncAsSint16LE(_seqNumber); + s.syncAsSint16LE(_playerDest.x); + s.syncAsSint16LE(_playerDest.y); } -void Scene1925::changeLevel(bool upFlag) { - if (R2_GLOBALS._scene1925CurrLevel < 0) - R2_GLOBALS._scene1925CurrLevel = 3; +void Scene1850::postInit(SceneObjectList *OwnerList) { + loadScene(1850); - if (upFlag) { - R2_GLOBALS._player.setup(1925, 1, 1); - R2_GLOBALS._player.setPosition(Common::Point(154, 200)); - ++R2_GLOBALS._scene1925CurrLevel; + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] != 1850) + R2_GLOBALS.clearFlag(31); + + _palette1.loadPalette(0); + + if (R2_GLOBALS.getFlag(31)) { + _sceneMode = 1850; + g_globals->_scenePalette.loadPalette(1850); } else { - R2_GLOBALS._player.setup(1925, 1, 1); - R2_GLOBALS._player.setPosition(Common::Point(154, 20)); - R2_GLOBALS._scene1925CurrLevel--; + _sceneMode = 1851; + g_globals->_scenePalette.loadPalette(1851); } - switch (R2_GLOBALS._scene1925CurrLevel) { - case -1: - R2_GLOBALS._sceneManager.changeScene(1945); - return; - break; - case 3: - loadScene(_levelResNum[4]); - _button.setDetails(Rect(133, 68, 140, 77), 1925, 3, -1, 5, 2, NULL); - _door.setDetails(1925, 0, 1, 2, 2, (SceneItem *) NULL); - _door.show(); - break; - case 512: - R2_GLOBALS._scene1925CurrLevel = 508; - // No break on purpose - default: - loadScene(_levelResNum[(R2_GLOBALS._scene1925CurrLevel % 4)]); - R2_GLOBALS._sceneItems.remove(&_button); - R2_GLOBALS._sceneItems.remove(&_door); - _door.hide(); - break; - } + SceneExt::postInit(); - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; -} + if (R2_GLOBALS._sceneManager._previousScene == 3150) + R2_GLOBALS._sound1.play(116); -void Scene1925::postInit(SceneObjectList *OwnerList) { - _levelResNum[0] = 1930; - _levelResNum[1] = 1935; - _levelResNum[2] = 1940; - _levelResNum[3] = 1935; - _levelResNum[4] = 1925; + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - if (R2_GLOBALS.getFlag(29)) { - if ((R2_GLOBALS._scene1925CurrLevel == -3) || (R2_GLOBALS._scene1925CurrLevel == 3)) - loadScene(_levelResNum[4]); - else - loadScene(_levelResNum[R2_GLOBALS._scene1925CurrLevel % 4]); - } else { - R2_GLOBALS._scene1925CurrLevel = -2; - loadScene(1920); - } - SceneExt::postInit(); - R2_GLOBALS._sound1.play(220); - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1925; - R2_GLOBALS._player._characterIndex = R2_SEEKER; + _shadeChanging = false; + _seqNumber = 0; + _playerDest = Common::Point(0, 0); - switch (R2_GLOBALS._scene1925CurrLevel) { - case -2: - _eastExit.setDetails(Rect(203, 44, 247, 111), EXITCURSOR_E, 1925); - _ladder.setDetails(Rect(31, 3, 45, 167), 1925, 6, -1, 8, 1, NULL); - break; - case 3: - _door.setDetails(1925, 0, 1, 2, 1, (SceneItem *) NULL); - _button.setDetails(Rect(133, 68, 140, 77), 1925, 3, -1, 5, 1, NULL); - // No break on purpose - case -3: - _westExit.setDetails(Rect(83, 38, 128, 101), EXITCURSOR_W, 1925); - // No break on purpose - default: - _exitUp.setDetails(Rect(128, 0, 186, 10), EXITCURSOR_N, 1925); - _exitDown.setDetails(Rect(128, 160, 190, 167), EXITCURSOR_S, 1925); - _ladder.setDetails(Rect(141, 11, 167, 159), 1925, 6, -1, -1, 1, NULL); - break; - } + R2_GLOBALS._player._characterScene[R2_QUINN] = 1850; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1850; - _door.postInit(); - _door.setup(1925, 5, 1); - _door.setPosition(Common::Point(128, 35)); - _door.hide(); + _button.setDetails(Rect(101, 56, 111, 63), 1850, 19, -1, -1, 1, NULL); - if (R2_GLOBALS._scene1925CurrLevel == 3) - _door.show(); + _leftDoor.postInit(); + _leftDoor.setup(1850, 3, 1); + _leftDoor.setPosition(Common::Point(66, 102)); + _leftDoor.setDetails(1850, 22, -1, -1, 1, (SceneItem *) NULL); - R2_GLOBALS._player.enableControl(CURSOR_USE); - switch (R2_GLOBALS._scene1925CurrLevel) { - case -2: - R2_GLOBALS._player.setup(20, 6, 1); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.setPosition(Common::Point(224, 109)); - break; - case -3: - _door.hide(); - R2_GLOBALS._player.setup(20, 5, 1); - R2_GLOBALS._player.setPosition(Common::Point(110, 100)); - break; - case 0: - R2_GLOBALS._player.setup(1925, 1, 1); - R2_GLOBALS._player.setPosition(Common::Point(154, 200)); - break; - default: - R2_GLOBALS._player.setup(1925, 1, 3); - R2_GLOBALS._player.setPosition(Common::Point(154, 110)); - break; + _rightDoor.postInit(); + _rightDoor.setup(1850, 2, 1); + _rightDoor.setPosition(Common::Point(253, 102)); + _rightDoor.setDetails(1850, 22, -1, -1, 1, (SceneItem *) NULL); + + R2_GLOBALS._walkRegions.disableRegion(1); + + _robot.postInit(); + + if (R2_GLOBALS.getFlag(34)) { + R2_GLOBALS._walkRegions.disableRegion(2); + _robot.setup(1851, 4, 3); + } else if (R2_GLOBALS.getFlag(30)) { + _robot.setup(1851, 2, 2); + } else { + R2_GLOBALS._walkRegions.disableRegion(5); + if (R2_GLOBALS.getFlag(33)) { + R2_GLOBALS._walkRegions.disableRegion(2); + _robot.setup(1851, 1, 3); + } else { + _robot.setup(1851, 2, 1); + } } - R2_GLOBALS._player._canWalk = false; - _newSceneMode = 0; - R2_GLOBALS._sceneManager._previousScene = 1925; - _background.setDetails(Rect(27, 0, 292, 200), 1925, 9, -1, -1, 1, NULL); -} + _robot.setPosition(Common::Point(219, 130)); + _robot.fixPriority(114); + _robot.setDetails(1850, -1, -1, -1, 1, (SceneItem *) NULL); -void Scene1925::remove() { - R2_GLOBALS._sound1.fadeOut2(NULL); - R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1925; - SceneExt::remove(); -} + R2_GLOBALS._player.postInit(); -void Scene1925::signal() { - switch (_sceneMode) { - case 1920: - // No break on purpose - case 1921: - // No break on purpose - case 1928: - // No break on purpose - case 1929: - // No break on purpose - case 1930: - R2_GLOBALS._scene1925CurrLevel = -3; - R2_GLOBALS._sceneManager.changeScene(1900); - break; - case 1926: - // No break on purpose - case 1931: - // Change level, down - changeLevel(false); - break; - case 1927: - // No break on purpose - case 1932: - // Change level, up - changeLevel(true); - break; - case 1925: - _westExit._enabled = false; - if (_newSceneMode != 0) { - _sceneMode = _newSceneMode; - _newSceneMode = 0; - setAction(&_sequenceManager, this, _sceneMode, &R2_GLOBALS._player, NULL); + _companion.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _companion.setDetails(9002, 0, 4, 3, 1, (SceneItem *) NULL); + } else { + _companion.setDetails(9001, 0, 5, 3, 1, (SceneItem *) NULL); + } + + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1850) { + R2_GLOBALS._player._effect = EFFECT_SHADED2; + _companion._effect = EFFECT_SHADED2; + if (R2_GLOBALS.getFlag(31)) { + R2_GLOBALS._player._shade = 0; + _companion._shade = 0; + } else { + R2_GLOBALS._player._shade = 6; + _companion._shade = 6; + } + + if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { + _airbag.postInit(); + if (R2_GLOBALS.getFlag(34)) { + _airbag.setup(1851, 4, 2); + _airbag.fixPriority(114); + } else { + _airbag.setup(1851, 4, 1); + } + + _airbag.setPosition(Common::Point(179, 113)); + + if ((_robot._strip == 1) && (_robot._frame == 3)){ + _airbag.hide(); + } + + _airbag.setDetails(1850, 6, -1, -1, 1, (SceneItem *) NULL); } - // No break on purpose - default: - R2_GLOBALS._player.enableControl(CURSOR_USE); - break; - } - R2_GLOBALS._player._canWalk = false; -} + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(32)) { + R2_GLOBALS._player.setVisage(1511); + _companion.setVisage(1508); -/*-------------------------------------------------------------------------- - * Scene 1945 - Spill Mountains Shaft Bottom - * - *--------------------------------------------------------------------------*/ + _screen.postInit(); + _screen.setup(1853, 3, 1); + _screen.setPosition(Common::Point(122, 113)); + _screen.fixPriority(114); + _screen._effect = EFFECT_SHADED2; + _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *) NULL); -Scene1945::Scene1945() { - _nextSceneMode1 = 0; - _nextSceneMode2 = 0; - _lampUsed = CURSOR_NONE; -} + _helmet.postInit(); + _helmet.setup(1853, 3, 2); + _helmet.setPosition(Common::Point(139, 111)); + _helmet.fixPriority(114); + _helmet._effect = EFFECT_SHADED2; + _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *) NULL); -void Scene1945::synchronize(Serializer &s) { - SceneExt::synchronize(s); + if (R2_GLOBALS.getFlag(31)) { + _screen._shade = 0; + _helmet._shade = 0; + } else { + _screen._shade = 6; + _helmet._shade = 6; + } + } else { + R2_GLOBALS._player.setVisage(1500); + _companion.setVisage(1505); + } + } else if (R2_GLOBALS.getFlag(32)) { + // Not Quinn, flag 32 + R2_GLOBALS._player.setVisage(1508); + _companion.setVisage(1511); - s.syncAsSint16LE(_nextSceneMode1); - s.syncAsSint16LE(_nextSceneMode2); - s.syncAsSint16LE(_lampUsed); -} + _screen.postInit(); + _screen.setup(1853, 3, 1); + _screen.setPosition(Common::Point(122, 113)); + _screen.fixPriority(114); + _screen._effect = EFFECT_SHADED2; + _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *) NULL); -bool Scene1945::Ice::startAction(CursorType action, Event &event) { - Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; + _helmet.postInit(); + _helmet.setup(1853, 3, 2); + _helmet.setPosition(Common::Point(139, 111)); + _helmet.fixPriority(114); + _helmet._effect = EFFECT_SHADED2; + _helmet.setDetails(1850, 28, -1, -1, 1, (SceneItem *) NULL); - switch (action) { - case R2_GUNPOWDER: - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 0; - if ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) - scene->_sceneMode = 1942; - else { - scene->_sceneMode = 1940; - scene->_nextSceneMode1 = 1942; - } - // At this point the original check if _sceneMode != 0. Skipped. - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_gunpowder, NULL); - return true; - break; - case CURSOR_USE: - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; - if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50) && (event.mousePos.x >= 130)) { - scene->_sceneMode = 1940; - // At this point the original check if _sceneMode != 0. Skipped. - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); - return true; + if (R2_GLOBALS.getFlag(31)) { + _screen._shade = 0; + _helmet._shade = 0; + } else { + _screen._shade = 6; + _helmet._shade = 6; + } } else { - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - if (event.mousePos.x > 130) - scene->_ice.setDetails(1945, 3, -1, -1, 3, (SceneItem *) NULL); - else - scene->_ice.setDetails(1945, 3, -1, 5, 3, (SceneItem *) NULL); + // Not Quinn, nor flag 32 + R2_GLOBALS._player.setVisage(1505); + _companion.setVisage(1500); } - // No break on purpose - default: - return SceneHotspot::startAction(action, event); - break; - } -} - -bool Scene1945::Ladder::startAction(CursorType action, Event &event) { - if (action != CURSOR_USE) - return SceneHotspot::startAction(action, event); - - Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setStrip(3); + R2_GLOBALS._player.setPosition(Common::Point(80, 114)); - if ((R2_GLOBALS._player._position.x == 221) && (R2_GLOBALS._player._position.y == 142)) { - scene->_sceneMode = 1949; - scene->_nextSceneMode1 = 1947; - } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) - || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { - scene->_sceneMode = 1947; - } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50) - && (event.mousePos.y >= 30)) { - scene->_sceneMode = 1940; - } else { - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - } + _companion.animate(ANIM_MODE_1, NULL); + _companion.setObjectWrapper(new SceneObjectWrapper()); + _companion.setStrip(3); + _companion.setPosition(Common::Point(180, 96)); - if (scene->_sceneMode != 0) - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + if (R2_GLOBALS.getFlag(30)) { + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _companion.animate(ANIM_MODE_NONE, NULL); + _companion.setObjectWrapper(NULL); + if (R2_GLOBALS.getFlag(32)) { + _companion.setup(1854, 1, 3); + } else { + _companion.setup(1854, 2, 3); + } - return true; -} + _companion.setPosition(Common::Point(164, 106)); + } else { + _companion.animate(ANIM_MODE_NONE, NULL); + _companion.setObjectWrapper(NULL); + if (R2_GLOBALS.getFlag(32)) { + R2_GLOBALS._player.setup(1854, 1, 3); + } else { + R2_GLOBALS._player.setup(1854, 2, 3); + } -bool Scene1945::Gunpowder::startAction(CursorType action, Event &event) { - if ((action == R2_ALCOHOL_LAMP_3) || (action == R2_ALCOHOL_LAMP_2)) { - Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.setPosition(Common::Point(164, 106)); + } + } - scene->_lampUsed = action; + R2_GLOBALS._player.enableControl(); + } else { // R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] != 1850 + R2_GLOBALS._player._effect = EFFECT_SHADED; + _companion._effect = EFFECT_SHADED; R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 0; - if ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) { - scene->_sceneMode= 1947; - scene->_nextSceneMode1 = 1943; - } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50)) { - scene->_sceneMode = 1940; - scene->_nextSceneMode1 = 1943; + _sceneMode = 10; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS.getFlag(29)) { + setAction(&_sequenceManager1, this, 1863, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + } else { + setAction(&_sequenceManager1, this, 1861, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); + } } else { - scene->_sceneMode = 1949; - scene->_nextSceneMode1 = 1947; - scene->_nextSceneMode2 = 1943; + if (R2_GLOBALS.getFlag(29)) { + setAction(&_sequenceManager1, this, 1864, &R2_GLOBALS._player, &_companion, &_rightDoor, NULL); + } else { + setAction(&_sequenceManager1, this, 1862, &R2_GLOBALS._player, &_companion, &_leftDoor, NULL); + } } - // At this point the original check if _sceneMode != 0. Skipped. - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); - return true; - } else { - return SceneActor::startAction(action, event); } -} - -void Scene1945::ExitUp::changeScene() { - Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; - if ((R2_GLOBALS._player._position.x == 221) && (R2_GLOBALS._player._position.y == 142)) { - scene->_sceneMode = 1949; - scene->_nextSceneMode1 = 1947; - } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) - || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { - scene->_sceneMode = 1947; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + _companion._moveDiff = Common::Point(5, 3); + } else { + R2_GLOBALS._player._moveDiff = Common::Point(5, 3); + _companion._moveDiff = Common::Point(3, 2); } - if (scene->_sceneMode == 0) { - scene->_sceneMode = 1941; - signal(); + _displayScreen.postInit(); + _displayScreen.setup(1850, 1, 1); + + if (R2_GLOBALS.getFlag(62)) { + _displayScreen.setPosition(Common::Point(159, 120)); } else { - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + _displayScreen.setPosition(Common::Point(159, 184)); } -} -void Scene1945::CorridorExit::changeScene() { - Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - - _moving = false; - R2_GLOBALS._player.disableControl(CURSOR_USE); - scene->_sceneMode = 0; + _displayScreen.fixPriority(113); - if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50)) { - scene->_sceneMode = 1940; - scene->_nextSceneMode1 = 1945; - } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) - || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { - scene->_sceneMode = 1945; + if (R2_GLOBALS.getFlag(34)) { + _displayScreen.setDetails(1850, 25, -1, -1, 4, &_robot); + } else { + _displayScreen.setDetails(1850, 25, -1, -1, 2, (SceneItem *) NULL); } - if (scene->_sceneMode != 0) - scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); -} + if (!R2_GLOBALS.getFlag(62)) { + _displayScreen.hide(); + } -void Scene1945::postInit(SceneObjectList *OwnerList) { - loadScene(1945); - SceneExt::postInit(); - R2_GLOBALS._sound1.play(220); + _background.setDetails(Rect(0, 0, 320, 200), 1850, 16, -1, -1, 1, NULL); - R2_GLOBALS._player.postInit(); - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; - R2_GLOBALS._player._characterScene[R2_SEEKER] = 1945; - R2_GLOBALS._player._characterIndex = R2_SEEKER; + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1850; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1850; +} - _exitUp.setDetails(Rect(128, 0, 186, 10), EXITCURSOR_N, 1945); - _corridorExit.setDetails(Rect(238, 144, 274, 167), EXITCURSOR_E, 1945); +void Scene1850::remove() { + g_globals->_scenePalette.loadPalette(0); - _ladder.setDetails(Rect(141, 3, 167, 126), 1945, 9, -1, -1, 1, NULL); + R2_GLOBALS._scenePalette._palette[765] = 255; + R2_GLOBALS._scenePalette._palette[766] = 255; + R2_GLOBALS._scenePalette._palette[767] = 255; - if (!R2_GLOBALS.getFlag(43)) { - _corridorExit._enabled = false; - _gunpowder.postInit(); - _gunpowder.setup(1945, 4, 1); - _gunpowder.setPosition(Common::Point(253, 169)); - _gunpowder.fixPriority(150); + SceneExt::remove(); +} - if (R2_GLOBALS.getFlag(42)) - _gunpowder.setDetails(1945, 15, -1, -1, 1, (SceneItem *) NULL); - else - _gunpowder.hide(); +void Scene1850::signal() { + switch (_sceneMode) { + case 10: + R2_GLOBALS._player._effect = EFFECT_SHADED2; + R2_GLOBALS._player._shade = 6; - _coveringIce.postInit(); - _coveringIce.setup(1945, 8, 1); - _coveringIce.setPosition(Common::Point(253, 169)); - _coveringIce.fixPriority(130); + _companion._effect = EFFECT_SHADED2; + _companion._shade = 6; - _alcoholLamp.postInit(); - _alcoholLamp.setup(1945, 3, 1); - _alcoholLamp.hide(); - } else { - _corridorExit._enabled = true; - } + R2_GLOBALS._walkRegions.disableRegion(5); - switch (R2_GLOBALS._sceneManager._previousScene) { - case 1925: - R2_GLOBALS._scene1925CurrLevel = 0; - R2_GLOBALS.clearFlag(29); - R2_GLOBALS._player.setup(1925, 1, 10); - R2_GLOBALS._player.setPosition(Common::Point(154, 50)); + if (R2_GLOBALS.getFlag(68)) { + R2_GLOBALS._player.enableControl(); + } else { + R2_GLOBALS.setFlag(68); + _sceneMode = 20; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(554, this); + } break; - case 1950: - _sceneMode = 1944; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); - R2_GLOBALS._player.disableControl(CURSOR_USE); + case 11: + R2_GLOBALS.clearFlag(30); + R2_GLOBALS._sceneManager.changeScene(1800); break; - default: - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._player.setup(20, 5, 1); - R2_GLOBALS._player.setPosition(Common::Point(191, 142)); + case 15: + _sceneMode = 16; break; - } + case 16: + _sceneMode = 1870; + setAction(&_sequenceManager1, this, 1870, &R2_GLOBALS._player, &_companion, + &_screen, &_helmet, NULL); + break; + case 20: + R2_GLOBALS._player.enableControl(CURSOR_TALK); + break; + case 21: + R2_GLOBALS._player.disableControl(); + _sceneMode = 1877; + setAction(&_sequenceManager1, this, 1877, &R2_GLOBALS._player, &_companion, + &_robot, NULL); + break; + case 30: + R2_GLOBALS._player.disableControl(); + _sceneMode = 1882; + setAction(&_sequenceManager1, this, 1882, &R2_GLOBALS._player, NULL); + break; + case 1852: + // No break on purpose: + case 1853: + if (_sceneMode == 1851) { // At this point, SceneMode can't be equal to 1851 => dead code + R2_GLOBALS.setFlag(31); + _palette1.loadPalette(1850); + _sceneMode = 1850; + } else { + R2_GLOBALS.clearFlag(31); + _palette1.loadPalette(1851); + _sceneMode = 1851; + } - R2_GLOBALS._player._canWalk = false; - _nextSceneMode1 = 0; - _nextSceneMode2 = 0; + _shadeChanging = true; + if (R2_GLOBALS.getFlag(30)) { + _displayScreen.setAction(&_sequenceManager2, NULL, 1867, &_displayScreen, NULL); + } else if (R2_GLOBALS.getFlag(34)) { + if (R2_GLOBALS.getFlag(62)) { + R2_GLOBALS.clearFlag(62); + _displayScreen.setAction(&_sequenceManager2, this, 1851, &_displayScreen, NULL); + } else { + R2_GLOBALS.setFlag(62); + _displayScreen.setAction(&_sequenceManager2, this, 1850, &_displayScreen, NULL); + } + } else if (R2_GLOBALS.getFlag(33)) { + R2_GLOBALS.setFlag(62); + R2_GLOBALS.setFlag(34); + R2_GLOBALS._walkRegions.disableRegion(2); - _ice.setDetails(11, 1945, 3, -1, 5); - _hole.setDetails(Rect(238, 144, 274, 167), 1945, 0, -1, 2, 1, NULL); - _ice2.setDetails(Rect(27, 3, 292, 167), 1945, 3, -1, -1, 1, NULL); -} + _airbag.postInit(); + _airbag.setDetails(1850, 6, -1, -1, 5, &_robot); -void Scene1945::remove() { - R2_GLOBALS._sound1.fadeOut2(NULL); - SceneExt::remove(); -} + _sceneMode = 1879; -void Scene1945::signal() { - switch (_sceneMode) { - case 1940: - if (_nextSceneMode1 == 1943) { - _sceneMode = _nextSceneMode1; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); + _displayScreen.setAction(&_sequenceManager2, this, 1879, &_robot, + &_displayScreen, &_airbag, NULL); } else { - _sceneMode = 1946; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); + _displayScreen.setAction(&_sequenceManager2, NULL, 1867, &_displayScreen, NULL); + } + + if (R2_GLOBALS.getFlag(34)) + R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, NULL); + else + R2_GLOBALS._scenePalette.addFader(_palette1._palette, 256, 5, this); + + if (_sceneMode == 1851) + _shadeDirection = -20; + else + _shadeDirection = 20; + + _shadeCountdown = 20; + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (_sceneMode == 1879) + _sceneMode = 1854; + + if (R2_GLOBALS.getFlag(32)) { + setAction(&_sequenceManager1, NULL, 1873, &R2_GLOBALS._player, NULL); + } else { + setAction(&_sequenceManager1, NULL, 1854, &R2_GLOBALS._player, NULL); + } + } else { + if (_sceneMode == 1879) + _sceneMode = 1855; + + if (R2_GLOBALS.getFlag(32)) { + setAction(&_sequenceManager1, NULL, 1874, &R2_GLOBALS._player, NULL); + } else { + setAction(&_sequenceManager1, NULL, 1855, &R2_GLOBALS._player, NULL); + } } - return; break; - case 1941: - if (_nextSceneMode1 == 0) { - R2_GLOBALS._scene1925CurrLevel = 0; - R2_GLOBALS.setFlag(29); - R2_GLOBALS._sceneManager.changeScene(1925); + case 1857: + if (R2_GLOBALS.getFlag(69)) { + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; } else { - _sceneMode = _nextSceneMode1; - _nextSceneMode1 = 0; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); + _sceneMode = 1858; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(555, this); + R2_GLOBALS.setFlag(69); } - return; - case 1942: - R2_INVENTORY.setObjectScene(R2_GUNPOWDER, 0); - _gunpowder.setDetails(1945, 15, -1, -1, 2, (SceneItem *) NULL); - R2_GLOBALS.setFlag(42); break; - case 1943: - R2_GLOBALS._sound1.fadeOut2(NULL); - R2_INVENTORY.setObjectScene(_lampUsed, 0); - _sceneMode = 1948; - setAction(&_sequenceManager1, this, _sceneMode, &_gunpowder, &_alcoholLamp, &_coveringIce, NULL); - R2_GLOBALS._player.setAction(&_sequenceManager2, NULL, 1941, &R2_GLOBALS._player, NULL); - return; - case 1944: + case 1858: + R2_GLOBALS._player.disableControl(); + _sceneMode = 1859; + setAction(&_sequenceManager1, this, 1859, &R2_GLOBALS._player, &_robot, NULL); + R2_GLOBALS.clearFlag(30); + break; + case 1859: + R2_GLOBALS.setFlag(70); + _sceneMode = 20; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(575, this); + break; + case 1860: + if (_playerDest.x != 0) { + R2_GLOBALS._player.enableControl(); + + PlayerMover *mover = new PlayerMover(); + R2_GLOBALS._player.addMover(mover, &_playerDest, this); + + _playerDest = Common::Point(0, 0); + } + + switch (_seqNumber) { + case 1: + _sceneMode = 1853; + if (R2_GLOBALS.getFlag(32)) { + setAction(&_sequenceManager1, this, 1872, &R2_GLOBALS._player, NULL); + } else { + setAction(&_sequenceManager1, this, 1853, &R2_GLOBALS._player, NULL); + } + break; + case 2: + _sceneMode = 11; + setAction(&_sequenceManager1, this, 1865, &R2_GLOBALS._player, &_leftDoor, NULL); + break; + case 3: + _sceneMode = 11; + setAction(&_sequenceManager1, this, 1866, &R2_GLOBALS._player, &_rightDoor, NULL); + break; + default: + break; + } + + _seqNumber = 0; + break; + case 1870: + R2_GLOBALS._walkRegions.disableRegion(5); + R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 1); + R2_GLOBALS.setFlag(32); + R2_GLOBALS._player.enableControl(CURSOR_WALK); break; - case 1945: - R2_GLOBALS._sceneManager.changeScene(1950); - return; - case 1946: - if (_nextSceneMode1 == 1942) { - _sceneMode = _nextSceneMode1; - _nextSceneMode1 = 0; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_gunpowder, NULL); - return; - } - _sceneMode = 0; + case 1875: + R2_INVENTORY.setObjectScene(R2_AIRBAG, 1850); + _sceneMode = 21; + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _stripManager.start(561, this); break; - case 1947: - if (_nextSceneMode1 == 1943) { - _sceneMode = _nextSceneMode1; - _nextSceneMode1 = 1948; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); + case 1877: + _screen.postInit(); + _screen._effect = EFFECT_SHADED2; + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _screen.setDetails(1850, 28, -1, -1, 2, (SceneItem *)NULL); } else { - _sceneMode = 1941; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); + _screen.setDetails(1850, 30, -1, -1, 2, (SceneItem *)NULL); } - return; - case 1948: - R2_GLOBALS._sound1.play(220); - _corridorExit._enabled = true; - R2_GLOBALS._sceneItems.remove(&_gunpowder); - R2_GLOBALS.clearFlag(42); - R2_GLOBALS.setFlag(43); - _nextSceneMode1 = 1940; - // No break on purpose - case 1949: - _sceneMode = _nextSceneMode1; - if (_nextSceneMode2 == 1943) { - _nextSceneMode1 = _nextSceneMode2; - _nextSceneMode2 = 0; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); + + _helmet.postInit(); + _helmet._effect = EFFECT_SHADED2; + + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _helmet.setDetails(1850, 29, -1, -1, 2, (SceneItem *)NULL); } else { - _nextSceneMode1 = 0; - setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); + _helmet.setDetails(1850, 28, -1, -1, 2, (SceneItem *)NULL); } - return; + + if (R2_GLOBALS.getFlag(31)) { + _screen._shade = 0; + _helmet._shade = 0; + } else { + _screen._shade = 6; + _helmet._shade = 6; + } + + R2_GLOBALS.clearFlag(30); + _sceneMode = 15; + setAction(&_sequenceManager1, this, 1869, &R2_GLOBALS._player, &_screen, NULL); + _companion.setAction(&_sequenceManager2, this, 1868, &_companion, &_helmet, NULL); + break; + case 1878: + R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 1850); + R2_GLOBALS.setFlag(33); + R2_GLOBALS._walkRegions.disableRegion(2); + R2_GLOBALS._player.enableControl(); + break; + case 1879: + R2_GLOBALS._player.enableControl(); + break; + case 1881: + R2_GLOBALS._sceneManager.changeScene(1875); + break; + case 1882: + R2_INVENTORY.setObjectScene(R2_AIRBAG, 1); + R2_GLOBALS._player.enableControl(); + break; default: + R2_GLOBALS._player.enableControl(); break; } - - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; -} - -/*-------------------------------------------------------------------------- - * Scene 1950 - Flup Tube Corridor Maze - * - *--------------------------------------------------------------------------*/ - -Scene1950::KeypadWindow::KeypadWindow() { - _buttonIndex = 0; } -void Scene1950::KeypadWindow::synchronize(Serializer &s) { - SceneArea::synchronize(s); - - s.syncAsSint16LE(_buttonIndex); -} +void Scene1850::process(Event &event) { + if ( (event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_WALK) + && (R2_GLOBALS._player._characterIndex == R2_SEEKER) && (R2_GLOBALS.getFlag(30))) { + _playerDest = event.mousePos; + R2_GLOBALS._player.disableControl(); + _sceneMode = 1860; + if (R2_GLOBALS.getFlag(32)) { + setAction(&_sequenceManager1, this, 1860, &R2_GLOBALS._player, &_robot, NULL); + } else { + setAction(&_sequenceManager1, this, 1859, &R2_GLOBALS._player, &_robot, NULL); + } + R2_GLOBALS.clearFlag(30); + event.handled = true; + } -Scene1950::KeypadWindow::KeypadButton::KeypadButton() { - _buttonIndex = 0; - _pressed = false; - _toggled = false; + Scene::process(event); } -void Scene1950::KeypadWindow::KeypadButton::synchronize(Serializer &s) { - SceneActor::synchronize(s); +void Scene1850::dispatch() { + if (_shadeChanging) { + _shadeCountdown--; + if (_shadeCountdown == 0) + _shadeChanging = false; - s.syncAsSint16LE(_buttonIndex); - s.syncAsSint16LE(_pressed); - s.syncAsSint16LE(_toggled); -} + if (_shadeDirection >= 0) { + R2_GLOBALS._player._shade = (_shadeCountdown * 6) / _shadeDirection; + } else { + R2_GLOBALS._player._shade = ((_shadeCountdown * 6) / _shadeDirection) + 6; + } + R2_GLOBALS._player._flags |= OBJFLAG_PANES; -void Scene1950::KeypadWindow::KeypadButton::init(int indx) { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + _companion._shade = R2_GLOBALS._player._shade; + _companion._flags |= OBJFLAG_PANES; - _buttonIndex = indx; - _pressed = false; - _toggled = false; + _screen._shade = R2_GLOBALS._player._shade; + _screen._flags |= OBJFLAG_PANES; - postInit(); - setup(1971, 2, 1); - fixPriority(249); - setPosition(Common::Point(((_buttonIndex % 4) * 22) + 127, ((_buttonIndex / 4) * 19) + 71)); - scene->_sceneAreas.push_front(this); -} + _helmet._shade = R2_GLOBALS._player._shade; + _helmet._flags |= OBJFLAG_PANES; + } -void Scene1950::KeypadWindow::KeypadButton::process(Event &event) { - if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) - && (_bounds.contains(event.mousePos)) && !_pressed) { - R2_GLOBALS._sound2.play(227); - if (!_toggled) { - setFrame(2); - _toggled = true; - } else { - setFrame(1); - _toggled = false; - } - _pressed = true; - event.handled = true; + if (R2_GLOBALS.getFlag(32)) { + _screen.setPosition(Common::Point(_displayScreen._position.x - 37, _displayScreen._position.y - 71)); + _helmet.setPosition(Common::Point(_displayScreen._position.x - 20, _displayScreen._position.y - 73)); } - if ((event.eventType == EVENT_BUTTON_UP) && _pressed) { - _pressed = false; - event.handled = true; - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - scene->doButtonPress(_buttonIndex); + if (R2_INVENTORY.getObjectScene(R2_AIRBAG) == 1850) { + _airbag.setPosition(Common::Point(_displayScreen._position.x + 20, _displayScreen._position.y - 71)); } + + Scene::dispatch(); } -bool Scene1950::KeypadWindow::KeypadButton::startAction(CursorType action, Event &event) { - if (action == CURSOR_USE) - return false; - return SceneActor::startAction(action, event); +/*-------------------------------------------------------------------------- + * Scene 1875 - Rim Lift Computer + * + *--------------------------------------------------------------------------*/ + +Scene1875::Button::Button() { + _buttonId = 0; + _buttonDown = false; } -void Scene1950::KeypadWindow::remove() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - for (_buttonIndex = 0; _buttonIndex < 16; ++_buttonIndex) { - scene->_sceneAreas.remove(&_buttons[_buttonIndex]); - _buttons[_buttonIndex].remove(); - } +void Scene1875::Button::synchronize(Serializer &s) { + SceneActor::synchronize(s); - ModalWindow::remove(); + s.syncAsSint16LE(_buttonId); + s.syncAsSint16LE(_buttonDown); +} - if (!R2_GLOBALS.getFlag(37)) - R2_GLOBALS._sound2.play(278); +void Scene1875::Button::doButtonPress() { + Scene1875 *scene = (Scene1875 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - scene->_eastExit._enabled = true; + R2_GLOBALS._sound1.play(227); - if (!R2_GLOBALS.getFlag(37)) { - if (R2_GLOBALS.getFlag(36)) { - scene->_sceneMode = 1964; - scene->setAction(&scene->_sequenceManager, scene, 1964, &R2_GLOBALS._player, NULL); + int newFrameNumber; + switch (_buttonId) { + case 3: + if ((scene->_map._frame == 1) && (scene->_button1._strip == 2)) { + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + scene->_sceneMode = 10; + scene->_stripManager.start(576, scene); } else { - scene->_sceneMode = 1965; - scene->setAction(&scene->_sequenceManager, scene, 1965, &R2_GLOBALS._player, NULL); + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1890; + scene->_rimPosition.postInit(); + scene->setAction(&scene->_sequenceManager, scene, 1890, &scene->_rimPosition, NULL); } + break; + case 4: + newFrameNumber = scene->_map._frame + 1; + if (newFrameNumber > 6) + newFrameNumber = 1; + scene->_map.setFrame(newFrameNumber); + break; + case 5: + newFrameNumber = scene->_map._frame - 1; + if (newFrameNumber < 1) + newFrameNumber = 6; + scene->_map.setFrame(newFrameNumber); + break; + default: + break; } } -void Scene1950::KeypadWindow::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY) { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - - if (R2_GLOBALS._player._mover) - R2_GLOBALS._player.addMover(NULL); - R2_GLOBALS._player._canWalk = false; - - ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY); - - _object1.fixPriority(248); - scene->_eastExit._enabled = false; - setup3(1950, 27, 28, 27); - - for (_buttonIndex = 0; _buttonIndex < 16; _buttonIndex++) - _buttons[_buttonIndex].init(_buttonIndex); -} - -void Scene1950::KeypadWindow::setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum) { - // Copy of Scene1200::LaserPanel::proc13() - _areaActor.setDetails(resNum, lookLineNum, talkLineNum, useLineNum, 2, (SceneItem *) NULL); -} - -/*--------------------------------------------------------------------------*/ - -bool Scene1950::Keypad::startAction(CursorType action, Event &event) { - if ((action != CURSOR_USE) || (R2_GLOBALS.getFlag(37))) - return SceneHotspot::startAction(action, event); +void Scene1875::Button::initButton(int buttonId) { + postInit(); + _buttonId = buttonId; + _buttonDown = false; + setVisage(1855); - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + if (_buttonId == 1) + setStrip(2); + else + setStrip(1); - R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS.getFlag(36)) { - scene->_sceneMode = 1962; - scene->setAction(&scene->_sequenceManager, scene, 1962, &R2_GLOBALS._player, NULL); - } else { - scene->_sceneMode = 1963; - scene->setAction(&scene->_sequenceManager, scene, 1963, &R2_GLOBALS._player, NULL); + setFrame(_buttonId); + switch (_buttonId) { + case 1: + setPosition(Common::Point(20, 144)); + break; + case 2: + setPosition(Common::Point(82, 144)); + break; + case 3: + setPosition(Common::Point(136, 144)); + break; + case 4: + setPosition(Common::Point(237, 144)); + break; + case 5: + setPosition(Common::Point(299, 144)); + break; + default: + break; } - return true; -} - -bool Scene1950::Door::startAction(CursorType action, Event &event) { - if (action != R2_SCRITH_KEY) - return SceneActor::startAction(action, event); - - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - - R2_GLOBALS._player.disableControl(); - R2_INVENTORY.setObjectScene(R2_SCRITH_KEY, 0); - scene->_sceneMode = 1958; - scene->setAction(&scene->_sequenceManager, scene, 1958, &R2_GLOBALS._player, &scene->_door, NULL); - return true; -} - -bool Scene1950::Scrolls::startAction(CursorType action, Event &event) { - if ((action != CURSOR_USE) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) != 1950)) - return SceneActor::startAction(action, event); - - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1968; - scene->setAction(&scene->_sequenceManager, scene, 1968, &R2_GLOBALS._player, NULL); - - return true; + setDetails(1875, 6, 1, -1, 2, (SceneItem *) NULL); } -bool Scene1950::Gem::startAction(CursorType action, Event &event) { - if ((action != CURSOR_USE) || (!R2_GLOBALS.getFlag(37))) - return SceneActor::startAction(action, event); +void Scene1875::Button::process(Event &event) { + if (!R2_GLOBALS._player._uiEnabled || event.handled) + return; - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + Scene1875 *scene = (Scene1875 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - scene->_sceneMode = 1967; - scene->setAction(&scene->_sequenceManager, scene, 1967, &R2_GLOBALS._player, NULL); + if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) + && (_bounds.contains(event.mousePos)) && !_buttonDown) { + setStrip(2); + switch (_buttonId) { + case 1: + R2_GLOBALS._sound2.play(227); + scene->_button2.setStrip(1); + break; + case 2: + R2_GLOBALS._sound2.play(227); + scene->_button1.setStrip(1); + break; + default: + break; + } + _buttonDown = true; + event.handled = true; + } - return true; + if ((event.eventType == EVENT_BUTTON_UP) && _buttonDown) { + if ((_buttonId == 3) || (_buttonId == 4) || (_buttonId == 5)) { + setStrip(1); + doButtonPress(); + } + _buttonDown = false; + event.handled = true; + } } -/*--------------------------------------------------------------------------*/ +void Scene1875::postInit(SceneObjectList *OwnerList) { + loadScene(1875); + SceneExt::postInit(); -Scene1950::Vampire::Vampire() { - _deadPosition = Common::Point(0, 0); - _deltaX = 0; - _deltaY = 0; - _vampireMode = 0; -} + R2_GLOBALS._player._characterScene[R2_QUINN] = 1875; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1875; -void Scene1950::Vampire::synchronize(Serializer &s) { - SceneActor::synchronize(s); + _stripManager.addSpeaker(&_quinnSpeaker); + _stripManager.addSpeaker(&_seekerSpeaker); - s.syncAsSint16LE(_deadPosition.x); - s.syncAsSint16LE(_deadPosition.y); - s.syncAsSint16LE(_deltaX); - s.syncAsSint16LE(_deltaY); - s.syncAsSint16LE(_vampireMode); -} + _button1.initButton(1); + _button2.initButton(2); + _button3.initButton(3); + _button4.initButton(4); + _button5.initButton(5); -void Scene1950::Vampire::signal() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + _map.postInit(); + _map.setup(1855, 4, 1); + _map.setPosition(Common::Point(160, 116)); - switch (_vampireMode) { - case 19: { - _vampireMode = 0; - setVisage(1960); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - setStrip(2); - else - setStrip(1); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.hide(); - NpcMover *mover = new NpcMover(); - addMover(mover, &scene->_vampireDestPos, scene); + if (R2_GLOBALS._sceneManager._previousScene == 1625) { + R2_GLOBALS._sound1.play(122); + R2_GLOBALS._player.disableControl(); + _sceneMode = 11; + _rimPosition.postInit(); + setAction(&_sequenceManager, this, 1892, &_rimPosition, NULL); + } else { + if (R2_GLOBALS._sceneManager._previousScene == 3150) { + R2_GLOBALS._sound1.play(116); } - break; - case 20: { - // Non fatal shot - _vampireMode = 19; - R2_GLOBALS._player.setVisage(22); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - R2_GLOBALS._player.setStrip(1); - else - R2_GLOBALS._player.setStrip(2); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--; - - if (R2_GLOBALS._flubMazeEntryDirection == 3) - _deadPosition.x = _position.x + 10; - else - _deadPosition.x = _position.x - 10; - _deadPosition.y = _position.y - 4; - - setVisage(1961); - - if (R2_GLOBALS._flubMazeEntryDirection == 3) - setStrip(2); - else - setStrip(1); - - animate(ANIM_MODE_2, NULL); - Common::Point pt = _deadPosition; - PlayerMover *mover = new PlayerMover(); - addMover(mover, &pt, this); R2_GLOBALS._player.enableControl(); - } - break; - case 21: { - // Fatal shot - R2_GLOBALS._player.setVisage(22); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - R2_GLOBALS._player.setStrip(1); - else - R2_GLOBALS._player.setStrip(2); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player._canWalk = false; + } - setVisage(1961); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - setStrip(4); - else - setStrip(3); - setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL); - addMover(NULL); - _numFrames = 8; - R2_GLOBALS._sound2.play(226); - animate(ANIM_MODE_5, NULL); - fixPriority(10); - - R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive = false; - R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--; - R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._position = _position; - _deltaX = (_position.x - R2_GLOBALS._player._position.x) / 2; - _deltaY = (_position.y - R2_GLOBALS._player._position.y) / 2; - - byte vampireCount = 0; - for (byte i = 0; i < 18; ++i) { - if (!R2_GLOBALS._vampireData[i]._isAlive) - ++vampireCount; - } - - if (vampireCount == 18) { - R2_GLOBALS.setFlag(36); - _vampireMode = 23; - Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else if (vampireCount == 1) { - _vampireMode = 22; - Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } else { - R2_GLOBALS._player.enableControl(CURSOR_WALK); - } + _screen.setDetails(Rect(43, 14, 275, 122), 1875, 9, 1, -1, 1, NULL); + _background.setDetails(Rect(0, 0, 320, 200), 1875, 3, -1, -1, 1, NULL); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - scene->_eastExit._enabled = true; - else - scene->_westExit._enabled = true; + R2_GLOBALS._player._characterScene[R2_QUINN] = 1875; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1875; + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1875; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1875; +} - scene->_vampireActive = false; - } +void Scene1875::signal() { + switch (_sceneMode) { + case 10: + R2_GLOBALS._player.disableControl(); + _sceneMode = 1891; + _rimPosition.postInit(); + setAction(&_sequenceManager, this, 1891, &_rimPosition, NULL); break; - case 22: - SceneItem::display(1950, 18, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - R2_GLOBALS._player.enableControl(CURSOR_WALK); + case 11: + R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS); + _sceneMode = 1892; + _stripManager.start(577, this); break; - case 23: - SceneItem::display(1950, 25, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - scene->_sceneMode = R2_GLOBALS._flubMazeEntryDirection; - scene->setAction(&scene->_sequenceManager, scene, 1960, &R2_GLOBALS._player, NULL); + case 1890: + _rimPosition.remove(); + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + break; + case 1891: + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._sceneManager.changeScene(1625); + break; + case 1892: + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._sceneManager.changeScene(1900); break; default: + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; break; } } -bool Scene1950::Vampire::startAction(CursorType action, Event &event) { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - - if (!R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive || - (action != R2_PHOTON_STUNNER)) - return SceneActor::startAction(action, event); +void Scene1875::process(Event &event) { + Scene::process(event); - R2_GLOBALS._player.disableControl(); + _button1.process(event); + _button2.process(event); + _button3.process(event); + _button4.process(event); + _button5.process(event); +} - if (R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired <= 1) - _vampireMode = 21; - else - _vampireMode = 20; +/*-------------------------------------------------------------------------- + * Scene 1900 - Spill Mountains Elevator Exit + * + *--------------------------------------------------------------------------*/ - R2_GLOBALS._player.setVisage(25); - if (R2_GLOBALS._flubMazeEntryDirection == 3) - R2_GLOBALS._player.setStrip(2); - else - R2_GLOBALS._player.setStrip(1); - R2_GLOBALS._player.animate(ANIM_MODE_5, this); - R2_GLOBALS._sound3.play(99); +bool Scene1900::LiftDoor::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneActor::startAction(action, event); - return true; -} + if ((_frame != 1) || (R2_GLOBALS._player._characterIndex != R2_SEEKER)) { + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + return SceneActor::startAction(action, event); + else + return true; + } -/*--------------------------------------------------------------------------*/ + Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; -void Scene1950::NorthExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.enableControl(CURSOR_USE); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 1; - scene->_sceneMode = 11; + if (_position.x >= 160) { + scene->_sceneMode = 1905; + scene->setAction(&scene->_sequenceManager1, scene, 1905, &R2_GLOBALS._player, &scene->_rightDoor, NULL); + } else { + R2_GLOBALS.setFlag(29); + scene->_sceneMode = 1904; + scene->setAction(&scene->_sequenceManager1, scene, 1904, &R2_GLOBALS._player, &scene->_leftDoor, NULL); + } - Common::Point pt(160, 127); - PlayerMover *mover = new PlayerMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); + return true; } -void Scene1950::UpExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; +void Scene1900::WestExit::changeScene() { + Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; - _enabled = false; R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 2; - scene->_sceneMode = 12; + scene->_sceneMode = 10; - if (!scene->_upExitStyle) { - if (R2_GLOBALS.getFlag(36)) - scene->setAction(&scene->_sequenceManager, scene, 1953, &R2_GLOBALS._player, NULL); - else - scene->setAction(&scene->_sequenceManager, scene, 1970, &R2_GLOBALS._player, NULL); - } else { - if (R2_GLOBALS.getFlag(36)) - scene->setAction(&scene->_sequenceManager, scene, 1952, &R2_GLOBALS._player, NULL); - else - scene->setAction(&scene->_sequenceManager, scene, 1969, &R2_GLOBALS._player, NULL); - } + Common::Point pt(-10, 135); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); } -void Scene1950::EastExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; +void Scene1900::EastExit::changeScene() { + Scene1900 *scene = (Scene1900 *)R2_GLOBALS._sceneManager._scene; - _enabled = false; R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 3; - scene->_sceneMode = 13; - - if (scene->_vampireActive) - R2_GLOBALS._player.animate(ANIM_MODE_9); + scene->_sceneMode = 11; - Common::Point pt(340, 160); + Common::Point pt(330, 135); NpcMover *mover = new NpcMover(); R2_GLOBALS._player.addMover(mover, &pt, scene); } -void Scene1950::DownExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; +void Scene1900::postInit(SceneObjectList *OwnerList) { + loadScene(1900); + SceneExt::postInit(); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 4; - scene->_sceneMode = 14; + // Debug message, skipped - if (R2_GLOBALS.getFlag(36)) - scene->setAction(&scene->_sequenceManager, scene, 1956, &R2_GLOBALS._player, NULL); - else - scene->setAction(&scene->_sequenceManager, scene, 1973, &R2_GLOBALS._player, NULL); -} + if (R2_GLOBALS._sceneManager._previousScene == -1) { + R2_GLOBALS._sceneManager._previousScene = 1925; + R2_GLOBALS._player._characterIndex = R2_SEEKER; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1925; + } -void Scene1950::SouthExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + if (R2_GLOBALS._sceneManager._previousScene != 1875) + R2_GLOBALS._sound1.play(200); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 5; - scene->_sceneMode = 15; + _stripManager.setColors(60, 255); + _stripManager.setFontNumber(3); + _stripManager.addSpeaker(&_seekerSpeaker); - Common::Point pt(160, 213); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); -} + _westExit.setDetails(Rect(0, 105, 14, 145), EXITCURSOR_W, 2000); + _westExit.setDest(Common::Point(14, 135)); -void Scene1950::WestExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + _eastExit.setDetails(Rect(305, 105, 320, 145), EXITCURSOR_E, 2000); + _eastExit.setDest(Common::Point(315, 135)); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 6; + R2_GLOBALS._player.postInit(); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + R2_GLOBALS._player.setup(2008, 3, 1); + else + R2_GLOBALS._player.setup(20, 3, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + R2_GLOBALS._player._moveDiff = Common::Point(3, 2); + else + R2_GLOBALS._player._moveDiff = Common::Point(5, 3); + R2_GLOBALS._player.disableControl(); - if (R2_GLOBALS._flubMazeArea == 2) { - // In the very first corridor area after the Scrith Door - if ((R2_GLOBALS.getFlag(36)) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 2) && (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)) { - scene->_sceneMode = 1961; - Common::Point pt(-20, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - } else { - if (!R2_GLOBALS.getFlag(36)) - SceneItem::display(1950, 33, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - if ((R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 1950)) - SceneItem::display(1950, 34, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - scene->_sceneMode = 0; - Common::Point pt(30, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - } - } else { - if (scene->_vampireActive) - R2_GLOBALS._player.animate(ANIM_MODE_9); + if (R2_GLOBALS._sceneManager._previousScene != 1925) + R2_GLOBALS.clearFlag(29); - scene->_sceneMode = 16; - Common::Point pt(-20, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - } -} + _leftDoor.postInit(); + _leftDoor.setup(1901, 1, 1); + _leftDoor.setPosition(Common::Point(95, 109)); + _leftDoor.fixPriority(100); -void Scene1950::ShaftExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _leftDoor.setDetails(1900, 0, 1, 2, 1, (SceneItem *) NULL); + else + _leftDoor.setDetails(1900, 0, 1, -1, 1, (SceneItem *) NULL); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 0; - scene->_sceneMode = 1951; - scene->setAction(&scene->_sequenceManager, scene, 1951, &R2_GLOBALS._player, NULL); -} + _rightDoor.postInit(); + _rightDoor.setup(1901, 2, 1); + _rightDoor.setPosition(Common::Point(225, 109)); + _rightDoor.fixPriority(100); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) + _rightDoor.setDetails(1900, 0, 1, 2, 1, (SceneItem *) NULL); + else + _rightDoor.setDetails(1900, 0, 1, -1, 1, (SceneItem *) NULL); -void Scene1950::DoorExit::changeScene() { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + if (R2_GLOBALS._sceneManager._previousScene != 1875) { + _leftDoorFrame.postInit(); + _leftDoorFrame.setup(1945, 6, 1); + _leftDoorFrame.setPosition(Common::Point(96, 109)); + _leftDoorFrame.fixPriority(80); - _enabled = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._flubMazeEntryDirection = 3; - if (R2_GLOBALS._player._visage == 22) { - scene->_sceneMode = 1975; - scene->setAction(&scene->_sequenceManager, scene, 1975, &R2_GLOBALS._player, NULL); - } else { - SceneItem::display(1950, 22, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - R2_GLOBALS._flubMazeEntryDirection = 0; - scene->_sceneMode = 0; - Common::Point pt(250, 150); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, scene); - _enabled = true; + _rightDoorFrame.postInit(); + _rightDoorFrame.setup(1945, 6, 2); + _rightDoorFrame.setPosition(Common::Point(223, 109)); + _rightDoorFrame.fixPriority(80); } -} -/*--------------------------------------------------------------------------*/ + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1875) { + R2_GLOBALS._player._characterIndex = R2_QUINN; + _companion.postInit(); + _sceneMode = 20; + R2_GLOBALS._player.setAction(&_sequenceManager1, NULL, 1901, &R2_GLOBALS._player, &_leftDoor, NULL); + _companion.setAction(&_sequenceManager2, this, 1900, &_companion, &_rightDoor, NULL); + } else if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 1925) { + if (R2_GLOBALS.getFlag(29)) { + R2_GLOBALS.clearFlag(29); + _leftDoor.hide(); -Scene1950::Scene1950() { - _upExitStyle = false; - _removeFlag = false; - _vampireActive = false; - _vampireDestPos = Common::Point(0, 0); - _vampireIndex = 0; -} + R2_GLOBALS._player.setStrip(6); + R2_GLOBALS._player.setPosition(Common::Point(90, 106)); + _sceneMode = 1906; + setAction(&_sequenceManager1, this, 1906, &R2_GLOBALS._player, &_leftDoor, NULL); + } else { + _rightDoor.hide(); + R2_GLOBALS._player.setStrip(5); + R2_GLOBALS._player.setPosition(Common::Point(230, 106)); + _sceneMode = 1907; + setAction(&_sequenceManager1, this, 1907, &R2_GLOBALS._player, &_rightDoor, NULL); + } -void Scene1950::synchronize(Serializer &s) { - SceneExt::synchronize(s); + if (R2_GLOBALS._player._characterScene[R2_QUINN] == R2_GLOBALS._player._characterScene[R2_SEEKER]) { + _companion.postInit(); + _companion.setPosition(Common::Point(30, 110)); + R2_GLOBALS._walkRegions.disableRegion(1); + _companion.setup(2008, 3, 1); + _companion.setDetails(9001, 0, -1, -1, 1, (SceneItem *) NULL); + } + R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1900; + } else { + if (R2_GLOBALS._player._characterScene[R2_QUINN] == R2_GLOBALS._player._characterScene[R2_SEEKER]) { + _companion.postInit(); + _companion.setPosition(Common::Point(30, 110)); + R2_GLOBALS._walkRegions.disableRegion(1); + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + _companion.setup(20, 3, 1); + _companion.setDetails(9002, 1, -1, -1, 1, (SceneItem *) NULL); + } else { + _companion.setup(2008, 3, 1); + _companion.setDetails(9001, 0, -1, -1, 1, (SceneItem *) NULL); + } + } - s.syncAsSint16LE(_upExitStyle); - s.syncAsSint16LE(_removeFlag); - s.syncAsSint16LE(_vampireActive); - s.syncAsSint16LE(_vampireDestPos.x); - s.syncAsSint16LE(_vampireDestPos.y); - s.syncAsSint16LE(_vampireIndex); -} - -void Scene1950::initArea() { - _northExit._enabled = false; - _upExit._enabled = false; - _eastExit._enabled = false; - _downExit._enabled = false; - _southExit._enabled = false; - _westExit._enabled = false; - _shaftExit._enabled = false; - _doorExit._enabled = false; - _northExit._insideArea = false; - _upExit._insideArea = false; - _eastExit._insideArea = false; - _downExit._insideArea = false; - _southExit._insideArea = false; - _westExit._insideArea = false; - _shaftExit._insideArea = false; - _doorExit._insideArea = false; - _northExit._moving = false; - _upExit._moving = false; - _eastExit._moving = false; - _downExit._moving = false; - _southExit._moving = false; - _westExit._moving = false; - _shaftExit._moving = false; - _doorExit._moving = false; - _upExitStyle = false; - - switch (R2_GLOBALS._flubMazeArea - 1) { - case 0: - loadScene(1948); - break; - case 1: - // No break on purpose - case 8: - // No break on purpose - case 10: - // No break on purpose - case 12: - // No break on purpose - case 16: - // No break on purpose - case 19: - // No break on purpose - case 23: - // No break on purpose - case 30: - // No break on purpose - case 44: - // No break on purpose - case 72: - // No break on purpose - case 74: - // No break on purpose - case 86: - // No break on purpose - case 96: - // No break on purpose - case 103: - loadScene(1950); - break; - case 2: - // No break on purpose - case 29: - loadScene(1965); - break; - case 3: - // No break on purpose - case 9: - // No break on purpose - case 11: - // No break on purpose - case 15: - // No break on purpose - case 24: - // No break on purpose - case 39: - // No break on purpose - case 45: - // No break on purpose - case 71: - // No break on purpose - case 73: - // No break on purpose - case 75: - // No break on purpose - case 79: - // No break on purpose - case 85: - // No break on purpose - case 87: - // No break on purpose - case 95: - loadScene(1955); - break; - case 4: - // No break on purpose - case 6: - // No break on purpose - case 13: - // No break on purpose - case 27: - // No break on purpose - case 41: - // No break on purpose - case 48: - // No break on purpose - case 50: - // No break on purpose - case 54: - // No break on purpose - case 76: - // No break on purpose - case 80: - // No break on purpose - case 90: - // No break on purpose - case 104: - loadScene(1975); - break; - case 5: - // No break on purpose - case 7: - // No break on purpose - case 14: - // No break on purpose - case 28: - // No break on purpose - case 32: - // No break on purpose - case 47: - // No break on purpose - case 53: - loadScene(1997); - break; - case 17: - // No break on purpose - case 20: - // No break on purpose - case 25: - // No break on purpose - case 31: - // No break on purpose - case 33: - // No break on purpose - case 46: - loadScene(1995); - break; - case 18: - // No break on purpose - case 22: - // No break on purpose - case 26: - // No break on purpose - case 36: - // No break on purpose - case 38: - // No break on purpose - case 43: - // No break on purpose - case 51: - // No break on purpose - case 70: - // No break on purpose - case 78: - // No break on purpose - case 84: - // No break on purpose - case 89: - // No break on purpose - case 101: - loadScene(1970); - break; - case 21: - // No break on purpose - case 34: - // No break on purpose - case 57: - // No break on purpose - case 58: - // No break on purpose - case 59: - // No break on purpose - case 62: - // No break on purpose - case 65: - loadScene(1980); - break; - case 35: - // No break on purpose - case 61: - // No break on purpose - case 77: - // No break on purpose - case 83: - loadScene(1982); - break; - case 37: - // No break on purpose - case 52: - // No break on purpose - case 82: - // No break on purpose - case 88: - // No break on purpose - case 92: - // No break on purpose - case 97: - // No break on purpose - case 100: - loadScene(1962); - break; - case 40: - // No break on purpose - case 102: - loadScene(1960); - break; - case 42: - // No break on purpose - case 55: - // No break on purpose - case 60: - // No break on purpose - case 66: - // No break on purpose - case 68: - // No break on purpose - case 69: - // No break on purpose - case 93: - // No break on purpose - case 98: - loadScene(1990); - break; - case 49: - // No break on purpose - case 81: - // No break on purpose - case 91: - // No break on purpose - case 94: - // No break on purpose - case 99: - loadScene(1967); - break; - case 56: - // No break on purpose - case 63: - // No break on purpose - case 64: - // No break on purpose - case 67: - loadScene(1985); - _upExitStyle = true; - break; - default: - break; + if (R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] == 2000) { + if (R2_GLOBALS._player._characterIndex == R2_QUINN) { + if (R2_GLOBALS._spillLocation[R2_QUINN] == 5) { + _sceneMode = 1902; + setAction(&_sequenceManager1, this, 1902, &R2_GLOBALS._player, NULL); + } else { + _sceneMode = 1903; + setAction(&_sequenceManager1, this, 1903, &R2_GLOBALS._player, NULL); + } + } else { + if (R2_GLOBALS._spillLocation[R2_SEEKER] == 5) { + _sceneMode = 1908; + setAction(&_sequenceManager1, this, 1908, &R2_GLOBALS._player, NULL); + } else { + _sceneMode = 1909; + setAction(&_sequenceManager1, this, 1909, &R2_GLOBALS._player, NULL); + } + } + } else { + R2_GLOBALS._player.setPosition(Common::Point(160, 135)); + R2_GLOBALS._player.enableControl(); + } + R2_GLOBALS._player._oldCharacterScene[R2_GLOBALS._player._characterIndex] = 1900; } - if (R2_GLOBALS._flubMazeArea != 1) - R2_GLOBALS._walkRegions.load(1950); + _elevator.setDetails(Rect(77, 2, 240, 103), 1900, 6, -1, -1, 1, NULL); + _background.setDetails(Rect(0, 0, 320, 200), 1900, 3, -1, -1, 1, NULL); +} - switch (R2_GLOBALS._flubMazeArea - 1) { - case 0: - _shaftExit._enabled = true; - if ((R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950)) - _doorExit._enabled = true; - R2_GLOBALS._walkRegions.disableRegion(2); - R2_GLOBALS._walkRegions.disableRegion(3); - R2_GLOBALS._walkRegions.disableRegion(4); - R2_GLOBALS._walkRegions.disableRegion(5); - R2_GLOBALS._walkRegions.disableRegion(6); - break; - case 1: - // No break on purpose - case 2: - // No break on purpose - case 3: - // No break on purpose - case 8: - // No break on purpose - case 9: - // No break on purpose +void Scene1900::remove() { + R2_GLOBALS._sound1.fadeOut(NULL); + SceneExt::remove(); +} + +void Scene1900::signal() { + switch (_sceneMode) { case 10: - // No break on purpose + R2_GLOBALS._spillLocation[R2_GLOBALS._player._characterIndex] = 5; + R2_GLOBALS._sceneManager.changeScene(2000); + break; case 11: - // No break on purpose - case 12: - // No break on purpose - case 15: - // No break on purpose - case 16: - // No break on purpose - case 19: - // No break on purpose - case 23: - // No break on purpose - case 24: - // No break on purpose - case 29: - // No break on purpose - case 30: - // No break on purpose - case 39: - // No break on purpose - case 40: - // No break on purpose - case 44: - // No break on purpose - case 45: - // No break on purpose - case 71: - // No break on purpose - case 72: - // No break on purpose - case 73: - // No break on purpose - case 74: - // No break on purpose - case 75: - // No break on purpose - case 79: - // No break on purpose - case 85: - // No break on purpose - case 86: - // No break on purpose - case 87: - // No break on purpose - case 95: - // No break on purpose - case 96: - // No break on purpose - case 102: - // No break on purpose - case 103: - _eastExit._enabled = true; - _westExit._enabled = true; + R2_GLOBALS._spillLocation[R2_GLOBALS._player._characterIndex] = 6; + R2_GLOBALS._sceneManager.changeScene(2000); break; - case 4: - // No break on purpose - case 6: - // No break on purpose - case 13: - // No break on purpose - case 17: - // No break on purpose case 20: - // No break on purpose - case 25: - // No break on purpose - case 27: - // No break on purpose - case 31: - // No break on purpose - case 33: - // No break on purpose - case 37: - // No break on purpose - case 41: - // No break on purpose - case 46: - // No break on purpose - case 48: - // No break on purpose - case 50: - // No break on purpose - case 52: - // No break on purpose - case 54: - // No break on purpose - case 76: - // No break on purpose - case 80: - // No break on purpose - case 82: - // No break on purpose - case 88: - // No break on purpose - case 90: - // No break on purpose - case 92: - // No break on purpose - case 97: - // No break on purpose - case 100: - // No break on purpose - case 104: - _westExit._enabled = true; - R2_GLOBALS._walkRegions.disableRegion(6); - R2_GLOBALS._walkRegions.disableRegion(9); + ++_sceneMode; + R2_GLOBALS._events.setCursor(CURSOR_WALK); + _stripManager.start(1300, this); + break; + case 21: + ++_sceneMode; + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS._player._action) + R2_GLOBALS._player._action->_endHandler = this; + else + signal(); break; - case 5: - // No break on purpose - case 7: - // No break on purpose - case 14: - // No break on purpose - case 18: - // No break on purpose case 22: + _sceneMode = 1910; + _companion.setAction(&_sequenceManager2, this, 1910, &_companion, NULL); + break; + case 1904: + R2_GLOBALS._scene1925CurrLevel = -3; // No break on purpose - case 26: - // No break on purpose - case 28: - // No break on purpose - case 32: - // No break on purpose - case 36: - // No break on purpose - case 38: - // No break on purpose - case 43: - // No break on purpose - case 47: - // No break on purpose - case 49: - // No break on purpose - case 51: - // No break on purpose - case 53: - // No break on purpose - case 70: - // No break on purpose - case 78: - // No break on purpose - case 81: - // No break on purpose - case 84: - // No break on purpose - case 89: - // No break on purpose - case 91: - // No break on purpose - case 94: - // No break on purpose - case 99: - // No break on purpose - case 101: - _eastExit._enabled = true; - R2_GLOBALS._walkRegions.disableRegion(1); - R2_GLOBALS._walkRegions.disableRegion(7); - R2_GLOBALS._walkRegions.disableRegion(13); + case 1905: + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._sceneManager.changeScene(1925); + break; + case 1910: + R2_INVENTORY.setObjectScene(R2_REBREATHER_TANK, 2535); + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._player._oldCharacterScene[R2_QUINN] = 1900; + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1900; + R2_GLOBALS._sceneManager.changeScene(2450); break; + case 1906: + R2_GLOBALS._scene1925CurrLevel = -3; + // No break on purpose default: - R2_GLOBALS._walkRegions.disableRegion(1); - R2_GLOBALS._walkRegions.disableRegion(6); - R2_GLOBALS._walkRegions.disableRegion(7); - R2_GLOBALS._walkRegions.disableRegion(9); - R2_GLOBALS._walkRegions.disableRegion(13); + R2_GLOBALS._player.enableControl(); break; } +} + +/*-------------------------------------------------------------------------- + * Scene 1925 - Spill Mountains Elevator Shaft + * + *--------------------------------------------------------------------------*/ + +Scene1925::Scene1925() { + _newSceneMode = 0; + for (int i = 0; i < 5; i++) + _levelResNum[i] = 0; +} + +void Scene1925::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_newSceneMode); + for (int i = 0; i < 5; i++) + s.syncAsSint16LE(_levelResNum[i]); +} + +bool Scene1925::Button::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneHotspot::startAction(action, event); + + if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) + return SceneHotspot::startAction(action, event); + + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + + if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20)) + scene->_sceneMode = 1928; + else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200)) + scene->_sceneMode = 1929; + else + scene->_sceneMode = 1930; + + R2_GLOBALS._player.disableControl(CURSOR_WALK); + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, + &scene->_door, NULL); + return true; +} + +bool Scene1925::Ladder::startAction(CursorType action, Event &event) { + if ((!R2_GLOBALS.getFlag(29)) || (action != CURSOR_USE)) + return SceneHotspot::startAction(action, event); + + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; + + if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { + scene->_westExit._enabled = false; + scene->_sceneMode = 1925; + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, + &R2_GLOBALS._player, &scene->_door, NULL); + return true; + } + + if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20) && (event.mousePos.y >= 30)) { + scene->_sceneMode = 1931; + } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200) && (event.mousePos.y < 140)) { + scene->_sceneMode = 1932; + } else if ( ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) + || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110)) + ) && (event.mousePos.y >= 100)) { + scene->_sceneMode = 1926; + } else if ( ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) + || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110)) + ) && (event.mousePos.y < 60)) { + scene->_sceneMode = 1927; + } else { + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + } - _northDoorway.remove(); - _northDoorway.removeObject(); - _southDoorway.remove(); + if (scene->_sceneMode != 0) + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); - switch (R2_GLOBALS._flubMazeArea - 4) { - case 0: - // No break on purpose - case 3: - // No break on purpose - case 16: - // No break on purpose - case 22: - // No break on purpose - case 24: - // No break on purpose - case 32: - // No break on purpose - case 33: - // No break on purpose - case 45: - // No break on purpose - case 46: - // No break on purpose - case 48: - // No break on purpose - case 51: - // No break on purpose - case 56: - // No break on purpose - case 59: - // No break on purpose - case 67: - // No break on purpose - case 68: - // No break on purpose - case 70: - // No break on purpose - case 73: - // No break on purpose - case 82: - // No break on purpose - case 90: - _northExit._enabled = true; - _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25); - //visage,strip,frame,px,py,priority,effect - _southDoorway.postInit(); - _southDoorway.setVisage(1950); - _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); - _southDoorway.setFrame(2); - _southDoorway.setPosition(Common::Point(160, 167)); - _southDoorway.fixPriority(220); - R2_GLOBALS._walkRegions.disableRegion(3); - R2_GLOBALS._walkRegions.disableRegion(4); - break; - case 7: - // No break on purpose - case 10: - // No break on purpose - case 23: - // No break on purpose - case 29: - // No break on purpose - case 31: - // No break on purpose - case 39: - // No break on purpose - case 40: - // No break on purpose - case 52: - // No break on purpose - case 53: - // No break on purpose - case 55: - // No break on purpose - case 63: - // No break on purpose - case 65: - // No break on purpose - case 66: - // No break on purpose - case 75: - // No break on purpose - case 77: - // No break on purpose - case 81: - // No break on purpose - case 87: - // No break on purpose - case 89: - // No break on purpose - case 97: - _southExit._enabled = true; + return true; +} - _southDoorway.postInit(); - _southDoorway.setVisage(1950); - _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); - _southDoorway.setFrame(3); - _southDoorway.setPosition(Common::Point(160, 167)); - _southDoorway.fixPriority(220); - break; - case 58: - // No break on purpose - case 74: - // No break on purpose - case 80: - _northExit._enabled = true; - _southExit._enabled = true; +void Scene1925::ExitUp::changeScene() { + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; - _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25); + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; - _southDoorway.postInit(); - _southDoorway.setVisage(1950); - _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); - _southDoorway.setFrame(3); - _southDoorway.setPosition(Common::Point(160, 167)); - _southDoorway.fixPriority(220); - R2_GLOBALS._walkRegions.disableRegion(3); - R2_GLOBALS._walkRegions.disableRegion(4); - break; - default: - _southDoorway.postInit(); - _southDoorway.setVisage(1950); - _southDoorway.setStrip(((R2_GLOBALS._flubMazeArea - 1) / 35) % 2 + 1); - _southDoorway.setFrame(2); - _southDoorway.setPosition(Common::Point(160, 167)); - _southDoorway.fixPriority(220); - break; + if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { + scene->_westExit._enabled = false; + scene->_newSceneMode = 1927; + scene->_sceneMode = 1925; + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, + &R2_GLOBALS._player, &scene->_door, NULL); + return; } - switch (R2_GLOBALS._flubMazeArea - 3) { - case 0: - // No break on purpose + if ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) + || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))) { + scene->_sceneMode = 1927; + } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 200)) { + scene->_sceneMode = 1932; + } + + if (scene->_sceneMode != 0) + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + else { + scene->_sceneMode = 1932; + scene->signal(); + } +} + +void Scene1925::ExitDown::changeScene() { + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; + + if ((R2_GLOBALS._player._position.x == 110) && (R2_GLOBALS._player._position.y == 100)) { + scene->_westExit._enabled = false; + scene->_newSceneMode = 1926; + scene->_sceneMode = 1925; + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, + &R2_GLOBALS._player, &scene->_door, NULL); + return; + } + + if ( ((R2_GLOBALS._player._position.x == 112) && (R2_GLOBALS._player._position.y == 101)) + || ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 110))) { + scene->_sceneMode = 1926; + } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 20)) { + scene->_sceneMode = 1931; + } + + if (scene->_sceneMode == 0) { + scene->_sceneMode = 1931; + scene->signal(); + } else + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); +} + +void Scene1925::WestExit::changeScene() { + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + scene->_sceneMode = 1921; + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); +} + +void Scene1925::EastExit::changeScene() { + Scene1925 *scene = (Scene1925 *)R2_GLOBALS._sceneManager._scene; + + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + scene->_sceneMode = 1920; + scene->setAction(&scene->_sequenceManager, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); +} + +void Scene1925::changeLevel(bool upFlag) { + if (R2_GLOBALS._scene1925CurrLevel < 0) + R2_GLOBALS._scene1925CurrLevel = 3; + + if (upFlag) { + R2_GLOBALS._player.setup(1925, 1, 1); + R2_GLOBALS._player.setPosition(Common::Point(154, 200)); + ++R2_GLOBALS._scene1925CurrLevel; + } else { + R2_GLOBALS._player.setup(1925, 1, 1); + R2_GLOBALS._player.setPosition(Common::Point(154, 20)); + R2_GLOBALS._scene1925CurrLevel--; + } + + switch (R2_GLOBALS._scene1925CurrLevel) { + case -1: + R2_GLOBALS._sceneManager.changeScene(1945); + return; + break; case 3: - // No break on purpose - case 5: - // No break on purpose - case 12: - // No break on purpose - case 15: - // No break on purpose - case 18: - // No break on purpose - case 19: - // No break on purpose - case 23: - // No break on purpose - case 26: - // No break on purpose - case 27: - // No break on purpose - case 29: - // No break on purpose - case 30: - // No break on purpose - case 31: - // No break on purpose - case 32: - // No break on purpose - case 44: - // No break on purpose - case 45: - // No break on purpose - case 51: - // No break on purpose - case 55: - // No break on purpose - case 56: - // No break on purpose - case 57: - // No break on purpose - case 60: - // No break on purpose - case 63: - _upExit._enabled = true; + loadScene(_levelResNum[4]); + _button.setDetails(Rect(133, 68, 140, 77), 1925, 3, -1, 5, 2, NULL); + _door.setDetails(1925, 0, 1, 2, 2, (SceneItem *) NULL); + _door.show(); break; - case 54: - // No break on purpose - case 61: - // No break on purpose - case 62: - // No break on purpose - case 65: - _upExit._enabled = true; - // No break on purpose - case 35: - // No break on purpose - case 38: - // No break on purpose - case 40: - // No break on purpose - case 47: - // No break on purpose - case 50: - // No break on purpose - case 53: - // No break on purpose - case 58: - // No break on purpose - case 64: - // No break on purpose - case 66: - // No break on purpose - case 67: - // No break on purpose - case 79: - // No break on purpose - case 80: - // No break on purpose - case 86: - // No break on purpose - case 89: - // No break on purpose - case 90: - // No break on purpose - case 91: - // No break on purpose - case 92: - // No break on purpose - case 95: - // No break on purpose - case 96: + case 512: + R2_GLOBALS._scene1925CurrLevel = 508; // No break on purpose - case 97: + default: + loadScene(_levelResNum[(R2_GLOBALS._scene1925CurrLevel % 4)]); + R2_GLOBALS._sceneItems.remove(&_button); + R2_GLOBALS._sceneItems.remove(&_door); + _door.hide(); + break; + } + + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; +} + +void Scene1925::postInit(SceneObjectList *OwnerList) { + _levelResNum[0] = 1930; + _levelResNum[1] = 1935; + _levelResNum[2] = 1940; + _levelResNum[3] = 1935; + _levelResNum[4] = 1925; + + if (R2_GLOBALS.getFlag(29)) { + if ((R2_GLOBALS._scene1925CurrLevel == -3) || (R2_GLOBALS._scene1925CurrLevel == 3)) + loadScene(_levelResNum[4]); + else + loadScene(_levelResNum[R2_GLOBALS._scene1925CurrLevel % 4]); + } else { + R2_GLOBALS._scene1925CurrLevel = -2; + loadScene(1920); + } + SceneExt::postInit(); + R2_GLOBALS._sound1.play(220); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1925; + R2_GLOBALS._player._characterIndex = R2_SEEKER; + + switch (R2_GLOBALS._scene1925CurrLevel) { + case -2: + _eastExit.setDetails(Rect(203, 44, 247, 111), EXITCURSOR_E, 1925); + _ladder.setDetails(Rect(31, 3, 45, 167), 1925, 6, -1, 8, 1, NULL); + break; + case 3: + _door.setDetails(1925, 0, 1, 2, 1, (SceneItem *) NULL); + _button.setDetails(Rect(133, 68, 140, 77), 1925, 3, -1, 5, 1, NULL); // No break on purpose - case 98: + case -3: + _westExit.setDetails(Rect(83, 38, 128, 101), EXITCURSOR_W, 1925); // No break on purpose - case 100: - _downExit._enabled = true; - R2_GLOBALS._walkRegions.disableRegion(4); - R2_GLOBALS._walkRegions.disableRegion(5); - R2_GLOBALS._walkRegions.disableRegion(6); - R2_GLOBALS._walkRegions.disableRegion(10); - R2_GLOBALS._walkRegions.disableRegion(11); default: + _exitUp.setDetails(Rect(128, 0, 186, 10), EXITCURSOR_N, 1925); + _exitDown.setDetails(Rect(128, 160, 190, 167), EXITCURSOR_S, 1925); + _ladder.setDetails(Rect(141, 11, 167, 159), 1925, 6, -1, -1, 1, NULL); break; } - R2_GLOBALS._uiElements.draw(); -} - -void Scene1950::enterArea() { - R2_GLOBALS._player.disableControl(); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - _vampire.remove(); - _door.remove(); - _scrolls.remove(); + _door.postInit(); + _door.setup(1925, 5, 1); + _door.setPosition(Common::Point(128, 35)); + _door.hide(); - _vampireActive = false; - _vampireIndex = 0; + if (R2_GLOBALS._scene1925CurrLevel == 3) + _door.show(); - // Certain areas have a vampire in them - switch (R2_GLOBALS._flubMazeArea) { - case 10: - _vampireIndex = 1; - break; - case 13: - _vampireIndex = 2; - break; - case 16: - _vampireIndex = 3; - break; - case 17: - _vampireIndex = 4; - break; - case 24: - _vampireIndex = 5; - break; - case 25: - _vampireIndex = 6; - break; - case 31: - _vampireIndex = 7; - break; - case 40: - _vampireIndex = 8; - break; - case 45: - _vampireIndex = 9; - break; - case 46: - _vampireIndex = 10; - break; - case 73: - _vampireIndex = 11; - break; - case 75: - _vampireIndex = 12; + R2_GLOBALS._player.enableControl(CURSOR_USE); + switch (R2_GLOBALS._scene1925CurrLevel) { + case -2: + R2_GLOBALS._player.setup(20, 6, 1); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setPosition(Common::Point(224, 109)); break; - case 80: - _vampireIndex = 13; + case -3: + _door.hide(); + R2_GLOBALS._player.setup(20, 5, 1); + R2_GLOBALS._player.setPosition(Common::Point(110, 100)); break; - case 87: - _vampireIndex = 14; + case 0: + R2_GLOBALS._player.setup(1925, 1, 1); + R2_GLOBALS._player.setPosition(Common::Point(154, 200)); break; - case 88: - _vampireIndex = 15; + default: + R2_GLOBALS._player.setup(1925, 1, 3); + R2_GLOBALS._player.setPosition(Common::Point(154, 110)); break; - case 96: - _vampireIndex = 16; + } + + R2_GLOBALS._player._canWalk = false; + _newSceneMode = 0; + R2_GLOBALS._sceneManager._previousScene = 1925; + _background.setDetails(Rect(27, 0, 292, 200), 1925, 9, -1, -1, 1, NULL); +} + +void Scene1925::remove() { + R2_GLOBALS._sound1.fadeOut2(NULL); + R2_GLOBALS._player._oldCharacterScene[R2_SEEKER] = 1925; + SceneExt::remove(); +} + +void Scene1925::signal() { + switch (_sceneMode) { + case 1920: + // No break on purpose + case 1921: + // No break on purpose + case 1928: + // No break on purpose + case 1929: + // No break on purpose + case 1930: + R2_GLOBALS._scene1925CurrLevel = -3; + R2_GLOBALS._sceneManager.changeScene(1900); break; - case 97: - _vampireIndex = 17; + case 1926: + // No break on purpose + case 1931: + // Change level, down + changeLevel(false); break; - case 104: - _vampireIndex = 18; + case 1927: + // No break on purpose + case 1932: + // Change level, up + changeLevel(true); break; + case 1925: + _westExit._enabled = false; + if (_newSceneMode != 0) { + _sceneMode = _newSceneMode; + _newSceneMode = 0; + setAction(&_sequenceManager, this, _sceneMode, &R2_GLOBALS._player, NULL); + } + // No break on purpose default: + R2_GLOBALS._player.enableControl(CURSOR_USE); break; } - if (_vampireIndex != 0) { - _vampire.postInit(); - _vampire._numFrames = 6; - _vampire._moveRate = 6; - _vampire._moveDiff = Common::Point(3, 2); - _vampire._effect = EFFECT_SHADED; - - if (!R2_GLOBALS._vampireData[_vampireIndex - 1]._isAlive) { - // Show vampire ashes - _vampire.setPosition(Common::Point(R2_GLOBALS._vampireData[_vampireIndex - 1]._position)); - _vampire.animate(ANIM_MODE_NONE, NULL); - _vampire.addMover(NULL); - _vampire.setVisage(1961); - _vampire.setStrip(4); - _vampire.setFrame(10); - _vampire.fixPriority(10); - _vampire.setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL); - } else { - // Start the vampire - _vampire.setVisage(1960); - _vampire.setPosition(Common::Point(160, 130)); - _vampire.animate(ANIM_MODE_2, NULL); - _vampire.setDetails(1950, 12, -1, 14, 2, (SceneItem *) NULL); - _vampireActive = true; - } - } - if ((R2_GLOBALS._flubMazeArea == 1) && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) != 0)) { - // Show doorway at the right hand side of the very first flub corridor - _door.postInit(); - _door.setVisage(1948); - _door.setStrip(3); - _door.setPosition(Common::Point(278, 155)); - _door.fixPriority(100); - _door.setDetails(1950, 19, 20, 23, 2, (SceneItem *) NULL); - } - - if (R2_GLOBALS._flubMazeArea == 102) { - R2_GLOBALS._walkRegions.load(1951); - R2_GLOBALS._walkRegions.disableRegion(1); - R2_GLOBALS._walkRegions.disableRegion(5); - R2_GLOBALS._walkRegions.disableRegion(6); - R2_GLOBALS._walkRegions.disableRegion(7); - - _cube.postInit(); - _cube.setVisage(1970); - _cube.setStrip(1); - if (R2_GLOBALS.getFlag(37)) - _cube.setFrame(3); - else - _cube.setFrame(1); - _cube.setPosition(Common::Point(193, 158)); - _cube.setDetails(1950, 3, 4, 5, 2, (SceneItem *) NULL); - - _pulsingLights.postInit(); - _pulsingLights.setVisage(1970); - _pulsingLights.setStrip(3); - _pulsingLights.animate(ANIM_MODE_2, NULL); - _pulsingLights._numFrames = 6; - _pulsingLights.setPosition(Common::Point(194, 158)); - _pulsingLights.fixPriority(159); - - _keypad.setDetails(Rect(188, 124, 199, 133), 1950, 27, 28, -1, 2, NULL); - - if (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) { - _gem.postInit(); - _gem.setVisage(1970); - _gem.setStrip(1); - _gem.setFrame(2); - _gem.fixPriority(160); - } - - if (R2_GLOBALS.getFlag(37)) { - _gem.setPosition(Common::Point(192, 118)); - _gem.setDetails(1950, 9, 4, -1, 2, (SceneItem *) NULL); - } else { - _containmentField.postInit(); - _containmentField.setVisage(1970); - _containmentField.setStrip(4); - _containmentField._numFrames = 4; - _containmentField.animate(ANIM_MODE_8, 0, NULL); - _containmentField.setPosition(Common::Point(192, 121)); - _containmentField.fixPriority(159); - _containmentField.setDetails(1950, 6, 7, 8, 2, (SceneItem *) NULL); - - _gem.setPosition(Common::Point(192, 109)); - _gem.setDetails(1950, 9, 7, 8, 2, (SceneItem *) NULL); - } - - _scrolls.postInit(); - _scrolls.setVisage(1972); - _scrolls.setStrip(1); - _scrolls.setPosition(Common::Point(76, 94)); - _scrolls.fixPriority(25); - _scrolls.setDetails(1950, 30, -1, -1, 2, (SceneItem *) NULL); - if (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2) - _scrolls.setFrame(2); - else - _scrolls.setFrame(1); + R2_GLOBALS._player._canWalk = false; +} - _removeFlag = true; - } else if (_removeFlag) { - _cube.remove(); - _containmentField.remove(); - _gem.remove(); - _pulsingLights.remove(); - _scrolls.remove(); +/*-------------------------------------------------------------------------- + * Scene 1945 - Spill Mountains Shaft Bottom + * + *--------------------------------------------------------------------------*/ - R2_GLOBALS._sceneItems.remove(&_background); - _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 2, NULL); +Scene1945::Scene1945() { + _nextSceneMode1 = 0; + _nextSceneMode2 = 0; + _lampUsed = CURSOR_NONE; +} - _removeFlag = false; - } +void Scene1945::synchronize(Serializer &s) { + SceneExt::synchronize(s); - switch (R2_GLOBALS._flubMazeEntryDirection) { - case 0: - _sceneMode = 1950; - if (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) - // The original uses CURSOR_ARROW. CURSOR_WALK is much more coherent - R2_GLOBALS._player.enableControl(CURSOR_WALK); - else - setAction(&_sequenceManager, this, 1950, &R2_GLOBALS._player, NULL); + s.syncAsSint16LE(_nextSceneMode1); + s.syncAsSint16LE(_nextSceneMode2); + s.syncAsSint16LE(_lampUsed); +} - break; - case 1: { - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - R2_GLOBALS._player.setPosition(Common::Point(160, 213)); - Common::Point pt(160, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); +bool Scene1945::Ice::startAction(CursorType action, Event &event) { + Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case R2_GUNPOWDER: + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 0; + if ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) + scene->_sceneMode = 1942; + else { + scene->_sceneMode = 1940; + scene->_nextSceneMode1 = 1942; } + // At this point the original check if _sceneMode != 0. Skipped. + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, &scene->_gunpowder, NULL); + return true; break; - case 2: - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - if (R2_GLOBALS.getFlag(36)) - setAction(&_sequenceManager, this, 1957, &R2_GLOBALS._player, NULL); - else - setAction(&_sequenceManager, this, 1974, &R2_GLOBALS._player, NULL); - break; - case 3: - // Entering from the left - if (!_vampireActive) { - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - R2_GLOBALS._player.setPosition(Common::Point(-20, 160)); - Common::Point pt(30, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); + case CURSOR_USE: + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; + if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50) && (event.mousePos.x >= 130)) { + scene->_sceneMode = 1940; + // At this point the original check if _sceneMode != 0. Skipped. + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + return true; } else { - _sceneMode = 18; - _eastExit._enabled = false; - _vampireDestPos = Common::Point(60, 152); R2_GLOBALS._player.enableControl(CURSOR_USE); R2_GLOBALS._player._canWalk = false; - - _vampire.setStrip(2); - NpcMover *mover = new NpcMover(); - _vampire.addMover(mover, &_vampireDestPos, this); - - R2_GLOBALS._player.setPosition(Common::Point(-20, 160)); - Common::Point pt2(30, 160); - NpcMover *mover2 = new NpcMover(); - R2_GLOBALS._player.addMover(mover2, &pt2, NULL); - } - break; - case 4: - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - if (!_upExitStyle) { - if (R2_GLOBALS.getFlag(36)) - setAction(&_sequenceManager, this, 1955, &R2_GLOBALS._player, NULL); - else - setAction(&_sequenceManager, this, 1972, &R2_GLOBALS._player, NULL); - } else { - if (R2_GLOBALS.getFlag(36)) - setAction(&_sequenceManager, this, 1954, &R2_GLOBALS._player, NULL); + if (event.mousePos.x > 130) + scene->_ice.setDetails(1945, 3, -1, -1, 3, (SceneItem *) NULL); else - setAction(&_sequenceManager, this, 1971, &R2_GLOBALS._player, NULL); - } - break; - case 5: { - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - R2_GLOBALS._player.setPosition(Common::Point(160, 127)); - Common::Point pt(160, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); + scene->_ice.setDetails(1945, 3, -1, 5, 3, (SceneItem *) NULL); } + // No break on purpose + default: + return SceneHotspot::startAction(action, event); break; - case 6: - // Entering from the right - if (!_vampireActive) { - _sceneMode = R2_GLOBALS._flubMazeEntryDirection; - if (R2_GLOBALS._flubMazeArea == 1) { - setAction(&_sequenceManager, this, 1961, &R2_GLOBALS._player, NULL); - } else { - R2_GLOBALS._player.setPosition(Common::Point(340, 160)); - Common::Point pt(289, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - } - } else { - _sceneMode = 17; - _westExit._enabled = false; - _vampireDestPos = Common::Point(259, 152); + } +} - R2_GLOBALS._player.enableControl(CURSOR_USE); - R2_GLOBALS._player._canWalk = false; +bool Scene1945::Ladder::startAction(CursorType action, Event &event) { + if (action != CURSOR_USE) + return SceneHotspot::startAction(action, event); - _vampire.setStrip(1); - NpcMover *mover = new NpcMover(); - _vampire.addMover(mover, &_vampireDestPos, this); + Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.setPosition(Common::Point(340, 160)); - Common::Point pt2(289, 160); - NpcMover *mover2 = new NpcMover(); - R2_GLOBALS._player.addMover(mover2, &pt2, NULL); + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; + + if ((R2_GLOBALS._player._position.x == 221) && (R2_GLOBALS._player._position.y == 142)) { + scene->_sceneMode = 1949; + scene->_nextSceneMode1 = 1947; + } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) + || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { + scene->_sceneMode = 1947; + } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50) + && (event.mousePos.y >= 30)) { + scene->_sceneMode = 1940; + } else { + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + } + + if (scene->_sceneMode != 0) + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + + return true; +} + +bool Scene1945::Gunpowder::startAction(CursorType action, Event &event) { + if ((action == R2_ALCOHOL_LAMP_3) || (action == R2_ALCOHOL_LAMP_2)) { + Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; + + scene->_lampUsed = action; + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 0; + if ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) { + scene->_sceneMode= 1947; + scene->_nextSceneMode1 = 1943; + } else if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50)) { + scene->_sceneMode = 1940; + scene->_nextSceneMode1 = 1943; + } else { + scene->_sceneMode = 1949; + scene->_nextSceneMode1 = 1947; + scene->_nextSceneMode2 = 1943; } - break; - default: - break; - } -} - -void Scene1950::doButtonPress(int indx) { - Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; - R2_GLOBALS._player.disableControl(); - - int prevIndex = indx - 1; - if ((indx / 4) == (prevIndex / 4)) { - if (prevIndex < 0) - prevIndex = 3; + // At this point the original check if _sceneMode != 0. Skipped. + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); + return true; } else { - prevIndex += 4; + return SceneActor::startAction(action, event); } +} - assert(prevIndex >= 0 && prevIndex < 16); - if (!_KeypadWindow._buttons[prevIndex]._toggled) { - _KeypadWindow._buttons[prevIndex].setFrame(2); - _KeypadWindow._buttons[prevIndex]._toggled = true; - } else { - _KeypadWindow._buttons[prevIndex].setFrame(1); - _KeypadWindow._buttons[prevIndex]._toggled = false; - } +void Scene1945::ExitUp::changeScene() { + Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - prevIndex = indx + 1; - if ((indx / 4) == (prevIndex / 4)) { - if (prevIndex > 15) - prevIndex = 12; - } else { - prevIndex -= 4; - } + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; - assert(prevIndex >= 0 && prevIndex < 16); - if (!_KeypadWindow._buttons[prevIndex]._toggled) { - _KeypadWindow._buttons[prevIndex].setFrame(2); - _KeypadWindow._buttons[prevIndex]._toggled = true; - } else { - _KeypadWindow._buttons[prevIndex].setFrame(1); - _KeypadWindow._buttons[prevIndex]._toggled = false; + if ((R2_GLOBALS._player._position.x == 221) && (R2_GLOBALS._player._position.y == 142)) { + scene->_sceneMode = 1949; + scene->_nextSceneMode1 = 1947; + } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) + || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { + scene->_sceneMode = 1947; } - prevIndex = indx - 4; - if (prevIndex < 0) - prevIndex += 16; - - assert(prevIndex >= 0 && prevIndex < 16); - if (!_KeypadWindow._buttons[prevIndex]._toggled) { - _KeypadWindow._buttons[prevIndex].setFrame(2); - _KeypadWindow._buttons[prevIndex]._toggled = true; + if (scene->_sceneMode == 0) { + scene->_sceneMode = 1941; + signal(); } else { - _KeypadWindow._buttons[prevIndex].setFrame(1); - _KeypadWindow._buttons[prevIndex]._toggled = false; + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); } +} - prevIndex = indx + 4; - if (prevIndex > 15) - prevIndex -= 16; +void Scene1945::CorridorExit::changeScene() { + Scene1945 *scene = (Scene1945 *)R2_GLOBALS._sceneManager._scene; - assert(prevIndex >= 0 && prevIndex < 16); - if (!_KeypadWindow._buttons[prevIndex]._toggled) { - _KeypadWindow._buttons[prevIndex].setFrame(2); - _KeypadWindow._buttons[prevIndex]._toggled = true; - } else { - _KeypadWindow._buttons[prevIndex].setFrame(1); - _KeypadWindow._buttons[prevIndex]._toggled = false; - } + _moving = false; + R2_GLOBALS._player.disableControl(CURSOR_USE); + scene->_sceneMode = 0; - // Check whether all the buttons are highlighted - int cpt = 0; - for (prevIndex = 0; prevIndex < 16; prevIndex++) { - if (_KeypadWindow._buttons[prevIndex]._toggled) - ++cpt; + if ((R2_GLOBALS._player._position.x == 154) && (R2_GLOBALS._player._position.y == 50)) { + scene->_sceneMode = 1940; + scene->_nextSceneMode1 = 1945; + } else if ( ((R2_GLOBALS._player._position.x == 197) && (R2_GLOBALS._player._position.y == 158)) + || ((R2_GLOBALS._player._position.x == 191) && (R2_GLOBALS._player._position.y == 142)) ) { + scene->_sceneMode = 1945; } - if (cpt != 16) { - R2_GLOBALS._player.enableControl(); - R2_GLOBALS._player._canWalk = false; - } else { - R2_GLOBALS.setFlag(37); - _sceneMode = 24; - setAction(&_sequenceManager, scene, 1976, NULL); - } + if (scene->_sceneMode != 0) + scene->setAction(&scene->_sequenceManager1, scene, scene->_sceneMode, &R2_GLOBALS._player, NULL); } -void Scene1950::postInit(SceneObjectList *OwnerList) { - _upExitStyle = false; - _removeFlag = false; - _vampireActive = false; - _vampireIndex = 0; - if (R2_GLOBALS._sceneManager._previousScene == 300) - R2_GLOBALS._flubMazeArea = 103; - - initArea(); +void Scene1945::postInit(SceneObjectList *OwnerList) { + loadScene(1945); SceneExt::postInit(); - R2_GLOBALS._sound1.play(105); - - _northExit.setDetails(Rect(130, 46, 189, 135), SHADECURSOR_UP, 1950); - _northExit.setDest(Common::Point(160, 145)); + R2_GLOBALS._sound1.play(220); - _upExit.setDetails(Rect(208, 0, 255, 73), EXITCURSOR_N, 1950); - _upExit.setDest(Common::Point(200, 151)); + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + R2_GLOBALS._player._characterScene[R2_SEEKER] = 1945; + R2_GLOBALS._player._characterIndex = R2_SEEKER; - _eastExit.setDetails(Rect(305, 95, 320, 147), EXITCURSOR_E, 1950); - _eastExit.setDest(Common::Point(312, 160)); + _exitUp.setDetails(Rect(128, 0, 186, 10), EXITCURSOR_N, 1945); + _corridorExit.setDetails(Rect(238, 144, 274, 167), EXITCURSOR_E, 1945); - _downExit.setDetails(Rect(208, 99, 255, 143), EXITCURSOR_S, 1950); - _downExit.setDest(Common::Point(200, 151)); + _ladder.setDetails(Rect(141, 3, 167, 126), 1945, 9, -1, -1, 1, NULL); - _southExit.setDetails(Rect(113, 154, 206, 168), SHADECURSOR_DOWN, 1950); - _southExit.setDest(Common::Point(160, 165)); + if (!R2_GLOBALS.getFlag(43)) { + _corridorExit._enabled = false; + _gunpowder.postInit(); + _gunpowder.setup(1945, 4, 1); + _gunpowder.setPosition(Common::Point(253, 169)); + _gunpowder.fixPriority(150); - _westExit.setDetails(Rect(0, 95, 14, 147), EXITCURSOR_W, 1950); - _westExit.setDest(Common::Point(7, 160)); + if (R2_GLOBALS.getFlag(42)) + _gunpowder.setDetails(1945, 15, -1, -1, 1, (SceneItem *) NULL); + else + _gunpowder.hide(); - _shaftExit.setDetails(Rect(72, 54, 120, 128), EXITCURSOR_NW, 1950); - _shaftExit.setDest(Common::Point(120, 140)); + _coveringIce.postInit(); + _coveringIce.setup(1945, 8, 1); + _coveringIce.setPosition(Common::Point(253, 169)); + _coveringIce.fixPriority(130); - _doorExit.setDetails(Rect(258, 60, 300, 145), EXITCURSOR_NE, 1950); - _doorExit.setDest(Common::Point(268, 149)); + _alcoholLamp.postInit(); + _alcoholLamp.setup(1945, 3, 1); + _alcoholLamp.hide(); + } else { + _corridorExit._enabled = true; + } - R2_GLOBALS._player.postInit(); - if ( (R2_INVENTORY.getObjectScene(R2_TANNER_MASK) == 0) && (R2_INVENTORY.getObjectScene(R2_PURE_GRAIN_ALCOHOL) == 0) - && (R2_INVENTORY.getObjectScene(R2_SOAKED_FACEMASK) == 0) && (!R2_GLOBALS.getFlag(36)) ) - R2_GLOBALS._player.setVisage(22); - else - R2_GLOBALS._player.setVisage(20); + switch (R2_GLOBALS._sceneManager._previousScene) { + case 1925: + R2_GLOBALS._scene1925CurrLevel = 0; + R2_GLOBALS.clearFlag(29); + R2_GLOBALS._player.setup(1925, 1, 10); + R2_GLOBALS._player.setPosition(Common::Point(154, 50)); + break; + case 1950: + _sceneMode = 1944; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); + R2_GLOBALS._player.disableControl(CURSOR_USE); + break; + default: + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.setup(20, 5, 1); + R2_GLOBALS._player.setPosition(Common::Point(191, 142)); + break; + } - R2_GLOBALS._player._moveDiff = Common::Point(5, 3); - _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 1, NULL); + R2_GLOBALS._player._canWalk = false; + _nextSceneMode1 = 0; + _nextSceneMode2 = 0; - enterArea(); + _ice.setDetails(11, 1945, 3, -1, 5); + _hole.setDetails(Rect(238, 144, 274, 167), 1945, 0, -1, 2, 1, NULL); + _ice2.setDetails(Rect(27, 3, 292, 167), 1945, 3, -1, -1, 1, NULL); } -void Scene1950::remove() { - R2_GLOBALS._sound1.stop(); - R2_GLOBALS._sound2.fadeOut2(NULL); +void Scene1945::remove() { + R2_GLOBALS._sound1.fadeOut2(NULL); SceneExt::remove(); } -void Scene1950::signal() { +void Scene1945::signal() { switch (_sceneMode) { - case 11: - R2_GLOBALS._flubMazeArea += 7; - initArea(); - enterArea(); - break; - case 12: - // Moving up a ladder within the Flub maze - R2_GLOBALS._flubMazeArea += 35; - initArea(); - enterArea(); - break; - case 1975: - SceneItem::display(1950, 21, SET_WIDTH, 280, SET_X, 160, SET_POS_MODE, 1, - SET_Y, 20, SET_EXT_BGCOLOR, 7, LIST_END); - // No break on purpose - case 13: - // Moving east within the Flub maze - ++R2_GLOBALS._flubMazeArea; - initArea(); - enterArea(); - break; - case 14: - // Moving down a ladder within the Flub maze - R2_GLOBALS._flubMazeArea -= 35; - initArea(); - enterArea(); - break; - case 15: - R2_GLOBALS._flubMazeArea -= 7; - initArea(); - enterArea(); - break; - case 16: - // Moving west within the Flub maze - // No break on purpose - case 1961: - --R2_GLOBALS._flubMazeArea; - initArea(); - enterArea(); - break; - case 17: { - _sceneMode = 13; - R2_GLOBALS._flubMazeEntryDirection = 3; - _vampireActive = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._player._canWalk = true; - R2_GLOBALS._player.setVisage(22); - R2_GLOBALS._player.animate(ANIM_MODE_9); - Common::Point pt(340, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - Common::Point pt2(289, 160); - NpcMover *mover2 = new NpcMover(); - _vampire.addMover(mover2, &pt2, NULL); + case 1940: + if (_nextSceneMode1 == 1943) { + _sceneMode = _nextSceneMode1; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); + } else { + _sceneMode = 1946; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); } + return; break; - case 18: { - _sceneMode = 16; - R2_GLOBALS._flubMazeEntryDirection = 6; - _vampireActive = false; - R2_GLOBALS._player.disableControl(CURSOR_WALK); - R2_GLOBALS._player._canWalk = true; - R2_GLOBALS._player.setVisage(22); - R2_GLOBALS._player.animate(ANIM_MODE_9); - Common::Point pt(-20, 160); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); - Common::Point pt2(30, 160); - NpcMover *mover2 = new NpcMover(); - _vampire.addMover(mover2, &pt2, NULL); + case 1941: + if (_nextSceneMode1 == 0) { + R2_GLOBALS._scene1925CurrLevel = 0; + R2_GLOBALS.setFlag(29); + R2_GLOBALS._sceneManager.changeScene(1925); + } else { + _sceneMode = _nextSceneMode1; + _nextSceneMode1 = 0; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); } + return; + case 1942: + R2_INVENTORY.setObjectScene(R2_GUNPOWDER, 0); + _gunpowder.setDetails(1945, 15, -1, -1, 2, (SceneItem *) NULL); + R2_GLOBALS.setFlag(42); break; - case 24: - _KeypadWindow.remove(); - _sceneMode = 1966; - _cube.setFrame(3); - setAction(&_sequenceManager, this, 1966, &_containmentField, &_gem, NULL); - break; - case 1951: + case 1943: R2_GLOBALS._sound1.fadeOut2(NULL); - R2_GLOBALS._sceneManager.changeScene(1945); - break; - case 1958: - SceneItem::display(1950, 24, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - R2_GLOBALS._player.enableControl(CURSOR_WALK); - _doorExit._enabled = true; - break; - case 1959: - R2_INVENTORY.setObjectScene(R2_SOAKED_FACEMASK, 0); - R2_GLOBALS._player.enableControl(CURSOR_WALK); - _doorExit._enabled = true; - break; - case 1962: - // No break on purpose - case 1963: - R2_GLOBALS._player.enableControl(); - _KeypadWindow.setup2(1971, 1, 1, 160, 135); + R2_INVENTORY.setObjectScene(_lampUsed, 0); + _sceneMode = 1948; + setAction(&_sequenceManager1, this, _sceneMode, &_gunpowder, &_alcoholLamp, &_coveringIce, NULL); + R2_GLOBALS._player.setAction(&_sequenceManager2, NULL, 1941, &R2_GLOBALS._player, NULL); + return; + case 1944: break; - case 1964: - // No break on purpose - case 1965: - if (!R2_GLOBALS.getFlag(37)) - SceneItem::display(1950, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); - - R2_GLOBALS._player.enableControl(); + case 1945: + R2_GLOBALS._sceneManager.changeScene(1950); + return; + case 1946: + if (_nextSceneMode1 == 1942) { + _sceneMode = _nextSceneMode1; + _nextSceneMode1 = 0; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_gunpowder, NULL); + return; + } + _sceneMode = 0; break; - case 1966: - _containmentField.remove(); - if (R2_GLOBALS.getFlag(36)) { - _sceneMode = 1964; - setAction(&_sequenceManager, this, 1964, &R2_GLOBALS._player, NULL); + case 1947: + if (_nextSceneMode1 == 1943) { + _sceneMode = _nextSceneMode1; + _nextSceneMode1 = 1948; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); } else { - _sceneMode = 1965; - setAction(&_sequenceManager, this, 1965, &R2_GLOBALS._player, NULL); + _sceneMode = 1941; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); } - _gem.setDetails(1950, 9, -1, -1, 2, (SceneItem *) NULL); - break; - case 1967: { - _sceneMode = 0; - R2_INVENTORY.setObjectScene(R2_SAPPHIRE_BLUE, 2); - _gem.remove(); - if (R2_GLOBALS.getFlag(36)) - R2_GLOBALS._player.setVisage(20); - else - R2_GLOBALS._player.setVisage(22); - - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - // This is a hack to work around a pathfinding issue. original destination is (218, 165) - Common::Point pt(128, 165); - NpcMover *mover = new NpcMover(); - R2_GLOBALS._player.addMover(mover, &pt, this); + return; + case 1948: + R2_GLOBALS._sound1.play(220); + _corridorExit._enabled = true; + R2_GLOBALS._sceneItems.remove(&_gunpowder); + R2_GLOBALS.clearFlag(42); + R2_GLOBALS.setFlag(43); + _nextSceneMode1 = 1940; + // No break on purpose + case 1949: + _sceneMode = _nextSceneMode1; + if (_nextSceneMode2 == 1943) { + _nextSceneMode1 = _nextSceneMode2; + _nextSceneMode2 = 0; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, &_alcoholLamp, NULL); + } else { + _nextSceneMode1 = 0; + setAction(&_sequenceManager1, this, _sceneMode, &R2_GLOBALS._player, NULL); } - break; - case 1968: - R2_GLOBALS._player.enableControl(); - R2_INVENTORY.setObjectScene(R2_ANCIENT_SCROLLS, 2); - _scrolls.setFrame(2); - if (R2_GLOBALS.getFlag(36)) - R2_GLOBALS._player.setVisage(20); - else - R2_GLOBALS._player.setVisage(22); - R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); - break; + return; default: - R2_GLOBALS._player.enableControl(CURSOR_WALK); break; } -} - -void Scene1950::process(Event &event) { - if ( (event.eventType == EVENT_BUTTON_DOWN) - && (R2_GLOBALS._player._uiEnabled) - && (R2_GLOBALS._events.getCursor() == R2_SOAKED_FACEMASK) - && (R2_GLOBALS._player._bounds.contains(event.mousePos)) - && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)) { - event.handled = true; - R2_GLOBALS._player.disableControl(); - _shaftExit._enabled = false; - _doorExit._enabled = false; - _sceneMode = 1959; - setAction(&_sequenceManager, this, 1959, &R2_GLOBALS._player, NULL); - } - Scene::process(event); + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; } } // End of namespace Ringworld2 diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 0b6738060c..e6f5e0ab97 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -135,53 +135,6 @@ public: virtual void saveCharacter(int characterIndex); }; -class Scene1200 : public SceneExt { - enum CrawlDirection { CRAWL_EAST = 1, CRAWL_WEST = 2, CRAWL_SOUTH = 3, CRAWL_NORTH = 4 }; - - class LaserPanel: public ModalWindow { - public: - class Jumper : public SceneActorExt { - public: - void init(int state); - virtual bool startAction(CursorType action, Event &event); - }; - - Jumper _jumper1; - Jumper _jumper2; - Jumper _jumper3; - - LaserPanel(); - - virtual void postInit(SceneObjectList *OwnerList = NULL); - virtual void remove(); - }; - -public: - NamedHotspot _item1; - SceneActor _actor1; - LaserPanel _laserPanel; - MazeUI _mazeUI; - SequenceManager _sequenceManager; - - int _nextCrawlDirection; - int _field414; - int _field416; - int _field418; - int _field41A; - bool _fixupMaze; - - Scene1200(); - void synchronize(Serializer &s); - - void startCrawling(CrawlDirection dir); - - virtual void postInit(SceneObjectList *OwnerList = NULL); - virtual void signal(); - virtual void process(Event &event); - virtual void dispatch(); - virtual void saveCharacter(int characterIndex); -}; - class Scene1500 : public SceneExt { public: SceneActor _starship; @@ -880,143 +833,6 @@ public: virtual void signal(); }; -class Scene1950 : public SceneExt { - /* Windows */ - class KeypadWindow: public ModalWindow { - public: - class KeypadButton : public SceneActor { - public: - int _buttonIndex; - bool _pressed; - bool _toggled; - - KeypadButton(); - void synchronize(Serializer &s); - - void init(int indx); - virtual void process(Event &event); - virtual bool startAction(CursorType action, Event &event); - }; - - SceneActor _areaActor; - KeypadButton _buttons[16]; - - int _buttonIndex; - - KeypadWindow(); - virtual void synchronize(Serializer &s); - virtual void remove(); - virtual void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY); - virtual void setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum); - }; - - class Keypad : public NamedHotspot { - public: - virtual bool startAction(CursorType action, Event &event); - }; - - /* Actors */ - class Door : public SceneActor { - public: - virtual bool startAction(CursorType action, Event &event); - }; - class Scrolls : public SceneActor { - public: - virtual bool startAction(CursorType action, Event &event); - }; - class Gem : public SceneActor { - public: - virtual bool startAction(CursorType action, Event &event); - }; - class Vampire : public SceneActor { - public: - Common::Point _deadPosition; - int _deltaX; - int _deltaY; - int _vampireMode; - - Vampire(); - void synchronize(Serializer &s); - - virtual void signal(); - virtual bool startAction(CursorType action, Event &event); - }; - - /* Exits */ - class NorthExit : public SceneExit { - public: - virtual void changeScene(); - }; - class UpExit : public SceneExit { - public: - virtual void changeScene(); - }; - class EastExit : public SceneExit { - public: - virtual void changeScene(); - }; - class DownExit : public SceneExit { - public: - virtual void changeScene(); - }; - class SouthExit : public SceneExit { - public: - virtual void changeScene(); - }; - class WestExit : public SceneExit { - public: - virtual void changeScene(); - }; - class ShaftExit : public SceneExit { - public: - virtual void changeScene(); - }; - class DoorExit : public SceneExit { - public: - virtual void changeScene(); - }; -private: - void initArea(); - void enterArea(); - void doButtonPress(int indx); -public: - NamedHotspot _background; - Keypad _keypad; - SceneActor _southDoorway; - SceneObject _northDoorway; - Door _door; - Scrolls _scrolls; - SceneActor _containmentField; - Gem _gem; - SceneActor _cube; - SceneActor _pulsingLights; - Vampire _vampire; - KeypadWindow _KeypadWindow; - NorthExit _northExit; - UpExit _upExit; - EastExit _eastExit; - DownExit _downExit; - SouthExit _southExit; - WestExit _westExit; - ShaftExit _shaftExit; - DoorExit _doorExit; - SequenceManager _sequenceManager; - - bool _upExitStyle; - bool _removeFlag; - bool _vampireActive; - Common::Point _vampireDestPos; - int _vampireIndex; - - Scene1950(); - void synchronize(Serializer &s); - - virtual void postInit(SceneObjectList *OwnerList = NULL); - virtual void remove(); - virtual void signal(); - virtual void process(Event &event); -}; - } // End of namespace Ringworld2 } // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_vampire.cpp b/engines/tsage/ringworld2/ringworld2_vampire.cpp new file mode 100644 index 0000000000..9d3b7f91a5 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_vampire.cpp @@ -0,0 +1,1821 @@ +/* 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 "tsage/ringworld2/ringworld2_vampire.h" + +namespace TsAGE { + +namespace Ringworld2 { + +/*-------------------------------------------------------------------------- + * Scene 1950 - Flup Tube Corridor Maze + * + *--------------------------------------------------------------------------*/ + +Scene1950::KeypadWindow::KeypadWindow() { + _buttonIndex = 0; +} + +void Scene1950::KeypadWindow::synchronize(Serializer &s) { + SceneArea::synchronize(s); + + s.syncAsSint16LE(_buttonIndex); +} + +Scene1950::KeypadWindow::KeypadButton::KeypadButton() { + _buttonIndex = 0; + _pressed = false; + _toggled = false; +} + +void Scene1950::KeypadWindow::KeypadButton::synchronize(Serializer &s) { + SceneActor::synchronize(s); + + s.syncAsSint16LE(_buttonIndex); + s.syncAsSint16LE(_pressed); + s.syncAsSint16LE(_toggled); +} + +void Scene1950::KeypadWindow::KeypadButton::init(int indx) { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _buttonIndex = indx; + _pressed = false; + _toggled = false; + + postInit(); + setup(1971, 2, 1); + fixPriority(249); + setPosition(Common::Point(((_buttonIndex % 4) * 22) + 127, ((_buttonIndex / 4) * 19) + 71)); + scene->_sceneAreas.push_front(this); +} + +void Scene1950::KeypadWindow::KeypadButton::process(Event &event) { + if ((event.eventType == EVENT_BUTTON_DOWN) && (R2_GLOBALS._events.getCursor() == CURSOR_USE) + && (_bounds.contains(event.mousePos)) && !_pressed) { + R2_GLOBALS._sound2.play(227); + if (!_toggled) { + setFrame(2); + _toggled = true; + } else { + setFrame(1); + _toggled = false; + } + _pressed = true; + event.handled = true; + } + + if ((event.eventType == EVENT_BUTTON_UP) && _pressed) { + _pressed = false; + event.handled = true; + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + scene->doButtonPress(_buttonIndex); + } +} + +bool Scene1950::KeypadWindow::KeypadButton::startAction(CursorType action, Event &event) { + if (action == CURSOR_USE) + return false; + return SceneActor::startAction(action, event); +} + +void Scene1950::KeypadWindow::remove() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + for (_buttonIndex = 0; _buttonIndex < 16; ++_buttonIndex) { + scene->_sceneAreas.remove(&_buttons[_buttonIndex]); + _buttons[_buttonIndex].remove(); + } + + ModalWindow::remove(); + + if (!R2_GLOBALS.getFlag(37)) + R2_GLOBALS._sound2.play(278); + + R2_GLOBALS._player.disableControl(CURSOR_WALK); + scene->_eastExit._enabled = true; + + if (!R2_GLOBALS.getFlag(37)) { + if (R2_GLOBALS.getFlag(36)) { + scene->_sceneMode = 1964; + scene->setAction(&scene->_sequenceManager, scene, 1964, &R2_GLOBALS._player, NULL); + } else { + scene->_sceneMode = 1965; + scene->setAction(&scene->_sequenceManager, scene, 1965, &R2_GLOBALS._player, NULL); + } + } +} + +void Scene1950::KeypadWindow::setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY) { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + if (R2_GLOBALS._player._mover) + R2_GLOBALS._player.addMover(NULL); + R2_GLOBALS._player._canWalk = false; + + ModalWindow::setup2(visage, stripFrameNum, frameNum, posX, posY); + + _object1.fixPriority(248); + scene->_eastExit._enabled = false; + setup3(1950, 27, 28, 27); + + for (_buttonIndex = 0; _buttonIndex < 16; _buttonIndex++) + _buttons[_buttonIndex].init(_buttonIndex); +} + +void Scene1950::KeypadWindow::setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum) { + // Copy of Scene1200::LaserPanel::proc13() + _areaActor.setDetails(resNum, lookLineNum, talkLineNum, useLineNum, 2, (SceneItem *) NULL); +} + +/*--------------------------------------------------------------------------*/ + +bool Scene1950::Keypad::startAction(CursorType action, Event &event) { + if ((action != CURSOR_USE) || (R2_GLOBALS.getFlag(37))) + return SceneHotspot::startAction(action, event); + + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(); + if (R2_GLOBALS.getFlag(36)) { + scene->_sceneMode = 1962; + scene->setAction(&scene->_sequenceManager, scene, 1962, &R2_GLOBALS._player, NULL); + } else { + scene->_sceneMode = 1963; + scene->setAction(&scene->_sequenceManager, scene, 1963, &R2_GLOBALS._player, NULL); + } + return true; +} + +bool Scene1950::Door::startAction(CursorType action, Event &event) { + if (action != R2_SCRITH_KEY) + return SceneActor::startAction(action, event); + + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(); + R2_INVENTORY.setObjectScene(R2_SCRITH_KEY, 0); + scene->_sceneMode = 1958; + scene->setAction(&scene->_sequenceManager, scene, 1958, &R2_GLOBALS._player, &scene->_door, NULL); + return true; +} + +bool Scene1950::Scrolls::startAction(CursorType action, Event &event) { + if ((action != CURSOR_USE) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) != 1950)) + return SceneActor::startAction(action, event); + + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1968; + scene->setAction(&scene->_sequenceManager, scene, 1968, &R2_GLOBALS._player, NULL); + + return true; +} + +bool Scene1950::Gem::startAction(CursorType action, Event &event) { + if ((action != CURSOR_USE) || (!R2_GLOBALS.getFlag(37))) + return SceneActor::startAction(action, event); + + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 1967; + scene->setAction(&scene->_sequenceManager, scene, 1967, &R2_GLOBALS._player, NULL); + + return true; +} + +/*--------------------------------------------------------------------------*/ + +Scene1950::Vampire::Vampire() { + _deadPosition = Common::Point(0, 0); + _deltaX = 0; + _deltaY = 0; + _vampireMode = 0; +} + +void Scene1950::Vampire::synchronize(Serializer &s) { + SceneActor::synchronize(s); + + s.syncAsSint16LE(_deadPosition.x); + s.syncAsSint16LE(_deadPosition.y); + s.syncAsSint16LE(_deltaX); + s.syncAsSint16LE(_deltaY); + s.syncAsSint16LE(_vampireMode); +} + +void Scene1950::Vampire::signal() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + switch (_vampireMode) { + case 19: { + _vampireMode = 0; + setVisage(1960); + if (R2_GLOBALS._flubMazeEntryDirection == 3) + setStrip(2); + else + setStrip(1); + + NpcMover *mover = new NpcMover(); + addMover(mover, &scene->_vampireDestPos, scene); + } + break; + case 20: { + // Non fatal shot + _vampireMode = 19; + R2_GLOBALS._player.setVisage(22); + if (R2_GLOBALS._flubMazeEntryDirection == 3) + R2_GLOBALS._player.setStrip(1); + else + R2_GLOBALS._player.setStrip(2); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--; + + if (R2_GLOBALS._flubMazeEntryDirection == 3) + _deadPosition.x = _position.x + 10; + else + _deadPosition.x = _position.x - 10; + _deadPosition.y = _position.y - 4; + + setVisage(1961); + + if (R2_GLOBALS._flubMazeEntryDirection == 3) + setStrip(2); + else + setStrip(1); + + animate(ANIM_MODE_2, NULL); + Common::Point pt = _deadPosition; + PlayerMover *mover = new PlayerMover(); + addMover(mover, &pt, this); + + R2_GLOBALS._player.enableControl(); + } + break; + case 21: { + // Fatal shot + R2_GLOBALS._player.setVisage(22); + if (R2_GLOBALS._flubMazeEntryDirection == 3) + R2_GLOBALS._player.setStrip(1); + else + R2_GLOBALS._player.setStrip(2); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + + setVisage(1961); + if (R2_GLOBALS._flubMazeEntryDirection == 3) + setStrip(4); + else + setStrip(3); + setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL); + addMover(NULL); + _numFrames = 8; + R2_GLOBALS._sound2.play(226); + animate(ANIM_MODE_5, NULL); + fixPriority(10); + + R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive = false; + R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired--; + R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._position = _position; + _deltaX = (_position.x - R2_GLOBALS._player._position.x) / 2; + _deltaY = (_position.y - R2_GLOBALS._player._position.y) / 2; + + byte vampireCount = 0; + for (byte i = 0; i < 18; ++i) { + if (!R2_GLOBALS._vampireData[i]._isAlive) + ++vampireCount; + } + + if (vampireCount == 18) { + R2_GLOBALS.setFlag(36); + _vampireMode = 23; + Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else if (vampireCount == 1) { + _vampireMode = 22; + Common::Point pt(R2_GLOBALS._player._position.x + _deltaX, R2_GLOBALS._player._position.y + _deltaY); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + R2_GLOBALS._player.enableControl(CURSOR_WALK); + } + + if (R2_GLOBALS._flubMazeEntryDirection == 3) + scene->_eastExit._enabled = true; + else + scene->_westExit._enabled = true; + + scene->_vampireActive = false; + } + break; + case 22: + SceneItem::display(1950, 18, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + R2_GLOBALS._player.enableControl(CURSOR_WALK); + break; + case 23: + SceneItem::display(1950, 25, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + scene->_sceneMode = R2_GLOBALS._flubMazeEntryDirection; + scene->setAction(&scene->_sequenceManager, scene, 1960, &R2_GLOBALS._player, NULL); + break; + default: + break; + } +} + +bool Scene1950::Vampire::startAction(CursorType action, Event &event) { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + if (!R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._isAlive || + (action != R2_PHOTON_STUNNER)) + return SceneActor::startAction(action, event); + + R2_GLOBALS._player.disableControl(); + + if (R2_GLOBALS._vampireData[scene->_vampireIndex - 1]._shotsRequired <= 1) + _vampireMode = 21; + else + _vampireMode = 20; + + R2_GLOBALS._player.setVisage(25); + if (R2_GLOBALS._flubMazeEntryDirection == 3) + R2_GLOBALS._player.setStrip(2); + else + R2_GLOBALS._player.setStrip(1); + R2_GLOBALS._player.animate(ANIM_MODE_5, this); + R2_GLOBALS._sound3.play(99); + + return true; +} + +/*--------------------------------------------------------------------------*/ + +void Scene1950::NorthExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 1; + scene->_sceneMode = 11; + + Common::Point pt(160, 127); + PlayerMover *mover = new PlayerMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} + +void Scene1950::UpExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 2; + scene->_sceneMode = 12; + + if (!scene->_upExitStyle) { + if (R2_GLOBALS.getFlag(36)) + scene->setAction(&scene->_sequenceManager, scene, 1953, &R2_GLOBALS._player, NULL); + else + scene->setAction(&scene->_sequenceManager, scene, 1970, &R2_GLOBALS._player, NULL); + } else { + if (R2_GLOBALS.getFlag(36)) + scene->setAction(&scene->_sequenceManager, scene, 1952, &R2_GLOBALS._player, NULL); + else + scene->setAction(&scene->_sequenceManager, scene, 1969, &R2_GLOBALS._player, NULL); + } +} + +void Scene1950::EastExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 3; + scene->_sceneMode = 13; + + if (scene->_vampireActive) + R2_GLOBALS._player.animate(ANIM_MODE_9); + + Common::Point pt(340, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} + +void Scene1950::DownExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 4; + scene->_sceneMode = 14; + + if (R2_GLOBALS.getFlag(36)) + scene->setAction(&scene->_sequenceManager, scene, 1956, &R2_GLOBALS._player, NULL); + else + scene->setAction(&scene->_sequenceManager, scene, 1973, &R2_GLOBALS._player, NULL); +} + +void Scene1950::SouthExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 5; + scene->_sceneMode = 15; + + Common::Point pt(160, 213); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); +} + +void Scene1950::WestExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 6; + + if (R2_GLOBALS._flubMazeArea == 2) { + // In the very first corridor area after the Scrith Door + if ((R2_GLOBALS.getFlag(36)) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 2) && (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2)) { + scene->_sceneMode = 1961; + Common::Point pt(-20, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); + } else { + if (!R2_GLOBALS.getFlag(36)) + SceneItem::display(1950, 33, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + if ((R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) || (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 1950)) + SceneItem::display(1950, 34, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + scene->_sceneMode = 0; + Common::Point pt(30, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); + } + } else { + if (scene->_vampireActive) + R2_GLOBALS._player.animate(ANIM_MODE_9); + + scene->_sceneMode = 16; + Common::Point pt(-20, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); + } +} + +void Scene1950::ShaftExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 0; + scene->_sceneMode = 1951; + scene->setAction(&scene->_sequenceManager, scene, 1951, &R2_GLOBALS._player, NULL); +} + +void Scene1950::DoorExit::changeScene() { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + + _enabled = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._flubMazeEntryDirection = 3; + if (R2_GLOBALS._player._visage == 22) { + scene->_sceneMode = 1975; + scene->setAction(&scene->_sequenceManager, scene, 1975, &R2_GLOBALS._player, NULL); + } else { + SceneItem::display(1950, 22, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + R2_GLOBALS._flubMazeEntryDirection = 0; + scene->_sceneMode = 0; + Common::Point pt(250, 150); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, scene); + _enabled = true; + } +} + +/*--------------------------------------------------------------------------*/ + +Scene1950::Scene1950() { + _upExitStyle = false; + _removeFlag = false; + _vampireActive = false; + _vampireDestPos = Common::Point(0, 0); + _vampireIndex = 0; +} + +void Scene1950::synchronize(Serializer &s) { + SceneExt::synchronize(s); + + s.syncAsSint16LE(_upExitStyle); + s.syncAsSint16LE(_removeFlag); + s.syncAsSint16LE(_vampireActive); + s.syncAsSint16LE(_vampireDestPos.x); + s.syncAsSint16LE(_vampireDestPos.y); + s.syncAsSint16LE(_vampireIndex); +} + +void Scene1950::initArea() { + _northExit._enabled = false; + _upExit._enabled = false; + _eastExit._enabled = false; + _downExit._enabled = false; + _southExit._enabled = false; + _westExit._enabled = false; + _shaftExit._enabled = false; + _doorExit._enabled = false; + _northExit._insideArea = false; + _upExit._insideArea = false; + _eastExit._insideArea = false; + _downExit._insideArea = false; + _southExit._insideArea = false; + _westExit._insideArea = false; + _shaftExit._insideArea = false; + _doorExit._insideArea = false; + _northExit._moving = false; + _upExit._moving = false; + _eastExit._moving = false; + _downExit._moving = false; + _southExit._moving = false; + _westExit._moving = false; + _shaftExit._moving = false; + _doorExit._moving = false; + _upExitStyle = false; + + switch (R2_GLOBALS._flubMazeArea - 1) { + case 0: + loadScene(1948); + break; + case 1: + // No break on purpose + case 8: + // No break on purpose + case 10: + // No break on purpose + case 12: + // No break on purpose + case 16: + // No break on purpose + case 19: + // No break on purpose + case 23: + // No break on purpose + case 30: + // No break on purpose + case 44: + // No break on purpose + case 72: + // No break on purpose + case 74: + // No break on purpose + case 86: + // No break on purpose + case 96: + // No break on purpose + case 103: + loadScene(1950); + break; + case 2: + // No break on purpose + case 29: + loadScene(1965); + break; + case 3: + // No break on purpose + case 9: + // No break on purpose + case 11: + // No break on purpose + case 15: + // No break on purpose + case 24: + // No break on purpose + case 39: + // No break on purpose + case 45: + // No break on purpose + case 71: + // No break on purpose + case 73: + // No break on purpose + case 75: + // No break on purpose + case 79: + // No break on purpose + case 85: + // No break on purpose + case 87: + // No break on purpose + case 95: + loadScene(1955); + break; + case 4: + // No break on purpose + case 6: + // No break on purpose + case 13: + // No break on purpose + case 27: + // No break on purpose + case 41: + // No break on purpose + case 48: + // No break on purpose + case 50: + // No break on purpose + case 54: + // No break on purpose + case 76: + // No break on purpose + case 80: + // No break on purpose + case 90: + // No break on purpose + case 104: + loadScene(1975); + break; + case 5: + // No break on purpose + case 7: + // No break on purpose + case 14: + // No break on purpose + case 28: + // No break on purpose + case 32: + // No break on purpose + case 47: + // No break on purpose + case 53: + loadScene(1997); + break; + case 17: + // No break on purpose + case 20: + // No break on purpose + case 25: + // No break on purpose + case 31: + // No break on purpose + case 33: + // No break on purpose + case 46: + loadScene(1995); + break; + case 18: + // No break on purpose + case 22: + // No break on purpose + case 26: + // No break on purpose + case 36: + // No break on purpose + case 38: + // No break on purpose + case 43: + // No break on purpose + case 51: + // No break on purpose + case 70: + // No break on purpose + case 78: + // No break on purpose + case 84: + // No break on purpose + case 89: + // No break on purpose + case 101: + loadScene(1970); + break; + case 21: + // No break on purpose + case 34: + // No break on purpose + case 57: + // No break on purpose + case 58: + // No break on purpose + case 59: + // No break on purpose + case 62: + // No break on purpose + case 65: + loadScene(1980); + break; + case 35: + // No break on purpose + case 61: + // No break on purpose + case 77: + // No break on purpose + case 83: + loadScene(1982); + break; + case 37: + // No break on purpose + case 52: + // No break on purpose + case 82: + // No break on purpose + case 88: + // No break on purpose + case 92: + // No break on purpose + case 97: + // No break on purpose + case 100: + loadScene(1962); + break; + case 40: + // No break on purpose + case 102: + loadScene(1960); + break; + case 42: + // No break on purpose + case 55: + // No break on purpose + case 60: + // No break on purpose + case 66: + // No break on purpose + case 68: + // No break on purpose + case 69: + // No break on purpose + case 93: + // No break on purpose + case 98: + loadScene(1990); + break; + case 49: + // No break on purpose + case 81: + // No break on purpose + case 91: + // No break on purpose + case 94: + // No break on purpose + case 99: + loadScene(1967); + break; + case 56: + // No break on purpose + case 63: + // No break on purpose + case 64: + // No break on purpose + case 67: + loadScene(1985); + _upExitStyle = true; + break; + default: + break; + } + + if (R2_GLOBALS._flubMazeArea != 1) + R2_GLOBALS._walkRegions.load(1950); + + switch (R2_GLOBALS._flubMazeArea - 1) { + case 0: + _shaftExit._enabled = true; + if ((R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) && (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950)) + _doorExit._enabled = true; + R2_GLOBALS._walkRegions.disableRegion(2); + R2_GLOBALS._walkRegions.disableRegion(3); + R2_GLOBALS._walkRegions.disableRegion(4); + R2_GLOBALS._walkRegions.disableRegion(5); + R2_GLOBALS._walkRegions.disableRegion(6); + break; + case 1: + // No break on purpose + case 2: + // No break on purpose + case 3: + // No break on purpose + case 8: + // No break on purpose + case 9: + // No break on purpose + case 10: + // No break on purpose + case 11: + // No break on purpose + case 12: + // No break on purpose + case 15: + // No break on purpose + case 16: + // No break on purpose + case 19: + // No break on purpose + case 23: + // No break on purpose + case 24: + // No break on purpose + case 29: + // No break on purpose + case 30: + // No break on purpose + case 39: + // No break on purpose + case 40: + // No break on purpose + case 44: + // No break on purpose + case 45: + // No break on purpose + case 71: + // No break on purpose + case 72: + // No break on purpose + case 73: + // No break on purpose + case 74: + // No break on purpose + case 75: + // No break on purpose + case 79: + // No break on purpose + case 85: + // No break on purpose + case 86: + // No break on purpose + case 87: + // No break on purpose + case 95: + // No break on purpose + case 96: + // No break on purpose + case 102: + // No break on purpose + case 103: + _eastExit._enabled = true; + _westExit._enabled = true; + break; + case 4: + // No break on purpose + case 6: + // No break on purpose + case 13: + // No break on purpose + case 17: + // No break on purpose + case 20: + // No break on purpose + case 25: + // No break on purpose + case 27: + // No break on purpose + case 31: + // No break on purpose + case 33: + // No break on purpose + case 37: + // No break on purpose + case 41: + // No break on purpose + case 46: + // No break on purpose + case 48: + // No break on purpose + case 50: + // No break on purpose + case 52: + // No break on purpose + case 54: + // No break on purpose + case 76: + // No break on purpose + case 80: + // No break on purpose + case 82: + // No break on purpose + case 88: + // No break on purpose + case 90: + // No break on purpose + case 92: + // No break on purpose + case 97: + // No break on purpose + case 100: + // No break on purpose + case 104: + _westExit._enabled = true; + R2_GLOBALS._walkRegions.disableRegion(6); + R2_GLOBALS._walkRegions.disableRegion(9); + break; + case 5: + // No break on purpose + case 7: + // No break on purpose + case 14: + // No break on purpose + case 18: + // No break on purpose + case 22: + // No break on purpose + case 26: + // No break on purpose + case 28: + // No break on purpose + case 32: + // No break on purpose + case 36: + // No break on purpose + case 38: + // No break on purpose + case 43: + // No break on purpose + case 47: + // No break on purpose + case 49: + // No break on purpose + case 51: + // No break on purpose + case 53: + // No break on purpose + case 70: + // No break on purpose + case 78: + // No break on purpose + case 81: + // No break on purpose + case 84: + // No break on purpose + case 89: + // No break on purpose + case 91: + // No break on purpose + case 94: + // No break on purpose + case 99: + // No break on purpose + case 101: + _eastExit._enabled = true; + R2_GLOBALS._walkRegions.disableRegion(1); + R2_GLOBALS._walkRegions.disableRegion(7); + R2_GLOBALS._walkRegions.disableRegion(13); + break; + default: + R2_GLOBALS._walkRegions.disableRegion(1); + R2_GLOBALS._walkRegions.disableRegion(6); + R2_GLOBALS._walkRegions.disableRegion(7); + R2_GLOBALS._walkRegions.disableRegion(9); + R2_GLOBALS._walkRegions.disableRegion(13); + break; + } + + _northDoorway.remove(); + _northDoorway.removeObject(); + _southDoorway.remove(); + + switch (R2_GLOBALS._flubMazeArea - 4) { + case 0: + // No break on purpose + case 3: + // No break on purpose + case 16: + // No break on purpose + case 22: + // No break on purpose + case 24: + // No break on purpose + case 32: + // No break on purpose + case 33: + // No break on purpose + case 45: + // No break on purpose + case 46: + // No break on purpose + case 48: + // No break on purpose + case 51: + // No break on purpose + case 56: + // No break on purpose + case 59: + // No break on purpose + case 67: + // No break on purpose + case 68: + // No break on purpose + case 70: + // No break on purpose + case 73: + // No break on purpose + case 82: + // No break on purpose + case 90: + _northExit._enabled = true; + _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25); + //visage,strip,frame,px,py,priority,effect + _southDoorway.postInit(); + _southDoorway.setVisage(1950); + _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); + _southDoorway.setFrame(2); + _southDoorway.setPosition(Common::Point(160, 167)); + _southDoorway.fixPriority(220); + R2_GLOBALS._walkRegions.disableRegion(3); + R2_GLOBALS._walkRegions.disableRegion(4); + break; + case 7: + // No break on purpose + case 10: + // No break on purpose + case 23: + // No break on purpose + case 29: + // No break on purpose + case 31: + // No break on purpose + case 39: + // No break on purpose + case 40: + // No break on purpose + case 52: + // No break on purpose + case 53: + // No break on purpose + case 55: + // No break on purpose + case 63: + // No break on purpose + case 65: + // No break on purpose + case 66: + // No break on purpose + case 75: + // No break on purpose + case 77: + // No break on purpose + case 81: + // No break on purpose + case 87: + // No break on purpose + case 89: + // No break on purpose + case 97: + _southExit._enabled = true; + + _southDoorway.postInit(); + _southDoorway.setVisage(1950); + _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); + _southDoorway.setFrame(3); + _southDoorway.setPosition(Common::Point(160, 167)); + _southDoorway.fixPriority(220); + break; + case 58: + // No break on purpose + case 74: + // No break on purpose + case 80: + _northExit._enabled = true; + _southExit._enabled = true; + + _northDoorway.setup(1950, (R2_GLOBALS._flubMazeArea % 2) + 1, 1, 160, 137, 25); + + _southDoorway.postInit(); + _southDoorway.setVisage(1950); + _southDoorway.setStrip((((R2_GLOBALS._flubMazeArea - 1) / 35) % 2) + 1); + _southDoorway.setFrame(3); + _southDoorway.setPosition(Common::Point(160, 167)); + _southDoorway.fixPriority(220); + R2_GLOBALS._walkRegions.disableRegion(3); + R2_GLOBALS._walkRegions.disableRegion(4); + break; + default: + _southDoorway.postInit(); + _southDoorway.setVisage(1950); + _southDoorway.setStrip(((R2_GLOBALS._flubMazeArea - 1) / 35) % 2 + 1); + _southDoorway.setFrame(2); + _southDoorway.setPosition(Common::Point(160, 167)); + _southDoorway.fixPriority(220); + break; + } + + switch (R2_GLOBALS._flubMazeArea - 3) { + case 0: + // No break on purpose + case 3: + // No break on purpose + case 5: + // No break on purpose + case 12: + // No break on purpose + case 15: + // No break on purpose + case 18: + // No break on purpose + case 19: + // No break on purpose + case 23: + // No break on purpose + case 26: + // No break on purpose + case 27: + // No break on purpose + case 29: + // No break on purpose + case 30: + // No break on purpose + case 31: + // No break on purpose + case 32: + // No break on purpose + case 44: + // No break on purpose + case 45: + // No break on purpose + case 51: + // No break on purpose + case 55: + // No break on purpose + case 56: + // No break on purpose + case 57: + // No break on purpose + case 60: + // No break on purpose + case 63: + _upExit._enabled = true; + break; + case 54: + // No break on purpose + case 61: + // No break on purpose + case 62: + // No break on purpose + case 65: + _upExit._enabled = true; + // No break on purpose + case 35: + // No break on purpose + case 38: + // No break on purpose + case 40: + // No break on purpose + case 47: + // No break on purpose + case 50: + // No break on purpose + case 53: + // No break on purpose + case 58: + // No break on purpose + case 64: + // No break on purpose + case 66: + // No break on purpose + case 67: + // No break on purpose + case 79: + // No break on purpose + case 80: + // No break on purpose + case 86: + // No break on purpose + case 89: + // No break on purpose + case 90: + // No break on purpose + case 91: + // No break on purpose + case 92: + // No break on purpose + case 95: + // No break on purpose + case 96: + // No break on purpose + case 97: + // No break on purpose + case 98: + // No break on purpose + case 100: + _downExit._enabled = true; + R2_GLOBALS._walkRegions.disableRegion(4); + R2_GLOBALS._walkRegions.disableRegion(5); + R2_GLOBALS._walkRegions.disableRegion(6); + R2_GLOBALS._walkRegions.disableRegion(10); + R2_GLOBALS._walkRegions.disableRegion(11); + default: + break; + } + R2_GLOBALS._uiElements.draw(); +} + +void Scene1950::enterArea() { + R2_GLOBALS._player.disableControl(); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + + _vampire.remove(); + _door.remove(); + _scrolls.remove(); + + _vampireActive = false; + _vampireIndex = 0; + + // Certain areas have a vampire in them + switch (R2_GLOBALS._flubMazeArea) { + case 10: + _vampireIndex = 1; + break; + case 13: + _vampireIndex = 2; + break; + case 16: + _vampireIndex = 3; + break; + case 17: + _vampireIndex = 4; + break; + case 24: + _vampireIndex = 5; + break; + case 25: + _vampireIndex = 6; + break; + case 31: + _vampireIndex = 7; + break; + case 40: + _vampireIndex = 8; + break; + case 45: + _vampireIndex = 9; + break; + case 46: + _vampireIndex = 10; + break; + case 73: + _vampireIndex = 11; + break; + case 75: + _vampireIndex = 12; + break; + case 80: + _vampireIndex = 13; + break; + case 87: + _vampireIndex = 14; + break; + case 88: + _vampireIndex = 15; + break; + case 96: + _vampireIndex = 16; + break; + case 97: + _vampireIndex = 17; + break; + case 104: + _vampireIndex = 18; + break; + default: + break; + } + + if (_vampireIndex != 0) { + _vampire.postInit(); + _vampire._numFrames = 6; + _vampire._moveRate = 6; + _vampire._moveDiff = Common::Point(3, 2); + _vampire._effect = EFFECT_SHADED; + + if (!R2_GLOBALS._vampireData[_vampireIndex - 1]._isAlive) { + // Show vampire ashes + _vampire.setPosition(Common::Point(R2_GLOBALS._vampireData[_vampireIndex - 1]._position)); + _vampire.animate(ANIM_MODE_NONE, NULL); + _vampire.addMover(NULL); + _vampire.setVisage(1961); + _vampire.setStrip(4); + _vampire.setFrame(10); + _vampire.fixPriority(10); + _vampire.setDetails(1950, 15, -1, 17, 2, (SceneItem *) NULL); + } else { + // Start the vampire + _vampire.setVisage(1960); + _vampire.setPosition(Common::Point(160, 130)); + _vampire.animate(ANIM_MODE_2, NULL); + _vampire.setDetails(1950, 12, -1, 14, 2, (SceneItem *) NULL); + _vampireActive = true; + } + } + if ((R2_GLOBALS._flubMazeArea == 1) && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) != 0)) { + // Show doorway at the right hand side of the very first flub corridor + _door.postInit(); + _door.setVisage(1948); + _door.setStrip(3); + _door.setPosition(Common::Point(278, 155)); + _door.fixPriority(100); + _door.setDetails(1950, 19, 20, 23, 2, (SceneItem *) NULL); + } + + if (R2_GLOBALS._flubMazeArea == 102) { + R2_GLOBALS._walkRegions.load(1951); + R2_GLOBALS._walkRegions.disableRegion(1); + R2_GLOBALS._walkRegions.disableRegion(5); + R2_GLOBALS._walkRegions.disableRegion(6); + R2_GLOBALS._walkRegions.disableRegion(7); + + _cube.postInit(); + _cube.setVisage(1970); + _cube.setStrip(1); + if (R2_GLOBALS.getFlag(37)) + _cube.setFrame(3); + else + _cube.setFrame(1); + _cube.setPosition(Common::Point(193, 158)); + _cube.setDetails(1950, 3, 4, 5, 2, (SceneItem *) NULL); + + _pulsingLights.postInit(); + _pulsingLights.setVisage(1970); + _pulsingLights.setStrip(3); + _pulsingLights.animate(ANIM_MODE_2, NULL); + _pulsingLights._numFrames = 6; + _pulsingLights.setPosition(Common::Point(194, 158)); + _pulsingLights.fixPriority(159); + + _keypad.setDetails(Rect(188, 124, 199, 133), 1950, 27, 28, -1, 2, NULL); + + if (R2_INVENTORY.getObjectScene(R2_SAPPHIRE_BLUE) == 1950) { + _gem.postInit(); + _gem.setVisage(1970); + _gem.setStrip(1); + _gem.setFrame(2); + _gem.fixPriority(160); + } + + if (R2_GLOBALS.getFlag(37)) { + _gem.setPosition(Common::Point(192, 118)); + _gem.setDetails(1950, 9, 4, -1, 2, (SceneItem *) NULL); + } else { + _containmentField.postInit(); + _containmentField.setVisage(1970); + _containmentField.setStrip(4); + _containmentField._numFrames = 4; + _containmentField.animate(ANIM_MODE_8, 0, NULL); + _containmentField.setPosition(Common::Point(192, 121)); + _containmentField.fixPriority(159); + _containmentField.setDetails(1950, 6, 7, 8, 2, (SceneItem *) NULL); + + _gem.setPosition(Common::Point(192, 109)); + _gem.setDetails(1950, 9, 7, 8, 2, (SceneItem *) NULL); + } + + _scrolls.postInit(); + _scrolls.setVisage(1972); + _scrolls.setStrip(1); + _scrolls.setPosition(Common::Point(76, 94)); + _scrolls.fixPriority(25); + _scrolls.setDetails(1950, 30, -1, -1, 2, (SceneItem *) NULL); + if (R2_INVENTORY.getObjectScene(R2_ANCIENT_SCROLLS) == 2) + _scrolls.setFrame(2); + else + _scrolls.setFrame(1); + + _removeFlag = true; + } else if (_removeFlag) { + _cube.remove(); + _containmentField.remove(); + _gem.remove(); + _pulsingLights.remove(); + _scrolls.remove(); + + R2_GLOBALS._sceneItems.remove(&_background); + _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 2, NULL); + + _removeFlag = false; + } + + switch (R2_GLOBALS._flubMazeEntryDirection) { + case 0: + _sceneMode = 1950; + if (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0) + // The original uses CURSOR_ARROW. CURSOR_WALK is much more coherent + R2_GLOBALS._player.enableControl(CURSOR_WALK); + else + setAction(&_sequenceManager, this, 1950, &R2_GLOBALS._player, NULL); + + break; + case 1: { + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + R2_GLOBALS._player.setPosition(Common::Point(160, 213)); + Common::Point pt(160, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + break; + case 2: + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + if (R2_GLOBALS.getFlag(36)) + setAction(&_sequenceManager, this, 1957, &R2_GLOBALS._player, NULL); + else + setAction(&_sequenceManager, this, 1974, &R2_GLOBALS._player, NULL); + break; + case 3: + // Entering from the left + if (!_vampireActive) { + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + R2_GLOBALS._player.setPosition(Common::Point(-20, 160)); + Common::Point pt(30, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } else { + _sceneMode = 18; + _eastExit._enabled = false; + _vampireDestPos = Common::Point(60, 152); + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + + _vampire.setStrip(2); + NpcMover *mover = new NpcMover(); + _vampire.addMover(mover, &_vampireDestPos, this); + + R2_GLOBALS._player.setPosition(Common::Point(-20, 160)); + Common::Point pt2(30, 160); + NpcMover *mover2 = new NpcMover(); + R2_GLOBALS._player.addMover(mover2, &pt2, NULL); + } + break; + case 4: + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + if (!_upExitStyle) { + if (R2_GLOBALS.getFlag(36)) + setAction(&_sequenceManager, this, 1955, &R2_GLOBALS._player, NULL); + else + setAction(&_sequenceManager, this, 1972, &R2_GLOBALS._player, NULL); + } else { + if (R2_GLOBALS.getFlag(36)) + setAction(&_sequenceManager, this, 1954, &R2_GLOBALS._player, NULL); + else + setAction(&_sequenceManager, this, 1971, &R2_GLOBALS._player, NULL); + } + break; + case 5: { + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + R2_GLOBALS._player.setPosition(Common::Point(160, 127)); + Common::Point pt(160, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + break; + case 6: + // Entering from the right + if (!_vampireActive) { + _sceneMode = R2_GLOBALS._flubMazeEntryDirection; + if (R2_GLOBALS._flubMazeArea == 1) { + setAction(&_sequenceManager, this, 1961, &R2_GLOBALS._player, NULL); + } else { + R2_GLOBALS._player.setPosition(Common::Point(340, 160)); + Common::Point pt(289, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + } else { + _sceneMode = 17; + _westExit._enabled = false; + _vampireDestPos = Common::Point(259, 152); + + R2_GLOBALS._player.enableControl(CURSOR_USE); + R2_GLOBALS._player._canWalk = false; + + _vampire.setStrip(1); + NpcMover *mover = new NpcMover(); + _vampire.addMover(mover, &_vampireDestPos, this); + + R2_GLOBALS._player.setPosition(Common::Point(340, 160)); + Common::Point pt2(289, 160); + NpcMover *mover2 = new NpcMover(); + R2_GLOBALS._player.addMover(mover2, &pt2, NULL); + } + break; + default: + break; + } +} + +void Scene1950::doButtonPress(int indx) { + Scene1950 *scene = (Scene1950 *)R2_GLOBALS._sceneManager._scene; + R2_GLOBALS._player.disableControl(); + + int prevIndex = indx - 1; + if ((indx / 4) == (prevIndex / 4)) { + if (prevIndex < 0) + prevIndex = 3; + } else { + prevIndex += 4; + } + + assert(prevIndex >= 0 && prevIndex < 16); + if (!_KeypadWindow._buttons[prevIndex]._toggled) { + _KeypadWindow._buttons[prevIndex].setFrame(2); + _KeypadWindow._buttons[prevIndex]._toggled = true; + } else { + _KeypadWindow._buttons[prevIndex].setFrame(1); + _KeypadWindow._buttons[prevIndex]._toggled = false; + } + + prevIndex = indx + 1; + if ((indx / 4) == (prevIndex / 4)) { + if (prevIndex > 15) + prevIndex = 12; + } else { + prevIndex -= 4; + } + + assert(prevIndex >= 0 && prevIndex < 16); + if (!_KeypadWindow._buttons[prevIndex]._toggled) { + _KeypadWindow._buttons[prevIndex].setFrame(2); + _KeypadWindow._buttons[prevIndex]._toggled = true; + } else { + _KeypadWindow._buttons[prevIndex].setFrame(1); + _KeypadWindow._buttons[prevIndex]._toggled = false; + } + + prevIndex = indx - 4; + if (prevIndex < 0) + prevIndex += 16; + + assert(prevIndex >= 0 && prevIndex < 16); + if (!_KeypadWindow._buttons[prevIndex]._toggled) { + _KeypadWindow._buttons[prevIndex].setFrame(2); + _KeypadWindow._buttons[prevIndex]._toggled = true; + } else { + _KeypadWindow._buttons[prevIndex].setFrame(1); + _KeypadWindow._buttons[prevIndex]._toggled = false; + } + + prevIndex = indx + 4; + if (prevIndex > 15) + prevIndex -= 16; + + assert(prevIndex >= 0 && prevIndex < 16); + if (!_KeypadWindow._buttons[prevIndex]._toggled) { + _KeypadWindow._buttons[prevIndex].setFrame(2); + _KeypadWindow._buttons[prevIndex]._toggled = true; + } else { + _KeypadWindow._buttons[prevIndex].setFrame(1); + _KeypadWindow._buttons[prevIndex]._toggled = false; + } + + // Check whether all the buttons are highlighted + int cpt = 0; + for (prevIndex = 0; prevIndex < 16; prevIndex++) { + if (_KeypadWindow._buttons[prevIndex]._toggled) + ++cpt; + } + + if (cpt != 16) { + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._canWalk = false; + } else { + R2_GLOBALS.setFlag(37); + _sceneMode = 24; + setAction(&_sequenceManager, scene, 1976, NULL); + } +} + +void Scene1950::postInit(SceneObjectList *OwnerList) { + _upExitStyle = false; + _removeFlag = false; + _vampireActive = false; + _vampireIndex = 0; + if (R2_GLOBALS._sceneManager._previousScene == 300) + R2_GLOBALS._flubMazeArea = 103; + + initArea(); + SceneExt::postInit(); + R2_GLOBALS._sound1.play(105); + + _northExit.setDetails(Rect(130, 46, 189, 135), SHADECURSOR_UP, 1950); + _northExit.setDest(Common::Point(160, 145)); + + _upExit.setDetails(Rect(208, 0, 255, 73), EXITCURSOR_N, 1950); + _upExit.setDest(Common::Point(200, 151)); + + _eastExit.setDetails(Rect(305, 95, 320, 147), EXITCURSOR_E, 1950); + _eastExit.setDest(Common::Point(312, 160)); + + _downExit.setDetails(Rect(208, 99, 255, 143), EXITCURSOR_S, 1950); + _downExit.setDest(Common::Point(200, 151)); + + _southExit.setDetails(Rect(113, 154, 206, 168), SHADECURSOR_DOWN, 1950); + _southExit.setDest(Common::Point(160, 165)); + + _westExit.setDetails(Rect(0, 95, 14, 147), EXITCURSOR_W, 1950); + _westExit.setDest(Common::Point(7, 160)); + + _shaftExit.setDetails(Rect(72, 54, 120, 128), EXITCURSOR_NW, 1950); + _shaftExit.setDest(Common::Point(120, 140)); + + _doorExit.setDetails(Rect(258, 60, 300, 145), EXITCURSOR_NE, 1950); + _doorExit.setDest(Common::Point(268, 149)); + + R2_GLOBALS._player.postInit(); + if ( (R2_INVENTORY.getObjectScene(R2_TANNER_MASK) == 0) && (R2_INVENTORY.getObjectScene(R2_PURE_GRAIN_ALCOHOL) == 0) + && (R2_INVENTORY.getObjectScene(R2_SOAKED_FACEMASK) == 0) && (!R2_GLOBALS.getFlag(36)) ) + R2_GLOBALS._player.setVisage(22); + else + R2_GLOBALS._player.setVisage(20); + + R2_GLOBALS._player._moveDiff = Common::Point(5, 3); + _background.setDetails(Rect(0, 0, 320, 200), 1950, 0, 1, 2, 1, NULL); + + enterArea(); +} + +void Scene1950::remove() { + R2_GLOBALS._sound1.stop(); + R2_GLOBALS._sound2.fadeOut2(NULL); + SceneExt::remove(); +} + +void Scene1950::signal() { + switch (_sceneMode) { + case 11: + R2_GLOBALS._flubMazeArea += 7; + initArea(); + enterArea(); + break; + case 12: + // Moving up a ladder within the Flub maze + R2_GLOBALS._flubMazeArea += 35; + initArea(); + enterArea(); + break; + case 1975: + SceneItem::display(1950, 21, SET_WIDTH, 280, SET_X, 160, SET_POS_MODE, 1, + SET_Y, 20, SET_EXT_BGCOLOR, 7, LIST_END); + // No break on purpose + case 13: + // Moving east within the Flub maze + ++R2_GLOBALS._flubMazeArea; + initArea(); + enterArea(); + break; + case 14: + // Moving down a ladder within the Flub maze + R2_GLOBALS._flubMazeArea -= 35; + initArea(); + enterArea(); + break; + case 15: + R2_GLOBALS._flubMazeArea -= 7; + initArea(); + enterArea(); + break; + case 16: + // Moving west within the Flub maze + // No break on purpose + case 1961: + --R2_GLOBALS._flubMazeArea; + initArea(); + enterArea(); + break; + case 17: { + _sceneMode = 13; + R2_GLOBALS._flubMazeEntryDirection = 3; + _vampireActive = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._player._canWalk = true; + R2_GLOBALS._player.setVisage(22); + R2_GLOBALS._player.animate(ANIM_MODE_9); + Common::Point pt(340, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + Common::Point pt2(289, 160); + NpcMover *mover2 = new NpcMover(); + _vampire.addMover(mover2, &pt2, NULL); + } + break; + case 18: { + _sceneMode = 16; + R2_GLOBALS._flubMazeEntryDirection = 6; + _vampireActive = false; + R2_GLOBALS._player.disableControl(CURSOR_WALK); + R2_GLOBALS._player._canWalk = true; + R2_GLOBALS._player.setVisage(22); + R2_GLOBALS._player.animate(ANIM_MODE_9); + Common::Point pt(-20, 160); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + Common::Point pt2(30, 160); + NpcMover *mover2 = new NpcMover(); + _vampire.addMover(mover2, &pt2, NULL); + } + break; + case 24: + _KeypadWindow.remove(); + _sceneMode = 1966; + _cube.setFrame(3); + setAction(&_sequenceManager, this, 1966, &_containmentField, &_gem, NULL); + break; + case 1951: + R2_GLOBALS._sound1.fadeOut2(NULL); + R2_GLOBALS._sceneManager.changeScene(1945); + break; + case 1958: + SceneItem::display(1950, 24, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + R2_GLOBALS._player.enableControl(CURSOR_WALK); + _doorExit._enabled = true; + break; + case 1959: + R2_INVENTORY.setObjectScene(R2_SOAKED_FACEMASK, 0); + R2_GLOBALS._player.enableControl(CURSOR_WALK); + _doorExit._enabled = true; + break; + case 1962: + // No break on purpose + case 1963: + R2_GLOBALS._player.enableControl(); + _KeypadWindow.setup2(1971, 1, 1, 160, 135); + break; + case 1964: + // No break on purpose + case 1965: + if (!R2_GLOBALS.getFlag(37)) + SceneItem::display(1950, 26, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, LIST_END); + + R2_GLOBALS._player.enableControl(); + break; + case 1966: + _containmentField.remove(); + if (R2_GLOBALS.getFlag(36)) { + _sceneMode = 1964; + setAction(&_sequenceManager, this, 1964, &R2_GLOBALS._player, NULL); + } else { + _sceneMode = 1965; + setAction(&_sequenceManager, this, 1965, &R2_GLOBALS._player, NULL); + } + _gem.setDetails(1950, 9, -1, -1, 2, (SceneItem *) NULL); + break; + case 1967: { + _sceneMode = 0; + R2_INVENTORY.setObjectScene(R2_SAPPHIRE_BLUE, 2); + _gem.remove(); + if (R2_GLOBALS.getFlag(36)) + R2_GLOBALS._player.setVisage(20); + else + R2_GLOBALS._player.setVisage(22); + + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + // This is a hack to work around a pathfinding issue. original destination is (218, 165) + Common::Point pt(128, 165); + NpcMover *mover = new NpcMover(); + R2_GLOBALS._player.addMover(mover, &pt, this); + } + break; + case 1968: + R2_GLOBALS._player.enableControl(); + R2_INVENTORY.setObjectScene(R2_ANCIENT_SCROLLS, 2); + _scrolls.setFrame(2); + if (R2_GLOBALS.getFlag(36)) + R2_GLOBALS._player.setVisage(20); + else + R2_GLOBALS._player.setVisage(22); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + break; + default: + R2_GLOBALS._player.enableControl(CURSOR_WALK); + break; + } +} + +void Scene1950::process(Event &event) { + if ( (event.eventType == EVENT_BUTTON_DOWN) + && (R2_GLOBALS._player._uiEnabled) + && (R2_GLOBALS._events.getCursor() == R2_SOAKED_FACEMASK) + && (R2_GLOBALS._player._bounds.contains(event.mousePos)) + && (R2_INVENTORY.getObjectScene(R2_SCRITH_KEY) == 0)) { + event.handled = true; + R2_GLOBALS._player.disableControl(); + _shaftExit._enabled = false; + _doorExit._enabled = false; + _sceneMode = 1959; + setAction(&_sequenceManager, this, 1959, &R2_GLOBALS._player, NULL); + } + + Scene::process(event); +} + +} // End of namespace Ringworld2 +} // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_vampire.h b/engines/tsage/ringworld2/ringworld2_vampire.h new file mode 100644 index 0000000000..f2539421f1 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_vampire.h @@ -0,0 +1,180 @@ +/* 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 TSAGE_RINGWORLD2_VAMPIRE_H +#define TSAGE_RINGWORLD2_VAMPIRE_H + +#include "tsage/converse.h" +#include "tsage/events.h" +#include "tsage/core.h" +#include "tsage/scenes.h" +#include "tsage/globals.h" +#include "tsage/sound.h" +#include "tsage/ringworld2/ringworld2_logic.h" + +namespace TsAGE { + +namespace Ringworld2 { + +using namespace TsAGE; + +class Scene1950 : public SceneExt { + /* Windows */ + class KeypadWindow: public ModalWindow { + public: + class KeypadButton : public SceneActor { + public: + int _buttonIndex; + bool _pressed; + bool _toggled; + + KeypadButton(); + void synchronize(Serializer &s); + + void init(int indx); + virtual void process(Event &event); + virtual bool startAction(CursorType action, Event &event); + }; + + SceneActor _areaActor; + KeypadButton _buttons[16]; + + int _buttonIndex; + + KeypadWindow(); + virtual void synchronize(Serializer &s); + virtual void remove(); + virtual void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY); + virtual void setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum); + }; + + class Keypad : public NamedHotspot { + public: + virtual bool startAction(CursorType action, Event &event); + }; + + /* Actors */ + class Door : public SceneActor { + public: + virtual bool startAction(CursorType action, Event &event); + }; + class Scrolls : public SceneActor { + public: + virtual bool startAction(CursorType action, Event &event); + }; + class Gem : public SceneActor { + public: + virtual bool startAction(CursorType action, Event &event); + }; + class Vampire : public SceneActor { + public: + Common::Point _deadPosition; + int _deltaX; + int _deltaY; + int _vampireMode; + + Vampire(); + void synchronize(Serializer &s); + + virtual void signal(); + virtual bool startAction(CursorType action, Event &event); + }; + + /* Exits */ + class NorthExit : public SceneExit { + public: + virtual void changeScene(); + }; + class UpExit : public SceneExit { + public: + virtual void changeScene(); + }; + class EastExit : public SceneExit { + public: + virtual void changeScene(); + }; + class DownExit : public SceneExit { + public: + virtual void changeScene(); + }; + class SouthExit : public SceneExit { + public: + virtual void changeScene(); + }; + class WestExit : public SceneExit { + public: + virtual void changeScene(); + }; + class ShaftExit : public SceneExit { + public: + virtual void changeScene(); + }; + class DoorExit : public SceneExit { + public: + virtual void changeScene(); + }; +private: + void initArea(); + void enterArea(); + void doButtonPress(int indx); +public: + NamedHotspot _background; + Keypad _keypad; + SceneActor _southDoorway; + SceneObject _northDoorway; + Door _door; + Scrolls _scrolls; + SceneActor _containmentField; + Gem _gem; + SceneActor _cube; + SceneActor _pulsingLights; + Vampire _vampire; + KeypadWindow _KeypadWindow; + NorthExit _northExit; + UpExit _upExit; + EastExit _eastExit; + DownExit _downExit; + SouthExit _southExit; + WestExit _westExit; + ShaftExit _shaftExit; + DoorExit _doorExit; + SequenceManager _sequenceManager; + + bool _upExitStyle; + bool _removeFlag; + bool _vampireActive; + Common::Point _vampireDestPos; + int _vampireIndex; + + Scene1950(); + void synchronize(Serializer &s); + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); + virtual void process(Event &event); +}; + +} // End of namespace Ringworld2 +} // End of namespace TsAGE + +#endif -- cgit v1.2.3 From fa5c22393138034efceb908e012f6783b65f36f5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 16 Oct 2014 08:07:38 +0200 Subject: TSAGE: R2R - Remove useless includes --- engines/tsage/ringworld2/ringworld2_airduct.cpp | 5 ----- engines/tsage/ringworld2/ringworld2_airduct.h | 1 - engines/tsage/ringworld2/ringworld2_outpost.cpp | 2 -- engines/tsage/ringworld2/ringworld2_outpost.h | 3 --- engines/tsage/ringworld2/ringworld2_vampire.h | 1 - 5 files changed, 12 deletions(-) diff --git a/engines/tsage/ringworld2/ringworld2_airduct.cpp b/engines/tsage/ringworld2/ringworld2_airduct.cpp index dc43dba1ae..136e8d5d1b 100644 --- a/engines/tsage/ringworld2/ringworld2_airduct.cpp +++ b/engines/tsage/ringworld2/ringworld2_airduct.cpp @@ -20,11 +20,6 @@ * */ -#include "graphics/cursorman.h" - -#include "tsage/scenes.h" -#include "tsage/tsage.h" -#include "tsage/staticres.h" #include "tsage/ringworld2/ringworld2_airduct.h" namespace TsAGE { diff --git a/engines/tsage/ringworld2/ringworld2_airduct.h b/engines/tsage/ringworld2/ringworld2_airduct.h index 4a89f58c96..89dfe778d0 100644 --- a/engines/tsage/ringworld2/ringworld2_airduct.h +++ b/engines/tsage/ringworld2/ringworld2_airduct.h @@ -23,7 +23,6 @@ #ifndef TSAGE_RINGWORLD2_AIRDUCT_H #define TSAGE_RINGWORLD2_AIRDUCT_H -#include "tsage/converse.h" #include "tsage/events.h" #include "tsage/core.h" #include "tsage/scenes.h" diff --git a/engines/tsage/ringworld2/ringworld2_outpost.cpp b/engines/tsage/ringworld2/ringworld2_outpost.cpp index 5766102c9a..05cfa6259b 100644 --- a/engines/tsage/ringworld2/ringworld2_outpost.cpp +++ b/engines/tsage/ringworld2/ringworld2_outpost.cpp @@ -21,8 +21,6 @@ */ #include "graphics/cursorman.h" - -#include "tsage/scenes.h" #include "tsage/tsage.h" #include "tsage/staticres.h" #include "tsage/ringworld2/ringworld2_outpost.h" diff --git a/engines/tsage/ringworld2/ringworld2_outpost.h b/engines/tsage/ringworld2/ringworld2_outpost.h index b3e663356e..6c6952c196 100644 --- a/engines/tsage/ringworld2/ringworld2_outpost.h +++ b/engines/tsage/ringworld2/ringworld2_outpost.h @@ -23,15 +23,12 @@ #ifndef TSAGE_RINGWORLD2_OUTPOST_H #define TSAGE_RINGWORLD2_OUTPOST_H -#include "common/scummsys.h" -#include "tsage/converse.h" #include "tsage/events.h" #include "tsage/core.h" #include "tsage/scenes.h" #include "tsage/globals.h" #include "tsage/sound.h" #include "tsage/ringworld2/ringworld2_logic.h" -#include "tsage/ringworld2/ringworld2_speakers.h" namespace TsAGE { diff --git a/engines/tsage/ringworld2/ringworld2_vampire.h b/engines/tsage/ringworld2/ringworld2_vampire.h index f2539421f1..ca7aa34544 100644 --- a/engines/tsage/ringworld2/ringworld2_vampire.h +++ b/engines/tsage/ringworld2/ringworld2_vampire.h @@ -23,7 +23,6 @@ #ifndef TSAGE_RINGWORLD2_VAMPIRE_H #define TSAGE_RINGWORLD2_VAMPIRE_H -#include "tsage/converse.h" #include "tsage/events.h" #include "tsage/core.h" #include "tsage/scenes.h" -- cgit v1.2.3 From dee4fd193d690baae5afaf906d7604a9df9155ef Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 16 Oct 2014 21:53:21 -0400 Subject: MADS: Fix stopping digital audio, music, and palette cycling when animation ends --- engines/mads/audio.cpp | 4 ++++ engines/mads/audio.h | 1 + engines/mads/menu_views.cpp | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp index 9d62c3f615..def2cd6c62 100644 --- a/engines/mads/audio.cpp +++ b/engines/mads/audio.cpp @@ -129,4 +129,8 @@ void AudioPlayer::playSound(int soundIndex, bool loop) { */ } +void AudioPlayer::stop() { + _mixer->stopHandle(_handle); +} + } // End of namespace M4 diff --git a/engines/mads/audio.h b/engines/mads/audio.h index 21f4bed59a..13c540bf85 100644 --- a/engines/mads/audio.h +++ b/engines/mads/audio.h @@ -46,6 +46,7 @@ public: void setSoundGroup(const Common::String &filename); void setDefaultSoundGroup(); void playSound(int soundIndex, bool loop = false); + void stop(); void setVolume(int volume); bool isPlaying() const; diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp index 6acf6cdf9f..857db68fa6 100644 --- a/engines/mads/menu_views.cpp +++ b/engines/mads/menu_views.cpp @@ -475,6 +475,13 @@ AnimationView::AnimationView(MADSEngine *vm) : MenuView(vm) { } AnimationView::~AnimationView() { + // Turn off palette cycling as well as any playing sound + Scene &scene = _vm->_game->_scene; + scene._cyclingActive = false; + _vm->_sound->stop(); + _vm->_audio->stop(); + + // Delete data delete _currentAnimation; delete _sceneInfo; } @@ -505,7 +512,7 @@ void AnimationView::display() { bool AnimationView::onEvent(Common::Event &event) { // Wait for the Escape key or a mouse press if (((event.type == Common::EVENT_KEYDOWN) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) || - (event.type == Common::EVENT_RBUTTONUP)) { + (event.type == Common::EVENT_LBUTTONUP)) { scriptDone(); return true; } -- cgit v1.2.3 From 497324467f86656b747022661852255d1f3343fb Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 17 Oct 2014 19:17:17 +0200 Subject: TINSEL: Move object creation from constructor to run() Moved the creation of _midiMusic, _pcmMusic, _sound and _bmv from the constructor to run(). It was reported on the forum that the MT-32 emulator didn't work for Discworld, and I'm speculating that this is because it was being initialized before the "extra path" had been added to the search path. It's likely that not all of these objects are needed for every version of the game. Fixing that is left as an exercise for someone more familiar with the different game versions than me. --- engines/tinsel/tinsel.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp index 31610a8467..57d8432f0e 100644 --- a/engines/tinsel/tinsel.cpp +++ b/engines/tinsel/tinsel.cpp @@ -821,7 +821,8 @@ const char *const TinselEngine::_textFiles[][3] = { TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) : - Engine(syst), _gameDescription(gameDesc), _random("tinsel") { + Engine(syst), _gameDescription(gameDesc), _random("tinsel"), + _sound(0), _midiMusic(0), _pcmMusic(0), _bmv(0) { _vm = this; _config = new Config(this); @@ -846,13 +847,6 @@ TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) if (cd_num >= 0) _system->getAudioCDManager()->openCD(cd_num); - _midiMusic = new MidiMusicPlayer(); - _pcmMusic = new PCMMusicPlayer(); - - _sound = new SoundManager(this); - - _bmv = new BMVPlayer(); - _mousePos.x = 0; _mousePos.y = 0; _keyHandler = NULL; @@ -896,6 +890,11 @@ void TinselEngine::initializePath(const Common::FSNode &gamePath) { } Common::Error TinselEngine::run() { + _midiMusic = new MidiMusicPlayer(); + _pcmMusic = new PCMMusicPlayer(); + _sound = new SoundManager(this); + _bmv = new BMVPlayer(); + // Initialize backend if (getGameID() == GID_DW2) { #ifndef DW2_EXACT_SIZE -- cgit v1.2.3 From 17a77ff69ced1c04e0520336c14e05fbf993108d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 14:59:16 +0300 Subject: SCI: Fix some typos, and remove some redundant curly braces --- engines/sci/detection.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 4f28738508..245b5646cc 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -563,9 +563,8 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, // If these files aren't found, it can't be SCI - if (!foundResMap && !foundRes000) { + if (!foundResMap && !foundRes000) return 0; - } ResourceManager resMan; resMan.addAppropriateSources(fslist); @@ -575,19 +574,17 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, #ifndef ENABLE_SCI32 // Is SCI32 compiled in? If not, and this is a SCI32 game, // stop here - if (getSciVersion() >= SCI_VERSION_2) { - return (const ADGameDescription *)&s_fallbackDesc; - } + if (getSciVersion() >= SCI_VERSION_2) + return 0; #endif ViewType gameViews = resMan.getViewType(); // Have we identified the game views? If not, stop here - // Can't be SCI (or unsupported SCI views). Pinball Creep by sierra also uses resource.map/resource.000 files - // but doesnt share sci format at all, if we dont return 0 here we will detect this game as SCI - if (gameViews == kViewUnknown) { + // Can't be SCI (or unsupported SCI views). Pinball Creep by Sierra also uses resource.map/resource.000 files + // but doesn't share SCI format at all + if (gameViews == kViewUnknown) return 0; - } // Set the platform to Amiga if the game is using Amiga views if (gameViews == kViewAmiga) @@ -597,9 +594,8 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, Common::String sierraGameId = resMan.findSierraGameId(); // If we don't have a game id, the game is not SCI - if (sierraGameId.empty()) { + if (sierraGameId.empty()) return 0; - } Common::String gameId = convertSierraGameId(sierraGameId, &s_fallbackDesc.flags, resMan); strncpy(s_fallbackGameIdBuf, gameId.c_str(), sizeof(s_fallbackGameIdBuf) - 1); -- cgit v1.2.3 From fe3ed8ded270510a6233a2ca2376befeceeed0e4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 15:02:32 +0300 Subject: SCI: Rename the version of addAppropriateSources() used in detection --- engines/sci/detection.cpp | 2 +- engines/sci/resource.cpp | 7 ++----- engines/sci/resource.h | 9 ++++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 245b5646cc..7176a18b46 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -567,7 +567,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, return 0; ResourceManager resMan; - resMan.addAppropriateSources(fslist); + resMan.addAppropriateSourcesForDetection(fslist); resMan.init(true); // TODO: Add error handling. diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 17195c14b8..f690f03cac 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -88,9 +88,6 @@ const char *getSciVersionDesc(SciVersion version) { ////////////////////////////////////////////////////////////////////// - -#undef SCI_REQUIRE_RESOURCE_FILES - //#define SCI_VERBOSE_RESMAN 1 static const char *const s_errorDescriptions[] = { @@ -639,7 +636,7 @@ int ResourceManager::addAppropriateSources() { return 1; } -int ResourceManager::addAppropriateSources(const Common::FSList &fslist) { +int ResourceManager::addAppropriateSourcesForDetection(const Common::FSList &fslist) { ResourceSource *map = 0; Common::Array sci21Maps; @@ -890,7 +887,7 @@ void ResourceManager::init(bool initFromFallbackDetector) { debugC(1, kDebugLevelResMan, "resMan: Detected volume version %d: %s", _volVersion, versionDescription(_volVersion)); if ((_mapVersion == kResVersionUnknown) && (_volVersion == kResVersionUnknown)) { - warning("Volume and map version not detected, assuming that this is not a sci game"); + warning("Volume and map version not detected, assuming that this is not a SCI game"); _viewType = kViewUnknown; return; } diff --git a/engines/sci/resource.h b/engines/sci/resource.h index e90f52a3ce..8260ddb27e 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -314,8 +314,15 @@ public: */ void init(bool initFromFallbackDetector = false); + /** + * Adds all of the resource files for a game + */ int addAppropriateSources(); - int addAppropriateSources(const Common::FSList &fslist); // TODO: Switch from FSList to Common::Archive? + + /** + * Similar to the function above, only called from the fallback detector + */ + int addAppropriateSourcesForDetection(const Common::FSList &fslist); // TODO: Switch from FSList to Common::Archive? /** * Looks up a resource's data. -- cgit v1.2.3 From 4736c490e1d3182f58db8a51b400f96b9559dad8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 15:33:07 +0300 Subject: SCI: Separate the rest of the detection-only functions This should fix bug #6717 - "SCI fallback detection assert failure" --- engines/sci/detection.cpp | 4 ++-- engines/sci/resource.cpp | 45 ++++++++++++++++++++++++++++++++++----------- engines/sci/resource.h | 7 ++++++- engines/sci/sci.h | 6 ++++++ 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 7176a18b46..85ff1c0062 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -568,13 +568,13 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const FileMap &allFiles, ResourceManager resMan; resMan.addAppropriateSourcesForDetection(fslist); - resMan.init(true); + resMan.initForDetection(); // TODO: Add error handling. #ifndef ENABLE_SCI32 // Is SCI32 compiled in? If not, and this is a SCI32 game, // stop here - if (getSciVersion() >= SCI_VERSION_2) + if (getSciVersionForDetection() >= SCI_VERSION_2) return 0; #endif diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index f690f03cac..d155792853 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -55,6 +55,11 @@ SciVersion getSciVersion() { return s_sciVersion; } +SciVersion getSciVersionForDetection() { + assert(!g_sci); + return s_sciVersion; +} + const char *getSciVersionDesc(SciVersion version) { switch (version) { case SCI_VERSION_NONE: @@ -855,7 +860,7 @@ void ResourceManager::freeResourceSources() { ResourceManager::ResourceManager() { } -void ResourceManager::init(bool initFromFallbackDetector) { +void ResourceManager::init() { _memoryLocked = 0; _memoryLRU = 0; _LRU.clear(); @@ -894,18 +899,17 @@ void ResourceManager::init(bool initFromFallbackDetector) { scanNewSources(); - if (!initFromFallbackDetector) { - if (!addAudioSources()) { - // FIXME: This error message is not always correct. - // OTOH, it is nice to be able to detect missing files/sources - // So we should definitely fix addAudioSources so this error - // only pops up when necessary. Disabling for now. - //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting"); - } - addScriptChunkSources(); - scanNewSources(); + if (!addAudioSources()) { + // FIXME: This error message is not always correct. + // OTOH, it is nice to be able to detect missing files/sources + // So we should definitely fix addAudioSources so this error + // only pops up when necessary. Disabling for now. + //error("Somehow I can't seem to find the sound files I need (RESOURCE.AUD/RESOURCE.SFX), aborting"); } + addScriptChunkSources(); + scanNewSources(); + detectSciVersion(); debugC(1, kDebugLevelResMan, "resMan: Detected %s", getSciVersionDesc(getSciVersion())); @@ -940,6 +944,22 @@ void ResourceManager::init(bool initFromFallbackDetector) { } } +void ResourceManager::initForDetection() { + assert(!g_sci); + + _memoryLocked = 0; + _memoryLRU = 0; + _LRU.clear(); + _resMap.clear(); + _audioMapSCI1 = NULL; + + _mapVersion = detectMapVersion(); + _volVersion = detectVolVersion(); + + scanNewSources(); + detectSciVersion(); +} + ResourceManager::~ResourceManager() { // freeing resources ResourceMap::iterator itr = _resMap.begin(); @@ -1642,6 +1662,9 @@ int ResourceManager::readResourceMapSCI1(ResourceSource *map) { do { type = fileStream->readByte() & 0x1F; resMap[type].wOffset = fileStream->readUint16LE(); + if (fileStream->eos()) + return SCI_ERROR_RESMAP_NOT_FOUND; + resMap[prevtype].wSize = (resMap[type].wOffset - resMap[prevtype].wOffset) / nEntrySize; prevtype = type; diff --git a/engines/sci/resource.h b/engines/sci/resource.h index 8260ddb27e..62f3c584ac 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -312,7 +312,12 @@ public: /** * Initializes the resource manager. */ - void init(bool initFromFallbackDetector = false); + void init(); + + /** + * Similar to the function above, only called from the fallback detector + */ + void initForDetection(); /** * Adds all of the resource files for a game diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 48bc4819d2..2377386c72 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -428,6 +428,12 @@ extern SciEngine *g_sci; */ SciVersion getSciVersion(); +/** + * Same as above, but this version doesn't assert on unknown SCI versions. + * Only used by the fallback detector + */ +SciVersion getSciVersionForDetection(); + /** * Convenience function converting an SCI version into a human-readable string. */ -- cgit v1.2.3 From 22aaf995ed4f5131ae9cf6753d228718a96293f3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 15:34:52 +0300 Subject: SCI: Hopefully fix bug #6718 in LSL6 Polish View flags are mainly used by LB2. The flag in the LSL6 view seems to be garbage, so we ignore it --- engines/sci/graphics/view.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp index f3f352e5b8..a88546e68c 100644 --- a/engines/sci/graphics/view.cpp +++ b/engines/sci/graphics/view.cpp @@ -283,6 +283,7 @@ void GfxView::initData(GuiResourceId resourceId) { _isScaleable = false; break; case 0x40: + case 0x4F: // LSL6 Polish, seems to be garbage - bug #6718 case 0: break; // don't do anything, we already have _isScaleable set default: -- cgit v1.2.3 From dd3e877b144a514fe2c93a253c40a3c47345806d Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Sun, 7 Sep 2014 14:21:34 +0200 Subject: GUI: Fix for bug 6719 (last line of help missing) Since 1.4 the font changed from a 14 to 15 pixel height wich causes one line of help text no longer to be shown. By changing the padding of the buttons the last lines fits again. --- gui/themes/scummmodern.zip | Bin 1489429 -> 1485886 bytes gui/themes/scummmodern/scummmodern_layout.stx | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip index e40e8b1e26..c7c585654d 100644 Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index b760e15919..7e61d6820e 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -1169,9 +1169,9 @@ height = 'Globals.Line.Height' /> - + -- cgit v1.2.3 From 72303564f70573dc4bacd9c726dc626920bf21e8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Oct 2014 11:20:50 -0400 Subject: MADS: Hook up Rex game endings to show the correct animation and/or credits --- engines/mads/menu_views.cpp | 15 +++++++++++++++ engines/mads/menu_views.h | 17 ++++++++++------- engines/mads/nebular/dialogs_nebular.cpp | 4 ++-- engines/mads/nebular/game_nebular.cpp | 26 ++++++++++++++++++++++++++ engines/mads/nebular/menu_nebular.cpp | 15 +++++++++++++++ engines/mads/nebular/menu_nebular.h | 12 ++++++++++++ engines/mads/scene.cpp | 3 +++ 7 files changed, 83 insertions(+), 9 deletions(-) diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp index 857db68fa6..1314774371 100644 --- a/engines/mads/menu_views.cpp +++ b/engines/mads/menu_views.cpp @@ -80,6 +80,15 @@ bool MenuView::onEvent(Common::Event &event) { return false; } +Common::String MenuView::getResourceName() { + Common::String s(_filename); + s.toLowercase(); + while (s.contains('.')) + s.deleteLastChar(); + + return s; +} + /*------------------------------------------------------------------------*/ char TextView::_resourceName[100]; @@ -112,12 +121,17 @@ TextView::TextView(MADSEngine *vm) : MenuView(vm) { } TextView::~TextView() { + // Turn off palette cycling as well as any playing sound + Scene &scene = _vm->_game->_scene; + scene._cyclingActive = false; + _vm->_sound->stop(); } void TextView::load() { Common::String scriptName(_resourceName); scriptName += ".txr"; + _filename = scriptName; if (!_script.open(scriptName)) error("Could not open resource %s", _resourceName); @@ -491,6 +505,7 @@ void AnimationView::load() { if (!resName.hasSuffix(".")) resName += ".res"; + _filename = resName; if (!_script.open(resName)) error("Could not open resource %s", resName.c_str()); diff --git a/engines/mads/menu_views.h b/engines/mads/menu_views.h index 6faa665bff..c13213c3ed 100644 --- a/engines/mads/menu_views.h +++ b/engines/mads/menu_views.h @@ -36,6 +36,7 @@ class MenuView: public FullScreenDialog { protected: bool _breakFlag; bool _redrawFlag; + Common::String _filename; virtual void doFrame() = 0; @@ -51,6 +52,8 @@ public: virtual ~MenuView() {} virtual void show(); + + Common::String getResourceName(); }; struct TextLine { @@ -106,11 +109,6 @@ private: */ int getParameter(const char **paramP); - /** - * Called when the script is finished - */ - void scriptDone(); - /** * Reset the game palette */ @@ -119,6 +117,11 @@ protected: virtual void display(); virtual void doFrame(); + + /** + * Called when the script is finished + */ + virtual void scriptDone(); public: /** * Queue the given text resource for display @@ -201,8 +204,6 @@ private: int getParameter(); - void scriptDone(); - void loadNextResource(); protected: virtual void display(); @@ -210,6 +211,8 @@ protected: virtual void doFrame(); virtual bool onEvent(Common::Event &event); + + virtual void scriptDone(); public: /** * Queue the given text resource for display diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 86244bd3bb..1900a12b59 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -314,13 +314,13 @@ void DialogsNebular::showDialog() { break; } case DIALOG_TEXTVIEW: { - TextView *dlg = new TextView(_vm); + TextView *dlg = new RexTextView(_vm); dlg->show(); delete dlg; break; } case DIALOG_ANIMVIEW: { - AnimationView *dlg = new AnimationView(_vm); + AnimationView *dlg = new RexAnimationView(_vm); dlg->show(); delete dlg; break; diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp index 902f42507a..eae74d6da0 100644 --- a/engines/mads/nebular/game_nebular.cpp +++ b/engines/mads/nebular/game_nebular.cpp @@ -27,6 +27,7 @@ #include "mads/game.h" #include "mads/screen.h" #include "mads/msurface.h" +#include "mads/menu_views.h" #include "mads/nebular/game_nebular.h" #include "mads/nebular/dialogs_nebular.h" #include "mads/nebular/globals_nebular.h" @@ -309,6 +310,31 @@ void GameNebular::setSectionHandler() { } void GameNebular::checkShowDialog() { + // Handling to start endgame sequences if the win/lose type has been set + switch (_winStatus) { + case 1: + // No shields failure ending + AnimationView::execute(_vm, "rexend1"); + break; + case 2: + // Shields, but no targetting failure ending + AnimationView::execute(_vm, "rexend2"); + break; + case 3: + // Completed game successfully, so activate quotes item on the main menu + ConfMan.setBool("ShowQuotes", true); + ConfMan.flushToDisk(); + + AnimationView::execute(_vm, "rexend3"); + break; + case 4: + // Decompression ending + TextView::execute(_vm, "ending4"); + break; + } + _winStatus = 0; + + // Loop for showing dialogs, if any need to be shown if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[kCopyProtectFailed]) { _player.releasePlayerSprites(); diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 717e3f6cf9..46dc411678 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -375,6 +375,21 @@ bool AdvertView::onEvent(Common::Event &event) { return false; } +/*------------------------------------------------------------------------*/ + +void RexAnimationView::scriptDone() { + AnimationView::scriptDone(); + + Common::String s = getResourceName(); + if (s == "rexend1") { + TextView::execute(_vm, "ending1"); + } else if (s == "rexend2") { + TextView::execute(_vm, "ending2"); + } else if (s == "rexend3") { + TextView::execute(_vm, "credits"); + } +} + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index 29777a7a7c..d00439c1e4 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -128,6 +128,18 @@ public: void show(); }; +class RexAnimationView : public AnimationView { +protected: + virtual void scriptDone(); +public: + RexAnimationView(MADSEngine *vm) : AnimationView(vm) {} +}; + +class RexTextView : public TextView { +public: + RexTextView(MADSEngine *vm) : TextView(vm) {} +}; + } // End of namespace Nebular } // End of namespace MADS diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index ad24dd4f60..18ceb3c813 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -360,6 +360,9 @@ void Scene::loop() { if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger && _vm->_game->_player._stepEnabled) _reloadSceneFlag = true; + + if (_vm->_game->_winStatus) + break; } } -- cgit v1.2.3 From a657c3982447704c9262926f853875ca80e7a7c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Oct 2014 11:42:11 -0400 Subject: MADS: Only show Quotes main menu item after winning the game --- engines/mads/nebular/menu_nebular.cpp | 14 ++++++++++++++ engines/mads/nebular/menu_nebular.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index 46dc411678..f2f90e2291 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -21,6 +21,7 @@ */ #include "common/scummsys.h" +#include "common/config-manager.h" #include "mads/game.h" #include "mads/mads.h" #include "mads/menu_views.h" @@ -62,6 +63,10 @@ MainMenu::~MainMenu() { scene._spriteSlots.reset(); } +bool MainMenu::shouldShowQuotes() { + return ConfMan.hasKey("ShowQuotes") && ConfMan.getBool("ShowQuotes"); +} + void MainMenu::display() { MenuView::display(); Scene &scene = _vm->_game->_scene; @@ -101,6 +106,9 @@ void MainMenu::doFrame() { handleAction((MADSGameAction)_selectedIndex); } else { for (_menuItemIndex = 0; _menuItemIndex < 6; ++_menuItemIndex) { + if (_menuItemIndex == 4 && !shouldShowQuotes()) + continue; + if (_menuItemIndex != _selectedIndex) { addSpriteSlot(); } @@ -120,6 +128,9 @@ void MainMenu::doFrame() { if (_skipFlag && _menuItemIndex >= 0) { // Quickly loop through all the menu items to display each's final frame for (; _menuItemIndex < 6; ++_menuItemIndex) { + if (_menuItemIndex == 4 && !shouldShowQuotes()) + continue; + // Draw the final frame of the menuitem _frameIndex = 0; addSpriteSlot(); @@ -129,9 +140,12 @@ void MainMenu::doFrame() { } else { if ((_menuItemIndex == -1) || (_frameIndex == 0)) { if (++_menuItemIndex == 6) { + // Reached end of display animation _vm->_events->showCursor(); return; + } else if (_menuItemIndex == 4 && !shouldShowQuotes()) { + ++_menuItemIndex; } _frameIndex = _menuItems[_menuItemIndex]->getCount() - 1; diff --git a/engines/mads/nebular/menu_nebular.h b/engines/mads/nebular/menu_nebular.h index d00439c1e4..77b8b6fc6e 100644 --- a/engines/mads/nebular/menu_nebular.h +++ b/engines/mads/nebular/menu_nebular.h @@ -80,6 +80,8 @@ private: * Add a sprite slot for the current menuitem frame */ void addSpriteSlot(); + + bool shouldShowQuotes(); protected: /** * Display the menu -- cgit v1.2.3 From dbfe4972e3a3e1d59aee8993697028cdd2de8da2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Oct 2014 11:55:30 -0400 Subject: MADS: Remove deprecated code from AnimationView and a bunch of out-of-date TODOs --- engines/mads/animation.cpp | 3 --- engines/mads/game.cpp | 2 -- engines/mads/menu_views.cpp | 36 ------------------------------------ engines/mads/menu_views.h | 4 ---- engines/mads/msurface.cpp | 4 ---- engines/mads/nebular/game_nebular.h | 4 +--- 6 files changed, 1 insertion(+), 52 deletions(-) diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp index 9f0e0adb6d..2b999fa305 100644 --- a/engines/mads/animation.cpp +++ b/engines/mads/animation.cpp @@ -340,9 +340,6 @@ void Animation::startAnimation(int endTrigger) { _unkIndex = -1; //SpriteAsset *asset = _scene->_sprites[_spriteListIndexes[_header._spritesIndex]]; - // TODO: Weird stuff with _unkList. Seems like it's treated as pointers - // here, but in processText, it's used as POINTs? - loadFrame(1); } diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index b544eff2db..63a7e40d1b 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -433,8 +433,6 @@ void Game::handleKeypress(const Common::Event &event) { default: break; } - - warning("TODO: handleKeypress - %d", (int)event.kbd.keycode); } void Game::synchronize(Common::Serializer &s, bool phase1) { diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp index 1314774371..03afc70c3e 100644 --- a/engines/mads/menu_views.cpp +++ b/engines/mads/menu_views.cpp @@ -765,40 +765,4 @@ int AnimationView::getParameter() { return result; } -void AnimationView::checkResource(const Common::String &resourceName) { - //bool hasSuffix = false; - -} - -int AnimationView::scanResourceIndex(const Common::String &resourceName) { - int foundIndex = -1; - - if (_v1) { - const char *chP = strchr(resourceName.c_str(), '\\'); - if (!chP) { - chP = strchr(resourceName.c_str(), '*'); - } - - Common::String resName = chP ? Common::String(chP + 1) : resourceName; - - if (_v2 != 3) { - assert(_resIndex.size() == 0); - } - - // Scan for the resource name - for (uint resIndex = 0; resIndex < _resIndex.size(); ++resIndex) { - ResIndexEntry &resEntry = _resIndex[resIndex]; - if (resEntry._resourceName.compareToIgnoreCase(resourceName)) { - foundIndex = resIndex; - break; - } - } - } - - if (foundIndex >= 0) { - // TODO - } - return -1; -} - } // End of namespace MADS diff --git a/engines/mads/menu_views.h b/engines/mads/menu_views.h index c13213c3ed..cc5a13006f 100644 --- a/engines/mads/menu_views.h +++ b/engines/mads/menu_views.h @@ -192,10 +192,6 @@ private: int _animFrameNumber; bool _nextCyclingActive; private: - void checkResource(const Common::String &resourceName); - - int scanResourceIndex(const Common::String &resourceName); - void load(); void processLines(); diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp index 0cb4530a84..39824bac4b 100644 --- a/engines/mads/msurface.cpp +++ b/engines/mads/msurface.cpp @@ -87,7 +87,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo // rectangle is always 0, 0 assert(clipRect.top == 0 && clipRect.left == 0); - // TODO: Put err* and scaled* into SpriteInfo int errX = info.hotX * info.scaleX % 100; int errY = info.hotY * info.scaleY % 100; int scaledWidth = scaleValue(info.width, info.scaleX, errX); @@ -160,7 +159,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo if (status == kStatusDraw && clipY == 0) { // Draw previously scaled line - // TODO Implement different drawing types (depth, shadow etc.) byte *tempDst = dst; for (int lineX = 0; lineX < scaledWidth; lineX++) { byte pixel = scaledLineBuf[lineX]; @@ -186,8 +184,6 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo } dst += pitch; heightAmt--; - // TODO depth etc. - //depthAddress += Destination -> Width; errY += 100; if (errY >= 0) diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h index da607d47ee..efa21a2e73 100644 --- a/engines/mads/nebular/game_nebular.h +++ b/engines/mads/nebular/game_nebular.h @@ -133,18 +133,16 @@ public: virtual void synchronize(Common::Serializer &s, bool phase1); }; - +// Section handlers aren't needed in ScummVM implementation class Section1Handler : public SectionHandler { public: Section1Handler(MADSEngine *vm) : SectionHandler(vm) {} - // TODO: Properly implement handler methods virtual void preLoadSection() {} virtual void sectionPtr2() {} virtual void postLoadSection() {} }; -// TODO: Properly implement handler classes typedef Section1Handler Section2Handler; typedef Section1Handler Section3Handler; typedef Section1Handler Section4Handler; -- cgit v1.2.3 From f0bcacc7b3ad9bc5bb88b9b7db8d36977e96fa08 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 20:12:42 +0300 Subject: MADS: Reset screen clip bounds before copying over a new screen This is needed for the in-game menu, where a dialog spawns another one --- engines/mads/dialogs.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp index 5ea8fb115c..5e38f34fc6 100644 --- a/engines/mads/dialogs.cpp +++ b/engines/mads/dialogs.cpp @@ -457,6 +457,7 @@ void FullScreenDialog::display() { _vm->_palette->setLowRange(); _vm->_screen.hLine(0, 20, MADS_SCREEN_WIDTH, 2); _vm->_screen.hLine(0, 179, MADS_SCREEN_WIDTH, 2); + _vm->_screen.resetClipBounds(); _vm->_screen.copyRectToScreen(Common::Rect(0, 0, MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT)); // Restrict the screen to the area between the two lines -- cgit v1.2.3 From ad1aedec7687019b44066bc7695f4d227cee1a5b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 20:19:14 +0300 Subject: MADS: Implement the Rex Cancel button in the game options dialog The current options are now saved when the dialog opens, and are restored to their original values if the user cancels --- engines/mads/nebular/dialogs_nebular.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 1900a12b59..6e0e7821ab 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -1061,6 +1061,14 @@ void OptionsDialog::display() { void OptionsDialog::show() { Nebular::GameNebular &game = *(Nebular::GameNebular *)_vm->_game; + + // Previous options, restored when cancel is selected + bool prevEasyMouse = _vm->_easyMouse; + bool prevInvObjectsAnimated = _vm->_invObjectsAnimated; + bool prevTextWindowStill = _vm->_textWindowStill; + ScreenFade prevScreenFade = _vm->_screenFade; + StoryMode prevStoryMode = game._storyMode; + do { _selectedLine = 0; GameDialog::show(); @@ -1105,10 +1113,15 @@ void OptionsDialog::show() { switch (_selectedLine) { case 8: // Done - // TODO: Copy from temporary config + // New options will be applied break; case 9: // Cancel - // TODO: Ignore all changes to temporary config + // Revert all options from the saved ones + _vm->_easyMouse = prevEasyMouse; + _vm->_invObjectsAnimated = prevInvObjectsAnimated; + _vm->_textWindowStill = prevTextWindowStill; + _vm->_screenFade = prevScreenFade; + game._storyMode = prevStoryMode; break; default: break; -- cgit v1.2.3 From 879890e021028983dda5af3ea83156357ba239a6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 20:46:17 +0300 Subject: MADS: Clear scene sprites and objects when showing a game menu This shows the game menu, albeit with the wrong palette --- engines/mads/nebular/dialogs_nebular.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 6e0e7821ab..f51d046951 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -594,6 +594,9 @@ GameDialog::GameDialog(MADSEngine *vm) : FullScreenDialog(vm) { _vm->_events->waitCursor(); scene.clearVocab(); scene._dynamicHotspots.clear(); + // Clear scene sprites and objects + scene._spriteSlots.reset(); + _vm->_game->_screenObjects.clear(); _vm->_dialogs->_defaultPosition = Common::Point(-1, -1); _menuSpritesIndex = 0; } -- cgit v1.2.3 From 92bf8a54200e762bc95a155e3cdcffd22ec258d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 18 Oct 2014 22:06:48 +0300 Subject: SCI: Fix bug #6703: "SCI: QFG1 VGA - Can't CTRL+S to access statistics" This actually affected all Control+key combinations. A regression from 0f90b8eaad0335715d5f6aea6ede32ebbb746e25 --- engines/sci/event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/sci/event.cpp b/engines/sci/event.cpp index 511d2014bd..b1c002413d 100644 --- a/engines/sci/event.cpp +++ b/engines/sci/event.cpp @@ -262,7 +262,7 @@ SciEvent EventManager::getScummVMEvent() { // Scancodify if appropriate if (modifiers & Common::KBD_ALT) input.character = altify(input.character); - else if ((modifiers & Common::KBD_CTRL) && input.character > 0 && input.character < 27) + if (getSciVersion() <= SCI_VERSION_1_MIDDLE && (modifiers & Common::KBD_CTRL) && input.character > 0 && input.character < 27) input.character += 96; // 0x01 -> 'a' // If no actual key was pressed (e.g. if only a modifier key was pressed), -- cgit v1.2.3 From 7bdf48170a86fddca28350afac5b90981be0d9a0 Mon Sep 17 00:00:00 2001 From: Sven Hesse Date: Sun, 19 Oct 2014 00:08:32 +0200 Subject: GOB: Remove useless memcpy() Happened while removing Draw::_vgaSmallPalette in 0f9b1364c. Fixes Coverity issue #1230309. --- engines/gob/inter_v1.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 40134bbf17..676564a9fb 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -1124,8 +1124,6 @@ void Inter_v1::o1_palLoad(OpFuncParams ¶ms) { _vm->_draw->_vgaPalette[i].green = _vm->_game->_script->readByte(); _vm->_draw->_vgaPalette[i].blue = _vm->_game->_script->readByte(); } - - memcpy(_vm->_draw->_vgaPalette, _vm->_draw->_vgaPalette, 16 * 3); break; case 53: -- cgit v1.2.3 From e06327e81aee35b9a523122637f79c9d0530c0bc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 18 Oct 2014 18:27:07 -0400 Subject: MADS: Minor clean up of sprite set removal --- engines/mads/sprites.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp index 6cb55aaeee..fd73930475 100644 --- a/engines/mads/sprites.cpp +++ b/engines/mads/sprites.cpp @@ -404,9 +404,9 @@ void SpriteSets::remove(int idx) { delete (*this)[idx]; (*this)[idx] = nullptr; } else { - while (size() > 0 && (*this)[size() - 1] == nullptr) { + do { remove_at(size() - 1); - } + } while (size() > 0 && (*this)[size() - 1] == nullptr); } if (_assetCount > 0) -- cgit v1.2.3 From 1d5536da02c20c5c635e02dd19aa38fb3b1128ec Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 19 Oct 2014 16:52:00 +0300 Subject: SCI: Enable some menus in Jones after restoring (bugs #6537 and #6723) The code path that is supposed to enable these never gets called when restoring from the main menu, or from the ScummVM launcher. Since the logic on when and what to enable is quite complex, the easiest thing to do is enable these entries manually after a game is loaded. --- engines/sci/engine/kfile.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 61fb717567..cb8ba7a565 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -37,6 +37,7 @@ #include "sci/engine/state.h" #include "sci/engine/kernel.h" #include "sci/engine/savegame.h" +#include "sci/graphics/menu.h" #include "sci/sound/audio.h" #include "sci/console.h" @@ -913,6 +914,23 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { // code concerning this via script patch. s->variables[VAR_GLOBAL][0xB3].setOffset(SAVEGAMEID_OFFICIALRANGE_START + savegameId); break; + case GID_JONES: + // HACK: The code that enables certain menu items isn't called when a game is restored from the + // launcher, or the "Restore game" option in the game's main menu - bugs #6537 and #6723. + // These menu entries are disabled when the game is launched, and are enabled when a new game is + // started. The code for enabling these entries is is all in script 1, room1::init, but that code + // path is never followed in these two cases (restoring game from the menu, or restoring a game + // from the ScummVM launcher). Thus, we perform the calls to enable the menus ourselves here. + // These two are needed when restoring from the launcher + g_sci->_gfxMenu->kernelSetAttribute(257 >> 8, 257 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> About Jones + g_sci->_gfxMenu->kernelSetAttribute(258 >> 8, 258 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> Help + // The rest are normally enabled from room1::init + g_sci->_gfxMenu->kernelSetAttribute(769 >> 8, 769 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Options -> Delete current player + g_sci->_gfxMenu->kernelSetAttribute(513 >> 8, 513 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Game -> Save Game + g_sci->_gfxMenu->kernelSetAttribute(515 >> 8, 515 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Game -> Restore Game + g_sci->_gfxMenu->kernelSetAttribute(1025 >> 8, 1025 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Status -> Statistics + g_sci->_gfxMenu->kernelSetAttribute(1026 >> 8, 1026 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Status -> Goals + break; default: break; } -- cgit v1.2.3 From d3475fe3b699d6d2d8cd87b1b1b480e685717c74 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 19 Oct 2014 17:03:14 +0300 Subject: GRAPHICS: Silence an MSVC warning --- graphics/transform_tools.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/transform_tools.h b/graphics/transform_tools.h index a51c8ee229..ec739f9ad0 100644 --- a/graphics/transform_tools.h +++ b/graphics/transform_tools.h @@ -28,7 +28,7 @@ namespace Graphics { - static const float kEpsilon = 0.00001; // arbitrarily taken number + static const float kEpsilon = 0.00001f; // arbitrarily taken number struct FloatPoint { float x; -- cgit v1.2.3 From 5a6a44f1c6cc59192ec702ee31a1a0feb881c2e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Oct 2014 14:49:20 -0400 Subject: ACCESS: Wait for keypress in speakText if voice is turned off --- engines/access/access.cpp | 7 ++++++- engines/access/sound.cpp | 1 + engines/access/sound.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 5636654d03..28847370a2 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -274,7 +274,12 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) if (soundsLeft == 0) return; - while(true) { + if (!_sound->_isVoice) { + _events->waitKeyMouse(); + return; + } + + for (;;) { _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundPriority[0] = 1; _sound->playSound(0); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 001d2f325b..90818ed5d3 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -32,6 +32,7 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _music = nullptr; _musicRepeat = false; _playingSound = false; + _isVoice = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index 3d967c6af4..cc02229b3b 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -48,6 +48,7 @@ public: Resource *_music; bool _musicRepeat; bool _playingSound; + bool _isVoice; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); -- cgit v1.2.3 From 1860c2107adb4d08ce6d5a360b47bf5c19392713 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 19 Oct 2014 23:44:45 +0200 Subject: SCI: Add notes --- engines/sci/engine/kfile.cpp | 2 ++ engines/sci/engine/savegame.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index cb8ba7a565..c56eb09482 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -922,6 +922,8 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { // path is never followed in these two cases (restoring game from the menu, or restoring a game // from the ScummVM launcher). Thus, we perform the calls to enable the menus ourselves here. // These two are needed when restoring from the launcher + // FIXME: The original interpreter saves and restores the menu state, so these attributes + // are automatically reset there. We may want to do the same. g_sci->_gfxMenu->kernelSetAttribute(257 >> 8, 257 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> About Jones g_sci->_gfxMenu->kernelSetAttribute(258 >> 8, 258 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, TRUE_REG); // Sierra -> Help // The rest are normally enabled from room1::init diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index cdcdcc41e5..9decc4cef6 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -844,6 +844,8 @@ bool gamestate_save(EngineState *s, Common::WriteStream *fh, const Common::Strin if (voc) voc->saveLoadWithSerializer(ser); + // TODO: SSCI (at least JonesCD, presumably more) also stores the Menu state + return true; } -- cgit v1.2.3 From 0b3a20f645324696e08745a9e8a3fc75e1700cac Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 22 Oct 2014 11:43:24 +0700 Subject: ZVISION: Some push toggles may contain few hotspot zones --- .../scripting/controls/push_toggle_control.cpp | 21 +++++++++++++++------ .../scripting/controls/push_toggle_control.h | 5 ++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 2f4af0d843..bf74a22051 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -42,6 +42,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); line.toLowercase(); + _hotspots.clear(); while (!stream.eos() && !line.contains('}')) { if (line.matchString("*_hotspot*", true)) { @@ -52,7 +53,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height); - _hotspot = Common::Rect(x, y, x + width, y + height); + _hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1)); } else if (line.matchString("cursor*", true)) { char nameBuffer[25]; @@ -86,12 +87,13 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab trimCommentsAndWhiteSpace(&line); } - if (_hotspot.isEmpty() || _hoverCursor.empty()) { - warning("Push_toggle cursor %u was parsed incorrectly", key); + if (_hotspots.size() == 0 || _hoverCursor.empty()) { + warning("Push_toggle %u was parsed incorrectly", key); } } PushToggleControl::~PushToggleControl() { + _hotspots.clear(); } bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { @@ -101,7 +103,7 @@ bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com if (_event != Common::EVENT_LBUTTONUP) return false; - if (_hotspot.contains(backgroundImageSpacePos)) { + if (contain(backgroundImageSpacePos)) { int32 val = _engine->getScriptManager()->getStateValue(_key); val = (val + 1) % _countTo; _engine->getScriptManager()->setStateValue(_key, val); @@ -117,7 +119,7 @@ bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const C if (_event != Common::EVENT_LBUTTONDOWN) return false; - if (_hotspot.contains(backgroundImageSpacePos)) { + if (contain(backgroundImageSpacePos)) { int32 val = _engine->getScriptManager()->getStateValue(_key); val = (val + 1) % _countTo; _engine->getScriptManager()->setStateValue(_key, val); @@ -130,7 +132,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_hotspot.contains(backgroundImageSpacePos)) { + if (contain(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor)); return true; } @@ -138,4 +140,11 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C return false; } +bool PushToggleControl::contain(const Common::Point &point) { + for (uint i = 0; i < _hotspots.size(); i++) + if (_hotspots[i].contains(point)) + return true; + return false; +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h index 6ba1bd77fa..7b45fb4831 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.h +++ b/engines/zvision/scripting/controls/push_toggle_control.h @@ -27,6 +27,7 @@ #include "common/rect.h" #include "common/events.h" +#include "common/array.h" namespace ZVision { @@ -65,13 +66,15 @@ private: * The area that will trigger the event * This is in image space coordinates, NOT screen space */ - Common::Rect _hotspot; + Common::Array _hotspots; /** The cursor to use when hovering over _hotspot */ Common::String _hoverCursor; /** Button maximal values count */ uint _countTo; Common::EventType _event; + + bool contain(const Common::Point &point); }; } // End of namespace ZVision -- cgit v1.2.3 From 4bc319441069101a902ed22f48bec40b7e6c9284 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 22 Oct 2014 11:44:49 +0700 Subject: ZVISION: Implement simple midi support --- engines/zvision/core/midi.cpp | 89 +++++++++++++++++++++++++++++++++++++++++++ engines/zvision/core/midi.h | 59 ++++++++++++++++++++++++++++ engines/zvision/module.mk | 1 + engines/zvision/zvision.cpp | 4 ++ engines/zvision/zvision.h | 5 +++ 5 files changed, 158 insertions(+) create mode 100644 engines/zvision/core/midi.cpp create mode 100644 engines/zvision/core/midi.h diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp new file mode 100644 index 0000000000..5cc8cd0402 --- /dev/null +++ b/engines/zvision/core/midi.cpp @@ -0,0 +1,89 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/midi.h" + +namespace ZVision { + +midiManager::midiManager() { + MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); + _driver = MidiDriver::createMidi(dev); + _driver->open(); +} + +midiManager::~midiManager() { + stop(); + _driver->close(); + delete _driver; +} + +void midiManager::stop() { + for (int8 i = 0; i < 16; i++) + if (_playChannels[i].playing) + noteOff(i); +} + +void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { + assert(channel <= 15); + + _playChannels[channel].playing = true; + _playChannels[channel].note = note; + _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); +} + +void midiManager::noteOff(int8 channel) { + assert(channel <= 15); + + if (_playChannels[channel].playing) { + _playChannels[channel].playing = false; + _driver->send(channel | (_playChannels[channel].note << 8) | 0x80); + } +} + +int8 midiManager::getFreeChannel() { + for (int8 i = 0; i < 16; i++) + if (!_playChannels[i].playing) + return i; + return -1; +} + +void midiManager::setPan(int8 channel, int8 pan) { + assert(channel <= 15); + + _driver->send(channel | (pan << 16) | 0xAB0); +} + +void midiManager::setVolume(int8 channel, int8 volume) { + assert(channel <= 15); + + _driver->send(channel | (volume << 16) | 0x7B0); +} + +void midiManager::setProgram(int8 channel, int8 prog) { + assert(channel <= 15); + + _driver->send(channel | (prog << 8) | 0xC0); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h new file mode 100644 index 0000000000..79f8ea3d04 --- /dev/null +++ b/engines/zvision/core/midi.h @@ -0,0 +1,59 @@ +/* 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 ZVISION_MIDI_H +#define ZVISION_MIDI_H + +#include "audio/mididrv.h" + +namespace ZVision { + +class midiManager { +public: + midiManager(); + ~midiManager(); + + void stop(); + void noteOn(int8 channel, int8 noteNumber, int8 velocity); + void noteOff(int8 channel); + void setPan(int8 channel, int8 pan); + void setVolume(int8 channel, int8 volume); + void setProgram(int8 channel, int8 prog); + + int8 getFreeChannel(); + +protected: + + struct chan { + bool playing; + int8 note; + + chan() : playing(false), note(0) {}; + }; + + MidiDriver *_driver; + chan _playChannels[16]; +}; + +} + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 872b48f775..3f00d67c4c 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -7,6 +7,7 @@ MODULE_OBJS := \ core/console.o \ core/events.o \ core/menu.o \ + core/midi.o \ core/save_manager.o \ core/search_manager.o \ cursors/cursor_manager.o \ diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index a534e49c25..a78d68dc8c 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -36,6 +36,7 @@ #include "zvision/core/search_manager.h" #include "zvision/text/text.h" #include "zvision/fonts/truetype_font.h" +#include "zvision/core/midi.h" #include "common/config-manager.h" #include "common/str.h" @@ -67,6 +68,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _saveManager(nullptr), _stringManager(nullptr), _cursorManager(nullptr), + _midiManager(nullptr), _aud_id(0), _rendDelay(2), _velocity(0) { @@ -85,6 +87,7 @@ ZVision::~ZVision() { delete _renderManager; delete _scriptManager; delete _rnd; + delete _midiManager; // Remove all of our debug levels DebugMan.clearAllDebugChannels(); @@ -156,6 +159,7 @@ void ZVision::initialize() { _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, &_pixelFormat); _textRenderer = new textRenderer(this); + _midiManager = new midiManager(); if (_gameDescription->gameId == GID_GRANDINQUISITOR) _menu = new menuZgi(this); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index e5d32bf678..cbd10da0d5 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -55,6 +55,7 @@ class RlfAnimation; class menuHandler; class textRenderer; class Subtitle; +class midiManager; class ZVision : public Engine { public: @@ -104,6 +105,7 @@ private: menuHandler *_menu; sManager *_searchManager; textRenderer *_textRenderer; + midiManager *_midiManager; // Clock Clock _clock; @@ -146,6 +148,9 @@ public: textRenderer *getTextRenderer() const { return _textRenderer; } + midiManager *getMidiManager() const { + return _midiManager; + } Common::RandomSource *getRandomSource() const { return _rnd; } -- cgit v1.2.3 From 8e9d201cc3496f79fa30d1e05c7372998895c0e6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 22 Oct 2014 11:49:24 +0700 Subject: ZVISION: Music actions and sidefx now handle midi sounds. --- engines/zvision/scripting/actions.cpp | 35 ++++++++++------ engines/zvision/scripting/actions.h | 4 +- engines/zvision/scripting/sidefx/music_node.cpp | 56 +++++++++++++++++++++++-- engines/zvision/scripting/sidefx/music_node.h | 55 +++++++++++++++++++++++- 4 files changed, 132 insertions(+), 18 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 839eb1f92c..2464f54861 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -313,21 +313,26 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l // type 4 are midi sound effect files if (type == 4) { - _soundType = Audio::Mixer::kSFXSoundType; - _fileName = Common::String::format("midi/%s/%u.wav", fileNameBuffer, loop); - _loop = false; + _midi = true; + int note; + int prog; + sscanf(line.c_str(), "%u %d %d %u", &type, &prog, ¬e, &volume); + _volume = volume; + _note = note; + _prog = prog; } else { - // TODO: See what the other types are so we can specify the correct Mixer::SoundType. In the meantime use kPlainSoundType - _soundType = Audio::Mixer::kPlainSoundType; + _midi = false; _fileName = Common::String(fileNameBuffer); _loop = loop == 1 ? true : false; - } - // Volume is optional. If it doesn't appear, assume full volume - if (volume != 255) { - // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] - _volume = volume * 255 / 100; + // Volume is optional. If it doesn't appear, assume full volume + if (volume != 255) { + // Volume in the script files is mapped to [0, 100], but the ScummVM mixer uses [0, 255] + _volume = volume * 255 / 100; + } } + + } ActionMusic::~ActionMusic() { @@ -339,10 +344,14 @@ bool ActionMusic::execute() { if (_engine->getScriptManager()->getSideFX(_slotkey)) return true; - if (!_engine->getSearchManager()->hasFile(_fileName)) - return true; + if (_midi) { + _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotkey, _prog, _note, _volume)); + } else { + if (!_engine->getSearchManager()->hasFile(_fileName)) + return true; - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); + } return true; } diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 5e34f6eaf0..b3c46d16ce 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -243,11 +243,13 @@ public: private: uint32 _key; - Audio::Mixer::SoundType _soundType; Common::String _fileName; bool _loop; byte _volume; bool _universe; + bool _midi; + int8 _note; + int8 _prog; }; class ActionPanTrack : public ResultAction { diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index 0351867dd9..4420da3e96 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -25,6 +25,7 @@ #include "zvision/scripting/sidefx/music_node.h" #include "zvision/zvision.h" +#include "zvision/core/midi.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/sound/zork_raw.h" @@ -37,7 +38,7 @@ namespace ZVision { MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) - : SideFX(engine, key, SIDEFX_AUDIO) { + : MusicNode_BASE(engine, key, SIDEFX_AUDIO) { _loop = loop; _volume = volume; _crossfade = false; @@ -174,7 +175,7 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) SideFX *fx = _engine->getScriptManager()->getSideFX(slot); if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode *mus = (MusicNode *)fx; + MusicNode_BASE *mus = (MusicNode_BASE *)fx; mus->setPanTrack(pos); } } @@ -182,9 +183,58 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) PanTrackNode::~PanTrackNode() { SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode *mus = (MusicNode *)fx; + MusicNode_BASE *mus = (MusicNode_BASE *)fx; mus->unsetPanTrack(); } } + +MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) + : MusicNode_BASE(engine, key, SIDEFX_AUDIO) { + _volume = volume; + _prog = program; + _noteNumber = note; + _pan = 0; + + _chan = _engine->getMidiManager()->getFreeChannel(); + + if (_chan >= 0) { + _engine->getMidiManager()->setVolume(_chan, _volume); + _engine->getMidiManager()->setPan(_chan, _pan); + _engine->getMidiManager()->setProgram(_chan, _prog); + _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume); + } + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +MusicMidiNode::~MusicMidiNode() { + if (_chan >= 0) { + _engine->getMidiManager()->noteOff(_chan); + } + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); +} + +void MusicMidiNode::setPanTrack(int16 pos) { +} + +void MusicMidiNode::unsetPanTrack() { +} + +void MusicMidiNode::setFade(int32 time, uint8 target) { +} + +bool MusicMidiNode::process(uint32 deltaTimeInMillis) { + return false; +} + +void MusicMidiNode::setVolume(uint8 new_volume) { + if (_chan >= 0) { + _engine->getMidiManager()->setVolume(_chan, new_volume); + } + _volume = new_volume; +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index 066b8f80f4..262b13085e 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -32,7 +32,30 @@ class String; } namespace ZVision { -class MusicNode : public SideFX { + +class MusicNode_BASE : public SideFX { +public: + MusicNode_BASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {} + ~MusicNode_BASE() {} + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + virtual bool process(uint32 deltaTimeInMillis) = 0; + + virtual void setVolume(uint8 volume) = 0; + + virtual void setPanTrack(int16 pos) = 0; + virtual void unsetPanTrack() = 0; + + virtual void setFade(int32 time, uint8 target) = 0; +}; + +class MusicNode : public MusicNode_BASE { public: MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); ~MusicNode(); @@ -68,6 +91,36 @@ private: Subtitle *_sub; }; +class MusicMidiNode : public MusicNode_BASE { +public: + MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); + ~MusicMidiNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + + void setVolume(uint8 volume); + + void setPanTrack(int16 pos); + void unsetPanTrack(); + + void setFade(int32 time, uint8 target); + +private: + int8 _chan; + int8 _noteNumber; + int8 _velocity; + int8 _pan; + int8 _volume; + int8 _prog; +}; + class PanTrackNode : public SideFX { public: PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); -- cgit v1.2.3 From c021759ad2f0fdb723f98a62739bdf6d5de9c350 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Oct 2014 20:43:22 -0400 Subject: MADS: Add md5 checks for the asound.00* sound drivers The implementation of the sound driver code relies on the data for each sound being at specific locations in the files, so this ensures that if any language version changes the sound files, we'll know about it --- engines/mads/nebular/sound_nebular.cpp | 28 ++++++++++++++++++++++++++++ engines/mads/nebular/sound_nebular.h | 5 +++++ engines/mads/sound.cpp | 9 +++++++++ 3 files changed, 42 insertions(+) diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp index c540eb4382..a6dce74bba 100644 --- a/engines/mads/nebular/sound_nebular.cpp +++ b/engines/mads/nebular/sound_nebular.cpp @@ -24,6 +24,7 @@ #include "audio/decoders/raw.h" #include "common/algorithm.h" #include "common/debug.h" +#include "common/md5.h" #include "common/memstream.h" #include "mads/sound.h" #include "mads/nebular/sound_nebular.h" @@ -218,6 +219,33 @@ ASound::~ASound() { _mixer->stopHandle(_soundHandle); } +void ASound::validate() { + byte digest[16]; + Common::File f; + static const char *const MD5[] = { + "205398468de2c8873b7d4d73d5be8ddc", + "f9b2d944a2fb782b1af5c0ad592306d3", + "7431f8dad77d6ddfc24e6f3c0c4ac7df", + "eb1f3f5a4673d3e73d8ac1818c957cf4", + "f936dd853073fa44f3daac512e91c476", + "3dc139d3e02437a6d9b732072407c366", + "af0edab2934947982e9a405476702e03", + "8cbc25570b50ba41c9b5361cad4fbedc", + "a31e4783e098f633cbb6689adb41dd4f" + }; + + for (int i = 1; i <= 9; ++i) { + Common::String filename = Common::String::format("ASOUND.00%d", i); + if (!f.open(filename)) + error("Could not process - %s", filename.c_str()); + Common::String md5str = Common::computeStreamMD5AsString(f, 8192); + f.close(); + + if (md5str != MD5[i - 1]) + error("Invalid sound file - %s", filename.c_str()); + } +} + void ASound::adlibInit() { write(4, 0x60); write(4, 0x80); diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h index abb6516030..ccfd40ad52 100644 --- a/engines/mads/nebular/sound_nebular.h +++ b/engines/mads/nebular/sound_nebular.h @@ -317,6 +317,11 @@ public: */ virtual ~ASound(); + /** + * Validates the Adlib sound files + */ + static void validate(); + /** * Execute a player command. Most commands represent sounds to play, but some * low number commands also provide control operations. diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp index d0aa770a4d..1652550ba3 100644 --- a/engines/mads/sound.cpp +++ b/engines/mads/sound.cpp @@ -39,6 +39,15 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) { _opl = OPL::Config::create(); _opl->init(11025); + + // Validate sound files + switch (_vm->getGameID()) { + case GType_RexNebular: + Nebular::ASound::validate(); + break; + default: + break; + } } SoundManager::~SoundManager() { -- cgit v1.2.3 From 6fc5092c039e296195709c2274f2a9d4238b6986 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 22 Oct 2014 21:05:47 -0400 Subject: MADS: Remove unused variable --- engines/mads/nebular/sound_nebular.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp index a6dce74bba..0a054440b2 100644 --- a/engines/mads/nebular/sound_nebular.cpp +++ b/engines/mads/nebular/sound_nebular.cpp @@ -220,7 +220,6 @@ ASound::~ASound() { } void ASound::validate() { - byte digest[16]; Common::File f; static const char *const MD5[] = { "205398468de2c8873b7d4d73d5be8ddc", -- cgit v1.2.3 From e738de70e51a1b348759d38756660e161567f991 Mon Sep 17 00:00:00 2001 From: Alexander Reim Date: Thu, 23 Oct 2014 09:19:48 +0200 Subject: WII: missing ASCII codes for some keys --- backends/platform/wii/osystem_events.cpp | 136 +++++++++++++++---------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/backends/platform/wii/osystem_events.cpp b/backends/platform/wii/osystem_events.cpp index 0563639de3..13f5d1fbe0 100644 --- a/backends/platform/wii/osystem_events.cpp +++ b/backends/platform/wii/osystem_events.cpp @@ -70,73 +70,73 @@ #endif #ifdef USE_WII_KBD -static int keymap[][2] = { - { KS_Return, Common::KEYCODE_RETURN }, - { KS_Up, Common::KEYCODE_UP }, - { KS_Down, Common::KEYCODE_DOWN }, - { KS_Left, Common::KEYCODE_LEFT }, - { KS_Right, Common::KEYCODE_RIGHT }, - { KS_Shift_L, Common::KEYCODE_LSHIFT }, - { KS_Shift_R, Common::KEYCODE_RSHIFT }, - { KS_Control_L, Common::KEYCODE_LCTRL }, - { KS_Control_R, Common::KEYCODE_RCTRL }, - { KS_Alt_L, Common::KEYCODE_LALT }, - { KS_Alt_R, Common::KEYCODE_RALT }, - { KS_Meta_L, Common::KEYCODE_LMETA }, - { KS_Meta_R, Common::KEYCODE_RMETA }, - { KS_KP_0, Common::KEYCODE_KP0 }, - { KS_KP_1, Common::KEYCODE_KP1 }, - { KS_KP_2, Common::KEYCODE_KP2 }, - { KS_KP_3, Common::KEYCODE_KP3 }, - { KS_KP_4, Common::KEYCODE_KP4 }, - { KS_KP_5, Common::KEYCODE_KP5 }, - { KS_KP_6, Common::KEYCODE_KP6 }, - { KS_KP_7, Common::KEYCODE_KP7 }, - { KS_KP_8, Common::KEYCODE_KP8 }, - { KS_KP_9, Common::KEYCODE_KP9 }, - { KS_Home, Common::KEYCODE_HOME }, - { KS_Insert, Common::KEYCODE_INSERT }, - { KS_End, Common::KEYCODE_END }, - { KS_Prior, Common::KEYCODE_PAGEUP }, - { KS_Next, Common::KEYCODE_PAGEDOWN }, - { KS_f1, Common::KEYCODE_F1 }, - { KS_f2, Common::KEYCODE_F2 }, - { KS_f3, Common::KEYCODE_F3 }, - { KS_f4, Common::KEYCODE_F4 }, - { KS_f5, Common::KEYCODE_F5 }, - { KS_f6, Common::KEYCODE_F6 }, - { KS_f7, Common::KEYCODE_F7 }, - { KS_f8, Common::KEYCODE_F8 }, - { KS_f9, Common::KEYCODE_F9 }, - { KS_f10, Common::KEYCODE_F10 }, - { KS_f11, Common::KEYCODE_F11 }, - { KS_f12, Common::KEYCODE_F12 }, - { KS_f13, Common::KEYCODE_F13 }, - { KS_f14, Common::KEYCODE_F14 }, - { KS_f15, Common::KEYCODE_F15 }, - { KS_F1, Common::KEYCODE_F1 }, - { KS_F2, Common::KEYCODE_F2 }, - { KS_F3, Common::KEYCODE_F3 }, - { KS_F4, Common::KEYCODE_F4 }, - { KS_F5, Common::KEYCODE_F5 }, - { KS_F6, Common::KEYCODE_F6 }, - { KS_F7, Common::KEYCODE_F7 }, - { KS_F8, Common::KEYCODE_F8 }, - { KS_F9, Common::KEYCODE_F9 }, - { KS_F10, Common::KEYCODE_F10 }, - { KS_F11, Common::KEYCODE_F11 }, - { KS_F12, Common::KEYCODE_F12 }, - { KS_F13, Common::KEYCODE_F13 }, - { KS_F14, Common::KEYCODE_F14 }, - { KS_F15, Common::KEYCODE_F15 }, - { KS_KP_Separator, Common::KEYCODE_KP_PERIOD }, - { KS_KP_Subtract, Common::KEYCODE_KP_DIVIDE }, - { KS_KP_Multiply, Common::KEYCODE_KP_MULTIPLY }, - { KS_KP_Add, Common::KEYCODE_KP_PLUS }, - { KS_KP_Subtract, Common::KEYCODE_KP_MINUS }, - { KS_KP_Equal, Common::KEYCODE_KP_EQUALS }, - { KS_KP_Enter, Common::KEYCODE_KP_ENTER }, - { 0, 0 } +static int keymap[][3] = { + { KS_Return, Common::KEYCODE_RETURN, Common::ASCII_RETURN }, + { KS_Up, Common::KEYCODE_UP, 0 }, + { KS_Down, Common::KEYCODE_DOWN, 0 }, + { KS_Left, Common::KEYCODE_LEFT, 0 }, + { KS_Right, Common::KEYCODE_RIGHT, 0 }, + { KS_Shift_L, Common::KEYCODE_LSHIFT, 0 }, + { KS_Shift_R, Common::KEYCODE_RSHIFT, 0 }, + { KS_Control_L, Common::KEYCODE_LCTRL, 0 }, + { KS_Control_R, Common::KEYCODE_RCTRL, 0 }, + { KS_Alt_L, Common::KEYCODE_LALT, 0 }, + { KS_Alt_R, Common::KEYCODE_RALT, 0 }, + { KS_Meta_L, Common::KEYCODE_LMETA, 0 }, + { KS_Meta_R, Common::KEYCODE_RMETA, 0 }, + { KS_KP_0, Common::KEYCODE_KP0, '0' }, + { KS_KP_1, Common::KEYCODE_KP1, '1' }, + { KS_KP_2, Common::KEYCODE_KP2, '2' }, + { KS_KP_3, Common::KEYCODE_KP3, '3' }, + { KS_KP_4, Common::KEYCODE_KP4, '4' }, + { KS_KP_5, Common::KEYCODE_KP5, '5' }, + { KS_KP_6, Common::KEYCODE_KP6, '6' }, + { KS_KP_7, Common::KEYCODE_KP7, '7' }, + { KS_KP_8, Common::KEYCODE_KP8, '8' }, + { KS_KP_9, Common::KEYCODE_KP9, '9' }, + { KS_Home, Common::KEYCODE_HOME, 0 }, + { KS_Insert, Common::KEYCODE_INSERT, 0 }, + { KS_End, Common::KEYCODE_END, 0 }, + { KS_Prior, Common::KEYCODE_PAGEUP, 0 }, + { KS_Next, Common::KEYCODE_PAGEDOWN, 0 }, + { KS_f1, Common::KEYCODE_F1, Common::ASCII_F1 }, + { KS_f2, Common::KEYCODE_F2, Common::ASCII_F2 }, + { KS_f3, Common::KEYCODE_F3, Common::ASCII_F3 }, + { KS_f4, Common::KEYCODE_F4, Common::ASCII_F4 }, + { KS_f5, Common::KEYCODE_F5, Common::ASCII_F5 }, + { KS_f6, Common::KEYCODE_F6, Common::ASCII_F6 }, + { KS_f7, Common::KEYCODE_F7, Common::ASCII_F7 }, + { KS_f8, Common::KEYCODE_F8, Common::ASCII_F8 }, + { KS_f9, Common::KEYCODE_F9, Common::ASCII_F9 }, + { KS_f10, Common::KEYCODE_F10, Common::ASCII_F10 }, + { KS_f11, Common::KEYCODE_F11, Common::ASCII_F11 }, + { KS_f12, Common::KEYCODE_F12, Common::ASCII_F12 }, + { KS_f13, Common::KEYCODE_F13, 0 }, + { KS_f14, Common::KEYCODE_F14, 0 }, + { KS_f15, Common::KEYCODE_F15, 0 }, + { KS_F1, Common::KEYCODE_F1, Common::ASCII_F1 }, + { KS_F2, Common::KEYCODE_F2, Common::ASCII_F2 }, + { KS_F3, Common::KEYCODE_F3, Common::ASCII_F3 }, + { KS_F4, Common::KEYCODE_F4, Common::ASCII_F4 }, + { KS_F5, Common::KEYCODE_F5, Common::ASCII_F5 }, + { KS_F6, Common::KEYCODE_F6, Common::ASCII_F6 }, + { KS_F7, Common::KEYCODE_F7, Common::ASCII_F7 }, + { KS_F8, Common::KEYCODE_F8, Common::ASCII_F8 }, + { KS_F9, Common::KEYCODE_F9, Common::ASCII_F9 }, + { KS_F10, Common::KEYCODE_F10, Common::ASCII_F10 }, + { KS_F11, Common::KEYCODE_F11, Common::ASCII_F11 }, + { KS_F12, Common::KEYCODE_F12, Common::ASCII_F12 }, + { KS_F13, Common::KEYCODE_F13, 0 }, + { KS_F14, Common::KEYCODE_F14, 0 }, + { KS_F15, Common::KEYCODE_F15, 0 }, + { KS_KP_Separator, Common::KEYCODE_KP_PERIOD, '.' }, + { KS_KP_Divide, Common::KEYCODE_KP_DIVIDE, '/' }, + { KS_KP_Multiply, Common::KEYCODE_KP_MULTIPLY, '*' }, + { KS_KP_Add, Common::KEYCODE_KP_PLUS, '+' }, + { KS_KP_Subtract, Common::KEYCODE_KP_MINUS, '-' }, + { KS_KP_Equal, Common::KEYCODE_KP_EQUALS, '=' }, + { KS_KP_Enter, Common::KEYCODE_KP_ENTER, Common::ASCII_RETURN }, + { 0, 0, 0 } }; #endif @@ -262,7 +262,7 @@ bool OSystem_Wii::pollKeyboard(Common::Event &event) { while (keymap[i][0] != 0) { if (keymap[i][0] == kbdEvent.symbol) { event.kbd.keycode = static_cast(keymap[i][1]); - event.kbd.ascii = 0; + event.kbd.ascii = keymap[i][2]; return true; } -- cgit v1.2.3 From 678f47f043fc5498daae5d4331e02d23a2186528 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 23 Oct 2014 17:09:58 +0700 Subject: ZVISION: Implement action:distort and distort sidefx node --- engines/zvision/graphics/render_manager.cpp | 4 + engines/zvision/graphics/render_manager.h | 2 + engines/zvision/graphics/render_table.cpp | 18 ++++ engines/zvision/graphics/render_table.h | 2 + engines/zvision/scripting/actions.cpp | 23 +++++ engines/zvision/scripting/actions.h | 7 ++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/sidefx/distort_node.cpp | 109 ++++++++++++++++++++++ engines/zvision/scripting/sidefx/distort_node.h | 63 +++++++++++++ 9 files changed, 229 insertions(+), 1 deletion(-) create mode 100644 engines/zvision/scripting/sidefx/distort_node.cpp create mode 100644 engines/zvision/scripting/sidefx/distort_node.h diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 0aa062214f..ce1962a8ee 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -1046,4 +1046,8 @@ EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 tr return newMap; } +void RenderManager::markDirty() { + _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 665a27bf64..e0fc5c248c 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -281,6 +281,8 @@ public: EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp); Common::Rect bkgRectToScreen(const Common::Rect &src); + + void markDirty(); }; } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 9bf40d3745..aeba729196 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -264,4 +264,22 @@ float RenderTable::getTiltGap() { return _tiltOptions.gap; } +float RenderTable::getAngle() { + if (_renderState == TILT) + return _tiltOptions.fieldOfView; + else if (_renderState == PANORAMA) + return _panoramaOptions.fieldOfView; + else + return 1.0; +} + +float RenderTable::getLinscale() { + if (_renderState == TILT) + return _tiltOptions.linearScale; + else if (_renderState == PANORAMA) + return _panoramaOptions.linearScale; + else + return 1.0; +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h index a268ee615f..7153738c6f 100644 --- a/engines/zvision/graphics/render_table.h +++ b/engines/zvision/graphics/render_table.h @@ -81,6 +81,8 @@ public: void setTiltReverse(bool reverse); float getTiltGap(); + float getAngle(); + float getLinscale(); private: void generatePanoramaLookupTable(); diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 2464f54861..9733c5cae8 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -33,6 +33,7 @@ #include "zvision/scripting/sidefx/music_node.h" #include "zvision/scripting/sidefx/syncsound_node.h" #include "zvision/scripting/sidefx/animation_node.h" +#include "zvision/scripting/sidefx/distort_node.h" #include "zvision/scripting/sidefx/ttytext_node.h" #include "zvision/scripting/sidefx/region_node.h" #include "zvision/scripting/controls/titler_control.h" @@ -192,6 +193,28 @@ bool ActionDisplayMessage::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionDistort +////////////////////////////////////////////////////////////////////////////// + +ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_st_angl, &_en_angl, &_st_lin, &_en_lin); +} + +ActionDistort::~ActionDistort() { + _engine->getScriptManager()->killSideFx(_distSlot); +} + +bool ActionDistort::execute() { + if (_engine->getScriptManager()->getSideFX(_distSlot)) + return true; + + _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _st_angl, _en_angl, _st_lin, _en_lin)); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionEnableControl ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index b3c46d16ce..f51847ed05 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -202,9 +202,16 @@ public: class ActionDistort : public ResultAction { public: ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line); + ~ActionDistort(); bool execute(); private: + int16 _distSlot; + int16 _speed; + float _st_angl; + float _en_angl; + float _st_lin; + float _en_lin; }; class ActionEnableControl : public ResultAction { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 8140d09a6a..df60b0b8d4 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -242,7 +242,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("dissolve", true)) { // TODO: Implement ActionDissolve } else if (act.matchString("distort", true)) { - // TODO: Implement ActionDistort + actionList.push_back(new ActionDistort(_engine, slot, args)); } else if (act.matchString("enable_control", true)) { actionList.push_back(new ActionEnableControl(_engine, slot, args)); } else if (act.matchString("flush_mouse_events", true)) { diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp new file mode 100644 index 0000000000..576a1f8592 --- /dev/null +++ b/engines/zvision/scripting/sidefx/distort_node.cpp @@ -0,0 +1,109 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/sidefx/distort_node.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/graphics/render_table.h" + +#include "common/stream.h" + + +namespace ZVision { + +DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin) + : SideFX(engine, key, SIDEFX_DISTORT) { + + _angle = _engine->getRenderManager()->getRenderTable()->getAngle(); + _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale(); + + _speed = speed; + _incr = true; + _st_angl = st_angl; + _en_angl = en_angl; + _st_lin = st_lin; + _en_lin = en_lin; + + _curFrame = 1.0; + + _diff_angl = en_angl - st_angl; + _diff_lin = en_lin - st_lin; + + _frmSpeed = (float)speed / 15.0; + _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); + if (_frames <= 0) + _frames = 1; + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +DistortNode::~DistortNode() { + setParams(_angle, _linScale); +} + +bool DistortNode::process(uint32 deltaTimeInMillis) { + + float updTime = deltaTimeInMillis / (1000.0 / 60.0); + + if (_incr) + _curFrame += updTime; + else + _curFrame -= updTime; + + if (_curFrame < 1.0) { + _curFrame = 1.0; + _incr = true; + } else if (_curFrame > _frames) { + _curFrame = _frames; + _incr = false; + } + + float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed); + + + setParams(_st_angl + diff * _diff_angl, _st_lin + diff * _diff_lin); + + return false; +} + +void DistortNode::setParams(float angl, float linScale) { + RenderTable *table = _engine->getRenderManager()->getRenderTable(); + if (table->getRenderState() == RenderTable::PANORAMA) { + table->setPanoramaFoV(angl); + table->setPanoramaScale(linScale); + table->generateRenderTable(); + _engine->getRenderManager()->markDirty(); + } else if (table->getRenderState() == RenderTable::TILT) { + table->setTiltFoV(angl); + table->setTiltScale(linScale); + table->generateRenderTable(); + _engine->getRenderManager()->markDirty(); + } +} + + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h new file mode 100644 index 0000000000..cba9c5eff2 --- /dev/null +++ b/engines/zvision/scripting/sidefx/distort_node.h @@ -0,0 +1,63 @@ +/* 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 ZVISION_DISTORT_NODE_H +#define ZVISION_DISTORT_NODE_H + +#include "zvision/scripting/sidefx.h" + +namespace ZVision { + +class ZVision; + +class DistortNode : public SideFX { +public: + DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin); + ~DistortNode(); + + bool process(uint32 deltaTimeInMillis); + +private: + int16 _speed; + float _st_angl; + float _en_angl; + float _st_lin; + float _en_lin; + + float _frmSpeed; + float _diff_angl; + float _diff_lin; + bool _incr; + int16 _frames; + + float _curFrame; + + float _angle; + float _linScale; + +private: + void setParams(float angl, float linScale); +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 19b2e9123db86193ad297bf867f7768dfdb389e9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 23 Oct 2014 17:12:25 +0700 Subject: ZVISION: Add distort_node to module.mk for success build --- engines/zvision/module.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 3f00d67c4c..1730bbc512 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS := \ scripting/script_manager.o \ scripting/sidefx.o \ scripting/sidefx/animation_node.o \ + scripting/sidefx/distort_node.o \ scripting/sidefx/music_node.o \ scripting/sidefx/region_node.o \ scripting/sidefx/syncsound_node.o \ -- cgit v1.2.3 From 8b18ba64ae544e762ca29449e7be29f6a430201e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 23 Oct 2014 17:13:56 +0700 Subject: ZVISION: Add support for doubleFPS feature --- engines/zvision/detection.cpp | 8 ++++++++ engines/zvision/zvision.cpp | 3 +++ engines/zvision/zvision.h | 1 + 3 files changed, 12 insertions(+) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 5ad2e7d977..1492ade639 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -106,6 +106,13 @@ static const ExtraGuiOption ZVisionExtraGuiOption = { false }; +static const ExtraGuiOption ZVisionExtraGuiOption2 = { + _s("Double FPS"), + _s("Halve the update delay"), + "doublefps", + false +}; + class ZVisionMetaEngine : public AdvancedMetaEngine { public: ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) { @@ -162,6 +169,7 @@ bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const { ExtraGuiOptions options; options.push_back(ZVisionExtraGuiOption); + options.push_back(ZVisionExtraGuiOption2); return options; } diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index a78d68dc8c..0bc5fef39a 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -173,6 +173,7 @@ void ZVision::initialize() { // Create debugger console. It requires GFX to be initialized _console = new Console(this); + _halveDelay = ConfMan.getBool("doublefps"); } Common::Error ZVision::run() { @@ -210,6 +211,8 @@ Common::Error ZVision::run() { int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); // Ensure non-negative delay = delay < 0 ? 0 : delay; + if (_halveDelay) + delay >>= 1; _system->delayMillis(delay); } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index cbd10da0d5..8a305f5d37 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -121,6 +121,7 @@ private: int _rendDelay; int16 _velocity; + bool _halveDelay; public: uint32 getFeatures() const; Common::Language getLanguage() const; -- cgit v1.2.3 From 9c885719fd27be0c84ede2f403dc5ab82065ecd4 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 24 Oct 2014 18:18:11 +0200 Subject: GCW0: Initial code for GCW Zero port --- dists/gcw0/default.gcw0.desktop | 16 ++++++ dists/gcw0/opk_make.sh | 111 ++++++++++++++++++++++++++++++++++++++++ dists/gcw0/scummvm.png | Bin 0 -> 2656 bytes dists/gcw0/scummvm.sh | 9 ++++ dists/gcw0/scummvmrc | 6 +++ ports.mk | 16 ++++++ 6 files changed, 158 insertions(+) create mode 100644 dists/gcw0/default.gcw0.desktop create mode 100755 dists/gcw0/opk_make.sh create mode 100644 dists/gcw0/scummvm.png create mode 100755 dists/gcw0/scummvm.sh create mode 100644 dists/gcw0/scummvmrc diff --git a/dists/gcw0/default.gcw0.desktop b/dists/gcw0/default.gcw0.desktop new file mode 100644 index 0000000000..32c2982da7 --- /dev/null +++ b/dists/gcw0/default.gcw0.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Name=ScummVM +Comment=Interpreter for several adventure games +Comment[pl]=Interpreter graficznych gier przygodowych +Comment[sv]=Tolk för flera äventyrsspel +Comment[he]=פרשן למספר משחקי הרפתקאות +Comment[de]=Interpreter für diverse Abenteuerspiele +Comment[es]=Intérprete para varias aventuras gráficas +Comment[ca]=Intèrpret per diverses aventures gràfiques +Exec=scummvm +Icon=scummvm +Terminal=false +Type=Application +Categories=Game;AdventureGame; +StartupNotify=false +X-OD-Manual=README diff --git a/dists/gcw0/opk_make.sh b/dists/gcw0/opk_make.sh new file mode 100755 index 0000000000..b1bfd03efb --- /dev/null +++ b/dists/gcw0/opk_make.sh @@ -0,0 +1,111 @@ +#!/bin/bash +# +# opk_make.sh +# +# This script is meant to ease generation of a opk file. Please consult the output +# when running --help for a list of available parameters and an explaination of +# those. +# +# Required tools when running the script: +# bash +# echo, cat, mv, rm, mksquashfs + +check_for_tool() +{ + which $1 &> /dev/null + if [ "$?" -ne "0" ]; + then + cecho "ERROR: Could not find the program '$1'. Please make sure +that it is available in your PATH since it is required to complete your request." $red + exit 1 + fi +} + +print_help() +{ + cat << EOSTREAM +opk_make.sh - A script to package "something" into a OPK. + +Usage: + $(basename ${0}) {--directory|-d} {--opk|-o} [{--help|-h}] + + +Switches: + --directory / -d Sets the folder that is to be used for the resulting opk + to . This option is mandatory for the script to + function correctly. + + --help / -h Displays this help text. + + --opkname / -o Sets the output filename of the resulting opk to . + This option is mandatory for the script to function + correctly. + +A version >=4.0 of squashfs is required to be available in your PATH. +EOSTREAM +} + + +# Parse command line parameters +while [ "${1}" != "" ]; do + if [ "${1}" = "--directory" ] || [ "${1}" = "-d" ]; + then + FOLDER=$2 + shift 2 + elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ]; + then + print_help + exit 0 + elif [ "${1}" = "--opkname" ] || [ "${1}" = "-o" ]; + then + OPKNAME=$2 + shift 2 + else + echo "ERROR: '$1' is not a known argument. Printing --help and aborting." + print_help + exit 1 + fi +done + + +# Probe if required variables were set +echo "Checking if all required variables were set." +if [ ! $OPKNAME ] || [ ! $FOLDER ]; +then + echo "ERROR: Not all required options were set! Please see the --help information below." + print_help + exit 1 +else + echo "OPKNAME set to '$OPKNAME'." +fi +# Check if the selected folder actually exists +if [ ! -d $FOLDER ]; +then + echo "ERROR: '$FOLDER' doesn't exist or is not a folder." + exit 1 +else + echo "FOLDER set to '$FOLDER'." +fi + +# Make iso from folder +echo "Creating an iso file based on '$FOLDER'." + +check_for_tool mksquashfs +if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ]; +then + echo "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" + exit 1 +fi +mksquashfs $FOLDER $OPKNAME.opk -noappend -no-exports -no-xattrs + +# Final message +if [ -f $OPKNAME ]; +then + echo "Successfully finished creating the opk '$OPKNAME'." +else + echo "There seems to have been a problem and '$OPKNAME' was not created. Please check +the output above for any error messages. A possible cause for this is that there was +not enough space available." + exit 1 +fi + diff --git a/dists/gcw0/scummvm.png b/dists/gcw0/scummvm.png new file mode 100644 index 0000000000..128e59efc4 Binary files /dev/null and b/dists/gcw0/scummvm.png differ diff --git a/dists/gcw0/scummvm.sh b/dists/gcw0/scummvm.sh new file mode 100755 index 0000000000..c12a3030cc --- /dev/null +++ b/dists/gcw0/scummvm.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +cd `dirname $0` + +if [ ! -f $HOME/.scummvmrc ] ; then + cp ./scummvmrc $HOME/.scummvmrc +fi + +exec ./scummvm diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc new file mode 100644 index 0000000000..afa295e4b6 --- /dev/null +++ b/dists/gcw0/scummvmrc @@ -0,0 +1,6 @@ +[scummvm] +fullscreen=true +gfx_mode=1x +aspect_ratio=true +themepath=/mnt/scummvm +browser_lastpath=/media diff --git a/ports.mk b/ports.mk index 97b43fe92e..ce6bf38ab2 100644 --- a/ports.mk +++ b/ports.mk @@ -293,6 +293,22 @@ win32setup: $(EXECUTABLE) makensis -V2 -Dtop_srcdir="../.." -Dstaging_dir="../../$(STAGINGPATH)" -Darch=$(ARCH) $(srcdir)/dists/win32/scummvm.nsi +# Special target for generationg GCW-Zero OPK bundle +gcw0-opk: + mkdir gcw0-opk + cp $(DIST_FILES_DOCS) gcw0-opk/ + cp $(DIST_FILES_THEMES) gcw0-opk/ +ifdef DIST_FILES_ENGINEDATA + cp $(DIST_FILES_ENGINEDATA) gcw0-opk/ +endif + $(STRIP) scummvm + chmod 755 scummvm + cp scummvm gcw0-opk/ + cp $(srcdir)/dists/gcw0/scummvm.png gcw0-opk/ + cp $(srcdir)/dists/gcw0/default.gcw0.desktop gcw0-opk/ + cp $(srcdir)/dists/gcw0/scummvmrc gcw0-opk/ + cp $(srcdir)/dists/gcw0/scummvm.sh gcw0-opk/ + ./dists/gcw0/opk_make.sh -d gcw0-opk -o scummvm.opk # # Special target to generate project files for various IDEs # Mainly Win32-specific -- cgit v1.2.3 From b6302c6e5155af097940c0043e1b7941c2c1fefe Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 25 Oct 2014 20:52:14 +0200 Subject: PRINCE: Fix potential out-of-bounds write (CID 1248504) There are kMaxTexts text slots, so kMaxTexts itself is not valid. --- engines/prince/prince.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 29c434e9c9..17cef6327f 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -730,8 +730,8 @@ bool PrinceEngine::loadSample(uint32 sampleSlot, const Common::String &streamNam bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::String &streamName) { debugEngine("Loading wav %s slot %d", streamName.c_str(), slot); - if (slot > kMaxTexts) { - error("Text slot bigger than MAXTEXTS %d", kMaxTexts); + if (slot >= kMaxTexts) { + error("Text slot bigger than MAXTEXTS %d", kMaxTexts - 1); return false; } -- cgit v1.2.3 From 0579bf6f18e56410e1b94e97034c8db774e73b06 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 25 Oct 2014 20:57:52 +0200 Subject: PRINCE: Fix potential out-of-bounds reads (CID 1248500, 1248503) Since heroSetTable[] is an array of int, use >= ARRAYSIZE() instead of > sizeof(). --- engines/prince/hero.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 06fba25ba9..146470f6b7 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -54,7 +54,7 @@ Hero::~Hero() { bool Hero::loadAnimSet(uint32 animSetNr) { _animSetNr = animSetNr; - if (animSetNr > sizeof(heroSetTable)) { + if (animSetNr >= ARRAYSIZE(heroSetTable)) { return false; } -- cgit v1.2.3 From f25e889c13238671c8ce33a95bcf59f82e70c5c3 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 25 Oct 2014 21:02:03 +0200 Subject: PRINCE: Fix potential out-of-bounds read (CID 1248502) Since _opcodes[] has kNumOpcodes elements, kNumOpcodes itself is not a valid index. --- engines/prince/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 0e9dd27877..25249d3236 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -477,7 +477,7 @@ uint32 Interpreter::step(uint32 opcodePC) { // Get the current opcode _lastOpcode = readScript16(); - if (_lastOpcode > kNumOpcodes) + if (_lastOpcode >= kNumOpcodes) error( "Trying to execute unknown opcode @0x%04X: %02d", _currentInstruction, -- cgit v1.2.3 From 4fdd9bbab33e00e2520c642bf5cca798b8e6e1b5 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 25 Oct 2014 21:11:49 +0200 Subject: ZVISION: Fix memory leak (CID 1109659) --- engines/zvision/fonts/truetype_font.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp index ba4d72bde8..45eaeeb2b4 100644 --- a/engines/zvision/fonts/truetype_font.cpp +++ b/engines/zvision/fonts/truetype_font.cpp @@ -95,6 +95,7 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, u lines.pop_back(); } if (lines.size() == 0) { + delete surface; return nullptr; } -- cgit v1.2.3 From 522cd1c97082a7cae83b39877d4d33abc6770756 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 09:30:21 +0100 Subject: PRINCE: Fix warning --- engines/prince/prince.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 17cef6327f..b0f2cd5056 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1901,29 +1901,29 @@ void PrinceEngine::blackPalette() { void PrinceEngine::setPalette(const byte *palette) { if (palette != nullptr) { - byte *blackPalette = (byte *)malloc(256 * 3); + byte *blackPalette_ = (byte *)malloc(256 * 3); int fadeStep = 0; for (int i = 0; i <= kFadeStep; i++) { for (int j = 0; j < 256; j++) { - blackPalette[3 * j] = palette[3 * j] * fadeStep / 4; - blackPalette[3 * j + 1] = palette[3 * j + 1] * fadeStep / 4; - blackPalette[3 * j + 2] = palette[3 * j + 2] * fadeStep / 4; + blackPalette_[3 * j] = palette[3 * j] * fadeStep / 4; + blackPalette_[3 * j + 1] = palette[3 * j + 1] * fadeStep / 4; + blackPalette_[3 * j + 2] = palette[3 * j + 2] * fadeStep / 4; } fadeStep++; - _graph->setPalette(blackPalette); + _graph->setPalette(blackPalette_); _system->updateScreen(); Common::Event event; Common::EventManager *eventMan = _system->getEventManager(); eventMan->pollEvent(event); if (shouldQuit()) { _graph->setPalette(palette); - free(blackPalette); + free(blackPalette_); return; } pause(); } _graph->setPalette(palette); - free(blackPalette); + free(blackPalette_); } } -- cgit v1.2.3 From 3b9ac0318cdd35d645e2ae724dcddb5a3d018345 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 09:32:58 +0100 Subject: PRINCE: Fix variable sign --- engines/prince/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 25249d3236..71d003da8f 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -391,7 +391,7 @@ bool Script::loadAllMasks(Common::Array &maskList, int offset) { debug("Can't load %s", msStreamName.c_str()); delete msStream; } else { - uint32 dataSize = msStream->size(); + int32 dataSize = msStream->size(); if (dataSize != -1) { tempMask._data = (byte *)malloc(dataSize); if (msStream->read(tempMask._data, dataSize) != dataSize) { -- cgit v1.2.3 From 123e52f441619d5c866b9f6e05fcc2775a405830 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 09:34:48 +0100 Subject: PRINCE: Fix another variable sign --- engines/prince/script.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 71d003da8f..d1a0034940 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -394,7 +394,7 @@ bool Script::loadAllMasks(Common::Array &maskList, int offset) { int32 dataSize = msStream->size(); if (dataSize != -1) { tempMask._data = (byte *)malloc(dataSize); - if (msStream->read(tempMask._data, dataSize) != dataSize) { + if (msStream->read(tempMask._data, dataSize) != (uint32)dataSize) { free(tempMask._data); delete msStream; return false; -- cgit v1.2.3 From d4c687ddc8b5e4075c8085b7e761a9da3f2cbe74 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 07:00:36 -0400 Subject: GCW0: Further work on the port --- backends/platform/dingux/dingux.mk | 28 ++++++++++++++++++++++++++++ dists/gcw0/scummvm.sh | 2 +- dists/gcw0/scummvmrc | 4 +++- ports.mk | 16 ---------------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk index 48a9347143..f02801ea98 100644 --- a/backends/platform/dingux/dingux.mk +++ b/backends/platform/dingux/dingux.mk @@ -1,6 +1,7 @@ DINGUX_EXE_STRIPPED := scummvm_stripped$(EXEEXT) bundle_name = dingux-dist/scummvm +gcw0_bundle = gcw0-opk all: $(DINGUX_EXE_STRIPPED) @@ -30,3 +31,30 @@ endif $(CP) $(srcdir)/backends/platform/dingux/scummvm.gpe $(bundle_name)/ $(CP) $(srcdir)/backends/platform/dingux/README.DINGUX $(bundle_name)/ $(CP) $(srcdir)/backends/platform/dingux/scummvm.png $(bundle_name)/ + +# Special target for generationg GCW-Zero OPK bundle +gcw0-opk: all + $(MKDIR) $(gcw0_bundle) + $(CP) $(DIST_FILES_DOCS) $(gcw0_bundle)/ + $(MKDIR) $(gcw0_bundle)/themes + $(CP) $(DIST_FILES_THEMES) $(gcw0_bundle)/themes/ +ifdef DIST_FILES_ENGINEDATA + $(MKDIR) $(gcw0_bundle)/engine-data + $(CP) $(DIST_FILES_ENGINEDATA) $(gcw0_bundle)/engine-data/ +endif +ifdef DYNAMIC_MODULES + $(MKDIR) $(gcw0_bundle)/plugins + $(CP) $(PLUGINS) $(gcw0_bundle)/plugins/ + $(STRIP) $(gcw0_bundle)/plugins/* +endif + $(STRIP) $(EXECUTABLE) -o $(gcw0_bundle)/scummvm + + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(gcw0_bundle)/ + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_small.zip $(gcw0_bundle)/ + + $(CP) $(srcdir)/dists/gcw0/scummvm.png $(gcw0_bundle)/ + $(CP) $(srcdir)/dists/gcw0/default.gcw0.desktop $(gcw0_bundle)/ + $(CP) $(srcdir)/dists/gcw0/scummvmrc $(gcw0_bundle)/ + $(CP) $(srcdir)/dists/gcw0/scummvm.sh $(gcw0_bundle)/ + ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm + diff --git a/dists/gcw0/scummvm.sh b/dists/gcw0/scummvm.sh index c12a3030cc..5ad7a8579a 100755 --- a/dists/gcw0/scummvm.sh +++ b/dists/gcw0/scummvm.sh @@ -3,7 +3,7 @@ cd `dirname $0` if [ ! -f $HOME/.scummvmrc ] ; then - cp ./scummvmrc $HOME/.scummvmrc + cp /mnt/ScummVM/scummvmrc $HOME/.scummvmrc fi exec ./scummvm diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc index afa295e4b6..87b97c191c 100644 --- a/dists/gcw0/scummvmrc +++ b/dists/gcw0/scummvmrc @@ -2,5 +2,7 @@ fullscreen=true gfx_mode=1x aspect_ratio=true -themepath=/mnt/scummvm +themepath=/mnt/ScummVM/themes browser_lastpath=/media +extrapath=/mnt/ScummVM/engine-data +pluginspath=/mnt/ScummVM/plugins diff --git a/ports.mk b/ports.mk index ce6bf38ab2..97b43fe92e 100644 --- a/ports.mk +++ b/ports.mk @@ -293,22 +293,6 @@ win32setup: $(EXECUTABLE) makensis -V2 -Dtop_srcdir="../.." -Dstaging_dir="../../$(STAGINGPATH)" -Darch=$(ARCH) $(srcdir)/dists/win32/scummvm.nsi -# Special target for generationg GCW-Zero OPK bundle -gcw0-opk: - mkdir gcw0-opk - cp $(DIST_FILES_DOCS) gcw0-opk/ - cp $(DIST_FILES_THEMES) gcw0-opk/ -ifdef DIST_FILES_ENGINEDATA - cp $(DIST_FILES_ENGINEDATA) gcw0-opk/ -endif - $(STRIP) scummvm - chmod 755 scummvm - cp scummvm gcw0-opk/ - cp $(srcdir)/dists/gcw0/scummvm.png gcw0-opk/ - cp $(srcdir)/dists/gcw0/default.gcw0.desktop gcw0-opk/ - cp $(srcdir)/dists/gcw0/scummvmrc gcw0-opk/ - cp $(srcdir)/dists/gcw0/scummvm.sh gcw0-opk/ - ./dists/gcw0/opk_make.sh -d gcw0-opk -o scummvm.opk # # Special target to generate project files for various IDEs # Mainly Win32-specific -- cgit v1.2.3 From 2699259638373381880a01eefdb8608b1d78579b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 07:19:37 -0400 Subject: GCW0: Correct launch options --- dists/gcw0/default.gcw0.desktop | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dists/gcw0/default.gcw0.desktop b/dists/gcw0/default.gcw0.desktop index 32c2982da7..46bd2be092 100644 --- a/dists/gcw0/default.gcw0.desktop +++ b/dists/gcw0/default.gcw0.desktop @@ -7,10 +7,10 @@ Comment[he]=פרשן למספר משחקי הרפתקאות Comment[de]=Interpreter für diverse Abenteuerspiele Comment[es]=Intérprete para varias aventuras gráficas Comment[ca]=Intèrpret per diverses aventures gràfiques -Exec=scummvm +Exec=scummvm.sh Icon=scummvm Terminal=false Type=Application -Categories=Game;AdventureGame; +Categories=games StartupNotify=false X-OD-Manual=README -- cgit v1.2.3 From 0ee20cebc759a8d7e75e34177ed71b62cdabd987 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 07:20:11 -0400 Subject: GCW0: Enable analog joystick by default --- dists/gcw0/scummvmrc | 1 + 1 file changed, 1 insertion(+) diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc index 87b97c191c..1f4043b3ae 100644 --- a/dists/gcw0/scummvmrc +++ b/dists/gcw0/scummvmrc @@ -6,3 +6,4 @@ themepath=/mnt/ScummVM/themes browser_lastpath=/media extrapath=/mnt/ScummVM/engine-data pluginspath=/mnt/ScummVM/plugins +joystick=0 -- cgit v1.2.3 From 5b5a2bc7a4c10e3c18a9cc7a7dca5c01c440d8f3 Mon Sep 17 00:00:00 2001 From: Matthias Mailänder Date: Sun, 14 Sep 2014 10:48:45 +0200 Subject: BUILD: Install the theme-able SVG icon Add missing hicolor SVG icon to install. Retain older pixmaps xpm icon for now. --- ports.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports.mk b/ports.mk index 97b43fe92e..fdab7e23af 100644 --- a/ports.mk +++ b/ports.mk @@ -12,6 +12,8 @@ install: $(INSTALL) -c -m 644 "$(srcdir)/dists/scummvm.6" "$(DESTDIR)$(mandir)/man6/scummvm.6" $(INSTALL) -d "$(DESTDIR)$(datarootdir)/pixmaps/" $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.xpm" "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm" + $(INSTALL) -d "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/" + $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.svg" "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg" $(INSTALL) -d "$(DESTDIR)$(docdir)" $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) "$(DESTDIR)$(docdir)" $(INSTALL) -d "$(DESTDIR)$(datadir)" @@ -28,6 +30,8 @@ install-strip: $(INSTALL) -c -m 644 "$(srcdir)/dists/scummvm.6" "$(DESTDIR)$(mandir)/man6/scummvm.6" $(INSTALL) -d "$(DESTDIR)$(datarootdir)/pixmaps/" $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.xpm" "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm" + $(INSTALL) -d "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/" + $(INSTALL) -c -m 644 "$(srcdir)/icons/scummvm.svg" "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg" $(INSTALL) -d "$(DESTDIR)$(docdir)" $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) "$(DESTDIR)$(docdir)" $(INSTALL) -d "$(DESTDIR)$(datadir)" @@ -41,6 +45,7 @@ uninstall: rm -f "$(DESTDIR)$(bindir)/$(EXECUTABLE)" rm -f "$(DESTDIR)$(mandir)/man6/scummvm.6" rm -f "$(DESTDIR)$(datarootdir)/pixmaps/scummvm.xpm" + rm -f "$(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/scummvm.svg" rm -rf "$(DESTDIR)$(docdir)" rm -rf "$(DESTDIR)$(datadir)" ifdef DYNAMIC_MODULES -- cgit v1.2.3 From f5e273ded942d2de09be4673cc6b6f136d6ed1e3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 14:29:43 -0400 Subject: GCW0: Create log file at game launch --- dists/gcw0/scummvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dists/gcw0/scummvm.sh b/dists/gcw0/scummvm.sh index 5ad7a8579a..4ffb429130 100755 --- a/dists/gcw0/scummvm.sh +++ b/dists/gcw0/scummvm.sh @@ -6,4 +6,4 @@ if [ ! -f $HOME/.scummvmrc ] ; then cp /mnt/ScummVM/scummvmrc $HOME/.scummvmrc fi -exec ./scummvm +exec ./scummvm 2>&1 >$HOME/scummvm.log -- cgit v1.2.3 From 293a0d0046c9f393f741de66a9ffa0dbc06991e2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 14:30:29 -0400 Subject: GCW0: Create target with unstripped binaries --- backends/platform/dingux/dingux.mk | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/backends/platform/dingux/dingux.mk b/backends/platform/dingux/dingux.mk index f02801ea98..1333e89ff8 100644 --- a/backends/platform/dingux/dingux.mk +++ b/backends/platform/dingux/dingux.mk @@ -33,7 +33,7 @@ endif $(CP) $(srcdir)/backends/platform/dingux/scummvm.png $(bundle_name)/ # Special target for generationg GCW-Zero OPK bundle -gcw0-opk: all +$(gcw0_bundle): all $(MKDIR) $(gcw0_bundle) $(CP) $(DIST_FILES_DOCS) $(gcw0_bundle)/ $(MKDIR) $(gcw0_bundle)/themes @@ -45,9 +45,8 @@ endif ifdef DYNAMIC_MODULES $(MKDIR) $(gcw0_bundle)/plugins $(CP) $(PLUGINS) $(gcw0_bundle)/plugins/ - $(STRIP) $(gcw0_bundle)/plugins/* endif - $(STRIP) $(EXECUTABLE) -o $(gcw0_bundle)/scummvm + $(CP) $(EXECUTABLE) $(gcw0_bundle)/scummvm $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(gcw0_bundle)/ $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_small.zip $(gcw0_bundle)/ @@ -56,5 +55,13 @@ endif $(CP) $(srcdir)/dists/gcw0/default.gcw0.desktop $(gcw0_bundle)/ $(CP) $(srcdir)/dists/gcw0/scummvmrc $(gcw0_bundle)/ $(CP) $(srcdir)/dists/gcw0/scummvm.sh $(gcw0_bundle)/ + +gcw0-opk-unstripped: $(gcw0_bundle) + $(CP) $(PLUGINS) $(gcw0_bundle)/plugins/ + $(CP) $(EXECUTABLE) $(gcw0_bundle)/scummvm ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm +gcw-opk: $(gcw0_bundle) + $(STRIP) $(gcw0_bundle)/plugins/* + $(STRIP) $(gcw0_bundle)/scummvm + ./dists/gcw0/opk_make.sh -d $(gcw0_bundle) -o scummvm -- cgit v1.2.3 From 6046863fdd2f5e5d3622c8942ce39ca743857988 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 14:31:02 -0400 Subject: BASE: Display virtual keyboard and keymapper in game options --- base/version.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/version.cpp b/base/version.cpp index ef02ff9d21..fcb2740de9 100644 --- a/base/version.cpp +++ b/base/version.cpp @@ -146,4 +146,12 @@ const char *gScummVMFeatures = "" #ifdef USE_PNG "PNG " #endif + +#ifdef ENABLE_KEYMAPPER + "keymapper " +#endif + +#ifdef ENABLE_VKEYBD + "virtual keyboard " +#endif ; -- cgit v1.2.3 From d1169beed169a906925ee078fd7439ac455c8b97 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 14:31:36 -0400 Subject: CONFIGURE: Create port-specific platform for GCW0 --- configure | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 5264e32410..09b8383120 100755 --- a/configure +++ b/configure @@ -822,9 +822,9 @@ Usage: $0 [OPTIONS]... Configuration: -h, --help display this help and exit - --backend=BACKEND backend to build (android, tizen, dc, dingux, ds, gph, - iphone, linuxmoto, maemo, n64, null, openpandora, ps2, - psp, samsungtv, sdl, webos, wii, wince) [sdl] + --backend=BACKEND backend to build (android, tizen, dc, dingux, ds, gcw0, + gph, iphone, linuxmoto, maemo, n64, null, openpandora, + ps2, psp, samsungtv, sdl, webos, wii, wince) [sdl] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX @@ -859,6 +859,7 @@ Special configuration feature: dreamcast for Sega Dreamcast ds for Nintendo DS gamecube for Nintendo GameCube + gcw0 for GCW Zero gp2x for GP2X gp2xwiz for GP2X Wiz iphone for Apple iPhone @@ -1298,7 +1299,7 @@ caanoo) _host_cpu=arm _host_alias=arm-none-linux-gnueabi ;; -dingux) +dingux | gcw0) _host_os=linux _host_cpu=mipsel _host_alias=mipsel-linux @@ -2588,6 +2589,27 @@ if test -n "$_host"; then add_line_to_config_h "/* #define DEBUG_WII_GDB */" add_line_to_config_h "#define USE_WII_DI" ;; + gcw0) + DEFINES="$DEFINES -DDINGUX" + DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" + ASFLAGS="$ASFLAGS" + CXXFLAGS="$CXXFLAGS -msoft-float" + CXXFLAGS="$CXXFLAGS -mips32" + _backend="dingux" + _mt32emu=no + _optimization_level=-O3 + # Disable alsa midi to get the port build on OpenDingux toolchain + _alsa=no + _vkeybd=yes + _build_hq_scalers=no + _keymapper=yes + # Force disable vorbis on dingux, it has terrible performance compared to tremor + _vorbis=no + # Force disable seq on dingux, no way to use it and it would get enabled by default with configure + _seq_midi=no + _port_mk="backends/platform/dingux/dingux.mk" + ;; gp2x) DEFINES="$DEFINES -DGP2X" CXXFLAGS="$CXXFLAGS -march=armv4t" -- cgit v1.2.3 From 732f9582fa368b810010cbebe89dc47a1defdba2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 15:41:30 -0400 Subject: GCW0: Remove absolute paths --- dists/gcw0/scummvm.sh | 4 ++-- dists/gcw0/scummvmrc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dists/gcw0/scummvm.sh b/dists/gcw0/scummvm.sh index 4ffb429130..c12a3030cc 100755 --- a/dists/gcw0/scummvm.sh +++ b/dists/gcw0/scummvm.sh @@ -3,7 +3,7 @@ cd `dirname $0` if [ ! -f $HOME/.scummvmrc ] ; then - cp /mnt/ScummVM/scummvmrc $HOME/.scummvmrc + cp ./scummvmrc $HOME/.scummvmrc fi -exec ./scummvm 2>&1 >$HOME/scummvm.log +exec ./scummvm diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc index 1f4043b3ae..fcffd9ada6 100644 --- a/dists/gcw0/scummvmrc +++ b/dists/gcw0/scummvmrc @@ -2,8 +2,8 @@ fullscreen=true gfx_mode=1x aspect_ratio=true -themepath=/mnt/ScummVM/themes +themepath=./themes browser_lastpath=/media -extrapath=/mnt/ScummVM/engine-data -pluginspath=/mnt/ScummVM/plugins +extrapath=./engine-data +pluginspath=./plugins joystick=0 -- cgit v1.2.3 From f16064613bb6a39835d56bc6abe99b3e37ad7f93 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 15:57:26 -0400 Subject: GCW0: Fix default joystick number --- dists/gcw0/scummvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dists/gcw0/scummvmrc b/dists/gcw0/scummvmrc index fcffd9ada6..c2087c222a 100644 --- a/dists/gcw0/scummvmrc +++ b/dists/gcw0/scummvmrc @@ -6,4 +6,4 @@ themepath=./themes browser_lastpath=/media extrapath=./engine-data pluginspath=./plugins -joystick=0 +joystick_num=0 -- cgit v1.2.3 From 9b8b737fad2da90d3a4ec40029f876300c9d181a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 22:20:57 +0100 Subject: KEYMAPPER: Fix off-by-one error with keymapper action names --- backends/keymapper/action.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index ed4bb86ce6..17b1153c77 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -37,7 +37,7 @@ namespace Common { struct HardwareInput; class Keymap; -#define ACTION_ID_SIZE (4) +#define ACTION_ID_SIZE (5) struct KeyActionEntry { const KeyState ks; -- cgit v1.2.3 From 238b3e1ac2a21ad9afd934b4bcd4057bce53ab7f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 27 Oct 2014 00:03:32 +0100 Subject: GCW0: Hardcoded (for now) GCW0 controls --- backends/events/dinguxsdl/dinguxsdl-events.cpp | 34 ++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp index 6f9f2a7748..cc15f2666c 100644 --- a/backends/events/dinguxsdl/dinguxsdl-events.cpp +++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp @@ -26,18 +26,48 @@ #include "backends/events/dinguxsdl/dinguxsdl-events.h" +#ifndef GCW0 #define PAD_UP SDLK_UP #define PAD_DOWN SDLK_DOWN #define PAD_LEFT SDLK_LEFT #define PAD_RIGHT SDLK_RIGHT #define BUT_A SDLK_LCTRL #define BUT_B SDLK_LALT -#define BUT_X SDLK_SPACE -#define BUT_Y SDLK_LSHIFT +#define BUT_X SDLK_SPACE // BUT_Y in GCW0 +#define BUT_Y SDLK_LSHIFT // BUT_X in GCW0 #define BUT_SELECT SDLK_ESCAPE #define BUT_START SDLK_RETURN #define TRIG_L SDLK_TAB #define TRIG_R SDLK_BACKSPACE +#else // GCW0 + +/****** + * GCW0 keymap + * Dingoo button + * A -> Left Button BUT_Y + * B -> right button BUT_B + * X -> ' ' BUT_A '0' + * Y -> '.' BUT_X + * Select -> ESC TRIG_R + * Start -> F5 TRIG_L + * L -> Shift BUT_START + * R -> VK BUT_SELECT + */ + +#define PAD_UP SDLK_UP +#define PAD_DOWN SDLK_DOWN +#define PAD_LEFT SDLK_LEFT +#define PAD_RIGHT SDLK_RIGHT +#define BUT_A SDLK_LSHIFT +#define BUT_B SDLK_LALT +#define BUT_X SDLK_SPACE +#define BUT_Y SDLK_LCTRL +#define BUT_SELECT SDLK_BACKSPACE +#define BUT_START SDLK_TAB +#define TRIG_L SDLK_RETURN +#define TRIG_R SDLK_ESCAPE + +#endif bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { if (ev.key.keysym.sym == PAD_UP) { -- cgit v1.2.3 From 8e3b6df83000ed02da9aa030d7b91e0f3e91a34d Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 26 Oct 2014 18:13:09 -0400 Subject: GCW0: Switch to HW floats and introduce the platform define --- configure | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configure b/configure index 09b8383120..ebca8322dc 100755 --- a/configure +++ b/configure @@ -2590,11 +2590,9 @@ if test -n "$_host"; then add_line_to_config_h "#define USE_WII_DI" ;; gcw0) - DEFINES="$DEFINES -DDINGUX" - DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL" + DEFINES="$DEFINES -DDINGUX -DGCW0" DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE" ASFLAGS="$ASFLAGS" - CXXFLAGS="$CXXFLAGS -msoft-float" CXXFLAGS="$CXXFLAGS -mips32" _backend="dingux" _mt32emu=no -- cgit v1.2.3 From 0db09d334ca1be244aa6b5865ff92919456c669f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 27 Oct 2014 03:18:03 +0200 Subject: QUEEN: Fix bug #6700 - "FOTAQ: Weird Response Glitches" Pending mouse clicks and keypresses are now cleared before and after the game options screen or dialog options are shown --- engines/queen/logic.cpp | 6 ++++++ engines/queen/talk.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/engines/queen/logic.cpp b/engines/queen/logic.cpp index d48bb8a498..664a9a15f9 100644 --- a/engines/queen/logic.cpp +++ b/engines/queen/logic.cpp @@ -2115,9 +2115,15 @@ void LogicInterview::setupSpecialMoveTable() { } void LogicGame::useJournal() { + _vm->input()->clearKeyVerb(); + _vm->input()->clearMouseButton(); + _vm->command()->clear(false); _journal->use(); _vm->walk()->stopJoe(); + + _vm->input()->clearKeyVerb(); + _vm->input()->clearMouseButton(); } bool LogicGame::changeToSpecialRoom() { diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp index 1b9d72babc..d00e64b777 100644 --- a/engines/queen/talk.cpp +++ b/engines/queen/talk.cpp @@ -1250,6 +1250,7 @@ int16 Talk::selectSentence() { } _vm->input()->clearKeyVerb(); + _vm->input()->clearMouseButton(); if (sentenceCount > 0) { int oldZone = 0; @@ -1328,6 +1329,9 @@ int16 Talk::selectSentence() { } } + _vm->input()->clearKeyVerb(); + _vm->input()->clearMouseButton(); + debug(6, "Selected sentence %i", selectedSentence); arrowBobUp->active = false; -- cgit v1.2.3 From b5b5417d64eacd21d441631e7a5e0c618bfadebd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 27 Oct 2014 03:36:52 +0200 Subject: QUEEN: Allow the engine to quit while dialog options are shown --- engines/queen/talk.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/engines/queen/talk.cpp b/engines/queen/talk.cpp index d00e64b777..e86a53d448 100644 --- a/engines/queen/talk.cpp +++ b/engines/queen/talk.cpp @@ -189,7 +189,7 @@ void Talk::talk(const char *filename, int personInRoom, char *cutawayFilename) { } } - if (_vm->input()->talkQuit()) + if (_vm->input()->talkQuit() || _vm->shouldQuit()) break; retval = _dialogueTree[level][selectedSentence].dialogueNodeValue1; @@ -1255,11 +1255,7 @@ int16 Talk::selectSentence() { if (sentenceCount > 0) { int oldZone = 0; - while (0 == selectedSentence) { - - if (_vm->input()->talkQuit()) - break; - + while (0 == selectedSentence && !_vm->input()->talkQuit() && !_vm->shouldQuit()) { _vm->update(); Common::Point mouse = _vm->input()->getMousePos(); -- cgit v1.2.3 From 2a6a79b1673e274420ca8c28f40f9855b1c6134f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 27 Oct 2014 12:28:18 +0200 Subject: SAGA: Remove the buggy actor swapping fixup code for IHNM This was a hack that was implemented while IHNM was being developed. That code should no longer be needed. If this issue does occur again, the actual cause should be investigated, instead of hiding it with workarounds. The code was buggy anyway, as _currentProtag was not initialized properly --- engines/saga/actor.h | 1 - engines/saga/saveload.cpp | 29 ++--------------------------- engines/saga/scene.h | 3 --- engines/saga/sfuncs.cpp | 4 ---- 4 files changed, 2 insertions(+), 35 deletions(-) diff --git a/engines/saga/actor.h b/engines/saga/actor.h index b8a5436d76..8dc27c74be 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -468,7 +468,6 @@ public: int actorIdToIndex(uint16 id) { return (id == ID_PROTAG) ? 0 : objectIdToIndex(id); } uint16 actorIndexToId(int index) { return (index == 0) ? ID_PROTAG : objectIndexToId(kGameObjectActor, index); } ActorData *getActor(uint16 actorId); - ActorData *getFirstActor() { return &_actors.front(); } // clarification: Obj - means game object, such Hat, Spoon etc, Object - means Actor,Obj,HitZone,StepZone diff --git a/engines/saga/saveload.cpp b/engines/saga/saveload.cpp index 90ba62070b..e659e09ce8 100644 --- a/engines/saga/saveload.cpp +++ b/engines/saga/saveload.cpp @@ -215,8 +215,7 @@ void SagaEngine::save(const char *fileName, const char *saveName) { #ifdef ENABLE_IHNM if (getGameId() == GID_IHNM) { out->writeSint32LE(_scene->currentChapterNumber()); - // Protagonist - out->writeSint32LE(_scene->currentProtag()); + out->writeSint32LE(0); // obsolete, was used for the protagonist out->writeSint32LE(_scene->getCurrentMusicTrack()); out->writeSint32LE(_scene->getCurrentMusicRepeat()); } @@ -316,7 +315,7 @@ void SagaEngine::load(const char *fileName) { if (getGameId() == GID_IHNM) { int currentChapter = _scene->currentChapterNumber(); _scene->setChapterNumber(in->readSint32LE()); - _scene->setProtag(in->readSint32LE()); + in->skip(4); // obsolete, was used for setting the protagonist if (_scene->currentChapterNumber() != currentChapter) _scene->changeScene(-2, 0, kTransitionFade, _scene->currentChapterNumber()); _scene->setCurrentMusicTrack(in->readSint32LE()); @@ -366,30 +365,6 @@ void SagaEngine::load(const char *fileName) { int volume = _music->getVolume(); _music->setVolume(0); -#ifdef ENABLE_IHNM - // Protagonist swapping - if (getGameId() == GID_IHNM) { - if (_scene->currentProtag() != 0 && _scene->currentChapterNumber() != 6) { - ActorData *actor1 = _actor->getFirstActor(); - ActorData *actor2; - // The original gets actor2 from the current protagonist ID, but this is sometimes wrong - // If the current protagonist ID is not correct, use the stored protagonist - if (!_actor->validActorId(_scene->currentProtag())) { - actor2 = _actor->_protagonist; - } else { - actor2 = _actor->getActor(_scene->currentProtag()); - } - - SWAP(actor1->_location, actor2->_location); - - actor2->_flags &= ~kProtagonist; - actor1->_flags |= kProtagonist; - _actor->_protagonist = _actor->_centerActor = actor1; - _scene->setProtag(actor1->_id); - } - } -#endif - _scene->clearSceneQueue(); _scene->changeScene(sceneNumber, ACTOR_NO_ENTRANCE, kTransitionNoFade); diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 6a9571d282..410713c5d5 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -286,8 +286,6 @@ class Scene { #endif return _sceneLUT[sceneNumber]; } - int currentProtag() const { return _currentProtag; } - void setProtag(int pr) { _currentProtag = pr; } int currentSceneNumber() const { return _sceneNumber; } int currentChapterNumber() const { return _chapterNumber; } void setChapterNumber(int ch) { _chapterNumber = ch; } @@ -341,7 +339,6 @@ class Scene { Common::Array _sceneLUT; SceneQueueList _sceneQueue; bool _sceneLoaded; - int _currentProtag; int _sceneNumber; int _chapterNumber; int _outsetSceneNumber; diff --git a/engines/saga/sfuncs.cpp b/engines/saga/sfuncs.cpp index cb963e23ac..2175d8f40a 100644 --- a/engines/saga/sfuncs.cpp +++ b/engines/saga/sfuncs.cpp @@ -748,14 +748,10 @@ void Script::sfSwapActors(SCRIPTFUNC_PARAMS) { actor1->_flags &= ~kProtagonist; actor2->_flags |= kProtagonist; _vm->_actor->_protagonist = _vm->_actor->_centerActor = actor2; - if (_vm->getGameId() == GID_IHNM) - _vm->_scene->setProtag(actorId2); } else if (actor2->_flags & kProtagonist) { actor2->_flags &= ~kProtagonist; actor1->_flags |= kProtagonist; _vm->_actor->_protagonist = _vm->_actor->_centerActor = actor1; - if (_vm->getGameId() == GID_IHNM) - _vm->_scene->setProtag(actorId1); } } -- cgit v1.2.3 From 7be3bc7004f0e20475bc32c6c54f0f94d2f8f7a4 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Mon, 22 Sep 2014 12:07:01 +0200 Subject: SCUMM: balloon - There is no spanish version. --- devtools/scumm-md5.txt | 2 +- engines/scumm/scumm-md5.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index f0cb577237..856abbf7e0 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -820,7 +820,7 @@ balloon Putt-Putt and Pep's Balloon-O-Rama bab0fb81dcb12b8930c5d850b8f2a7de 12800 de Windows HE 80 - - George Kormendi 145bd3373574feb668cc2eea2ec6cf86 -1 ru Windows HE 80 - - sev 27b2ef1653089fe5b897d9cc89ce784f -1 ru Windows HE 80 - - George Kormendi - 2232b0b9411575b1f9961713ebc9de61 -1 All Windows HE 80 - ES and NL exiltd (ES), Ben Castricum (NL) + 2232b0b9411575b1f9961713ebc9de61 -1 nl Windows HE 80 - - Ben Castricum a22af0ad0e3126d19d22707b0267a37d -1 nl Windows HE 80 - - Ben Castricum a56a05c6b865b9956639f8c51269e5ab -1 nl Mac HE 80 - - Ben Castricum d7b247c26bf1f01f8f7daf142be84de3 -1 en Windows HE 99 Updated - iziku diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 0eeff57ff7..5c8e68e50b 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Wed Jun 25 10:34:07 2014 + This file was generated by the md5table tool on Mon Sep 22 10:04:01 2014 DO NOT EDIT MANUALLY! */ @@ -112,7 +112,7 @@ static const MD5Table md5table[] = { { "2108d83dcf09f8adb4bc524669c8cf51", "PuttTime", "HE 99", "Updated", -1, Common::EN_USA, Common::kPlatformUnknown }, { "21a6592322f92550f144f68a8a4e685e", "dig", "", "", -1, Common::FR_FRA, Common::kPlatformMacintosh }, { "21abe302e1b1e2b66d6f5c12e241ebfd", "freddicove", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows }, - { "2232b0b9411575b1f9961713ebc9de61", "balloon", "HE 80", "", -1, Common::UNK_LANG, Common::kPlatformWindows }, + { "2232b0b9411575b1f9961713ebc9de61", "balloon", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformWindows }, { "225e18566e810c634bf7de63e7568e3e", "mustard", "", "", -1, Common::EN_USA, Common::kPlatformUnknown }, { "22c9eb04455440131ffc157aeb8d40a8", "fbear", "HE 70", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "22de86b2f7ec6e5db745ed1123310b44", "spyfox2", "", "Demo", 15832, Common::FR_FRA, Common::kPlatformWindows }, -- cgit v1.2.3 From 1351f6505d6b0d2daf3f5a973b8fd2c6f4ed81e4 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Mon, 22 Sep 2014 12:25:59 +0200 Subject: SCUMM: freddi1 - Add support for 'FREDDI_ROBO' CD sold with Packard Bell PCs. --- engines/scumm/detection_tables.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 791963e237..fa1f9154dd 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -680,6 +680,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "freddi", "Freddi Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi", "Freddi Fish", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi", "FreddiD", kGenHEPC, Common::NL_NLD, UNK, 0 }, + { "freddi", "FreddiE", kGenHEPC, UNK_LANG, UNK, 0 }, { "freddi", "Freddi Fisk", kGenHEMac, Common::SE_SWE, Common::kPlatformMacintosh, 0 }, { "freddi", "FRITZI", kGenHEPC, Common::DE_DEU, UNK, 0 }, { "freddi", "Marine Malice", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, -- cgit v1.2.3 From 5d6944ab52b2f2d97c613f41ea19f757ea992800 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Mon, 20 Oct 2014 14:12:50 +0200 Subject: SCUMM: freddicove - Detect dutch game variant found on CD EAN 8716051020172 --- devtools/scumm-md5.txt | 1 + engines/scumm/scumm-md5.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 856abbf7e0..cb242b4f43 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -577,6 +577,7 @@ freddicove Freddi Fish 5: The Case of the Creature of Coral Cove 590e6546aacd0d374b7f3a4f53013ab1 -1 All All - - - cyx 21abe302e1b1e2b66d6f5c12e241ebfd -1 ru Windows unenc Unencrypted - sev b8955d7d23b4972229060d1592489fef -1 nl All HE 100 - - adutchguy, daniel9 + 8f345db2f3f5a25ed6305001957e6f72 41182 nl All HE 100 - - Ben Castricum b100abf7ff83146df50db78dbd5e9cfa -1 fr All HE 100 - - alamaz, gist974 4ce2d5b355964bbcb5e5ce73236ef868 -1 ru Windows HE 100 - - sev diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 5c8e68e50b..496115e8d0 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Sep 22 10:04:01 2014 + This file was generated by the md5table tool on Mon Oct 20 12:16:47 2014 DO NOT EDIT MANUALLY! */ @@ -396,6 +396,7 @@ static const MD5Table md5table[] = { { "8e9830a6f2702be5b22c8fa0a6aaf977", "freddi2", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, { "8eb84cee9b429314c7f0bdcf560723eb", "monkey", "FM-TOWNS", "", 9925, Common::EN_ANY, Common::kPlatformFMTowns }, { "8ee63cafb1fe9d62aa0d5a23117e70e7", "freddi2", "HE 100", "Updated", -1, Common::EN_USA, Common::kPlatformUnknown }, + { "8f345db2f3f5a25ed6305001957e6f72", "freddicove", "HE 100", "", 41182, Common::NL_NLD, Common::kPlatformUnknown }, { "8f3758ff98c9c5d78e5d635222cad026", "atlantis", "Floppy", "Floppy", -1, Common::IT_ITA, Common::kPlatformDOS }, { "8fec68383202d38c0d25e9e3b757c5df", "comi", "Demo", "Demo", 18041, Common::UNK_LANG, Common::kPlatformWindows }, { "8ffd618a776a4c0d8922bb28b09f8ce8", "airport", "", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, -- cgit v1.2.3 From 81795ce4445bdd8f3cb7565759b9fc3844e89c9c Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Sun, 5 Oct 2014 10:38:14 +0200 Subject: SCUMM: Identify several windows variants as such --- devtools/scumm-md5.txt | 4 ++-- engines/scumm/detection_tables.h | 8 ++++---- engines/scumm/scumm-md5.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index cb242b4f43..476b27ddb1 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -516,7 +516,7 @@ freddi Freddi Fish 1: The Case of the Missing Kelp Seeds freddi2 Freddi Fish 2: The Case of the Haunted Schoolhouse 0a295b80f9a9edf818e8e161a0e83830 -1 fr All HE 80 - - gist974, ThierryFR fce4b8010704b103acfeea9413788f32 -1 de All HE 80 - - Joachim Eberhard - 8e9830a6f2702be5b22c8fa0a6aaf977 -1 nl Mac HE 80 - - daniel9 + 8e9830a6f2702be5b22c8fa0a6aaf977 65305 nl All HE 80 - - daniel9 5057fb0e99e5aa29df1836329232f101 -1 All Windows HE 80 - - sev ac62d50e39492ee3738b4e83a5ac780f -1 nl Windows HE 80 - - joostp 151071053a1d0021198216713939521d -1 en Windows HE 80 - - vampir_raziel @@ -679,7 +679,7 @@ pajama3 Pajama Sam 3: You Are What You Eat From Your Head to Your Feet f7711f9264d4d43c2a1518ec7c10a607 79382 us All - - - Kirben 2e8a1f76ea33bc5e04347646feee173d -1 de All - - - Joachim Eberhard aefa244ea034b7cd2041f0a44be7d9ba -1 en Mac - - - pix_climber - 06c3cf4f31daad8b1cd93153491db9e6 -1 nl Mac - - - daniel9 + 06c3cf4f31daad8b1cd93153491db9e6 79382 nl All - - - daniel9 7410a8ba9795020cd42f171c4320659e -1 fr Windows - - - gist974 20176076d708bf14407bcc9bdcd7a418 -1 ru Windows - - - sev diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index fa1f9154dd..3f08f17aff 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -686,7 +686,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "freddi", "Marine Malice", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, { "freddi", "MM-DEMO", kGenHEPC, UNK_LANG, UNK, 0 }, - { "freddi2", "freddi2", kGenHEPC, UNK_LANG, UNK, 0 }, + { "freddi2", "freddi2", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "freddi2", "FF2-demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "freddi2", "ff2-demo", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "freddi2", "FFHSDemo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -748,7 +748,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "lost", "lost", kGenHEPC, UNK_LANG, UNK, 0 }, { "lost", "Lost and Found", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "lost", "smaller", kGenHEPC, UNK_LANG, UNK, 0 }, - { "lost", "verloren", kGenHEPC, Common::NL_NLD, UNK, 0 }, + { "lost", "verloren", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 }, { "lost", "Verloren", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "maze", "maze", kGenHEPC, UNK_LANG, UNK, 0 }, @@ -793,7 +793,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "pajama2", "PJ2 Demo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "pajama2", "PS2DEMO", kGenHEPC, Common::HE_ISR, UNK, 0 }, - { "pajama3", "pajama3", kGenHEPC, UNK_LANG, UNK, 0 }, + { "pajama3", "pajama3", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "pajama3", "FPJ3Demo", kGenHEPC, Common::FR_FRA, UNK, 0 }, { "pajama3", "GPJ3Demo", kGenHEPC, Common::DE_DEU, UNK, 0 }, { "pajama3", "PajamaHTF", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, @@ -892,7 +892,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "socks", "socks", kGenHEPC, UNK_LANG, UNK, 0 }, { "socks", "SockWorks", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, UNK, 0 }, + { "socks", "SokkenSoep", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 }, { "socks", "SokkenSoep", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "spyfox", "spyfox", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 496115e8d0..d7ec9bb686 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Oct 20 12:16:47 2014 + This file was generated by the md5table tool on Mon Oct 20 12:17:31 2014 DO NOT EDIT MANUALLY! */ @@ -28,7 +28,7 @@ static const MD5Table md5table[] = { { "055ffe4f47753e47594ac67823220c54", "puttrace", "HE 99", "", -1, Common::DE_DEU, Common::kPlatformUnknown }, { "057c9b456dedcc4d71b991a3072a20b3", "monkey", "SEGA", "", 9465, Common::JA_JPN, Common::kPlatformSegaCD }, { "06b187468113f9ae5a400b148a847fac", "atlantis", "Floppy", "Floppy", 12075, Common::EN_ANY, Common::kPlatformMacintosh }, - { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, + { "06c3cf4f31daad8b1cd93153491db9e6", "pajama3", "", "", 79382, Common::NL_NLD, Common::kPlatformUnknown }, { "07433205acdca3bc553d0e731588b35f", "airport", "", "", -1, Common::EN_ANY, Common::kPlatformWindows }, { "07a1eefd8ca95d77310311446c0f53d0", "brstorm", "", "", 5433, Common::EN_ANY, Common::kPlatformUnknown }, { "07b810e37be7489263f7bc7627d4765d", "freddi4", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows }, @@ -393,7 +393,7 @@ static const MD5Table md5table[] = { { "8e3241ddd6c8dadf64305e8740d45e13", "balloon", "HE 100", "Updated", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "8e4ee4db46954bfe2912e259a16fad82", "monkey2", "", "", -1, Common::FR_FRA, Common::kPlatformDOS }, { "8e9417564f33790815445b2136efa667", "atlantis", "", "CD", 11915, Common::JA_JPN, Common::kPlatformMacintosh }, - { "8e9830a6f2702be5b22c8fa0a6aaf977", "freddi2", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, + { "8e9830a6f2702be5b22c8fa0a6aaf977", "freddi2", "HE 80", "", 65305, Common::NL_NLD, Common::kPlatformUnknown }, { "8eb84cee9b429314c7f0bdcf560723eb", "monkey", "FM-TOWNS", "", 9925, Common::EN_ANY, Common::kPlatformFMTowns }, { "8ee63cafb1fe9d62aa0d5a23117e70e7", "freddi2", "HE 100", "Updated", -1, Common::EN_USA, Common::kPlatformUnknown }, { "8f345db2f3f5a25ed6305001957e6f72", "freddicove", "HE 100", "", 41182, Common::NL_NLD, Common::kPlatformUnknown }, -- cgit v1.2.3 From 180099ac785fd52e0b534ffa37db98c2e834226b Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Mon, 27 Oct 2014 16:31:08 +0100 Subject: SCUMM: Remove obsolete comment from md5 table This is no longer the case since pull request 177 was merged. --- devtools/scumm-md5.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 476b27ddb1..acee5d87b3 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -21,9 +21,6 @@ # - Source # -> The source of the information, useful in case it has to be verified # -# TODO: We really should have a separate target for "Misc FM-TOWNS demos", so -# that their description in the launcher doesn't start with "Zak McKracken" -# # # Table of email addresse of contributors: Sometimes we need to add new # information to this table, or need to verify the correctness of an -- cgit v1.2.3 From df12402a58680a1215532ae6bd8e23d8b8256cc6 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Mon, 13 Oct 2014 09:12:52 +0200 Subject: SCUMM: Fix bug 6739 - Untranslated dialogs --- engines/scumm/dialogs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 52120949cc..c22525b6f2 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -180,9 +180,9 @@ static const ResString string_map_table_v345[] = { // I18N: You may specify 'Yes' symbol at the end of the line, like this: // "Moechten Sie wirklich neu starten? (J/N)J" // Will react to J as 'Yes' - {5, _s("Are you sure you want to restart? (Y/N)")}, + {5, _s("Are you sure you want to restart? (Y/N)Y")}, // I18N: you may specify 'Yes' symbol at the end of the line. See previous comment - {6, _s("Are you sure you want to quit? (Y/N)")}, + {6, _s("Are you sure you want to quit? (Y/N)Y")}, // Added in SCUMM4 {7, _s("Save")}, @@ -460,7 +460,7 @@ const Common::String InfoDialog::queryResString(int stringno) { tmp += chr; } } - return tmp; + return _(tmp); } #pragma mark - -- cgit v1.2.3 From 7661b8adfccde8190dc795c71033014f486cf800 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 27 Oct 2014 16:45:31 +0100 Subject: HOPKINS: Fix the censorship flag (bug #6591) --- engines/hopkins/files.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 6620f2878c..3100ed6cdc 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -74,7 +74,7 @@ int FileManager::readStream(Common::ReadStream &stream, void *buf, size_t nbytes * It's now using the config manager and a per-engine GUI option. */ void FileManager::initCensorship() { - _vm->_globals->_censorshipFl = ConfMan.getBool("enable_gore"); + _vm->_globals->_censorshipFl = !ConfMan.getBool("enable_gore"); } /** -- cgit v1.2.3 From da9ffe9dbc0912463c6161186085525bb775c0c1 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Mon, 27 Oct 2014 23:04:25 +0100 Subject: SCI: Add note on SSCI 11 FindColor bug --- engines/sci/graphics/palette.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index a3624c7959..c98d1d8e8d 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -524,6 +524,10 @@ uint16 GfxPalette::matchColor(byte r, byte g, byte b) { cdiff = (dr*dr) + (dg*dg) + (db*db); // minimum sum match (Sierra's) // cdiff = ABS(dr) + ABS(dg) + ABS(db); +// Note: (most? all?) SCI 1.1 interpreters have a bug in this code, +// and in fact have dr, dg, db as signed int8. This makes the comparison +// wrap around so that 0 and 255 have an effective distance of 1. +// See bug 6455 for a symptom of this in SQ5. if (cdiff < diff) { if (cdiff == 0) return i | 0x8000; // setting this flag to indicate exact match -- cgit v1.2.3 From f317e8c8777bdc8482b5e55f3f28873a61eab7da Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 28 Oct 2014 01:40:40 +0100 Subject: SCI: implement 8-bit color matching SCI1.1 bug effectively fixes bug #6455 thanks to wjp and [md5] --- engines/sci/console.cpp | 1 + engines/sci/graphics/palette.cpp | 28 +++++++++++++++++++++------- engines/sci/graphics/palette.h | 2 ++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 565e9752c3..510c8cd9ca 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -485,6 +485,7 @@ bool Console::cmdGetVersion(int argc, const char **argv) { #endif debugPrintf("View type: %s\n", viewTypeDesc[g_sci->getResMan()->getViewType()]); debugPrintf("Uses palette merging: %s\n", g_sci->_gfxPalette->isMerging() ? "yes" : "no"); + debugPrintf("Uses 16 bit color matching: %s\n", g_sci->_gfxPalette->isUsing16bitColorMatch() ? "yes" : "no"); debugPrintf("Resource volume version: %s\n", g_sci->getResMan()->getVolVersionDesc()); debugPrintf("Resource map version: %s\n", g_sci->getResMan()->getMapVersionDesc()); debugPrintf("Contains selector vocabulary (vocab.997): %s\n", hasVocab997 ? "yes" : "no"); diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index c98d1d8e8d..36b9660d4e 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -65,14 +65,19 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen) // the real merging done in earlier games. If we use the copying over, we // will get issues because some views have marked all colors as being used // and those will overwrite the current palette in that case - if (getSciVersion() < SCI_VERSION_1_1) + if (getSciVersion() < SCI_VERSION_1_1) { _useMerging = true; - else if (getSciVersion() == SCI_VERSION_1_1) + _use16bitColorMatch = true; + } else if (getSciVersion() == SCI_VERSION_1_1) { // there are some games that use inbetween SCI1.1 interpreter, so we have // to detect if the current game is merging or copying _useMerging = _resMan->detectPaletteMergingSci11(); - else // SCI32 + _use16bitColorMatch = _useMerging; + } else { + // SCI32 _useMerging = false; + _use16bitColorMatch = false; // not verified that SCI32 uses 8-bit color matching + } palVaryInit(); @@ -120,6 +125,10 @@ bool GfxPalette::isMerging() { return _useMerging; } +bool GfxPalette::isUsing16bitColorMatch() { + return _use16bitColorMatch; +} + // meant to get called only once during init of engine void GfxPalette::setDefault() { if (_resMan->getViewType() == kViewEga) @@ -520,14 +529,19 @@ uint16 GfxPalette::matchColor(byte r, byte g, byte b) { dr = _sysPalette.colors[i].r - r; dg = _sysPalette.colors[i].g - g; db = _sysPalette.colors[i].b - b; + if (!_use16bitColorMatch) { + // remove upper bits for most SCI1.1 games + // this bug was introduced with Quest For Glory 3 interpreter + // we have to implement it, otherwise some colors will be "wrong" + // See Space Quest 5 bug #6455 + dr &= 0xFF; + dg &= 0xFF; + db &= 0xFF; + } // minimum squares match cdiff = (dr*dr) + (dg*dg) + (db*db); // minimum sum match (Sierra's) // cdiff = ABS(dr) + ABS(dg) + ABS(db); -// Note: (most? all?) SCI 1.1 interpreters have a bug in this code, -// and in fact have dr, dg, db as signed int8. This makes the comparison -// wrap around so that 0 and 255 have an effective distance of 1. -// See bug 6455 for a symptom of this in SQ5. if (cdiff < diff) { if (cdiff == 0) return i | 0x8000; // setting this flag to indicate exact match diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h index 347695deb8..93cc2a8189 100644 --- a/engines/sci/graphics/palette.h +++ b/engines/sci/graphics/palette.h @@ -46,6 +46,7 @@ public: ~GfxPalette(); bool isMerging(); + bool isUsing16bitColorMatch(); void setDefault(); void createFromData(byte *data, int bytesLeft, Palette *paletteOut); @@ -124,6 +125,7 @@ private: bool _sysPaletteChanged; bool _useMerging; + bool _use16bitColorMatch; Common::Array _schedules; -- cgit v1.2.3 From 22be7f4346e3f09a8d86a61f6d1b5e6c1b11b703 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 14:26:19 +0200 Subject: COMMON: Add reference links for the enabled C++11 features in MSVC --- common/c++11-compat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/c++11-compat.h b/common/c++11-compat.h index 9fd252cc67..a56b79514c 100644 --- a/common/c++11-compat.h +++ b/common/c++11-compat.h @@ -32,6 +32,7 @@ // though. // #if !defined(nullptr) // XCode 5.0.1 has __cplusplus=199711 but defines this +// MSVC 2010 and newer fully support nullptr: http://msdn.microsoft.com/en-us/library/hh567368.aspx #if !defined(_MSC_VER) || _MSC_VER < 1600 #define nullptr 0 #endif @@ -41,6 +42,7 @@ // Replacement for the override keyword. This allows compilation of code // which uses it, but does not feature any semantic. // +// MSVC 2012 and newer fully support override: http://msdn.microsoft.com/en-us/library/hh567368.aspx #if !defined(_MSC_VER) || _MSC_VER < 1700 #define override #endif -- cgit v1.2.3 From 75305f136f666444b5fb3da06b22edaeb00952f0 Mon Sep 17 00:00:00 2001 From: Fedor Date: Wed, 3 Sep 2014 15:27:41 +0300 Subject: GRAPHICS: Remove some trailing whitespace in surface.h --- graphics/surface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphics/surface.h b/graphics/surface.h index ad15944361..aaa386b168 100644 --- a/graphics/surface.h +++ b/graphics/surface.h @@ -228,7 +228,7 @@ public: * @param srcSurface The source of the bitmap data * @param destX The x coordinate of the destination rectangle * @param destY The y coordinate of the destination rectangle - * @param subRect The subRect of surface to be blitted + * @param subRect The subRect of surface to be blitted */ void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect); -- cgit v1.2.3 From f50715a3f1a7f8bd42136ea899dede02b6a39579 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:31:11 +0200 Subject: AUTHORS: Remove trailing whitespace --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 37067e5e04..5f19af4612 100644 --- a/AUTHORS +++ b/AUTHORS @@ -651,7 +651,7 @@ Special thanks to repository, planet and doxygen sites as well as tons of HD space DOSBox Team - For their awesome OPL2 and OPL3 emulator - Yusuke Kamiyamane - For contributing some GUI icons + Yusuke Kamiyamane - For contributing some GUI icons Till Kresslein - For design of modern ScummVM GUI Jezar - For his freeverb filter implementation Jim Leiterman - Various info on his FM-TOWNS/Marty SCUMM ports -- cgit v1.2.3 From 4577da88ad507ce3a132c3912209d9968b01df89 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:31:33 +0200 Subject: README: Remove trailing whitespace --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 0a256b39f3..5b0569089c 100644 --- a/README +++ b/README @@ -427,7 +427,7 @@ in the previous paragraph. 3.3) Maniac Mansion NES notes: ---- ------------------------- Supported versions are English GB (E), French (F), German (G), Italian (I), -Swedish (SW) and English US (U). ScummVM requires just the PRG section +Swedish (SW) and English US (U). ScummVM requires just the PRG section to run and not the whole ROM. In order to get the game working, you will have to strip out the first @@ -1441,7 +1441,7 @@ The platforms that currently have a different default directory are: \Profiles\username\Application Data\ScummVM\Saved games\ Saved games are stored under a hidden area in Windows NT4/2000/XP/Vista/7, -which can be accessed by running "%APPDATA%\ScummVM\Saved Games\" or by +which can be accessed by running "%APPDATA%\ScummVM\Saved Games\" or by enabling hidden files in Windows Explorer. Note for Windows NT4/2000/XP/Vista/7 users: The default saved games location -- cgit v1.2.3 From 614de0d761bb8be80bf2b8b500e1810cb67a7535 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:33:41 +0200 Subject: GRAPHICS: Remove trailing whitespace --- graphics/VectorRenderer.h | 2 +- graphics/VectorRendererSpec.cpp | 52 ++++++++++++++++++++--------------------- graphics/VectorRendererSpec.h | 2 +- graphics/transform_struct.h | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h index 703da68182..6b657f758d 100644 --- a/graphics/VectorRenderer.h +++ b/graphics/VectorRenderer.h @@ -105,7 +105,7 @@ VectorRenderer *createRenderer(int mode); */ class VectorRenderer { public: - VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0), _shadowFillMode(kShadowExponential), + VectorRenderer() : _activeSurface(NULL), _fillMode(kFillDisabled), _shadowOffset(0), _shadowFillMode(kShadowExponential), _disableShadows(false), _strokeWidth(1), _gradientFactor(1) { } diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index a9594f7dd2..81a0c04441 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -1134,7 +1134,7 @@ void VectorRendererSpec:: drawTabShadow(int x1, int y1, int w, int h, int r) { int offset = 3; int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; - + // "Harder" shadows when having lower BPP, since we will have artifacts (greenish tint on the modern theme) uint8 expFactor = 3; uint16 alpha = (_activeSurface->format.bytesPerPixel > 2) ? 4 : 8; @@ -1162,7 +1162,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) { // this is ok on filled circles, but when blending on surfaces, // we cannot let it blend twice. awful. uint32 hb = 0; - + while (x++ < y) { BE_ALGORITHM(); @@ -1176,7 +1176,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) { hb |= (1 << y); } } - + ptr_fill += pitch * r; while (short_h--) { blendFill(ptr_fill, ptr_fill + width + 1, color, (uint8)alpha); @@ -1189,7 +1189,7 @@ drawTabShadow(int x1, int y1, int w, int h, int r) { alpha = (alpha * (expFactor << 8)) >> 9; } } - + /** BEVELED TABS FOR CLASSIC THEME **/ template void VectorRendererSpec:: @@ -1647,7 +1647,7 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, BE_RESET(); r--; - + int alphaStep_tr = ((alpha_t - alpha_r)/(y+1)); int alphaStep_br = ((alpha_r - alpha_b)/(y+1)); int alphaStep_bl = ((alpha_b - alpha_l)/(y+1)); @@ -1657,16 +1657,16 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, while (x++ < (y - 2)) { BE_ALGORITHM(); - BE_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, x, y, px, py, (uint8)(alpha_r + (alphaStep_tr * x))); + BE_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, x, y, px, py, (uint8)(alpha_r + (alphaStep_tr * x))); BE_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, x, y, px, py, (uint8)(alpha_b + (alphaStep_br * x))); BE_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, x, y, px, py, (uint8)(alpha_l + (alphaStep_bl * x))); BE_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, x, y, px, py, (uint8)(alpha_t + (alphaStep_tl * x))); - + BE_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)(alpha_t - (alphaStep_tr * x))); BE_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, x, y, px, py, (uint8)(alpha_r - (alphaStep_br * x))); BE_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, x, y, px, py, (uint8)(alpha_b - (alphaStep_bl * x))); BE_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, x, y, px, py, (uint8)(alpha_l - (alphaStep_tl * x))); - + if (Base::_strokeWidth > 1) { BE_DRAWCIRCLE_BCOLOR(ptr_tr, ptr_tl, ptr_bl, ptr_br, x - 1, y, px, py); BE_DRAWCIRCLE_BCOLOR(ptr_tr, ptr_tl, ptr_bl, ptr_br, x, y, px - pitch, py); @@ -1754,7 +1754,7 @@ void VectorRendererSpec:: drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { const uint8 borderAlpha_t = 0; const uint8 borderAlpha_r = 127; - const uint8 borderAlpha_b = 255; + const uint8 borderAlpha_b = 255; const uint8 borderAlpha_l = 63; const uint8 bevelAlpha_t = 255; @@ -1876,7 +1876,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) { // "Harder" shadows when having lower BPP, since we will have artifacts (greenish tint on the modern theme) uint8 expFactor = 3; uint16 alpha = (_activeSurface->format.bytesPerPixel > 2) ? 4 : 8; - + // These constants ensure a border of 2px on the left and of each rounded square int xstart = (x1 > 2) ? x1 - 2 : x1; int ystart = y1; @@ -1886,7 +1886,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) { for (int i = offset; i >= 0; i--) { int f, ddF_x, ddF_y; int x, y, px, py; - + PixelType *ptr_tl = (PixelType *)Base::_activeSurface->getBasePtr(xstart + r, ystart + r); PixelType *ptr_tr = (PixelType *)Base::_activeSurface->getBasePtr(xstart + width - r, ystart + r); PixelType *ptr_bl = (PixelType *)Base::_activeSurface->getBasePtr(xstart + r, ystart + height - r); @@ -1903,14 +1903,14 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) { // this is ok on filled circles, but when blending on surfaces, // we cannot let it blend twice. awful. uint32 hb = 0; - + while (x++ < y) { BE_ALGORITHM(); if (((1 << x) & hb) == 0) { blendFill(ptr_tl - y - px, ptr_tr + y - px, color, (uint8)alpha); - + // Will create a dark line of pixles if left out if (hb > 0) { blendFill(ptr_bl - y + px, ptr_br + y + px, color, (uint8)alpha); @@ -1924,7 +1924,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) { hb |= (1 << y); } } - + ptr_fill += pitch * r; while (short_h--) { blendFill(ptr_fill, ptr_fill + width + 1, color, (uint8)alpha); @@ -1936,7 +1936,7 @@ drawRoundedSquareShadow(int x1, int y1, int r, int w, int h, int offset) { ystart += 1; width -= 2; height -= 2; - + if (_shadowFillMode == kShadowExponential) // Multiply with expfactor alpha = (alpha * (expFactor << 8)) >> 9; @@ -2178,14 +2178,14 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, // only when the inside isn't filled if (sw != strokeWidth || fill_m != Base::kFillDisabled) a2 = 255; - - // inner arc - WU_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t - (alphaStep_tr * y)) << 8) * a2) >> 16)); + + // inner arc + WU_DRAWCIRCLE_BCOLOR_TR_CW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t - (alphaStep_tr * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r - (alphaStep_br * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_b - (alphaStep_bl * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_l - (alphaStep_tl * y)) << 8) * a2) >> 16)); - - WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a2) >> 16)); + + WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_b + (alphaStep_br * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_l + (alphaStep_bl * y)) << 8) * a2) >> 16)); WU_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, (x - 1), y, (px - pitch), py, (uint8)((uint32)(((alpha_t + (alphaStep_tl * y)) << 8) * a2) >> 16)); @@ -2196,8 +2196,8 @@ drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, WU_DRAWCIRCLE_BCOLOR_BR_CW(ptr_br, x, y, px, py, (uint8)((uint32)(((alpha_r - (alphaStep_br * y)) << 8) * a1) >> 16)); WU_DRAWCIRCLE_BCOLOR_BL_CW(ptr_bl, x, y, px, py, (uint8)((uint32)(((alpha_b - (alphaStep_bl * y)) << 8) * a1) >> 16)); WU_DRAWCIRCLE_BCOLOR_TL_CW(ptr_tl, x, y, px, py, (uint8)((uint32)(((alpha_l - (alphaStep_tl * y)) << 8) * a1) >> 16)); - - WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a1) >> 16)); + + WU_DRAWCIRCLE_BCOLOR_TR_CCW(ptr_tr, x, y, px, py, (uint8)((uint32)(((alpha_r + (alphaStep_tr * y)) << 8) * a1) >> 16)); WU_DRAWCIRCLE_BCOLOR_BR_CCW(ptr_br, x, y, px, py, (uint8)((uint32)(((alpha_b + (alphaStep_br * y)) << 8) * a1) >> 16)); WU_DRAWCIRCLE_BCOLOR_BL_CCW(ptr_bl, x, y, px, py, (uint8)((uint32)(((alpha_l + (alphaStep_bl * y)) << 8) * a1) >> 16)); WU_DRAWCIRCLE_BCOLOR_TL_CCW(ptr_tl, x, y, px, py, (uint8)((uint32)(((alpha_t + (alphaStep_tl * y)) << 8) * a1) >> 16)); @@ -2220,7 +2220,7 @@ drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType colo int x, y; const int pitch = Base::_activeSurface->pitch / Base::_activeSurface->format.bytesPerPixel; int px, py; - + uint32 rsq = r*r; frac_t T = 0, oldT; uint8 a1, a2; @@ -2318,14 +2318,14 @@ void VectorRendererAA:: drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m) { const uint8 borderAlpha_t = 0; const uint8 borderAlpha_r = 127; - const uint8 borderAlpha_b = 255; + const uint8 borderAlpha_b = 255; const uint8 borderAlpha_l = 63; const uint8 bevelAlpha_t = 255; const uint8 bevelAlpha_r = 31; const uint8 bevelAlpha_b = 0; const uint8 bevelAlpha_l = 127; - + if (Base::_strokeWidth) { if (r != 0 && Base::_bevel > 0) { drawBorderRoundedSquareAlg(x1, y1, r, w, h, color, fill_m, borderAlpha_t, borderAlpha_r, borderAlpha_b, borderAlpha_l); @@ -2334,7 +2334,7 @@ drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, Vecto drawBorderRoundedSquareAlg(x1, y1, r, w, h, color, fill_m, 255, 255, 255, 255); } } - + // If only border is visible if ((!(w <= 0 || h <= 0)) && (fill_m != Base::kFillDisabled)) { if (fill_m == Base::kFillBackground) diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h index c035ca0e19..f47cc3997a 100644 --- a/graphics/VectorRendererSpec.h +++ b/graphics/VectorRendererSpec.h @@ -301,7 +301,7 @@ protected: virtual void drawRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m); virtual void drawBorderRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m, uint8 alpha_t, uint8 alpha_l, uint8 alpha_r, uint8 alpha_b); - + virtual void drawInteriorRoundedSquareAlg(int x1, int y1, int r, int w, int h, PixelType color, VectorRenderer::FillMode fill_m); virtual void drawRoundedSquareShadow(int x, int y, int r, int w, int h, int offset) { diff --git a/graphics/transform_struct.h b/graphics/transform_struct.h index 640daf9f4c..1d37492de4 100644 --- a/graphics/transform_struct.h +++ b/graphics/transform_struct.h @@ -48,7 +48,7 @@ const int32 kDefaultHotspotX = 0; const int32 kDefaultHotspotY = 0; const int32 kDefaultOffsetX = 0; const int32 kDefaultOffsetY = 0; -const int32 kDefaultAngle = 0; +const int32 kDefaultAngle = 0; struct TransformStruct { private: -- cgit v1.2.3 From b845d41d16f8452122cc8a3b6194da11b3310b5d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:34:09 +0200 Subject: VIDEO: Remove trailing whitespace --- video/avi_decoder.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index d9761e1c38..a5016632d6 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -149,7 +149,7 @@ bool AVIDecoder::parseNextChunk() { skipChunk(size); break; case ID_IDX1: - readOldIndex(size); + readOldIndex(size); break; default: error("Unknown tag \'%s\' found", tag2str(tag)); @@ -528,7 +528,7 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { // Recreate the audio stream audioTrack->resetStream(); - uint framesNeeded = _header.initialFrames; + uint framesNeeded = _header.initialFrames; if (framesNeeded == 0) framesNeeded = 1; @@ -623,7 +623,7 @@ void AVIDecoder::readOldIndex(uint32 size) { OldIndex firstEntry; firstEntry.id = _fileStream->readUint32BE(); firstEntry.flags = _fileStream->readUint32LE(); - firstEntry.offset = _fileStream->readUint32LE(); + firstEntry.offset = _fileStream->readUint32LE(); firstEntry.size = _fileStream->readUint32LE(); // Check if the offset is already absolute -- cgit v1.2.3 From 0d81e522c1a256570a8bc6fd481d2efab83b07df Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:34:48 +0200 Subject: GUI: Remove trailing whitespace --- gui/about.cpp | 2 +- gui/widgets/edittext.cpp | 2 +- gui/widgets/tab.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gui/about.cpp b/gui/about.cpp index fe726df750..b25efc1cd0 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -241,7 +241,7 @@ void AboutDialog::drawDialog() { while (*str && *str == ' ') str++; - if (*str) + if (*str) g_gui.theme()->drawText(Common::Rect(_x + _xOff, y, _x + _w - _xOff, y + g_gui.theme()->getFontHeight()), str, state, align, ThemeEngine::kTextInversionNone, 0, false, ThemeEngine::kFontStyleBold, ThemeEngine::kFontColorNormal, true, _textDrawableArea); y += _lineHeight; } diff --git a/gui/widgets/edittext.cpp b/gui/widgets/edittext.cpp index 3e72350c99..550b1bd153 100644 --- a/gui/widgets/edittext.cpp +++ b/gui/widgets/edittext.cpp @@ -94,7 +94,7 @@ void EditTextWidget::drawWidget() { // Draw the text adjustOffset(); - + const Common::Rect &r = Common::Rect(_x + 2 + _leftPadding, _y + 2, _x + _leftPadding + getEditRect().width() + 8, _y + _h); setTextDrawableArea(r); diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index a01ee2d9dc..148f164fbb 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -28,7 +28,7 @@ #include "common/array.h" namespace GUI { - + enum { kTabForwards = 1, kTabBackwards = -1 -- cgit v1.2.3 From 67fec75b4e68a3a5ebfbd6a56d61fab480f282b4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:35:24 +0200 Subject: IMAGE: Remove trailing whitespace --- image/codecs/mpeg.h | 2 +- image/iff.cpp | 2 +- image/image_decoder.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/image/codecs/mpeg.h b/image/codecs/mpeg.h index 6cb10f21ac..82c3ad19ac 100644 --- a/image/codecs/mpeg.h +++ b/image/codecs/mpeg.h @@ -62,7 +62,7 @@ namespace Graphics { struct Surface; } -namespace Image { +namespace Image { /** * MPEG 1/2 video decoder. diff --git a/image/iff.cpp b/image/iff.cpp index d93e9ff878..d75fffb31f 100644 --- a/image/iff.cpp +++ b/image/iff.cpp @@ -31,7 +31,7 @@ namespace Image { IFFDecoder::IFFDecoder() { _surface = 0; _palette = 0; - + // these 2 properties are not reset by destroy(), so the default is set here. _numRelevantPlanes = 8; _pixelPacking = false; diff --git a/image/image_decoder.h b/image/image_decoder.h index 4d3512e0f6..2018cebd37 100644 --- a/image/image_decoder.h +++ b/image/image_decoder.h @@ -48,7 +48,7 @@ public: /** * Load an image from the specified stream - * + * * loadStream() should implicitly call destroy() to free the memory * of the last loadStream() call. * -- cgit v1.2.3 From d2c69a79fe1a728ee17ca415ffce1720dae7fe99 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:36:22 +0200 Subject: BACKENDS: Remove trailing whitespace --- backends/graphics/opengl/opengl-graphics.cpp | 6 +++--- backends/graphics/openglsdl/openglsdl-graphics.cpp | 2 +- backends/platform/sdl/sdl.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index cbd06e9161..c455c4ce2e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -489,7 +489,7 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) { if (!_overlay) { return; } - + // It might be confusing that we actually have to handle something // here when the overlay is visible. This is because for very small // resolutions we have a minimal overlay size and have to adjust @@ -1044,8 +1044,8 @@ void OpenGLGraphicsManager::recalculateDisplayArea() { } // We center the screen in the middle for now. - _displayX = (_outputScreenWidth - _displayWidth ) / 2; - _displayY = (_outputScreenHeight - _displayHeight) / 2; + _displayX = (_outputScreenWidth - _displayWidth ) / 2; + _displayY = (_outputScreenHeight - _displayHeight) / 2; } void OpenGLGraphicsManager::updateCursorPalette() { diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index c998f3d1f1..b028cd5b1a 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -282,7 +282,7 @@ bool OpenGLSdlGraphicsManager::setupMode(uint width, uint height) { if (!_fullscreenVideoModes.empty()) { VideoModeArray::const_iterator i = _fullscreenVideoModes.end(); --i; - + _desiredFullscreenWidth = i->width; _desiredFullscreenHeight = i->height; } else { diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 41610dc0c7..4dc5929dab 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -390,7 +390,7 @@ Common::String OSystem_SDL::getSystemLanguage() const { #else // WIN32 // Activating current locale settings const Common::String locale = setlocale(LC_ALL, ""); - + // Restore default C locale to prevent issues with // portability of sscanf(), atof(), etc. // See bug #3615148 -- cgit v1.2.3 From daf110c86709a3e1899b4d1ae4d50efdf9ec9549 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:37:45 +0200 Subject: COMMON: Remove trailing whitespace --- common/EventMapper.cpp | 6 +++--- common/scummsys.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp index b92116cbe7..cf65946d50 100644 --- a/common/EventMapper.cpp +++ b/common/EventMapper.cpp @@ -45,7 +45,7 @@ List DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) { if (ev.type == EVENT_MBUTTONUP) { if ((g_system->getMillis() - vkeybdThen) >= vkeybdTime) { mappedEvent.type = EVENT_VIRTUAL_KEYBOARD; - + // Avoid blocking event from engine. addDelayedEvent(100, ev); } @@ -59,7 +59,7 @@ List DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) { #ifdef ENABLE_VKEYBD else if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F7) { mappedEvent.type = EVENT_VIRTUAL_KEYBOARD; - + // Avoid blocking CTRL-F7 events from engine. addDelayedEvent(100, ev); } @@ -67,7 +67,7 @@ List DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) { #ifdef ENABLE_KEYMAPPER else if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F8) { mappedEvent.type = EVENT_KEYMAPPER_REMAP; - + // Avoid blocking CTRL-F8 events from engine. addDelayedEvent(100, ev); } diff --git a/common/scummsys.h b/common/scummsys.h index c30bc4a52a..0c4687e03e 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -148,7 +148,7 @@ #endif #endif -// The following math constants are usually defined by the system math.h header, but +// The following math constants are usually defined by the system math.h header, but // they are not part of the ANSI C++ standards and so can NOT be relied upon to be // present i.e. when -std=c++11 is passed to GCC, enabling strict ANSI compliance. // As we rely on these being present, we define them if they are not set. -- cgit v1.2.3 From 50c1d5c3a1622bc8d8cca1996fe0d64661bc2526 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:38:22 +0200 Subject: WINTERMUTE: Remove trailing whitespace --- engines/wintermute/math/rect32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/math/rect32.h b/engines/wintermute/math/rect32.h index 93b5c68a30..00326d6747 100644 --- a/engines/wintermute/math/rect32.h +++ b/engines/wintermute/math/rect32.h @@ -50,7 +50,7 @@ struct Point32 { y -= delta.y; return *this; } - + operator FloatPoint() { return FloatPoint(x,y); } -- cgit v1.2.3 From 338f3dc1035267f94c53e0705473c10b8251fe11 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 15:46:19 +0200 Subject: TONY: Fix image loading on BE systems again This was originally changed in commit 43520ce4f3, but it has been removed accidentally in commit 84fb3e816d --- engines/tony/gfxcore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index b8350eb8d7..2a32926c53 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -1958,7 +1958,7 @@ void RMGfxSourceBuffer16::prepareImage() { pixel = (r << 11) | (g << 6) | b; - WRITE_LE_UINT16(&buf[i], pixel); + buf[i] = pixel; } } -- cgit v1.2.3 From c18dba13266e9901653cd60869642dad9ccc6337 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:01:35 +0200 Subject: CREDITS: Properly sync trailing whitespace changes in all files This was initially only done for the AUTHORS file in commit f50715a --- devtools/credits.pl | 2 +- gui/credits.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devtools/credits.pl b/devtools/credits.pl index 0960011802..9a3cd5c9ac 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -1205,7 +1205,7 @@ begin_credits("Credits"); add_person("Ivan Dubrov", "", "For contributing the initial version of the Gobliiins engine"); add_person("Henrik Engqvist", "qvist", "For generously providing hosting for our buildbot, SVN repository, planet and doxygen sites as well as tons of HD space"); add_person("DOSBox Team", "", "For their awesome OPL2 and OPL3 emulator"); - add_person("Yusuke Kamiyamane", "", "For contributing some GUI icons "); + add_person("Yusuke Kamiyamane", "", "For contributing some GUI icons"); add_person("Till Kresslein", "Krest", "For design of modern ScummVM GUI"); add_person("", "Jezar", "For his freeverb filter implementation"); add_person("Jim Leiterman", "", "Various info on his FM-TOWNS/Marty SCUMM ports"); diff --git a/gui/credits.h b/gui/credits.h index e32a0705bf..38287ebdf9 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -810,7 +810,7 @@ static const char *credits[] = { "C0""DOSBox Team", "C2""For their awesome OPL2 and OPL3 emulator", "C0""Yusuke Kamiyamane", -"C2""For contributing some GUI icons ", +"C2""For contributing some GUI icons", "C0""Till Kresslein", "C2""For design of modern ScummVM GUI", "C0""Jezar", -- cgit v1.2.3 From 7e03520030c09d60f86578cdbc98b15581c4c471 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:03:17 +0200 Subject: TSAGE: Remove trailing whitespace --- engines/tsage/ringworld2/ringworld2_outpost.cpp | 2 +- engines/tsage/ringworld2/ringworld2_scenes3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/tsage/ringworld2/ringworld2_outpost.cpp b/engines/tsage/ringworld2/ringworld2_outpost.cpp index 05cfa6259b..cad21b4623 100644 --- a/engines/tsage/ringworld2/ringworld2_outpost.cpp +++ b/engines/tsage/ringworld2/ringworld2_outpost.cpp @@ -4605,7 +4605,7 @@ void Scene1337::subD1940(bool flag) { } void Scene1337::subD1975(int arg1, int arg2) { - // No implementation required in ScummVM: Mouse handling with tons of caching + // No implementation required in ScummVM: Mouse handling with tons of caching } void Scene1337::OptionsDialog::show() { diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp index 9eaead630b..8610e0c8bc 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp @@ -3878,7 +3878,7 @@ void Scene3500::dispatch() { Scene::dispatch(); // WORKAROUND: The _mazeUI wasn't originally added to the scene in postInit. - // This is only needed to fix old savegames + // This is only needed to fix old savegames if (!R2_GLOBALS._sceneObjects->contains(&_mazeUI)) _mazeUI.draw(); -- cgit v1.2.3 From 62c2e46566b940746d059bfeb23023b45bbca9ef Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:04:11 +0200 Subject: CGE: Remove trailing whitespace --- engines/cge/vga13h.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp index babcb7e667..4d3a103663 100644 --- a/engines/cge/vga13h.cpp +++ b/engines/cge/vga13h.cpp @@ -640,7 +640,7 @@ Vga::Vga(CGEEngine *vm) : _frmCnt(0), _msg(NULL), _name(NULL), _setPal(false), _ if (ConfMan.getBool("enable_color_blind")) _mono = 1; - + _oldColors = (Dac *)malloc(sizeof(Dac) * kPalCount); _newColors = (Dac *)malloc(sizeof(Dac) * kPalCount); -- cgit v1.2.3 From 2621d22cb7d71e23a96fbdb8d65759a107930d67 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:04:52 +0200 Subject: AGOS: Remove trailing whitespace --- engines/agos/input.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/agos/input.cpp b/engines/agos/input.cpp index 8a4e87017a..687a8ef1cf 100644 --- a/engines/agos/input.cpp +++ b/engines/agos/input.cpp @@ -460,7 +460,7 @@ void AGOSEngine_Simon1::handleMouseWheelUp() { _saveLoadEdit = false; listSaveGames(); } - } else { + } else { AGOSEngine::handleMouseWheelUp(); } } @@ -472,11 +472,11 @@ void AGOSEngine_Simon1::handleMouseWheelDown() { _saveLoadRowCurPos += 1; if (_saveLoadRowCurPos >= _numSaveGameRows) _saveLoadRowCurPos = _numSaveGameRows; - + _saveLoadEdit = false; listSaveGames(); } - } else { + } else { AGOSEngine::handleMouseWheelDown(); } } @@ -492,7 +492,7 @@ void AGOSEngine_Elvira2::handleMouseWheelUp() { _saveLoadRowCurPos -= 3; listSaveGames(); - } else { + } else { AGOSEngine::handleMouseWheelUp(); } } @@ -506,7 +506,7 @@ void AGOSEngine_Elvira2::handleMouseWheelDown() { _saveLoadRowCurPos = 1; listSaveGames(); - } else { + } else { AGOSEngine::handleMouseWheelDown(); } } -- cgit v1.2.3 From c76c72c7998820c5046db7dbf58dc7dfd4af97dc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:06:07 +0200 Subject: CGE2: Remove trailing whitespace --- engines/cge2/cge2.cpp | 2 +- engines/cge2/cge2.h | 2 +- engines/cge2/cge2_main.cpp | 24 ++++++++++++------------ engines/cge2/cge2_main.h | 2 +- engines/cge2/events.cpp | 4 ++-- engines/cge2/hero.cpp | 10 +++++----- engines/cge2/map.cpp | 2 +- engines/cge2/saveload.cpp | 4 ++-- engines/cge2/snail.cpp | 10 +++++----- engines/cge2/spare.h | 2 +- engines/cge2/talk.cpp | 2 +- engines/cge2/vga13h.cpp | 8 ++++---- 12 files changed, 36 insertions(+), 36 deletions(-) diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp index 37d87ba09c..ee62e20ac6 100644 --- a/engines/cge2/cge2.cpp +++ b/engines/cge2/cge2.cpp @@ -97,7 +97,7 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription) _midiNotify = nullptr; _spriteNotify = nullptr; _startGameSlot = 0; - + _sayCap = ConfMan.getBool("subtitles"); _sayVox = !ConfMan.getBool("speech_mute"); _muteAll = ConfMan.getBool("mute"); diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 50b418f294..fbe4cb3abc 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -269,7 +269,7 @@ public: void snRoom(Sprite *spr, bool on); void snGhost(Bitmap *bmp); void snSay(Sprite *spr, int val); - + void hide1(Sprite *spr); Sprite *expandSprite(Sprite *spr); void qGame(); diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index 3e3d615a91..4e3d229618 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -58,7 +58,7 @@ void System::touch(uint16 mask, V2D pos, Common::KeyCode keyCode) { if (_vm->_gamePhase != kPhaseInGame) return; _vm->_infoLine->setText(nullptr); - + if (mask & kMouseLeftUp) { if (pos.y >= 0) { // world if (!_vm->_talk && pos.y < _vm->_mouseTop) @@ -184,7 +184,7 @@ Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) if (line.empty()) continue; Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr)); - + char *p = token(tmpStr); if (*p == '@') { if (label != kNoByte) @@ -327,7 +327,7 @@ void CGE2Engine::loadScript(const char *fname, bool onlyToolbar) { lcnt++; Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr)); - + ok = false; // not OK if break V3D P; @@ -419,7 +419,7 @@ void CGE2Engine::sceneUp(int cav) { _map->load(_now); _spare->takeScene(_now); openPocket(); - + for (int i = 0; i < 2; i++) { Hero *h = _heroTab[i]->_ptr; if (h && h->_scene == _now) { @@ -432,7 +432,7 @@ void CGE2Engine::sceneUp(int cav) { h->setContact(); } } - + _sound->stop(); _fx->clear(); @@ -596,7 +596,7 @@ void CGE2Engine::tick() { for (Sprite *spr = _vga->_showQ->first(); spr; spr = spr->_next) { if (spr->_time && (--spr->_time == 0)) spr->tick(); - + if (_waitRef && (_waitRef == spr->_ref) && spr->seqTest(_waitSeq)) _waitRef = 0; } @@ -658,10 +658,10 @@ void CGE2Engine::loadUser() { void CGE2Engine::loadHeroes() { // Original name: loadGame() // load sprites & pocket - + Sprite *s; Hero *h = nullptr; - + // initialize Andzia/Anna s = _spare->take(142); if (s) { @@ -698,7 +698,7 @@ void CGE2Engine::loadPos() { if (_resman->exist("CGE.HXY")) { for (int cav = 0; cav < kSceneMax; cav++) _heroTab[1]->_posTab[cav] = new V2D(this, 180, 10); - + EncryptedStream file(this, "CGE.HXY"); for (int cav = 0; cav < kSceneMax; cav++) { @@ -752,7 +752,7 @@ void CGE2Engine::cge2_main() { runGame(); _gamePhase = kPhaseOver; } - + _vga->sunset(); } else _vga->sunset(); @@ -767,7 +767,7 @@ char *CGE2Engine::mergeExt(char *buf, const char *name, const char *ext) { return buf; } -void CGE2Engine::setEye(const V3D &e) { +void CGE2Engine::setEye(const V3D &e) { *_eye = e; } @@ -931,7 +931,7 @@ void CGE2Engine::offUse() { // This fixes the issue of empty speech bubbles in the original. // Now we only let this cycle pass if it randoms a valid value for getText(). int txt = 0; - do { + do { txt = kOffUseText + _sex * offUseCount + newRandom(offUseCount); } while (_text->getText(txt) == nullptr); diff --git a/engines/cge2/cge2_main.h b/engines/cge2/cge2_main.h index 88cca1cc1e..4d92c33e50 100644 --- a/engines/cge2/cge2_main.h +++ b/engines/cge2/cge2_main.h @@ -40,7 +40,7 @@ public: Sprite *_blinkSprite; System(CGE2Engine *vm); - + virtual void touch(uint16 mask, V2D pos, Common::KeyCode keyCode); void tick(); private: diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp index ed1ec66bb1..85743c8011 100644 --- a/engines/cge2/events.cpp +++ b/engines/cge2/events.cpp @@ -132,7 +132,7 @@ Mouse::Mouse(CGE2Engine *vm) : Sprite(vm), _busy(nullptr), _hold(nullptr), _hx(0 _busy = nullptr; _active = false; _flags._kill = false; - + setSeq(_stdSeq8); BitmapPtr MC = new Bitmap[2]; @@ -260,7 +260,7 @@ void EventManager::handleEvents() { if (e._spritePtr) { if (e._mask & kEventKeyb) e._spritePtr->touch(e._mask, _vm->_mouse->_point, e._keyCode); - else + else e._spritePtr->touch(e._mask, _vm->_mouse->_point - e._spritePtr->_pos2D, e._keyCode); } else if (_vm->_sys) _vm->_sys->touch(e._mask, _vm->_mouse->_point, e._keyCode); diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 225df54bd1..42ae67cc2b 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -205,7 +205,7 @@ Sprite *Hero::expand() { int i = stepSize() / 2; _maxDist = (int)sqrt(double(i * i * 2)); setCurrent(); - + return this; } @@ -558,9 +558,9 @@ int CGE2Engine::mapCross(const V2D &a, const V2D &b) { if (p) { if (cross(a, b, *n0, *n)) ++cnt; - + if (*n == *p) - p = nullptr; + p = nullptr; } else { p = n; } @@ -587,7 +587,7 @@ void Hero::operator--() { bool Sprite::works(Sprite *spr) { if (!spr || !spr->_ext) return false; - + bool ok = false; Action a = _vm->_heroTab[_vm->_sex]->_ptr->action(); @@ -615,7 +615,7 @@ bool Sprite::works(Sprite *spr) { } } } - + return ok; } diff --git a/engines/cge2/map.cpp b/engines/cge2/map.cpp index 8c1f00048f..275e15f55a 100644 --- a/engines/cge2/map.cpp +++ b/engines/cge2/map.cpp @@ -48,7 +48,7 @@ void Map::load(int scene) { return; EncryptedStream file(_vm, fileName.c_str()); - + Common::String line; for (line = file.readLine(); !file.eos(); line = file.readLine()) { if (line.empty()) diff --git a/engines/cge2/saveload.cpp b/engines/cge2/saveload.cpp index fd60422dff..7735c077a6 100644 --- a/engines/cge2/saveload.cpp +++ b/engines/cge2/saveload.cpp @@ -104,7 +104,7 @@ bool CGE2Engine::loadGame(int slotNumber) { saveFile->read(dataBuffer, size); readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES); delete saveFile; - + // Check to see if it's a ScummVM savegame or not char buffer[kSavegameStrSize + 1]; readStream->read(buffer, kSavegameStrSize + 1); @@ -132,7 +132,7 @@ bool CGE2Engine::loadGame(int slotNumber) { delete readStream; loadHeroes(); - + return true; } diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index 8e1ddf2d9b..7580ef4425 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -92,7 +92,7 @@ void CommandHandler::runCommand() { } _textDelay = false; } - + if (_vm->_talk && tailCmd._commandType != kCmdPause) break; } @@ -332,7 +332,7 @@ void CGE2Engine::snRSeq(Sprite *spr, int val) { void CGE2Engine::snSend(Sprite *spr, int val) { if (!spr) return; - + // Sending", spr->_file // from scene", spr->_scene // to scene", val @@ -691,7 +691,7 @@ Sprite *CGE2Engine::expandSprite(Sprite *spr) { void CGE2Engine::qGame() { // Write out the user's progress saveGame(0, Common::String("Automatic Savegame")); - + busy(false); _vga->sunset(); _endGame = true; @@ -853,13 +853,13 @@ void CGE2Engine::feedSnail(Sprite *spr, Action snq, Hero *hero) { if (s == spr) break; } - + _commandHandler->addCommand(c->_commandType, c->_ref, c->_val, spr); ++c; } } - + } } // End of namespace CGE2. diff --git a/engines/cge2/spare.h b/engines/cge2/spare.h index 7dc6ce60f5..24a97712ff 100644 --- a/engines/cge2/spare.h +++ b/engines/cge2/spare.h @@ -38,7 +38,7 @@ class Spare { public: Spare(CGE2Engine *vm) : _vm(vm) {} ~Spare() { clear(); } - void store(Sprite *spr); + void store(Sprite *spr); Sprite *locate(int ref); Sprite *take(int ref); void takeScene(int cav); diff --git a/engines/cge2/talk.cpp b/engines/cge2/talk.cpp index 9109da90f1..8e6be6cac2 100644 --- a/engines/cge2/talk.cpp +++ b/engines/cge2/talk.cpp @@ -121,7 +121,7 @@ Talk::Talk(CGE2Engine *vm, const char *text, TextBoxStyle mode, ColorBank color, Talk::Talk(CGE2Engine *vm, ColorBank color) : Sprite(vm), _mode(kTBPure), _created(false), _wideSpace(false), _vm(vm) { _color = _vm->_font->_colorSet[color]; - + if (color == kCBRel) _vm->setAutoColors(); } diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 227633579e..f4064f3565 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -45,13 +45,13 @@ void V3D::sync(Common::Serializer &s) { _z.sync(s); } -FXP FXP::operator*(const FXP& x) const { - FXP y; +FXP FXP::operator*(const FXP& x) const { + FXP y; int32 t1 = (v >> 8) * x.v; int32 t2 = ((v & 0xFF) * x.v) >> 8; y.v = t1 + t2; - return y; + return y; } FXP FXP::operator/(const FXP& x) const { @@ -613,7 +613,7 @@ void Sprite::gotoxyz(V2D pos) { ++trim; } _pos2D.x = pos.x; - + if (pos.y < -kPanHeight) { pos.y = -kPanHeight; ++trim; -- cgit v1.2.3 From 176f8209c731ef3f93749ff4a4d304f3e494b2c9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:06:48 +0200 Subject: HOPKINS: Remove trailing whitespace --- engines/hopkins/computer.cpp | 2 +- engines/hopkins/talk.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp index 84d5c631c7..18b16cb4c8 100644 --- a/engines/hopkins/computer.cpp +++ b/engines/hopkins/computer.cpp @@ -883,7 +883,7 @@ void ComputerManager::getScoreName() { _vm->_graphicsMan->setColorPercentage(254, 0, 0, 0); byte *ptr = _vm->_fileIO->loadFile("ALPHA.SPR"); _vm->_graphicsMan->fadeInBreakout(); - + // Figure out the line to put the new high score on int scoreLine = 0; while (scoreLine < 5 && _breakoutScore < atol(_score[scoreLine]._score.c_str())) diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index df7b26c82c..00c4ab0332 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -68,7 +68,7 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename) getStringFromBuffer(40, spriteFilename, (const char *)_characterBuffer); getStringFromBuffer(0, _questionsFilename, (const char *)_characterBuffer); getStringFromBuffer(20, _answersFilename, (const char *)_characterBuffer); - + switch (_vm->_globals->_language) { case LANG_FR: _answersFilename = _questionsFilename = "RUE.TXT"; -- cgit v1.2.3 From ceab7a8742a690f71c1080604bd6aebe1261286c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:07:16 +0200 Subject: KYRA: Remove trailing whitespace --- engines/kyra/vqa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/kyra/vqa.cpp b/engines/kyra/vqa.cpp index fb51c05e51..cfd5f6ffc6 100644 --- a/engines/kyra/vqa.cpp +++ b/engines/kyra/vqa.cpp @@ -532,7 +532,7 @@ void VQADecoder::VQAVideoTrack::handleVQFR(Common::SeekableReadStream *stream) { uint32 tag = readTag(stream); uint32 i; size = stream->readUint32BE(); - + switch (tag) { case MKTAG('C','B','F','0'): // Full codebook stream->read(_codeBook, size); -- cgit v1.2.3 From eed9da3ea29324617ae4367569bc7cea1f16d902 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:12:25 +0200 Subject: SWORD1: Remove trailing whitespace --- engines/sword1/console.cpp | 2 +- engines/sword1/sound.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/sword1/console.cpp b/engines/sword1/console.cpp index 7fabc62192..3a4b51965b 100644 --- a/engines/sword1/console.cpp +++ b/engines/sword1/console.cpp @@ -36,7 +36,7 @@ SwordConsole::SwordConsole(SwordEngine *vm) : GUI::Debugger(), _vm(vm) { SwordConsole::~SwordConsole() { } - + bool SwordConsole::Cmd_SpeechEndianness(int argc, const char **argv) { if (argc == 1) { debugPrintf("Using %s speech\n", _vm->_sound->_bigEndianSpeech ? "be" : "le"); diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index 9140bddb65..4deaf06edc 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -144,7 +144,7 @@ void Sound::checkSpeechFileEndianness() { debug(8, "Speech endianness heuristic: average = %f for BE and %f for LE (%d samples)", be_diff, le_diff, maxSamples); } } - + double Sound::endiannessHeuristicValue(int16* data, uint32 dataSize, uint32 &maxSamples) { if (!data) return 50000.; // the heuristic value for the wrong endianess is about 21000 (1/3rd of the 16 bits range) -- cgit v1.2.3 From e938ddcef7f40027ea3d2bae3e71730d8f74eb4b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:13:07 +0200 Subject: SWORD25: Remove trailing whitespace --- engines/sword25/gfx/renderobjectmanager.cpp | 2 +- engines/sword25/util/pluto/pluto.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/sword25/gfx/renderobjectmanager.cpp b/engines/sword25/gfx/renderobjectmanager.cpp index 4927b4c58e..8aeecad6b1 100644 --- a/engines/sword25/gfx/renderobjectmanager.cpp +++ b/engines/sword25/gfx/renderobjectmanager.cpp @@ -107,7 +107,7 @@ bool RenderObjectManager::render() { if (!_currQueue->exists(*it)) _uta->addRect((*it)._bbox); } - + // Add rectangles of objects which are different from the previous frame for (RenderObjectQueue::iterator it = _currQueue->begin(); it != _currQueue->end(); ++it) { if (!_prevQueue->exists(*it)) diff --git a/engines/sword25/util/pluto/pluto.cpp b/engines/sword25/util/pluto/pluto.cpp index 78b0a815e8..cbe16b0d5b 100644 --- a/engines/sword25/util/pluto/pluto.cpp +++ b/engines/sword25/util/pluto/pluto.cpp @@ -325,7 +325,7 @@ static void persisttable(PersistInfo *pi) #ifdef TOTEXT printf("persisttable\n"); #endif - + /* perms reftbl ... tbl */ lua_checkstack(pi->L, 3); if(persistspecialobject(pi, 1)) { @@ -1192,7 +1192,7 @@ int persist_l(lua_State *L) wi.buf = NULL; wi.buflen = 0; - + lua_settop(L, 2); /* perms? rootobj? */ luaL_checktype(L, 1, LUA_TTABLE); @@ -1750,7 +1750,7 @@ static void unpersistthread(int ref, UnpersistInfo *upi) #else verify(LIF(Z,read)(&upi->zio, &L2->errfunc, sizeof(ptrdiff_t)) == 0); #endif - + //read_size(&upi->zio, (size_t *)&L2->errfunc); L2->base = L2->stack + stackbase; L2->top = L2->stack + stacktop; @@ -2045,7 +2045,7 @@ int unpersist_l(lua_State *L) int version_l(lua_State *L) { const char *version = VERSION; - + lua_settop(L, 0); /* (empty) */ lua_pushlstring(L, version, strlen(version)); -- cgit v1.2.3 From 3575235ca628cd7f483f0ca42eb601f82d70efb8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:13:40 +0200 Subject: TONY: Remove trailing whitespace --- engines/tony/mpal/lzo.cpp | 2 +- engines/tony/window.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/tony/mpal/lzo.cpp b/engines/tony/mpal/lzo.cpp index 314d6f3ed5..6cc2333315 100644 --- a/engines/tony/mpal/lzo.cpp +++ b/engines/tony/mpal/lzo.cpp @@ -116,7 +116,7 @@ int lzo1x_decompress(const byte *in, uint32 in_len, byte *out, uint32 *out_len) *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; - do + do *op++ = *ip++; while (--t > 0); diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index c62f483a35..3b3687419b 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -55,7 +55,7 @@ RMWindow::~RMWindow() { void RMWindow::init() { Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); - + reset(); } -- cgit v1.2.3 From 66abcb4829d6297f7f637d5eb976f72f9e6591cc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:14:08 +0200 Subject: TOON: Remove trailing whitespace --- engines/toon/character.cpp | 2 +- engines/toon/state.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 51e8dee19f..686fe99beb 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -1059,7 +1059,7 @@ void Character::playAnim(int32 animId, int32 unused, int32 flags) { _specialAnim->loadAnimation(animName); _animSpecialId = animId; - + if (_animationInstance) { _animationInstance->setAnimation(_specialAnim); _animationInstance->setAnimationRange(0, _specialAnim->_numFrames - 1); diff --git a/engines/toon/state.cpp b/engines/toon/state.cpp index 6ac5808219..000f94d659 100644 --- a/engines/toon/state.cpp +++ b/engines/toon/state.cpp @@ -115,7 +115,7 @@ State::State(void) { #endif memset(_conversationState, 0, sizeof(Conversation) * 60); - + _conversationData = nullptr; _currentConversationId = -1; _exitConversation = true; -- cgit v1.2.3 From e4f3f44c23c05410ddf5a1f1d387ca7d3acaef80 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:15:01 +0200 Subject: ZVISION: Remove trailing whitespace --- engines/zvision/archives/zfs_archive.cpp | 2 +- engines/zvision/core/save_manager.cpp | 4 ++-- engines/zvision/scripting/actions.cpp | 6 +++--- engines/zvision/scripting/controls/animation_control.h | 2 +- engines/zvision/scripting/controls/lever_control.cpp | 12 ++++++------ engines/zvision/scripting/controls/push_toggle_control.cpp | 4 ++-- engines/zvision/scripting/controls/timer_node.cpp | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- engines/zvision/utility/utility.cpp | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/engines/zvision/archives/zfs_archive.cpp b/engines/zvision/archives/zfs_archive.cpp index f5fa6fc9bf..d18cc9966b 100644 --- a/engines/zvision/archives/zfs_archive.cpp +++ b/engines/zvision/archives/zfs_archive.cpp @@ -79,7 +79,7 @@ void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { // Read in each entry header for (uint32 i = 0; i < _header.filesPerBlock; ++i) { ZfsEntryHeader entryHeader; - + entryHeader.name = readEntryName(stream); entryHeader.offset = stream->readUint32LE(); entryHeader.id = stream->readUint32LE(); diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 07fb7637e7..e10201e024 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -106,7 +106,7 @@ void SaveManager::autoSave() { void SaveManager::writeSaveGameData(Common::OutSaveFile *file) { // Create a thumbnail and save it Graphics::saveThumbnail(*file); - + // Write out the save date/time TimeDate td; g_system->getTimeAndDate(td); @@ -171,7 +171,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea warning("File is not a ZVision save file. Aborting load"); return false; } - + // Read in the version header.version = in->readByte(); diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 517278e155..219f418b13 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -123,7 +123,7 @@ ActionDisableControl::ActionDisableControl(const Common::String &line) { bool ActionDisableControl::execute(ZVision *engine) { debug("Disabling control %u", _key); - + ScriptManager *scriptManager = engine->getScriptManager(); scriptManager->setStateFlags(_key, scriptManager->getStateFlags(_key) | ScriptManager::DISABLED); @@ -194,7 +194,7 @@ bool ActionMusic::execute(ZVision *engine) { } else { audioStream = makeRawZorkStream(_fileName, engine); } - + if (_loop) { Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); engine->_mixer->playStream(_soundType, 0, loopingAudioStream, -1, _volume); @@ -327,7 +327,7 @@ ActionSetPartialScreen::ActionSetPartialScreen(const Common::String &line) { bool ActionSetPartialScreen::execute(ZVision *engine) { RenderManager *renderManager = engine->getRenderManager(); - + if (_backgroundColor > 0) { renderManager->clearWorkingWindowTo555Color(_backgroundColor); } diff --git a/engines/zvision/scripting/controls/animation_control.h b/engines/zvision/scripting/controls/animation_control.h index 6c4d6dfcf7..bdb07d39ea 100644 --- a/engines/zvision/scripting/controls/animation_control.h +++ b/engines/zvision/scripting/controls/animation_control.h @@ -56,7 +56,7 @@ private: private: uint32 _animationKey; - + union { RlfAnimation *rlf; Video::VideoDecoder *avi; diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 9724e661b7..c029a2a7a1 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -84,7 +84,7 @@ LeverControl::~LeverControl() { } else if (_fileType == RLF) { delete _animation.rlf; } - + delete[] _frameInfo; } @@ -194,7 +194,7 @@ void LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common if (!_enabled) { return; } - + if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { _mouseIsCaptured = true; _lastMousePos = backgroundImageSpacePos; @@ -205,7 +205,7 @@ void LeverControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: if (!_enabled) { return; } - + if (_mouseIsCaptured) { _mouseIsCaptured = false; _engine->getScriptManager()->setStateValue(_key, _currentFrame); @@ -220,7 +220,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common if (!_enabled) { return false; } - + bool cursorWasChanged = false; if (_mouseIsCaptured) { @@ -276,7 +276,7 @@ bool LeverControl::process(uint32 deltaTimeInMillis) { renderFrame(_returnRoutesCurrentFrame); } } - + return false; } @@ -387,7 +387,7 @@ void LeverControl::renderFrame(uint frameNumber) { // getFrameData() will automatically optimize to getNextFrame() / getPreviousFrame() if it can frameData = (const uint16 *)_animation.rlf->getFrameData(frameNumber)->getPixels(); width = _animation.rlf->width(); // Use the animation width instead of _animationCoords.width() - height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height() + height = _animation.rlf->height(); // Use the animation height instead of _animationCoords.height() } else if (_fileType == AVI) { _animation.avi->seekToFrame(frameNumber); const Graphics::Surface *surface = _animation.avi->decodeNextFrame(); diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 82736b7576..a96c95b377 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -76,7 +76,7 @@ void PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com if (!_enabled) { return; } - + if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getScriptManager()->setStateValue(_key, 1); } @@ -86,7 +86,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C if (!_enabled) { return false; } - + if (_hotspot.contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(_hoverCursor); return true; diff --git a/engines/zvision/scripting/controls/timer_node.cpp b/engines/zvision/scripting/controls/timer_node.cpp index c8c8a85d34..6f88b056a1 100644 --- a/engines/zvision/scripting/controls/timer_node.cpp +++ b/engines/zvision/scripting/controls/timer_node.cpp @@ -31,7 +31,7 @@ namespace ZVision { - + TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) : Control(engine, key) { if (_engine->getGameId() == GID_NEMESIS) { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 753ce4ac6a..416bac00f3 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -236,7 +236,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (line.matchString("*:ttytext*", true)) { // TODO: Implement ActionTTYText } else if (line.matchString("*:universe_music*", true)) { - // TODO: Implement ActionUniverseMusic + // TODO: Implement ActionUniverseMusic } else if (line.matchString("*:copy_file*", true)) { // Not used. Purposely left empty } else { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 41b835e550..da82308051 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -260,7 +260,7 @@ Control *ScriptManager::getControl(uint32 key) { void ScriptManager::focusControl(uint32 key) { for (ControlList::iterator iter = _activeControls.begin(); iter != _activeControls.end(); ++iter) { uint32 controlKey = (*iter)->getKey(); - + if (controlKey == key) { (*iter)->focus(); } else if (controlKey == _currentlyFocusedControl) { diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp index 905bc4513a..2079d23733 100644 --- a/engines/zvision/utility/utility.cpp +++ b/engines/zvision/utility/utility.cpp @@ -203,7 +203,7 @@ void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Com return; Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine); - + Common::DumpFile output; output.open(outputFile); -- cgit v1.2.3 From 2cbd2402a516e852c0d04650825b8f3ce96b6a51 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:15:43 +0200 Subject: SCUMM: Remove trailing whitespace --- engines/scumm/cdda.cpp | 2 +- engines/scumm/detection.cpp | 2 +- engines/scumm/scumm.h | 2 +- engines/scumm/sound.cpp | 4 ++-- engines/scumm/vars.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/scumm/cdda.cpp b/engines/scumm/cdda.cpp index adb414ecce..d797712a31 100644 --- a/engines/scumm/cdda.cpp +++ b/engines/scumm/cdda.cpp @@ -46,7 +46,7 @@ private: public: CDDAStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse); virtual ~CDDAStream(); - + int readBuffer(int16 *buffer, const int numSamples); bool isStereo() const { return true; } int getRate() const { return 44100; } diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index a7922b232e..10482ba1fc 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -244,7 +244,7 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename case kGenRoomNum: result = Common::String::format(pattern, 0); break; - + case kGenDiskNumSteam: case kGenRoomNumSteam: { const SteamIndexFile *indexFile = lookUpSteamIndexFile(pattern, platform); diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index af118a89a1..46512f8ce6 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1362,7 +1362,7 @@ public: byte VAR_SCRIPT_CYCLE; // Used in runScript()/runObjectScript() byte VAR_NUM_SCRIPT_CYCLES; // Used in runAllScripts() - + byte VAR_QUIT_SCRIPT; // Used in confirmExitDialog() // Exists both in V7 and in V72HE: diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index cb428d1c15..84d2b37f96 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -1066,9 +1066,9 @@ void Sound::playCDTrackInternal(int track, int numLoops, int startFrame, int dur Common::File *cddaFile = new Common::File(); if (cddaFile->open("CDDA.SOU")) { Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75); - Audio::Timestamp end = Audio::Timestamp(0, startFrame + duration, 75); + Audio::Timestamp end = Audio::Timestamp(0, startFrame + duration, 75); Audio::SeekableAudioStream *stream = makeCDDAStream(cddaFile, DisposeAfterUse::YES); - + _mixer->playStream(Audio::Mixer::kMusicSoundType, &_loomSteamCDAudioHandle, Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops)); } else { diff --git a/engines/scumm/vars.cpp b/engines/scumm/vars.cpp index a903ac5804..a6be5c3f3a 100644 --- a/engines/scumm/vars.cpp +++ b/engines/scumm/vars.cpp @@ -715,7 +715,7 @@ void ScummEngine_v99he::resetScummVars() { VAR(140) = 0; #endif } - + if (_game.id == GID_PUTTZOO && _game.heversion == 100 && _game.platform == Common::kPlatformWindows) { // Specific to Nimbus Games version. VAR(156) = 1; -- cgit v1.2.3 From 6bdb362370df85da27ddae45065464240548e2ab Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:16:12 +0200 Subject: SAGA: Remove trailing whitespace --- engines/saga/introproc_ite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/saga/introproc_ite.cpp b/engines/saga/introproc_ite.cpp index 0c1a2ce233..0b129dbcc0 100644 --- a/engines/saga/introproc_ite.cpp +++ b/engines/saga/introproc_ite.cpp @@ -374,7 +374,7 @@ int Scene::ITEIntroCaveCommonProc(int param, int caveScene) { lang = 2; int n_dialogues = 0; - + switch (caveScene) { case 1: n_dialogues = ARRAYSIZE(introDialogueCave1[lang]); -- cgit v1.2.3 From 9783f0bbd9f7aca0622ec0138d727abdcbd4145c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:17:06 +0200 Subject: SCI: Remove trailing whitespace --- engines/sci/console.cpp | 4 ++-- engines/sci/engine/kernel.h | 4 ++-- engines/sci/engine/script_patches.h | 2 +- engines/sci/graphics/paint32.cpp | 2 +- engines/sci/graphics/picture.cpp | 4 ++-- engines/sci/graphics/portrait.cpp | 42 ++++++++++++++++++------------------- engines/sci/graphics/portrait.h | 2 +- engines/sci/graphics/screen.cpp | 6 +++--- engines/sci/graphics/view.cpp | 2 +- engines/sci/module.mk | 4 ++-- engines/sci/resource_audio.cpp | 2 +- engines/sci/sci.cpp | 6 +++--- engines/sci/sound/music.cpp | 2 +- engines/sci/sound/music.h | 2 +- 14 files changed, 42 insertions(+), 42 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 510c8cd9ca..e233c4cba4 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -664,7 +664,7 @@ bool Console::cmdDiskDump(int argc, const char **argv) { int resNumFrom = 0; int resNumTo = 0; int resNumCur = 0; - + if (argc != 3) { debugPrintf("Dumps the specified resource to disk as a patch file\n"); debugPrintf("Usage: %s \n", argv[0]); @@ -672,7 +672,7 @@ bool Console::cmdDiskDump(int argc, const char **argv) { cmdResourceTypes(argc, argv); return true; } - + if (strcmp(argv[2], "*") == 0) { resNumFrom = 0; resNumTo = 65535; diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index dddf845222..a65bcb7df5 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -145,7 +145,7 @@ public: */ Kernel(ResourceManager *resMan, SegManager *segMan); ~Kernel(); - + void init(); uint getSelectorNamesSize() const; @@ -161,7 +161,7 @@ public: * @return The appropriate selector ID, or -1 on error */ int findSelector(const char *selectorName) const; - + bool selectorNamesAvailable(); // Script dissection/dumping functions diff --git a/engines/sci/engine/script_patches.h b/engines/sci/engine/script_patches.h index 0b35792949..7023ef327e 100644 --- a/engines/sci/engine/script_patches.h +++ b/engines/sci/engine/script_patches.h @@ -98,7 +98,7 @@ private: void enablePatch(const SciScriptPatcherEntry *patchTable, const char *searchDescription); int32 findSignature(const SciScriptPatcherEntry *patchEntry, SciScriptPatcherRuntimeEntry *runtimeEntry, const byte *scriptData, const uint32 scriptSize, bool isMacSci11); void applyPatch(const SciScriptPatcherEntry *patchEntry, byte *scriptData, const uint32 scriptSize, int32 signatureOffset, bool isMacSci11); - + Selector *_selectorIdTable; SciScriptPatcherRuntimeEntry *_runtimeTable; }; diff --git a/engines/sci/graphics/paint32.cpp b/engines/sci/graphics/paint32.cpp index 7d106b5b02..a210a469f1 100644 --- a/engines/sci/graphics/paint32.cpp +++ b/engines/sci/graphics/paint32.cpp @@ -46,7 +46,7 @@ void GfxPaint32::fillRect(Common::Rect rect, byte color) { Common::Rect clipRect = rect; clipRect.clip(_screen->getWidth(), _screen->getHeight()); - + for (y = clipRect.top; y < clipRect.bottom; y++) { for (x = clipRect.left; x < clipRect.right; x++) { _screen->putPixel(x, y, GFX_SCREEN_MASK_VISUAL, color, 0, 0); diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index 434a490109..d751f9738f 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -246,7 +246,7 @@ void GfxPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rlePos int16 y, lastY, x, leftX, rightX; int pixelCount; uint16 width, height; - + // if the picture is not an overlay and we are also not in EGA mode, use priority 0 if (!isEGA && !_addToFlag) priority = 0; @@ -362,7 +362,7 @@ void GfxPicture::drawCelData(byte *inbuffer, int size, int headerPos, int rlePos ptr = celBitmap; ptr += skipCelBitmapPixels; ptr += skipCelBitmapLines * width; - + if ((!isEGA) || (priority < 16)) { // VGA + EGA, EGA only checks priority, when given priority is below 16 if (!_mirroredFlag) { diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 488450485d..668de616fb 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -134,34 +134,34 @@ void Portrait::init() { // raw lip-sync ID table follows uint32 lipSyncIDTableSize; - + lipSyncIDTableSize = READ_LE_UINT32(data); data += 4; assert( lipSyncIDTableSize == (_lipSyncIDCount * 4) ); _lipSyncIDTable = data; data += lipSyncIDTableSize; - + // raw lip-sync frame table follows uint32 lipSyncDataTableSize; uint32 lipSyncDataTableLastOffset; byte lipSyncData; uint16 lipSyncDataNr; uint16 lipSyncCurOffset; - + lipSyncDataTableSize = READ_LE_UINT32(data); data += 4; assert( lipSyncDataTableSize == 0x220 ); // always this size, just a safety-check - + _lipSyncData = data; lipSyncDataTableLastOffset = lipSyncDataTableSize - 1; _lipSyncDataOffsetTable = new uint16[ _lipSyncIDCount ]; - + lipSyncDataNr = 0; lipSyncCurOffset = 0; while ( (lipSyncCurOffset < lipSyncDataTableSize) && (lipSyncDataNr < _lipSyncIDCount) ) { // We are currently at the start of ID-frame data _lipSyncDataOffsetTable[lipSyncDataNr] = lipSyncCurOffset; - + // Look for end of ID-frame data lipSyncData = *data++; lipSyncCurOffset++; while ( (lipSyncData != 0xFF) && (lipSyncCurOffset < lipSyncDataTableLastOffset) ) { @@ -195,7 +195,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint Resource *syncResource = _resMan->findResource(syncResourceId, true); uint syncOffset = 0; #endif - + #ifdef DEBUG_PORTRAIT // prints out the current lip sync ASCII data char debugPrint[4000]; @@ -246,7 +246,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint warning("kPortrait: no rave resource %d %X", resourceId, audioNumber); return; } - + // Do animation depending on rave resource till audio is done playing int16 raveTicks; uint16 raveID; @@ -264,7 +264,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint raveTicks = raveGetTicks(raveResource, &raveOffset); if (raveTicks < 0) break; - + // get lipSyncID raveID = raveGetID(raveResource, &raveOffset); if (raveID) { @@ -272,7 +272,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } else { raveLipSyncData = NULL; } - + timerPosition += raveTicks; // Wait till syncTime passed, then show specific animation bitmap @@ -287,7 +287,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint curPosition = _audio->getAudioPosition(); } while ((curPosition != -1) && (curPosition < timerPosition) && (!userAbort)); } - + if (raveLipSyncData) { // lip sync data is // Tick:Byte, Bitmap-Nr:BYTE @@ -308,7 +308,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } while ((curPosition != -1) && (curPosition < timerPositionWithin) && (!userAbort)); raveLipSyncBitmapNr = *raveLipSyncData++; - + // bitmap nr within sync data is base 1, we need base 0 raveLipSyncBitmapNr--; @@ -319,7 +319,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } else { warning("kPortrait: rave lip sync data tried to draw non-existent bitmap %d", raveLipSyncBitmapNr); } - + raveLipSyncTicks = *raveLipSyncData++; } } @@ -372,7 +372,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } } #endif - + // Reset the portrait bitmap to "closed mouth" state (rave.dll seems to do the same) drawBitmap(0); bitsShow(); @@ -393,10 +393,10 @@ int16 Portrait::raveGetTicks(Resource *resource, uint *offset) { byte *curData = resource->data + curOffset; byte curByte; uint16 curValue = 0; - + if (curOffset >= resource->size) return -1; - + while (curOffset < resource->size) { curByte = *curData++; curOffset++; if ( curByte == ' ' ) @@ -418,7 +418,7 @@ uint16 Portrait::raveGetID(Resource *resource, uint *offset) { byte *curData = resource->data + curOffset; byte curByte = 0; uint16 curValue = 0; - + while (curOffset < resource->size) { curByte = *curData++; curOffset++; if ( curByte == ' ' ) @@ -429,7 +429,7 @@ uint16 Portrait::raveGetID(Resource *resource, uint *offset) { curValue |= curByte; } } - + *offset = curOffset; return curValue; } @@ -440,17 +440,17 @@ byte *Portrait::raveGetLipSyncData(uint16 raveID) { byte *lipSyncIDPtr = _lipSyncIDTable; byte lipSyncIDByte1, lipSyncIDByte2; uint16 lipSyncID; - + lipSyncIDPtr++; // skip over first byte while (lipSyncIDNr < _lipSyncIDCount) { lipSyncIDByte1 = *lipSyncIDPtr++; lipSyncIDByte2 = *lipSyncIDPtr++; lipSyncID = ( lipSyncIDByte1 << 8 ) | lipSyncIDByte2; - + if ( lipSyncID == raveID ) { return _lipSyncData + _lipSyncDataOffsetTable[lipSyncIDNr]; } - + lipSyncIDNr++; lipSyncIDPtr += 2; // ID is every 4 bytes } diff --git a/engines/sci/graphics/portrait.h b/engines/sci/graphics/portrait.h index 877b253bcf..e0888daa86 100644 --- a/engines/sci/graphics/portrait.h +++ b/engines/sci/graphics/portrait.h @@ -72,7 +72,7 @@ private: Common::String _resourceName; byte *_fileData; - + uint32 _lipSyncIDCount; byte *_lipSyncIDTable; diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index c5c94d7991..d66352b411 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -50,7 +50,7 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { _upscaledHires = GFX_SCREEN_UPSCALED_640x480; #endif } - + if (g_sci->getPlatform() == Common::kPlatformMacintosh) { if (getSciVersion() <= SCI_VERSION_01) _upscaledHires = GFX_SCREEN_UPSCALED_480x300; @@ -232,7 +232,7 @@ void GfxScreen::copyRectToScreen(const Common::Rect &rect, int16 x, int16 y) { } else { int rectHeight = _upscaledHeightMapping[rect.bottom] - _upscaledHeightMapping[rect.top]; int rectWidth = _upscaledWidthMapping[rect.right] - _upscaledWidthMapping[rect.left]; - + g_system->copyRectToScreen(_activeScreen + _upscaledHeightMapping[rect.top] * _displayWidth + _upscaledWidthMapping[rect.left], _displayWidth, _upscaledWidthMapping[x], _upscaledHeightMapping[y], rectWidth, rectHeight); } } @@ -329,7 +329,7 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte int16 top = CLIP(startPoint.y, 0, maxHeight); int16 right = CLIP(endPoint.x, 0, maxWidth); int16 bottom = CLIP(endPoint.y, 0, maxHeight); - + //set_drawing_flag byte drawMask = getDrawingMask(color, priority, control); diff --git a/engines/sci/graphics/view.cpp b/engines/sci/graphics/view.cpp index a88546e68c..da61ecf4c3 100644 --- a/engines/sci/graphics/view.cpp +++ b/engines/sci/graphics/view.cpp @@ -367,7 +367,7 @@ void GfxView::initData(GuiResourceId resourceId) { default: error("ViewType was not detected, can't continue"); } - + // Inject our own views // Currently only used for Dual mode (speech + text) for games, that do not have a "dual" icon already // Which is Laura Bow 2 + King's Quest 6 diff --git a/engines/sci/module.mk b/engines/sci/module.mk index 6b6058c819..33392e3b42 100644 --- a/engines/sci/module.mk +++ b/engines/sci/module.mk @@ -76,8 +76,8 @@ MODULE_OBJS := \ sound/drivers/midi.o \ sound/drivers/pcjr.o \ video/seq_decoder.o - - + + ifdef ENABLE_SCI32 MODULE_OBJS += \ engine/kgraphics32.o \ diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp index 66778f0914..c775f502c5 100644 --- a/engines/sci/resource_audio.cpp +++ b/engines/sci/resource_audio.cpp @@ -110,7 +110,7 @@ bool Resource::loadFromAudioVolumeSCI11(Common::SeekableReadStream *file) { unalloc(); return false; } - + _headerSize = file->readByte(); if (type == kResourceTypeAudio) { diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index fc723f18cf..60a1271b89 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -219,7 +219,7 @@ Common::Error SciEngine::run() { // Add the after market GM patches for the specified game, if they exist _resMan->addNewGMPatch(_gameId); _gameObjectAddress = _resMan->findGameObject(); - + _scriptPatcher = new ScriptPatcher(); SegManager *segMan = new SegManager(_resMan, _scriptPatcher); @@ -896,7 +896,7 @@ void SciEngine::syncSoundSettings() { bool SciEngine::speechAndSubtitlesEnabled() { bool subtitlesOn = ConfMan.getBool("subtitles"); bool speechOn = !ConfMan.getBool("speech_mute"); - + if (isCD() && subtitlesOn && speechOn) return true; return false; @@ -936,7 +936,7 @@ void SciEngine::updateScummVMAudioOptions() { // depending on the in-game settings if (isCD() && getSciVersion() == SCI_VERSION_1_1) { uint16 ingameSetting = _gamestate->variables[VAR_GLOBAL][90].getOffset(); - + switch (ingameSetting) { case 1: // subtitles diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index 362cca699d..7a6eaf62b4 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -142,7 +142,7 @@ void SciMusic::init() { _driverLastChannel = _pMidiDrv->getLastChannel(); if (getSciVersion() <= SCI_VERSION_0_LATE) _globalReverb = _pMidiDrv->getReverb(); // Init global reverb for SCI0 - + _currentlyPlayingSample = NULL; } diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 6149bb799e..4e44074630 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -264,7 +264,7 @@ private: int _driverFirstChannel; int _driverLastChannel; - + MusicEntry *_currentlyPlayingSample; }; -- cgit v1.2.3 From 26588f81b4f4749c0136cdf4f5de09405dee9e3a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:17:44 +0200 Subject: PEGASUS: Remove trailing whitespace --- engines/pegasus/input.cpp | 2 +- engines/pegasus/pegasus.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp index e1b7e25cd5..73c319bd8b 100644 --- a/engines/pegasus/input.cpp +++ b/engines/pegasus/input.cpp @@ -57,7 +57,7 @@ InputDeviceManager::InputDeviceManager() { _keyMap[Common::KEYCODE_p] = false; _keyMap[Common::KEYCODE_TILDE] = false; _keyMap[Common::KEYCODE_BACKQUOTE] = false; - _keyMap[Common::KEYCODE_KP7] = false; + _keyMap[Common::KEYCODE_KP7] = false; _keyMap[Common::KEYCODE_BACKSPACE] = false; _keyMap[Common::KEYCODE_KP_MULTIPLY] = false; _keyMap[Common::KEYCODE_KP9] = false; diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 0c8ea2e4ee..4262ad4c12 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -979,7 +979,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) { resetIntroTimer(); break; case kMenuCmdPauseSave: - result = showSaveDialog(); + result = showSaveDialog(); if (result.getCode() != Common::kUserCanceled) { if (result.getCode() != Common::kNoError) -- cgit v1.2.3 From e0c281b9b22fa8e515eb3b8c02a80ff3431acbc6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:18:11 +0200 Subject: NEVERHOOD: Remove trailing whitespace --- engines/neverhood/console.cpp | 2 +- engines/neverhood/sound.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp index 91ab3e767a..7ee6b30311 100644 --- a/engines/neverhood/console.cpp +++ b/engines/neverhood/console.cpp @@ -55,7 +55,7 @@ bool Console::Cmd_Scene(int argc, const char **argv) { const char *sceneTypes[] = { "normal", "smacker", "navigation" }; - debugPrintf("Current module: %d, previous module: %d, scene %d (%s scene)\n", currentModule, previousModule, scenenNum, sceneTypes[sceneType]); + debugPrintf("Current module: %d, previous module: %d, scene %d (%s scene)\n", currentModule, previousModule, scenenNum, sceneTypes[sceneType]); if (sceneType == kSceneTypeNormal) { Scene *scene = (Scene *)((GameModule *)_vm->_gameModule->_childObject)->_childObject; diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp index d53243d4ba..b15bea4a64 100644 --- a/engines/neverhood/sound.cpp +++ b/engines/neverhood/sound.cpp @@ -560,7 +560,7 @@ int NeverhoodAudioStream::readBuffer(int16 *buffer, const int numSamples) { } else { while (samplesRead--) { *buffer++ = READ_LE_UINT16(src); - src += 2; + src += 2; } } -- cgit v1.2.3 From 01e8286e1c8df605c98f828e5834584c997713b4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:19:26 +0200 Subject: MADS: Remove trailing whitespace --- engines/mads/game.cpp | 2 +- engines/mads/menu_views.cpp | 24 ++++++++++++------------ engines/mads/nebular/dialogs_nebular.cpp | 2 +- engines/mads/nebular/dialogs_nebular.h | 4 ++-- engines/mads/nebular/game_nebular.cpp | 2 +- engines/mads/nebular/menu_nebular.cpp | 16 ++++++++-------- engines/mads/nebular/nebular_scenes6.cpp | 2 +- engines/mads/nebular/nebular_scenes7.cpp | 2 +- engines/mads/nebular/nebular_scenes8.cpp | 2 +- engines/mads/palette.cpp | 4 ++-- engines/mads/scene_data.cpp | 2 +- engines/mads/sequence.cpp | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index 63a7e40d1b..94653f9a39 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -556,7 +556,7 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea if (!_saveThumb) createThumbnail(); Graphics::saveThumbnail(*out, *_saveThumb); - + _saveThumb->free(); delete _saveThumb; _saveThumb = nullptr; diff --git a/engines/mads/menu_views.cpp b/engines/mads/menu_views.cpp index 03afc70c3e..ee4268a650 100644 --- a/engines/mads/menu_views.cpp +++ b/engines/mads/menu_views.cpp @@ -37,7 +37,7 @@ MenuView::MenuView(MADSEngine *vm) : FullScreenDialog(vm) { } void MenuView::show() { - Scene &scene = _vm->_game->_scene; + Scene &scene = _vm->_game->_scene; EventsManager &events = *_vm->_events; _vm->_screenFade = SCREEN_FADE_FAST; @@ -195,7 +195,7 @@ void TextView::processCommand() { paramP = commandStr + 10; resetPalette(); int screenId = getParameter(¶mP); - + SceneInfo *sceneInfo = SceneInfo::init(_vm); sceneInfo->load(screenId, 0, "", 0, scene._depthSurface, scene._backgroundSurface); scene._spriteSlots.fullRefresh(); @@ -230,7 +230,7 @@ void TextView::processCommand() { int soundId = getParameter(¶mP); _vm->_sound->command(soundId); - } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') || + } else if (!strncmp(commandStr, "COLOR", 5) && ((commandStr[5] == '0') || (commandStr[5] == '1'))) { // Set the text colors int index = commandStr[5] - '0'; @@ -254,7 +254,7 @@ void TextView::processCommand() { sceneInfo->_width = MADS_SCREEN_WIDTH; sceneInfo->_height = MADS_SCENE_HEIGHT; _spareScreens[spareIndex].setSize(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT); - sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE, + sceneInfo->loadMadsV1Background(screenId, "", SCENEFLAG_TRANSLATE, _spareScreens[spareIndex]); delete sceneInfo; @@ -409,7 +409,7 @@ void TextView::doFrame() { Common::copy(srcP, srcP + MADS_SCREEN_WIDTH, destP); } - Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH, + Common::copy(linesTemp, linesTemp + _pan.y * MADS_SCREEN_WIDTH, (byte *)scene._backgroundSurface.getPixels()); delete[] linesTemp; } @@ -429,7 +429,7 @@ void TextView::doFrame() { if (tl._pos.y < 0) { _textLines.remove_at(i); } else { - tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y, + tl._textDisplayIndex = scene._textDisplay.add(tl._pos.x, tl._pos.y, 0x605, -1, tl._line, _font); } } @@ -537,7 +537,7 @@ bool AnimationView::onEvent(Common::Event &event) { void AnimationView::doFrame() { Scene &scene = _vm->_game->_scene; - + if (_resourceIndex == -1 || _currentAnimation->freeFlag()) { if (++_resourceIndex == (int)_resources.size()) { scriptDone(); @@ -565,7 +565,7 @@ void AnimationView::loadNextResource() { if (resEntry._bgFlag) palette.resetGamePalette(1, 8); - palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1] + palette._mainPalette[253 * 3] = palette._mainPalette[253 * 3 + 1] = palette._mainPalette[253 * 3 + 2] = 0xb4; palette.setPalette(&palette._mainPalette[253 * 3], 253, 1); @@ -587,7 +587,7 @@ void AnimationView::loadNextResource() { delete _currentAnimation; _currentAnimation = Animation::init(_vm, &scene); int flags = ANIMFLAG_ANIMVIEW | (resEntry._bgFlag ? ANIMFLAG_LOAD_BACKGROUND : 0); - _currentAnimation->load(scene._backgroundSurface, scene._depthSurface, + _currentAnimation->load(scene._backgroundSurface, scene._depthSurface, resEntry._resourceName, flags, &paletteCycles, _sceneInfo); // Signal for a screen refresh @@ -656,7 +656,7 @@ void AnimationView::processLines() { if (c != '\r' && c != '\0') _currentLine += c; } - + // Process the line while (!_currentLine.empty()) { if (_currentLine.hasPrefix("-")) { @@ -672,7 +672,7 @@ void AnimationView::processLines() { } // Add resource into list along with any set state information - _resources.push_back(ResourceEntry(resName, _sfx, _soundFlag, + _resources.push_back(ResourceEntry(resName, _sfx, _soundFlag, _bgLoadFlag, _showWhiteBars)); // Fx resets between resource entries @@ -753,7 +753,7 @@ int AnimationView::getParameter() { while (!_currentLine.empty()) { char c = _currentLine[0]; - + if (c >= '0' && c <= '9') { _currentLine.deleteChar(0); result = result * 10 + (c - '0'); diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index f51d046951..f5355517bd 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -908,7 +908,7 @@ void GameDialog::refreshText() { } if (!skipFlag) { - _lines[i]._textDisplayIndex = scene._textDisplay.add(_lines[i]._pos.x, _lines[i]._pos.y, + _lines[i]._textDisplayIndex = scene._textDisplay.add(_lines[i]._pos.x, _lines[i]._pos.y, fontColor, _lines[i]._widthAdjust, _lines[i]._msg, _lines[i]._font); } } diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h index d00cd87ead..5dbe4da6f0 100644 --- a/engines/mads/nebular/dialogs_nebular.h +++ b/engines/mads/nebular/dialogs_nebular.h @@ -116,7 +116,7 @@ class GameDialog: public FullScreenDialog { Common::String _msg; Font *_font; int _widthAdjust; - + DialogLine(); DialogLine(const Common::String &s); }; @@ -130,7 +130,7 @@ protected: int _menuSpritesIndex; int _lineIndex; int _textLineCount; - + /** * Display the dialog */ diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp index eae74d6da0..fd669bc5cf 100644 --- a/engines/mads/nebular/game_nebular.cpp +++ b/engines/mads/nebular/game_nebular.cpp @@ -625,7 +625,7 @@ void GameNebular::doObjectAction() { _objects.addToInventory(OBJ_DURAFAIL_CELLS); if (_difficulty == DIFFICULTY_HARD) { dialogs.showItem(OBJ_DURAFAIL_CELLS, 416); - } + } _globals[kHandsetCellStatus] = 0; break; case 3: diff --git a/engines/mads/nebular/menu_nebular.cpp b/engines/mads/nebular/menu_nebular.cpp index f2f90e2291..28de4e5650 100644 --- a/engines/mads/nebular/menu_nebular.cpp +++ b/engines/mads/nebular/menu_nebular.cpp @@ -48,7 +48,7 @@ MainMenu::MainMenu(MADSEngine *vm): MenuView(vm) { _highlightedIndex = -1; _selectedIndex = -1; _buttonDown = false; - + for (int i = 0; i < 7; ++i) _menuItems[i] = nullptr; } @@ -85,7 +85,7 @@ void MainMenu::display() { Common::Point pt(frame0->_offset.x - (frame0->w / 2), frame0->_offset.y - frame0->h); screenObjects.add( - Common::Rect(pt.x, pt.y + DIALOG_TOP, pt.x + frame0->w, + Common::Rect(pt.x, pt.y + DIALOG_TOP, pt.x + frame0->w, pt.y + frame0->h + DIALOG_TOP), LAYER_GUI, CAT_COMMAND, i); } @@ -126,7 +126,7 @@ void MainMenu::doFrame() { // If the user has chosen to skip the animation, show the full menu immediately if (_skipFlag && _menuItemIndex >= 0) { - // Quickly loop through all the menu items to display each's final frame + // Quickly loop through all the menu items to display each's final frame for (; _menuItemIndex < 6; ++_menuItemIndex) { if (_menuItemIndex == 4 && !shouldShowQuotes()) continue; @@ -161,7 +161,7 @@ void MainMenu::doFrame() { void MainMenu::addSpriteSlot() { Scene &scene = _vm->_game->_scene; SpriteSlots &spriteSlots = scene._spriteSlots; - + int seqIndex = (_menuItemIndex < 6) ? _menuItemIndex : _frameIndex; spriteSlots.deleteTimer(seqIndex); @@ -255,7 +255,7 @@ bool MainMenu::onEvent(Common::Event &event) { } return true; - case Common::EVENT_MOUSEMOVE: + case Common::EVENT_MOUSEMOVE: if (_buttonDown) { int menuIndex = getHighlightedItem(event.mouse); if (menuIndex != _highlightedIndex) { @@ -287,7 +287,7 @@ bool MainMenu::onEvent(Common::Event &event) { default: break; } - + return false; } @@ -317,7 +317,7 @@ void MainMenu::handleAction(MADSGameAction action) { break; case RESUME_GAME: - // The original resumed the most recently saved game. Instead, + // The original resumed the most recently saved game. Instead, // just show the load game scren _vm->_dialogs->_pendingDialog = DIALOG_RESTORE; return; @@ -354,7 +354,7 @@ void AdvertView::show() { uint32 expiryTime = g_system->getMillis() + 10 * 1000; _vm->_palette->resetGamePalette(4, 8); - + // Load the advert background onto the screen SceneInfo *sceneInfo = SceneInfo::init(_vm); sceneInfo->load(screenId, 0, Common::String(), 0, _vm->_game->_scene._depthSurface, diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp index 13ee1a3dc1..679039535f 100644 --- a/engines/mads/nebular/nebular_scenes6.cpp +++ b/engines/mads/nebular/nebular_scenes6.cpp @@ -3155,7 +3155,7 @@ bool Scene611::check2ChargedBatteries() { } bool Scene611::check4ChargedBatteries() { - if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS) + if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS) && _globals[kDurafailRecharged]) return true; diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp index 930bb7c250..0f019c4b19 100644 --- a/engines/mads/nebular/nebular_scenes7.cpp +++ b/engines/mads/nebular/nebular_scenes7.cpp @@ -2616,7 +2616,7 @@ void Scene752::actions() { default: break; } - } else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._savedFields._mainObjectSource == CAT_HOTSPOT) && + } else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._savedFields._mainObjectSource == CAT_HOTSPOT) && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) { switch (_game._trigger) { case 0: diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index 14f36756de..62a1a262b0 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -1098,7 +1098,7 @@ void Scene804::actions() { _action.isAction(VERB_OPEN, NOUN_SERVICE_PANEL)) { _scene->_nextSceneId = 805; } else if ((_action.isAction(VERB_ACTIVATE, NOUN_REMOTE)) && _globals[kTopButtonPushed]) { - if (!_globals[kInSpace]) { + if (!_globals[kInSpace]) { // Top button pressed on panel in hanger control if (!_globals[kBeamIsUp]) { _globals[kFromCockpit] = true; diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 1787b3c298..836d04f7c0 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -233,7 +233,7 @@ int PaletteUsage::process(Common::Array &palette, uint flags) { // CHECKME: When pressing on F1 in the first screen, newPalIndex is set to 0xFF at this point // which is a valid value for the index. Maybe a better check would be "< 256" ? //assert(newPalIndex != -1); - + int var52 = (noUsageFlag && palette[palIndex]._u2) ? 2 : 0; _vm->_palette->_palFlags[newPalIndex] |= var52 | rgbMask; @@ -342,7 +342,7 @@ int PaletteUsage::checkRGB(const byte *rgb, int palStart, bool flag, int *palInd if ((!(*flagsP & 1) || flag) && !(*flagsP & 2)) { if (!memcmp(palP, rgb, 3)) { *flagsP |= mask; - + if (palIndex) *palIndex = result; match = true; diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp index b0a5aa35c6..b5e219ed04 100644 --- a/engines/mads/scene_data.cpp +++ b/engines/mads/scene_data.cpp @@ -264,7 +264,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName, assert(asset && _depthStyle != 2); MSprite *spr = asset->getFrame(asset->getCount() - 1); - bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, + bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, si._scale, spr->getTransparencyIndex()); } diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp index 07b1451718..05f00afb5a 100644 --- a/engines/mads/sequence.cpp +++ b/engines/mads/sequence.cpp @@ -473,7 +473,7 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point( frame->_offset.x + frame->w / 2, frame->_offset.y + frame->h / 2)); - return add(srcSpriteIndex, flipped, sprites->getCount(), triggerCountdown, timeoutTicks, + return add(srcSpriteIndex, flipped, sprites->getCount(), triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0, true, 100, depth - 1, -1, ANIMTYPE_REVERSIBLE, 0, 0); } -- cgit v1.2.3 From 8d11226723964d754dff2efca35d082e25affae3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:20:43 +0200 Subject: MORTEVIELLE: Remove trailing whitespace --- engines/mortevielle/detection_tables.h | 2 +- engines/mortevielle/mortevielle.h | 2 +- engines/mortevielle/utils.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/mortevielle/detection_tables.h b/engines/mortevielle/detection_tables.h index 0aa27b89eb..d244d15365 100644 --- a/engines/mortevielle/detection_tables.h +++ b/engines/mortevielle/detection_tables.h @@ -75,7 +75,7 @@ static const MortevielleGameDescription MortevielleGameDescriptions[] = { // DOS English version doesn't exist. Technically, they are French or German versions, // using English strings stored mort.dat - + // English on top of French version { { diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h index c3d1e4ae8b..5f7f175c26 100644 --- a/engines/mortevielle/mortevielle.h +++ b/engines/mortevielle/mortevielle.h @@ -421,7 +421,7 @@ public: byte *_curPict; byte *_curAnim; byte *_rightFramePict; - + PaletteManager _paletteManager; GfxSurface _backgroundSurface; Common::RandomSource _randomSource; diff --git a/engines/mortevielle/utils.cpp b/engines/mortevielle/utils.cpp index d5dec6a286..40136ad78b 100644 --- a/engines/mortevielle/utils.cpp +++ b/engines/mortevielle/utils.cpp @@ -3097,7 +3097,7 @@ void MortevielleEngine::putObject() { */ void MortevielleEngine::addObjectToInventory(int objectId) { int i; - + for (i = 1; (i <= 5) && (_coreVar._inventory[i] != 0); i++) ; -- cgit v1.2.3 From 0f0ca25e4321b978370e1f7d325fd31f144d0ca1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:21:53 +0200 Subject: PRINCE: Remove trailing whitespace --- engines/prince/animation.cpp | 6 +++--- engines/prince/animation.h | 2 +- engines/prince/archive.cpp | 2 +- engines/prince/cursor.h | 2 +- engines/prince/graphics.cpp | 2 +- engines/prince/graphics.h | 2 +- engines/prince/hero.cpp | 2 +- engines/prince/hero.h | 4 ++-- engines/prince/mhwanh.cpp | 4 ++-- engines/prince/mob.h | 2 +- engines/prince/object.cpp | 2 +- engines/prince/object.h | 2 +- engines/prince/prince.cpp | 14 +++++++------- engines/prince/prince.h | 4 ++-- engines/prince/pscr.h | 2 +- engines/prince/resource.h | 6 +++--- engines/prince/saveload.cpp | 4 ++-- engines/prince/script.cpp | 14 +++++++------- 18 files changed, 38 insertions(+), 38 deletions(-) diff --git a/engines/prince/animation.cpp b/engines/prince/animation.cpp index b4bde27f69..aabdd7a623 100644 --- a/engines/prince/animation.cpp +++ b/engines/prince/animation.cpp @@ -132,7 +132,7 @@ int16 Animation::getPhaseOffsetX(int phaseIndex) const { if (phaseIndex < _phaseCount) { return _phaseList[phaseIndex]._phaseOffsetX; } else { - error("getPhaseOffsetX() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); + error("getPhaseOffsetX() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); } } @@ -140,7 +140,7 @@ int16 Animation::getPhaseOffsetY(int phaseIndex) const { if (phaseIndex < _phaseCount) { return _phaseList[phaseIndex]._phaseOffsetY; } else { - error("getPhaseOffsetY() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); + error("getPhaseOffsetY() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); } } @@ -148,7 +148,7 @@ int16 Animation::getPhaseFrameIndex(int phaseIndex) const { if (phaseIndex < _phaseCount) { return _phaseList[phaseIndex]._phaseToFrameIndex; } else { - error("getPhaseFrameIndex() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); + error("getPhaseFrameIndex() phaseIndex: %d, phaseCount: %d", phaseIndex, _phaseCount); } } diff --git a/engines/prince/animation.h b/engines/prince/animation.h index 733acb399c..3471ffa158 100644 --- a/engines/prince/animation.h +++ b/engines/prince/animation.h @@ -35,7 +35,7 @@ public: Animation(); ~Animation(); bool loadStream(Common::SeekableReadStream &stream); - + int16 getLoopCount() const; int32 getPhaseCount() const; int32 getFrameCount() const; diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp index ae6a2b7546..7a4a35abd8 100644 --- a/engines/prince/archive.cpp +++ b/engines/prince/archive.cpp @@ -64,7 +64,7 @@ bool PtcArchive::open(const Common::String &filename) { byte *fileTableEnd = fileTable + fileTableSize; _stream->read(fileTable, fileTableSize); decrypt(fileTable, fileTableSize); - + for (byte *fileItem = fileTable; fileItem < fileTableEnd; fileItem += 32) { FileEntry item; Common::String name = (const char*)fileItem; diff --git a/engines/prince/cursor.h b/engines/prince/cursor.h index 9387f344dc..fb07d01729 100644 --- a/engines/prince/cursor.h +++ b/engines/prince/cursor.h @@ -30,7 +30,7 @@ namespace Prince { class Cursor { -public: +public: Cursor(); ~Cursor(); diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp index ad6a2ff85c..f556d81eab 100644 --- a/engines/prince/graphics.cpp +++ b/engines/prince/graphics.cpp @@ -194,7 +194,7 @@ void GraphicsMan::drawTransparentDrawNode(Graphics::Surface *screen, DrawNode *d /** * Similar to drawTransparentDrawNode but with additional anti-aliasing code for sprite drawing. * Edge smoothing is based on 256 x 256 table of colors transition. - * Algorithm is checking if currently drawing pixel is located next to the edge of sprite and if it makes jagged line. + * Algorithm is checking if currently drawing pixel is located next to the edge of sprite and if it makes jagged line. * If it does then this pixel is set with color from transition table calculated of original background pixel color * and sprite's edge pixel color. */ diff --git a/engines/prince/graphics.h b/engines/prince/graphics.h index b6f002b7da..1a1737f976 100644 --- a/engines/prince/graphics.h +++ b/engines/prince/graphics.h @@ -35,7 +35,7 @@ class GraphicsMan { public: GraphicsMan(PrinceEngine *vm); ~GraphicsMan(); - + void update(Graphics::Surface *screen); void change(); diff --git a/engines/prince/hero.cpp b/engines/prince/hero.cpp index 146470f6b7..b873e83360 100644 --- a/engines/prince/hero.cpp +++ b/engines/prince/hero.cpp @@ -129,7 +129,7 @@ int Hero::getScaledValue(int size) { Graphics::Surface *Hero::zoomSprite(Graphics::Surface *heroFrame) { Graphics::Surface *zoomedFrame = new Graphics::Surface(); zoomedFrame->create(_scaledFrameXSize, _scaledFrameYSize, Graphics::PixelFormat::createFormatCLUT8()); - + int sprZoomX; int sprZoomY = _vm->_scaleValue; uint xSource = 0; diff --git a/engines/prince/hero.h b/engines/prince/hero.h index d5f7d8cc7a..703ef0650d 100644 --- a/engines/prince/hero.h +++ b/engines/prince/hero.h @@ -129,7 +129,7 @@ public: void drawHeroShadow(Graphics::Surface *heroFrame); void freeOldMove(); void freeHeroAnim(); - + uint16 _number; uint16 _visible; int16 _state; @@ -170,7 +170,7 @@ public: int _color; // subtitles color uint32 _animSetNr; // number of animation set Common::Array _moveSet; // MoveAnims MoveSet - + uint32 _moveDelay; uint32 _shadMinus; diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp index ef94ef71f9..608ccc23d7 100644 --- a/engines/prince/mhwanh.cpp +++ b/engines/prince/mhwanh.cpp @@ -38,7 +38,7 @@ MhwanhDecoder::~MhwanhDecoder() { void MhwanhDecoder::destroy() { if (_surface != nullptr) { _surface->free(); - delete _surface; + delete _surface; _surface = nullptr; } if (_palette != nullptr) { @@ -57,7 +57,7 @@ bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream) { _palette[i * 3] = stream.readByte(); _palette[i * 3 + 1] = stream.readByte(); _palette[i * 3 + 2] = stream.readByte(); - } + } _surface = new Graphics::Surface(); _surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); diff --git a/engines/prince/mob.h b/engines/prince/mob.h index cc60e36f9b..0ea610dd8f 100644 --- a/engines/prince/mob.h +++ b/engines/prince/mob.h @@ -50,7 +50,7 @@ public: void setData(AttrId dataId, uint16 value); uint16 getData(AttrId dataId); - bool _visible; + bool _visible; uint16 _type; uint16 _mask; Common::Rect _rect; diff --git a/engines/prince/object.cpp b/engines/prince/object.cpp index a9a96455b1..2dc5da68e7 100644 --- a/engines/prince/object.cpp +++ b/engines/prince/object.cpp @@ -79,7 +79,7 @@ bool Object::loadFromStream(Common::SeekableReadStream &stream) { _flags = stream.readUint16LE(); _z = stream.readUint16LE(); - + stream.seek(pos + 16); return true; diff --git a/engines/prince/object.h b/engines/prince/object.h index 68edd061a0..ff22a05805 100644 --- a/engines/prince/object.h +++ b/engines/prince/object.h @@ -62,7 +62,7 @@ public: private: void loadSurface(Common::SeekableReadStream &stream); - Graphics::Surface *_surface; + Graphics::Surface *_surface; }; } // End of namespace Prince diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index b0f2cd5056..04a482c570 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -213,11 +213,11 @@ GUI::Debugger *PrinceEngine::getDebugger() { void PrinceEngine::init() { const Common::FSNode gameDataDir(ConfMan.get("path")); - + debugEngine("Adding all path: %s", gameDataDir.getPath().c_str()); PtcArchive *all = new PtcArchive(); - if (!all->open("all/databank.ptc")) + if (!all->open("all/databank.ptc")) error("Can't open all/databank.ptc"); PtcArchive *voices = new PtcArchive(); @@ -261,7 +261,7 @@ void PrinceEngine::init() { _variaTxt = new VariaTxt(); Resource::loadResource(_variaTxt, "variatxt.dat", true); - + _cursor1 = new Cursor(); Resource::loadResource(_cursor1, "mouse1.cur", true); @@ -705,7 +705,7 @@ void PrinceEngine::freeAllSamples() { } bool PrinceEngine::loadSample(uint32 sampleSlot, const Common::String &streamName) { - // FIXME: This is just a workaround streamName is a path + // FIXME: This is just a workaround streamName is a path // SOUND\\SCIERKA1.WAV for now only last path component is used Common::String normalizedPath = lastPathComponent(streamName, '\\'); @@ -756,7 +756,7 @@ bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::Strin } id = sampleStream->readUint32LE(); - debugEngine("SetVoice slot %d time %04x", slot, id); + debugEngine("SetVoice slot %d time %04x", slot, id); id <<= 3; id /= 22050; id += 2; @@ -768,7 +768,7 @@ bool PrinceEngine::loadVoice(uint32 slot, uint32 sampleSlot, const Common::Strin _secondHero->_talkTime = id; } - debugEngine("SetVoice slot %d time %04x", slot, id); + debugEngine("SetVoice slot %d time %04x", slot, id); sampleStream->seek(SEEK_SET); _audioStream[sampleSlot] = Audio::makeWAVStream(sampleStream, DisposeAfterUse::NO); delete sampleStream; @@ -4321,7 +4321,7 @@ int PrinceEngine::scanDirectionsFindNext(byte *tempCoordsBuf, int xDiff, int yDi tempCoordsBuf += 4; if (tempCoordsBuf == _coords) { - direction = tempX; + direction = tempX; break; } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 0e5bf97dde..930c3c7bd3 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -242,7 +242,7 @@ struct DebugChannel { enum Type { kScript, - kEngine + kEngine }; }; @@ -658,7 +658,7 @@ private: Common::Array _invMobList; bool _flicLooped; - + void mainLoop(); }; diff --git a/engines/prince/pscr.h b/engines/prince/pscr.h index d59fa37d81..fdcdb524a9 100644 --- a/engines/prince/pscr.h +++ b/engines/prince/pscr.h @@ -40,7 +40,7 @@ public: Graphics::Surface *getSurface() const { return _surface; } private: void loadSurface(Common::SeekableReadStream &stream); - Graphics::Surface *_surface; + Graphics::Surface *_surface; }; } // End of namespace Prince diff --git a/engines/prince/resource.h b/engines/prince/resource.h index b1fbd9c4f0..f42eb87842 100644 --- a/engines/prince/resource.h +++ b/engines/prince/resource.h @@ -41,13 +41,13 @@ namespace Resource { bool loadResource(T *resource, const char *resourceName, bool required) { Common::ScopedPtr stream(SearchMan.createReadStreamForMember(resourceName)); if (!stream) { - if (required) + if (required) error("Can't load %s", resourceName); return false; } return loadFromStream(*resource, *stream); - } + } template bool loadResource(Common::Array &array, Common::SeekableReadStream &stream, bool required = true) { @@ -82,7 +82,7 @@ namespace Resource { } // FIXME: This is stupid. Maybe loadFromStream should be helper method that returns initiailzed object - while (true) { + while (true) { T* t = new T(); if (!t->loadFromStream(*stream)) { delete t; diff --git a/engines/prince/saveload.cpp b/engines/prince/saveload.cpp index 39a4002b40..706079ffaf 100644 --- a/engines/prince/saveload.cpp +++ b/engines/prince/saveload.cpp @@ -480,7 +480,7 @@ bool PrinceEngine::loadGame(int slotNumber) { saveFile->read(dataBuffer, size); readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES); delete saveFile; - + // Check to see if it's a ScummVM savegame or not char buffer[kSavegameStrSize + 1]; readStream->read(buffer, kSavegameStrSize + 1); @@ -507,7 +507,7 @@ bool PrinceEngine::loadGame(int slotNumber) { // TODO //syncSpeechSettings(); - + return true; } diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index d1a0034940..deb52d7622 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -43,7 +43,7 @@ Room::Room() {} bool Room::loadRoom(byte *roomData) { int roomSize = 64; Common::MemoryReadStream roomStream(roomData, roomSize); - + _mobs = roomStream.readSint32LE(); _backAnim = roomStream.readSint32LE(); _obj = roomStream.readSint32LE(); @@ -131,7 +131,7 @@ bool Script::loadStream(Common::SeekableReadStream &stream) { _scriptInfo.invObjGive = scriptDataStream.readSint32LE(); _scriptInfo.stdGiveItem = scriptDataStream.readSint32LE(); _scriptInfo.goTester = scriptDataStream.readSint32LE(); - + return true; } @@ -427,7 +427,7 @@ int32 InterpreterFlags::getFlagValue(Flags::Id flagId) { return _flags[(uint32)flagId - kFlagMask]; } -Interpreter::Interpreter(PrinceEngine *vm, Script *script, InterpreterFlags *flags) : +Interpreter::Interpreter(PrinceEngine *vm, Script *script, InterpreterFlags *flags) : _vm(vm), _script(script), _flags(flags), _stacktop(0), _opcodeNF(false), _opcodeEnd(false), _waitFlag(0), _result(true) { @@ -479,8 +479,8 @@ uint32 Interpreter::step(uint32 opcodePC) { if (_lastOpcode >= kNumOpcodes) error( - "Trying to execute unknown opcode @0x%04X: %02d", - _currentInstruction, + "Trying to execute unknown opcode @0x%04X: %02d", + _currentInstruction, _lastOpcode); // Execute the current opcode @@ -570,7 +570,7 @@ int32 Interpreter::readScriptFlagValue() { return value; } -Flags::Id Interpreter::readScriptFlagId() { +Flags::Id Interpreter::readScriptFlagId() { return (Flags::Id)readScript16(); } @@ -1689,7 +1689,7 @@ void Interpreter::O_POPSTRING() { void Interpreter::O_SETFGCODE() { int32 offset = readScript32(); - _fgOpcodePC = _currentInstruction + offset - 4; + _fgOpcodePC = _currentInstruction + offset - 4; debugInterpreter("O_SETFGCODE next %08x, offset %08x", _fgOpcodePC, offset); } -- cgit v1.2.3 From 361f4d4717b2f719a61ca9de421907503e99f37f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:22:48 +0200 Subject: FULLPIPE: Remove trailing whitespace --- engines/fullpipe/fullpipe.cpp | 4 ++-- engines/fullpipe/gfx.cpp | 8 ++++---- engines/fullpipe/input.cpp | 2 +- engines/fullpipe/motion.cpp | 14 +++++++------- engines/fullpipe/scene.cpp | 2 +- engines/fullpipe/scenes/scene02.cpp | 2 +- engines/fullpipe/scenes/scene14.cpp | 2 +- engines/fullpipe/scenes/scene15.cpp | 2 +- engines/fullpipe/scenes/scene16.cpp | 8 ++++---- engines/fullpipe/scenes/scene23.cpp | 2 +- engines/fullpipe/scenes/scene28.cpp | 2 +- engines/fullpipe/scenes/scene29.cpp | 2 +- engines/fullpipe/scenes/scene37.cpp | 2 +- engines/fullpipe/sound.cpp | 2 +- engines/fullpipe/statics.cpp | 8 ++++---- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index bb0838395d..ebaff32550 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -163,7 +163,7 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) for (int i = 0; i < 11; i++) _currSoundList1[i] = 0; - + for (int i = 0; i < 200; i++) _mapTable[i] = 0; @@ -285,7 +285,7 @@ Common::Error FullpipeEngine::run() { freeGameLoader(); _currentScene = 0; _updateTicks = 0; - + loadGam("fullpipe.gam"); _needRestart = false; } diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 61fbf7192f..42846850ca 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -153,7 +153,7 @@ bool PictureObject::load(MfcArchive &file, bool bigPicture) { if (count > 0) { GameObject *o = new GameObject(); - + o->load(file); _pictureObject2List->push_back(o); } @@ -286,9 +286,9 @@ bool GameObject::load(MfcArchive &file) { _okeyCode = 0; _flags = 0; _field_20 = 0; - + _id = file.readUint16LE(); - + _objectName = file.readPascalString(); _ox = file.readUint32LE(); _oy = file.readUint32LE(); @@ -498,7 +498,7 @@ bool Picture::load(MfcArchive &file) { _x = file.readUint32LE(); _y = file.readUint32LE(); _field_44 = file.readUint16LE(); - + assert(g_fp->_gameProjectVersion >= 2); _width = file.readUint32LE(); diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp index 7c97461a24..b681f4fbe7 100644 --- a/engines/fullpipe/input.cpp +++ b/engines/fullpipe/input.cpp @@ -70,7 +70,7 @@ void setInputDisabled(bool state) { void InputController::addCursor(CursorInfo *cursor) { CursorInfo *newc = new CursorInfo(cursor); Common::Point p; - + cursor->picture->getDimensions(&p); newc->width = p.x; diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 49cf88434e..9573e0517b 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -1040,11 +1040,11 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int if (!mq || !mq->getExCommandByIndex(0)) return 0; - + ExCommand *ex = mq->getExCommandByIndex(0); - if ((ex->_messageKind != 1 && ex->_messageKind != 20) || - ex->_messageNum != subj->_movement->_id || + if ((ex->_messageKind != 1 && ex->_messageKind != 20) || + ex->_messageNum != subj->_movement->_id || (ex->_field_14 >= 1 && ex->_field_14 <= subj->_movement->_currDynamicPhaseIndex)) subj->playIdle(); } @@ -1416,8 +1416,8 @@ Common::Array *MovGraph::genMovArr(int x, int y, int *arrSize, int fla movarr = new MovArr; movarr->_link = lnk; - movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) + - (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) / + movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) + + (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) / lnk->_distance / lnk->_distance; movarr->_point = point; @@ -1445,8 +1445,8 @@ Common::Array *MovGraph::genMovArr(int x, int y, int *arrSize, int fla } else { movarr = new MovArr; movarr->_link = lnk; - movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) + - (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) / + movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) + + (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) / lnk->_distance / lnk->_distance; movarr->_point.x = x; movarr->_point.y = y; diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 8463b3ab40..00dd70c1b2 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -162,7 +162,7 @@ bool Scene::load(MfcArchive &file) { Background::load(file); _sceneId = file.readUint16LE(); - + _sceneName = file.readPascalString(); debug(0, "scene: <%s> %d", transCyrillic((byte *)_sceneName), _sceneId); diff --git a/engines/fullpipe/scenes/scene02.cpp b/engines/fullpipe/scenes/scene02.cpp index 109a20a07a..fd542d580d 100644 --- a/engines/fullpipe/scenes/scene02.cpp +++ b/engines/fullpipe/scenes/scene02.cpp @@ -134,5 +134,5 @@ int sceneHandler02(ExCommand *ex) { return res; } - + } // End of namespace Fullpipe diff --git a/engines/fullpipe/scenes/scene14.cpp b/engines/fullpipe/scenes/scene14.cpp index 21dbe8101f..446f477133 100644 --- a/engines/fullpipe/scenes/scene14.cpp +++ b/engines/fullpipe/scenes/scene14.cpp @@ -57,7 +57,7 @@ void scene14_initScene(Scene *sc) { ball->_flags &= 0xFFFB; g_vars->scene14_balls.push_back(ball); - + for (uint i = 0; i < 3; i++) { ball = new StaticANIObject(ball); // create a copy diff --git a/engines/fullpipe/scenes/scene15.cpp b/engines/fullpipe/scenes/scene15.cpp index 452f2edeca..efc69a5fa6 100644 --- a/engines/fullpipe/scenes/scene15.cpp +++ b/engines/fullpipe/scenes/scene15.cpp @@ -71,7 +71,7 @@ void scene15_initScene(Scene *sc) { grandma->hide(); g_fp->setObjectState(sO_LeftPipe_15, g_fp->getObjectEnumState(sO_LeftPipe_15, sO_IsOpened)); } - + g_vars->scene15_plusminus = sc->getStaticANIObject1ById(ANI_PLUSMINUS, -1); if (g_fp->getObjectState(sO_Guard_2) == g_fp->getObjectEnumState(sO_Guard_2, sO_Off)) diff --git a/engines/fullpipe/scenes/scene16.cpp b/engines/fullpipe/scenes/scene16.cpp index ed3c51a6c2..e9d3a37efd 100644 --- a/engines/fullpipe/scenes/scene16.cpp +++ b/engines/fullpipe/scenes/scene16.cpp @@ -57,9 +57,9 @@ void scene16_initScene(Scene *sc) { boy[1] = new StaticANIObject(boy[0]); sc->addStaticANIObject(boy[1], 1); - + int idx = 0; - + for (int i = 0; i < 3; i++) { g_vars->scene16_figures.push_back(boy[idx]); @@ -68,7 +68,7 @@ void scene16_initScene(Scene *sc) { if (idx >= 2) idx = 0; } - + g_vars->scene16_figures.push_back(sc->getStaticANIObject1ById(ANI_GIRL, -1)); for (int i = 0; i < 4; i++) { @@ -259,7 +259,7 @@ void sceneHandler16_drink() { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYKICK), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode); - + ex = new ExCommand(ANI_MAN, 34, 384, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 3u; ex->_field_14 = 384; diff --git a/engines/fullpipe/scenes/scene23.cpp b/engines/fullpipe/scenes/scene23.cpp index ccfbac9223..f66ea12b4b 100644 --- a/engines/fullpipe/scenes/scene23.cpp +++ b/engines/fullpipe/scenes/scene23.cpp @@ -146,7 +146,7 @@ void scene23_initScene(Scene *sc) { sc->getStaticANIObject1ById(ANI_INV_LEVERHANDLE, -1)->hide(); } - + g_fp->_currentScene = oldsc; } diff --git a/engines/fullpipe/scenes/scene28.cpp b/engines/fullpipe/scenes/scene28.cpp index c21ce05502..de5a96e70d 100644 --- a/engines/fullpipe/scenes/scene28.cpp +++ b/engines/fullpipe/scenes/scene28.cpp @@ -46,7 +46,7 @@ void scene28_initScene(Scene *sc) { g_vars->scene28_lift6inside = false; g_fp->_floaters->init(g_fp->getGameLoaderGameVar()->getSubVarByName("SC_28")); - + g_fp->initArcadeKeys("SC_28"); } diff --git a/engines/fullpipe/scenes/scene29.cpp b/engines/fullpipe/scenes/scene29.cpp index 8f82e99ad1..222a541554 100644 --- a/engines/fullpipe/scenes/scene29.cpp +++ b/engines/fullpipe/scenes/scene29.cpp @@ -840,7 +840,7 @@ void sceneHandler29_shootersEscape() { void sceneHandler29_manRideBack() { g_vars->scene29_manX -= 2; - + g_fp->_aniMan->setOXY(g_vars->scene29_manX, g_vars->scene29_manY); } diff --git a/engines/fullpipe/scenes/scene37.cpp b/engines/fullpipe/scenes/scene37.cpp index 09da01f138..324d3ac92d 100644 --- a/engines/fullpipe/scenes/scene37.cpp +++ b/engines/fullpipe/scenes/scene37.cpp @@ -91,7 +91,7 @@ void scene37_initScene(Scene *sc) { g_vars->scene37_rings.push_back(ring); g_fp->setObjectState(sO_LeftPipe_37, g_fp->getObjectEnumState(sO_LeftPipe_37, sO_IsClosed)); - + Scene *oldsc = g_fp->_currentScene; g_fp->_currentScene = sc; diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index a4ca06f489..230d6c39a9 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -62,7 +62,7 @@ bool SoundList::load(MfcArchive &file, char *fname) { } return true; - + } bool SoundList::loadFile(const char *fname, char *libname) { diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 717de84925..880c2eb0df 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -246,7 +246,7 @@ bool StaticANIObject::load(MfcArchive &file) { void StaticANIObject::setOXY(int x, int y) { _ox = x; _oy = y; - + if (_movement) _movement->setOXY(x, y); } @@ -713,7 +713,7 @@ void StaticANIObject::setSpeed(int speed) { void StaticANIObject::setAlpha(int alpha) { for (uint i = 0; i < _movements.size(); i++) _movements[i]->setAlpha(alpha); - + for (uint i = 0; i < _staticsList.size(); i++) _staticsList[i]->setAlpha(alpha); } @@ -1813,7 +1813,7 @@ void Movement::initStatics(StaticANIObject *ani) { _staticsObj2 = ani->addReverseStatics(_currMovement->_staticsObj2); _staticsObj1 = ani->addReverseStatics(_currMovement->_staticsObj1); - + _mx = _currMovement->_mx; _my = _currMovement->_my; @@ -2279,7 +2279,7 @@ bool StaticPhase::load(MfcArchive &file) { _initialCountdown = file.readUint16LE(); _field_6A = file.readUint16LE(); - + if (g_fp->_gameProjectVersion >= 12) { _exCommand = (ExCommand *)file.readClass(); -- cgit v1.2.3 From 88e5998ee5aa9123f2c9c4f9b54269fbf840172b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 28 Oct 2014 16:24:45 +0200 Subject: BBVS: Remove trailing whitespace --- engines/bbvs/bbvs.cpp | 98 +++++++++++++++++----------------- engines/bbvs/bbvs.h | 78 +++++++++++++-------------- engines/bbvs/detection.cpp | 2 +- engines/bbvs/dialogs.cpp | 8 +-- engines/bbvs/dialogs.h | 6 +-- engines/bbvs/gamemodule.cpp | 40 +++++++------- engines/bbvs/gamemodule.h | 50 ++++++++--------- engines/bbvs/graphics.cpp | 4 +- engines/bbvs/minigames/bbairguitar.cpp | 62 ++++++++++----------- engines/bbvs/minigames/bbairguitar.h | 34 ++++++------ engines/bbvs/minigames/bbant.cpp | 64 +++++++++++----------- engines/bbvs/minigames/bbant.h | 26 ++++----- engines/bbvs/minigames/bbloogie.cpp | 68 +++++++++++------------ engines/bbvs/minigames/bbloogie.h | 36 ++++++------- engines/bbvs/minigames/bbtennis.cpp | 44 +++++++-------- engines/bbvs/minigames/bbtennis.h | 22 ++++---- engines/bbvs/minigames/minigame.cpp | 6 +-- engines/bbvs/minigames/minigame.h | 14 ++--- engines/bbvs/saveload.cpp | 26 ++++----- engines/bbvs/scene.cpp | 20 +++---- engines/bbvs/spritemodule.cpp | 12 ++--- engines/bbvs/videoplayer.cpp | 4 +- engines/bbvs/walk.cpp | 24 ++++----- 23 files changed, 374 insertions(+), 374 deletions(-) diff --git a/engines/bbvs/bbvs.cpp b/engines/bbvs/bbvs.cpp index d2e13e525c..11e4b6cea7 100644 --- a/engines/bbvs/bbvs.cpp +++ b/engines/bbvs/bbvs.cpp @@ -60,7 +60,7 @@ static const BBPoint kInventorySlotPositions[] = { {135, 93}, {134, 145}, { 96, 224}, {128, 224}, {160, 224}, {192, 224}, {224, 224}, {240, 224}, {256, 224}, { 0, 0} }; - + static const BBRect kVerbRects[6] = { {-32, -2, 19, 27}, {-33, -33, 19, 27}, { 12, -2, 19, 27}, { 13, -33, 19, 27}, {-10, 8, 19, 27}, {-11, -49, 19, 27} @@ -77,7 +77,7 @@ bool WalkArea::contains(const Common::Point &pt) const { BbvsEngine::BbvsEngine(OSystem *syst, const ADGameDescription *gd) : Engine(syst), _gameDescription(gd) { - + _random = new Common::RandomSource("bbvs"); _currActionCommandIndex = -1; _buttheadObject = nullptr; @@ -148,14 +148,14 @@ Common::Error BbvsEngine::run() { _gameModule = new GameModule(); _spriteModule = new SpriteModule(); _sound = new SoundMan(); - + allocSnapshot(); memset(_easterEggInput, 0, sizeof(_easterEggInput)); - + _gameTicks = 0; _playVideoNumber = 0; _bootSaveSlot = -1; - + memset(_inventoryItemStatus, 0, sizeof(_inventoryItemStatus)); memset(_gameVars, 0, sizeof(_gameVars)); memset(_sceneVisited, 0, sizeof(_sceneVisited)); @@ -189,7 +189,7 @@ Common::Error BbvsEngine::run() { _playVideoNumber = 0; } } - + writeContinueSavegame(); freeSnapshot(); @@ -282,20 +282,20 @@ void BbvsEngine::updateGame() { inputTicks = 1; _gameTicks = _system->getMillis(); } - + if (inputTicks > 20) { inputTicks = 20; _gameTicks = _system->getMillis(); } - + if (inputTicks == 0) return; - + if (_mouseX >= 320 || _mouseY >= 240) { _mouseY = -1; _mouseX = -1; } - + bool done; do { @@ -304,14 +304,14 @@ void BbvsEngine::updateGame() { _mouseButtons &= ~kRightButtonClicked; _keyCode = Common::KEYCODE_INVALID; } while (--inputTicks && _playVideoNumber == 0 && _gameTicks > 0 && !done); - + if (!done && _playVideoNumber == 0 && _gameTicks > 0) { DrawList drawList; buildDrawList(drawList); _screen->drawDrawList(drawList, _spriteModule); drawScreen(); } - + _system->delayMillis(10); } @@ -329,7 +329,7 @@ void BbvsEngine::updateBackgroundSounds() { _backgroundSoundsActive[i] = 0; } } -} +} bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCode keyCode) { @@ -339,7 +339,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo _bootSaveSlot = -1; return false; } - + if (_newSceneNum != 0) { _gameTicks = 0; return changeScene(); @@ -413,7 +413,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo } updateInventory(mouseButtons & kLeftButtonClicked); break; - + case kGSVerbs: _isSaveAllowed = false; updateVerbs(); @@ -426,7 +426,7 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo } } break; - + case kGSWait: case kGSWaitDialog: _isSaveAllowed = false; @@ -438,14 +438,14 @@ bool BbvsEngine::update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCo else updateCommon(); break; - + case kGSDialog: _isSaveAllowed = true; saveSnapshot(); updateDialog(mouseButtons & kLeftButtonClicked); updateCommon(); break; - + } return true; @@ -503,7 +503,7 @@ void BbvsEngine::buildDrawList(DrawList &drawList) { // Verbs background drawList.add(_gameModule->getGuiSpriteIndex(13), _verbPos.x - _cameraPos.x, _verbPos.y - _cameraPos.y, 500); - // Selected inventory item + // Selected inventory item if (_currInventoryItem >= 0) { drawList.add(_gameModule->getInventoryItemSpriteIndex(2 * _currInventoryItem), _verbPos.x - _cameraPos.x, _verbPos.y - _cameraPos.y + 27, 500); @@ -538,7 +538,7 @@ void BbvsEngine::updateVerbs() { _mouseCursorSpriteIndex = 0; return; } - + for (int i = 0; i < 6; ++i) { const BBRect &verbRect = kVerbRects[i]; const int16 x = _verbPos.x + verbRect.x; @@ -551,7 +551,7 @@ void BbvsEngine::updateVerbs() { break; } } - + switch (_currVerbNum) { case kVerbLook: case kVerbUse: @@ -585,7 +585,7 @@ void BbvsEngine::updateDialog(bool clicked) { _gameState = kGSScene; return; } - + int slotX = (_mousePos.x - _cameraPos.x) / 32; if (slotX >= _dialogSlotCount) { @@ -597,7 +597,7 @@ void BbvsEngine::updateDialog(bool clicked) { _mouseCursorSpriteIndex = _gameModule->getGuiSpriteIndex(5); _activeItemType = kITDialog; - + // Find the selected dialog item index for (int i = 0; i < 50 && slotX >= 0; ++i) { if (_dialogItemStatus[i]) { @@ -605,7 +605,7 @@ void BbvsEngine::updateDialog(bool clicked) { _activeItemIndex = i; } } - + // Select the dialog item action if it was clicked if (clicked) { for (int i = 0; i < _gameModule->getActionsCount(); ++i) { @@ -622,7 +622,7 @@ void BbvsEngine::updateDialog(bool clicked) { } void BbvsEngine::updateInventory(bool clicked) { - + Common::Rect kInvButtonRects[3] = { Common::Rect(97, 13, 97 + 20, 13 + 26), Common::Rect(135, 15, 135 + 46, 15 + 25), @@ -636,10 +636,10 @@ void BbvsEngine::updateInventory(bool clicked) { if (_currVerbNum != kVerbLook && _currVerbNum != kVerbUse && _currVerbNum != kVerbInvItem) _currVerbNum = kVerbUse; - + const int16 mx = _mousePos.x - _cameraPos.x; const int16 my = _mousePos.y - _cameraPos.y; - + // Check inventory exit left/right edge of screen if (mx < 40 || mx > 280) { _mouseCursorSpriteIndex = _gameModule->getGuiSpriteIndex(10); @@ -652,7 +652,7 @@ void BbvsEngine::updateInventory(bool clicked) { return; } - // Check hovered/clicked inventory button + // Check hovered/clicked inventory button _inventoryButtonIndex = -1; if (kInvButtonRects[0].contains(mx, my)) { _inventoryButtonIndex = 0; @@ -677,10 +677,10 @@ void BbvsEngine::updateInventory(bool clicked) { // Find hovered/clicked inventory item int currItem = -1; - + if (_currVerbNum == kVerbInvItem) currItem = _currInventoryItem; - + _activeItemType = kITEmpty; for (int i = 0; i < 50; ++i) { @@ -769,7 +769,7 @@ void BbvsEngine::updateScene(bool clicked) { } } } - + for (int i = 0; i < _gameModule->getBgObjectsCount(); ++i) { BgObject *bgObject = _gameModule->getBgObject(i); if (lastPriority <= bgObject->rect.bottom && bgObject->rect.contains(_mousePos)) { @@ -921,7 +921,7 @@ bool BbvsEngine::performActionCommand(ActionCommand *actionCommand) { return false; case kActionCmdWalkObject: - { + { SceneObject *sceneObject = &_sceneObjects[actionCommand->sceneObjectIndex]; debug(5, "[%s] walks from (%d, %d) to (%d, %d)", sceneObject->sceneObjectDef->name, sceneObject->x >> 16, sceneObject->y >> 16, actionCommand->walkDest.x, actionCommand->walkDest.y); @@ -998,14 +998,14 @@ bool BbvsEngine::performActionCommand(ActionCommand *actionCommand) { bool BbvsEngine::processCurrAction() { bool actionsFinished = false; - + if (_sceneObjectActions.size() == 0) { - + for (uint i = 0; i < _currAction->actionCommands.size(); ++i) { ActionCommand *actionCommand = &_currAction->actionCommands[i]; if (actionCommand->timeStamp != 0) break; - + if (actionCommand->cmd == kActionCmdMoveObject || actionCommand->cmd == kActionCmdAnimObject) { SceneObjectAction *sceneObjectAction = 0; // See if there's already an entry for the SceneObject @@ -1027,14 +1027,14 @@ bool BbvsEngine::processCurrAction() { sceneObjectAction->animationIndex = actionCommand->param; } } - + if (actionCommand->cmd == kActionCmdSetCameraPos) { _currCameraNum = actionCommand->param; _newCameraPos = _gameModule->getCameraInit(actionCommand->param)->cameraPos; } } - + // Delete entries for SceneObjects without anim for (uint i = 0; i < _sceneObjectActions.size();) { if (!_sceneObjects[_sceneObjectActions[i].sceneObjectIndex].anim) @@ -1107,7 +1107,7 @@ void BbvsEngine::updateCommon() { if (doActionCommands) { ActionCommand *actionCommand = &_currAction->actionCommands[_currActionCommandIndex]; - + while (actionCommand->timeStamp == _currActionCommandTimeStamp && _currActionCommandIndex < (int)_currAction->actionCommands.size()) { if (!performActionCommand(actionCommand)) { @@ -1161,7 +1161,7 @@ void BbvsEngine::updateCommon() { } updateWalkObject(sceneObject); } - + if (sceneObject->walkCount > 0 && sceneObject->turnCount == 0) { debug(5, "walk step, xIncr: %d, yIncr: %d", sceneObject->xIncr, sceneObject->yIncr); sceneObject->x += sceneObject->xIncr; @@ -1226,7 +1226,7 @@ void BbvsEngine::updateCommon() { } } } - + if (_cameraPos.x < _newCameraPos.x) ++_cameraPos.x; if (_cameraPos.x > _newCameraPos.x) @@ -1235,7 +1235,7 @@ void BbvsEngine::updateCommon() { ++_cameraPos.y; if (_cameraPos.y > _newCameraPos.y) --_cameraPos.y; - + // Check if Butthead is inside a scene exit if (_newSceneNum == 0 && !_currAction && _buttheadObject) { int16 buttheadX = _buttheadObject->x >> 16; @@ -1314,13 +1314,13 @@ void BbvsEngine::stopSounds() { bool BbvsEngine::runMinigame(int minigameNum) { debug(0, "BbvsEngine::runMinigame() minigameNum: %d", minigameNum); - + bool fromMainGame = _currSceneNum != kMainMenu; - + _sound->unloadSounds(); - + Minigame *minigame = 0; - + switch (minigameNum) { case kMinigameBbLoogie: minigame = new MinigameBbLoogie(this); @@ -1338,9 +1338,9 @@ bool BbvsEngine::runMinigame(int minigameNum) { error("Incorrect minigame number %d", minigameNum); break; } - + bool minigameResult = minigame->run(fromMainGame); - + delete minigame; // Check if the principal was hit with a megaloogie in the loogie minigame @@ -1370,11 +1370,11 @@ void BbvsEngine::checkEasterEgg(char key) { "SKCUS", "NAMTAH" }; - + static const int kEasterEggLengths[] = { 7, 5, 5, 6 }; - + if (_currSceneNum == kCredits) { memcpy(&_easterEggInput[1], &_easterEggInput[0], 6); _easterEggInput[0] = key; diff --git a/engines/bbvs/bbvs.h b/engines/bbvs/bbvs.h index 6a9a13905c..bbd8046a8b 100644 --- a/engines/bbvs/bbvs.h +++ b/engines/bbvs/bbvs.h @@ -149,7 +149,7 @@ struct BBPoint { struct BBRect { int16 x, y, width, height; -}; +}; struct BBPolygon { const BBPoint *points; @@ -229,66 +229,66 @@ public: private: const ADGameDescription *_gameDescription; Graphics::PixelFormat _pixelFormat; -public: +public: Common::RandomSource *_random; - + GameModule *_gameModule; SpriteModule *_spriteModule; SoundMan *_sound; - + Screen *_screen; - + int _bootSaveSlot; - + int _mouseX, _mouseY; uint _mouseButtons; Common::KeyCode _keyCode; - + int _mouseCursorSpriteIndex; int _gameState; int _gameTicks; - + Common::Point _mousePos; Common::Point _verbPos; Common::Point _walkMousePos; - + int _activeItemType; int _activeItemIndex; int _currTalkObjectIndex; - + Common::Point _cameraPos, _newCameraPos; - + int _newSceneNum, _prevSceneNum, _currSceneNum; int _playVideoNumber; - + int _dialogSlotCount; byte _dialogItemStatus[kDialogItemStatusCount]; - + byte _gameVars[kGameVarsCount]; byte _sceneVisited[kSceneVisitedCount]; int _currVerbNum; - + int _currInventoryItem; byte _inventoryItemStatus[kInventoryItemStatusCount]; int _inventoryButtonIndex; - + Action *_currAction; uint32 _currActionCommandTimeStamp; int _currActionCommandIndex; - + Common::Array _walkAreaActions; - + SceneObject _sceneObjects[kSceneObjectsCount]; Common::Array _sceneObjectActions; - + SceneObject *_buttheadObject, *_beavisObject; int _currCameraNum; - + byte _backgroundSoundsActive[kSceneSoundsCount]; Audio::SoundHandle _speechSoundHandle; - + int _walkAreasCount; WalkArea _walkAreas[80]; int _walkInfosCount; @@ -298,40 +298,40 @@ public: Common::Rect _tempWalkableRects1[256]; Common::Rect _tempWalkableRects2[256]; WalkInfo *_walkInfoPtrs[256]; - + WalkArea *_sourceWalkArea, *_destWalkArea; Common::Point _sourceWalkAreaPt, _destWalkAreaPt, _finalWalkPt; int _currWalkDistance; bool _walkReachedDestArea; - + bool _hasSnapshot; byte *_snapshot; Common::SeekableMemoryWriteStream *_snapshotStream; - + char _easterEggInput[7]; - + void updateEvents(); int getRandom(int max); void drawDebugInfo(); void drawScreen(); - + void updateGame(); bool evalCondition(Conditions &conditions); bool evalCameraCondition(Conditions &conditions, int value); int evalDialogCondition(Conditions &conditions); void evalActionResults(ActionResults &results); - + void updateBackgroundSounds(); void loadScene(int sceneNum); void initScene(bool sounds); - bool changeScene(); + bool changeScene(); bool update(int mouseX, int mouseY, uint mouseButtons, Common::KeyCode keyCode); - + void buildDrawList(DrawList &drawList); - + void updateVerbs(); void updateDialog(bool clicked); void updateInventory(bool clicked); @@ -342,7 +342,7 @@ public: void skipCurrAction(); void updateCommon(); - + void updateWalkableRects(); void startWalkObject(SceneObject *sceneObject); void updateWalkObject(SceneObject *sceneObject); @@ -360,20 +360,20 @@ public: void walkFindPath(WalkArea *sourceWalkArea, int infoCount); int calcDistance(const Common::Point &pt1, const Common::Point &pt2); void walkFoundPath(int count); - + void updateSceneObjectsTurnValue(); void updateDialogConditions(); - - void playSpeech(int soundNum); + + void playSpeech(int soundNum); void stopSpeech(); - + void playSound(uint soundNum, bool loop = false); void stopSound(uint soundNum); void stopSounds(); - + bool runMinigame(int minigameNum); void playVideo(int videoNum); - + void runMainMenu(); void checkEasterEgg(char key); @@ -409,13 +409,13 @@ public: bool existsSavegame(int num); static Common::String getSavegameFilename(const Common::String &target, int num); static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header); - + void allocSnapshot(); void freeSnapshot(); void saveSnapshot(); - + void writeContinueSavegame(); - + }; } // End of namespace Bbvs diff --git a/engines/bbvs/detection.cpp b/engines/bbvs/detection.cpp index e7383163f5..3e247aad99 100644 --- a/engines/bbvs/detection.cpp +++ b/engines/bbvs/detection.cpp @@ -133,7 +133,7 @@ SaveStateDescriptor BbvsMetaEngine::querySaveMetaInfos(const char *target, int s Bbvs::BbvsEngine::kReadSaveHeaderError error; error = Bbvs::BbvsEngine::readSaveHeader(in, true, header); delete in; - if (error == Bbvs::BbvsEngine::kRSHENoError) { + if (error == Bbvs::BbvsEngine::kRSHENoError) { SaveStateDescriptor desc(slot, header.description); // Slot 0 is used for the "Continue" save desc.setDeletableFlag(slot != 0); diff --git a/engines/bbvs/dialogs.cpp b/engines/bbvs/dialogs.cpp index 5247a58ec8..af95f06c1e 100644 --- a/engines/bbvs/dialogs.cpp +++ b/engines/bbvs/dialogs.cpp @@ -34,7 +34,7 @@ struct MenuButton { static const MenuButton kMenuButtons[] = { // Main menu - {"New Game", kCmdNewGame}, + {"New Game", kCmdNewGame}, {"Continue", kCmdContinue}, {"Options", kCmdOptions}, {"Mini Games", kCmdMiniGames}, @@ -61,7 +61,7 @@ MainMenu::~MainMenu() { } void MainMenu::init() { - _buttons[0] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0); + _buttons[0] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0); _buttons[1] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0); _buttons[2] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0); _buttons[3] = new GUI::ButtonWidget(this, 0, 0, 1, 1, "", 0, 0); @@ -76,14 +76,14 @@ void MainMenu::reflowLayout() { const int buttonWidth = screenW * 70 / 320; const int buttonHeight = screenH * 14 / 240; const int buttonPadding = screenW * 3 / 320; - + _w = 2 * buttonWidth + buttonPadding; _h = 3 * buttonHeight + 3 * buttonPadding; _x = (screenW - _w) / 2; _y = screenH - _h; int x = 0, y = 0; - + x = 0; y = 0; _buttons[0]->resize(x, y, buttonWidth, buttonHeight); diff --git a/engines/bbvs/dialogs.h b/engines/bbvs/dialogs.h index 2dce2a110b..7db0b182b7 100644 --- a/engines/bbvs/dialogs.h +++ b/engines/bbvs/dialogs.h @@ -67,13 +67,13 @@ protected: BbvsEngine *_vm; void init(); - + GUI::ButtonWidget *_buttons[5]; - + void gotoMenuScreen(int index); bool canContinue(); void gotoScene(int sceneNum); - + }; } diff --git a/engines/bbvs/gamemodule.cpp b/engines/bbvs/gamemodule.cpp index d6343084ab..80f0e81450 100644 --- a/engines/bbvs/gamemodule.cpp +++ b/engines/bbvs/gamemodule.cpp @@ -39,11 +39,11 @@ GameModule::~GameModule() { void GameModule::load(const char *filename) { debug(0, "GameModule::load()"); - + unload(); Common::File fd; - + if (!fd.open(filename)) error("GameModule::load() Could not open %s", filename); @@ -68,7 +68,7 @@ void GameModule::load(const char *filename) { fd.seek(0x1A8); _buttheadObjectIndex = fd.readUint32LE(); - + fd.close(); debug(0, "GameModule::load() OK"); @@ -177,7 +177,7 @@ int GameModule::getBgSpritePriority(int index) { int GameModule::getSceneSoundsCount() { return _sceneSoundsCount; } - + SceneSound *GameModule::getSceneSound(int index) { assert(index < _sceneSoundsCount); return &_sceneSounds[index]; @@ -257,7 +257,7 @@ void GameModule::unload() { void GameModule::loadBgSprites(Common::SeekableReadStream &s) { debug(0, "GameModule::loadBgSprites()"); - + s.seek(0x14); _bgSpriteCount = s.readUint32LE(); uint32 bgSpriteIndicesOffs = s.readUint32LE(); @@ -275,7 +275,7 @@ void GameModule::loadBgSprites(Common::SeekableReadStream &s) { void GameModule::loadCameraInits(Common::SeekableReadStream &s) { debug(0, "GameModule::loadCameraInits()"); - + s.seek(0x20); for (int i = 0; i < kCameraInitsCount; ++i) { CameraInit &cameraInit = _cameraInits[i]; @@ -283,13 +283,13 @@ void GameModule::loadCameraInits(Common::SeekableReadStream &s) { for (int j = 0; j < 8; ++j) cameraInit.cameraLinks[j] = s.readByte(); for (int j = 0; j < 8; ++j) - cameraInit.rects[j] = readRect(s); + cameraInit.rects[j] = readRect(s); } } void GameModule::loadWalkRects(Common::SeekableReadStream &s) { debug(0, "GameModule::loadWalkRects()"); - + s.seek(0x150); _walkRectsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -301,7 +301,7 @@ void GameModule::loadWalkRects(Common::SeekableReadStream &s) { void GameModule::loadSceneExits(Common::SeekableReadStream &s) { debug(0, "GameModule::loadSceneExits()"); - + s.seek(0x158); _sceneExitsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -329,13 +329,13 @@ void GameModule::loadBgObjects(Common::SeekableReadStream &s) { void GameModule::loadAnimations(Common::SeekableReadStream &s) { debug(0, "GameModule::loadAnimations()"); - + s.seek(0x168); _animationsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); _animations = new Animation[_animationsCount]; for (int i = 0; i < _animationsCount; ++i) { - Animation &anim = _animations[i]; + Animation &anim = _animations[i]; s.seek(offs + i * 20); anim.frameCount = s.readUint32LE(); uint32 frameSpriteIndicesOffs = s.readUint32LE(); @@ -363,7 +363,7 @@ void GameModule::loadAnimations(Common::SeekableReadStream &s) { void GameModule::loadSceneObjectDefs(Common::SeekableReadStream &s) { debug(0, "GameModule::loadSceneObjectDefs()"); - + s.seek(0x170); _sceneObjectDefsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -379,7 +379,7 @@ void GameModule::loadSceneObjectDefs(Common::SeekableReadStream &s) { void GameModule::loadSceneObjectInits(Common::SeekableReadStream &s) { debug(0, "GameModule::loadSceneObjectInits()"); - + s.seek(0x178); _sceneObjectInitsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -396,7 +396,7 @@ void GameModule::loadSceneObjectInits(Common::SeekableReadStream &s) { void GameModule::loadActions(Common::SeekableReadStream &s) { debug(0, "GameModule::loadActions()"); - + s.seek(0x180); _actionsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -427,7 +427,7 @@ void GameModule::loadActions(Common::SeekableReadStream &s) { void GameModule::loadGuiSpriteIndices(Common::SeekableReadStream &s) { debug(0, "GameModule::loadGuiSpriteIndices()"); - + s.seek(0x188); uint32 offs = s.readUint32LE(); s.seek(offs); @@ -437,7 +437,7 @@ void GameModule::loadGuiSpriteIndices(Common::SeekableReadStream &s) { void GameModule::loadInventoryItemSpriteIndices(Common::SeekableReadStream &s) { debug(0, "GameModule::loadInventoryItemSpriteIndices()"); - + s.seek(0x18C); uint32 offs = s.readUint32LE(); s.seek(offs); @@ -447,7 +447,7 @@ void GameModule::loadInventoryItemSpriteIndices(Common::SeekableReadStream &s) { void GameModule::loadInventoryItemInfos(Common::SeekableReadStream &s) { debug(0, "GameModule::loadInventoryItemInfos()"); - + s.seek(0x190); uint32 offs = s.readUint32LE(); s.seek(offs); @@ -462,7 +462,7 @@ void GameModule::loadInventoryItemInfos(Common::SeekableReadStream &s) { void GameModule::loadDialogItemSpriteIndices(Common::SeekableReadStream &s) { debug(0, "GameModule::loadDialogItemSpriteIndices()"); - + s.seek(0x194); uint32 offs = s.readUint32LE(); s.seek(offs); @@ -473,7 +473,7 @@ void GameModule::loadDialogItemSpriteIndices(Common::SeekableReadStream &s) { void GameModule::loadSceneSounds(Common::SeekableReadStream &s) { debug(0, "GameModule::loadSceneSounds()"); - + s.seek(0x1A0); _sceneSoundsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); @@ -487,7 +487,7 @@ void GameModule::loadSceneSounds(Common::SeekableReadStream &s) { void GameModule::loadPreloadSounds(Common::SeekableReadStream &s) { debug(0, "GameModule::loadPreloadSounds()"); - + s.seek(0x198); _preloadSoundsCount = s.readUint32LE(); uint32 offs = s.readUint32LE(); diff --git a/engines/bbvs/gamemodule.h b/engines/bbvs/gamemodule.h index 4d4f5b90a1..b31b95dcee 100644 --- a/engines/bbvs/gamemodule.h +++ b/engines/bbvs/gamemodule.h @@ -134,29 +134,29 @@ class GameModule { public: GameModule(); ~GameModule(); - + void load(const char *filename); - + int getFieldC(); int getButtheadObjectIndex(); - + int getGuiSpriteIndex(int index); int getInventoryItemSpriteIndex(int index); int getDialogItemSpriteIndex(int index); - + int getActionsCount(); Action *getAction(int index); - + InventoryItemInfo *getInventoryItemInfo(int index); CameraInit *getCameraInit(int cameraNum); - + int getSceneExitsCount(); SceneExit *getSceneExit(int index); - + int getWalkRectsCount(); Common::Rect *getWalkRects(); - + int getSceneObjectDefsCount(); SceneObjectDef *getSceneObjectDef(int index); @@ -170,44 +170,44 @@ public: int getBgSpriteIndex(int index); int getBgSpritePriority(int index); - int getSceneSoundsCount(); + int getSceneSoundsCount(); SceneSound *getSceneSound(int index); - uint getSceneSoundIndex(uint soundNum); - + uint getSceneSoundIndex(uint soundNum); + uint getPreloadSoundsCount(); uint getPreloadSound(uint index); Animation *getAnimation(int index); - + protected: - + int _bgSpriteCount; int *_bgSpriteIndices; int16 *_bgSpritePriorities; - + CameraInit _cameraInits[kCameraInitsCount]; - + int _walkRectsCount; Common::Rect *_walkRects; - + int _sceneExitsCount; SceneExit *_sceneExits; - + int _bgObjectsCount; BgObject *_bgObjects; - + int _animationsCount; Animation *_animations; - + int _sceneObjectDefsCount; SceneObjectDef *_sceneObjectDefs; - + int _sceneObjectInitsCount; SceneObjectInit *_sceneObjectInits; int _actionsCount; Action *_actions; - + int _sceneSoundsCount; SceneSound *_sceneSounds; @@ -218,16 +218,16 @@ protected: int _inventoryItemSpriteIndices[kInventoryItemSpriteCount]; InventoryItemInfo _inventoryItemInfos[kInventoryItemCount]; int _dialogItemSpriteIndices[kDialogItemSpriteCount]; - + int _fieldC; int _buttheadObjectIndex; Common::Point readPoint(Common::SeekableReadStream &s); Common::Rect readRect(Common::SeekableReadStream &s); Conditions readConditions(Common::SeekableReadStream &s); - + void unload(); - + void loadBgSprites(Common::SeekableReadStream &s); void loadCameraInits(Common::SeekableReadStream &s); void loadWalkRects(Common::SeekableReadStream &s); @@ -243,7 +243,7 @@ protected: void loadDialogItemSpriteIndices(Common::SeekableReadStream &s); void loadSceneSounds(Common::SeekableReadStream &s); void loadPreloadSounds(Common::SeekableReadStream &s); - + }; } // End of namespace Bbvs diff --git a/engines/bbvs/graphics.cpp b/engines/bbvs/graphics.cpp index 810d910abf..43840607c8 100644 --- a/engines/bbvs/graphics.cpp +++ b/engines/bbvs/graphics.cpp @@ -104,9 +104,9 @@ void Screen::drawSprite(Sprite &sprite, int x, int y) { } if (destX + width >= _surface->w) width = _surface->w - destX; - + debug(0, "drawSprite() (%d, %d, %d, %d); skipX: %d; skipY: %d; %d", destX, destY, width, height, skipX, skipY, sprite.type); - + if (sprite.type == 1) { for (int yc = 0; yc < height; ++yc) { byte *source = sprite.getRow(skipY + yc); diff --git a/engines/bbvs/minigames/bbairguitar.cpp b/engines/bbvs/minigames/bbairguitar.cpp index f2e42313e3..1984dbb0fd 100644 --- a/engines/bbvs/minigames/bbairguitar.cpp +++ b/engines/bbvs/minigames/bbairguitar.cpp @@ -198,12 +198,12 @@ void MinigameBbAirGuitar::buildDrawList1(DrawList &drawList) { if (_trackBarX > kTrackBarMaxX) _trackBarX = kTrackBarMaxX; - + _trackBarThumbRect.top = 208; _trackBarThumbRect.bottom = 218; _trackBarThumbRect.left = _trackBarX; _trackBarThumbRect.right = _trackBarX + 6; - + drawList.add(_objects[5].anim->frameIndices[0], _trackBarX, 208, 100); if (_playerMode != 0) { @@ -228,7 +228,7 @@ void MinigameBbAirGuitar::buildDrawList1(DrawList &drawList) { drawList.add(_objects[i].anim->frameIndices[frameIndex], kPointsTbl2[i - 47].x, kPointsTbl2[i - 47].y, 254); } } - + if (_backgroundSpriteIndex > 0) drawList.add(_backgroundSpriteIndex, 0, 0, 0); @@ -394,7 +394,7 @@ void MinigameBbAirGuitar::initObjects1() { _track[0].noteNum = -1; stop(); changePatch(0); - + } bool MinigameBbAirGuitar::updateStatus(int mouseX, int mouseY, uint mouseButtons) { @@ -408,7 +408,7 @@ bool MinigameBbAirGuitar::updateStatus(int mouseX, int mouseY, uint mouseButtons } bool MinigameBbAirGuitar::updateStatus0(int mouseX, int mouseY, uint mouseButtons) { - + if (mouseButtons & kAnyButtonDown) { stopSound(1); _rockTunePlaying = false; @@ -436,14 +436,14 @@ bool MinigameBbAirGuitar::updateStatus0(int mouseX, int mouseY, uint mouseButton } } - + return true; } bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButtons) { - + int currTicks = _vm->_system->getMillis(); - + if (_playerMode == 1 && _track[_trackIndex].ticks <= currTicks - _noteStartTime) { noteOff(_track[_trackIndex].noteNum); if (_trackIndex < _trackCount && _track[++_trackIndex].noteNum != -1) @@ -481,17 +481,17 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton } else { ++_vuMeterRight2; } - + if (_resetAnims && _vm->_system->getMillis() - _noteStartTime >= 1000) resetObjs(); - + _objects[0].x = mouseX; _objects[0].y = mouseY; - + _trackBarMouseX = CLIP(mouseX, kTrackBarMinX, kTrackBarMaxX); - + bool checkClick = false; - + if (mouseButtons & kAnyButtonClicked) { checkClick = true; } else if (!(mouseButtons & kAnyButtonDown)) { @@ -506,14 +506,14 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton } } else if (!_movingTrackBar) checkClick = true; - + if (checkClick) { afterButtonReleased(); _objects[0].frameIndex = 1; - + if (ptInRect(&kRect2, mouseX, mouseY)) { - + if (_playerMode != 1 && ptInRect(&kPianoRect, mouseX, mouseY)) { for (int i = 0; i <= 12; ++i) { if (ptInPoly(&kPianoKeyAreas[i], mouseX, mouseY)) { @@ -538,7 +538,7 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton break; } } - + if (playerButtonNum >= 0) { _currButtonNum = playerButtonNum; _currPlayerButtonRect = &kPlayerButtonRects[playerButtonNum]; @@ -673,12 +673,12 @@ bool MinigameBbAirGuitar::updateStatus1(int mouseX, int mouseY, uint mouseButton } } } - + if (_buttonClickTicks + 1000 < currTicks) _buttonClickTicks = currTicks; - + int newKind = _buttonClickTicks + 500 < currTicks ? 1 : 0; - + switch (_playerMode) { case 1: @@ -770,20 +770,20 @@ bool MinigameBbAirGuitar::run(bool fromMainGame) { _gameResult = false; _gameDone = false; initObjects(); - + _spriteModule = new SpriteModule(); _spriteModule->load("bbairg/bbairg.000"); Palette palette = _spriteModule->getPalette(); _vm->_screen->setPalette(palette); - + loadSounds(); - + while (!_vm->shouldQuit() &&!_gameDone) { _vm->updateEvents(); update(); } - + _vm->_sound->unloadSounds(); delete _spriteModule; @@ -803,15 +803,15 @@ void MinigameBbAirGuitar::update() { inputTicks = 1; _gameTicks = _vm->_system->getMillis(); } - + if (_vm->_keyCode == Common::KEYCODE_ESCAPE) { _gameDone = true; return; } - + if (inputTicks == 0) return; - + bool done; do { @@ -820,9 +820,9 @@ void MinigameBbAirGuitar::update() { _vm->_mouseButtons &= ~kRightButtonClicked; _vm->_keyCode = Common::KEYCODE_INVALID; } while (--inputTicks && _gameTicks > 0 && !done); - + drawSprites(); - + _vm->_system->delayMillis(10); } @@ -1001,7 +1001,7 @@ void MinigameBbAirGuitar::calcTotalTicks1() { } void MinigameBbAirGuitar::noteOn(int noteNum) { - + if (_currNoteNum != -2) { if (noteNum == _currNoteNum) return; @@ -1087,7 +1087,7 @@ void MinigameBbAirGuitar::noteOn(int noteNum) { } void MinigameBbAirGuitar::noteOff(int noteNum) { - + if (_currNoteNum != noteNum) return; diff --git a/engines/bbvs/minigames/bbairguitar.h b/engines/bbvs/minigames/bbairguitar.h index d4fd6ec30c..40b8a50a03 100644 --- a/engines/bbvs/minigames/bbairguitar.h +++ b/engines/bbvs/minigames/bbairguitar.h @@ -32,7 +32,7 @@ public: MinigameBbAirGuitar(BbvsEngine *vm) : Minigame(vm) {}; bool run(bool fromMainGame); public: - + struct Obj { int kind; int x, y; @@ -44,24 +44,24 @@ public: int16 frameIndexAdd; int16 unk2; }; - + enum { kMaxObjectsCount = 256, kMaxTracks = 2049 }; - + struct PianoKeyInfo { int x, y; int frameIndex; }; - + struct TrackEvt { int8 noteNum; int16 ticks; }; - + Obj _objects[kMaxObjectsCount]; - + int _playerMode; bool _modified; @@ -82,24 +82,24 @@ public: int *_currFrameIndex; int _btn3KindToggle; - + const BBPolygon *_currPianoKeyArea; const Rect *_currPlayerButtonRect; - + bool _movingTrackBar; int _trackBarMouseX; int _trackBarX; Rect _trackBarThumbRect; - + int _currTrackPos, _totalTrackLength; int _ticksDelta; - + int _actionStartTrackPos, _actionTrackPos; int _actionStartTime; int _currNoteNum; int _currPatchNum; - + const ObjAnimation *getAnimation(int animIndex); bool ptInRect(const Rect *r, int x, int y); bool ptInPoly(const BBPolygon *poly, int x, int y); @@ -109,14 +109,14 @@ public: void buildDrawList1(DrawList &drawList); void drawSprites(); - + void initObjs(); Obj *getFreeObject(); - + void initObjects(); void initObjects0(); void initObjects1(); - + bool updateStatus(int mouseX, int mouseY, uint mouseButtons); bool updateStatus0(int mouseX, int mouseY, uint mouseButtons); bool updateStatus1(int mouseX, int mouseY, uint mouseButtons); @@ -124,7 +124,7 @@ public: void updateObjs(); void update(); - + void play(); void record(); void setPlayerMode3(); @@ -136,9 +136,9 @@ public: void noteOn(int noteNum); void noteOff(int noteNum); void resetObjs(); - + void loadSounds(); - void playNote(int noteNum); + void playNote(int noteNum); void stopNote(int noteNum); }; diff --git a/engines/bbvs/minigames/bbant.cpp b/engines/bbvs/minigames/bbant.cpp index 9786682ada..3678934345 100644 --- a/engines/bbvs/minigames/bbant.cpp +++ b/engines/bbvs/minigames/bbant.cpp @@ -94,7 +94,7 @@ void MinigameBbAnt::buildDrawList1(DrawList &drawList) { drawNumber(drawList, _score, 68, 16); drawList.add(getAnimation(166)->frameIndices[0], 230, 2, 2000); drawNumber(drawList, _levelTimeLeft, 280, 16); - + for (int i = 0; i < _stompCount; ++i) drawList.add(getAnimation(130)->frameIndices[0], 20 + i * 30, 230, 2000); @@ -116,7 +116,7 @@ void MinigameBbAnt::buildDrawList3(DrawList &drawList) { drawNumber(drawList, _hiScore, 208, 107); } -void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) { +void MinigameBbAnt::drawMagnifyingGlass(DrawList &drawList) { scale2x(_objects[0].x - 28, _objects[0].y - 27); drawList.clear(); drawList.add(_objects[0].anim->frameIndices[0], _objects[0].x, _objects[0].y, _objects[0].priority); @@ -358,7 +358,7 @@ bool MinigameBbAnt::updateStatus0(int mouseX, int mouseY, uint mouseButtons) { _objects[0].x = 0; if (_objects[0].y < 0) _objects[0].y = 0; - + if ((mouseButtons & kLeftButtonDown) || (mouseButtons & kRightButtonDown)) { _gameState = 1; initObjects(); @@ -447,7 +447,7 @@ bool MinigameBbAnt::updateStatus1(int mouseX, int mouseY, uint mouseButtons) { int maxKindCount = 0, objKind = 0; _stompCounter2 = _stompCounter1; - + for (int i = 0; i < 4; ++i) testTbl[i] = _vm->getRandom(_bugsChanceByKind[i] - _bugsCountByKind[i]); @@ -471,7 +471,7 @@ bool MinigameBbAnt::updateStatus1(int mouseX, int mouseY, uint mouseButtons) { if (_stompCounter1 > 20) --_stompCounter1; } - + return true; } @@ -701,7 +701,7 @@ void MinigameBbAnt::updateBugObjAnim(int objIndex) { void MinigameBbAnt::updateObjAnim2(int objIndex) { Obj *obj = &_objects[objIndex]; - + obj->animIndexIncr += _vm->getRandom(3) - 1; if (obj->animIndexIncr < 0) obj->animIndexIncr = 7; @@ -736,7 +736,7 @@ bool MinigameBbAnt::isBugOutOfScreen(int objIndex) { void MinigameBbAnt::updateObjAnim3(int objIndex) { Obj *obj = &_objects[objIndex]; - + obj->animIndexIncr += _vm->getRandom(3) - 1; if (obj->animIndexIncr < 0) obj->animIndexIncr = 7; @@ -752,7 +752,7 @@ void MinigameBbAnt::updateBugObj1(int objIndex) { Obj *obj = &_objects[objIndex]; bool flag1 = false; bool flag2 = false; - + if (--obj->ticks == 0) { ++obj->frameIndex; if (obj->anim->frameCount == obj->frameIndex) { @@ -911,7 +911,7 @@ void MinigameBbAnt::updateStompObj(int objIndex) { void MinigameBbAnt::updateSmokeObj(int objIndex) { Obj *obj = &_objects[objIndex]; - + obj->x += obj->xIncr; obj->y += obj->yIncr; @@ -1047,7 +1047,7 @@ bool MinigameBbAnt::isMagGlassAtBug(int objIndex) { Obj *obj = &_objects[objIndex]; Obj *obj0 = &_objects[0]; bool result = false; - + if (obj->kind >= 1 && obj->kind <= 5) { const BBRect &frameRect1 = obj0->anim->frameRects[0]; const int obj1X1 = obj0->x + frameRect1.x; @@ -1102,7 +1102,7 @@ bool MinigameBbAnt::testObj5(int objIndex) { } void MinigameBbAnt::updateObjs(uint mouseButtons) { - + for (int i = 12; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; @@ -1162,7 +1162,7 @@ void MinigameBbAnt::updateObjs(uint mouseButtons) { } } - + } } @@ -1170,9 +1170,9 @@ void MinigameBbAnt::updateObjs(uint mouseButtons) { bool MinigameBbAnt::run(bool fromMainGame) { memset(_objects, 0, sizeof(_objects)); - + _numbersAnim = getAnimation(167); - + _backgroundSpriteIndex = 303; _titleScreenSpriteIndex = 304; @@ -1187,23 +1187,23 @@ bool MinigameBbAnt::run(bool fromMainGame) { _gameDone = false; initObjects(); initVars(); - + _spriteModule = new SpriteModule(); _spriteModule->load("bbant/bbant.000"); Palette palette = _spriteModule->getPalette(); _vm->_screen->setPalette(palette); - + loadSounds(); _gameTicks = 0; playSound(12, true); - + while (!_vm->shouldQuit() &&!_gameDone) { _vm->updateEvents(); update(); } - + _vm->_sound->unloadSounds(); if (!_fromMainGame) @@ -1243,19 +1243,19 @@ void MinigameBbAnt::update() { _vm->_mouseButtons &= ~kRightButtonClicked; _vm->_keyCode = Common::KEYCODE_INVALID; } while (--inputTicks && _gameTicks > 0 && !done); - + drawSprites(); - + _vm->_system->delayMillis(10); } void MinigameBbAnt::scale2x(int x, int y) { - Graphics::Surface *surface = _vm->_screen->_surface; - + Graphics::Surface *surface = _vm->_screen->_surface; + int srcX = x + 14, srcY = y + 14; int srcW = kScaleDim, srcH = kScaleDim; - + if (srcX < 0) { srcW += srcX; srcX = 0; @@ -1265,21 +1265,21 @@ void MinigameBbAnt::scale2x(int x, int y) { srcH += srcY; srcY = 0; } - + if (srcX + srcW >= 320) srcW = 320 - srcX - 1; - + if (srcY + srcH >= 240) srcH = 240 - srcY - 1; - + for (int yc = 0; yc < srcH; ++yc) { byte *src = (byte*)surface->getBasePtr(srcX, srcY + yc); memcpy(&_scaleBuf[yc * kScaleDim], src, srcW); } - + int dstX = x, dstY = y; int dstW = 2 * kScaleDim, dstH = 2 * kScaleDim; - + if (dstX < 0) { dstW += dstX; dstX = 0; @@ -1289,15 +1289,15 @@ void MinigameBbAnt::scale2x(int x, int y) { dstH += dstY; dstY = 0; } - + if (dstX + dstW >= 320) dstW = 320 - dstX - 1; - + if (dstY + dstH >= 240) dstH = 240 - dstY - 1; - + int w = MIN(srcW * 2, dstW), h = MIN(srcH * 2, dstH); - + for (int yc = 0; yc < h; ++yc) { byte *src = _scaleBuf + kScaleDim * (yc / 2); byte *dst = (byte*)surface->getBasePtr(dstX, dstY + yc); diff --git a/engines/bbvs/minigames/bbant.h b/engines/bbvs/minigames/bbant.h index be2afe688d..88b4af9c71 100644 --- a/engines/bbvs/minigames/bbant.h +++ b/engines/bbvs/minigames/bbant.h @@ -32,7 +32,7 @@ public: MinigameBbAnt(BbvsEngine *vm) : Minigame(vm) {}; bool run(bool fromMainGame); public: - + struct Obj { int kind; int x, y, priority; @@ -55,21 +55,21 @@ public: int status2; int flag; }; - + enum { kMaxObjectsCount = 256, kScaleDim = 28 }; - + struct ObjInit { const ObjAnimation *anim1; const ObjAnimation *anim2; const ObjAnimation *anim3; int x, y; }; - + Obj _objects[kMaxObjectsCount]; - + int _score, _hiScore; int _totalBugsCount; @@ -96,37 +96,37 @@ public: int _countdown6; int _countdown5; int _countdown7; - + byte _scaleBuf[kScaleDim * kScaleDim]; const ObjAnimation *getAnimation(int animIndex); const ObjInit *getObjInit(int index); const ObjAnimation * const *getObjKindAnimTable(int kind); const ObjAnimation *getObjAnim(int index); - + void buildDrawList0(DrawList &drawList); void buildDrawList1(DrawList &drawList); void buildDrawList2(DrawList &drawList); void buildDrawList3(DrawList &drawList); void drawMagnifyingGlass(DrawList &drawList); - + void drawSprites(); void drawSprites0(); void drawSprites1(); void drawSprites2(); void drawSprites3(); - + Obj *getFreeObject(); - + void initObjects(); void initObjects0(); void initObjects1(); - + void initVars(); void initVars1(); void initVars2(); void initVars3(); - + bool updateStatus(int mouseX, int mouseY, uint mouseButtons); bool updateStatus0(int mouseX, int mouseY, uint mouseButtons); bool updateStatus1(int mouseX, int mouseY, uint mouseButtons); @@ -161,7 +161,7 @@ public: void updateObjs(uint mouseButtons); void update(); - + void scale2x(int x, int y); void loadSounds(); diff --git a/engines/bbvs/minigames/bbloogie.cpp b/engines/bbvs/minigames/bbloogie.cpp index 4601e9ff93..68a3147f9a 100644 --- a/engines/bbvs/minigames/bbloogie.cpp +++ b/engines/bbvs/minigames/bbloogie.cpp @@ -117,7 +117,7 @@ void MinigameBbLoogie::buildDrawList0(DrawList &drawList) { } void MinigameBbLoogie::buildDrawList1(DrawList &drawList) { - + for (int i = 0; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; switch (obj->kind) { @@ -163,7 +163,7 @@ void MinigameBbLoogie::buildDrawList1(DrawList &drawList) { } void MinigameBbLoogie::buildDrawList2(DrawList &drawList) { - + buildDrawList1(drawList); if (_level > 0 && (_bonusDisplayDelay1 > 0 || _bonusDisplayDelay2 > 0)) { @@ -180,7 +180,7 @@ void MinigameBbLoogie::buildDrawList2(DrawList &drawList) { } void MinigameBbLoogie::buildDrawList3(DrawList &drawList) { - + for (int i = 0; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; if (obj->kind == 2) @@ -191,7 +191,7 @@ void MinigameBbLoogie::buildDrawList3(DrawList &drawList) { if (_backgroundSpriteIndex) drawList.add(_backgroundSpriteIndex, 0, 0, 0); - + drawList.add(getAnimation(10)->frameIndices[0], 230, 2, 2000); drawNumber(drawList, _levelTimeLeft, 280, 16); @@ -201,7 +201,7 @@ void MinigameBbLoogie::buildDrawList3(DrawList &drawList) { int numberX2 = drawNumber(drawList, _currScore, 68, 16); drawList.add(getAnimation(9)->frameIndices[10], numberX2, 16, 2000); drawNumber(drawList, _dispLevelScore, numberX2 + 10, 16); - + drawList.add(getAnimation(20)->frameIndices[0], 120, 70, 2000); drawList.add(getAnimation(13)->frameIndices[0], 95, 95, 2000); @@ -416,7 +416,7 @@ bool MinigameBbLoogie::updateStatus(int mouseX, int mouseY, uint mouseButtons) { } bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons) { - + _objects[0].x = mouseX; _objects[0].y = mouseY; @@ -445,7 +445,7 @@ bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons) _objects[4].kind = 0; _objects[2].kind = 1; } - + for (int i = 0; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; if (obj->kind == 11) { @@ -487,12 +487,12 @@ bool MinigameBbLoogie::updateStatus0(int mouseX, int mouseY, uint mouseButtons) initVars(); _gameTicks = 0; } - + return true; } bool MinigameBbLoogie::updateStatus1(int mouseX, int mouseY, uint mouseButtons) { - + if (--_levelTimeDelay == 0) { _levelTimeDelay = 58; --_levelTimeLeft; @@ -568,9 +568,9 @@ bool MinigameBbLoogie::updateStatus2(int mouseX, int mouseY, uint mouseButtons) } bool MinigameBbLoogie::updateStatus3(int mouseX, int mouseY, uint mouseButtons) { - + _objects[0].x = mouseX; - + for (int i = 0; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; if (obj->kind == 2) { @@ -582,7 +582,7 @@ bool MinigameBbLoogie::updateStatus3(int mouseX, int mouseY, uint mouseButtons) } } } - + return true; } @@ -620,7 +620,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { break; } } - + if (--_carDelay == 0) { // Car Obj *obj = getFreeObject(); @@ -633,7 +633,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { obj->yIncr = 0; _carDelay = _vm->getRandom(256) + 800; } - + if (--_bikeDelay == 0) { // Bike Obj *obj = getFreeObject(); @@ -646,7 +646,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { obj->yIncr = 0; _bikeDelay = _vm->getRandom(512) + 500; } - + if (--_squirrelDelay == 0) { // Squirrel Obj *obj = getFreeObject(); @@ -662,7 +662,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { playSound(9); _squirrelDelay = _vm->getRandom(512) + 300; } - + if (--_paperPlaneDelay == 0) { // Paper plane Obj *obj = getFreeObject(); @@ -685,7 +685,7 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { } _paperPlaneDelay = 400; } - + if (_principalDelay >= 0 && --_principalDelay == 0) { // Principal Obj *obj = getFreeObject(); @@ -703,13 +703,13 @@ void MinigameBbLoogie::updateObjs(uint mouseButtons) { _principalFirstFrameIndex = 11; _principalLastFrameIndex = 16; } - + } void MinigameBbLoogie::updatePlayer(int objIndex, uint mouseButtons) { Obj *obj = &_objects[0]; - + switch (obj->status) { case 1: @@ -817,7 +817,7 @@ void MinigameBbLoogie::updateLoogie(int objIndex) { obj->y -= kLoogieOffY[obj->unk2 / 8]; --obj->unk2; } - + if (obj->ticks-- == 0) { obj->ticks = getAnimation(5)->frameTicks[0]; ++obj->frameIndex; @@ -832,9 +832,9 @@ void MinigameBbLoogie::updateLoogie(int objIndex) { void MinigameBbLoogie::updateCar(int objIndex) { Obj *obj = &_objects[objIndex]; - + obj->x += obj->xIncr; - + if (obj->ticks-- == 0) { if (obj->frameIndex++ == 3 || obj->frameIndex == 6) obj->frameIndex = 0; @@ -867,7 +867,7 @@ void MinigameBbLoogie::updateCar(int objIndex) { void MinigameBbLoogie::updateBike(int objIndex) { Obj *obj = &_objects[objIndex]; - + obj->x += obj->xIncr; if (obj->ticks-- == 0) { @@ -965,7 +965,7 @@ void MinigameBbLoogie::updatePaperPlane(int objIndex) { loogieObj = findLoogieObj(loogieObjIndex++); } } - + } void MinigameBbLoogie::updateIndicator(int objIndex) { @@ -995,7 +995,7 @@ void MinigameBbLoogie::updateIndicator(int objIndex) { obj->kind = 0; obj->anim = getAnimation(6); } - + } void MinigameBbLoogie::updatePrincipal(int objIndex) { @@ -1281,22 +1281,22 @@ bool MinigameBbLoogie::run(bool fromMainGame) { _gameDone = false; initObjects(); initVars(); - + _spriteModule = new SpriteModule(); _spriteModule->load("bbloogie/bbloogie.000"); Palette palette = _spriteModule->getPalette(); _vm->_screen->setPalette(palette); - + loadSounds(); playSound(32, true); - + while (!_vm->shouldQuit() &&!_gameDone) { _vm->updateEvents(); update(); } - + _vm->_sound->unloadSounds(); if (!_fromMainGame) @@ -1319,15 +1319,15 @@ void MinigameBbLoogie::update() { inputTicks = 1; _gameTicks = _vm->_system->getMillis(); } - + if (_vm->_keyCode == Common::KEYCODE_ESCAPE) { _gameDone = true; return; } - + if (inputTicks == 0) return; - + bool done; do { @@ -1336,9 +1336,9 @@ void MinigameBbLoogie::update() { _vm->_mouseButtons &= ~kRightButtonClicked; _vm->_keyCode = Common::KEYCODE_INVALID; } while (--inputTicks && _gameTicks > 0 && !done); - + drawSprites(); - + _vm->_system->delayMillis(10); } diff --git a/engines/bbvs/minigames/bbloogie.h b/engines/bbvs/minigames/bbloogie.h index 1dd4049b41..04ead51a1e 100644 --- a/engines/bbvs/minigames/bbloogie.h +++ b/engines/bbvs/minigames/bbloogie.h @@ -32,7 +32,7 @@ public: MinigameBbLoogie(BbvsEngine *vm) : Minigame(vm) {}; bool run(bool fromMainGame); public: - + struct Obj { int kind; int x, y; @@ -44,33 +44,33 @@ public: int16 frameIndexAdd; int16 unk2; }; - + enum { kMaxObjectsCount = 256 }; - + enum { kGSTitleScreen = 0, // Title screen kGSMainGame = 1, // Game when called as part of the main game kGSStandaloneGame = 2, // Game when called as standalone game kGSScoreCountUp = 3 // Score countup and next level text }; - + Obj _objects[kMaxObjectsCount]; - + int _playerKind; const ObjAnimation *_playerAnim; const uint *_playerSounds1, *_playerSounds2; uint _playerSounds1Count, _playerSounds2Count; - + int _level, _levelTimeLeft, _levelTimeDelay; - int _numberOfHits, _currScore, _hiScore; + int _numberOfHits, _currScore, _hiScore; int _doubleScore, _megaLoogieCount; - + int _dispLevelScore, _nextLevelScore; int _timeBonusCtr, _bonusDisplayDelay1, _bonusDisplayDelay2, _bonusDisplayDelay3; - + int _carDelay; int _bikeDelay; int _squirrelDelay; @@ -78,37 +78,37 @@ public: int _paperPlaneDelay; int _principalDelay; - int _prevPrincipalStatus; + int _prevPrincipalStatus; int _principalCtr, _principalFirstFrameIndex, _principalLastFrameIndex; bool _principalAngry; - + const ObjAnimation *getAnimation(int animIndex); - + void buildDrawList(DrawList &drawList); void buildDrawList0(DrawList &drawList); void buildDrawList1(DrawList &drawList); void buildDrawList2(DrawList &drawList); void buildDrawList3(DrawList &drawList); - + void drawSprites(); - + void initObjs(); Obj *getFreeObject(); Obj *findLoogieObj(int startObjIndex); bool isHit(Obj *obj1, Obj *obj2); bool isCursorAtObj(int objIndex); - + void initObjects(); void initObjects0(); void initObjects1(); void initObjects3(); - + void initVars(); void initVars0(); void initVars1(); void initVars2(); void initVars3(); - + bool updateStatus(int mouseX, int mouseY, uint mouseButtons); bool updateStatus0(int mouseX, int mouseY, uint mouseButtons); bool updateStatus1(int mouseX, int mouseY, uint mouseButtons); @@ -129,7 +129,7 @@ public: void incNumberOfHits(); void incScore(int incrAmount); void playRndSound(); - + void update(); void loadSounds(); diff --git a/engines/bbvs/minigames/bbtennis.cpp b/engines/bbvs/minigames/bbtennis.cpp index ddd5cfc804..7763548330 100644 --- a/engines/bbvs/minigames/bbtennis.cpp +++ b/engines/bbvs/minigames/bbtennis.cpp @@ -86,7 +86,7 @@ void MinigameBbTennis::buildDrawList(DrawList &drawList) { } void MinigameBbTennis::buildDrawList0(DrawList &drawList) { - + drawList.add(_objects[0].anim->frameIndices[_objects[0].frameIndex], _objects[0].x, _objects[0].y, 2000); for (int i = 0; i < kMaxObjectsCount; ++i) { @@ -154,7 +154,7 @@ void MinigameBbTennis::buildDrawList1(DrawList &drawList) { break; } - + drawList.add(index, x, y, priority); } @@ -174,16 +174,16 @@ void MinigameBbTennis::buildDrawList1(DrawList &drawList) { drawList.add(getAnimation(9)->frameIndices[0], 256, 52, 500); drawList.add(getAnimation(10)->frameIndices[0], 60, 162, 500); drawList.add(getAnimation(21)->frameIndices[0], 36, 18, 2000); - + drawNumber(drawList, _score, 70, 18); - + for (int i = 0; i < _numHearts; ++i) drawList.add(getAnimation(7)->frameIndices[0], 20 + i * 20, 236, 990); } void MinigameBbTennis::buildDrawList2(DrawList &drawList) { - + for (int i = 0; i < kMaxObjectsCount; ++i) { Obj *obj = &_objects[i]; if (obj->kind) @@ -384,7 +384,7 @@ bool MinigameBbTennis::updateStatus1(int mouseX, int mouseY, uint mouseButtons) _objects[0].x = mouseX; _objects[0].y = mouseY; - + if (_allHeartsGone) { _gameState = 2; initObjects(); @@ -427,13 +427,13 @@ bool MinigameBbTennis::updateStatus1(int mouseX, int mouseY, uint mouseButtons) if (_newBallTimer > 0) --_newBallTimer; - + if (++_delayDecreaseTimer == 30) { _delayDecreaseTimer = 0; if (_playerDecrease < 199) ++_playerDecrease; } - + updateObjs(); if (!_playedThisIsTheCoolest && _score > 3 && _vm->getRandom(10) == 1 && !isAnySoundPlaying(kAllSounds, 11)) { @@ -482,7 +482,7 @@ void MinigameBbTennis::updateObjs() { break; } } - + if (_rapidFireBallsCount == 0) { --_squirrelDelay; if (--_squirrelDelay == 0) { @@ -763,7 +763,7 @@ void MinigameBbTennis::updateTennisPlayer(int objIndex) { } ++_tennisPlayerDelay; break; - + case 2: if (--obj->ticks == 0) { ++obj->frameIndex; @@ -1077,7 +1077,7 @@ void MinigameBbTennis::updateNetPlayer(int objIndex) { void MinigameBbTennis::updateEnemyTennisBall(int objIndex) { Obj *obj = &_objects[objIndex]; - + if (--obj->ticks == 0) { --obj->frameIndex; obj->ticks = getAnimation(6)->frameTicks[obj->frameIndex]; @@ -1103,7 +1103,7 @@ void MinigameBbTennis::updateEnemyTennisBall(int objIndex) { obj->x = (int)obj->fltX; obj->fltY = obj->fltY - obj->fltStepY; obj->y = (int)obj->fltY; - + } void MinigameBbTennis::makeEnemyBall(int x, int y, int frameIndex) { @@ -1184,7 +1184,7 @@ void MinigameBbTennis::hitSomething() { bool MinigameBbTennis::run(bool fromMainGame) { memset(_objects, 0, sizeof(_objects)); - + _numbersAnim = getAnimation(20); _backgroundSpriteIndex = 272; @@ -1201,23 +1201,23 @@ bool MinigameBbTennis::run(bool fromMainGame) { _gameDone = false; initObjects(); initVars(); - + _spriteModule = new SpriteModule(); _spriteModule->load("bbtennis/bbtennis.000"); Palette palette = _spriteModule->getPalette(); _vm->_screen->setPalette(palette); - + loadSounds(); _gameTicks = 0; playSound(29, true); - + while (!_vm->shouldQuit() &&!_gameDone) { _vm->updateEvents(); update(); } - + _vm->_sound->unloadSounds(); if (!_fromMainGame) @@ -1240,15 +1240,15 @@ void MinigameBbTennis::update() { inputTicks = 1; _gameTicks = _vm->_system->getMillis(); } - + if (_vm->_keyCode == Common::KEYCODE_ESCAPE) { _gameDone = true; return; } - + if (inputTicks == 0) return; - + bool done; do { @@ -1257,9 +1257,9 @@ void MinigameBbTennis::update() { _vm->_mouseButtons &= ~kRightButtonClicked; _vm->_keyCode = Common::KEYCODE_INVALID; } while (--inputTicks && _gameTicks > 0 && !done); - + drawSprites(); - + _vm->_system->delayMillis(10); } diff --git a/engines/bbvs/minigames/bbtennis.h b/engines/bbvs/minigames/bbtennis.h index 690bd724a0..7eac904c4d 100644 --- a/engines/bbvs/minigames/bbtennis.h +++ b/engines/bbvs/minigames/bbtennis.h @@ -32,7 +32,7 @@ public: MinigameBbTennis(BbvsEngine *vm) : Minigame(vm) {}; bool run(bool fromMainGame); public: - + struct Obj { int kind; int x, y; @@ -51,20 +51,20 @@ public: int ballStepCtr; int netPlayDirection; }; - + enum { kMaxObjectsCount = 256 }; - + enum { kGSTitleScreen = 0, // Title screen kGSMainGame = 1, // Game when called as part of the main game kGSStandaloneGame = 2, // Game when called as standalone game kGSScoreCountUp = 3 // Score countup and next level text }; - + Obj _objects[kMaxObjectsCount]; - + int _numHearts; int _squirrelDelay; int _tennisPlayerDelay; @@ -85,29 +85,29 @@ public: bool _endSoundPlaying; const ObjAnimation *getAnimation(int animIndex); - + void buildDrawList(DrawList &drawList); void buildDrawList0(DrawList &drawList); void buildDrawList1(DrawList &drawList); void buildDrawList2(DrawList &drawList); - + void drawSprites(); - + void initObjs(); Obj *getFreeObject(); Obj *findTennisBall(int startObjIndex); bool isHit(Obj *obj1, Obj *obj2); - + void initObjects(); void initObjects0(); void initObjects1(); void initObjects2(); - + void initVars(); void initVars0(); void initVars1(); void initVars2(); - + bool updateStatus(int mouseX, int mouseY, uint mouseButtons); bool updateStatus0(int mouseX, int mouseY, uint mouseButtons); bool updateStatus1(int mouseX, int mouseY, uint mouseButtons); diff --git a/engines/bbvs/minigames/minigame.cpp b/engines/bbvs/minigames/minigame.cpp index aae18072d9..58d98a9df8 100644 --- a/engines/bbvs/minigames/minigame.cpp +++ b/engines/bbvs/minigames/minigame.cpp @@ -44,13 +44,13 @@ Minigame::~Minigame() { int Minigame::drawNumber(DrawList &drawList, int number, int x, int y) { int digits = 1, rightX = x; - + for (int mag = 10; number / mag != 0; mag *= 10) ++digits; - + rightX = x + digits * 10; x = rightX; - + while (digits--) { const int n = number % 10; x -= 10; diff --git a/engines/bbvs/minigames/minigame.h b/engines/bbvs/minigames/minigame.h index 675dec360d..1c24110519 100644 --- a/engines/bbvs/minigames/minigame.h +++ b/engines/bbvs/minigames/minigame.h @@ -51,30 +51,30 @@ public: virtual ~Minigame(); virtual bool run(bool fromMainGame) = 0; protected: - BbvsEngine *_vm; + BbvsEngine *_vm; SpriteModule *_spriteModule; - + int _gameState; int _gameTicks; bool _gameResult; bool _gameDone; bool _fromMainGame; int _hiScoreTable[kMinigameCount]; - + int _backgroundSpriteIndex, _titleScreenSpriteIndex; - + const ObjAnimation *_numbersAnim; - + int drawNumber(DrawList &drawList, int number, int x, int y); void playSound(uint index, bool loop = false); void stopSound(uint index); bool isSoundPlaying(uint index); bool isAnySoundPlaying(const uint *indices, uint count); - + void saveHiscore(int minigameNum, int score); int loadHiscore(int minigameNum); - + }; } // End of namespace Bbvs diff --git a/engines/bbvs/saveload.cpp b/engines/bbvs/saveload.cpp index ff53cc457b..e7725713fd 100644 --- a/engines/bbvs/saveload.cpp +++ b/engines/bbvs/saveload.cpp @@ -73,7 +73,7 @@ void BbvsEngine::savegame(const char *filename, const char *description) { byte descriptionLen = strlen(description); out->writeByte(descriptionLen); out->write(description, descriptionLen); - + Graphics::saveThumbnail(*out); // Not used yet, reserved for future usage @@ -86,7 +86,7 @@ void BbvsEngine::savegame(const char *filename, const char *description) { out->writeUint32LE(saveTime); out->writeUint32LE(playTime); // Header end - + out->write(_snapshot, _snapshotStream->pos()); out->finalize(); @@ -103,15 +103,15 @@ void BbvsEngine::loadgame(const char *filename) { SaveHeader header; kReadSaveHeaderError errorCode = readSaveHeader(in, false, header); - + if (errorCode != kRSHENoError) { warning("Error loading savegame '%s'", filename); delete in; return; } - + g_engine->setTotalPlayTime(header.playTime * 1000); - + memset(_sceneObjects, 0, sizeof(_sceneObjects)); for (int i = 0; i < kSceneObjectsCount; ++i) { _sceneObjects[i].walkDestPt.x = -1; @@ -120,7 +120,7 @@ void BbvsEngine::loadgame(const char *filename) { _currSceneNum = 0; _newSceneNum = in->readUint32LE(); - + initScene(false); _prevSceneNum = in->readUint32LE(); @@ -157,16 +157,16 @@ void BbvsEngine::loadgame(const char *filename) { obj->frameIndex = in->readUint32LE(); obj->frameTicks = in->readUint32LE(); obj->walkCount = in->readUint32LE(); - obj->xIncr = in->readUint32LE(); + obj->xIncr = in->readUint32LE(); obj->yIncr = in->readUint32LE(); - obj->turnValue = in->readUint32LE(); - obj->turnCount = in->readUint32LE(); + obj->turnValue = in->readUint32LE(); + obj->turnCount = in->readUint32LE(); obj->turnTicks = in->readUint32LE(); obj->walkDestPt.x = in->readUint16LE(); obj->walkDestPt.y = in->readUint16LE(); obj->anim = obj->animIndex > 0 ? _gameModule->getAnimation(obj->animIndex) : 0; } - + updateWalkableRects(); // Restart scene background sounds @@ -259,10 +259,10 @@ void BbvsEngine::saveSnapshot() { _snapshotStream->writeUint32LE(obj->frameIndex); _snapshotStream->writeUint32LE(obj->frameTicks); _snapshotStream->writeUint32LE(obj->walkCount); - _snapshotStream->writeUint32LE(obj->xIncr); + _snapshotStream->writeUint32LE(obj->xIncr); _snapshotStream->writeUint32LE(obj->yIncr); - _snapshotStream->writeUint32LE(obj->turnValue); - _snapshotStream->writeUint32LE(obj->turnCount); + _snapshotStream->writeUint32LE(obj->turnValue); + _snapshotStream->writeUint32LE(obj->turnCount); _snapshotStream->writeUint32LE(obj->turnTicks); _snapshotStream->writeUint16LE(obj->walkDestPt.x); _snapshotStream->writeUint16LE(obj->walkDestPt.y); diff --git a/engines/bbvs/scene.cpp b/engines/bbvs/scene.cpp index 0d86eb4dbc..a89c88fd82 100644 --- a/engines/bbvs/scene.cpp +++ b/engines/bbvs/scene.cpp @@ -34,7 +34,7 @@ static const int kAfterVideoSceneNum[] = { void BbvsEngine::loadScene(int sceneNum) { debug(0, "BbvsEngine::loadScene() sceneNum: %d", sceneNum); - + Common::String sprFilename = Common::String::format("vnm/vspr%04d.vnm", sceneNum); Common::String gamFilename = Common::String::format("vnm/game%04d.vnm", sceneNum); @@ -42,7 +42,7 @@ void BbvsEngine::loadScene(int sceneNum) { _spriteModule->load(sprFilename.c_str()); _gameModule->load(gamFilename.c_str()); - + Palette palette = _spriteModule->getPalette(); _screen->setPalette(palette); @@ -106,10 +106,10 @@ void BbvsEngine::initScene(bool sounds) { loadScene(_newSceneNum); _currSceneNum = _newSceneNum; _newSceneNum = 0; - + for (int i = 0; i < _gameModule->getSceneObjectDefsCount(); ++i) _sceneObjects[i].sceneObjectDef = _gameModule->getSceneObjectDef(i); - + for (int i = 0; i < _gameModule->getSceneObjectInitsCount(); ++i) { SceneObjectInit *soInit = _gameModule->getSceneObjectInit(i); if (evalCondition(soInit->conditions)) { @@ -149,10 +149,10 @@ void BbvsEngine::initScene(bool sounds) { } } } - + _cameraPos = _gameModule->getCameraInit(_currCameraNum)->cameraPos; _newCameraPos = _cameraPos; - + _walkAreaActions.clear(); for (int i = 0; i < _gameModule->getActionsCount(); ++i) { Action *action = _gameModule->getAction(i); @@ -165,7 +165,7 @@ void BbvsEngine::initScene(bool sounds) { _activeItemIndex = 0; _activeItemType = kITEmpty; - + for (int i = 0; i < _gameModule->getActionsCount(); ++i) { Action *action = _gameModule->getAction(i); if (evalCondition(action->conditions)) { @@ -183,7 +183,7 @@ void BbvsEngine::initScene(bool sounds) { break; } } - + if (sounds) updateBackgroundSounds(); @@ -192,7 +192,7 @@ void BbvsEngine::initScene(bool sounds) { bool BbvsEngine::changeScene() { writeContinueSavegame(); - + if (_newSceneNum >= 27 && _newSceneNum <= 30) { // Run minigames stopSpeech(); @@ -221,7 +221,7 @@ bool BbvsEngine::changeScene() { } return true; - + } } // End of namespace Bbvs diff --git a/engines/bbvs/spritemodule.cpp b/engines/bbvs/spritemodule.cpp index 8eae7f9a6a..f8b0d9afd5 100644 --- a/engines/bbvs/spritemodule.cpp +++ b/engines/bbvs/spritemodule.cpp @@ -41,15 +41,15 @@ SpriteModule::~SpriteModule() { void SpriteModule::load(const char *filename) { unload(); - + Common::File fd; if (!fd.open(filename)) error("SpriteModule::load() Could not open %s", filename); - + fd.readUint32LE(); // Skip magic fd.readUint32LE(); // Skip unused fd.readUint32LE(); // Skip filesize - + _paletteOffs = fd.readUint32LE(); fd.readUint32LE(); // Skip unused flagsTbl1Ofs fd.readUint32LE(); // Skip unused flagsTbl2Ofs @@ -57,18 +57,18 @@ void SpriteModule::load(const char *filename) { _paletteStart = fd.readUint32LE(); _paletteCount = fd.readUint32LE(); _spritesCount = fd.readUint32LE(); - + debug(0, "_paletteOffs: %08X", _paletteOffs); debug(0, "_spriteTblOffs: %08X", _spriteTblOffs); debug(0, "_paletteStart: %d", _paletteStart); debug(0, "_paletteCount: %d", _paletteCount); debug(0, "_spritesCount: %d", _spritesCount); - + _spriteDataSize = fd.size(); _spriteData = new byte[_spriteDataSize]; fd.seek(0); fd.read(_spriteData, _spriteDataSize); - + // Convert palette byte *palette = _spriteData + _paletteOffs; for (int i = 0; i < _paletteCount; ++i) { diff --git a/engines/bbvs/videoplayer.cpp b/engines/bbvs/videoplayer.cpp index fda9372ade..9ea73ad10b 100644 --- a/engines/bbvs/videoplayer.cpp +++ b/engines/bbvs/videoplayer.cpp @@ -42,7 +42,7 @@ void BbvsEngine::playVideo(int videoNum) { warning("Couldn't switch to a RGB color video mode to play a video."); return; } - + Video::VideoDecoder *videoDecoder = new Video::AVIDecoder(); if (!videoDecoder->loadFile(videoFilename)) { delete videoDecoder; @@ -74,7 +74,7 @@ void BbvsEngine::playVideo(int videoNum) { } delete videoDecoder; - + initGraphics(320, 240, false); } diff --git a/engines/bbvs/walk.cpp b/engines/bbvs/walk.cpp index 077110b867..5ef14101a0 100644 --- a/engines/bbvs/walk.cpp +++ b/engines/bbvs/walk.cpp @@ -46,7 +46,7 @@ static const int8 kWalkAnimTbl[32] = { void BbvsEngine::startWalkObject(SceneObject *sceneObject) { if (_buttheadObject != sceneObject && _beavisObject != sceneObject) return; - + initWalkAreas(sceneObject); _sourceWalkAreaPt.x = sceneObject->x >> 16; _sourceWalkAreaPt.y = sceneObject->y >> 16; @@ -60,7 +60,7 @@ void BbvsEngine::startWalkObject(SceneObject *sceneObject) { _destWalkArea = getWalkAreaAtPos(_destWalkAreaPt); if (!_destWalkArea) return; - + if (_sourceWalkArea != _destWalkArea) { _currWalkDistance = kMaxDistance; walkFindPath(_sourceWalkArea, 0); @@ -68,12 +68,12 @@ void BbvsEngine::startWalkObject(SceneObject *sceneObject) { } walkObject(sceneObject, _destWalkAreaPt, sceneObject->sceneObjectDef->walkSpeed); - + } void BbvsEngine::updateWalkObject(SceneObject *sceneObject) { int animIndex; - + if (sceneObject->walkCount > 0 && (sceneObject->xIncr != 0 || sceneObject->yIncr != 0)) { if (ABS(sceneObject->xIncr) <= ABS(sceneObject->yIncr)) sceneObject->turnValue = sceneObject->yIncr >= 0 ? 0 : 4; @@ -89,7 +89,7 @@ void BbvsEngine::updateWalkObject(SceneObject *sceneObject) { Animation *anim = 0; if (animIndex > 0) anim = _gameModule->getAnimation(animIndex); - + if (sceneObject->anim != anim) { if (anim) { sceneObject->anim = anim; @@ -305,12 +305,12 @@ bool BbvsEngine::canButtheadWalkToDest(const Common::Point &destPt) { } void BbvsEngine::canWalkToDest(WalkArea *walkArea, int infoCount) { - + if (_destWalkArea == walkArea) { _walkReachedDestArea = true; return; } - + if (_gameModule->getFieldC() <= 320 || infoCount <= 20) { walkArea->checked = true; for (int linkIndex = 0; linkIndex < walkArea->linksCount; ++linkIndex) { @@ -364,10 +364,10 @@ int BbvsEngine::calcDistance(const Common::Point &pt1, const Common::Point &pt2) void BbvsEngine::walkFoundPath(int count) { debug(5, "BbvsEngine::walkFoundPath(%d)", count); - + Common::Point midPt = _sourceWalkAreaPt; int totalMidPtDistance = 0; - + if (count > 0) { Common::Point lastMidPt; int halfCount = (count + 1) >> 1; @@ -384,13 +384,13 @@ void BbvsEngine::walkFoundPath(int count) { if (distance >= _currWalkDistance) return; - + debug(5, "BbvsEngine::walkFoundPath() distance smaller"); _currWalkDistance = distance; Common::Point destPt = _destWalkAreaPt, newDestPt; - + while (1) { int index = 0; @@ -408,7 +408,7 @@ void BbvsEngine::walkFoundPath(int count) { WalkInfo *walkInfo = _walkInfoPtrs[--count]; destPt.x = walkInfo->x; destPt.y = walkInfo->y; - + if (walkInfo->direction) { newDestPt.x = walkInfo->x; newDestPt.y = walkInfo->y + walkInfo->delta - 1; -- cgit v1.2.3 From 7126374b428ebb2feb7b431bdf5c906482d248dd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 28 Oct 2014 18:15:41 +0100 Subject: HOPKINS: Rename the parameter of PlayAnimSound to make it meaningful --- engines/hopkins/sound.cpp | 32 ++++++++++++++++---------------- engines/hopkins/sound.h | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 773c714899..d86fc449ee 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -261,9 +261,9 @@ void SoundManager::loadAnimSound() { } } -void SoundManager::playAnimSound(int soundNumber) { +void SoundManager::playAnimSound(int animFrame) { if (!_vm->_globals->_censorshipFl && _specialSoundNum == 2) { - switch (soundNumber) { + switch (animFrame) { case 20: playSample(5); break; @@ -282,35 +282,35 @@ void SoundManager::playAnimSound(int soundNumber) { playSample(4); break; } - } else if (_specialSoundNum == 1 && soundNumber == 17) + } else if (_specialSoundNum == 1 && animFrame == 17) playSoundFile("SOUND42.WAV"); - else if (_specialSoundNum == 5 && soundNumber == 19) + else if (_specialSoundNum == 5 && animFrame == 19) playWav(1); - else if (_specialSoundNum == 14 && soundNumber == 625) + else if (_specialSoundNum == 14 && animFrame == 625) playWav(1); - else if (_specialSoundNum == 16 && soundNumber == 25) + else if (_specialSoundNum == 16 && animFrame == 25) playWav(1); else if (_specialSoundNum == 17) { - if (soundNumber == 6) + if (animFrame == 6) playSample(1); - else if (soundNumber == 14) + else if (animFrame == 14) playSample(2); - else if (soundNumber == 67) + else if (animFrame == 67) playSample(3); - } else if (_specialSoundNum == 198 && soundNumber == 15) + } else if (_specialSoundNum == 198 && animFrame == 15) playWav(1); - else if (_specialSoundNum == 199 && soundNumber == 72) + else if (_specialSoundNum == 199 && animFrame == 72) playWav(1); - else if (_specialSoundNum == 208 && soundNumber == 40) + else if (_specialSoundNum == 208 && animFrame == 40) playWav(1); - else if (_specialSoundNum == 210 && soundNumber == 2) + else if (_specialSoundNum == 210 && animFrame == 2) playWav(1); - else if (_specialSoundNum == 211 && soundNumber == 22) + else if (_specialSoundNum == 211 && animFrame == 22) playWav(1); else if (_specialSoundNum == 229) { - if (soundNumber == 15) + if (animFrame == 15) playWav(1); - else if (soundNumber == 91) + else if (animFrame == 91) playWav(2); } } diff --git a/engines/hopkins/sound.h b/engines/hopkins/sound.h index 97cdcdc1dd..1fb4f9ae71 100644 --- a/engines/hopkins/sound.h +++ b/engines/hopkins/sound.h @@ -116,7 +116,7 @@ public: ~SoundManager(); void loadAnimSound(); - void playAnimSound(int soundNumber); + void playAnimSound(int animFrame); void loadSample(int wavIndex, const Common::String &file); void playSample(int wavIndex, int voiceMode = 9); -- cgit v1.2.3 From 9ad2135ff960da2bbc1882ac50f2188b5a9e228e Mon Sep 17 00:00:00 2001 From: lukaslw Date: Tue, 28 Oct 2014 19:20:56 +0100 Subject: PRINCE: Allow to load translation file - prince_translation.dat Update detection file to allow English language with both PL and DE data files. Add setMobTranslationTexts() to update mob names to translated ones in each location --- engines/prince/archive.cpp | 22 +++++++++++ engines/prince/archive.h | 1 + engines/prince/detection.h | 38 +++++++++++++++++-- engines/prince/prince.cpp | 92 +++++++++++++++++++++++++++++++++++++++++++--- engines/prince/prince.h | 6 +++ 5 files changed, 149 insertions(+), 10 deletions(-) diff --git a/engines/prince/archive.cpp b/engines/prince/archive.cpp index 7a4a35abd8..a01f824df8 100644 --- a/engines/prince/archive.cpp +++ b/engines/prince/archive.cpp @@ -79,6 +79,28 @@ bool PtcArchive::open(const Common::String &filename) { return true; } +bool PtcArchive::openTranslation(const Common::String &filename) { + _stream = SearchMan.createReadStreamForMember(filename); + if (!_stream) + return false; + + Common::Array translationNames; + Common::String translationFileName; + const int kTranslationFiles = 5; + for (int i = 0; i < kTranslationFiles; i++) { + translationFileName = _stream->readLine(); + translationNames.push_back(translationFileName); + } + FileEntry item; + for (int i = 0; i < kTranslationFiles; i++) { + item._offset = _stream->readUint32LE(); + item._size = _stream->readUint32LE(); + _items[translationNames[i]] = item; + } + + return true; +} + void PtcArchive::close() { delete _stream; _stream = nullptr; diff --git a/engines/prince/archive.h b/engines/prince/archive.h index e211036ed6..a640b77911 100644 --- a/engines/prince/archive.h +++ b/engines/prince/archive.h @@ -35,6 +35,7 @@ public: ~PtcArchive(); bool open(const Common::String &filename); + bool openTranslation(const Common::String &filename); void close(); bool isOpen() const { return _stream != 0; } diff --git a/engines/prince/detection.h b/engines/prince/detection.h index 5cc0d32be4..6720e5e0b7 100644 --- a/engines/prince/detection.h +++ b/engines/prince/detection.h @@ -28,9 +28,15 @@ namespace Prince { +enum PrinceGameType { + UNK_DATA, + DE_DATA, + PL_DATA +}; + struct PrinceGameDescription { ADGameDescription desc; - int gameType; + PrinceGameType gameType; }; static const PlainGameDescriptor princeGames[] = { @@ -49,7 +55,7 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - 0 + DE_DATA }, { { @@ -61,9 +67,33 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - 1 + PL_DATA + }, + { + { + "prince", + "The Prince and the Coward", + AD_ENTRY1s("databank.ptc", "5fa03833177331214ec1354761b1d2ee", 3565031), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_TESTING, + GUIO1(GUIO_NONE) + }, + DE_DATA + }, + { + { + "prince", + "The Prince and the Coward", + AD_ENTRY1s("databank.ptc", "48ec9806bda9d152acbea8ce31c93c49", 3435298), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_TESTING, + GUIO1(GUIO_NONE) + }, + PL_DATA }, - { AD_TABLE_END_MARKER, 0 } + { AD_TABLE_END_MARKER, UNK_DATA } }; const static char *directoryGlobs[] = { diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 04a482c570..a6197260e4 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -61,6 +61,7 @@ #include "prince/animation.h" #include "prince/option_text.h" #include "prince/curve_values.h" +#include "prince/detection.h" namespace Prince { @@ -95,7 +96,8 @@ PrinceEngine::PrinceEngine(OSystem *syst, const PrinceGameDescription *gameDesc) _tracePointFirstPointFlag(false), _coordsBuf2(nullptr), _coords2(nullptr), _coordsBuf3(nullptr), _coords3(nullptr), _shanLen(0), _directionTable(nullptr), _currentMidi(0), _lightX(0), _lightY(0), _curveData(nullptr), _curvPos(0), _creditsData(nullptr), _creditsDataSize(0), _currentTime(0), _zoomBitmap(nullptr), _shadowBitmap(nullptr), _transTable(nullptr), - _flcFrameSurface(nullptr), _shadScaleValue(0), _shadLineLen(0), _scaleValue(0), _dialogImage(nullptr) { + _flcFrameSurface(nullptr), _shadScaleValue(0), _shadLineLen(0), _scaleValue(0), _dialogImage(nullptr), _mobTranslationData(nullptr), + _mobTranslationSize(0) { // Debug/console setup DebugMan.addDebugChannel(DebugChannel::kScript, "script", "Prince Script debug channel"); @@ -204,6 +206,8 @@ PrinceEngine::~PrinceEngine() { _dialogImage->free(); delete _dialogImage; } + + free(_mobTranslationData); } GUI::Debugger *PrinceEngine::getDebugger() { @@ -228,11 +232,20 @@ void PrinceEngine::init() { if (!sound->open("sound/databank.ptc")) error("Can't open sound/databank.ptc"); + PtcArchive *translation = new PtcArchive(); + if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) { + if (!translation->openTranslation("all/prince_translation.dat")) + error("Can't open prince_translation.dat"); + } + SearchMan.addSubDirectoryMatching(gameDataDir, "all"); SearchMan.add("all", all); SearchMan.add("voices", voices); SearchMan.add("sound", sound); + if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) { + SearchMan.add("translation", translation); + } _graph = new GraphicsMan(this); @@ -261,6 +274,11 @@ void PrinceEngine::init() { _variaTxt = new VariaTxt(); Resource::loadResource(_variaTxt, "variatxt.dat", true); + if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) { + Resource::loadResource(_variaTxt, "variatxt.dat", true); + } else { + Resource::loadResource(_variaTxt, "variatxt_translate.dat", true); + } _cursor1 = new Cursor(); Resource::loadResource(_cursor1, "mouse1.cur", true); @@ -268,7 +286,12 @@ void PrinceEngine::init() { _cursor3 = new Cursor(); Resource::loadResource(_cursor3, "mouse2.cur", true); - Common::SeekableReadStream *talkTxtStream = SearchMan.createReadStreamForMember("talktxt.dat"); + Common::SeekableReadStream *talkTxtStream; + if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) { + talkTxtStream = SearchMan.createReadStreamForMember("talktxt.dat"); + } else { + talkTxtStream = SearchMan.createReadStreamForMember("talktxt_translate.dat"); + } if (!talkTxtStream) { error("Can't load talkTxtStream"); return; @@ -279,7 +302,12 @@ void PrinceEngine::init() { delete talkTxtStream; - Common::SeekableReadStream *invTxtStream = SearchMan.createReadStreamForMember("invtxt.dat"); + Common::SeekableReadStream *invTxtStream; + if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) { + invTxtStream = SearchMan.createReadStreamForMember("invtxt.dat"); + } else { + invTxtStream = SearchMan.createReadStreamForMember("invtxt_translate.dat"); + } if (!invTxtStream) { error("Can't load invTxtStream"); return; @@ -354,7 +382,12 @@ void PrinceEngine::init() { _shadowLine = (byte *)malloc(kShadowLineArraySize); - Common::SeekableReadStream *creditsDataStream = SearchMan.createReadStreamForMember("credits.dat"); + Common::SeekableReadStream *creditsDataStream; + if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) { + creditsDataStream = SearchMan.createReadStreamForMember("credits.dat"); + } else { + creditsDataStream = SearchMan.createReadStreamForMember("credits_translate.dat"); + } if (!creditsDataStream) { error("Can't load creditsDataStream"); return; @@ -363,6 +396,10 @@ void PrinceEngine::init() { _creditsData = (byte *)malloc(_creditsDataSize); creditsDataStream->read(_creditsData, _creditsDataSize); delete creditsDataStream; + + if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) { + loadMobTranslationTexts(); + } } void PrinceEngine::showLogo() { @@ -469,13 +506,17 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { loadMobPriority("mobpri"); _mobList.clear(); - if (getLanguage() == Common::DE_DEU) { + if (getGameType() == PrinceGameType::DE_DATA) { const Common::String mobLstName = Common::String::format("mob%02d.lst", _locationNr); debug("name: %s", mobLstName.c_str()); Resource::loadResource(_mobList, mobLstName.c_str(), false); - } else { + } else if (getGameType() == PrinceGameType::PL_DATA) { Resource::loadResource(_mobList, "mob.lst", false); } + if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) { + // update Mob texts for translated version + setMobTranslationTexts(); + } _animList.clear(); Resource::loadResource(_animList, "anim.lst", false); @@ -947,6 +988,45 @@ bool PrinceEngine::loadMobPriority(const char *resourceName) { return true; } +void PrinceEngine::loadMobTranslationTexts() { + Common::SeekableReadStream *mobTranslationStream = SearchMan.createReadStreamForMember("mob_translate.dat"); + if (!mobTranslationStream) { + error("Can't load mob_translate.dat"); + } + _mobTranslationSize = mobTranslationStream->size(); + _mobTranslationData = (byte *)malloc(_mobTranslationSize); + mobTranslationStream->read(_mobTranslationData, _mobTranslationSize); + delete mobTranslationStream; +} + +void PrinceEngine::setMobTranslationTexts() { + int locationOffset = READ_UINT16(_mobTranslationData + (_locationNr - 1) * 2); + if (locationOffset) { + byte *locationText = _mobTranslationData + locationOffset; + for (uint i = 0; i < _mobList.size(); i++) { + byte c; + locationText++; + _mobList[i]._name.clear(); + while ((c = *locationText)) { + _mobList[i]._name += c; + locationText++; + } + locationText++; + _mobList[i]._examText.clear(); + c = *locationText; + locationText++; + if (c) { + _mobList[i]._examText += c; + do { + c = *locationText; + _mobList[i]._examText += c; + locationText++; + } while (c != 255); + } + } + } +} + void PrinceEngine::keyHandler(Common::Event event) { uint16 nChar = event.kbd.keycode; switch (nChar) { diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 930c3c7bd3..48491c63bd 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -285,6 +285,9 @@ public: uint32 _talkTxtSize; byte *_talkTxt; + uint32 _mobTranslationSize; + byte *_mobTranslationData; + bool loadLocation(uint16 locationNr); bool loadAnim(uint16 animNr, bool loop); bool loadVoice(uint32 textSlot, uint32 sampleSlot, const Common::String &name); @@ -294,6 +297,9 @@ public: bool loadTrans(byte *transTable, const char *resourceName); bool loadMobPriority(const char *resourceName); + void loadMobTranslationTexts(); + void setMobTranslationTexts(); + bool loadMusic(int musNumber); void stopMusic(); -- cgit v1.2.3 From 5f022f2e9e333318d38a456ce5db63b19e203b84 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Tue, 28 Oct 2014 21:36:25 +0100 Subject: PRINCE: Change PrinceGameType enum names Fix compilation on gcc --- engines/prince/detection.h | 16 ++++++++-------- engines/prince/prince.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engines/prince/detection.h b/engines/prince/detection.h index 6720e5e0b7..7e5bdd6b7b 100644 --- a/engines/prince/detection.h +++ b/engines/prince/detection.h @@ -29,9 +29,9 @@ namespace Prince { enum PrinceGameType { - UNK_DATA, - DE_DATA, - PL_DATA + kPrinceDataUNK, + kPrinceDataDE, + kPrinceDataPL }; struct PrinceGameDescription { @@ -55,7 +55,7 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - DE_DATA + kPrinceDataDE }, { { @@ -67,7 +67,7 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - PL_DATA + kPrinceDataPL }, { { @@ -79,7 +79,7 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - DE_DATA + kPrinceDataDE }, { { @@ -91,9 +91,9 @@ static const PrinceGameDescription gameDescriptions[] = { ADGF_TESTING, GUIO1(GUIO_NONE) }, - PL_DATA + kPrinceDataPL }, - { AD_TABLE_END_MARKER, UNK_DATA } + { AD_TABLE_END_MARKER, kPrinceDataUNK } }; const static char *directoryGlobs[] = { diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index a6197260e4..00e1736c46 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -506,11 +506,11 @@ bool PrinceEngine::loadLocation(uint16 locationNr) { loadMobPriority("mobpri"); _mobList.clear(); - if (getGameType() == PrinceGameType::DE_DATA) { + if (getGameType() == kPrinceDataDE) { const Common::String mobLstName = Common::String::format("mob%02d.lst", _locationNr); debug("name: %s", mobLstName.c_str()); Resource::loadResource(_mobList, mobLstName.c_str(), false); - } else if (getGameType() == PrinceGameType::PL_DATA) { + } else if (getGameType() == kPrinceDataPL) { Resource::loadResource(_mobList, "mob.lst", false); } if (getLanguage() != Common::PL_POL && getLanguage() != Common::DE_DEU) { -- cgit v1.2.3 From 28967b617f53dbda91d549007dc8af2581dbae3a Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 28 Oct 2014 22:37:57 +0100 Subject: SCI: properly reversed color matching thanks wjp --- engines/sci/graphics/palette.cpp | 82 +++++++++++++++++++++++----------------- engines/sci/graphics/palette.h | 4 ++ engines/sci/resource.cpp | 3 ++ 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 36b9660d4e..4d2c874e04 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -73,6 +73,8 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen) // to detect if the current game is merging or copying _useMerging = _resMan->detectPaletteMergingSci11(); _use16bitColorMatch = _useMerging; + // Note: Laura Bow 2 floppy uses the new palette format and is detected + // as 8 bit color matching because of that. } else { // SCI32 _useMerging = false; @@ -473,8 +475,8 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) { // check if exact color could be matched res = matchColor(newPalette->colors[i].r, newPalette->colors[i].g, newPalette->colors[i].b); - if (res & 0x8000) { // exact match was found - newPalette->mapping[i] = res & 0xFF; + if (res & SCI_PALETTE_MATCH_PERFECT) { // exact match was found + newPalette->mapping[i] = res & SCI_PALETTE_MATCH_COLORMASK; continue; } @@ -495,8 +497,8 @@ bool GfxPalette::merge(Palette *newPalette, bool force, bool forceRealMerge) { // if still no luck - set an approximate color if (j == 256) { - newPalette->mapping[i] = res & 0xFF; - _sysPalette.colors[res & 0xFF].used |= 0x10; + newPalette->mapping[i] = res & SCI_PALETTE_MATCH_COLORMASK; + _sysPalette.colors[res & SCI_PALETTE_MATCH_COLORMASK].used |= 0x10; } } @@ -518,38 +520,50 @@ void GfxPalette::drewPicture(GuiResourceId pictureId) { } } -uint16 GfxPalette::matchColor(byte r, byte g, byte b) { - byte found = 0xFF; - int diff = 0x2FFFF, cdiff; - int16 dr,dg,db; - - for (int i = 1; i < 255; i++) { - if ((!_sysPalette.colors[i].used)) - continue; - dr = _sysPalette.colors[i].r - r; - dg = _sysPalette.colors[i].g - g; - db = _sysPalette.colors[i].b - b; - if (!_use16bitColorMatch) { - // remove upper bits for most SCI1.1 games - // this bug was introduced with Quest For Glory 3 interpreter - // we have to implement it, otherwise some colors will be "wrong" - // See Space Quest 5 bug #6455 - dr &= 0xFF; - dg &= 0xFF; - db &= 0xFF; +uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) { + int16 colorNr; + int16 differenceRed, differenceGreen, differenceBlue; + int16 differenceTotal = 0; + int16 bestDifference = 0x7FFF; + uint16 bestColor = 255; + + if (_use16bitColorMatch) { + // used by SCI0 to SCI1, also by the first few SCI1.1 games + for (colorNr = 0; colorNr < 256; colorNr++) { + if ((!_sysPalette.colors[colorNr].used)) + continue; + differenceRed = ABS(_sysPalette.colors[colorNr].r - matchRed); + differenceGreen = ABS(_sysPalette.colors[colorNr].g - matchGreen); + differenceBlue = ABS(_sysPalette.colors[colorNr].b - matchBlue); + differenceTotal = differenceRed + differenceGreen + differenceBlue; + if (differenceTotal <= bestDifference) { + bestDifference = differenceTotal; + bestColor = colorNr; + } } -// minimum squares match - cdiff = (dr*dr) + (dg*dg) + (db*db); -// minimum sum match (Sierra's) -// cdiff = ABS(dr) + ABS(dg) + ABS(db); - if (cdiff < diff) { - if (cdiff == 0) - return i | 0x8000; // setting this flag to indicate exact match - found = i; - diff = cdiff; + } else { + // SCI1.1, starting with QfG3 introduced a bug in the matching code + // we have to implement it as well, otherwise some colors will be "wrong" in comparison to the original interpreter + // See Space Quest 5 bug #6455 + for (colorNr = 0; colorNr < 256; colorNr++) { + if ((!_sysPalette.colors[colorNr].used)) + continue; + differenceRed = (uint8)ABS(_sysPalette.colors[colorNr].r - matchRed); + differenceGreen = (uint8)ABS(_sysPalette.colors[colorNr].g - matchGreen); + differenceBlue = (uint8)ABS(_sysPalette.colors[colorNr].b - matchBlue); + differenceTotal = differenceRed + differenceGreen + differenceBlue; + if (differenceTotal < 0) { + differenceTotal = differenceTotal; + } + if (differenceTotal <= bestDifference) { + bestDifference = differenceTotal; + bestColor = colorNr; + } } } - return found; + if (differenceTotal == 0) // original interpreter does not do this, instead it does 2 calls for merges in the worst case + return colorNr | SCI_PALETTE_MATCH_PERFECT; // we set this flag, so that we can optimize during palette merge + return bestColor; } void GfxPalette::getSys(Palette *pal) { @@ -639,7 +653,7 @@ void GfxPalette::kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 int } int16 GfxPalette::kernelFindColor(uint16 r, uint16 g, uint16 b) { - return matchColor(r, g, b) & 0xFF; + return matchColor(r, g, b) & SCI_PALETTE_MATCH_COLORMASK; } // Returns true, if palette got changed diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h index 93cc2a8189..500a45eccf 100644 --- a/engines/sci/graphics/palette.h +++ b/engines/sci/graphics/palette.h @@ -31,6 +31,10 @@ namespace Sci { class ResourceManager; class GfxScreen; +// Special flag implemented by us for optimization in palette merge +#define SCI_PALETTE_MATCH_PERFECT 0x8000 +#define SCI_PALETTE_MATCH_COLORMASK 0xFF + enum ColorRemappingType { kRemappingNone = 0, kRemappingByRange = 1, diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index d155792853..10740a8b7b 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -2350,6 +2350,9 @@ bool ResourceManager::detectPaletteMergingSci11() { // Old palette format used in palette resource? -> it's merging if ((data[0] == 0 && data[1] == 1) || (data[0] == 0 && data[1] == 0 && READ_LE_UINT16(data + 29) == 0)) return true; + // Hardcoded: Laura Bow 2 floppy uses new palette resource, but still palette merging + 16 bit color matching + if ((g_sci->getGameId() == GID_LAURABOW2) && (!g_sci->isCD()) && (!g_sci->isDemo())) + return true; return false; } return false; -- cgit v1.2.3 From bb29cdc899dcf48fb67b369273194dab32843665 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 28 Oct 2014 22:41:14 +0100 Subject: SCI: color matching - remove debug code --- engines/sci/graphics/palette.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 4d2c874e04..5058eaa550 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -552,9 +552,6 @@ uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) { differenceGreen = (uint8)ABS(_sysPalette.colors[colorNr].g - matchGreen); differenceBlue = (uint8)ABS(_sysPalette.colors[colorNr].b - matchBlue); differenceTotal = differenceRed + differenceGreen + differenceBlue; - if (differenceTotal < 0) { - differenceTotal = differenceTotal; - } if (differenceTotal <= bestDifference) { bestDifference = differenceTotal; bestColor = colorNr; -- cgit v1.2.3 From 5c91173337278d1d23d03efbeb4e6b6debba0d6d Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 29 Oct 2014 00:12:12 +0100 Subject: SCI: color matching bug fix --- engines/sci/graphics/palette.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 5058eaa550..59abef5550 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -525,7 +525,7 @@ uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) { int16 differenceRed, differenceGreen, differenceBlue; int16 differenceTotal = 0; int16 bestDifference = 0x7FFF; - uint16 bestColor = 255; + uint16 bestColorNr = 255; if (_use16bitColorMatch) { // used by SCI0 to SCI1, also by the first few SCI1.1 games @@ -538,7 +538,7 @@ uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) { differenceTotal = differenceRed + differenceGreen + differenceBlue; if (differenceTotal <= bestDifference) { bestDifference = differenceTotal; - bestColor = colorNr; + bestColorNr = colorNr; } } } else { @@ -554,13 +554,13 @@ uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) { differenceTotal = differenceRed + differenceGreen + differenceBlue; if (differenceTotal <= bestDifference) { bestDifference = differenceTotal; - bestColor = colorNr; + bestColorNr = colorNr; } } } if (differenceTotal == 0) // original interpreter does not do this, instead it does 2 calls for merges in the worst case - return colorNr | SCI_PALETTE_MATCH_PERFECT; // we set this flag, so that we can optimize during palette merge - return bestColor; + return bestColorNr | SCI_PALETTE_MATCH_PERFECT; // we set this flag, so that we can optimize during palette merge + return bestColorNr; } void GfxPalette::getSys(Palette *pal) { -- cgit v1.2.3 From 40b224fc74337315dd485a7e8cdbf19bd37dc941 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 29 Oct 2014 11:19:15 +0200 Subject: SCUMM: Disallow saving while a room 'prequel' is shown in v0-v3 games These are cases where the screen is completely blank, showing text. In such cases, no room is set, thus no room resources are available. An example is the screen shown after the credits in the Zak FM-TOWNS intro ("The next day..."). Thanks to segrax for finding this case. This commit is based off pull request 522, but completely disallows saving in such scenes, instead of adding explicit checks for them --- engines/scumm/saveload.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 7eadb042fb..0c0f6be73b 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -109,7 +109,12 @@ Common::Error ScummEngine::saveGameState(int slot, const Common::String &desc) { } bool ScummEngine::canSaveGameStateCurrently() { - // FIXME: For now always allow loading in V0-V3 games + // Disallow saving in v0-v3 games when a 'prequel' to a cutscene is shown. + // This is a blank screen with text, and while this is shown, saving should + // be disabled, as no room is set. + if (_game.version <= 3 && _currentScript == 0xFF && _roomResource == 0 && _currentRoom == 0) + return false; + // TODO: Should we disallow saving in some more places, // e.g. when a SAN movie is playing? Not sure whether the // original EXE allowed this. -- cgit v1.2.3 From c2951e2594c320c244898237d434e7d83a027662 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Oct 2014 05:14:13 +0100 Subject: HOPKINS: Add specific code to handle the butchered Polish version with sync sound --- engines/hopkins/sound.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index d86fc449ee..6b3149e247 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -275,11 +275,23 @@ void SoundManager::playAnimSound(int animFrame) { case 75: playSample(2); break; + case 95: + // This fixes an original bug in the Polish version of the bug, which was literally butchered for some reason + if (_vm->getLanguage() == Common::PL_POL) + playSample(3); + break; case 109: - playSample(3); + if (_vm->getLanguage() != Common::PL_POL) + playSample(3); + break; + case 108: + // This fixes an original bug in the Polish version of the bug, which was literally butchered for some reason + if (_vm->getLanguage() == Common::PL_POL) + playSample(4); break; case 122: - playSample(4); + if (_vm->getLanguage() != Common::PL_POL) + playSample(4); break; } } else if (_specialSoundNum == 1 && animFrame == 17) -- cgit v1.2.3 From 75198ce17c6e13dd01ca44e17c7ad8a40d38dcf8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 29 Oct 2014 17:13:16 +0100 Subject: HOPKINS: Fix a couple of comments --- engines/hopkins/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 6b3149e247..b429eb863a 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -276,7 +276,7 @@ void SoundManager::playAnimSound(int animFrame) { playSample(2); break; case 95: - // This fixes an original bug in the Polish version of the bug, which was literally butchered for some reason + // This fixes an original bug in the Polish version of the game, which was literally butchered for some reason if (_vm->getLanguage() == Common::PL_POL) playSample(3); break; @@ -285,7 +285,7 @@ void SoundManager::playAnimSound(int animFrame) { playSample(3); break; case 108: - // This fixes an original bug in the Polish version of the bug, which was literally butchered for some reason + // This fixes an original bug in the Polish version of the game, which was literally butchered for some reason if (_vm->getLanguage() == Common::PL_POL) playSample(4); break; -- cgit v1.2.3 From 86a3d504672e86e0acb62c93d1f120f7e1162ba2 Mon Sep 17 00:00:00 2001 From: Kirben Date: Fri, 31 Oct 2014 09:22:12 +1100 Subject: SCUMM: Fix bug #6742 - PJGAMES: Crash upon playing Happy Fun Squares on Hard. --- engines/scumm/scumm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 46512f8ce6..967909e505 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -642,7 +642,7 @@ protected: byte _opcode; byte _currentScript; int _scummStackPos; - int _vmStack[150]; + int _vmStack[256]; OpcodeEntry _opcodes[256]; -- cgit v1.2.3 From 0c5fae865218aa140f65e6ac56eeda835bda4f52 Mon Sep 17 00:00:00 2001 From: Kirben Date: Fri, 31 Oct 2014 09:37:46 +1100 Subject: SCUMM: Add Dutch Windows demo of Let's Explore the Farm with Buzzy. --- devtools/scumm-md5.txt | 1 + engines/scumm/scumm-md5.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index acee5d87b3..122df76ec0 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -625,6 +625,7 @@ farm Let's Explore the Farm with Buzzy 5dda73606533d66a4c3f4f9ea6e842af 87061 ru Windows - - - sev 39fd6db10d0222d817025c4d3346e3b4 -1 en Mac - Demo - Joachim Eberhard + 6c375c2236d99f56e6c2cf540e74e474 36864 nl Windows - Demo - Kirben bf8b52fdd9a69c67f34e8e9fec72661c -1 en Windows HE 71 Demo - khalek, sev 0557df19f046a84c2fdc63507c6616cb -1 nl Windows HE 72 Demo - adutchguy 8d479e36f35e80257dfc102cf4b8a912 34333 en Windows HE 72 Demo - khalek, sev diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index d7ec9bb686..f29239606a 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Mon Oct 20 12:17:31 2014 + This file was generated by the md5table tool on Thu Oct 30 22:35:51 2014 DO NOT EDIT MANUALLY! */ @@ -310,6 +310,7 @@ static const MD5Table md5table[] = { { "6bca7a1a96d16e52b8f3c42b50dbdca3", "fbear", "HE 62", "", -1, Common::JA_JPN, Common::kPlatform3DO }, { "6bf70eee5de3d24d2403e0dd3d267e8a", "spyfox", "", "", 49221, Common::UNK_LANG, Common::kPlatformWindows }, { "6c2bff0e327f2962e809c2e1a82d7309", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformAmiga }, + { "6c375c2236d99f56e6c2cf540e74e474", "farm", "", "Demo", 36864, Common::NL_NLD, Common::kPlatformWindows }, { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, { "6dead580b0ff14d5f7b33b4219f04159", "samnmax", "", "Demo", 16556335, Common::EN_ANY, Common::kPlatformMacintosh }, { "6df20c50c1ab19799de9be7ae7716881", "fbear", "HE 62", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh }, -- cgit v1.2.3 From 6bc36cbdf412db1ce10adcdc50eb98135908612e Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 31 Oct 2014 08:16:33 +0100 Subject: DEBUGGER: Add FIXME comment about file name vs base name --- gui/debugger.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 560e516a94..216bd626fe 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -556,6 +556,10 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) { filename = filename + " " + argv[i]; } Common::MacResManager macResMan; + // FIXME: There currently isn't any way to tell the Mac resource + // manager to open a specific file. Instead, it takes a "base name" + // and constructs a file name out of that. While usually a desirable + // thing, it's not ideal here. if (!macResMan.open(filename)) { debugPrintf("Resource file '%s' not found\n", filename.c_str()); } else { -- cgit v1.2.3 From 5b42fa81961d86b20659e50f10eb828b900dd1d9 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Fri, 31 Oct 2014 20:33:00 +0100 Subject: SCI: script patch for qfg1ega (fixes bug #6407) throwing rocks at bird's nest, running ego gets stuck --- engines/sci/engine/script_patches.cpp | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index 8bbbd713a6..3d76848a76 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -1916,6 +1916,43 @@ static const SciScriptPatcherEntry pq1vgaSignatures[] = { SCI_SIGNATUREENTRY_TERMINATOR }; +// =========================================================================== +// At the healer's house there is a bird's nest up on the tree. +// The player can throw rocks at it until it falls to the ground. +// The hero will then grab the item, that is in the nest. +// +// When running is active, the hero will not reach the actual destination +// and because of that, the game will get stuck. +// +// We just change the coordinate of the destination slightly, so that walking, +// sneaking and running work. +// +// This bug was fixed by Sierra at least in the Japanese PC-9801 version. +// Applies to at least: English floppy (1.000, 1.012) +// Responsible method: pickItUp::changeState (script 54) +// Fixes bug: #6407 +static const uint16 qfg1egaSignatureThrowRockAtNest[] = { + 0x4a, 0x04, // send 04 (nest::x) + 0x36, // push + SIG_MAGICDWORD, + 0x35, 0x0f, // ldi 0f (15d) + 0x02, // add + 0x36, // push + SIG_END +}; + +static const uint16 qfg1egaPatchThrowRockAtNest[] = { + PATCH_ADDTOOFFSET(+3), + 0x35, 0x12, // ldi 12 (18d) + PATCH_END +}; + +// script, description, signature patch +static const SciScriptPatcherEntry qfg1egaSignatures[] = { + { true, 54, "throw rock at nest while running", 1, qfg1egaSignatureThrowRockAtNest, qfg1egaPatchThrowRockAtNest }, + SCI_SIGNATUREENTRY_TERMINATOR +}; + // =========================================================================== // script 215 of qfg1vga pointBox::doit actually processes button-presses // during fighting with monsters. It strangely also calls kGetEvent. Because @@ -3036,6 +3073,9 @@ void ScriptPatcher::processScript(uint16 scriptNr, byte *scriptData, const uint3 case GID_PQ1: signatureTable = pq1vgaSignatures; break; + case GID_QFG1: + signatureTable = qfg1egaSignatures; + break; case GID_QFG1VGA: signatureTable = qfg1vgaSignatures; break; -- cgit v1.2.3 From 9561d5f6f8d5fab355ee56f70879443177b58ee1 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 1 Nov 2014 00:57:26 +0100 Subject: SCI: revert r55034, fixes bug #6539 original bug wasn't solved properly will reopen the original bug #5334 and figure out that one instead --- engines/sci/graphics/text16.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 245d6996cb..808ce45d0d 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -337,8 +337,6 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId maxTextWidth = MAX(textWidth, maxTextWidth); totalHeight += textHeight; curPos += charCount; - while (*curPos == ' ') - curPos++; // skip over breaking spaces } rect.bottom = totalHeight; rect.right = maxWidth ? maxWidth : MIN(rect.right, maxTextWidth); @@ -458,8 +456,6 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA hline += textHeight; text += charCount; - while (*text == ' ') - text++; // skip over breaking spaces } SetFont(previousFontId); _ports->penColor(previousPenColor); -- cgit v1.2.3 From 14ab55e9badc97fd6554214408da33663a88c792 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 1 Nov 2014 12:35:59 +0100 Subject: HOPKINS: Add a check for another sound related to frames removed in the Polish version. Fix for bug #6591 --- engines/hopkins/sound.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index b429eb863a..6660233740 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -273,7 +273,10 @@ void SoundManager::playAnimSound(int animFrame) { playSample(1); break; case 75: - playSample(2); + // This removes the sound of the gun played while the guard is being shot, as this part of the scene has been + // removed in the Polish version of the game + if (_vm->getLanguage() != Common::PL_POL) + playSample(2); break; case 95: // This fixes an original bug in the Polish version of the game, which was literally butchered for some reason -- cgit v1.2.3 From c4e40fc83fa79ed14f9a5dd434b952d5b3e4eb56 Mon Sep 17 00:00:00 2001 From: Kirben Date: Sat, 1 Nov 2014 23:01:29 +1100 Subject: SCUMM: Correct file size for Dutch Windows demo of Let's Explore the Farm with Buzzy. --- devtools/scumm-md5.txt | 2 +- engines/scumm/scumm-md5.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 122df76ec0..eef50003d2 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -625,7 +625,7 @@ farm Let's Explore the Farm with Buzzy 5dda73606533d66a4c3f4f9ea6e842af 87061 ru Windows - - - sev 39fd6db10d0222d817025c4d3346e3b4 -1 en Mac - Demo - Joachim Eberhard - 6c375c2236d99f56e6c2cf540e74e474 36864 nl Windows - Demo - Kirben + 6c375c2236d99f56e6c2cf540e74e474 34333 nl Windows - Demo - Kirben bf8b52fdd9a69c67f34e8e9fec72661c -1 en Windows HE 71 Demo - khalek, sev 0557df19f046a84c2fdc63507c6616cb -1 nl Windows HE 72 Demo - adutchguy 8d479e36f35e80257dfc102cf4b8a912 34333 en Windows HE 72 Demo - khalek, sev diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index f29239606a..878b2eeef3 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Thu Oct 30 22:35:51 2014 + This file was generated by the md5table tool on Sat Nov 01 11:52:16 2014 DO NOT EDIT MANUALLY! */ @@ -310,7 +310,7 @@ static const MD5Table md5table[] = { { "6bca7a1a96d16e52b8f3c42b50dbdca3", "fbear", "HE 62", "", -1, Common::JA_JPN, Common::kPlatform3DO }, { "6bf70eee5de3d24d2403e0dd3d267e8a", "spyfox", "", "", 49221, Common::UNK_LANG, Common::kPlatformWindows }, { "6c2bff0e327f2962e809c2e1a82d7309", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformAmiga }, - { "6c375c2236d99f56e6c2cf540e74e474", "farm", "", "Demo", 36864, Common::NL_NLD, Common::kPlatformWindows }, + { "6c375c2236d99f56e6c2cf540e74e474", "farm", "", "Demo", 34333, Common::NL_NLD, Common::kPlatformWindows }, { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, { "6dead580b0ff14d5f7b33b4219f04159", "samnmax", "", "Demo", 16556335, Common::EN_ANY, Common::kPlatformMacintosh }, { "6df20c50c1ab19799de9be7ae7716881", "fbear", "HE 62", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh }, -- cgit v1.2.3 From c9e74d6d54bf59b3587eea0785ce31df5d46615b Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 1 Nov 2014 23:36:29 +0100 Subject: SCI: text16 GetLongest() changes fixes bug #5334 also fixes bug #5159 also fixes Japanese line wrapping (hopefully) --- engines/sci/graphics/text16.cpp | 177 +++++++++++++++++++++++++--------------- engines/sci/graphics/text16.h | 2 +- 2 files changed, 114 insertions(+), 65 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 808ce45d0d..66cff422ae 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -143,7 +143,8 @@ int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int1 return textCodeSize; } -static const uint16 text16_punctuationSjis[] = { +// Has actually punctuation and characters in it, that may not be the first in a line +static const uint16 text16_shiftJIS_punctuation[] = { 0x9F82, 0xA182, 0xA382, 0xA582, 0xA782, 0xC182, 0xA782, 0xC182, 0xE182, 0xE382, 0xE582, 0xEC82, 0x4083, 0x4283, 0x4483, 0x4683, 0x4883, 0x6283, 0x8383, 0x8583, 0x8783, 0x8E83, 0x9583, 0x9683, 0x5B81, 0x4181, 0x4281, 0x7681, 0x7881, 0x4981, 0x4881, 0 @@ -151,10 +152,21 @@ static const uint16 text16_punctuationSjis[] = { // return max # of chars to fit maxwidth with full words, does not include // breaking space -int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId) { +// Also adjusts text pointer to the new position for the caller +// +// Special cases in games: +// Laura Bow 2 - Credits in the game menu - all the text lines start with spaces (bug #5159) +// Act 6 Coroner questionaire - the text of all control buttons has trailing spaces +// "Detective Ryan Hanrahan O'Riley" contains even more spaces (bug #5334) +// Conquests of Camelot - talking with Cobb - one text box of the dialogue contains a longer word, +// that will be broken into 2 lines (bug #5159) +int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId orgFontId) { uint16 curChar = 0; - int16 maxChars = 0, curCharCount = 0; - uint16 width = 0; + const char *textStartPtr = textPtr; + const char *lastSpacePtr = NULL; + int16 lastSpaceCharCount = 0; + int16 curCharCount = 0, resultCharCount = 0; + uint16 curWidth = 0, tempWidth = 0; GuiResourceId previousFontId = GetFontId(); int16 previousPenColor = _ports->_curPort->penClr; @@ -162,35 +174,34 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF if (!_font) return 0; - while (width <= maxWidth) { - curChar = (*(const byte *)text++); + while (1) { + curChar = (*(const byte *)textPtr); if (_font->isDoubleByte(curChar)) { - curChar |= (*(const byte *)text++) << 8; - curCharCount++; + curChar |= (*(const byte *)textPtr + 1) << 8; } switch (curChar) { case 0x7C: if (getSciVersion() >= SCI_VERSION_1_1) { - curCharCount++; - curCharCount += CodeProcessing(text, orgFontId, previousPenColor, false); + curCharCount++; textPtr++; + curCharCount += CodeProcessing(textPtr, orgFontId, previousPenColor, false); continue; } break; // We need to add 0xD, 0xA and 0xD 0xA to curCharCount and then exit - // which means, we split text like - // 'Mature, experienced software analyst available.' 0xD 0xA - // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2) - // and 0xA '-------' 0xA (which is the official sierra subtitle separator) + // which means, we split text like for example + // - 'Mature, experienced software analyst available.' 0xD 0xA + // 'Bug installation a proven speciality. "No version too clean."' (normal game text, this is from lsl2) + // - 0xA '-------' 0xA (which is the official sierra subtitle separator) (found in multilingual versions) // Sierra did it the same way. case 0xD: // Check, if 0xA is following, if so include it as well - if ((*(const unsigned char *)text) == 0xA) - curCharCount++; + if ((*(const byte *)textPtr + 1) == 0xA) + curCharCount++; textPtr++; // it's meant to pass through here case 0xA: case 0x9781: // this one is used by SQ4/japanese as line break as well - curCharCount++; + curCharCount++; textPtr++; // and it's also meant to pass through here case 0: SetFont(previousFontId); @@ -198,55 +209,90 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF return curCharCount; case ' ': - maxChars = curCharCount; // return count up to (but not including) breaking space + lastSpaceCharCount = curCharCount; // return count up to (but not including) breaking space + lastSpacePtr = textPtr + 1; // remember position right after the current space break; } - // Sometimes this can go off the screen, like for example bug #3040161. - // However, we only perform this for non-Japanese games, as these require - // special handling, done after this loop. - if (width + _font->getCharWidth(curChar) > maxWidth && g_sci->getLanguage() != Common::JA_JPN) + tempWidth += _font->getCharWidth(curChar); + + // Width is too large? -> break out + if (tempWidth > maxWidth) break; - width += _font->getCharWidth(curChar); - curCharCount++; - } - // Text without spaces, probably Kanji/Japanese - if (maxChars == 0) { - maxChars = curCharCount; + // still fits, remember width + curWidth = tempWidth; - uint16 nextChar; + // go to next character + curCharCount++; textPtr++; + if (curChar > 0xFF) { + // Double-Byte + curCharCount++; textPtr++; + } + } - // We remove the last char only, if maxWidth was actually equal width - // before adding the last char. Otherwise we won't get the same cutting - // as in sierra pc98 sci. - if (maxWidth == (width - _font->getCharWidth(curChar))) { - maxChars--; - if (curChar > 0xFF) - maxChars--; - nextChar = curChar; - } else { - nextChar = (*(const byte *)text++); - if (_font->isDoubleByte(nextChar)) - nextChar |= (*(const byte *)text++) << 8; - } - // sierra checked the following character against a punctuation kanji table - if (nextChar > 0xFF) { - // if the character is punctuation, we go back one character - uint nonBreakingNr = 0; - while (text16_punctuationSjis[nonBreakingNr]) { - if (text16_punctuationSjis[nonBreakingNr] == nextChar) { - maxChars--; - if (curChar > 0xFF) - maxChars--; // go back 2 chars, when last char was double byte + if (lastSpaceCharCount) { + // Break and at least one space was found before that + resultCharCount = lastSpaceCharCount; + + // additionally skip over all spaces, that are following that space, but don't count them for displaying purposes + textPtr = lastSpacePtr; + while (*textPtr == ' ') + textPtr++; + + } else { + // Break without spaces found, we split the very first word - may also be Kanji/Japanese + if (curChar > 0xFF) { + // current charracter is Japanese + + // PC-9801 SCI actually added the last character, which shouldn't fit anymore, still onto the + // screen in case maxWidth wasn't fully reached with the last character + if (maxWidth == curWidth) { + curCharCount -= 2; textPtr -= 2; + if (textPtr < textStartPtr) + error("Seeking back went too far, data corruption?"); + + curChar = (*(const byte *)textPtr); + if (!_font->isDoubleByte(curChar)) + error("Non double byte while seeking back"); + curChar |= (*(const byte *)textPtr + 1) << 8; + } + + // But it also checked, if the current character is not inside a punctuation table and it even + // went backwards in case it found multiple ones inside that table. + uint nonBreakingPos = 0; + + while (1) { + // Look up if character shouldn't be the first on a new line + nonBreakingPos = 0; + while (text16_shiftJIS_punctuation[nonBreakingPos]) { + if (text16_shiftJIS_punctuation[nonBreakingPos] == curChar) + break; + nonBreakingPos++; + } + if (!text16_shiftJIS_punctuation[nonBreakingPos]) { + // character is fine break; } - nonBreakingNr++; + // Character is not acceptable, seek backward in the text + curCharCount -= 2; textPtr -= 2; + if (textPtr < textStartPtr) + error("Seeking back went too far, data corruption?"); + + curChar = (*(const byte *)textPtr); + if (!_font->isDoubleByte(curChar)) + error("Non double byte while seeking back"); + curChar |= (*(const byte *)textPtr + 1) << 8; } + // include the current character + curCharCount += 2; textPtr += 2; } + + // We split the word in that case + resultCharCount = curCharCount; } SetFont(previousFontId); _ports->penColor(previousPenColor); - return maxChars; + return resultCharCount; } void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont) { @@ -328,15 +374,16 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId // rect.right=found widest line with RTextWidth and GetLongest // rect.bottom=num. lines * GetPointSize rect.right = (maxWidth ? maxWidth : 192); - const char *curPos = text; - while (*curPos) { - charCount = GetLongest(curPos, rect.right, fontId); + const char *curTextPos = text; // in work position for GetLongest() + const char *curTextLine = text; // starting point of current line + while (*curTextPos) { + charCount = GetLongest(curTextPos, rect.right, fontId); if (charCount == 0) break; - Width(curPos, 0, charCount, fontId, textWidth, textHeight, false); + Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, false); maxTextWidth = MAX(textWidth, maxTextWidth); totalHeight += textHeight; - curPos += charCount; + curTextLine = curTextPos; } rect.bottom = totalHeight; rect.right = maxWidth ? maxWidth : MIN(rect.right, maxTextWidth); @@ -410,6 +457,8 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA GuiResourceId previousFontId = GetFontId(); int16 previousPenColor = _ports->_curPort->penClr; bool doubleByteMode = false; + const char *curTextPos = text; + const char *curTextLine = text; if (fontId != -1) SetFont(fontId); @@ -426,11 +475,11 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA _codeRefTempRect.left = _codeRefTempRect.top = -1; maxTextWidth = 0; - while (*text) { - charCount = GetLongest(text, rect.width(), fontId); + while (*curTextPos) { + charCount = GetLongest(curTextPos, rect.width(), fontId); if (charCount == 0) break; - Width(text, 0, charCount, fontId, textWidth, textHeight, true); + Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, true); maxTextWidth = MAX(maxTextWidth, textWidth); switch (alignment) { case SCI_TEXT16_ALIGNMENT_RIGHT: @@ -449,13 +498,13 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA _ports->moveTo(rect.left + offset, rect.top + hline); if (show) { - Show(text, 0, charCount, fontId, previousPenColor); + Show(curTextLine, 0, charCount, fontId, previousPenColor); } else { - Draw(text, 0, charCount, fontId, previousPenColor); + Draw(curTextLine, 0, charCount, fontId, previousPenColor); } hline += textHeight; - text += charCount; + curTextLine = curTextPos; } SetFont(previousFontId); _ports->penColor(previousPenColor); diff --git a/engines/sci/graphics/text16.h b/engines/sci/graphics/text16.h index ab0cb13a64..715891be44 100644 --- a/engines/sci/graphics/text16.h +++ b/engines/sci/graphics/text16.h @@ -51,7 +51,7 @@ public: void ClearChar(int16 chr); - int16 GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId); + int16 GetLongest(const char *&text, int16 maxWidth, GuiResourceId orgFontId); void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont); void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight); void ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor); -- cgit v1.2.3 From c4ca0a7de29ab32d35e72ae88ed399b377a3c2c7 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 02:16:00 +0100 Subject: SCI: fix bug in text16 / GetLongest() --- engines/sci/graphics/text16.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 66cff422ae..37d786a849 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -196,8 +196,9 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId // Sierra did it the same way. case 0xD: // Check, if 0xA is following, if so include it as well - if ((*(const byte *)textPtr + 1) == 0xA) + if ((*(const byte *)textPtr + 1) == 0xA) { curCharCount++; textPtr++; + } // it's meant to pass through here case 0xA: case 0x9781: // this one is used by SQ4/japanese as line break as well -- cgit v1.2.3 From 9d693b9a793f1d14d9b80a0341ac55dfc2da0b0b Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 02:31:32 +0100 Subject: SCI: fix another bug in text16 / GetLongest() --- engines/sci/graphics/text16.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 37d786a849..4f9b6c7da8 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -177,7 +177,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId while (1) { curChar = (*(const byte *)textPtr); if (_font->isDoubleByte(curChar)) { - curChar |= (*(const byte *)textPtr + 1) << 8; + curChar |= (*(const byte *)(textPtr + 1)) << 8; } switch (curChar) { case 0x7C: @@ -196,7 +196,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId // Sierra did it the same way. case 0xD: // Check, if 0xA is following, if so include it as well - if ((*(const byte *)textPtr + 1) == 0xA) { + if ((*(const byte *)(textPtr + 1)) == 0xA) { curCharCount++; textPtr++; } // it's meant to pass through here @@ -255,7 +255,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId curChar = (*(const byte *)textPtr); if (!_font->isDoubleByte(curChar)) error("Non double byte while seeking back"); - curChar |= (*(const byte *)textPtr + 1) << 8; + curChar |= (*(const byte *)(textPtr + 1)) << 8; } // But it also checked, if the current character is not inside a punctuation table and it even @@ -282,7 +282,7 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId curChar = (*(const byte *)textPtr); if (!_font->isDoubleByte(curChar)) error("Non double byte while seeking back"); - curChar |= (*(const byte *)textPtr + 1) << 8; + curChar |= (*(const byte *)(textPtr + 1)) << 8; } // include the current character curCharCount += 2; textPtr += 2; -- cgit v1.2.3 From 5aae18feb80ff7aa58ce6f7400d54673af58196b Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 13:08:33 +0100 Subject: SCI: text16 Shift-JIS font switch fixed fixes Police Quest 2 Japanese intro and others, where the internal SCI font was used and not the Shift-JIS hires font --- engines/sci/graphics/text16.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 4f9b6c7da8..3769cd3af9 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -362,12 +362,12 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId else fontId = previousFontId; - if (g_sci->getLanguage() == Common::JA_JPN) - SwitchToFont900OnSjis(text); - rect.top = rect.left = 0; if (maxWidth < 0) { // force output as single line + if (g_sci->getLanguage() == Common::JA_JPN) + SwitchToFont900OnSjis(text); + StringWidth(text, fontId, textWidth, textHeight); rect.bottom = textHeight; rect.right = textWidth; @@ -378,6 +378,10 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId const char *curTextPos = text; // in work position for GetLongest() const char *curTextLine = text; // starting point of current line while (*curTextPos) { + // We need to check for Shift-JIS every line + if (g_sci->getLanguage() == Common::JA_JPN) + SwitchToFont900OnSjis(curTextPos); + charCount = GetLongest(curTextPos, rect.right, fontId); if (charCount == 0) break; @@ -466,17 +470,19 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA else fontId = previousFontId; - if (g_sci->getLanguage() == Common::JA_JPN) { - if (SwitchToFont900OnSjis(text)) - doubleByteMode = true; - } - // Reset reference code rects _codeRefRects.clear(); _codeRefTempRect.left = _codeRefTempRect.top = -1; maxTextWidth = 0; while (*curTextPos) { + // We need to check for Shift-JIS every line + // Police Quest 2 PC-9801 often draws English + Japanese text during the same call + if (g_sci->getLanguage() == Common::JA_JPN) { + if (SwitchToFont900OnSjis(curTextPos)) + doubleByteMode = true; + } + charCount = GetLongest(curTextPos, rect.width(), fontId); if (charCount == 0) break; -- cgit v1.2.3 From 8ffd8793ed1f50872c572c6886a5e9100e8312e4 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 15:44:22 +0100 Subject: SCI: add support for \n and \r in Japanese text fixes Police Quest 2 Japanese intro thx to wjp for helping --- engines/sci/engine/state.cpp | 45 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 7701822f6d..1b7fa7699e 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -227,26 +227,53 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu // Japanese including Kanji, displayed with system font // Convert half-width characters to full-width equivalents Common::String fullWidth; - byte c; + byte curChar, curChar2; + uint16 mappedChar; + + seeker++; + + while (1) { + curChar = *(seeker); + + switch (curChar) { + case 0: // Terminator NUL + return fullWidth; + case '\\': + // "\n", "\N", "\r" and "\R" were overwritten with SPACE + 0x0D in PC-9801 SSCI + // inside GetLongest() (text16). We do it here, because it's much cleaner and + // we have to process the text here anyway. + // Occurs for example in Police Quest 2 intro + curChar2 = *(seeker + 1); + switch (curChar2) { + case 'n': + case 'N': + case 'r': + case 'R': + fullWidth += ' '; + fullWidth += 0x0D; // CR + seeker += 2; + continue; + } + } + + seeker++; - while ((c = *(++seeker))) { - uint16 mappedChar = s_halfWidthSJISMap[c]; + mappedChar = s_halfWidthSJISMap[curChar]; if (mappedChar) { fullWidth += mappedChar >> 8; fullWidth += mappedChar & 0xFF; } else { // Copy double-byte character - char c2 = *(++seeker); - if (!c2) { - error("SJIS character %02X is missing second byte", c); + curChar2 = *(seeker++); + if (!curChar) { + error("SJIS character %02X is missing second byte", curChar); break; } - fullWidth += c; - fullWidth += c2; + fullWidth += curChar; + fullWidth += curChar2; } } - return fullWidth; } else { return Common::String(seeker + 1); } -- cgit v1.2.3 From 11ba4474830ad0557de5a8c2b47dcd3000bc0032 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 19:31:37 +0100 Subject: SCI: bugfix in GetLongest() for Japanese SQ4 --- engines/sci/graphics/text16.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 3769cd3af9..c5c2054add 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -201,14 +201,17 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId } // it's meant to pass through here case 0xA: - case 0x9781: // this one is used by SQ4/japanese as line break as well - curCharCount++; textPtr++; - // and it's also meant to pass through here case 0: SetFont(previousFontId); _ports->penColor(previousPenColor); return curCharCount; + case 0x9781: // this one is used by SQ4/japanese as line break as well + curCharCount += 2; textPtr += 2; + SetFont(previousFontId); + _ports->penColor(previousPenColor); + return curCharCount; + case ' ': lastSpaceCharCount = curCharCount; // return count up to (but not including) breaking space lastSpacePtr = textPtr + 1; // remember position right after the current space -- cgit v1.2.3 From fa7a6d473e07d3bf2068bd58d3474e77634b0b30 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 19:37:23 +0100 Subject: SCI: GetClosest() bugfix the bugfix thx wjp --- engines/sci/graphics/text16.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index c5c2054add..7552cb89ef 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -201,13 +201,13 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId } // it's meant to pass through here case 0xA: - case 0: - SetFont(previousFontId); - _ports->penColor(previousPenColor); - return curCharCount; - case 0x9781: // this one is used by SQ4/japanese as line break as well - curCharCount += 2; textPtr += 2; + curCharCount++; textPtr++; + if (curChar > 0xFF) { + curCharCount++; textPtr++; + } + // and it's also meant to pass through here + case 0: SetFont(previousFontId); _ports->penColor(previousPenColor); return curCharCount; -- cgit v1.2.3 From 3f7566c7b183452a6203140b923d7e7a273369dd Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 2 Nov 2014 23:30:06 +0100 Subject: SCI: hoyle 4 workaround properly done (bug #6614) fixes placement of edit control caused by uninitialized reads --- engines/sci/engine/workarounds.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp index ea4dc2fe71..c5730b5345 100644 --- a/engines/sci/engine/workarounds.cpp +++ b/engines/sci/engine/workarounds.cpp @@ -91,7 +91,8 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = { { GID_HOYLE4, 700, -1, 1, "BridgeDefense", "think", -1, -1, { WORKAROUND_FAKE, 0 } }, // sometimes while playing bridge, temp var 3, 17 and others, objects LeadReturn_Trump, ThirdSeat_Trump and others { GID_HOYLE4, 700, 730, 1, "BridgeDefense", "beatTheirBest", -1, 3, { WORKAROUND_FAKE, 0 } }, // rarely while playing bridge { GID_HOYLE4, 700, -1, 1, "Code", "doit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when placing a bid in bridge (always), temp var 11, 24, 27, 46, 75, objects compete_tree, compwe_tree, other1_tree, b1 - bugs #5663 and #5794 - { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, -1, { WORKAROUND_FAKE, 0 } }, // when saving the game (may also occur in other situations) - bug #6601 + { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, 0, { WORKAROUND_FAKE, 118 } }, // when saving the game (may also occur in other situations) - bug #6601, bug #6614 + { GID_HOYLE4, 700, 921, 0, "Print", "addEdit", -1, 1, { WORKAROUND_FAKE, 1 } }, // see above, Text-control saves its coordinates to temp[0] and temp[1], Edit-control adjusts to those uninitialized temps, who by accident were left over from the Text-control { GID_HOYLE4, 300, 300, 0, "", "export 2", 0x1d4d, 0, { WORKAROUND_FAKE, 0 } }, // after passing around cards in hearts { GID_HOYLE4, 400, 400, 1, "GinHand", "calcRuns", -1, 4, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Gin Rummy (e.g. when knocking and placing a card) - bug #5665 { GID_HOYLE4, 500, 17, 1, "Character", "say", -1, 504, { WORKAROUND_FAKE, 0 } }, // sometimes while playing Cribbage (e.g. when the opponent says "Last Card") - bug #5662 -- cgit v1.2.3 From dfc3bcae20584b79f0b7ea2a6e4ccf0fed29797f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 2 Nov 2014 19:26:18 -0500 Subject: VIDEO: Separate AVI video and audio track reading Relying on the videos to have 'initial frames' for audio tracks is not the best way to handle AVI videos. Now videos without initial frames (or broken interleaving) will buffer properly. --- video/avi_decoder.cpp | 369 ++++++++++++++++++++++++++------------------------ video/avi_decoder.h | 16 ++- 2 files changed, 206 insertions(+), 179 deletions(-) diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index a5016632d6..7119c72f07 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -319,8 +319,25 @@ bool AVIDecoder::loadStream(Common::SeekableReadStream *stream) { return false; } - // Seek back to the start of the MOVI list - _fileStream->seek(_movieListStart); + // Create the status entries + uint32 index = 0; + for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, index++) { + TrackStatus status; + status.track = *it; + status.index = index; + status.chunkSearchOffset = _movieListStart; + + if ((*it)->getTrackType() == Track::kTrackTypeVideo) + _videoTracks.push_back(status); + else + _audioTracks.push_back(status); + } + + if (_videoTracks.size() != 1) { + warning("Unhandled AVI video track count: %d", _videoTracks.size()); + close(); + return false; + } // Check if this is a special Duck Truemotion video checkTruemotion1(); @@ -340,79 +357,138 @@ void AVIDecoder::close() { _indexEntries.clear(); memset(&_header, 0, sizeof(_header)); + + _videoTracks.clear(); + _audioTracks.clear(); } void AVIDecoder::readNextPacket() { - if ((uint32)_fileStream->pos() >= _movieListEnd) { - // Ugh, reached the end premature. - forceVideoEnd(); + // Shouldn't get this unless called on a non-open video + if (_videoTracks.empty()) return; - } - uint32 nextTag = _fileStream->readUint32BE(); - uint32 size = _fileStream->readUint32LE(); + // Get the video frame first + handleNextPacket(_videoTracks[0]); + + // Handle audio tracks next + for (uint32 i = 0; i < _audioTracks.size(); i++) + handleNextPacket(_audioTracks[i]); +} + +void AVIDecoder::handleNextPacket(TrackStatus &status) { + // If there's no more to search, bail out + if (status.chunkSearchOffset + 8 >= _movieListEnd) { + if (status.track->getTrackType() == Track::kTrackTypeVideo) { + // Horrible AVI video has a premature end + // Force the frame to be the last frame + debug(0, "Forcing end of AVI video"); + ((AVIVideoTrack *)status.track)->forceTrackEnd(); + } - if (_fileStream->eos()) { - // Also premature end. - forceVideoEnd(); return; } - if (nextTag == ID_LIST) { - // A list of audio/video chunks - int32 startPos = _fileStream->pos(); + // See if audio needs to be buffered and break out if not + if (status.track->getTrackType() == Track::kTrackTypeAudio && !shouldQueueAudio(status)) + return; - if (_fileStream->readUint32BE() != ID_REC) - error("Expected 'rec ' LIST"); + // Seek to where we shall start searching + _fileStream->seek(status.chunkSearchOffset); + + for (;;) { + // If there's no more to search, bail out + if ((uint32)_fileStream->pos() + 8 >= _movieListEnd) { + if (status.track->getTrackType() == Track::kTrackTypeVideo) { + // Horrible AVI video has a premature end + // Force the frame to be the last frame + debug(0, "Forcing end of AVI video"); + ((AVIVideoTrack *)status.track)->forceTrackEnd(); + } - size -= 4; // subtract list type + break; + } - // Decode chunks in the list - while (_fileStream->pos() < startPos + (int32)size) - readNextPacket(); + uint32 nextTag = _fileStream->readUint32BE(); + uint32 size = _fileStream->readUint32LE(); - return; - } else if (nextTag == ID_JUNK || nextTag == ID_IDX1) { - skipChunk(size); - return; - } + if (nextTag == ID_LIST) { + // A list of audio/video chunks + if (_fileStream->readUint32BE() != ID_REC) + error("Expected 'rec ' LIST"); - Track *track = getTrack(getStreamIndex(nextTag)); + continue; + } else if (nextTag == ID_JUNK || nextTag == ID_IDX1) { + skipChunk(size); + continue; + } - if (!track) - error("Cannot get track from tag '%s'", tag2str(nextTag)); + // Only accept chunks for this stream + uint32 streamIndex = getStreamIndex(nextTag); + if (streamIndex != status.index) { + skipChunk(size); + continue; + } - Common::SeekableReadStream *chunk = 0; + Common::SeekableReadStream *chunk = 0; - if (size != 0) { - chunk = _fileStream->readStream(size); - _fileStream->skip(size & 1); - } + if (size != 0) { + chunk = _fileStream->readStream(size); + _fileStream->skip(size & 1); + } - if (track->getTrackType() == Track::kTrackTypeAudio) { - if (getStreamType(nextTag) != kStreamTypeAudio) - error("Invalid audio track tag '%s'", tag2str(nextTag)); + if (status.track->getTrackType() == Track::kTrackTypeAudio) { + if (getStreamType(nextTag) != kStreamTypeAudio) + error("Invalid audio track tag '%s'", tag2str(nextTag)); - assert(chunk); - ((AVIAudioTrack *)track)->queueSound(chunk); - } else { - AVIVideoTrack *videoTrack = (AVIVideoTrack *)track; + assert(chunk); + ((AVIAudioTrack *)status.track)->queueSound(chunk); - if (getStreamType(nextTag) == kStreamTypePaletteChange) { - // Palette Change - videoTrack->loadPaletteFromChunk(chunk); + // Break out if we have enough audio + if (!shouldQueueAudio(status)) + break; } else { - // Otherwise, assume it's a compressed frame - videoTrack->decodeFrame(chunk); + AVIVideoTrack *videoTrack = (AVIVideoTrack *)status.track; + + if (getStreamType(nextTag) == kStreamTypePaletteChange) { + // Palette Change + videoTrack->loadPaletteFromChunk(chunk); + } else { + // Otherwise, assume it's a compressed frame + videoTrack->decodeFrame(chunk); + break; + } } } + + // Start us off in this position next time + status.chunkSearchOffset = _fileStream->pos(); +} + +bool AVIDecoder::shouldQueueAudio(TrackStatus& status) { + // Sanity check: + if (status.track->getTrackType() != Track::kTrackTypeAudio) + return false; + + // If video is done, make sure that the rest of the audio is queued + // (I guess this is also really a sanity check) + AVIVideoTrack *videoTrack = (AVIVideoTrack *)_videoTracks[0].track; + if (videoTrack->endOfTrack()) + return true; + + // Being three frames ahead should be enough for any video. + return ((AVIAudioTrack *)status.track)->getCurChunk() < (uint32)(videoTrack->getCurFrame() + 3); } bool AVIDecoder::rewind() { if (!VideoDecoder::rewind()) return false; - _fileStream->seek(_movieListStart); + for (uint32 i = 0; i < _videoTracks.size(); i++) + _videoTracks[i].chunkSearchOffset = _movieListStart; + + for (uint32 i = 0; i < _audioTracks.size(); i++) + _audioTracks[i].chunkSearchOffset = _movieListStart; + return true; } @@ -421,29 +497,9 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { if (time > getDuration()) return false; - // Track down our video track. - // We only support seeking with one video track right now. - AVIVideoTrack *videoTrack = 0; - int videoIndex = -1; - uint trackID = 0; - - for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, trackID++) { - if ((*it)->getTrackType() == Track::kTrackTypeVideo) { - if (videoTrack) { - // Already have one - // -> Not supported - return false; - } - - videoTrack = (AVIVideoTrack *)*it; - videoIndex = trackID; - } - } - - // Need a video track to go forwards - // If there isn't a video track, why would anyone be using AVI then? - if (!videoTrack) - return false; + // Get our video + AVIVideoTrack *videoTrack = (AVIVideoTrack *)_videoTracks[0].track; + uint32 videoIndex = _videoTracks[0].index; // If we seek directly to the end, just mark the tracks as over if (time == getDuration()) { @@ -464,7 +520,6 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { int lastKeyFrame = -1; int frameIndex = -1; - int lastRecord = -1; uint curFrame = 0; // Go through and figure out where we should be @@ -472,40 +527,40 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { for (uint32 i = 0; i < _indexEntries.size(); i++) { const OldIndex &index = _indexEntries[i]; - if (index.id == ID_REC) { - // Keep track of any records we find - lastRecord = i; - } else { - if (getStreamIndex(index.id) != videoIndex) - continue; + // We don't care about RECs + if (index.id == ID_REC) + continue; - uint16 streamType = getStreamType(index.id); + // We're only looking at entries for this track + if (getStreamIndex(index.id) != videoIndex) + continue; - if (streamType == kStreamTypePaletteChange) { - // We need to handle any palette change we see since there's no - // flag to tell if this is a "key" palette. - // Decode the palette - _fileStream->seek(_indexEntries[i].offset + 8); - Common::SeekableReadStream *chunk = 0; + uint16 streamType = getStreamType(index.id); - if (_indexEntries[i].size != 0) - chunk = _fileStream->readStream(_indexEntries[i].size); + if (streamType == kStreamTypePaletteChange) { + // We need to handle any palette change we see since there's no + // flag to tell if this is a "key" palette. + // Decode the palette + _fileStream->seek(_indexEntries[i].offset + 8); + Common::SeekableReadStream *chunk = 0; - videoTrack->loadPaletteFromChunk(chunk); - } else { - // Check to see if this is a keyframe - // The first frame has to be a keyframe - if ((_indexEntries[i].flags & AVIIF_INDEX) || curFrame == 0) - lastKeyFrame = i; - - // Did we find the target frame? - if (frame == curFrame) { - frameIndex = i; - break; - } + if (_indexEntries[i].size != 0) + chunk = _fileStream->readStream(_indexEntries[i].size); - curFrame++; + videoTrack->loadPaletteFromChunk(chunk); + } else { + // Check to see if this is a keyframe + // The first frame has to be a keyframe + if ((_indexEntries[i].flags & AVIIF_INDEX) || curFrame == 0) + lastKeyFrame = i; + + // Did we find the target frame? + if (frame == curFrame) { + frameIndex = i; + break; } + + curFrame++; } } @@ -513,57 +568,36 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { return false; // Update all the audio tracks - uint audioIndex = 0; - - for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, audioIndex++) { - if ((*it)->getTrackType() != Track::kTrackTypeAudio) - continue; - - AVIAudioTrack *audioTrack = (AVIAudioTrack *)*it; - - // We need to find where the start of audio should be. - // Which is exactly 'initialFrames' audio chunks back from where - // our found frame is. + for (uint32 i = 0; i < _audioTracks.size(); i++) { + AVIAudioTrack *audioTrack = (AVIAudioTrack *)_audioTracks[i].track; // Recreate the audio stream audioTrack->resetStream(); - uint framesNeeded = _header.initialFrames; - if (framesNeeded == 0) - framesNeeded = 1; + // Set the chunk index for the track + audioTrack->setCurChunk(frame); - uint startAudioChunk = 0; - int startAudioSearch = (lastRecord < 0) ? (frameIndex - 1) : (lastRecord - 1); + uint32 chunksFound = 0; + for (uint32 j = 0; j < _indexEntries.size(); j++) { + const OldIndex &index = _indexEntries[j]; - for (int i = startAudioSearch; i >= 0; i--) { - if (getStreamIndex(_indexEntries[i].id) != audioIndex) + // Continue ignoring RECs + if (index.id == ID_REC) continue; - assert(getStreamType(_indexEntries[i].id) == kStreamTypeAudio); - - framesNeeded--; + if (getStreamIndex(index.id) == _audioTracks[i].index) { + if (chunksFound == frame) { + _fileStream->seek(index.offset + 8); + Common::SeekableReadStream *audioChunk = _fileStream->readStream(index.size); + audioTrack->queueSound(audioChunk); + _audioTracks[i].chunkSearchOffset = (j == _indexEntries.size() - 1) ? _movieListEnd : _indexEntries[j + 1].offset; + break; + } - if (framesNeeded == 0) { - startAudioChunk = i; - break; + chunksFound++; } } - // Now go forward and queue them all - for (int i = startAudioChunk; i <= startAudioSearch; i++) { - if (_indexEntries[i].id == ID_REC) - continue; - - if (getStreamIndex(_indexEntries[i].id) != audioIndex) - continue; - - assert(getStreamType(_indexEntries[i].id) == kStreamTypeAudio); - - _fileStream->seek(_indexEntries[i].offset + 8); - Common::SeekableReadStream *chunk = _fileStream->readStream(_indexEntries[i].size); - audioTrack->queueSound(chunk); - } - // Skip any audio to bring us to the right time audioTrack->skipAudio(time, videoTrack->getFrameTime(frame)); } @@ -592,15 +626,11 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) { videoTrack->decodeFrame(chunk); } - // Seek to the right spot - // To the beginning of the last record, or frame if that doesn't exist - if (lastRecord >= 0) - _fileStream->seek(_indexEntries[lastRecord].offset); - else - _fileStream->seek(_indexEntries[frameIndex].offset); - + // Set the video track's frame videoTrack->setCurFrame((int)frame - 1); + // Set the video track's search offset to the right spot + _videoTracks[0].chunkSearchOffset = _indexEntries[frameIndex].offset; return true; } @@ -654,45 +684,22 @@ void AVIDecoder::readOldIndex(uint32 size) { } } -void AVIDecoder::forceVideoEnd() { - // Horrible AVI video has a premature end - // Force the frame to be the last frame - debug(0, "Forcing end of AVI video"); - - for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) - if ((*it)->getTrackType() == Track::kTrackTypeVideo) - ((AVIVideoTrack *)*it)->forceTrackEnd(); -} - void AVIDecoder::checkTruemotion1() { - AVIVideoTrack *track = 0; - - for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) { - if ((*it)->getTrackType() == Track::kTrackTypeVideo) { - if (track) { - // Multiple tracks; isn't going to be truemotion 1 - return; - } + // If we got here from loadStream(), we know the track is valid + assert(!_videoTracks.empty()); - track = (AVIVideoTrack *)*it; - } - } - - // No track found? - if (!track) - return; + TrackStatus &status = _videoTracks[0]; + AVIVideoTrack *track = (AVIVideoTrack *)status.track; // Ignore non-truemotion tracks if (!track->isTruemotion1()) return; - // Search for a non-empty frame - const Graphics::Surface *frame = 0; - for (int i = 0; i < 10 && !frame; i++) - frame = decodeNextFrame(); + // Read the next video packet + handleNextPacket(status); + const Graphics::Surface *frame = track->decodeNextFrame(); if (!frame) { - // Probably shouldn't happen rewind(); return; } @@ -809,7 +816,7 @@ void AVIDecoder::AVIVideoTrack::forceTrackEnd() { } AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) - : _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType) { + : _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType), _curChunk(0) { _audStream = createAudioStream(); } @@ -836,12 +843,12 @@ void AVIDecoder::AVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { _audStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMMSIma, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES); } else if (_wvInfo.tag == kWaveFormatDK3) { _audStream->queueAudioStream(Audio::makeADPCMStream(stream, DisposeAfterUse::YES, stream->size(), Audio::kADPCMDK3, _wvInfo.samplesPerSec, _wvInfo.channels, _wvInfo.blockAlign), DisposeAfterUse::YES); - } else if (_wvInfo.tag == kWaveFormatMP3) { - warning("AVI: MP3 audio stream is not supported"); } } else { delete stream; } + + _curChunk++; } void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime) { @@ -862,6 +869,7 @@ void AVIDecoder::AVIAudioTrack::skipAudio(const Audio::Timestamp &time, const Au void AVIDecoder::AVIAudioTrack::resetStream() { delete _audStream; _audStream = createAudioStream(); + _curChunk = 0; } bool AVIDecoder::AVIAudioTrack::rewind() { @@ -874,12 +882,17 @@ Audio::AudioStream *AVIDecoder::AVIAudioTrack::getAudioStream() const { } Audio::QueuingAudioStream *AVIDecoder::AVIAudioTrack::createAudioStream() { - if (_wvInfo.tag == kWaveFormatPCM || _wvInfo.tag == kWaveFormatMSADPCM || _wvInfo.tag == kWaveFormatMSIMAADPCM || _wvInfo.tag == kWaveFormatDK3 || _wvInfo.tag == kWaveFormatMP3) + if (_wvInfo.tag == kWaveFormatPCM || _wvInfo.tag == kWaveFormatMSADPCM || _wvInfo.tag == kWaveFormatMSIMAADPCM || _wvInfo.tag == kWaveFormatDK3) return Audio::makeQueuingAudioStream(_wvInfo.samplesPerSec, _wvInfo.channels == 2); + else if (_wvInfo.tag == kWaveFormatMP3) + warning("Unsupported AVI MP3 tracks"); else if (_wvInfo.tag != kWaveFormatNone) // No sound warning("Unsupported AVI audio format %d", _wvInfo.tag); return 0; } +AVIDecoder::TrackStatus::TrackStatus() : track(0), chunkSearchOffset(0) { +} + } // End of namespace Video diff --git a/video/avi_decoder.h b/video/avi_decoder.h index 4461e537c5..eef127155e 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -216,6 +216,8 @@ protected: Audio::Mixer::SoundType getSoundType() const { return _soundType; } void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime); void resetStream(); + uint32 getCurChunk() const { return _curChunk; } + void setCurChunk(uint32 chunk) { _curChunk = chunk; } bool isRewindable() const { return true; } bool rewind(); @@ -238,6 +240,15 @@ protected: Audio::Mixer::SoundType _soundType; Audio::QueuingAudioStream *_audStream; Audio::QueuingAudioStream *createAudioStream(); + uint32 _curChunk; + }; + + struct TrackStatus { + TrackStatus(); + + Track *track; + uint32 index; + uint32 chunkSearchOffset; }; AVIHeader _header; @@ -260,9 +271,12 @@ protected: void handleStreamHeader(uint32 size); uint16 getStreamType(uint32 tag) const { return tag & 0xFFFF; } byte getStreamIndex(uint32 tag) const; - void forceVideoEnd(); void checkTruemotion1(); + void handleNextPacket(TrackStatus& status); + bool shouldQueueAudio(TrackStatus& status); + Common::Array _videoTracks, _audioTracks; + public: virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo); }; -- cgit v1.2.3 From 124ac887fd491effed8db2b342f45d7c498c2d28 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 2 Nov 2014 20:45:38 -0500 Subject: VIDEO: Make AVIAudioTrack::resetStream() virtual In case a subclass (like Zork) needs to override it --- video/avi_decoder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/video/avi_decoder.h b/video/avi_decoder.h index eef127155e..8941ff4e75 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -215,7 +215,7 @@ protected: virtual void queueSound(Common::SeekableReadStream *stream); Audio::Mixer::SoundType getSoundType() const { return _soundType; } void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime); - void resetStream(); + virtual void resetStream(); uint32 getCurChunk() const { return _curChunk; } void setCurChunk(uint32 chunk) { _curChunk = chunk; } -- cgit v1.2.3 From f733498388267e1fb848eb758a2625c157a84857 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 01:08:15 +0200 Subject: GROOVIE: Finish implementation of o_hotspot_outrect This is needed by the main menu in the 11th Hour --- engines/groovie/script.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 7625151082..4f4e45ddd2 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -1595,8 +1595,7 @@ void Script::o_hotspot_outrect() { bool contained = rect.contains(mousepos); if (!contained) { - error("hotspot-outrect unimplemented"); - // TODO: what to do with address? + _currentInstruction = address; } } -- cgit v1.2.3 From 9d6437c01ef4e476fce47d37f4e879b39e830857 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 01:43:19 +0200 Subject: GROOVIE: Add initial full screen functionality for V2 games --- engines/groovie/graphics.cpp | 25 ++++++++++++++++++++++--- engines/groovie/graphics.h | 2 ++ engines/groovie/roq.cpp | 6 ++++++ engines/groovie/script.cpp | 20 +++++++++++--------- 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp index b85277fac7..e0c198f377 100644 --- a/engines/groovie/graphics.cpp +++ b/engines/groovie/graphics.cpp @@ -63,7 +63,7 @@ void GraphicsMan::update() { // Clear the buffer when ending the fade out if (_fading == 2) - _foreground.fillRect(Common::Rect(640, 320), 0); + _foreground.fillRect(Common::Rect(640, _foreground.h), 0); } } @@ -74,6 +74,22 @@ void GraphicsMan::update() { } } +void GraphicsMan::switchToFullScreen(bool fullScreen) { + _foreground.free(); + _background.free(); + + if (fullScreen) { + _foreground.create(640, 480, _vm->_pixelFormat); + _background.create(640, 480, _vm->_pixelFormat); + } else { + _vm->_system->fillScreen(0); + _foreground.create(640, 320, _vm->_pixelFormat); + _background.create(640, 320, _vm->_pixelFormat); + } + + _changed = true; +} + void GraphicsMan::change() { _changed = true; } @@ -84,7 +100,7 @@ void GraphicsMan::mergeFgAndBg() { countf = (byte *)_foreground.getPixels(); countb = (byte *)_background.getPixels(); - for (i = 640 * 320; i; i--) { + for (i = 640 * _foreground.h; i; i--) { if (255 == *(countf)) { *(countf) = *(countb); } @@ -94,7 +110,10 @@ void GraphicsMan::mergeFgAndBg() { } void GraphicsMan::updateScreen(Graphics::Surface *source) { - _vm->_system->copyRectToScreen(source->getPixels(), 640, 0, 80, 640, 320); + if (!isFullScreen()) + _vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 80, 640, 320); + else + _vm->_system->copyRectToScreen(source->getPixels(), source->pitch, 0, 0, 640, 480); change(); } diff --git a/engines/groovie/graphics.h b/engines/groovie/graphics.h index 72ab01deb6..69934f9d68 100644 --- a/engines/groovie/graphics.h +++ b/engines/groovie/graphics.h @@ -38,6 +38,8 @@ public: void update(); void change(); void mergeFgAndBg(); + void switchToFullScreen(bool fullScreen); + bool isFullScreen() { return (_foreground.h == 480); } void updateScreen(Graphics::Surface *source); Graphics::Surface _foreground; // The main surface that most things are drawn to Graphics::Surface _background; // Used occasionally, mostly (only?) in puzzles diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 379fcabc07..0c735962b6 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -277,6 +277,12 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { _prevBuf->create(width, height, _vm->_pixelFormat); } + // Switch from/to fullscreen, if needed + if (_bg->h != 480 && height == 480) + _vm->_graphicsMan->switchToFullScreen(true); + else if (_bg->h == 480 && height != 480) + _vm->_graphicsMan->switchToFullScreen(false); + // Clear the buffers with black _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 4f4e45ddd2..1d4ad0aec9 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -350,9 +350,10 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) { // Show hotspots when debugging if (DebugMan.isDebugChannelEnabled(kDebugHotspots)) { - rect.translate(0, -80); + if (!_vm->_graphicsMan->isFullScreen()) + rect.translate(0, -80); _vm->_graphicsMan->_foreground.frameRect(rect, 250); - _vm->_system->copyRectToScreen(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_foreground.pitch, 0, 80, 640, 320); + _vm->_graphicsMan->updateScreen(&_vm->_graphicsMan->_foreground); _vm->_system->updateScreen(); } @@ -962,7 +963,7 @@ void Script::o_strcmpnejmp_var() { // 0x21 void Script::o_copybgtofg() { // 0x22 debugC(1, kDebugScript, "COPY_BG_TO_FG"); - memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * 320); + memcpy(_vm->_graphicsMan->_foreground.getPixels(), _vm->_graphicsMan->_background.getPixels(), 640 * _vm->_graphicsMan->_foreground.h); } void Script::o_strcmpeqjmp() { // 0x23 @@ -1198,6 +1199,7 @@ void Script::o_copyrecttobg() { // 0x37 uint16 top = readScript16bits(); uint16 right = readScript16bits(); uint16 bottom = readScript16bits(); + uint16 baseTop = (!_vm->_graphicsMan->isFullScreen()) ? 80 : 0; // Sanity checks to prevent bad pointer access crashes if (left > right) { @@ -1216,9 +1218,9 @@ void Script::o_copyrecttobg() { // 0x37 bottom = top; top = j; } - if (top < 80) { - warning("COPYRECT top < 80... clamping"); - top = 80; + if (top < baseTop) { + warning("COPYRECT top < baseTop... clamping"); + top = baseTop; } if (top >= 480) { warning("COPYRECT top >= 480... clamping"); @@ -1243,13 +1245,13 @@ void Script::o_copyrecttobg() { // 0x37 debugC(1, kDebugScript, "COPYRECT((%d,%d)->(%d,%d))", left, top, right, bottom); - fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - 80); - bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - 80); + fg = (byte *)_vm->_graphicsMan->_foreground.getBasePtr(left, top - baseTop); + bg = (byte *)_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop); for (i = 0; i < height; i++) { memcpy(bg + offset, fg + offset, width); offset += 640; } - _vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - 80), 640, left, top, width, height); + _vm->_system->copyRectToScreen(_vm->_graphicsMan->_background.getBasePtr(left, top - baseTop), 640, left, top, width, height); _vm->_graphicsMan->change(); } -- cgit v1.2.3 From a82740516c9f973d8beaf1b11dd2f0a8a6beff5e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 11:33:33 +0200 Subject: GROOVIE: Implement o2_copyscreentobg and o2_copybgtoscreen --- engines/groovie/script.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 1d4ad0aec9..479ede5ff4 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -1671,15 +1671,29 @@ void Script::o2_vdxtransition() { void Script::o2_copyscreentobg() { uint16 val = readScript16bits(); + // TODO: Parameter + if (val) + warning("o2_copyscreentobg: Param is %d", val); + + Graphics::Surface *screen = _vm->_system->lockScreen(); + _vm->_graphicsMan->_background.copyFrom(screen->getSubArea(Common::Rect(0, 80, 640, 320))); + _vm->_system->unlockScreen(); + debugC(1, kDebugScript, "CopyScreenToBG3: 0x%04X", val); - error("Unimplemented Opcode 0x4F"); } void Script::o2_copybgtoscreen() { uint16 val = readScript16bits(); + // TODO: Parameter + if (val) + warning("o2_copybgtoscreen: Param is %d", val); + + Graphics::Surface *screen = _vm->_system->lockScreen(); + _vm->_graphicsMan->_background.copyRectToSurface(*screen, 0, 80, Common::Rect(0, 0, 640, 320 - 80)); + _vm->_system->unlockScreen(); + debugC(1, kDebugScript, "CopyBG3ToScreen: 0x%04X", val); - error("Unimplemented Opcode 0x50"); } void Script::o2_setvideoskip() { -- cgit v1.2.3 From 5dc03107fd86abb725eff6d9ea704267534d9dfe Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 11:36:25 +0200 Subject: GROOVIE: Add a stub for opcode 42 in V2 games This was o_cellmove in T7G (the Microscope puzzle) --- engines/groovie/script.cpp | 8 +++++++- engines/groovie/script.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index 479ede5ff4..c4091f6da7 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -1701,6 +1701,12 @@ void Script::o2_setvideoskip() { debugC(1, kDebugScript, "SetVideoSkip (0x%04X)", _videoSkipAddress); } +void Script::o2_stub42() { + uint8 arg = readScript8bits(); + // TODO: Switch with 5 cases (0 - 5). Anything above 5 is a NOP + debugC(1, kDebugScript, "STUB42 (0x%02X)", arg); +} + void Script::o2_stub52() { uint8 arg = readScript8bits(); debugC(1, kDebugScript, "STUB52 (0x%02X)", arg); @@ -1874,7 +1880,7 @@ Script::OpcodeFunc Script::_opcodesV2[NUM_OPCODES] = { &Script::o_loadscript, &Script::o_setvideoorigin, // 0x40 &Script::o_sub, - &Script::o_cellmove, + &Script::o2_stub42, &Script::o_returnscript, &Script::o_sethotspotright, // 0x44 &Script::o_sethotspotleft, diff --git a/engines/groovie/script.h b/engines/groovie/script.h index 35e52593de..a9f6143509 100644 --- a/engines/groovie/script.h +++ b/engines/groovie/script.h @@ -238,6 +238,7 @@ private: void o2_setvideoskip(); void o2_copyscreentobg(); void o2_copybgtoscreen(); + void o2_stub42(); void o2_stub52(); void o2_setscriptend(); }; -- cgit v1.2.3 From 35577ab71e8482ce629decb220b7df0cf0482d0f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 11:38:01 +0200 Subject: GROOVIE: Initial implementation of direct game load for the 11th Hour --- engines/groovie/script.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index c4091f6da7..eef97b6ff9 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -179,12 +179,20 @@ void Script::directGameLoad(int slot) { // TODO: Return to the main script, likely reusing most of o_returnscript() - // HACK: We set variable 0x19 to the slot to load, and set the current - // instruction to the one that actually loads the saved game specified - // in that variable. This will change in other versions of the game and - // in other games. - setVariable(0x19, slot); - _currentInstruction = 0x287; + // HACK: We set the slot to load in the appropriate variable, and set the + // current instruction to the one that actually loads the saved game + // specified in that variable. This differs depending on the game and its + // version. + if (_version == kGroovieT7G) { + // 7th Guest + setVariable(0x19, slot); + _currentInstruction = 0x287; + } else { + // 11th Hour + setVariable(0xF, slot); + // FIXME: This bypasses a lot of the game's initialization procedure + _currentInstruction = 0xE78E; + } // TODO: We'll probably need to start by running the beginning of the // script to let it do the soundcard initialization and then do the -- cgit v1.2.3 From 2d42ab88b714ba720971482b31378f9c985dfab7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 3 Nov 2014 12:41:37 +0200 Subject: GROOVIE: Fix video transparency in V2 games --- engines/groovie/roq.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 0c735962b6..065621e8e0 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -28,6 +28,7 @@ #include "groovie/groovie.h" #include "common/debug.h" +#include "common/debug-channels.h" #include "common/rect.h" #include "common/substream.h" #include "common/textconsole.h" @@ -63,6 +64,18 @@ ROQPlayer::~ROQPlayer() { } uint16 ROQPlayer::loadInternal() { + if (DebugMan.isDebugChannelEnabled(kDebugVideo)) { + int8 i; + debugN(1, "Groovie::ROQ: New ROQ: bitflags are "); + for (i = 15; i >= 0; i--) { + debugN(1, "%d", _flags & (1 << i)? 1 : 0); + if (i % 4 == 0) { + debugN(1, " "); + } + } + debug(1, " <- 0 "); + } + // Begin reading the file debugC(1, kDebugVideo, "Groovie::ROQ: Loading video"); @@ -106,13 +119,18 @@ uint16 ROQPlayer::loadInternal() { } void ROQPlayer::buildShowBuf() { + uint32 transparent = _alpha ? 0 : _vm->_pixelFormat.RGBToColor(255, 255, 255); + for (int line = 0; line < _bg->h; line++) { uint32 *out = (uint32 *)_bg->getBasePtr(0, line); uint32 *in = (uint32 *)_currBuf->getBasePtr(0, line / _scaleY); for (int x = 0; x < _bg->w; x++) { // Copy a pixel - *out++ = *in; + if (*in != transparent) + *out++ = *in; + else + out++; // Skip to the next pixel if (!(x % _scaleX)) -- cgit v1.2.3 From 3f21de4694080f07f7927afdc11c4093e523dd6f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 4 Nov 2014 10:08:07 +0600 Subject: ZVISION: Make ZorkAVIAudioTrack resetable --- engines/zvision/video/zork_avi_decoder.cpp | 4 ++++ engines/zvision/video/zork_avi_decoder.h | 1 + 2 files changed, 5 insertions(+) diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index e7624342e8..a9dc7765d4 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -55,4 +55,8 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s } } +void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() { + decoder->init(); +} + } // End of namespace ZVision diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index db1ad312c7..89c0d1e4b9 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -52,6 +52,7 @@ private: } void queueSound(Common::SeekableReadStream *stream); + void resetStream(); private: RawChunkStream *decoder; }; -- cgit v1.2.3 From d40caba5b748be38f2b6fe4c70af7eeccedd0ab8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 4 Nov 2014 10:09:27 +0600 Subject: ZVISION: If ZorkAVIAudioTrack got another format call AVIAudioTrack::queueSound --- engines/zvision/video/zork_avi_decoder.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index a9dc7765d4..415a20d3f2 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -48,10 +48,9 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s if (chunk.data) _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO); + } else { + AVIAudioTrack::queueSound(stream); } - } else { - warning("Got %d wave format in AVI\n", _wvInfo.tag); - delete stream; } } -- cgit v1.2.3 From be8cf9767470cc8ca9d35539b768817cf74b89c6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Tue, 4 Nov 2014 10:12:13 +0600 Subject: ZVISION: Implement settings functions --- engines/zvision/scripting/script_manager.cpp | 4 ++- engines/zvision/scripting/script_manager.h | 1 + engines/zvision/zvision.cpp | 52 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index fea3c2e199..d2165734b4 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -96,7 +96,7 @@ void ScriptManager::execScope(script_scope &scope) { for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) (*PuzzleIter)->addedBySetState = 0; - if (scope.proc_count < 2 || getStateValue(76)) { + if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) { for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) checkPuzzleCriteria(*PuzzleIter, scope.proc_count); } else { @@ -738,6 +738,8 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { // Place for read prefs _engine->setRenderDelay(10); setStateValue(StateKey_RestoreFlag, 1); + + _engine->loadSettings(); } Location ScriptManager::getCurrentLocation() const { diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 219cff9f45..3fcbad5fa4 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -86,6 +86,7 @@ enum StateKey { StateKey_ShowErrorDlg = 73, StateKey_DebugCheats = 74, StateKey_JapanFonts = 75, + StateKey_ExecScopeStyle = 76, StateKey_Brightness = 77, StateKey_EF9_R = 91, StateKey_EF9_G = 92, diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 0bc5fef39a..77c47d9b1e 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -54,6 +54,32 @@ namespace ZVision { +#define ZVISION_SETTINGS_KEYS_COUNT 17 + +struct zvisionIniSettings { + const char *name; + int16 slot; + int16 deflt; +} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { + {"ZVision_KeyboardTurnSpeed", StateKey_KbdRotateSpeed, 5}, + {"ZVision_PanaRotateSpeed", StateKey_RotateSpeed, 540}, + {"ZVision_QSoundEnabled", StateKey_Qsound, 1}, + {"ZVision_VenusEnabled", StateKey_VenusEnable, 1}, + {"ZVision_HighQuality", StateKey_HighQuality, 1}, + {"ZVision_Platform", StateKey_Platform, 0}, + {"ZVision_InstallLevel", StateKey_InstallLevel, 0}, + {"ZVision_CountryCode", StateKey_CountryCode, 0}, + {"ZVision_CPU", StateKey_CPU, 1}, + {"ZVision_MovieCursor", StateKey_MovieCursor, 1}, + {"ZVision_NoAnimWhileTurning", StateKey_NoTurnAnim, 0}, + {"ZVision_Win958", StateKey_WIN958, 0}, + {"ZVision_ShowErrorDialogs", StateKey_ShowErrorDlg, 0}, + {"ZVision_ShowSubtitles", StateKey_Subtitles, 1}, + {"ZVision_DebugCheats", StateKey_DebugCheats, 0}, + {"ZVision_JapaneseFonts", StateKey_JapanFonts, 0}, + {"ZVision_Brightness", StateKey_Brightness, 0} +}; + ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), @@ -93,6 +119,28 @@ ZVision::~ZVision() { DebugMan.clearAllDebugChannels(); } +void ZVision::registerDefaultSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].deflt); + ConfMan.registerDefault("doublefps", false); +} + +void ZVision::loadSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) + _scriptManager->setStateValue(settingsKeys[i].slot, ConfMan.getInt(settingsKeys[i].name)); + + if (getGameId() == GID_NEMESIS) + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); + else + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0); +} + +void ZVision::saveSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) + ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); + ConfMan.flushToDisk(); +} + void ZVision::initialize() { const Common::FSNode gameDataDir(ConfMan.get("path")); @@ -171,6 +219,10 @@ void ZVision::initialize() { _scriptManager->initialize(); _stringManager->initialize(_gameDescription->gameId); + registerDefaultSettings(); + + loadSettings(); + // Create debugger console. It requires GFX to be initialized _console = new Console(this); _halveDelay = ConfMan.getBool("doublefps"); -- cgit v1.2.3 From 70fe89b92d81bcdbc827c4467e508b3ad3d26051 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Nov 2014 11:51:13 +0200 Subject: GROOVIE: More work on transparency in the puzzle scenes for V2 games This fixes most of the transparency issues in the puzzle screens. They are still not correct, as the relevant videos play completely, instead of showing a single frame. This also fixes issues with commit 2d42ab8 --- engines/groovie/roq.cpp | 23 ++++++++++++++--------- engines/groovie/roq.h | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 065621e8e0..34689d8aa2 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -47,6 +47,7 @@ namespace Groovie { ROQPlayer::ROQPlayer(GroovieEngine *vm) : VideoPlayer(vm), _codingTypeCount(0), + _fg(&_vm->_graphicsMan->_foreground), _bg(&_vm->_graphicsMan->_background), _firstFrame(true) { @@ -119,18 +120,19 @@ uint16 ROQPlayer::loadInternal() { } void ROQPlayer::buildShowBuf() { - uint32 transparent = _alpha ? 0 : _vm->_pixelFormat.RGBToColor(255, 255, 255); + if (_alpha) + _fg->copyFrom(*_bg); for (int line = 0; line < _bg->h; line++) { - uint32 *out = (uint32 *)_bg->getBasePtr(0, line); + uint32 *out = _alpha ? (uint32 *)_fg->getBasePtr(0, line) : (uint32 *)_bg->getBasePtr(0, line); uint32 *in = (uint32 *)_currBuf->getBasePtr(0, line / _scaleY); for (int x = 0; x < _bg->w; x++) { - // Copy a pixel - if (*in != transparent) - *out++ = *in; - else + // Copy a pixel, checking the alpha channel first + if (_alpha && !(*in & 0xFF)) out++; + else + *out++ = *in; // Skip to the next pixel if (!(x % _scaleX)) @@ -167,7 +169,8 @@ bool ROQPlayer::playFrameInternal() { if (_dirty) { // Update the screen - _syst->copyRectToScreen(_bg->getPixels(), _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h); + void *src = (_alpha) ? _fg->getPixels() : _bg->getPixels(); + _syst->copyRectToScreen(src, _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h); _syst->updateScreen(); // Clear the dirty flag @@ -302,8 +305,10 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) { _vm->_graphicsMan->switchToFullScreen(false); // Clear the buffers with black - _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); - _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); + if (!_alpha) { + _currBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); + _prevBuf->fillRect(Common::Rect(width, height), _vm->_pixelFormat.RGBToColor(0, 0, 0)); + } return true; } diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h index 7e7d38580e..3a85517f59 100644 --- a/engines/groovie/roq.h +++ b/engines/groovie/roq.h @@ -75,7 +75,7 @@ private: byte _codebook4[256 * 4]; // Buffers - Graphics::Surface *_bg; + Graphics::Surface *_fg, *_bg; Graphics::Surface *_currBuf, *_prevBuf; void buildShowBuf(); byte _scaleX, _scaleY; -- cgit v1.2.3 From d8e650b4cbfd76ed448e5ebc2caab3db5b1d1d55 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Nov 2014 11:52:09 +0200 Subject: GROOVIE: Handle flag 2 for V2 games (show a whole overlay video) --- engines/groovie/roq.cpp | 9 +++++++-- engines/groovie/roq.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 34689d8aa2..1996181571 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -77,6 +77,10 @@ uint16 ROQPlayer::loadInternal() { debug(1, " <- 0 "); } + // Flags: + // - 2 For overlay videos, show the whole video + _flagTwo = ((_flags & (1 << 2)) != 0); + // Begin reading the file debugC(1, kDebugVideo, "Groovie::ROQ: Loading video"); @@ -177,8 +181,9 @@ bool ROQPlayer::playFrameInternal() { _dirty = false; } - // Return whether the video has ended - return _file->eos(); + // Report the end of the video if we reached the end of the file or if we + // just wanted to play one frame. + return _file->eos() || (_alpha && !_flagTwo); } bool ROQPlayer::readBlockHeader(ROQBlockHeader &blockHeader) { diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h index 3a85517f59..b720e6a235 100644 --- a/engines/groovie/roq.h +++ b/engines/groovie/roq.h @@ -74,6 +74,9 @@ private: uint32 _codebook2[256 * 4]; byte _codebook4[256 * 4]; + // Flags + bool _flagTwo; + // Buffers Graphics::Surface *_fg, *_bg; Graphics::Surface *_currBuf, *_prevBuf; -- cgit v1.2.3 From c9a60233d587fd67ec00aeb494e8a7c1df4d2a3f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Nov 2014 12:40:08 +0200 Subject: GROOVIE: More bugfixes for V2 puzzle overlay videos --- engines/groovie/roq.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 1996181571..49d6158973 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -169,7 +169,9 @@ bool ROQPlayer::playFrameInternal() { } // Wait until the current frame can be shown - waitFrame(); + // Don't wait if we're just showing one frame + if (!(_alpha && !_flagTwo)) + waitFrame(); if (_dirty) { // Update the screen @@ -177,6 +179,10 @@ bool ROQPlayer::playFrameInternal() { _syst->copyRectToScreen(src, _bg->pitch, 0, (_syst->getHeight() - _bg->h) / 2, _bg->w, _bg->h); _syst->updateScreen(); + // For overlay videos, set the background buffer when the video ends + if (_alpha && (!_flagTwo || (_flagTwo && _file->eos()))) + _bg->copyFrom(*_fg); + // Clear the dirty flag _dirty = false; } -- cgit v1.2.3 From 028238ed5481838828652d43e647d317641745fe Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Nov 2014 12:57:58 +0200 Subject: GROOVIE: Handle transparency in Gamepad videos in the 11th Hour --- engines/groovie/roq.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 49d6158973..8f272d4404 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -135,6 +135,10 @@ void ROQPlayer::buildShowBuf() { // Copy a pixel, checking the alpha channel first if (_alpha && !(*in & 0xFF)) out++; + else if (_fg->h == 480 && *in == _vm->_pixelFormat.RGBToColor(255, 255, 255)) + // Handle transparency in Gamepad videos + // TODO: For now, we detect these videos by checking for full screen + out++; else *out++ = *in; -- cgit v1.2.3 From dfe465e26ba88b850644979cbd9835d296fca728 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sun, 26 Oct 2014 22:57:28 +0100 Subject: WINTERMUTE: Introduce WMEGameDescription I aped what has been done with AGS: in engines/agi/detection.cpp, adding a struct that includes ADGameDescription at the beginning. This is also recommended in advancedDetector.h --- engines/wintermute/base/base_engine.cpp | 3 +- engines/wintermute/base/base_engine.h | 9 +- engines/wintermute/detection.cpp | 6 +- engines/wintermute/detection_tables.h | 2801 +++++++++++++++++-------------- engines/wintermute/game_description.h | 53 + engines/wintermute/wintermute.cpp | 4 +- engines/wintermute/wintermute.h | 5 +- 7 files changed, 1647 insertions(+), 1234 deletions(-) create mode 100644 engines/wintermute/game_description.h diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 7c2e9c8468..2166a3e070 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -61,10 +61,11 @@ BaseEngine::~BaseEngine() { delete _classReg; } -void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang) { +void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable) { instance()._targetName = targetName; instance()._gameId = gameId; instance()._language = lang; + instance()._targetExecutable = targetExecutable; instance().init(); } diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index dd82cf9c29..0f4a6b0775 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -34,6 +34,8 @@ #include "common/random.h" #include "common/language.h" +#include "engines/wintermute/game_description.h" + namespace Wintermute { class BaseFileManager; @@ -53,10 +55,12 @@ class BaseEngine : public Common::Singleton { Common::RandomSource *_rnd; SystemClassRegistry *_classReg; Common::Language _language; + WMETargetExecutable _targetExecutable; public: BaseEngine(); ~BaseEngine(); - static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang); + static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang, WMETargetExecutable targetExecutable = LATEST_VERSION); + void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } Common::RandomSource *getRandomSource() { return _rnd; } @@ -73,6 +77,9 @@ public: const char *getGameTargetName() const { return _targetName.c_str(); } Common::String getGameId() const { return _gameId; } Common::Language getLanguage() const { return _language; } + WMETargetExecutable getTargetExecutable() const { + return _targetExecutable; + } }; } // End of namespace Wintermute diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index a659c434d0..aca682ae99 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -74,7 +74,7 @@ static const char *directoryGlobs[] = { class WintermuteMetaEngine : public AdvancedMetaEngine { public: - WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(ADGameDescription), Wintermute::wintermuteGames, gameGuiOptions) { + WintermuteMetaEngine() : AdvancedMetaEngine(Wintermute::gameDescriptions, sizeof(WMEGameDescription), Wintermute::wintermuteGames, gameGuiOptions) { _singleid = "wintermute"; _guioptions = GUIO2(GUIO_NOMIDI, GAMEOPTION_SHOW_FPS); _maxScanDepth = 2; @@ -127,8 +127,8 @@ public: virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { assert(syst); assert(engine); - - *engine = new Wintermute::WintermuteEngine(syst, desc); + const WMEGameDescription *gd = (const WMEGameDescription *)desc; + *engine = new Wintermute::WintermuteEngine(syst, gd); return true; } diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index 8206ca9643..98bf3c1136 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -90,1341 +90,1692 @@ static const PlainGameDescriptor wintermuteGames[] = { {0, 0} }; -static const ADGameDescription gameDescriptions[] = { - // Five Lethal Demons - { - "5ld", - "", - AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Five Magical Amulets - { - "5ma", - "", - AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Actual Destination - { - "actualdest", - "", - AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Boredom of Agustin Cordes - { - "agustin", - "", - AD_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Beyond the Threshold - { - "bthreshold", - "", - AD_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Bickadoodle - { - "bickadoodle", - "", - AD_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Bickadoodle (Ver 1.1) - { - "bickadoodle", - "Version 1.1", - AD_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/) - { - "bickadoodle", - "", - AD_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Book of Gron Part One - { - "bookofgron", - "", - AD_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Carol Reed 4 - East Side Story (Demo) - { - "carolreed4", - "Demo", - AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Carol Reed 4 - East Side Story - { - "carolreed4", - "", - AD_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Carol Reed 5 - The Colour of Murder - { - "carolreed5", - "", - AD_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Carol Reed 6 - Black Circle - { - "carolreed6", - "", - AD_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Carol Reed 7 - Blue Madonna (Demo) - { - "carolreed7", - "Demo", - AD_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Carol Reed 7 - Blue Madonna - { - "carolreed7", - "", - AD_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Carol Reed 8 - Amber's Blood - { - "carolreed8", - "", - AD_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Carol Reed 9 - Cold Case Summer - { - "carolreed9", - "", - AD_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Chivalry is Not Dead - { - "chivalry", - "", - AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - // Chivalry is Not Dead (Version from deirdrakai.com) - { - "chivalry", - "", - AD_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - // Conspiracao Dumont - { - "conspiracao", - "", - AD_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Corrosion: Cold Winter Waiting - { - "corrosion", - "", - AD_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - // Dead City (Czech) - { - "deadcity", - "", - { - // The Czech data are in data.dcp, so in this case we'll have to - // just detect the english version twice, to give the user a choice. - {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Dead City (English) - { - "deadcity", - "", - { - {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Dead City (Italian) - { - "deadcity", - "", +static const WMEGameDescription gameDescriptions[] = { + { + // Five Lethal Demons + { + "5ld", + "", + AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Five Magical Amulets + { + "5ma", + "", + AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + WME_1_7_0 + }, + { + // Actual Destination + { + "actualdest", + "", + AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Boredom of Agustin Cordes + { + "agustin", + "", + AD_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Beyond the Threshold + { + "bthreshold", + "", + AD_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Bickadoodle + { + "bickadoodle", + "", + AD_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Bickadoodle (Ver 1.1) + { + "bickadoodle", + "Version 1.1", + AD_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/) + { + "bickadoodle", + "", + AD_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Book of Gron Part One + { + "bookofgron", + "", + AD_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 4 - East Side Story (Demo) + { + "carolreed4", + "Demo", + AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 4 - East Side Story + { + "carolreed4", + "", + AD_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 5 - The Colour of Murder + { + "carolreed5", + "", + AD_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 6 - Black Circle + { + "carolreed6", + "", + AD_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 7 - Blue Madonna (Demo) + { + "carolreed7", + "Demo", + AD_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 7 - Blue Madonna + { + "carolreed7", + "", + AD_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 8 - Amber's Blood + { + "carolreed8", + "", + AD_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Carol Reed 9 - Cold Case Summer + { + "carolreed9", + "", + AD_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Chivalry is Not Dead + { + "chivalry", + "", + AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_TESTING, + GUIO0() + }, + LATEST_VERSION + }, + { + // Chivalry is Not Dead (Version from deirdrakai.com) + { + "chivalry", + "", + AD_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_TESTING, + GUIO0() + }, + LATEST_VERSION + }, + { + // Conspiracao Dumont + { + "conspiracao", + "", + AD_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Corrosion: Cold Winter Waiting + { + "corrosion", + "", + AD_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_TESTING, + GUIO0() + }, + LATEST_VERSION + }, + { + // Dead City (Czech) + { + "deadcity", + "", + { + // The Czech data are in data.dcp, so in this case we'll have to + // just detect the english version twice, to give the user a choice. + {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Dead City (English) { - {"italian.dcp", 0, "92d8efb94436bec7bd1b7fe0b548192e", 454037}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND + "deadcity", + "", + { + {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Dead City (Russian) { - "deadcity", - "", + // Dead City (Italian) { - {"russian.dcp", 0, "a0ae71e9e1185596fffb07ad2c951eb9", 653317}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND + "deadcity", + "", + { + {"italian.dcp", 0, "92d8efb94436bec7bd1b7fe0b548192e", 454037}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Dirty Split (Czech) - { - "dirtysplit", - "", + { + // Dead City (Russian) + { + "deadcity", + "", + { + {"russian.dcp", 0, "a0ae71e9e1185596fffb07ad2c951eb9", 653317}, + {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, + AD_LISTEND + }, + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Dirty Split (Czech) { - {"czech.dcp", 0, "08a71446467cf8f9444cfea446b46ad6", 127697934}, - {"data.dcp", 0, "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623}, + "dirtysplit", + "", + { + {"czech.dcp", 0, "08a71446467cf8f9444cfea446b46ad6", 127697934}, + {"data.dcp", 0, "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623}, + }, + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Dirty Split (English) { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + // Dirty Split (English) + { + "dirtysplit", + "", + AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION }, - // Dirty Split (French) { - "dirtysplit", - "", + // Dirty Split (French) { - {"french.dcp", 0, "a0508dedebd0fe478d0158fa4c2a1136", 125534323}, - {"data.dcp", 0, "e6d70c7f5d181b761cfcf974adf9186a", 88577623}, - AD_LISTEND + "dirtysplit", + "", + { + {"french.dcp", 0, "a0508dedebd0fe478d0158fa4c2a1136", 125534323}, + {"data.dcp", 0, "e6d70c7f5d181b761cfcf974adf9186a", 88577623}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Dirty Split (German) { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + // Dirty Split (German) + { + "dirtysplit", + "", + AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION }, - // Dirty Split (Italian) { - "dirtysplit", - "", + // Dirty Split (Italian) { - {"italian.dcp", 0, "8108807fbd8af70be1ec452d0fd1131b", 125513726}, - {"data.dcp", 0, "35a150e22af274185883fdbb142c6fb1", 88577623}, + "dirtysplit", + "", + { + {"italian.dcp", 0, "8108807fbd8af70be1ec452d0fd1131b", 125513726}, + {"data.dcp", 0, "35a150e22af274185883fdbb142c6fb1", 88577623}, + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Dirty Split (Spanish) { - "dirtysplit", - "", - { - {"spanish.dcp", 0, "b3982c0a5e85b42e1e38240fef004aa4", 164428596}, - {"data.dcp", 0, "63766d6c68b9f00b632ea1736fc8a95c", 88577621}, - }, - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Des Reves Elastiques Avec Mille Insectes Nommes Georges - { - "dreaming", - "", - AD_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Dreamscape - { - "dreamscape", - "", - AD_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Escape from the Mansion - { - "escapemansion", - "Beta 1", - AD_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Escape from the Mansion - { - "escapemansion", - "Beta 2", - AD_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Escape from the Mansion - { - "escapemansion", - "1.3", - AD_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Four - { - "four", - "", - AD_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Framed - { - "framed", - "", - AD_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Ghost in the Sheet - { - "ghostsheet", - "", - { - {"english.dcp", 0, "e6d0aad2c89996bcabe416105a3d6d3a", 12221017}, - {"data.dcp", 0, "b2f8b05328e4881e15e98e845b63f451", 168003}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Ghost in the Sheet (Demo) - { - "ghostsheet", - "Demo", - AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Hamlet or the last game without MMORPS features, shaders and product placement - { - "hamlet", - "", - AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Helga Deep In Trouble (English) - { - "helga", - "", - { - {"english.dcp", 0, "bfa136b21bdbc7d8691c0770a6d40bc3", 135931}, - {"data.dcp", 0, "25cb955a60b58326f2eeda1ce288fb37", 183251259}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Helga Deep In Trouble (Demo) (English) - { - "helga", - "Demo", - { - {"english.dcp", 0, "b3a93e678f0ef97200f691cd1724643f", 135864}, - {"data.dcp", 0, "45134ed93bc391edf148b79cdcbf2a09", 154266028}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // James Peris: No License Nor Control (English) - { - "jamesperis", - "", - AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // James Peris: No License Nor Control (Spanish) - { - "jamesperis", - "", - AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // James Peris: No License Nor Control (Demo) (English) - { - "jamesperis", - "Demo", - AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // James Peris: No License Nor Control (Demo) (Spanish) - { - "jamesperis", - "Demo", - AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // J.U.L.I.A. (English) - { - "julia", - "", - AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // J.U.L.I.A. (English, Bundle in a box-version) - { - "julia", - "Version 1.2", - AD_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // J.U.L.I.A. (English) (Demo) - { - "julia", - "Demo", - AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // J.U.L.I.A. (English) (Greenlight Demo) - { - "julia", - "Greenlight Demo", - AD_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Kulivocko (Czech) - { - "kulivocko", - "", - AD_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Kulivocko (Czech) (Demo) - { - "kulivocko", - "Demo", - AD_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Life In 3 Minutes - { - "lifein3minutes", - "", - AD_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Looky Demo (English) - { - "looky", - "Demo", - { - {"english.dcp", 0, "1388e1dd320f4d553dea3b0316812f9d", 1358442}, - {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Looky Demo (German) - { - "looky", - "Demo", - { - {"german.dcp", 0, "606c048426dfbe94442b59fd34a5c76e", 14339496}, - {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Looky (German) - { - "looky", - "", - { - {"german.dcp", 0, "bf4c2b8c26342342441a6d64934ab832", 107027865}, - {"data.dcp", 0, "50de0beaa5ad621aa9f020df901d1e74", 1342214}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Mirage - { - "mirage", - "", - AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Oknytt - { - "oknytt", - "Version 1.0", - AD_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Night Train Demo - { - "nighttrain", - "", - AD_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Paintaria - { - "paintaria", - "", - AD_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Pigeons in the Park - { - "pigeons", - "", - AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Project: Doom - { - "projectdoom", - "", - AD_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Project Joe - { - "projectjoe", - "", - AD_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Project Lonely Robot - { - "lonelyrobot", - "beta", - AD_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Reversion: The Escape Version 1.0 - { - "reversion1", - "Version 1.0", - AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Reversion: The Escape Version 1.1 (Chinese) - { - "reversion1", - "Version 1.1", - { - {"chinese.dcp", 0, "cf97150739499a4c15f51dc534ff85a1", 6330561}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + // Dirty Split (Spanish) + { + "dirtysplit", + "", + { + {"spanish.dcp", 0, "b3982c0a5e85b42e1e38240fef004aa4", 164428596}, + {"data.dcp", 0, "63766d6c68b9f00b632ea1736fc8a95c", 88577621}, + }, + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Des Reves Elastiques Avec Mille Insectes Nommes Georges + { + "dreaming", + "", + AD_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Dreamscape + { + "dreamscape", + "", + AD_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Escape from the Mansion + { + "escapemansion", + "Beta 1", + AD_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION }, - // Reversion: The Escape Version 1.1 (English) { - "reversion1", - "Version 1.1", + // Escape from the Mansion { - {"english.dcp", 0, "7b2f061d7c91365c5d04605f1de032b3", 5702699}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "escapemansion", + "Beta 2", + AD_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.1 (French) { - "reversion1", - "Version 1.1", + // Escape from the Mansion { - {"french.dcp", 0, "214204b6022c5ed67fada44557690faf", 6327400}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "escapemansion", + "1.3", + AD_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.1 (German) { - "reversion1", - "Version 1.1", + // Four { - {"german.dcp", 0, "96677823b36d580a4a29e3659071071c", 6340699}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "four", + "", + AD_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.1 (Italian) { - "reversion1", - "Version 1.1", + // Framed { - {"italian.dcp", 0, "9ce80c1835108f10170a02969f71efe1", 6301836}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "framed", + "", + AD_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.1 (Portuguese) { - "reversion1", - "Version 1.1", + // Ghost in the Sheet { - {"portugues.dcp", 0, "8772501afa2c630a7c697eb99e9c7bda", 5053303}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "ghostsheet", + "", + { + {"english.dcp", 0, "e6d0aad2c89996bcabe416105a3d6d3a", 12221017}, + {"data.dcp", 0, "b2f8b05328e4881e15e98e845b63f451", 168003}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (Chinese) { - "reversion1", - "Version 1.3", + // Ghost in the Sheet (Demo) { - {"xlanguage_nz.dcp", 0, "92c4065156e464211685bf799b3279fd", 5130600}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "ghostsheet", + "Demo", + AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (English) { - "reversion1", - "Version 1.3", + // Hamlet or the last game without MMORPS features, shaders and product placement { - {"xlanguage_en.dcp", 0, "05845e1283920a6e4044f2a54f7a9519", 4818543}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "hamlet", + "", + AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (French) { - "reversion1", - "Version 1.3", + // Helga Deep In Trouble (English) { - {"xlanguage_fr.dcp", 0, "441795490e9307eb2ed07830779881ac", 5425959}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "helga", + "", + { + {"english.dcp", 0, "bfa136b21bdbc7d8691c0770a6d40bc3", 135931}, + {"data.dcp", 0, "25cb955a60b58326f2eeda1ce288fb37", 183251259}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (German) { - "reversion1", - "Version 1.3", + // Helga Deep In Trouble (Demo) (English) { - {"xlanguage_de.dcp", 0, "b588041015b93e54b4c246ca77d01e76", 5423798}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "helga", + "Demo", + { + {"english.dcp", 0, "b3a93e678f0ef97200f691cd1724643f", 135864}, + {"data.dcp", 0, "45134ed93bc391edf148b79cdcbf2a09", 154266028}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (Italian) { - "reversion1", - "Version 1.3", + // James Peris: No License Nor Control (English) { - {"xlanguage_it.dcp", 0, "a1f4199079b75ee10cded41f05b45d5f", 5386424}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "jamesperis", + "", + AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3 (Portuguese) { - "reversion1", - "Version 1.3", + // James Peris: No License Nor Control (Spanish) { - {"xlanguage_pt.dcp", 0, "3d653debd37e56756a79401e1004c4d2", 4149165}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND + "jamesperis", + "", + AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (Chinese) { - "reversion1", - "Version 1.3.2369", + // James Peris: No License Nor Control (Demo) (English) { - {"xlanguage_nz.dcp", 0, "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "jamesperis", + "Demo", + AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (English) { - "reversion1", - "Version 1.3.2369", + // James Peris: No License Nor Control (Demo) (Spanish) { - {"xlanguage_en.dcp", 0, "64b6fa7eedc09c231f6ce046e77fee05", 11339619}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "jamesperis", + "Demo", + AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (French) { - "reversion1", - "Version 1.3.2369", + // J.U.L.I.A. (English) { - {"xlanguage_fr.dcp", 0, "d561d562224afea809153a1fd9fdb0c0", 11963210}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "julia", + "", + AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (German) { - "reversion1", - "Version 1.3.2369", + // J.U.L.I.A. (English, Bundle in a box-version) { - {"xlanguage_de.dcp", 0, "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "julia", + "Version 1.2", + AD_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (Italian) { - "reversion1", - "Version 1.3.2369", + // J.U.L.I.A. (English) (Demo) { - {"xlanguage_it.dcp", 0, "10d09b7fe61946f09dd91d5e8d090f94", 11913752}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "julia", + "Demo", + AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (Latvian) { - "reversion1", - "Version 1.3.2369", + // J.U.L.I.A. (English) (Greenlight Demo) { - {"xlanguage_lv.dcp", 0, "704359ab5040b0dab6545064d7aa6eb9", 11414925}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "julia", + "Greenlight Demo", + AD_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::LV_LAT, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (Polish) { - "reversion1", - "Version 1.3.2369", + // Kulivocko (Czech) { - {"xlanguage_pl.dcp", 0, "c4ad33f57e1e998169552d521c1d6638", 11532215}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "kulivocko", + "", + AD_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::PL_POL, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Escape Version 1.3.2369 (Portuguese) { - "reversion1", - "Version 1.3.2369", + // Kulivocko (Czech) (Demo) { - {"xlanguage_pt.dcp", 0, "886886b6b14aadac844078de856799a6", 10620797}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND + "kulivocko", + "Demo", + AD_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), + Common::CZ_CZE, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Meeting (Chinese) { - "reversion2", - "", + // Life In 3 Minutes { - {"xlanguage_nz.dcp", 0, "8c3709474a87a7876109025dff41ff3f", 8746015}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND + "lifein3minutes", + "", + AD_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Meeting (English) { - "reversion2", - "", + // Looky Demo (English) { - {"xlanguage_en.dcp", 0, "ca357d86618d1ab76a21c913f4403cbd", 8414976}, - {"data.dcp", 0, "f7938cbfdc48f07934550245a3286921", 255672016}, - AD_LISTEND + "looky", + "Demo", + { + {"english.dcp", 0, "1388e1dd320f4d553dea3b0316812f9d", 1358442}, + {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() + LATEST_VERSION }, - // Reversion: The Meeting (Spanish) { - "reversion2", - "", - AD_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Reversion: The Meeting Version 2.0.2412 (Chinese) - { - "reversion2", - "Version 2.0.2412", + // Looky Demo (German) { - {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, - {"xlanguage_nz.dcp", 0, "17c79af4928e24484bee77a7e807cc2a", 10737127}, - {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformLinux, - ADGF_UNSTABLE, - GUIO0() - }, - // Reversion: The Meeting Version 2.0.2412 (English) - { - "reversion2", - "Version 2.0.2412", - { - {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, - {"xlanguage_en.dcp", 0, "0598bf752ce93b42bcaf1094df537c7b", 8533057}, - {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformLinux, - ADGF_UNSTABLE, - GUIO0() - }, - // Rhiannon: Curse of the four Branches - { - "rhiannon", - "", - AD_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Rhiannon: Curse of the four Branches (English PC DVD) - { - "rhiannon", - "DVD", - AD_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // 1 1/2 Ritter: Auf der Suche nach der hinreissenden Herzelinde - { - "ritter", - "", - AD_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Satan and Son - { - "satanandson", - "", - AD_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Rosemary - { - "rosemary", - "", - AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Securanote - { - "securanote", - "", - AD_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554), - Common::EN_ANY, - Common::kPlatformIOS, - ADGF_UNSTABLE, - GUIO0() - }, - // Shaban - { - "shaban", - "", - AD_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Shine of a Star - { - "shinestar", - "", - AD_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Sofia's Debt - { - "sofiasdebt", - "", - AD_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Space Invaders (Demo) - { - "spaceinvaders", - "Demo", - AD_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // Space Madness - { - "spacemadness", - "1.0.2", - AD_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Ancient Mark - Episode 1 - { - "theancientmark1", - "", - AD_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Box - { - "thebox", - "", - AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Kite (Version 1.1) - { - "thekite", - "Version 1.1", - AD_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Kite (Version 1.2.e) - { - "thekite", - "Version 1.2.e", - AD_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Kite (Version 1.2.i) (Italian) - { - "thekite", - "Version 1.2.i", - AD_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274), - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Kite (Version 1.2.r) (Russian) - { - "thekite", - "Version 1.2.r", - AD_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Kite (Version 1.3.e) - { - "thekite", - "Version 1.3.e", - AD_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Fairy Tales About Toshechka and Boshechka - { - "tib", - "", - AD_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // The Trader of Stories - { - "tradestory", - "Demo", - AD_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // the white chamber (multi-language) - { - "twc", - "", - AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), - Common::UNK_LANG, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Vsevolod Prologue (Demo) - { - "vsevolod", - "Prologue", - AD_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - // War - { - "war", - "", - AD_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Wilma Tetris - { - "wtetris", - "", - AD_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - // Zilm: A Game of Reflex 1.0 - { - "Zilm", - "1.0", - AD_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - AD_TABLE_END_MARKER + "looky", + "Demo", + { + {"german.dcp", 0, "606c048426dfbe94442b59fd34a5c76e", 14339496}, + {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Looky (German) + { + "looky", + "", + { + {"german.dcp", 0, "bf4c2b8c26342342441a6d64934ab832", 107027865}, + {"data.dcp", 0, "50de0beaa5ad621aa9f020df901d1e74", 1342214}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Mirage + { + "mirage", + "", + AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Oknytt + { + "oknytt", + "Version 1.0", + AD_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Night Train Demo + { + "nighttrain", + "", + AD_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Paintaria + { + "paintaria", + "", + AD_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Pigeons in the Park + { + "pigeons", + "", + AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Project: Doom + { + "projectdoom", + "", + AD_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Project Joe + { + "projectjoe", + "", + AD_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Project Lonely Robot + { + "lonelyrobot", + "beta", + AD_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.0 + { + "reversion1", + "Version 1.0", + AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (Chinese) + { + "reversion1", + "Version 1.1", + { + {"chinese.dcp", 0, "cf97150739499a4c15f51dc534ff85a1", 6330561}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::ZH_CNA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (English) + { + "reversion1", + "Version 1.1", + { + {"english.dcp", 0, "7b2f061d7c91365c5d04605f1de032b3", 5702699}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (French) + { + "reversion1", + "Version 1.1", + { + {"french.dcp", 0, "214204b6022c5ed67fada44557690faf", 6327400}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (German) + { + "reversion1", + "Version 1.1", + { + {"german.dcp", 0, "96677823b36d580a4a29e3659071071c", 6340699}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (Italian) + { + "reversion1", + "Version 1.1", + { + {"italian.dcp", 0, "9ce80c1835108f10170a02969f71efe1", 6301836}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.1 (Portuguese) + { + "reversion1", + "Version 1.1", + { + {"portugues.dcp", 0, "8772501afa2c630a7c697eb99e9c7bda", 5053303}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::PT_BRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (Chinese) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_nz.dcp", 0, "92c4065156e464211685bf799b3279fd", 5130600}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::ZH_CNA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (English) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_en.dcp", 0, "05845e1283920a6e4044f2a54f7a9519", 4818543}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (French) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_fr.dcp", 0, "441795490e9307eb2ed07830779881ac", 5425959}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (German) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_de.dcp", 0, "b588041015b93e54b4c246ca77d01e76", 5423798}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (Italian) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_it.dcp", 0, "a1f4199079b75ee10cded41f05b45d5f", 5386424}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3 (Portuguese) + { + "reversion1", + "Version 1.3", + { + {"xlanguage_pt.dcp", 0, "3d653debd37e56756a79401e1004c4d2", 4149165}, + {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, + AD_LISTEND + }, + Common::PT_BRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (Chinese) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_nz.dcp", 0, "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::ZH_CNA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (English) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_en.dcp", 0, "64b6fa7eedc09c231f6ce046e77fee05", 11339619}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (French) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_fr.dcp", 0, "d561d562224afea809153a1fd9fdb0c0", 11963210}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::FR_FRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (German) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_de.dcp", 0, "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (Italian) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_it.dcp", 0, "10d09b7fe61946f09dd91d5e8d090f94", 11913752}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (Latvian) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_lv.dcp", 0, "704359ab5040b0dab6545064d7aa6eb9", 11414925}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::LV_LAT, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (Polish) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_pl.dcp", 0, "c4ad33f57e1e998169552d521c1d6638", 11532215}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::PL_POL, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Escape Version 1.3.2369 (Portuguese) + { + "reversion1", + "Version 1.3.2369", + { + {"xlanguage_pt.dcp", 0, "886886b6b14aadac844078de856799a6", 10620797}, + {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, + AD_LISTEND + }, + Common::PT_BRA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Meeting (Chinese) + { + "reversion2", + "", + { + {"xlanguage_nz.dcp", 0, "8c3709474a87a7876109025dff41ff3f", 8746015}, + {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, + AD_LISTEND + }, + Common::ZH_CNA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Meeting (English) + { + "reversion2", + "", + { + {"xlanguage_en.dcp", 0, "ca357d86618d1ab76a21c913f4403cbd", 8414976}, + {"data.dcp", 0, "f7938cbfdc48f07934550245a3286921", 255672016}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Meeting (Spanish) + { + "reversion2", + "", + AD_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), + Common::ES_ESP, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Meeting Version 2.0.2412 (Chinese) + { + "reversion2", + "Version 2.0.2412", + { + {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, + {"xlanguage_nz.dcp", 0, "17c79af4928e24484bee77a7e807cc2a", 10737127}, + {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, + AD_LISTEND + }, + Common::ZH_CNA, + Common::kPlatformLinux, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Reversion: The Meeting Version 2.0.2412 (English) + { + "reversion2", + "Version 2.0.2412", + { + {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, + {"xlanguage_en.dcp", 0, "0598bf752ce93b42bcaf1094df537c7b", 8533057}, + {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformLinux, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Rhiannon: Curse of the four Branches + { + "rhiannon", + "", + AD_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Rhiannon: Curse of the four Branches (English PC DVD) + { + "rhiannon", + "DVD", + AD_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // 1 1/2 Ritter: Auf der Suche nach der hinreissenden Herzelinde + { + "ritter", + "", + AD_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Satan and Son + { + "satanandson", + "", + AD_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Rosemary + { + "rosemary", + "", + AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Securanote + { + "securanote", + "", + AD_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554), + Common::EN_ANY, + Common::kPlatformIOS, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Shaban + { + "shaban", + "", + AD_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Shine of a Star + { + "shinestar", + "", + AD_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Sofia's Debt + { + "sofiasdebt", + "", + AD_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Space Invaders (Demo) + { + "spaceinvaders", + "Demo", + AD_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // Space Madness + { + "spacemadness", + "1.0.2", + AD_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Ancient Mark - Episode 1 + { + "theancientmark1", + "", + AD_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Box + { + "thebox", + "", + AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Kite (Version 1.1) + { + "thekite", + "Version 1.1", + AD_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Kite (Version 1.2.e) + { + "thekite", + "Version 1.2.e", + AD_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Kite (Version 1.2.i) (Italian) + { + "thekite", + "Version 1.2.i", + AD_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274), + Common::IT_ITA, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Kite (Version 1.2.r) (Russian) + { + "thekite", + "Version 1.2.r", + AD_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ), + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Kite (Version 1.3.e) + { + "thekite", + "Version 1.3.e", + AD_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Fairy Tales About Toshechka and Boshechka + { + "tib", + "", + AD_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526), + Common::RU_RUS, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // The Trader of Stories + { + "tradestory", + "Demo", + AD_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // the white chamber (multi-language) + { + "twc", + "", + AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), + Common::UNK_LANG, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Vsevolod Prologue (Demo) + { + "vsevolod", + "Prologue", + AD_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE | + ADGF_DEMO, + GUIO0() + }, + LATEST_VERSION + }, + { + // War + { + "war", + "", + AD_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Wilma Tetris + { + "wtetris", + "", + AD_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + // Zilm: A Game of Reflex 1.0 + { + "Zilm", + "1.0", + AD_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_UNSTABLE, + GUIO0() + }, + LATEST_VERSION + }, + { + AD_TABLE_END_MARKER, + LATEST_VERSION + } }; } // End of namespace Wintermute diff --git a/engines/wintermute/game_description.h b/engines/wintermute/game_description.h new file mode 100644 index 0000000000..313fff8bbf --- /dev/null +++ b/engines/wintermute/game_description.h @@ -0,0 +1,53 @@ +/* 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 WINTERMUTE_GAME_DESCRIPTION_H +#define WINTERMUTE_GAME_DESCRIPTION_H + +#include "engines/advancedDetector.h" + +namespace Wintermute { + +enum WMETargetExecutable { + OLDEST_VERSION, + WME_1_0_0, + WME_1_1_0, + WME_1_2_0, + WME_1_3_0, + WME_1_4_0, + WME_1_5_0, + WME_1_6_0, + WME_1_7_0, + WME_1_8_0, + WME_1_8_6, + WME_1_9_0, + LATEST_VERSION +}; + +struct WMEGameDescription { + ADGameDescription adDesc; + WMETargetExecutable targetExecutable; +}; + +} + +#endif /* WINTERMUTE_GAME_DESCRIPTION_H_ */ diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index 81b6e53c9f..e35bb60c3d 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -53,7 +53,7 @@ WintermuteEngine::WintermuteEngine() : Engine(g_system) { _gameDescription = nullptr; } -WintermuteEngine::WintermuteEngine(OSystem *syst, const ADGameDescription *desc) +WintermuteEngine::WintermuteEngine(OSystem *syst, const WMEGameDescription *desc) : Engine(syst), _gameDescription(desc) { // Put your engine in a sane state, but do nothing big yet; // in particular, do not load data from files; rather, if you @@ -133,7 +133,7 @@ Common::Error WintermuteEngine::run() { } int WintermuteEngine::init() { - BaseEngine::createInstance(_targetName, _gameDescription->gameid, _gameDescription->language); + BaseEngine::createInstance(_targetName, _gameDescription->adDesc.gameid, _gameDescription->adDesc.language, _gameDescription->targetExecutable); _game = new AdGame(_targetName); if (!_game) { return 1; diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index 017809d56a..f8f5fc7deb 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -26,6 +26,7 @@ #include "engines/engine.h" #include "engines/advancedDetector.h" #include "gui/debugger.h" +#include "engines/wintermute/game_description.h" namespace Wintermute { @@ -44,7 +45,7 @@ enum { class WintermuteEngine : public Engine { public: - WintermuteEngine(OSystem *syst, const ADGameDescription *desc); + WintermuteEngine(OSystem *syst, const WMEGameDescription *desc); WintermuteEngine(); ~WintermuteEngine(); @@ -67,7 +68,7 @@ private: int messageLoop(); GUI::Debugger *_debugger; BaseGame *_game; - const ADGameDescription *_gameDescription; + const WMEGameDescription *_gameDescription; friend class Console; }; -- cgit v1.2.3 From b460323e58e189650dc03e67d75b3a193f7a6685 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Sun, 5 Oct 2014 11:52:26 +0200 Subject: WINTERMUTE: killAllSounds only if WME targetExecutable >= 1.8.6 This fixes #6647 --- engines/wintermute/base/base_sprite.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 04060bff32..09e138a1fd 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -41,6 +41,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/game_description.h" namespace Wintermute { @@ -347,9 +348,17 @@ void BaseSprite::reset() { } else { _currentFrame = -1; } - - killAllSounds(); - + if (BaseEngine::instance().getTargetExecutable() >= WME_1_8_6) { + /* + * This was added in WME 1.8.6 + * + * 5MA and possibly other games ship with pre-1.8.6 WME, and + * depends (e.g.: menu sounds, etc) on this not being triggered. + * + * See bug #6647 + */ + killAllSounds(); + } _lastFrameTime = 0; _finished = false; _moveX = _moveY = 0; -- cgit v1.2.3 From f1eb2513f032013ba8a62872abf63b2ad0e6a876 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 4 Nov 2014 17:20:09 +0100 Subject: WINTERMUTE: Use macros to simplify detection_tables.h --- engines/wintermute/detection_tables.h | 2124 +++++++-------------------------- 1 file changed, 443 insertions(+), 1681 deletions(-) diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index 98bf3c1136..f6f9e24730 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -90,1688 +90,444 @@ static const PlainGameDescriptor wintermuteGames[] = { {0, 0} }; +// Duplicates WME_ENTRY1s, for consistency +#define WME_ENTRY1s(f1, h1, s1) { {f1, 0, h1, s1}, AD_LISTEND } +#define WME_ENTRY2s(f1, h1, s1, f2, h2, s2) { {f1, 0, h1, s1}, {f2, 0, h2, s2}, AD_LISTEND } +#define WME_ENTRY3s(f1, h1, s1, f2, h2, s2, f3, h3, s3) { {f1, 0, h1, s1}, {f2, 0, h2, s2}, {f3, 0, h3, s3}, AD_LISTEND } + +#define WME_PLATENTRY(shortName, extraName, hashEntry, lang, plat, status, version) \ + { \ + { \ + shortName, \ + extraName, \ + hashEntry, \ + lang, \ + plat, \ + status, \ + GUIO0(), \ + }, \ + version \ + } + +// Convenience variant, as most of the games are Windows-games +#define WME_WINENTRY(shortName, extraName, hashEntry, lang, status, version) \ + { \ + { \ + shortName, \ + extraName, \ + hashEntry, \ + lang, \ + Common::kPlatformWindows, \ + status, \ + GUIO0(), \ + }, \ + version \ + } + +/* To add new entries: + * Make sure you have a target name defined at the top of the file + * + * If the game has only one language, and can be detected using only one file, + * then use WME_WINENTRY, with WME_ENTRY1s as exemplified below. + * + * If the game has more than one language, and the main data file is common across + * the versions, then you should use WME_WINENTRY with WME_ENTRY2s/WME_ENTRY3s, with + * the language file as the first hit, and the data file as the second. (Make sure to + * NOT create a WME_ENTRY1s matching the same data file as the 2/3 file match) + */ + static const WMEGameDescription gameDescriptions[] = { - { - // Five Lethal Demons - { - "5ld", - "", - AD_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Five Magical Amulets - { - "5ma", - "", - AD_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - WME_1_7_0 - }, - { - // Actual Destination - { - "actualdest", - "", - AD_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Boredom of Agustin Cordes - { - "agustin", - "", - AD_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Beyond the Threshold - { - "bthreshold", - "", - AD_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Bickadoodle - { - "bickadoodle", - "", - AD_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Bickadoodle (Ver 1.1) - { - "bickadoodle", - "Version 1.1", - AD_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/) - { - "bickadoodle", - "", - AD_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Book of Gron Part One - { - "bookofgron", - "", - AD_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 4 - East Side Story (Demo) - { - "carolreed4", - "Demo", - AD_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 4 - East Side Story - { - "carolreed4", - "", - AD_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 5 - The Colour of Murder - { - "carolreed5", - "", - AD_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 6 - Black Circle - { - "carolreed6", - "", - AD_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 7 - Blue Madonna (Demo) - { - "carolreed7", - "Demo", - AD_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 7 - Blue Madonna - { - "carolreed7", - "", - AD_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 8 - Amber's Blood - { - "carolreed8", - "", - AD_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Carol Reed 9 - Cold Case Summer - { - "carolreed9", - "", - AD_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Chivalry is Not Dead - { - "chivalry", - "", - AD_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - LATEST_VERSION - }, - { - // Chivalry is Not Dead (Version from deirdrakai.com) - { - "chivalry", - "", - AD_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - LATEST_VERSION - }, - { - // Conspiracao Dumont - { - "conspiracao", - "", - AD_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Corrosion: Cold Winter Waiting - { - "corrosion", - "", - AD_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_TESTING, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dead City (Czech) - { - "deadcity", - "", - { - // The Czech data are in data.dcp, so in this case we'll have to - // just detect the english version twice, to give the user a choice. - {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dead City (English) - { - "deadcity", - "", - { - {"english.dcp", 0, "c591046d6de7e381d76f70e0787b2b1f", 415935}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dead City (Italian) - { - "deadcity", - "", - { - {"italian.dcp", 0, "92d8efb94436bec7bd1b7fe0b548192e", 454037}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dead City (Russian) - { - "deadcity", - "", - { - {"russian.dcp", 0, "a0ae71e9e1185596fffb07ad2c951eb9", 653317}, - {"data.dcp", 0, "7ebfd50d1a22370ed7b079bcaa631d62", 9070205}, - AD_LISTEND - }, - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (Czech) - { - "dirtysplit", - "", - { - {"czech.dcp", 0, "08a71446467cf8f9444cfea446b46ad6", 127697934}, - {"data.dcp", 0, "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623}, - }, - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (English) - { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (French) - { - "dirtysplit", - "", - { - {"french.dcp", 0, "a0508dedebd0fe478d0158fa4c2a1136", 125534323}, - {"data.dcp", 0, "e6d70c7f5d181b761cfcf974adf9186a", 88577623}, - AD_LISTEND - }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (German) - { - "dirtysplit", - "", - AD_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (Italian) - { - "dirtysplit", - "", - { - {"italian.dcp", 0, "8108807fbd8af70be1ec452d0fd1131b", 125513726}, - {"data.dcp", 0, "35a150e22af274185883fdbb142c6fb1", 88577623}, - }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dirty Split (Spanish) - { - "dirtysplit", - "", - { - {"spanish.dcp", 0, "b3982c0a5e85b42e1e38240fef004aa4", 164428596}, - {"data.dcp", 0, "63766d6c68b9f00b632ea1736fc8a95c", 88577621}, - }, - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Des Reves Elastiques Avec Mille Insectes Nommes Georges - { - "dreaming", - "", - AD_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Dreamscape - { - "dreamscape", - "", - AD_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Escape from the Mansion - { - "escapemansion", - "Beta 1", - AD_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Escape from the Mansion - { - "escapemansion", - "Beta 2", - AD_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Escape from the Mansion - { - "escapemansion", - "1.3", - AD_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Four - { - "four", - "", - AD_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Framed - { - "framed", - "", - AD_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Ghost in the Sheet - { - "ghostsheet", - "", - { - {"english.dcp", 0, "e6d0aad2c89996bcabe416105a3d6d3a", 12221017}, - {"data.dcp", 0, "b2f8b05328e4881e15e98e845b63f451", 168003}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Ghost in the Sheet (Demo) - { - "ghostsheet", - "Demo", - AD_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Hamlet or the last game without MMORPS features, shaders and product placement - { - "hamlet", - "", - AD_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Helga Deep In Trouble (English) - { - "helga", - "", - { - {"english.dcp", 0, "bfa136b21bdbc7d8691c0770a6d40bc3", 135931}, - {"data.dcp", 0, "25cb955a60b58326f2eeda1ce288fb37", 183251259}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Helga Deep In Trouble (Demo) (English) - { - "helga", - "Demo", - { - {"english.dcp", 0, "b3a93e678f0ef97200f691cd1724643f", 135864}, - {"data.dcp", 0, "45134ed93bc391edf148b79cdcbf2a09", 154266028}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // James Peris: No License Nor Control (English) - { - "jamesperis", - "", - AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // James Peris: No License Nor Control (Spanish) - { - "jamesperis", - "", - AD_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // James Peris: No License Nor Control (Demo) (English) - { - "jamesperis", - "Demo", - AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // James Peris: No License Nor Control (Demo) (Spanish) - { - "jamesperis", - "Demo", - AD_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // J.U.L.I.A. (English) - { - "julia", - "", - AD_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // J.U.L.I.A. (English, Bundle in a box-version) - { - "julia", - "Version 1.2", - AD_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // J.U.L.I.A. (English) (Demo) - { - "julia", - "Demo", - AD_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // J.U.L.I.A. (English) (Greenlight Demo) - { - "julia", - "Greenlight Demo", - AD_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Kulivocko (Czech) - { - "kulivocko", - "", - AD_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Kulivocko (Czech) (Demo) - { - "kulivocko", - "Demo", - AD_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), - Common::CZ_CZE, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Life In 3 Minutes - { - "lifein3minutes", - "", - AD_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Looky Demo (English) - { - "looky", - "Demo", - { - {"english.dcp", 0, "1388e1dd320f4d553dea3b0316812f9d", 1358442}, - {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Looky Demo (German) - { - "looky", - "Demo", - { - {"german.dcp", 0, "606c048426dfbe94442b59fd34a5c76e", 14339496}, - {"data.dcp", 0, "7074bcd7bc7ad7eb04c271aafb964c32", 13815660}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Looky (German) - { - "looky", - "", - { - {"german.dcp", 0, "bf4c2b8c26342342441a6d64934ab832", 107027865}, - {"data.dcp", 0, "50de0beaa5ad621aa9f020df901d1e74", 1342214}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Mirage - { - "mirage", - "", - AD_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Oknytt - { - "oknytt", - "Version 1.0", - AD_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Night Train Demo - { - "nighttrain", - "", - AD_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Paintaria - { - "paintaria", - "", - AD_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Pigeons in the Park - { - "pigeons", - "", - AD_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Project: Doom - { - "projectdoom", - "", - AD_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Project Joe - { - "projectjoe", - "", - AD_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Project Lonely Robot - { - "lonelyrobot", - "beta", - AD_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.0 - { - "reversion1", - "Version 1.0", - AD_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (Chinese) - { - "reversion1", - "Version 1.1", - { - {"chinese.dcp", 0, "cf97150739499a4c15f51dc534ff85a1", 6330561}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (English) - { - "reversion1", - "Version 1.1", - { - {"english.dcp", 0, "7b2f061d7c91365c5d04605f1de032b3", 5702699}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (French) - { - "reversion1", - "Version 1.1", - { - {"french.dcp", 0, "214204b6022c5ed67fada44557690faf", 6327400}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (German) - { - "reversion1", - "Version 1.1", - { - {"german.dcp", 0, "96677823b36d580a4a29e3659071071c", 6340699}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (Italian) - { - "reversion1", - "Version 1.1", - { - {"italian.dcp", 0, "9ce80c1835108f10170a02969f71efe1", 6301836}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.1 (Portuguese) - { - "reversion1", - "Version 1.1", - { - {"portugues.dcp", 0, "8772501afa2c630a7c697eb99e9c7bda", 5053303}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (Chinese) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_nz.dcp", 0, "92c4065156e464211685bf799b3279fd", 5130600}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (English) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_en.dcp", 0, "05845e1283920a6e4044f2a54f7a9519", 4818543}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (French) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_fr.dcp", 0, "441795490e9307eb2ed07830779881ac", 5425959}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (German) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_de.dcp", 0, "b588041015b93e54b4c246ca77d01e76", 5423798}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (Italian) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_it.dcp", 0, "a1f4199079b75ee10cded41f05b45d5f", 5386424}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3 (Portuguese) - { - "reversion1", - "Version 1.3", - { - {"xlanguage_pt.dcp", 0, "3d653debd37e56756a79401e1004c4d2", 4149165}, - {"data.dcp", 0, "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907}, - AD_LISTEND - }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (Chinese) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_nz.dcp", 0, "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (English) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_en.dcp", 0, "64b6fa7eedc09c231f6ce046e77fee05", 11339619}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (French) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_fr.dcp", 0, "d561d562224afea809153a1fd9fdb0c0", 11963210}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::FR_FRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (German) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_de.dcp", 0, "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (Italian) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_it.dcp", 0, "10d09b7fe61946f09dd91d5e8d090f94", 11913752}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (Latvian) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_lv.dcp", 0, "704359ab5040b0dab6545064d7aa6eb9", 11414925}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::LV_LAT, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (Polish) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_pl.dcp", 0, "c4ad33f57e1e998169552d521c1d6638", 11532215}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::PL_POL, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Escape Version 1.3.2369 (Portuguese) - { - "reversion1", - "Version 1.3.2369", - { - {"xlanguage_pt.dcp", 0, "886886b6b14aadac844078de856799a6", 10620797}, - {"data.dcp", 0, "aecb5deeea7b0baa871fbd0cef35a648", 254219204}, - AD_LISTEND - }, - Common::PT_BRA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Meeting (Chinese) - { - "reversion2", - "", - { - {"xlanguage_nz.dcp", 0, "8c3709474a87a7876109025dff41ff3f", 8746015}, - {"data.dcp", 0, "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Meeting (English) - { - "reversion2", - "", - { - {"xlanguage_en.dcp", 0, "ca357d86618d1ab76a21c913f4403cbd", 8414976}, - {"data.dcp", 0, "f7938cbfdc48f07934550245a3286921", 255672016}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Meeting (Spanish) - { - "reversion2", - "", - AD_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), - Common::ES_ESP, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Meeting Version 2.0.2412 (Chinese) - { - "reversion2", - "Version 2.0.2412", - { - {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, - {"xlanguage_nz.dcp", 0, "17c79af4928e24484bee77a7e807cc2a", 10737127}, - {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, - AD_LISTEND - }, - Common::ZH_CNA, - Common::kPlatformLinux, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Reversion: The Meeting Version 2.0.2412 (English) - { - "reversion2", - "Version 2.0.2412", - { - {"data.dcp", 0, "f4ffc4df24b7bebad56a24930f33a2bc", 255766600}, - {"xlanguage_en.dcp", 0, "0598bf752ce93b42bcaf1094df537c7b", 8533057}, - {"Linux.dcp", 0, "21858bd77dc86b03f701fd47900e2f51", 984535}, - AD_LISTEND - }, - Common::EN_ANY, - Common::kPlatformLinux, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Rhiannon: Curse of the four Branches - { - "rhiannon", - "", - AD_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Rhiannon: Curse of the four Branches (English PC DVD) - { - "rhiannon", - "DVD", - AD_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // 1 1/2 Ritter: Auf der Suche nach der hinreissenden Herzelinde - { - "ritter", - "", - AD_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278), - Common::DE_DEU, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Satan and Son - { - "satanandson", - "", - AD_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Rosemary - { - "rosemary", - "", - AD_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Securanote - { - "securanote", - "", - AD_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554), - Common::EN_ANY, - Common::kPlatformIOS, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Shaban - { - "shaban", - "", - AD_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Shine of a Star - { - "shinestar", - "", - AD_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Sofia's Debt - { - "sofiasdebt", - "", - AD_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Space Invaders (Demo) - { - "spaceinvaders", - "Demo", - AD_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // Space Madness - { - "spacemadness", - "1.0.2", - AD_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Ancient Mark - Episode 1 - { - "theancientmark1", - "", - AD_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Box - { - "thebox", - "", - AD_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Kite (Version 1.1) - { - "thekite", - "Version 1.1", - AD_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Kite (Version 1.2.e) - { - "thekite", - "Version 1.2.e", - AD_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Kite (Version 1.2.i) (Italian) - { - "thekite", - "Version 1.2.i", - AD_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274), - Common::IT_ITA, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Kite (Version 1.2.r) (Russian) - { - "thekite", - "Version 1.2.r", - AD_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Kite (Version 1.3.e) - { - "thekite", - "Version 1.3.e", - AD_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Fairy Tales About Toshechka and Boshechka - { - "tib", - "", - AD_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526), - Common::RU_RUS, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // The Trader of Stories - { - "tradestory", - "Demo", - AD_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // the white chamber (multi-language) - { - "twc", - "", - AD_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), - Common::UNK_LANG, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Vsevolod Prologue (Demo) - { - "vsevolod", - "Prologue", - AD_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE | - ADGF_DEMO, - GUIO0() - }, - LATEST_VERSION - }, - { - // War - { - "war", - "", - AD_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Wilma Tetris - { - "wtetris", - "", - AD_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, - { - // Zilm: A Game of Reflex 1.0 - { - "Zilm", - "1.0", - AD_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726), - Common::EN_ANY, - Common::kPlatformWindows, - ADGF_UNSTABLE, - GUIO0() - }, - LATEST_VERSION - }, + // Five Lethal Demons + WME_WINENTRY("5ld", "", + WME_ENTRY1s("data.dcp", "1037a77cbd001e0644898addc022322c", 15407750), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Five Magical Amulets + WME_WINENTRY("5ma", "", + WME_ENTRY1s("data.dcp", "0134e92bcd5fd2837df3971087e96067", 163316498), Common::EN_ANY, ADGF_UNSTABLE, WME_1_7_0), + // Actual Destination + WME_WINENTRY("actualdest", "", + WME_ENTRY1s("data.dcp", "6926f44b26f21ceb1d840eaab9aeb510", 9081740), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Boredom of Agustin Cordes + WME_WINENTRY("agustin", "", + WME_ENTRY1s("data.dcp", "abb79c16c9b92e9b06525a4c7c3f5861", 2461949), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Beyond the Threshold + WME_WINENTRY("bthreshold", "", + WME_ENTRY1s("data.dcp", "d49bf9ccb2e74507447c82d6ad3e2bc4", 12773712), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Bickadoodle + WME_WINENTRY("bickadoodle", "", + WME_ENTRY1s("data.dcp", "84db4d1594cac95e25614985775d10a8", 35303844), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Bickadoodle (Ver 1.1) + WME_WINENTRY("bickadoodle", "Version 1.1", + WME_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/) + WME_WINENTRY("bickadoodle", "", + WME_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Book of Gron Part One + WME_WINENTRY("bookofgron", "", + WME_ENTRY1s("data.dcp", "e61b2ebee044a82fa0f8ca0fce2c8946", 83129531), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION), + // Carol Reed 4 - East Side Story (Demo) + WME_WINENTRY("carolreed4", "Demo", + WME_ENTRY1s("data.dcp", "b3f8b09bb4b05ee3e9d14697525257f9", 59296246), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Carol Reed 4 - East Side Story + WME_WINENTRY("carolreed4", "", + WME_ENTRY1s("data.dcp", "b26377797f060afc2d440d820100c1ce", 529320536), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Carol Reed 5 - The Colour of Murder + WME_WINENTRY("carolreed5", "", + WME_ENTRY1s("data.dcp", "3fcfca44209545d0e26774156427b494", 603660415), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Carol Reed 6 - Black Circle + WME_WINENTRY("carolreed6", "", + WME_ENTRY1s("data.dcp", "0e4c532beecf23d85012168753f41189", 456258147), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Carol Reed 7 - Blue Madonna (Demo) + WME_WINENTRY("carolreed7", "Demo", + WME_ENTRY1s("data.dcp", "0372ad0c775266f6355e9e8ae397a2f1", 103719442), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Carol Reed 7 - Blue Madonna + WME_WINENTRY("carolreed7", "", + WME_ENTRY1s("data.dcp", "24e3db3e2fabfc956713796d87a3efb0", 495471147), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Carol Reed 8 - Amber's Blood + WME_WINENTRY("carolreed8", "", + WME_ENTRY1s("data.dcp", "859d16b0d5b9b255e470cbded2c6cedc", 502714557), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Carol Reed 9 - Cold Case Summer + WME_WINENTRY("carolreed9", "", + WME_ENTRY1s("data.dcp", "2b343b48a7aee508d728a546b414a255", 620005266), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Chivalry is Not Dead + WME_WINENTRY("chivalry", "", + WME_ENTRY1s("data.dcp", "ebd0915d9a12df5224be22f53bb23eb6", 7278306), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION), + // Chivalry is Not Dead (Version from deirdrakai.com) + WME_WINENTRY("chivalry", "", + WME_ENTRY1s("data.dcp", "ae6d91b9517f4d2851a8ad94c96951c8", 7278302), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION), + // Conspiracao Dumont + WME_WINENTRY("conspiracao", "", + WME_ENTRY1s("ConspiracaoDumont.exe", "106f3f2c8f18bb5ffffeed634ace256c", 32908032), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Corrosion: Cold Winter Waiting + WME_WINENTRY("corrosion", "", + WME_ENTRY1s("data.dcp", "ae885b1a8faa0b27f43c0e8f0df02fc9", 525931618), Common::EN_ANY, ADGF_TESTING, LATEST_VERSION), + // Dead City (Czech) + // The Czech data are in data.dcp, so in this case we'll have to + // just detect the english version twice, to give the user a choice. + WME_WINENTRY("deadcity", "", + WME_ENTRY2s("english.dcp", "c591046d6de7e381d76f70e0787b2b1f", 415935, + "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION), + // Dead City (English) + WME_WINENTRY("deadcity", "", + WME_ENTRY2s("english.dcp", "c591046d6de7e381d76f70e0787b2b1f", 415935, + "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Dead City (Italian) + WME_WINENTRY("deadcity", "", + WME_ENTRY2s("italian.dcp", "92d8efb94436bec7bd1b7fe0b548192e", 454037, + "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // Dead City (Russian) + WME_WINENTRY("deadcity", "", + WME_ENTRY2s("russian.dcp", "a0ae71e9e1185596fffb07ad2c951eb9", 653317, + "data.dcp", "7ebfd50d1a22370ed7b079bcaa631d62", 9070205), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (Czech) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY2s("czech.dcp", "08a71446467cf8f9444cfea446b46ad6", 127697934, + "data.dcp", "8b4b81b718bf65f30a67fc0b1e329eb5", 88577623), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (English) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY1s("data.dcp", "8f3dae199361ece0f59fb20cfff6eed3", 88577621), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (French) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY2s("french.dcp", "a0508dedebd0fe478d0158fa4c2a1136", 125534323, + "data.dcp", "e6d70c7f5d181b761cfcf974adf9186a", 88577623), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (German) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY1s("data.dcp", "139d8a25579e969f8b37d20e6e3de5f9", 92668291), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (Italian) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY2s("italian.dcp", "8108807fbd8af70be1ec452d0fd1131b", 125513726, + "data.dcp", "35a150e22af274185883fdbb142c6fb1", 88577623), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // Dirty Split (Spanish) + WME_WINENTRY("dirtysplit", "", + WME_ENTRY2s("spanish.dcp", "b3982c0a5e85b42e1e38240fef004aa4", 164428596, + "data.dcp", "63766d6c68b9f00b632ea1736fc8a95c", 88577621), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION), + // Des Reves Elastiques Avec Mille Insectes Nommes Georges + WME_WINENTRY("dreaming", "", + WME_ENTRY1s("data.dcp", "4af26d97ea063fc1277ce30ae431de90", 8804073), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Dreamscape + WME_WINENTRY("dreamscape", "", + WME_ENTRY1s("data.dcp", "7a5752ed4446c862be9f02d7932acf54", 17034377), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Escape from the Mansion + WME_WINENTRY("escapemansion", "Beta 1", + WME_ENTRY1s("data.dcp", "d8e348b2312cc36a929cad75f12e0b3a", 21452380), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Escape from the Mansion + WME_WINENTRY("escapemansion", "Beta 2", + WME_ENTRY1s("data.dcp", "ded5fa6c5f2afdaf2cafb53e52cd3dd8", 21455763), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Escape from the Mansion + WME_WINENTRY("escapemansion", "1.3", + WME_ENTRY1s("data.dcp", "1e5d231b56c8a228cd15cb690f50253e", 29261972), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Four + WME_WINENTRY("four", "", + WME_ENTRY1s("data.dcp", "ec05cd5e37c9a524053b8859635a4234", 62599855), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Framed + WME_WINENTRY("framed", "", + WME_ENTRY1s("data.dcp", "e7259fb36f2c6f9f28242291e0c3de98", 34690568), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Ghost in the Sheet + WME_WINENTRY("ghostsheet", "", + WME_ENTRY2s("english.dcp", "e6d0aad2c89996bcabe416105a3d6d3a", 12221017, + "data.dcp", "b2f8b05328e4881e15e98e845b63f451", 168003), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Ghost in the Sheet (Demo) + WME_WINENTRY("ghostsheet", "Demo", + WME_ENTRY1s("data.dcp", "dc1f6595f412ac25a52eaf47dad4ab81", 169083), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Hamlet or the last game without MMORPS features, shaders and product placement + WME_WINENTRY("hamlet", "", + + WME_ENTRY1s("data.dcp", "f624add957a77c9930529fb28cc2450f", 88183022), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Helga Deep In Trouble (English) + WME_WINENTRY("helga", "", + WME_ENTRY2s("english.dcp", "bfa136b21bdbc7d8691c0770a6d40bc3", 135931, + "data.dcp", "25cb955a60b58326f2eeda1ce288fb37", 183251259), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Helga Deep In Trouble (Demo) (English) + WME_WINENTRY("helga", "Demo", + WME_ENTRY2s("english.dcp", "b3a93e678f0ef97200f691cd1724643f", 135864, + "data.dcp", "45134ed93bc391edf148b79cdcbf2a09", 154266028), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // James Peris: No License Nor Control (English) + WME_WINENTRY("jamesperis", "", + WME_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // James Peris: No License Nor Control (Spanish) + WME_WINENTRY("jamesperis", "", + WME_ENTRY1s("data.dcp", "a420961e170cb7d168a0d2bae2fe5218", 225294032), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION), + // James Peris: No License Nor Control (Demo) (English) + WME_WINENTRY("jamesperis", "Demo", + WME_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // James Peris: No License Nor Control (Demo) (Spanish) + WME_WINENTRY("jamesperis", "Demo", + WME_ENTRY1s("data.dcp", "edb9f9c7a08993c1e28f4e477b5f9830", 116113507), Common::ES_ESP, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // J.U.L.I.A. (English) + WME_WINENTRY("julia", "", + WME_ENTRY1s("data.dcp", "c2264b4f8fcd132d2913ff5b6076a24f", 10109741), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // J.U.L.I.A. (English, Bundle in a box-version) + WME_WINENTRY("julia", "Version 1.2", + WME_ENTRY1s("data.dcp", "fe90023ccc22f35185b40b910e0d03a2", 10101373), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // J.U.L.I.A. (English) (Demo) + WME_WINENTRY("julia", "Demo", + WME_ENTRY1s("data.dcp", "f0bbc3394555a9811f6050dae428cab6", 7655237), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // J.U.L.I.A. (English) (Greenlight Demo) + WME_WINENTRY("julia", "Greenlight Demo", + WME_ENTRY1s("data.dcp", "4befd448d36b0dae9c3ab1aa7cb8b78d", 7271886), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Kulivocko (Czech) + WME_WINENTRY("kulivocko", "", + WME_ENTRY1s("data.dcp", "44306dc470e9b27474043932eccee02f", 155106392), Common::CZ_CZE, ADGF_UNSTABLE, LATEST_VERSION), + // Kulivocko (Czech) (Demo) + WME_WINENTRY("kulivocko", "Demo", + WME_ENTRY1s("data.dcp", "63b164bdfadecbb0deb5da691afb8154", 48362234), Common::CZ_CZE, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Life In 3 Minutes + WME_WINENTRY("lifein3minutes", "", + WME_ENTRY1s("data.dcp", "c6368950e37a95bf098b02b4eaa5b929", 141787214), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Looky Demo (English) + WME_WINENTRY("looky", "Demo", + WME_ENTRY2s("english.dcp", "1388e1dd320f4d553dea3b0316812f9d", 1358442, + "data.dcp", "7074bcd7bc7ad7eb04c271aafb964c32", 13815660), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Looky Demo (German) + WME_WINENTRY("looky", "Demo", + WME_ENTRY2s("german.dcp", "606c048426dfbe94442b59fd34a5c76e", 14339496, + "data.dcp", "7074bcd7bc7ad7eb04c271aafb964c32", 13815660), Common::DE_DEU, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Looky (German) + WME_WINENTRY("looky", "", + WME_ENTRY2s("german.dcp", "bf4c2b8c26342342441a6d64934ab832", 107027865, + "data.dcp", "50de0beaa5ad621aa9f020df901d1e74", 1342214), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Mirage + WME_WINENTRY("mirage", "", + WME_ENTRY1s("data.dcp", "d230b0b99c0aa77b9ecd094d8ee5573b", 17844056), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Oknytt + WME_WINENTRY("oknytt", "Version 1.0", + WME_ENTRY1s("data.dcp", "6456cf8f429905c83f07509f9da536dd", 109502959), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Night Train Demo + WME_WINENTRY("nighttrain", "", + WME_ENTRY1s("data.dcp", "5a027ef84b083a730c9a4c85ec1d3a32", 131760816), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Paintaria + WME_WINENTRY("paintaria", "", + WME_ENTRY1s("data.dcp", "354c08440c98150ff0d4008dd2865880", 48326040), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Pigeons in the Park + WME_WINENTRY("pigeons", "", + WME_ENTRY1s("data.dcp", "9143a5b6ff8206aefe3c4c643add3ec7", 2611100), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Project: Doom + WME_WINENTRY("projectdoom", "", + WME_ENTRY1s("data.dcp", "d5894b65a40706845434b99870bcab92", 99223761), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Project Joe + WME_WINENTRY("projectjoe", "", + WME_ENTRY1s("data.dcp", "ada3c08542901295076b5349e655e73f", 160780037), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Project Lonely Robot + WME_WINENTRY("lonelyrobot", "beta", + WME_ENTRY1s("data.dcp", "a0cf7ad5bab957416dcda454e9f28ef0", 3420120), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Reversion: The Escape Version 1.0 + WME_WINENTRY("reversion1", "Version 1.0", + WME_ENTRY1s("data.dcp", "cd616f98ebfd047e0c540b50b4b70761", 254384531), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (Chinese) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("chinese.dcp", "cf97150739499a4c15f51dc534ff85a1", 6330561, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (English) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("english.dcp", "7b2f061d7c91365c5d04605f1de032b3", 5702699, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (French) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("french.dcp", "214204b6022c5ed67fada44557690faf", 6327400, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (German) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("german.dcp", "96677823b36d580a4a29e3659071071c", 6340699, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (Italian) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("italian.dcp", "9ce80c1835108f10170a02969f71efe1", 6301836, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.1 (Portuguese) + WME_WINENTRY("reversion1", "Version 1.1", + WME_ENTRY2s("portugues.dcp", "8772501afa2c630a7c697eb99e9c7bda", 5053303, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (Chinese) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_nz.dcp", "92c4065156e464211685bf799b3279fd", 5130600, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (English) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_en.dcp", "05845e1283920a6e4044f2a54f7a9519", 4818543, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (French) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_fr.dcp", "441795490e9307eb2ed07830779881ac", 5425959, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (German) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_de.dcp", "b588041015b93e54b4c246ca77d01e76", 5423798, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (Italian) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_it.dcp", "a1f4199079b75ee10cded41f05b45d5f", 5386424, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3 (Portuguese) + WME_WINENTRY("reversion1", "Version 1.3", + WME_ENTRY2s("xlanguage_pt.dcp", "3d653debd37e56756a79401e1004c4d2", 4149165, + "data.dcp", "9ebb12f6fd7c038d079f81beb3bd96d5", 254185907), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (Chinese) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_nz.dcp", "7146dfa43ffdf0886e034fffe2c8a0c0", 13722261, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (English) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_en.dcp", "64b6fa7eedc09c231f6ce046e77fee05", 11339619, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (French) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_fr.dcp", "d561d562224afea809153a1fd9fdb0c0", 11963210, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::FR_FRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (German) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_de.dcp", "4e3f614c36bd6bae74b8cc83e663a8f0", 14040310, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (Italian) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_it.dcp", "10d09b7fe61946f09dd91d5e8d090f94", 11913752, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (Latvian) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_lv.dcp", "704359ab5040b0dab6545064d7aa6eb9", 11414925, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::LV_LAT, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (Polish) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_pl.dcp", "c4ad33f57e1e998169552d521c1d6638", 11532215, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::PL_POL, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Escape Version 1.3.2369 (Portuguese) + WME_WINENTRY("reversion1", "Version 1.3.2369", + WME_ENTRY2s("xlanguage_pt.dcp", "886886b6b14aadac844078de856799a6", 10620797, + "data.dcp", "aecb5deeea7b0baa871fbd0cef35a648", 254219204), Common::PT_BRA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Meeting (Chinese) + WME_WINENTRY("reversion2", "", + WME_ENTRY2s("xlanguage_nz.dcp", "8c3709474a87a7876109025dff41ff3f", 8746015, + "data.dcp", "cb9865dc7e1db2990a8cf4bc13cf4999", 257643032), Common::ZH_CNA, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Meeting (English) + WME_WINENTRY("reversion2", "", + WME_ENTRY2s("xlanguage_en.dcp", "ca357d86618d1ab76a21c913f4403cbd", 8414976, + "data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Meeting (Spanish) + WME_WINENTRY("reversion2", "", + WME_ENTRY1s("data.dcp", "f7938cbfdc48f07934550245a3286921", 255672016), Common::ES_ESP, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Meeting Version 2.0.2412 (Chinese) + WME_PLATENTRY("reversion2", "Version 2.0.2412", + WME_ENTRY3s("data.dcp", "f4ffc4df24b7bebad56a24930f33a2bc", 255766600, + "xlanguage_nz.dcp", "17c79af4928e24484bee77a7e807cc2a", 10737127, + "Linux.dcp", "21858bd77dc86b03f701fd47900e2f51", 984535), Common::ZH_CNA, Common::kPlatformLinux, ADGF_UNSTABLE, LATEST_VERSION), + // Reversion: The Meeting Version 2.0.2412 (English) + WME_PLATENTRY("reversion2", "Version 2.0.2412", + WME_ENTRY3s("data.dcp", "f4ffc4df24b7bebad56a24930f33a2bc", 255766600, + "xlanguage_en.dcp", "0598bf752ce93b42bcaf1094df537c7b", 8533057, + "Linux.dcp", "21858bd77dc86b03f701fd47900e2f51", 984535), Common::EN_ANY, Common::kPlatformLinux, ADGF_UNSTABLE, LATEST_VERSION), + // Rhiannon: Curse of the four Branches + WME_WINENTRY("rhiannon", "", + WME_ENTRY1s("data.dcp", "870f348900b735f1cc79c0608ce32b0e", 1046169851), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Rhiannon: Curse of the four Branches (English PC DVD) + WME_WINENTRY("rhiannon", "DVD", + WME_ENTRY1s("data.dcp", "6736bbc921bb6ce5161b3ad095a97bd4", 1053441028), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // 1 1/2 Ritter: Auf der Suche nach der hinreissenden Herzelinde + WME_WINENTRY("ritter", "", + WME_ENTRY1s("data.dcp", "5ac416cee605d3a30f4d59687b1cdab2", 364260278), Common::DE_DEU, ADGF_UNSTABLE, LATEST_VERSION), + // Satan and Son + WME_WINENTRY("satanandson", "", + WME_ENTRY1s("data.dcp", "16a6ba8174b697bbba9299619d1e20c4", 67539054), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Rosemary + WME_WINENTRY("rosemary", "", + WME_ENTRY1s("data.dcp", "4f2631138bd4d27587d9043f8aeff3df", 29483643), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Securanote + WME_PLATENTRY("securanote", "", + WME_ENTRY1s("data.dcp", "5213d3e59b9e95b7fbd5c56f7de5341a", 2625554), Common::EN_ANY, Common::kPlatformIOS, ADGF_UNSTABLE, LATEST_VERSION), + // Shaban + WME_WINENTRY("shaban", "", + WME_ENTRY1s("data.dcp", "35f702ca9baabc5c620e0be230195c8a", 755388466), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Shine of a Star + WME_WINENTRY("shinestar", "", + WME_ENTRY1s("data.dcp", "f05abe9e2427a5e4f73648fa09c4ba8e", 94113060), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Sofia's Debt + WME_WINENTRY("sofiasdebt", "", + WME_ENTRY1s("SD.exe", "e9515f9ba1a2925bb6733476a826a650", 9915047), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Space Invaders (Demo) + WME_WINENTRY("spaceinvaders", "Demo", + WME_ENTRY1s("data.dcp", "3f27adefdf72f2c1601cf555c80a509f", 1308361), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // Space Madness + WME_WINENTRY("spacemadness", "1.0.2", + WME_ENTRY1s("data.dcp", "b9b83135dc7a9e1b4b5f50195dbeb630", 39546622), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Ancient Mark - Episode 1 + WME_WINENTRY("theancientmark1", "", + WME_ENTRY1s("data.dcp", "ca04c26f03b2bd307368b306b297ddd7", 364664692), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Box + WME_WINENTRY("thebox", "", + WME_ENTRY1s("data.dcp", "ec5f0c7e8174e307701447b53afe7e2f", 108372483), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Kite (Version 1.1) + WME_WINENTRY("thekite", "Version 1.1", + WME_ENTRY1s("data.dcp", "92d29428f464469bda2d81b03d4d5c3e", 47332296), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Kite (Version 1.2.e) + WME_WINENTRY("thekite", "Version 1.2.e", + WME_ENTRY1s("data.dcp", "92451578b1bdd2b32a1db592a4f6d5fc", 47360539), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // The Kite (Version 1.2.i) (Italian) + WME_WINENTRY("thekite", "Version 1.2.i", + WME_ENTRY1s("data.dcp", "d3435b106a1b3b4c1df8ad596d271586", 47509274), Common::IT_ITA, ADGF_UNSTABLE, LATEST_VERSION), + // The Kite (Version 1.2.r) (Russian) + WME_WINENTRY("thekite", "Version 1.2.r", + WME_ENTRY1s("data.dcp", "d531e097dd884737469da014ed882cde", 47554582 ), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION), + // The Kite (Version 1.3.e) + WME_WINENTRY("thekite", "Version 1.3.e", + WME_ENTRY1s("data.dcp", "9761827b51370263b7623721545d7627", 47382987), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Fairy Tales About Toshechka and Boshechka + WME_WINENTRY("tib", "", + WME_ENTRY1s("data.dcp", "87d296ef3f46570ed18f000d3885db77", 340264526), Common::RU_RUS, ADGF_UNSTABLE, LATEST_VERSION), + // The Trader of Stories + WME_WINENTRY("tradestory", "Demo", + WME_ENTRY1s("data.dcp", "0a0b51191636cc8ead89b905281c3218", 40401902), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // the white chamber (multi-language) + WME_WINENTRY("twc", "", + WME_ENTRY1s("data.dcp", "0011d01142547c61e51ba24dc42b579e", 186451273), Common::UNK_LANG, ADGF_UNSTABLE, LATEST_VERSION), + // Vsevolod Prologue (Demo) + WME_WINENTRY("vsevolod", "Prologue", + WME_ENTRY1s("data.dcp", "f2dcffd2692dbfcc9371fa1a87970fe7", 388669493), Common::EN_ANY, ADGF_UNSTABLE | ADGF_DEMO, LATEST_VERSION), + // War + WME_WINENTRY("war", "", + WME_ENTRY1s("data.dcp", "003e317cda6d0137bbd5e5d7f089ee4d", 32591890), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Wilma Tetris + WME_WINENTRY("wtetris", "", + WME_ENTRY1s("data.dcp", "946e3a0496e6c12fb344c9ed861ff015", 2780093), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Zilm: A Game of Reflex 1.0 + WME_WINENTRY("Zilm", "1.0", + WME_ENTRY1s("data.dcp", "098dffaf03d8adbb4cb5633e4733e63c", 351726), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), { AD_TABLE_END_MARKER, LATEST_VERSION @@ -1780,3 +536,9 @@ static const WMEGameDescription gameDescriptions[] = { } // End of namespace Wintermute +#undef WEM_ENTRY1s +#undef WEM_ENTRY2s +#undef WEM_ENTRY3s +#undef WME_WINENTRY +#undef WME_PLATENTRY + -- cgit v1.2.3 From 2f868ae5b6ed2c5449048db7206357870ce740a1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 4 Nov 2014 18:08:20 +0100 Subject: WINTERMUTE: Add detection for Bickadoodle 1.2 (Fixes bug 6735) --- engines/wintermute/detection_tables.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/wintermute/detection_tables.h b/engines/wintermute/detection_tables.h index f6f9e24730..4e3320159a 100644 --- a/engines/wintermute/detection_tables.h +++ b/engines/wintermute/detection_tables.h @@ -158,6 +158,9 @@ static const WMEGameDescription gameDescriptions[] = { // Bickadoodle (Ver 1.1) WME_WINENTRY("bickadoodle", "Version 1.1", WME_ENTRY1s("data.dcp", "8bb52ac9a9ee129c5059e8e808b669d7", 35337760), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), + // Bickadoodle (Ver 1.2) + WME_WINENTRY("bickadoodle", "Version 1.2", + WME_ENTRY1s("data.dcp", "1796a48f3ed72dd785ce93334ab883cc", 35337760), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), // Bickadoodle (download from http://aethericgames.com/games/bickadoodle/download-bickadoodle/) WME_WINENTRY("bickadoodle", "", WME_ENTRY1s("data.dcp", "1584d83577c32add0fce27fae91141a2", 35337728), Common::EN_ANY, ADGF_UNSTABLE, LATEST_VERSION), -- cgit v1.2.3 From ee876b56b291676faa4526b6df1e385d8560087f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 4 Nov 2014 18:34:06 +0100 Subject: WINTERMUTE: Add VK-translations for F1-F12 and HOME --- engines/wintermute/base/base_keyboard_state.cpp | 48 +++++++++++++++++++++---- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 61087c5836..0babc07586 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -278,10 +278,24 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { enum VKeyCodes { kVkEscape = 27, kVkSpace = 32, + kVkHome = 36, kVkLeft = 37, kVkUp = 38, kVkRight = 39, - kVkDown = 40 + kVkDown = 40, + + kVkF1 = 112, + kVkF2 = 113, + kVkF3 = 114, + kVkF4 = 115, + kVkF5 = 116, + kVkF6 = 117, + kVkF7 = 118, + kVkF8 = 119, + kVkF9 = 120, + kVkF10 = 121, + kVkF11 = 122, + kVkF12 = 123 }; ////////////////////////////////////////////////////////////////////////// @@ -290,22 +304,42 @@ Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { switch (vkey) { case kVkEscape: return Common::KEYCODE_ESCAPE; - break; case kVkSpace: return Common::KEYCODE_SPACE; - break; + case kVkHome: + return Common::KEYCODE_HOME; case kVkLeft: return Common::KEYCODE_LEFT; - break; case kVkRight: return Common::KEYCODE_RIGHT; - break; case kVkUp: return Common::KEYCODE_UP; - break; case kVkDown: return Common::KEYCODE_DOWN; - break; + case kVkF1: + return Common::KEYCODE_F1; + case kVkF2: + return Common::KEYCODE_F2; + case kVkF3: + return Common::KEYCODE_F3; + case kVkF4: + return Common::KEYCODE_F4; + case kVkF5: + return Common::KEYCODE_F5; + case kVkF6: + return Common::KEYCODE_F6; + case kVkF7: + return Common::KEYCODE_F7; + case kVkF8: + return Common::KEYCODE_F8; + case kVkF9: + return Common::KEYCODE_F9; + case kVkF10: + return Common::KEYCODE_F10; + case kVkF11: + return Common::KEYCODE_F11; + case kVkF12: + return Common::KEYCODE_F12; default: warning("Unknown VKEY: %d", vkey); return (Common::KeyCode)vkey; -- cgit v1.2.3 From ad8dbd364203a463fbae935b751cf96f76c38cf5 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 4 Nov 2014 19:46:44 +0100 Subject: SCI: kStrCat does language-splitting for QfG1 too --- engines/sci/engine/kstring.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index 56dad583e4..eef758a0d9 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -42,10 +42,12 @@ reg_t kStrCat(EngineState *s, int argc, reg_t *argv) { Common::String s1 = s->_segMan->getString(argv[0]); Common::String s2 = s->_segMan->getString(argv[1]); - // The Japanese version of PQ2 splits the two strings here - // (check bug #3396887). - if (g_sci->getGameId() == GID_PQ2 && - g_sci->getLanguage() == Common::JA_JPN) { + // Japanese PC-9801 interpreter splits strings here + // see bug #5834 + // Verified for Police Quest 2 + Quest For Glory 1 + // However Space Quest 4 PC-9801 doesn't + if ((g_sci->getLanguage() == Common::JA_JPN) + && (getSciVersion() <= SCI_VERSION_01)) { s1 = g_sci->strSplit(s1.c_str(), NULL); s2 = g_sci->strSplit(s2.c_str(), NULL); } -- cgit v1.2.3 From eff78c442474185ecb1bde59bfc54c276178c480 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 4 Nov 2014 22:01:21 +0100 Subject: SCI: fix Japanese Space Quest 4 (intro + buttons) At least SQ4 uses #j text prefix as signal for the interpreter to not use the PC9801 hires font, but to use the internal low res font instead --- engines/sci/engine/kgraphics.cpp | 33 +++++++++++---- engines/sci/engine/state.cpp | 84 ++++++++++++++++++++----------------- engines/sci/graphics/controls16.cpp | 12 +++--- engines/sci/graphics/controls16.h | 6 +-- engines/sci/graphics/paint16.cpp | 6 +-- engines/sci/graphics/paint16.h | 2 +- engines/sci/graphics/text16.cpp | 24 ++++++----- engines/sci/graphics/text16.h | 13 ++++-- engines/sci/sci.h | 7 +++- 9 files changed, 112 insertions(+), 75 deletions(-) diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c2089bcd4d..ee2249bd9d 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -354,13 +354,16 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { } textWidth = dest[3].toUint16(); textHeight = dest[2].toUint16(); + + uint16 languageSplitter = 0; + Common::String splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter, sep); #ifdef ENABLE_SCI32 if (g_sci->_gfxText32) - g_sci->_gfxText32->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); + g_sci->_gfxText32->kernelTextSize(splitText.c_str(), font_nr, maxwidth, &textWidth, &textHeight); else #endif - g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); + g_sci->_gfxText16->kernelTextSize(splitText.c_str(), languageSplitter, font_nr, maxwidth, &textWidth, &textHeight); // One of the game texts in LB2 German contains loads of spaces in // its end. We trim the text here, otherwise the graphics code will @@ -376,7 +379,7 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { // Copy over the trimmed string... s->_segMan->strcpy(argv[1], text.c_str()); // ...and recalculate bounding box dimensions - g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); + g_sci->_gfxText16->kernelTextSize(splitText.c_str(), languageSplitter, font_nr, maxwidth, &textWidth, &textHeight); } } @@ -818,16 +821,29 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { if (!textReference.isNull()) text = s->_segMan->getString(textReference); + uint16 languageSplitter = 0; + Common::String splitText; + + switch (type) { + case SCI_CONTROLS_TYPE_BUTTON: + case SCI_CONTROLS_TYPE_TEXTEDIT: + splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter, NULL); + break; + case SCI_CONTROLS_TYPE_TEXT: + splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter); + break; + } + switch (type) { case SCI_CONTROLS_TYPE_BUTTON: debugC(kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d", PRINT_REG(controlObject), x, y); - g_sci->_gfxControls16->kernelDrawButton(rect, controlObject, g_sci->strSplit(text.c_str(), NULL).c_str(), fontId, style, hilite); + g_sci->_gfxControls16->kernelDrawButton(rect, controlObject, splitText.c_str(), languageSplitter, fontId, style, hilite); return; case SCI_CONTROLS_TYPE_TEXT: alignment = readSelectorValue(s->_segMan, controlObject, SELECTOR(mode)); debugC(kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d", PRINT_REG(controlObject), text.c_str(), x, y, alignment); - g_sci->_gfxControls16->kernelDrawText(rect, controlObject, g_sci->strSplit(text.c_str()).c_str(), fontId, alignment, style, hilite); + g_sci->_gfxControls16->kernelDrawText(rect, controlObject, splitText.c_str(), languageSplitter, fontId, alignment, style, hilite); s->r_acc = g_sci->_gfxText16->allocAndFillReferenceRectArray(); return; @@ -841,7 +857,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { writeSelectorValue(s->_segMan, controlObject, SELECTOR(cursor), cursorPos); } debugC(kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d", PRINT_REG(controlObject), PRINT_REG(textReference), text.c_str(), x, y); - g_sci->_gfxControls16->kernelDrawTextEdit(rect, controlObject, g_sci->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, cursorPos, maxChars, hilite); + g_sci->_gfxControls16->kernelDrawTextEdit(rect, controlObject, splitText.c_str(), languageSplitter, fontId, mode, style, cursorPos, maxChars, hilite); return; case SCI_CONTROLS_TYPE_ICON: @@ -1165,8 +1181,11 @@ reg_t kDisplay(EngineState *s, int argc, reg_t *argv) { argc--; argc--; argv++; argv++; text = g_sci->getKernel()->lookupText(textp, index); } + + uint16 languageSplitter = 0; + Common::String splitText = g_sci->strSplitLanguage(text.c_str(), &languageSplitter); - return g_sci->_gfxPaint16->kernelDisplay(g_sci->strSplit(text.c_str()).c_str(), argc, argv); + return g_sci->_gfxPaint16->kernelDisplay(splitText.c_str(), languageSplitter, argc, argv); } reg_t kSetVideoMode(EngineState *s, int argc, reg_t *argv) { diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 1b7fa7699e..c07dc925e0 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -203,37 +203,45 @@ static kLanguage charToLanguage(const char c) { } } -Common::String SciEngine::getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2) const { - kLanguage secondLang = K_LANG_NONE; - - const char *seeker = str.c_str(); - while (*seeker) { - if ((*seeker == '%') || (*seeker == '#')) { - secondLang = charToLanguage(*(seeker + 1)); - - if (secondLang != K_LANG_NONE) +Common::String SciEngine::getSciLanguageString(const Common::String &str, kLanguage requestedLanguage, kLanguage *secondaryLanguage, uint16 *languageSplitter) const { + kLanguage foundLanguage = K_LANG_NONE; + const byte *textPtr = (byte *)str.c_str(); + byte curChar = 0; + byte curChar2 = 0; + + while (1) { + curChar = *textPtr; + if (!curChar) + break; + + if ((curChar == '%') || (curChar == '#')) { + curChar2 = *(textPtr + 1); + foundLanguage = charToLanguage(curChar2); + + if (foundLanguage != K_LANG_NONE) { + // Return language splitter + if (languageSplitter) + *languageSplitter = curChar | ( curChar2 << 8 ); + // Return the secondary language found in the string + if (secondaryLanguage) + *secondaryLanguage = foundLanguage; break; + } } - - ++seeker; + textPtr++; } - // Return the secondary language found in the string - if (lang2) - *lang2 = secondLang; - - if (secondLang == lang) { - if (*(++seeker) == 'J') { + if (foundLanguage == requestedLanguage) { + if (curChar2 == 'J') { // Japanese including Kanji, displayed with system font // Convert half-width characters to full-width equivalents Common::String fullWidth; - byte curChar, curChar2; uint16 mappedChar; - seeker++; + textPtr += 2; // skip over language splitter while (1) { - curChar = *(seeker); + curChar = *textPtr; switch (curChar) { case 0: // Terminator NUL @@ -243,7 +251,7 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu // inside GetLongest() (text16). We do it here, because it's much cleaner and // we have to process the text here anyway. // Occurs for example in Police Quest 2 intro - curChar2 = *(seeker + 1); + curChar2 = *(textPtr + 1); switch (curChar2) { case 'n': case 'N': @@ -251,12 +259,12 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu case 'R': fullWidth += ' '; fullWidth += 0x0D; // CR - seeker += 2; + textPtr += 2; continue; } } - seeker++; + textPtr++; mappedChar = s_halfWidthSJISMap[curChar]; if (mappedChar) { @@ -264,7 +272,7 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu fullWidth += mappedChar & 0xFF; } else { // Copy double-byte character - curChar2 = *(seeker++); + curChar2 = *(textPtr++); if (!curChar) { error("SJIS character %02X is missing second byte", curChar); break; @@ -275,14 +283,14 @@ Common::String SciEngine::getSciLanguageString(const Common::String &str, kLangu } } else { - return Common::String(seeker + 1); + return Common::String((const char *)(textPtr + 2)); } } - if (*seeker) - return Common::String(str.c_str(), seeker - str.c_str()); - else - return str; + if (curChar) + return Common::String(str.c_str(), (const char *)textPtr - str.c_str()); + + return str; } kLanguage SciEngine::getSciLanguage() { @@ -341,25 +349,25 @@ void SciEngine::setSciLanguage() { setSciLanguage(getSciLanguage()); } -Common::String SciEngine::strSplit(const char *str, const char *sep) { - kLanguage lang = getSciLanguage(); - kLanguage subLang = K_LANG_NONE; +Common::String SciEngine::strSplitLanguage(const char *str, uint16 *languageSplitter, const char *sep) { + kLanguage activeLanguage = getSciLanguage(); + kLanguage subtitleLanguage = K_LANG_NONE; if (SELECTOR(subtitleLang) != -1) - subLang = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(subtitleLang)); + subtitleLanguage = (kLanguage)readSelectorValue(_gamestate->_segMan, _gameObjectAddress, SELECTOR(subtitleLang)); - kLanguage secondLang; - Common::String retval = getSciLanguageString(str, lang, &secondLang); + kLanguage foundLanguage; + Common::String retval = getSciLanguageString(str, activeLanguage, &foundLanguage, languageSplitter); // Don't add subtitle when separator is not set, subtitle language is not set, or // string contains only one language - if ((sep == NULL) || (subLang == K_LANG_NONE) || (secondLang == K_LANG_NONE)) + if ((sep == NULL) || (subtitleLanguage == K_LANG_NONE) || (foundLanguage == K_LANG_NONE)) return retval; // Add subtitle, unless the subtitle language doesn't match the languages in the string - if ((subLang == K_LANG_ENGLISH) || (subLang == secondLang)) { + if ((subtitleLanguage == K_LANG_ENGLISH) || (subtitleLanguage == foundLanguage)) { retval += sep; - retval += getSciLanguageString(str, subLang); + retval += getSciLanguageString(str, subtitleLanguage); } return retval; diff --git a/engines/sci/graphics/controls16.cpp b/engines/sci/graphics/controls16.cpp index f2b2ccdfe6..e2e250cf9d 100644 --- a/engines/sci/graphics/controls16.cpp +++ b/engines/sci/graphics/controls16.cpp @@ -280,7 +280,7 @@ int GfxControls16::getPicNotValid() { return _screen->_picNotValid; } -void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite) { +void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 style, bool hilite) { int16 sci0EarlyPen = 0, sci0EarlyBack = 0; if (!hilite) { if (getSciVersion() == SCI_VERSION_0_EARLY) { @@ -295,7 +295,7 @@ void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *t _paint16->frameRect(rect); rect.grow(-2); _ports->textGreyedOutput(!(style & SCI_CONTROLS_STYLE_ENABLED)); - _text16->Box(text, false, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId); + _text16->Box(text, languageSplitter, false, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId); _ports->textGreyedOutput(false); rect.grow(1); if (style & SCI_CONTROLS_STYLE_SELECTED) @@ -318,12 +318,12 @@ void GfxControls16::kernelDrawButton(Common::Rect rect, reg_t obj, const char *t } } -void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, TextAlignment alignment, int16 style, bool hilite) { +void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, TextAlignment alignment, int16 style, bool hilite) { if (!hilite) { rect.grow(1); _paint16->eraseRect(rect); rect.grow(-1); - _text16->Box(text, false, rect, alignment, fontId); + _text16->Box(text, languageSplitter, false, rect, alignment, fontId); if (style & SCI_CONTROLS_STYLE_SELECTED) { _paint16->frameRect(rect); } @@ -335,7 +335,7 @@ void GfxControls16::kernelDrawText(Common::Rect rect, reg_t obj, const char *tex } } -void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) { +void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) { Common::Rect textRect = rect; uint16 oldFontId = _text16->GetFontId(); @@ -343,7 +343,7 @@ void GfxControls16::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char _texteditCursorVisible = false; texteditCursorErase(); _paint16->eraseRect(rect); - _text16->Box(text, false, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId); + _text16->Box(text, languageSplitter, false, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId); _paint16->frameRect(rect); if (style & SCI_CONTROLS_STYLE_SELECTED) { _text16->SetFont(fontId); diff --git a/engines/sci/graphics/controls16.h b/engines/sci/graphics/controls16.h index 6a70c71aae..39ffa243fb 100644 --- a/engines/sci/graphics/controls16.h +++ b/engines/sci/graphics/controls16.h @@ -55,9 +55,9 @@ public: GfxControls16(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen); ~GfxControls16(); - void kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite); - void kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite); - void kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite); + void kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 style, bool hilite); + void kernelDrawText(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 alignment, int16 style, bool hilite); + void kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, uint16 languageSplitter, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite); void kernelDrawIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite); void kernelDrawList(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 style, int16 upperPos, int16 cursorPos, bool isAlias, bool hilite); void kernelTexteditChange(reg_t controlObject, reg_t eventObject); diff --git a/engines/sci/graphics/paint16.cpp b/engines/sci/graphics/paint16.cpp index b835eb92ca..f80703e14d 100644 --- a/engines/sci/graphics/paint16.cpp +++ b/engines/sci/graphics/paint16.cpp @@ -476,7 +476,7 @@ void GfxPaint16::kernelGraphRedrawBox(Common::Rect rect) { #define SCI_DISPLAY_DUMMY3 117 #define SCI_DISPLAY_DONTSHOWBITS 121 -reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) { +reg_t GfxPaint16::kernelDisplay(const char *text, uint16 languageSplitter, int argc, reg_t *argv) { reg_t displayArg; TextAlignment alignment = SCI_TEXT16_ALIGNMENT_LEFT; int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1; @@ -572,7 +572,7 @@ reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) { } // now drawing the text - _text16->Size(rect, text, -1, width); + _text16->Size(rect, text, languageSplitter, -1, width); rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop); // Note: This code has been found in SCI1 middle and newer games. It was // previously only for SCI1 late and newer, but the LSL1 interpreter contains @@ -588,7 +588,7 @@ reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) { result = bitsSave(rect, GFX_SCREEN_MASK_VISUAL); if (colorBack != -1) fillRect(rect, GFX_SCREEN_MASK_VISUAL, colorBack, 0, 0); - _text16->Box(text, false, rect, alignment, -1); + _text16->Box(text, languageSplitter, false, rect, alignment, -1); if (_screen->_picNotValid == 0 && bRedraw) bitsShow(rect); // restoring port and cursor pos diff --git a/engines/sci/graphics/paint16.h b/engines/sci/graphics/paint16.h index 882f311a5b..955cfdec8f 100644 --- a/engines/sci/graphics/paint16.h +++ b/engines/sci/graphics/paint16.h @@ -80,7 +80,7 @@ public: void kernelGraphUpdateBox(const Common::Rect &rect, bool hiresMode); void kernelGraphRedrawBox(Common::Rect rect); - reg_t kernelDisplay(const char *text, int argc, reg_t *argv); + reg_t kernelDisplay(const char *text, uint16 languageSplitter, int argc, reg_t *argv); reg_t kernelPortraitLoad(const Common::String &resourceName); void kernelPortraitShow(const Common::String &resourceName, Common::Point position, uint16 resourceNum, uint16 noun, uint16 verb, uint16 cond, uint16 seq); diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index 7552cb89ef..edeef31a5f 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -353,7 +353,7 @@ void GfxText16::DrawString(const char *str, GuiResourceId orgFontId, int16 orgPe Draw(str, 0, (int16)strlen(str), orgFontId, orgPenColor); } -int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId, int16 maxWidth) { +int16 GfxText16::Size(Common::Rect &rect, const char *text, uint16 languageSplitter, GuiResourceId fontId, int16 maxWidth) { GuiResourceId previousFontId = GetFontId(); int16 previousPenColor = _ports->_curPort->penClr; int16 charCount; @@ -369,7 +369,7 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId if (maxWidth < 0) { // force output as single line if (g_sci->getLanguage() == Common::JA_JPN) - SwitchToFont900OnSjis(text); + SwitchToFont900OnSjis(text, languageSplitter); StringWidth(text, fontId, textWidth, textHeight); rect.bottom = textHeight; @@ -383,7 +383,7 @@ int16 GfxText16::Size(Common::Rect &rect, const char *text, GuiResourceId fontId while (*curTextPos) { // We need to check for Shift-JIS every line if (g_sci->getLanguage() == Common::JA_JPN) - SwitchToFont900OnSjis(curTextPos); + SwitchToFont900OnSjis(curTextPos, languageSplitter); charCount = GetLongest(curTextPos, rect.right, fontId); if (charCount == 0) @@ -458,7 +458,7 @@ void GfxText16::Show(const char *text, int16 from, int16 len, GuiResourceId orgF } // Draws a text in rect. -void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) { +void GfxText16::Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) { int16 textWidth, maxTextWidth, textHeight, charCount; int16 offset = 0; int16 hline = 0; @@ -482,7 +482,7 @@ void GfxText16::Box(const char *text, bool show, const Common::Rect &rect, TextA // We need to check for Shift-JIS every line // Police Quest 2 PC-9801 often draws English + Japanese text during the same call if (g_sci->getLanguage() == Common::JA_JPN) { - if (SwitchToFont900OnSjis(curTextPos)) + if (SwitchToFont900OnSjis(curTextPos, languageSplitter)) doubleByteMode = true; } @@ -576,11 +576,13 @@ void GfxText16::DrawStatus(const char *text) { // Sierra did this in their PC98 interpreter only, they identify a text as being // sjis and then switch to font 900 -bool GfxText16::SwitchToFont900OnSjis(const char *text) { +bool GfxText16::SwitchToFont900OnSjis(const char *text, uint16 languageSplitter) { byte firstChar = (*(const byte *)text++); - if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF))) { - SetFont(900); - return true; + if (languageSplitter != 0x6a23) { // #j prefix as language splitter + if (((firstChar >= 0x81) && (firstChar <= 0x9F)) || ((firstChar >= 0xE0) && (firstChar <= 0xEF))) { + SetFont(900); + return true; + } } return false; } @@ -609,9 +611,9 @@ reg_t GfxText16::allocAndFillReferenceRectArray() { return NULL_REG; } -void GfxText16::kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) { +void GfxText16::kernelTextSize(const char *text, uint16 languageSplitter, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) { Common::Rect rect(0, 0, 0, 0); - Size(rect, text, font, maxWidth); + Size(rect, text, languageSplitter, font, maxWidth); *textWidth = rect.width(); *textHeight = rect.height(); } diff --git a/engines/sci/graphics/text16.h b/engines/sci/graphics/text16.h index 715891be44..2724d97347 100644 --- a/engines/sci/graphics/text16.h +++ b/engines/sci/graphics/text16.h @@ -56,10 +56,15 @@ public: void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight); void ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor); void DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor); - int16 Size(Common::Rect &rect, const char *text, GuiResourceId fontId, int16 maxWidth); + int16 Size(Common::Rect &rect, const char *text, uint16 textLanguage, GuiResourceId fontId, int16 maxWidth); void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor); void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor); - void Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId); + void Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId); + + void Box(const char *text, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) { + Box(text, 0, show, rect, alignment, fontId); + } + void DrawString(const char *text); void DrawStatus(const char *text); @@ -67,13 +72,13 @@ public: reg_t allocAndFillReferenceRectArray(); - void kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight); + void kernelTextSize(const char *text, uint16 textLanguage, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight); void kernelTextFonts(int argc, reg_t *argv); void kernelTextColors(int argc, reg_t *argv); private: void init(); - bool SwitchToFont900OnSjis(const char *text); + bool SwitchToFont900OnSjis(const char *text, uint16 languageSplitter); GfxCache *_cache; GfxPorts *_ports; diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 2377386c72..4928fd1b4e 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -314,13 +314,16 @@ public: * if NULL is passed no subtitle will be added to the returned string * @return processed string */ - Common::String strSplit(const char *str, const char *sep = "\r----------\r"); + Common::String strSplitLanguage(const char *str, uint16 *splitLanguage, const char *sep = "\r----------\r"); + Common::String strSplit(const char *str, const char *sep = "\r----------\r") { + return strSplitLanguage(str, NULL, sep); + } kLanguage getSciLanguage(); void setSciLanguage(kLanguage lang); void setSciLanguage(); - Common::String getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2 = NULL) const; + Common::String getSciLanguageString(const Common::String &str, kLanguage lang, kLanguage *lang2 = NULL, uint16 *languageSplitter = NULL) const; // Check if vocabulary needs to get switched (in multilingual parser games) void checkVocabularySwitch(); -- cgit v1.2.3 From 0a2c1a809f1335f2d259fa7e3070405232687b00 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Nov 2014 19:07:03 +0100 Subject: WINTERMUTE: Keep _[show|current]Subtitle private in video_subtitler.h --- engines/wintermute/video/video_subtitler.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index c1730c84fd..f97461cd87 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -39,15 +39,14 @@ class VideoSubtitler : public: VideoSubtitler(BaseGame *inGame); virtual ~VideoSubtitler(void); - - bool _showSubtitle; - uint32 _currentSubtitle; bool loadSubtitles(const Common::String &filename, const Common::String &subtitleFile); void display(); void update(uint32 frame); private: Common::Array _subtitles; int32 _lastSample; + bool _showSubtitle; + uint32 _currentSubtitle; }; } // End of namespace Wintermute -- cgit v1.2.3 From 215ac157e6f694327d5de0ec46a6fc1eabbf4719 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Nov 2014 19:28:42 +0100 Subject: WINTERMUTE: Declare vars inside appropriate block in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 52bae27d2d..e3127d1c5e 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -85,7 +85,6 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: file->read(buffer, fileSize); - int start, end; bool inToken; char *tokenStart = 0; int tokenLength = 0; @@ -98,6 +97,8 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: * {StartFrame}{EndFrame} FirstLine | SecondLine \n */ while (pos < fileSize) { + int start, end; + start = end = -1; inToken = false; tokenPos = -1; -- cgit v1.2.3 From 2f082f6e438598f9093c92482bd6f75af264d785 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Nov 2014 19:31:10 +0100 Subject: WINTERMUTE: Remove redundant explicit call to Common::String constructor --- engines/wintermute/video/video_subtitler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index e3127d1c5e..86f8f9b128 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -66,7 +66,7 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: * /some/path/movie.sub */ if (subtitleFile.size() != 0) { - newFile = Common::String(subtitleFile); + newFile = subtitleFile; } else { Common::String path = PathUtil::getDirectoryName(filename); Common::String name = PathUtil::getFileNameWithoutExtension(filename); -- cgit v1.2.3 From 998da18c05c159f6dffe2b25d0afe23021c8ec38 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Nov 2014 19:42:17 +0100 Subject: WINTERMUTE: Move var declarations inside loop in loadSubtitles --- engines/wintermute/video/video_subtitler.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.cpp b/engines/wintermute/video/video_subtitler.cpp index 86f8f9b128..95d938574b 100644 --- a/engines/wintermute/video/video_subtitler.cpp +++ b/engines/wintermute/video/video_subtitler.cpp @@ -85,25 +85,20 @@ bool VideoSubtitler::loadSubtitles(const Common::String &filename, const Common: file->read(buffer, fileSize); - bool inToken; - char *tokenStart = 0; - int tokenLength = 0; - int tokenPos = 0; - - int pos = 0; - int lineLength = 0; /* This is where we parse .sub files. * Subtitles cards are in the form * {StartFrame}{EndFrame} FirstLine | SecondLine \n */ - while (pos < fileSize) { - int start, end; - - start = end = -1; - inToken = false; - tokenPos = -1; + int pos = 0; - lineLength = 0; + while (pos < fileSize) { + char *tokenStart = 0; + int tokenLength = 0; + int tokenPos = -1; + int lineLength = 0; + int start = -1; + int end = -1; + bool inToken = false; while (pos + lineLength < fileSize && buffer[pos + lineLength] != '\n' && -- cgit v1.2.3 From 9787fc5768fdc7338433fa5bcbc606f7d8ffe1d2 Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 5 Nov 2014 19:45:39 +0100 Subject: WINTERMUTE: Fix formatting in video_subtitler.h --- engines/wintermute/video/video_subtitler.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/wintermute/video/video_subtitler.h b/engines/wintermute/video/video_subtitler.h index f97461cd87..94f22909a1 100644 --- a/engines/wintermute/video/video_subtitler.h +++ b/engines/wintermute/video/video_subtitler.h @@ -34,8 +34,7 @@ namespace Wintermute { -class VideoSubtitler : - public BaseClass { +class VideoSubtitler : public BaseClass { public: VideoSubtitler(BaseGame *inGame); virtual ~VideoSubtitler(void); -- cgit v1.2.3 From 0fd16ef39f503016c710e264752f41caa8daf724 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Thu, 6 Nov 2014 20:45:24 +0100 Subject: SCI: hopefully Japanese text wrapping is fine now also removed duplicate entries in punctuation table thanks to wjp --- engines/sci/graphics/text16.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index edeef31a5f..f463dff4b1 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -145,9 +145,9 @@ int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int1 // Has actually punctuation and characters in it, that may not be the first in a line static const uint16 text16_shiftJIS_punctuation[] = { - 0x9F82, 0xA182, 0xA382, 0xA582, 0xA782, 0xC182, 0xA782, 0xC182, 0xE182, 0xE382, 0xE582, 0xEC82, - 0x4083, 0x4283, 0x4483, 0x4683, 0x4883, 0x6283, 0x8383, 0x8583, 0x8783, 0x8E83, 0x9583, 0x9683, - 0x5B81, 0x4181, 0x4281, 0x7681, 0x7881, 0x4981, 0x4881, 0 + 0x9F82, 0xA182, 0xA382, 0xA582, 0xA782, 0xC182, 0xE182, 0xE382, 0xE582, 0xEC82, 0x4083, 0x4283, + 0x4483, 0x4683, 0x4883, 0x6283, 0x8383, 0x8583, 0x8783, 0x8E83, 0x9583, 0x9683, 0x5B81, 0x4181, + 0x4281, 0x7681, 0x7881, 0x4981, 0x4881, 0 }; // return max # of chars to fit maxwidth with full words, does not include @@ -237,34 +237,32 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId if (lastSpaceCharCount) { // Break and at least one space was found before that resultCharCount = lastSpaceCharCount; - + // additionally skip over all spaces, that are following that space, but don't count them for displaying purposes textPtr = lastSpacePtr; while (*textPtr == ' ') textPtr++; - + } else { // Break without spaces found, we split the very first word - may also be Kanji/Japanese if (curChar > 0xFF) { // current charracter is Japanese - + // PC-9801 SCI actually added the last character, which shouldn't fit anymore, still onto the // screen in case maxWidth wasn't fully reached with the last character - if (maxWidth == curWidth) { - curCharCount -= 2; textPtr -= 2; - if (textPtr < textStartPtr) - error("Seeking back went too far, data corruption?"); + if (( maxWidth - 1 ) > curWidth) { + curCharCount += 2; textPtr += 2; curChar = (*(const byte *)textPtr); - if (!_font->isDoubleByte(curChar)) - error("Non double byte while seeking back"); - curChar |= (*(const byte *)(textPtr + 1)) << 8; + if (_font->isDoubleByte(curChar)) { + curChar |= (*(const byte *)(textPtr + 1)) << 8; + } } - + // But it also checked, if the current character is not inside a punctuation table and it even // went backwards in case it found multiple ones inside that table. uint nonBreakingPos = 0; - + while (1) { // Look up if character shouldn't be the first on a new line nonBreakingPos = 0; @@ -281,14 +279,12 @@ int16 GfxText16::GetLongest(const char *&textPtr, int16 maxWidth, GuiResourceId curCharCount -= 2; textPtr -= 2; if (textPtr < textStartPtr) error("Seeking back went too far, data corruption?"); - + curChar = (*(const byte *)textPtr); if (!_font->isDoubleByte(curChar)) error("Non double byte while seeking back"); curChar |= (*(const byte *)(textPtr + 1)) << 8; } - // include the current character - curCharCount += 2; textPtr += 2; } // We split the word in that case -- cgit v1.2.3 From 3131e3aa5a3a4911c12223af06ad0d2885f64606 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Nov 2014 10:21:24 +0600 Subject: ZVISION: Add missing methods definition --- engines/zvision/zvision.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8a305f5d37..0bee639458 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -180,6 +180,9 @@ public: void setRenderDelay(uint); bool canRender(); + void loadSettings(); + void saveSettings(); + private: void initialize(); void initFonts(); @@ -191,6 +194,8 @@ private: void onMouseMove(const Common::Point &pos); void updateRotation(); + + void registerDefaultSettings(); }; } // End of namespace ZVision -- cgit v1.2.3 From 7151240345cc723c0084a4ea5dda9aaaa4dff690 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Nov 2014 10:23:29 +0600 Subject: ZVISION: Now setBackgroundPosition must care about statekey value --- engines/zvision/graphics/render_manager.cpp | 3 +++ engines/zvision/zvision.cpp | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index ce1962a8ee..4d5bcf754b 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -24,6 +24,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" #include "zvision/text/text.h" #include "zvision/utility/lzss_read_stream.h" @@ -384,6 +385,8 @@ void RenderManager::setBackgroundPosition(int offset) { if (_bkgOff != offset) _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); _bkgOff = offset; + + _engine->getScriptManager()->setStateValue(StateKey_ViewPos, offset); } uint32 RenderManager::getCurrentBackgroundOffset() { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 77c47d9b1e..41d3eea6aa 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -383,7 +383,6 @@ void ZVision::updateRotation() { if (new_pos < 0) new_pos += scr_width; - _scriptManager->setStateValue(StateKey_ViewPos, new_pos); _renderManager->setBackgroundPosition(new_pos); } else if (renderState == RenderTable::TILT) { int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); @@ -398,7 +397,6 @@ void ZVision::updateRotation() { if (new_pos <= tilt_gap) new_pos = tilt_gap; - _scriptManager->setStateValue(StateKey_ViewPos, new_pos); _renderManager->setBackgroundPosition(new_pos); } } -- cgit v1.2.3 From 0efa1bc5606c9fd984df077d55cf93a7903f5f67 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 7 Nov 2014 10:25:11 +0600 Subject: ZVISION: Implement action:rotate_to --- engines/zvision/scripting/actions.cpp | 15 +++++++ engines/zvision/scripting/actions.h | 10 +++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/zvision.cpp | 52 +++++++++++++++++++++++++ engines/zvision/zvision.h | 2 + 5 files changed, 80 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 9733c5cae8..2754a39676 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -612,6 +612,21 @@ bool ActionRandom::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionRotateTo +////////////////////////////////////////////////////////////////////////////// + +ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%d, %d", &_toPos, &_time); +} + +bool ActionRotateTo::execute() { + _engine->rotateTo(_toPos, _time); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionSetPartialScreen diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index f51847ed05..6a200198b7 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -360,6 +360,16 @@ private: ValueSlot *_max; }; +class ActionRotateTo : public ResultAction { +public: + ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + int32 _toPos; + int32 _time; +}; + class ActionSetPartialScreen : public ResultAction { public: ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index df60b0b8d4..b16a2d9474 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -270,7 +270,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("restore_game", true)) { // TODO: Implement ActionRestoreGame } else if (act.matchString("rotate_to", true)) { - // TODO: Implement ActionRotateTo + actionList.push_back(new ActionRotateTo(_engine, slot, args)); } else if (act.matchString("save_game", true)) { // TODO: Implement ActionSaveGame } else if (act.matchString("set_partial_screen", true)) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 41d3eea6aa..79f7d74a8d 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -402,4 +402,56 @@ void ZVision::updateRotation() { } } +void ZVision::rotateTo(int16 _toPos, int16 _time) { + if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA) + return; + + if (_time == 0) + _time = 1; + + int32 maxX = _renderManager->getBkgSize().x; + int32 curX = _renderManager->getCurrentBackgroundOffset(); + int32 dx = 0; + + if (curX == _toPos) + return; + + if (curX > _toPos) { + if (curX - _toPos > maxX / 2) + dx = (_toPos + (maxX - curX)) / _time; + else + dx = -(curX - _toPos) / _time; + } else { + if (_toPos - curX > maxX / 2) + dx = -((maxX - _toPos) + curX) / _time; + else + dx = (_toPos - curX) / _time; + } + + _clock.stop(); + + for (int16 i = 0; i <= _time; i++) { + if (i == _time) + curX = _toPos; + else + curX += dx; + + if (curX < 0) + curX = maxX - curX; + else if (curX >= maxX) + curX %= maxX; + + _renderManager->setBackgroundPosition(curX); + + _renderManager->prepareBkg(); + _renderManager->renderBackbufferToScreen(); + + _system->updateScreen(); + + _system->delayMillis(500 / _time); + } + + _clock.start(); +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 0bee639458..e2bde7bd9e 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -170,6 +170,8 @@ public: */ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL); + void rotateTo(int16 to, int16 time); + Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); -- cgit v1.2.3 From 9f2c3d794e4594fd736b6130412c1685ea21afc9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 7 Nov 2014 12:09:13 +0200 Subject: GROOVIE: Do not play audio in V2 games when only one frame is shown --- engines/groovie/roq.cpp | 18 ++++++++++++------ engines/groovie/roq.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp index 8f272d4404..f14cacd6b8 100644 --- a/engines/groovie/roq.cpp +++ b/engines/groovie/roq.cpp @@ -174,7 +174,7 @@ bool ROQPlayer::playFrameInternal() { // Wait until the current frame can be shown // Don't wait if we're just showing one frame - if (!(_alpha && !_flagTwo)) + if (!playFirstFrame()) waitFrame(); if (_dirty) { @@ -193,7 +193,7 @@ bool ROQPlayer::playFrameInternal() { // Report the end of the video if we reached the end of the file or if we // just wanted to play one frame. - return _file->eos() || (_alpha && !_flagTwo); + return _file->eos() || playFirstFrame(); } bool ROQPlayer::readBlockHeader(ROQBlockHeader &blockHeader) { @@ -492,7 +492,7 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) { } // Initialize the audio stream if needed - if (!_audioStream) { + if (!_audioStream && !playFirstFrame()) { _audioStream = Audio::makeQueuingAudioStream(22050, false); Audio::SoundHandle sound_handle; g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &sound_handle, _audioStream); @@ -521,7 +521,10 @@ bool ROQPlayer::processBlockSoundMono(ROQBlockHeader &blockHeader) { #ifdef SCUMM_LITTLE_ENDIAN flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags); + if (!playFirstFrame()) + _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags); + else + free(buffer); return true; } @@ -535,7 +538,7 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) { } // Initialize the audio stream if needed - if (!_audioStream) { + if (!_audioStream && !playFirstFrame()) { _audioStream = Audio::makeQueuingAudioStream(22050, true); Audio::SoundHandle sound_handle; g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &sound_handle, _audioStream); @@ -577,7 +580,10 @@ bool ROQPlayer::processBlockSoundStereo(ROQBlockHeader &blockHeader) { #ifdef SCUMM_LITTLE_ENDIAN flags |= Audio::FLAG_LITTLE_ENDIAN; #endif - _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags); + if (!playFirstFrame()) + _audioStream->queueBuffer((byte *)buffer, blockHeader.size * 2, DisposeAfterUse::YES, flags); + else + free(buffer); return true; } diff --git a/engines/groovie/roq.h b/engines/groovie/roq.h index b720e6a235..ce1a3a2d58 100644 --- a/engines/groovie/roq.h +++ b/engines/groovie/roq.h @@ -57,6 +57,7 @@ private: bool processBlockSoundMono(ROQBlockHeader &blockHeader); bool processBlockSoundStereo(ROQBlockHeader &blockHeader); bool processBlockAudioContainer(ROQBlockHeader &blockHeader); + bool playFirstFrame() { return _alpha && !_flagTwo; } void paint2(byte i, int destx, int desty); void paint4(byte i, int destx, int desty); -- cgit v1.2.3 From 53002dd2d067c24baaecfbc32071365bef58cfca Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 12:21:38 +0600 Subject: ZVISION: Implement action:animunload --- engines/zvision/scripting/actions.cpp | 19 +++++++++++++++++++ engines/zvision/scripting/actions.h | 2 ++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 2754a39676..8a3d17f2c5 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -440,6 +440,25 @@ bool ActionPreloadAnimation::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionUnloadAnimation +////////////////////////////////////////////////////////////////////////////// + +ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + + sscanf(line.c_str(), "%u", &_key); +} + +bool ActionUnloadAnimation::execute() { + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + + if (nod && nod->getType() == SideFX::SIDEFX_ANIM) + _engine->getScriptManager()->deleteSideFx(_key); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionPlayAnimation diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 6a200198b7..731105d591 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -347,6 +347,8 @@ class ActionUnloadAnimation : public ResultAction { public: ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); +private: + uint32 _key; }; class ActionRandom : public ResultAction { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index b16a2d9474..a2b5311666 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -220,7 +220,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("animpreload", true)) { actionList.push_back(new ActionPreloadAnimation(_engine, slot, args)); } else if (act.matchString("animunload", true)) { - //actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); + actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); } else if (act.matchString("attenuate", true)) { actionList.push_back(new ActionAttenuate(_engine, slot, args)); } else if (act.matchString("assign", true)) { -- cgit v1.2.3 From d0f6b61d7d86598c71c7ff8679f610bbd1341aaa Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 12:26:04 +0600 Subject: ZVISION: Implement action:delay_render --- engines/zvision/scripting/actions.cpp | 13 +++++++++++++ engines/zvision/scripting/actions.h | 3 +-- engines/zvision/scripting/scr_file_handling.cpp | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 8a3d17f2c5..3763eb6e30 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -160,6 +160,19 @@ bool ActionCrossfade::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionDelayRender +////////////////////////////////////////////////////////////////////////////// + +ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%u", &_framesToDelay); +} + +bool ActionDelayRender::execute() { + _engine->setRenderDelay(_framesToDelay); + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionDisableControl diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 731105d591..ade57ba14c 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -162,8 +162,7 @@ public: bool execute(); private: - // TODO: Check if this should actually be frames or if it should be milliseconds/seconds - uint32 framesToDelay; + uint32 _framesToDelay; }; class ActionDisableControl : public ResultAction { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index a2b5311666..68840aa413 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -232,7 +232,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("debug", true)) { // TODO: Implement ActionDebug } else if (act.matchString("delay_render", true)) { - // TODO: Implement ActionDelayRender + actionList.push_back(new ActionDelayRender(_engine, slot, args)); } else if (act.matchString("disable_control", true)) { actionList.push_back(new ActionDisableControl(_engine, slot, args)); } else if (act.matchString("disable_venus", true)) { -- cgit v1.2.3 From 7ddfcfd17ec1e367896c223d5b8dc59b44d4029e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 12:44:00 +0600 Subject: ZVISION: Implement action:disable_venus and action:set_venus --- engines/zvision/scripting/actions.cpp | 32 +++++++++++++++++++++++++ engines/zvision/scripting/actions.h | 10 ++++++++ engines/zvision/scripting/scr_file_handling.cpp | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 3763eb6e30..33add9f8fa 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -188,6 +188,21 @@ bool ActionDisableControl::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionDisableVenus +////////////////////////////////////////////////////////////////////////////// + +ActionDisableVenus::ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%d", &_key); +} + +bool ActionDisableVenus::execute() { + _engine->getScriptManager()->setStateValue(_key, 0); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionDisplayMessage ////////////////////////////////////////////////////////////////////////////// @@ -715,6 +730,23 @@ bool ActionSetScreen::execute() { return true; } + +////////////////////////////////////////////////////////////////////////////// +// ActionSetVenus +////////////////////////////////////////////////////////////////////////////// + +ActionSetVenus::ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%d", &_key); +} + +bool ActionSetVenus::execute() { + if (_engine->getScriptManager()->getStateValue(_key)) + _engine->getScriptManager()->setStateValue(StateKey_Venus, _key); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionStop ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index ade57ba14c..b80af9a6c5 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -180,6 +180,7 @@ public: bool execute(); private: + int32 _key; }; class ActionDisplayMessage : public ResultAction { @@ -392,6 +393,15 @@ private: Common::String _fileName; }; +class ActionSetVenus : public ResultAction { +public: + ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + int32 _key; +}; + class ActionStop : public ResultAction { public: ActionStop(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 68840aa413..c7268e6111 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -236,7 +236,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("disable_control", true)) { actionList.push_back(new ActionDisableControl(_engine, slot, args)); } else if (act.matchString("disable_venus", true)) { - // TODO: Implement ActionDisableVenus + actionList.push_back(new ActionDisableVenus(_engine, slot, args)); } else if (act.matchString("display_message", true)) { actionList.push_back(new ActionDisplayMessage(_engine, slot, args)); } else if (act.matchString("dissolve", true)) { @@ -278,7 +278,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("set_screen", true)) { actionList.push_back(new ActionSetScreen(_engine, slot, args)); } else if (act.matchString("set_venus", true)) { - // TODO: Implement ActionSetVenus + actionList.push_back(new ActionSetVenus(_engine, slot, args)); } else if (act.matchString("stop", true)) { actionList.push_back(new ActionStop(_engine, slot, args)); } else if (act.matchString("streamvideo", true)) { -- cgit v1.2.3 From b8ef942f692d7354fed3fd889994c499db714ba7 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 12:58:11 +0600 Subject: ZVISION: Implement action:dissolve --- engines/zvision/graphics/render_manager.cpp | 5 +++++ engines/zvision/graphics/render_manager.h | 2 ++ engines/zvision/scripting/actions.cpp | 14 ++++++++++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 4d5bcf754b..8411f190a7 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -1053,4 +1053,9 @@ void RenderManager::markDirty() { _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); } +void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) { + _curBkg.fillRect(Common::Rect(_curBkg.w, _curBkg.h), _curBkg.format.RGBToColor(r, g, b)); + markDirty(); +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index e0fc5c248c..ae24ce4f58 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -283,6 +283,8 @@ public: Common::Rect bkgRectToScreen(const Common::Rect &src); void markDirty(); + + void bkgFill(uint8 r, uint8 g, uint8 b); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 33add9f8fa..96411e2c3d 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -221,6 +221,20 @@ bool ActionDisplayMessage::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionDissolve +////////////////////////////////////////////////////////////////////////////// + +ActionDissolve::ActionDissolve(ZVision *engine) : + ResultAction(engine, 0) { +} + +bool ActionDissolve::execute() { + // Cause black screen flick + // _engine->getRenderManager()->bkgFill(0, 0, 0); + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionDistort ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index c7268e6111..daec4f8f18 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -240,7 +240,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("display_message", true)) { actionList.push_back(new ActionDisplayMessage(_engine, slot, args)); } else if (act.matchString("dissolve", true)) { - // TODO: Implement ActionDissolve + actionList.push_back(new ActionDissolve(_engine)); } else if (act.matchString("distort", true)) { actionList.push_back(new ActionDistort(_engine, slot, args)); } else if (act.matchString("enable_control", true)) { -- cgit v1.2.3 From 66d2cb46989537d80855952cff2c0be1b5d6c320 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 12:59:58 +0600 Subject: ZVISION: Implement action:flush_mouse_events --- engines/zvision/scripting/actions.cpp | 14 ++++++++++++++ engines/zvision/scripting/actions.h | 6 ++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 11 +++++++++++ engines/zvision/scripting/script_manager.h | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 96411e2c3d..42b71ea5cc 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -271,6 +271,20 @@ bool ActionEnableControl::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionFlushMouseEvents +////////////////////////////////////////////////////////////////////////////// + +ActionFlushMouseEvents::ActionFlushMouseEvents(ZVision *engine, int32 slotkey) : + ResultAction(engine, slotkey) { +} + +bool ActionFlushMouseEvents::execute() { + _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONUP); + _engine->getScriptManager()->flushEvent(Common::EVENT_LBUTTONDOWN); + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionInventory ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index b80af9a6c5..c03238571c 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -223,6 +223,12 @@ private: uint32 _key; }; +class ActionFlushMouseEvents : public ResultAction { +public: + ActionFlushMouseEvents(ZVision *engine, int32 slotkey); + bool execute(); +}; + class ActionInventory : public ResultAction { public: ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index daec4f8f18..a4d127f6f9 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -246,7 +246,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("enable_control", true)) { actionList.push_back(new ActionEnableControl(_engine, slot, args)); } else if (act.matchString("flush_mouse_events", true)) { - // TODO: Implement ActionFlushMouseEvents + actionList.push_back(new ActionFlushMouseEvents(_engine, slot)); } else if (act.matchString("inventory", true)) { actionList.push_back(new ActionInventory(_engine, slot, args)); } else if (act.matchString("kill", true)) { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index d2165734b4..28958dd972 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -775,6 +775,17 @@ void ScriptManager::addEvent(Common::Event event) { _controlEvents.push_back(event); } +void ScriptManager::flushEvent(Common::EventType type) { + EventList::iterator it = _controlEvents.begin(); + while (it != _controlEvents.end()) { + + if ((*it).type == type) + it = _controlEvents.erase(it); + else + it++; + } +} + ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val): _sc_man(sc_man) { value = 0; diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 3fcbad5fa4..fb17077aa6 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -200,6 +200,7 @@ public: void killSideFxType(SideFX::SideFXType type); void addEvent(Common::Event); + void flushEvent(Common::EventType type); /** * Called when LeftMouse is pushed. -- cgit v1.2.3 From 44eeb4027250a2989a9e34a303383fa8533a7a84 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 13:02:48 +0600 Subject: ZVISION: Implement action:menu_bar_enable --- engines/zvision/core/menu.h | 4 ++++ engines/zvision/scripting/actions.cpp | 13 +++++++++++++ engines/zvision/scripting/actions.h | 8 ++++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/zvision.cpp | 5 +++++ engines/zvision/zvision.h | 2 ++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index cc802ee5f5..7e6acf325c 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -48,6 +48,10 @@ public: virtual void onMouseDown(const Common::Point &Pos) {}; virtual void onMouseUp(const Common::Point &Pos) {}; virtual void process(uint32 deltaTimeInMillis) {}; + + void setEnable(uint16 flags) { + menu_bar_flag = flags; + } protected: uint16 menu_bar_flag; ZVision *_engine; diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 42b71ea5cc..fbf887f779 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -374,6 +374,19 @@ bool ActionKill::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionMenuBarEnable +////////////////////////////////////////////////////////////////////////////// + +ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + sscanf(line.c_str(), "%hu", &_menus); +} + +bool ActionMenuBarEnable::execute() { + _engine->menuBarEnable(_menus); + return true; +} ////////////////////////////////////////////////////////////////////////////// // ActionMusic diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index c03238571c..fed620926d 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -248,6 +248,14 @@ private: uint32 _type; }; +class ActionMenuBarEnable : public ResultAction { +public: + ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); +private: + uint16 _menus; +}; + class ActionMusic : public ResultAction { public: ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index a4d127f6f9..ca92890b19 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -252,7 +252,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("kill", true)) { actionList.push_back(new ActionKill(_engine, slot, args)); } else if (act.matchString("menu_bar_enable", true)) { - // TODO: Implement ActionMenuBarEnable + actionList.push_back(new ActionMenuBarEnable(_engine, slot, args)); } else if (act.matchString("music", true)) { actionList.push_back(new ActionMusic(_engine, slot, args, false)); } else if (act.matchString("pan_track", true)) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 79f7d74a8d..4f05edaefd 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -454,4 +454,9 @@ void ZVision::rotateTo(int16 _toPos, int16 _time) { _clock.start(); } +void ZVision::menuBarEnable(uint16 menus) { + if (_menu) + _menu->setEnable(menus); +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index e2bde7bd9e..def9bbbdfb 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -185,6 +185,8 @@ public: void loadSettings(); void saveSettings(); + void menuBarEnable(uint16 menus); + private: void initialize(); void initFonts(); -- cgit v1.2.3 From 19e2251a7562defc560a25dd4655ededad4d5369 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 13:04:27 +0600 Subject: ZVISION: Implement action:preferences --- engines/zvision/scripting/actions.cpp | 21 +++++++++++++++++++++ engines/zvision/scripting/actions.h | 9 +++++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index fbf887f779..1e1b3b2862 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -473,6 +473,27 @@ bool ActionPanTrack::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionPreferences +////////////////////////////////////////////////////////////////////////////// + +ActionPreferences::ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + if (line.compareToIgnoreCase("save") == 0) + _save = true; + else + _save = false; +} + +bool ActionPreferences::execute() { + if (_save) + _engine->saveSettings(); + else + _engine->loadSettings(); + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionPreloadAnimation ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index fed620926d..dd771c1078 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -334,6 +334,15 @@ private: int32 _framerate; }; +class ActionPreferences : public ResultAction { +public: + ActionPreferences(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + bool _save; +}; + class ActionQuit : public ResultAction { public: ActionQuit(ZVision *engine, int32 slotkey) : ResultAction(engine, slotkey) {} diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index ca92890b19..06354feaae 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -260,7 +260,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("playpreload", true)) { actionList.push_back(new ActionPlayPreloadAnimation(_engine, slot, args)); } else if (act.matchString("preferences", true)) { - // TODO: Implement ActionPreferences + actionList.push_back(new ActionPreferences(_engine, slot, args)); } else if (act.matchString("quit", true)) { actionList.push_back(new ActionQuit(_engine, slot)); } else if (act.matchString("random", true)) { -- cgit v1.2.3 From ea8cc34a66f7b8a853d396daaade9de25efb431f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 13:06:48 +0600 Subject: ZVISION: Implement action:restore_game --- engines/zvision/scripting/actions.cpp | 17 +++++++++++ engines/zvision/scripting/actions.h | 9 ++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 40 +++++++++++++------------ engines/zvision/scripting/script_manager.h | 4 +-- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 1e1b3b2862..04f318b84e 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -42,6 +42,7 @@ #include "zvision/graphics/effects/fog.h" #include "zvision/graphics/effects/light.h" #include "zvision/graphics/effects/wave.h" +#include "zvision/core/save_manager.h" #include "common/file.h" @@ -721,6 +722,22 @@ bool ActionRandom::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionRestoreGame +////////////////////////////////////////////////////////////////////////////// + +ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + char buf[128]; + sscanf(line.c_str(), "%s", buf); + _fileName = Common::String(buf); +} + +bool ActionRestoreGame::execute() { + _engine->getSaveManager()->loadGame(_fileName); + return false; +} + ////////////////////////////////////////////////////////////////////////////// // ActionRotateTo ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index dd771c1078..a6b5aa1290 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -385,6 +385,15 @@ private: ValueSlot *_max; }; +class ActionRestoreGame : public ResultAction { +public: + ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + Common::String _fileName; +}; + class ActionRotateTo : public ResultAction { public: ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 06354feaae..d5f5704f2a 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -268,7 +268,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("region", true)) { actionList.push_back(new ActionRegion(_engine, slot, args)); } else if (act.matchString("restore_game", true)) { - // TODO: Implement ActionRestoreGame + actionList.push_back(new ActionRestoreGame(_engine, slot, args)); } else if (act.matchString("rotate_to", true)) { actionList.push_back(new ActionRotateTo(_engine, slot, args)); } else if (act.matchString("save_game", true)) { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 28958dd972..457b491042 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -79,14 +79,18 @@ void ScriptManager::update(uint deltaTimeMillis) { do_changeLocation(); updateNodes(deltaTimeMillis); - execScope(nodeview); - execScope(room); - execScope(world); - execScope(universe); + if (! execScope(nodeview)) + return; + if (! execScope(room)) + return; + if (! execScope(world)) + return; + if (! execScope(universe)) + return; updateControls(deltaTimeMillis); } -void ScriptManager::execScope(script_scope &scope) { +bool ScriptManager::execScope(script_scope &scope) { // Swap queues PuzzleList *tmp = scope.exec_queue; scope.exec_queue = scope.scope_queue; @@ -98,15 +102,18 @@ void ScriptManager::execScope(script_scope &scope) { if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) { for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) - checkPuzzleCriteria(*PuzzleIter, scope.proc_count); + if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count)) + return false; } else { for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter) - checkPuzzleCriteria(*PuzzleIter, scope.proc_count); + if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count)) + return false; } if (scope.proc_count < 2) { scope.proc_count++; } + return true; } void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) { @@ -185,16 +192,16 @@ void ScriptManager::updateControls(uint deltaTimeMillis) { break; } -void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { +bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { // Check if the puzzle is already finished // Also check that the puzzle isn't disabled if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) { - return; + return true; } // Check each Criteria if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0) - return; + return true; bool criteriaMet = false; for (Common::List >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) { @@ -243,18 +250,13 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) { // Set the puzzle as completed setStateValue(puzzle->key, 1); - bool shouldContinue = true; for (Common::List::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) { - shouldContinue = shouldContinue && (*resultIter)->execute(); - if (!shouldContinue) { - break; - } - } - - if (!shouldContinue) { - return; + if (!(*resultIter)->execute()) + return false; } } + + return true; } void ScriptManager::cleanStateTable() { diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index fb17077aa6..ddb8c885aa 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -253,10 +253,10 @@ private: void addPuzzlesToReferenceTable(script_scope &scope); void updateNodes(uint deltaTimeMillis); void updateControls(uint deltaTimeMillis); - void checkPuzzleCriteria(Puzzle *puzzle, uint counter); + bool checkPuzzleCriteria(Puzzle *puzzle, uint counter); void cleanStateTable(); void cleanScriptScope(script_scope &scope); - void execScope(script_scope &scope); + bool execScope(script_scope &scope); /** Perform change location */ void do_changeLocation(); -- cgit v1.2.3 From be5860b93af1d17d31e9430fc096ef02683324ee Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Sat, 8 Nov 2014 13:08:40 +0600 Subject: ZVISION: Change comments of not implemented actions --- engines/zvision/scripting/scr_file_handling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index d5f5704f2a..de092183c6 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -230,7 +230,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("crossfade", true)) { actionList.push_back(new ActionCrossfade(_engine, slot, args)); } else if (act.matchString("debug", true)) { - // TODO: Implement ActionDebug + // Not used. Purposely left empty } else if (act.matchString("delay_render", true)) { actionList.push_back(new ActionDelayRender(_engine, slot, args)); } else if (act.matchString("disable_control", true)) { @@ -272,7 +272,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("rotate_to", true)) { actionList.push_back(new ActionRotateTo(_engine, slot, args)); } else if (act.matchString("save_game", true)) { - // TODO: Implement ActionSaveGame + // Not used. Purposely left empty } else if (act.matchString("set_partial_screen", true)) { actionList.push_back(new ActionSetPartialScreen(_engine, slot, args)); } else if (act.matchString("set_screen", true)) { -- cgit v1.2.3 From ccb051f0e37481161a8546f74e6e96e2013de9e9 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 19:41:26 +0100 Subject: PRINCE: Implement pauseEngineIntern() - pause and resume music in GMM --- engines/prince/prince.cpp | 10 ++++++++++ engines/prince/prince.h | 1 + 2 files changed, 11 insertions(+) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 00e1736c46..43ff218e1d 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -427,6 +427,16 @@ Common::Error PrinceEngine::run() { return Common::kNoError; } +void PrinceEngine::pauseEngineIntern(bool pause) { + Engine::pauseEngineIntern(pause); + if (pause) { + _midiPlayer->pause(); + } + else { + _midiPlayer->resume(); + } +} + bool AnimListItem::loadFromStream(Common::SeekableReadStream &stream) { int32 pos = stream.pos(); diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 48491c63bd..15887b2de8 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -256,6 +256,7 @@ public: virtual ~PrinceEngine(); virtual bool hasFeature(EngineFeature f) const; + virtual void pauseEngineIntern(bool pause); virtual bool canSaveGameStateCurrently(); virtual bool canLoadGameStateCurrently(); virtual Common::Error saveGameState(int slot, const Common::String &desc); -- cgit v1.2.3 From 56af32f2ad06ea61f1a7c6662325e36d176f2c35 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 20:14:33 +0100 Subject: PRINCE: Reduce pause() and pause2() to one function and rename it to pausePrinceEngine() --- engines/prince/prince.cpp | 33 +++++++++++++-------------------- engines/prince/prince.h | 3 +-- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 43ff218e1d..ad682c415e 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1983,7 +1983,7 @@ void PrinceEngine::blackPalette() { free(blackPalette1); return; } - pause(); + pausePrinceEngine(); } free(paletteBackup); free(blackPalette1); @@ -2010,22 +2010,15 @@ void PrinceEngine::setPalette(const byte *palette) { free(blackPalette_); return; } - pause(); + pausePrinceEngine(); } _graph->setPalette(palette); free(blackPalette_); } } -void PrinceEngine::pause() { - int delay = 1000 / kFPS - int32(_system->getMillis() - _currentTime); - delay = delay < 0 ? 0 : delay; - _system->delayMillis(delay); - _currentTime = _system->getMillis(); -} - -void PrinceEngine::pause2() { - int delay = 1000 / (kFPS * 2) - int32(_system->getMillis() - _currentTime); +void PrinceEngine::pausePrinceEngine(int fps) { + int delay = 1000 / fps - int32(_system->getMillis() - _currentTime); delay = delay < 0 ? 0 : delay; _system->delayMillis(delay); _currentTime = _system->getMillis(); @@ -2138,7 +2131,7 @@ void PrinceEngine::addInvObj() { if (shouldQuit()) { return; } - pause(); + pausePrinceEngine(); } while (_mst_shadow2 > 256) { rememberScreenInv(); @@ -2152,7 +2145,7 @@ void PrinceEngine::addInvObj() { if (shouldQuit()) { return; } - pause(); + pausePrinceEngine(); } } else { //CURSEBLINK: @@ -2170,7 +2163,7 @@ void PrinceEngine::addInvObj() { if (shouldQuit()) { return; } - pause(); + pausePrinceEngine(); } while (_mst_shadow2 > 256) { rememberScreenInv(); @@ -2184,7 +2177,7 @@ void PrinceEngine::addInvObj() { if (shouldQuit()) { return; } - pause(); + pausePrinceEngine(); } } } @@ -2200,7 +2193,7 @@ void PrinceEngine::addInvObj() { if (shouldQuit()) { return; } - pause(); + pausePrinceEngine(); } } @@ -2828,7 +2821,7 @@ void PrinceEngine::displayInventory() { getDebugger()->onFrame(); _graph->update(_graph->_screenForInventory); - pause(); + pausePrinceEngine(); } if (_currentPointerNumber == 2) { @@ -2953,7 +2946,7 @@ void PrinceEngine::dialogRun() { getDebugger()->onFrame(); _graph->update(_graph->_frontScreen); - pause(); + pausePrinceEngine(); } _dialogImage->free(); delete _dialogImage; @@ -3212,7 +3205,7 @@ void PrinceEngine::scrollCredits() { } _graph->change(); _graph->update(_graph->_frontScreen); - pause2(); + pausePrinceEngine(kFPS * 2); } char letter2; byte *scan2 = scrollAdress; @@ -4816,7 +4809,7 @@ void PrinceEngine::mainLoop() { openInventoryCheck(); - pause(); + pausePrinceEngine(); } } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 15887b2de8..c9cb83d0b3 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -640,8 +640,7 @@ private: static bool compareDrawNodes(DrawNode d1, DrawNode d2); void runDrawNodes(); void makeShadowTable(int brightness); - void pause(); - void pause2(); + void pausePrinceEngine(int fps = kFPS); uint32 getTextWidth(const char *s); void debugEngine(const char *s, ...); -- cgit v1.2.3 From e228a313e2a8b4997c256a9735eecbbe442a48c7 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 20:41:00 +0100 Subject: PRINCE: Fix double loading of variaTxt.dat file in init() --- engines/prince/prince.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index ad682c415e..f0d360309c 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -273,7 +273,6 @@ void PrinceEngine::init() { _debugger = new Debugger(this, _flags); _variaTxt = new VariaTxt(); - Resource::loadResource(_variaTxt, "variatxt.dat", true); if (getLanguage() == Common::PL_POL || getLanguage() == Common::DE_DEU) { Resource::loadResource(_variaTxt, "variatxt.dat", true); } else { -- cgit v1.2.3 From bb145b439d1ed243d3968264a191fb9760d0b629 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 20:57:37 +0100 Subject: PRINCE: Silence signed and unsigned comparison warnings in gcc --- engines/prince/prince.cpp | 4 ++-- engines/prince/prince.h | 6 +++--- engines/prince/script.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index f0d360309c..1c0198d6f6 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -1595,7 +1595,7 @@ void PrinceEngine::setBackAnim(Anim &backAnim) { } void PrinceEngine::showBackAnims() { - for (uint i = 0; i < kMaxBackAnims; i++) { + for (int i = 0; i < kMaxBackAnims; i++) { BAS &seq = _backAnimList[i]._seq; int activeSubAnim = seq._currRelative; if (!_backAnimList[i].backAnims.empty()) { @@ -4188,7 +4188,7 @@ int PrinceEngine::checkRightUpDir() { } bool PrinceEngine::tracePath(int x1, int y1, int x2, int y2) { - for (int i = 0; i < kPathBitmapLen; i++) { + for (uint i = 0; i < kPathBitmapLen; i++) { _roomPathBitmapTemp[i] = 0; } if (x1 != x2 || y1 != y2) { diff --git a/engines/prince/prince.h b/engines/prince/prince.h index c9cb83d0b3..6dce044a41 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -372,7 +372,7 @@ public: static const int16 kZoomBitmapHeight = kMaxPicHeight / kZoomStep; static const int16 kNormalWidth = 640; static const int16 kNormalHeight = 480; - static const int32 kTransTableSize = 256 * 256; + static const uint32 kTransTableSize = 256 * 256; static const int kMaxNormAnims = 64; static const int kMaxBackAnims = 64; @@ -408,7 +408,7 @@ public: int _currentPointerNumber; static const int16 kMaxInv = 90; // max amount of inventory items in whole game - static const int16 kMaxItems = 30; // size of inventory + static const uint16 kMaxItems = 30; // size of inventory uint32 _invTxtSize; byte *_invTxt; @@ -537,7 +537,7 @@ public: // Pathfinding static const int16 kPathGridStep = 2; - static const int32 kPathBitmapLen = (kMaxPicHeight / kPathGridStep * kMaxPicWidth / kPathGridStep) / 8; + static const uint32 kPathBitmapLen = (kMaxPicHeight / kPathGridStep * kMaxPicWidth / kPathGridStep) / 8; static const int32 kTracePts = 8000; static const int32 kPBW = kMaxPicWidth / 16; // PathBitmapWidth static const int kMinDistance = 2500; diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index deb52d7622..1e50fe5ec4 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -1629,7 +1629,7 @@ void Interpreter::O_BACKANIMRANGE() { } void Interpreter::O_CLEARPATH() { - for (int i = 0; i < _vm->kPathBitmapLen; i++) { + for (uint i = 0; i < _vm->kPathBitmapLen; i++) { _vm->_roomPathBitmap[i] = 255; } debugInterpreter("O_CLEARPATH"); -- cgit v1.2.3 From 71eedf9a3ebae5ba3c8bba075e4bc02fa5c474b2 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 21:00:47 +0100 Subject: PRINCE: Silence last comparison warning in gcc --- engines/prince/script.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/prince/script.h b/engines/prince/script.h index 4799e84944..23c0468d15 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -241,7 +241,7 @@ private: typedef void (Interpreter::*OpcodeFunc)(); static OpcodeFunc _opcodes[]; - static const int kGiveLetterScriptFix = 79002; + static const uint kGiveLetterScriptFix = 79002; // Keep opcode handlers names as they are in original code // making it easier to switch back and forth -- cgit v1.2.3 From e33383b19f361cb3eabdc4c3322e623917438d32 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sat, 8 Nov 2014 23:51:56 +0100 Subject: PRINCE: showLogo() - allow to skip logo animation or quit game during it --- engines/prince/prince.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 1c0198d6f6..144876ca75 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -403,7 +403,6 @@ void PrinceEngine::init() { void PrinceEngine::showLogo() { MhwanhDecoder logo; - _system->delayMillis(1000 / kFPS * 20); if (Resource::loadResource(&logo, "logo.raw", true)) { loadSample(0, "LOGO.WAV"); playSample(0, 0); @@ -411,7 +410,31 @@ void PrinceEngine::showLogo() { _graph->change(); _graph->update(_graph->_frontScreen); setPalette(logo.getPalette()); - _system->delayMillis(1000 / kFPS * 70); + + uint32 logoStart = _system->getMillis(); + while (_system->getMillis() < logoStart + 5000) { + Common::Event event; + Common::EventManager *eventMan = _system->getEventManager(); + while (eventMan->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_KEYDOWN: + if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { + stopSample(0); + return; + } + break; + case Common::EVENT_LBUTTONDOWN: + stopSample(0); + return; + default: + break; + } + } + + if (shouldQuit()) { + return; + } + } } } -- cgit v1.2.3 From b5596482f0b21ffea3a4e2e78b9a5814ec9723af Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 00:04:51 +0100 Subject: PRINCE: Allow to skip intro animation with LMB --- engines/prince/prince.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 144876ca75..6239d6aa40 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -2410,6 +2410,7 @@ void PrinceEngine::moveRunHero(int heroId, int x, int y, int dir, bool runHeroFl } void PrinceEngine::leftMouseButton() { + _flags->setFlagValue(Flags::ESCAPED2, 1); // skip intro animation _flags->setFlagValue(Flags::LMOUSE, 1); if (_flags->getFlagValue(Flags::POWERENABLED)) { _flags->setFlagValue(Flags::MBFLAG, 1); -- cgit v1.2.3 From 8ad075a764ba948b922a01218989fa3d09d828ad Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 00:11:34 +0100 Subject: PRINCE: Allow RTL engine feature --- engines/prince/detection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp index 3f83009de8..dd553adc6e 100644 --- a/engines/prince/detection.cpp +++ b/engines/prince/detection.cpp @@ -61,7 +61,8 @@ bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const { bool Prince::PrinceEngine::hasFeature(EngineFeature f) const { return (f == kSupportsLoadingDuringRuntime) || - (f == kSupportsSavingDuringRuntime); + (f == kSupportsSavingDuringRuntime) || + (f == kSupportsRTL); } } // End of namespace Prince -- cgit v1.2.3 From ce1e776eeef153ca3aa6beaae5ce3786919368d6 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 01:42:54 +0100 Subject: PRINCE: Add loading during startup and syncSoundSettings features --- engines/prince/detection.cpp | 3 ++- engines/prince/prince.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/engines/prince/detection.cpp b/engines/prince/detection.cpp index dd553adc6e..3fe7993fdb 100644 --- a/engines/prince/detection.cpp +++ b/engines/prince/detection.cpp @@ -55,7 +55,8 @@ bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const { (f == kSavesSupportMetaInfo) || (f == kSavesSupportThumbnail) || (f == kSavesSupportCreationDate) || - (f == kSupportsListSaves); + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup); } bool Prince::PrinceEngine::hasFeature(EngineFeature f) const { diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 6239d6aa40..5055c6a225 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -439,13 +439,16 @@ void PrinceEngine::showLogo() { } Common::Error PrinceEngine::run() { - + syncSoundSettings(); + int startGameSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; init(); - - showLogo(); - + if (startGameSlot == -1) { + showLogo(); + } else { + loadLocation(59); // load intro location - easiest way to set everything up + loadGame(startGameSlot); + } mainLoop(); - return Common::kNoError; } -- cgit v1.2.3 From d5938d25204f6d2bb2f97d9340db281742db8c5b Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 02:15:56 +0100 Subject: PRINCE: canSaveGameStateCurrently() - check conditions when you can't save the game state --- engines/prince/saveload.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/engines/prince/saveload.cpp b/engines/prince/saveload.cpp index 706079ffaf..65983f40de 100644 --- a/engines/prince/saveload.cpp +++ b/engines/prince/saveload.cpp @@ -172,13 +172,20 @@ void PrinceMetaEngine::removeSaveState(const char *target, int slot) const { g_system->getSavefileManager()->removeSavefile(fileName); } -// TODO bool PrinceEngine::canSaveGameStateCurrently() { - return true; + if (_mouseFlag && _mouseFlag != 3) { + if (_mainHero->_visible) { + // 29 - Basement + if (_locationNr != 29) { + return true; + } + } + } + return false; } -// TODO bool PrinceEngine::canLoadGameStateCurrently() { + // Always true return true; } -- cgit v1.2.3 From cb01dd36b62fca7b8bcd8d41d701f6f41b8249d8 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 02:42:48 +0100 Subject: PRINCE: canLoadGameStateCurrently() - to check if loading is allowed Also block saving during dialogbox and inventory drawing --- engines/prince/saveload.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/engines/prince/saveload.cpp b/engines/prince/saveload.cpp index 65983f40de..46e598be70 100644 --- a/engines/prince/saveload.cpp +++ b/engines/prince/saveload.cpp @@ -177,7 +177,10 @@ bool PrinceEngine::canSaveGameStateCurrently() { if (_mainHero->_visible) { // 29 - Basement if (_locationNr != 29) { - return true; + // No dialog box and not in inventory + if (!_dialogFlag && !_showInventoryFlag) { + return true; + } } } } @@ -185,8 +188,18 @@ bool PrinceEngine::canSaveGameStateCurrently() { } bool PrinceEngine::canLoadGameStateCurrently() { - // Always true - return true; + if (_mouseFlag && _mouseFlag != 3) { + if (_mainHero->_visible) { + // 29 - Basement + if (_locationNr != 29) { + // No dialog box and not in inventory + if (!_dialogFlag && !_showInventoryFlag) { + return true; + } + } + } + } + return false; } Common::Error PrinceEngine::saveGameState(int slot, const Common::String &desc) { @@ -512,9 +525,6 @@ bool PrinceEngine::loadGame(int slotNumber) { syncGame(readStream, nullptr); delete readStream; - // TODO - //syncSpeechSettings(); - return true; } -- cgit v1.2.3 From 3472d95f4546fd1c1212e0f9ef85deaefa23e689 Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 03:05:34 +0100 Subject: PRINCE: playSample() - split to sound and speech types to correct volume settings --- engines/prince/prince.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 5055c6a225..55f12a6560 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -754,7 +754,11 @@ void PrinceEngine::playSample(uint16 sampleId, uint16 loopType) { return; } _audioStream[sampleId]->rewind(); - _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[sampleId], _audioStream[sampleId], sampleId, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + if (sampleId < 28) { + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[sampleId], _audioStream[sampleId], sampleId, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + } else { + _mixer->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle[sampleId], _audioStream[sampleId], sampleId, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO); + } } } -- cgit v1.2.3 From 72e6a9eeab1082892e5d77fabc4f0b50f839615a Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 9 Nov 2014 12:54:41 +0100 Subject: SCI: some more work on 480x300 mac support --- engines/sci/graphics/cursor.cpp | 8 +- engines/sci/graphics/font.cpp | 8 +- engines/sci/graphics/font.h | 4 +- engines/sci/graphics/picture.cpp | 84 +++++--- engines/sci/graphics/ports.cpp | 16 +- engines/sci/graphics/screen.cpp | 385 +++++++++++++++++++++++------------ engines/sci/graphics/screen.h | 94 +++++++-- engines/sci/graphics/transitions.cpp | 6 +- 8 files changed, 412 insertions(+), 193 deletions(-) diff --git a/engines/sci/graphics/cursor.cpp b/engines/sci/graphics/cursor.cpp index 048ec1e9b9..1a58de073c 100644 --- a/engines/sci/graphics/cursor.cpp +++ b/engines/sci/graphics/cursor.cpp @@ -47,7 +47,7 @@ GfxCursor::GfxCursor(ResourceManager *resMan, GfxPalette *palette, GfxScreen *sc _isVisible = true; // center mouse cursor - setPosition(Common::Point(_screen->getWidth() / 2, _screen->getHeight() / 2)); + setPosition(Common::Point(_screen->getScriptWidth() / 2, _screen->getScriptHeight() / 2)); _moveZoneActive = false; _zoomZoneActive = false; @@ -151,14 +151,14 @@ void GfxCursor::kernelSetShape(GuiResourceId resourceId) { colorMapping[0] = 0; // Black is hardcoded colorMapping[1] = _screen->getColorWhite(); // White is also hardcoded colorMapping[2] = SCI_CURSOR_SCI0_TRANSPARENCYCOLOR; - colorMapping[3] = _palette->matchColor(170, 170, 170); // Grey + colorMapping[3] = _palette->matchColor(170, 170, 170) & SCI_PALETTE_MATCH_COLORMASK; // Grey // TODO: Figure out if the grey color is hardcoded // HACK for the magnifier cursor in LB1, fixes its color (bug #3487092) if (g_sci->getGameId() == GID_LAURABOW && resourceId == 1) colorMapping[3] = _screen->getColorWhite(); // HACK for Longbow cursors, fixes the shade of grey they're using (bug #3489101) if (g_sci->getGameId() == GID_LONGBOW) - colorMapping[3] = _palette->matchColor(223, 223, 223); // Light Grey + colorMapping[3] = _palette->matchColor(223, 223, 223) & SCI_PALETTE_MATCH_COLORMASK; // Light Grey // Seek to actual data resourceData += 4; @@ -481,7 +481,7 @@ void GfxCursor::kernelSetPos(Common::Point pos) { void GfxCursor::kernelMoveCursor(Common::Point pos) { _coordAdjuster->moveCursor(pos); - if (pos.x > _screen->getWidth() || pos.y > _screen->getHeight()) { + if (pos.x > _screen->getScriptWidth() || pos.y > _screen->getScriptHeight()) { warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x); return; } diff --git a/engines/sci/graphics/font.cpp b/engines/sci/graphics/font.cpp index e4684ff134..2268ec0459 100644 --- a/engines/sci/graphics/font.cpp +++ b/engines/sci/graphics/font.cpp @@ -48,8 +48,8 @@ GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *scr // filling info for every char for (int16 i = 0; i < _numChars; i++) { _chars[i].offset = READ_SCI32ENDIAN_UINT16(_resourceData + 6 + i * 2); - _chars[i].w = _resourceData[_chars[i].offset]; - _chars[i].h = _resourceData[_chars[i].offset + 1]; + _chars[i].width = _resourceData[_chars[i].offset]; + _chars[i].height = _resourceData[_chars[i].offset + 1]; } } @@ -66,10 +66,10 @@ byte GfxFontFromResource::getHeight() { return _fontHeight; } byte GfxFontFromResource::getCharWidth(uint16 chr) { - return chr < _numChars ? _chars[chr].w : 0; + return chr < _numChars ? _chars[chr].width : 0; } byte GfxFontFromResource::getCharHeight(uint16 chr) { - return chr < _numChars ? _chars[chr].h : 0; + return chr < _numChars ? _chars[chr].height : 0; } byte *GfxFontFromResource::getCharData(uint16 chr) { return chr < _numChars ? _resourceData + _chars[chr].offset + 2 : 0; diff --git a/engines/sci/graphics/font.h b/engines/sci/graphics/font.h index 58b2ba4813..451261f315 100644 --- a/engines/sci/graphics/font.h +++ b/engines/sci/graphics/font.h @@ -71,9 +71,11 @@ private: byte *_resourceData; struct Charinfo { - byte w, h; + byte width; + byte height; int16 offset; }; + byte _fontHeight; uint16 _numChars; Charinfo *_chars; diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index d751f9738f..d7ef84dc1e 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -88,10 +88,13 @@ void GfxPicture::draw(int16 animationNr, bool mirroredFlag, bool addToFlag, int1 } void GfxPicture::reset() { + int16 startY = _ports->getPort()->top; + int16 startX = 0; int16 x, y; - for (y = _ports->getPort()->top; y < _screen->getHeight(); y++) { - for (x = 0; x < _screen->getWidth(); x++) { - _screen->putPixel(x, y, GFX_SCREEN_MASK_ALL, 255, 0, 0); + _screen->vectorAdjustCoordinate(&startX, &startY); + for (y = startY; y < _screen->getHeight(); y++) { + for (x = startX; x < _screen->getWidth(); x++) { + _screen->vectorPutPixel(x, y, GFX_SCREEN_MASK_ALL, 255, 0, 0); } } } @@ -482,6 +485,8 @@ enum { PIC_OPX_VGA_PRIORITY_TABLE_EXPLICIT = 4 }; +//#define DEBUG_PICTURE_DRAW 1 + #ifdef DEBUG_PICTURE_DRAW const char *picOpcodeNames[] = { "Set color", @@ -589,6 +594,9 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { while (curPos < dataSize) { #ifdef DEBUG_PICTURE_DRAW debug("Picture op: %X (%s) at %d", data[curPos], picOpcodeNames[data[curPos] - 0xF0], curPos); + _screen->copyToScreen(); + g_system->updateScreen(); + g_system->delayMillis(400); #endif switch (pic_op = data[curPos++]) { case PIC_OP_SET_COLOR: @@ -934,17 +942,17 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by Common::Point p, p1; byte screenMask = _screen->getDrawingMask(color, priority, control); byte matchedMask, matchMask; - int16 w, e, a_set, b_set; bool isEGA = (_resMan->getViewType() == kViewEga); p.x = x + curPort->left; p.y = y + curPort->top; - stack.push(p); - byte searchColor = _screen->getVisual(p.x, p.y); - byte searchPriority = _screen->getPriority(p.x, p.y); - byte searchControl = _screen->getControl(p.x, p.y); + _screen->vectorAdjustCoordinate(&p.x, &p.y); + + byte searchColor = _screen->vectorGetVisual(p.x, p.y); + byte searchPriority = _screen->vectorGetPriority(p.x, p.y); + byte searchControl = _screen->vectorGetControl(p.x, p.y); if (isEGA) { // In EGA games a pixel in the framebuffer is only 4 bits. We store @@ -991,22 +999,31 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by } // hard borders for filling - int l = curPort->rect.left + curPort->left; - int t = curPort->rect.top + curPort->top; - int r = curPort->rect.right + curPort->left - 1; - int b = curPort->rect.bottom + curPort->top - 1; + int16 borderLeft = curPort->rect.left + curPort->left; + int16 borderTop = curPort->rect.top + curPort->top; + int16 borderRight = curPort->rect.right + curPort->left - 1; + int16 borderBottom = curPort->rect.bottom + curPort->top - 1; + int16 curToLeft, curToRight, a_set, b_set; + + // Translate coordinates, if required (needed for Macintosh 480x300) + _screen->vectorAdjustCoordinate(&borderLeft, &borderTop); + _screen->vectorAdjustCoordinate(&borderRight, &borderBottom); + //return; + + stack.push(p); + while (stack.size()) { p = stack.pop(); - if ((matchedMask = _screen->isFillMatch(p.x, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)) == 0) // already filled + if ((matchedMask = _screen->vectorIsFillMatch(p.x, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA)) == 0) // already filled continue; - _screen->putPixel(p.x, p.y, screenMask, color, priority, control); - w = p.x; - e = p.x; + _screen->vectorPutPixel(p.x, p.y, screenMask, color, priority, control); + curToLeft = p.x; + curToRight = p.x; // moving west and east pointers as long as there is a matching color to fill - while (w > l && (matchedMask = _screen->isFillMatch(w - 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA))) - _screen->putPixel(--w, p.y, screenMask, color, priority, control); - while (e < r && (matchedMask = _screen->isFillMatch(e + 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA))) - _screen->putPixel(++e, p.y, screenMask, color, priority, control); + while (curToLeft > borderLeft && (matchedMask = _screen->vectorIsFillMatch(curToLeft - 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA))) + _screen->vectorPutPixel(--curToLeft, p.y, screenMask, color, priority, control); + while (curToRight < borderRight && (matchedMask = _screen->vectorIsFillMatch(curToRight + 1, p.y, matchMask, searchColor, searchPriority, searchControl, isEGA))) + _screen->vectorPutPixel(++curToRight, p.y, screenMask, color, priority, control); #if 0 // debug code for floodfill _screen->copyToScreen(); @@ -1015,10 +1032,10 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by #endif // checking lines above and below for possible flood targets a_set = b_set = 0; - while (w <= e) { - if (p.y > t && (matchedMask = _screen->isFillMatch(w, p.y - 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line above + while (curToLeft <= curToRight) { + if (p.y > borderTop && (matchedMask = _screen->vectorIsFillMatch(curToLeft, p.y - 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line above if (a_set == 0) { - p1.x = w; + p1.x = curToLeft; p1.y = p.y - 1; stack.push(p1); a_set = 1; @@ -1026,16 +1043,16 @@ void GfxPicture::vectorFloodFill(int16 x, int16 y, byte color, byte priority, by } else a_set = 0; - if (p.y < b && (matchedMask = _screen->isFillMatch(w, p.y + 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line below + if (p.y < borderBottom && (matchedMask = _screen->vectorIsFillMatch(curToLeft, p.y + 1, matchMask, searchColor, searchPriority, searchControl, isEGA))) { // one line below if (b_set == 0) { - p1.x = w; + p1.x = curToLeft; p1.y = p.y + 1; stack.push(p1); b_set = 1; } } else b_set = 0; - w++; + curToLeft++; } } } @@ -1173,7 +1190,7 @@ void GfxPicture::vectorPatternBox(Common::Rect box, byte color, byte prio, byte for (y = box.top; y < box.bottom; y++) { for (x = box.left; x < box.right; x++) { - _screen->putPixel(x, y, flag, color, prio, control); + _screen->vectorPutPixel(x, y, flag, color, prio, control); } } } @@ -1186,7 +1203,7 @@ void GfxPicture::vectorPatternTexturedBox(Common::Rect box, byte color, byte pri for (y = box.top; y < box.bottom; y++) { for (x = box.left; x < box.right; x++) { if (*textureData) { - _screen->putPixel(x, y, flag, color, prio, control); + _screen->vectorPutPixel(x, y, flag, color, prio, control); } textureData++; } @@ -1203,7 +1220,7 @@ void GfxPicture::vectorPatternCircle(Common::Rect box, byte size, byte color, by for (y = box.top; y < box.bottom; y++) { for (x = box.left; x < box.right; x++) { if (bitmap & 1) { - _screen->putPixel(x, y, flag, color, prio, control); + _screen->vectorPutPixel(x, y, flag, color, prio, control); } bitNo++; if (bitNo == 8) { @@ -1222,12 +1239,12 @@ void GfxPicture::vectorPatternTexturedCircle(Common::Rect box, byte size, byte c byte bitNo = 0; const bool *textureData = &vectorPatternTextures[vectorPatternTextureOffset[texture]]; int y, x; - + for (y = box.top; y < box.bottom; y++) { for (x = box.left; x < box.right; x++) { if (bitmap & 1) { if (*textureData) { - _screen->putPixel(x, y, flag, color, prio, control); + _screen->vectorPutPixel(x, y, flag, color, prio, control); } textureData++; } @@ -1252,7 +1269,10 @@ void GfxPicture::vectorPattern(int16 x, int16 y, byte color, byte priority, byte rect.top = y; rect.left = x; rect.setHeight((size*2)+1); rect.setWidth((size*2)+2); _ports->offsetRect(rect); - rect.clip(_screen->getWidth(), _screen->getHeight()); + rect.clip(_screen->getScriptWidth(), _screen->getScriptHeight()); + + _screen->vectorAdjustCoordinate(&rect.left, &rect.top); + _screen->vectorAdjustCoordinate(&rect.right, &rect.bottom); if (code & SCI_PATTERN_CODE_RECTANGLE) { // Rectangle diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index 56c63a7b12..bcc991081e 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -63,10 +63,10 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te openPort(_menuPort); setPort(_menuPort); _text16->SetFont(0); - _menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight()); - _menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9); - _menuRect = Common::Rect(0, 0, _screen->getWidth(), 10); - _menuLine = Common::Rect(0, 9, _screen->getWidth(), 10); + _menuPort->rect = Common::Rect(0, 0, _screen->getScriptWidth(), _screen->getScriptHeight()); + _menuBarRect = Common::Rect(0, 0, _screen->getScriptWidth(), 9); + _menuRect = Common::Rect(0, 0, _screen->getScriptWidth(), 10); + _menuLine = Common::Rect(0, 9, _screen->getScriptWidth(), 10); _wmgrPort = new Port(1); _windowsById.resize(2); @@ -122,13 +122,13 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te } else { _wmgrPort->rect.bottom = _screen->getHeight(); } - _wmgrPort->rect.right = _screen->getWidth(); + _wmgrPort->rect.right = _screen->getScriptWidth(); _wmgrPort->rect.moveTo(0, 0); _wmgrPort->curTop = 0; _wmgrPort->curLeft = 0; _windowList.push_front(_wmgrPort); - _picWind = addWindow(Common::Rect(0, offTop, _screen->getWidth(), _screen->getHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true); + _picWind = addWindow(Common::Rect(0, offTop, _screen->getScriptWidth(), _screen->getScriptHeight()), 0, 0, SCI_WINDOWMGR_STYLE_TRANSPARENT | SCI_WINDOWMGR_STYLE_NOFRAME, 0, true); // For SCI0 games till kq4 (.502 - not including) we set _picWind top to offTop instead // Because of the menu/status bar if (_usesOldGfxFunctions) @@ -321,13 +321,13 @@ Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restor // their interpreter even in the newer VGA games. r.left = r.left & 0xFFFE; - if (r.width() > _screen->getWidth()) { + if (r.width() > _screen->getScriptWidth()) { // We get invalid dimensions at least at the end of sq3 (script bug!). // Same happens very often in lsl5, sierra sci didnt fix it but it looked awful. // Also happens frequently in the demo of GK1. warning("Fixing too large window, left: %d, right: %d", dims.left, dims.right); r.left = 0; - r.right = _screen->getWidth() - 1; + r.right = _screen->getScriptWidth() - 1; if ((style != _styleUser) && !(style & SCI_WINDOWMGR_STYLE_NOFRAME)) r.right--; } diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index d66352b411..594c4b3442 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -37,7 +37,13 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { // Scale the screen, if needed _upscaledHires = GFX_SCREEN_UPSCALED_DISABLED; - + + // we default to scripts running at 320x200 + _scriptWidth = 320; + _scriptHeight = 200; + _width = 0; + _height = 0; + // King's Quest 6 and Gabriel Knight 1 have hires content, gk1/cd was able // to provide that under DOS as well, but as gk1/floppy does support // upscaled hires scriptswise, but doesn't actually have the hires content @@ -51,9 +57,32 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { #endif } + // Japanese versions of games use hi-res font on upscaled version of the game. + if ((g_sci->getLanguage() == Common::JA_JPN) && (getSciVersion() <= SCI_VERSION_1_1)) + _upscaledHires = GFX_SCREEN_UPSCALED_640x400; + + // Macintosh SCI0 games used 480x300, while the scripts were running at 320x200 if (g_sci->getPlatform() == Common::kPlatformMacintosh) { - if (getSciVersion() <= SCI_VERSION_01) + if (getSciVersion() <= SCI_VERSION_01) { _upscaledHires = GFX_SCREEN_UPSCALED_480x300; + _width = 480; + _height = 300; // regular visual, priority and control map are 480x300 (this is different than other upscaled SCI games) + } + + // Some Mac SCI1/1.1 games only take up 190 rows and do not + // have the menu bar. + // TODO: Verify that LSL1 and LSL5 use height 190 + switch (g_sci->getGameId()) { + case GID_FREDDYPHARKAS: + case GID_KQ5: + case GID_KQ6: + case GID_LSL1: + case GID_LSL5: + case GID_SQ1: + _width = 190; + default: + break; + } } #ifdef ENABLE_SCI32 @@ -64,70 +93,66 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { } #endif - if (_resMan->detectHires()) { - _width = 640; - _pitch = 640; - _height = 480; - } else { - _width = 320; - _pitch = 320; - _height = getLowResScreenHeight(); - } - #ifdef ENABLE_SCI32 // Phantasmagoria 1 sets a window area of 630x450 - if (g_sci->getGameId() == GID_PHANTASMAGORIA) { - _width = 630; - _height = 450; - } + //if (g_sci->getGameId() == GID_PHANTASMAGORIA) { + // _width = 630; + // _height = 450; + //} #endif - // Japanese versions of games use hi-res font on upscaled version of the game. - if ((g_sci->getLanguage() == Common::JA_JPN) && (getSciVersion() <= SCI_VERSION_1_1)) - _upscaledHires = GFX_SCREEN_UPSCALED_640x400; + if (_resMan->detectHires()) { + _scriptWidth = 640; + _scriptHeight = 480; + } - _pixels = _pitch * _height; + // if not yet set, set those to script-width/height + if (!_width) + _width = _scriptWidth; + if (!_height) + _height = _scriptHeight; + + _pixels = _width * _height; switch (_upscaledHires) { case GFX_SCREEN_UPSCALED_480x300: // Space Quest 3, Hoyle 1+2 on MAC use this one - // TODO: Sierra's upscaling worked differently. We need to figure out the exact algo _displayWidth = 480; _displayHeight = 300; - for (int i = 0; i <= _height; i++) + for (int i = 0; i <= _scriptHeight; i++) _upscaledHeightMapping[i] = (i * 3) >> 1; - for (int i = 0; i <= _width; i++) + for (int i = 0; i <= _scriptWidth; i++) _upscaledWidthMapping[i] = (i * 3) >> 1; break; case GFX_SCREEN_UPSCALED_640x400: // Police Quest 2 and Quest For Glory on PC9801 (Japanese) _displayWidth = 640; _displayHeight = 400; - for (int i = 0; i <= _height; i++) + for (int i = 0; i <= _scriptHeight; i++) _upscaledHeightMapping[i] = i * 2; - for (int i = 0; i <= _width; i++) + for (int i = 0; i <= _scriptWidth; i++) _upscaledWidthMapping[i] = i * 2; break; case GFX_SCREEN_UPSCALED_640x440: // used by King's Quest 6 on Windows _displayWidth = 640; _displayHeight = 440; - for (int i = 0; i <= _height; i++) + for (int i = 0; i <= _scriptHeight; i++) _upscaledHeightMapping[i] = (i * 11) / 5; - for (int i = 0; i <= _width; i++) + for (int i = 0; i <= _scriptWidth; i++) _upscaledWidthMapping[i] = i * 2; break; case GFX_SCREEN_UPSCALED_640x480: // Gabriel Knight 1 (VESA, Mac) _displayWidth = 640; _displayHeight = 480; - for (int i = 0; i <= _height; i++) + for (int i = 0; i <= _scriptHeight; i++) _upscaledHeightMapping[i] = (i * 12) / 5; - for (int i = 0; i <= _width; i++) + for (int i = 0; i <= _scriptWidth; i++) _upscaledWidthMapping[i] = i * 2; break; default: - _displayWidth = _pitch; + _displayWidth = _width; _displayHeight = _height; memset(&_upscaledHeightMapping, 0, sizeof(_upscaledHeightMapping) ); memset(&_upscaledWidthMapping, 0, sizeof(_upscaledWidthMapping) ); @@ -135,6 +160,8 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { } _displayPixels = _displayWidth * _displayHeight; + + // Allocate visual, priority, control and display screen _visualScreen = (byte *)calloc(_pixels, 1); _priorityScreen = (byte *)calloc(_pixels, 1); _controlScreen = (byte *)calloc(_pixels, 1); @@ -179,6 +206,34 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { error("Unknown SCI1.1 Mac game"); } else initGraphics(_displayWidth, _displayHeight, _displayWidth > 320); + + // Initialize code pointers + _vectorAdjustCoordinatePtr = &GfxScreen::vectorAdjustCoordinateNOP; + _vectorAdjustLineCoordinatesPtr = &GfxScreen::vectorAdjustLineCoordinatesNOP; + _vectorIsFillMatchPtr = &GfxScreen::vectorIsFillMatchNormal; + _vectorPutPixelPtr = &GfxScreen::putPixelNormal; + _vectorPutLinePixelPtr = &GfxScreen::putPixel; + _vectorGetPixelPtr = &GfxScreen::getPixelNormal; + _putPixelPtr = &GfxScreen::putPixelNormal; + _getPixelPtr = &GfxScreen::getPixelNormal; + + switch (_upscaledHires) { + case GFX_SCREEN_UPSCALED_480x300: + _vectorAdjustCoordinatePtr = &GfxScreen::vectorAdjustCoordinate480x300Mac; + _vectorAdjustLineCoordinatesPtr = &GfxScreen::vectorAdjustLineCoordinates480x300Mac; + // vectorPutPixel -> we already adjust coordinates for vector code, that's why we can set pixels directly + // vectorGetPixel -> see vectorPutPixel + _vectorPutLinePixelPtr = &GfxScreen::vectorPutLinePixel480x300Mac; + _putPixelPtr = &GfxScreen::putPixelAllUpscaled; + _getPixelPtr = &GfxScreen::getPixelUpscaled; + break; + case GFX_SCREEN_UPSCALED_640x400: + case GFX_SCREEN_UPSCALED_640x440: + case GFX_SCREEN_UPSCALED_640x480: + _vectorPutPixelPtr = &GfxScreen::putPixelDisplayUpscaled; + _putPixelPtr = &GfxScreen::putPixelDisplayUpscaled; + break; + } } GfxScreen::~GfxScreen() { @@ -248,43 +303,162 @@ byte GfxScreen::getDrawingMask(byte color, byte prio, byte control) { return flag; } -void GfxScreen::putPixel(int x, int y, byte drawMask, byte color, byte priority, byte control) { - int offset = y * _pitch + x; +void GfxScreen::vectorAdjustCoordinateNOP(int16 *x, int16 *y) { +} - if (drawMask & GFX_SCREEN_MASK_VISUAL) { - _visualScreen[offset] = color; - if (!_upscaledHires) { - _displayScreen[offset] = color; +void GfxScreen::vectorAdjustCoordinate480x300Mac(int16 *x, int16 *y) { + *x = _upscaledWidthMapping[*x]; + *y = _upscaledHeightMapping[*y]; +} + +void GfxScreen::vectorAdjustLineCoordinatesNOP(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) { +} + +void GfxScreen::vectorAdjustLineCoordinates480x300Mac(int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) { + int16 displayLeft = _upscaledWidthMapping[*left]; + int16 displayRight = _upscaledWidthMapping[*right]; + int16 displayTop = _upscaledHeightMapping[*top]; + int16 displayBottom = _upscaledHeightMapping[*bottom]; + + if (displayLeft < displayRight) { + // one more pixel to the left, one more pixel to the right + if (displayLeft > 0) + vectorPutLinePixel(displayLeft - 1, displayTop, drawMask, color, priority, control); + vectorPutLinePixel(displayRight + 1, displayBottom, drawMask, color, priority, control); + } else if (displayLeft > displayRight) { + if (displayRight > 0) + vectorPutLinePixel(displayRight - 1, displayBottom, drawMask, color, priority, control); + vectorPutLinePixel(displayLeft + 1, displayTop, drawMask, color, priority, control); + } + *left = displayLeft; + *top = displayTop; + *right = displayRight; + *bottom = displayBottom; +} + +byte GfxScreen::vectorIsFillMatchNormal(int16 x, int16 y, byte screenMask, byte checkForColor, byte checkForPriority, byte checkForControl, bool isEGA) { + int offset = y * _width + x; + byte match = 0; + + if (screenMask & GFX_SCREEN_MASK_VISUAL) { + if (!isEGA) { + if (*(_visualScreen + offset) == checkForColor) + match |= GFX_SCREEN_MASK_VISUAL; } else { - putScaledPixelOnDisplay(x, y, color); + // In EGA games a pixel in the framebuffer is only 4 bits. We store + // a full byte per pixel to allow undithering, but when comparing + // pixels for flood-fill purposes, we should only compare the + // visible color of a pixel. + + byte EGAcolor = *(_visualScreen + offset); + if ((x ^ y) & 1) + EGAcolor = (EGAcolor ^ (EGAcolor >> 4)) & 0x0F; + else + EGAcolor = EGAcolor & 0x0F; + if (EGAcolor == checkForColor) + match |= GFX_SCREEN_MASK_VISUAL; } } + if ((screenMask & GFX_SCREEN_MASK_PRIORITY) && *(_priorityScreen + offset) == checkForPriority) + match |= GFX_SCREEN_MASK_PRIORITY; + if ((screenMask & GFX_SCREEN_MASK_CONTROL) && *(_controlScreen + offset) == checkForControl) + match |= GFX_SCREEN_MASK_CONTROL; + return match; +} + +// Special 480x300 Mac putPixel for vector line drawing, also draws an additional pixel below the actual one +void GfxScreen::vectorPutLinePixel480x300Mac(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + int offset = y * _width + x; + + if (drawMask & GFX_SCREEN_MASK_VISUAL) { + _visualScreen[offset] = color; + _visualScreen[offset + _width] = color; + _displayScreen[offset] = color; + // also set pixel below actual pixel + _displayScreen[offset + _displayWidth] = color; + } + if (drawMask & GFX_SCREEN_MASK_PRIORITY) { + _priorityScreen[offset] = priority; + _priorityScreen[offset + _width] = priority; + } + if (drawMask & GFX_SCREEN_MASK_CONTROL) { + _controlScreen[offset] = control; + _controlScreen[offset + _width] = control; + } +} + +// Directly sets a pixel on various screens, display is not upscaled +void GfxScreen::putPixelNormal(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + int offset = y * _width + x; + + if (drawMask & GFX_SCREEN_MASK_VISUAL) { + _visualScreen[offset] = color; + _displayScreen[offset] = color; + } + if (drawMask & GFX_SCREEN_MASK_PRIORITY) + _priorityScreen[offset] = priority; + if (drawMask & GFX_SCREEN_MASK_CONTROL) + _controlScreen[offset] = control; +} + +// Directly sets a pixel on various screens, display IS upscaled +void GfxScreen::putPixelDisplayUpscaled(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + int offset = y * _width + x; + + if (drawMask & GFX_SCREEN_MASK_VISUAL) { + _visualScreen[offset] = color; + putScaledPixelOnScreen(_displayScreen, x, y, color); + } if (drawMask & GFX_SCREEN_MASK_PRIORITY) _priorityScreen[offset] = priority; if (drawMask & GFX_SCREEN_MASK_CONTROL) _controlScreen[offset] = control; } +// Directly sets a pixel on various screens, ALL screens ARE upscaled +void GfxScreen::putPixelAllUpscaled(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + if (drawMask & GFX_SCREEN_MASK_VISUAL) { + putScaledPixelOnScreen(_visualScreen, x, y, color); + putScaledPixelOnScreen(_displayScreen, x, y, color); + } + if (drawMask & GFX_SCREEN_MASK_PRIORITY) + putScaledPixelOnScreen(_priorityScreen, x, y, priority); + if (drawMask & GFX_SCREEN_MASK_CONTROL) + putScaledPixelOnScreen(_controlScreen, x, y, control); +} + /** * This is used to put font pixels onto the screen - we adjust differently, so that we won't * do triple pixel lines in any case on upscaled hires. That way the font will not get distorted * Sierra SCI didn't do this */ -void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) { - int actualY = startingY + y; +void GfxScreen::putFontPixel(int16 startingY, int16 x, int16 y, byte color) { + int16 actualY = startingY + y; if (_fontIsUpscaled) { // Do not scale ourselves, but put it on the display directly putPixelOnDisplay(x, actualY, color); } else { - int offset = actualY * _pitch + x; + int offset = actualY * _width + x; _visualScreen[offset] = color; switch (_upscaledHires) { case GFX_SCREEN_UPSCALED_DISABLED: _displayScreen[offset] = color; break; + case GFX_SCREEN_UPSCALED_640x400: + case GFX_SCREEN_UPSCALED_640x440: + case GFX_SCREEN_UPSCALED_640x480: { + // to 1-> 4 pixels upscaling for all of those, so that fonts won't look weird + int displayOffset = (_upscaledHeightMapping[startingY] + y * 2) * _displayWidth + x * 2; + _displayScreen[displayOffset] = color; + _displayScreen[displayOffset + 1] = color; + displayOffset += _displayWidth; + _displayScreen[displayOffset] = color; + _displayScreen[displayOffset + 1] = color; + break; + } default: - putScaledPixelOnDisplay(x, actualY, color); + putScaledPixelOnScreen(_displayScreen, x, actualY, color); break; } } @@ -295,12 +469,15 @@ void GfxScreen::putFontPixel(int startingY, int x, int y, byte color) { * only used on upscaled-Hires games where hires content needs to get drawn ONTO * the upscaled display screen (like japanese fonts, hires portraits, etc.). */ -void GfxScreen::putPixelOnDisplay(int x, int y, byte color) { +void GfxScreen::putPixelOnDisplay(int16 x, int16 y, byte color) { int offset = y * _displayWidth + x; _displayScreen[offset] = color; } -void GfxScreen::putScaledPixelOnDisplay(int x, int y, byte color) { +//void GfxScreen::putScaledPixelOnDisplay(int16 x, int16 y, byte color) { +//} + +void GfxScreen::putScaledPixelOnScreen(byte *screen, int16 x, int16 y, byte data) { int displayOffset = _upscaledHeightMapping[y] * _displayWidth + _upscaledWidthMapping[x]; int heightOffsetBreak = (_upscaledHeightMapping[y + 1] - _upscaledHeightMapping[y]) * _displayWidth; int heightOffset = 0; @@ -308,7 +485,7 @@ void GfxScreen::putScaledPixelOnDisplay(int x, int y, byte color) { do { int widthOffset = 0; do { - _displayScreen[displayOffset + heightOffset + widthOffset] = color; + screen[displayOffset + heightOffset + widthOffset] = data; widthOffset++; } while (widthOffset != widthOffsetBreak); heightOffset += _displayWidth; @@ -333,12 +510,14 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte //set_drawing_flag byte drawMask = getDrawingMask(color, priority, control); + vectorAdjustLineCoordinates(&left, &top, &right, &bottom, drawMask, color, priority, control); + // horizontal line if (top == bottom) { if (right < left) SWAP(right, left); for (int i = left; i <= right; i++) - putPixel(i, top, drawMask, color, priority, control); + vectorPutLinePixel(i, top, drawMask, color, priority, control); return; } // vertical line @@ -346,20 +525,20 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte if (top > bottom) SWAP(top, bottom); for (int i = top; i <= bottom; i++) - putPixel(left, i, drawMask, color, priority, control); + vectorPutLinePixel(left, i, drawMask, color, priority, control); return; } // sloped line - draw with Bresenham algorithm - int dy = bottom - top; - int dx = right - left; - int stepy = dy < 0 ? -1 : 1; - int stepx = dx < 0 ? -1 : 1; + int16 dy = bottom - top; + int16 dx = right - left; + int16 stepy = dy < 0 ? -1 : 1; + int16 stepx = dx < 0 ? -1 : 1; dy = ABS(dy) << 1; dx = ABS(dx) << 1; // setting the 1st and last pixel - putPixel(left, top, drawMask, color, priority, control); - putPixel(right, bottom, drawMask, color, priority, control); + vectorPutLinePixel(left, top, drawMask, color, priority, control); + vectorPutLinePixel(right, bottom, drawMask, color, priority, control); // drawing the line if (dx > dy) { // going horizontal int fraction = dy - (dx >> 1); @@ -370,7 +549,7 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte } left += stepx; fraction += dy; - putPixel(left, top, drawMask, color, priority, control); + vectorPutLinePixel(left, top, drawMask, color, priority, control); } } else { // going vertical int fraction = dx - (dy >> 1); @@ -381,7 +560,7 @@ void GfxScreen::drawLine(Common::Point startPoint, Common::Point endPoint, byte } top += stepy; fraction += dx; - putPixel(left, top, drawMask, color, priority, control); + vectorPutLinePixel(left, top, drawMask, color, priority, control); } } } @@ -394,46 +573,14 @@ void GfxScreen::putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, u commonFont->drawChar(displayPtr, chr, _displayWidth, 1, color, 0, -1, -1); } -byte GfxScreen::getVisual(int x, int y) { - return _visualScreen[y * _pitch + x]; -} - -byte GfxScreen::getPriority(int x, int y) { - return _priorityScreen[y * _pitch + x]; -} - -byte GfxScreen::getControl(int x, int y) { - return _controlScreen[y * _pitch + x]; +byte GfxScreen::getPixelNormal(byte *screen, int16 x, int16 y) { + return screen[y * _width + x]; } -byte GfxScreen::isFillMatch(int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA) { - int offset = y * _pitch + x; - byte match = 0; - - if (screenMask & GFX_SCREEN_MASK_VISUAL) { - if (!isEGA) { - if (*(_visualScreen + offset) == t_color) - match |= GFX_SCREEN_MASK_VISUAL; - } else { - // In EGA games a pixel in the framebuffer is only 4 bits. We store - // a full byte per pixel to allow undithering, but when comparing - // pixels for flood-fill purposes, we should only compare the - // visible color of a pixel. - - byte c = *(_visualScreen + offset); - if ((x ^ y) & 1) - c = (c ^ (c >> 4)) & 0x0F; - else - c = c & 0x0F; - if (c == t_color) - match |= GFX_SCREEN_MASK_VISUAL; - } - } - if ((screenMask & GFX_SCREEN_MASK_PRIORITY) && *(_priorityScreen + offset) == t_pri) - match |= GFX_SCREEN_MASK_PRIORITY; - if ((screenMask & GFX_SCREEN_MASK_CONTROL) && *(_controlScreen + offset) == t_con) - match |= GFX_SCREEN_MASK_CONTROL; - return match; +byte GfxScreen::getPixelUpscaled(byte *screen, int16 x, int16 y) { + int16 mappedX = _upscaledWidthMapping[x]; + int16 mappedY = _upscaledHeightMapping[y]; + return screen[mappedY * _width + mappedX]; } int GfxScreen::bitsGetDataSize(Common::Rect rect, byte mask) { @@ -469,14 +616,14 @@ void GfxScreen::bitsSave(Common::Rect rect, byte mask, byte *memoryPtr) { memcpy(memoryPtr, (void *)&mask, sizeof(mask)); memoryPtr += sizeof(mask); if (mask & GFX_SCREEN_MASK_VISUAL) { - bitsSaveScreen(rect, _visualScreen, _pitch, memoryPtr); + bitsSaveScreen(rect, _visualScreen, _width, memoryPtr); bitsSaveDisplayScreen(rect, memoryPtr); } if (mask & GFX_SCREEN_MASK_PRIORITY) { - bitsSaveScreen(rect, _priorityScreen, _pitch, memoryPtr); + bitsSaveScreen(rect, _priorityScreen, _width, memoryPtr); } if (mask & GFX_SCREEN_MASK_CONTROL) { - bitsSaveScreen(rect, _controlScreen, _pitch, memoryPtr); + bitsSaveScreen(rect, _controlScreen, _width, memoryPtr); } if (mask & GFX_SCREEN_MASK_DISPLAY) { if (!_upscaledHires) @@ -530,14 +677,14 @@ void GfxScreen::bitsRestore(byte *memoryPtr) { memcpy((void *)&mask, memoryPtr, sizeof(mask)); memoryPtr += sizeof(mask); if (mask & GFX_SCREEN_MASK_VISUAL) { - bitsRestoreScreen(rect, memoryPtr, _visualScreen, _pitch); + bitsRestoreScreen(rect, memoryPtr, _visualScreen, _width); bitsRestoreDisplayScreen(rect, memoryPtr); } if (mask & GFX_SCREEN_MASK_PRIORITY) { - bitsRestoreScreen(rect, memoryPtr, _priorityScreen, _pitch); + bitsRestoreScreen(rect, memoryPtr, _priorityScreen, _width); } if (mask & GFX_SCREEN_MASK_CONTROL) { - bitsRestoreScreen(rect, memoryPtr, _controlScreen, _pitch); + bitsRestoreScreen(rect, memoryPtr, _controlScreen, _width); } if (mask & GFX_SCREEN_MASK_DISPLAY) { if (!_upscaledHires) @@ -612,21 +759,22 @@ void GfxScreen::dither(bool addToFlag) { byte color, ditheredColor; byte *visualPtr = _visualScreen; byte *displayPtr = _displayScreen; - + if (!_unditheringEnabled) { // Do dithering on visual and display-screen for (y = 0; y < _height; y++) { - for (x = 0; x < _pitch; x++) { + for (x = 0; x < _width; x++) { color = *visualPtr; if (color & 0xF0) { color ^= color << 4; color = ((x^y) & 1) ? color >> 4 : color & 0x0F; switch (_upscaledHires) { case GFX_SCREEN_UPSCALED_DISABLED: + case GFX_SCREEN_UPSCALED_480x300: *displayPtr = color; break; default: - putScaledPixelOnDisplay(x, y, color); + putScaledPixelOnScreen(_displayScreen, x, y, color); break; } *visualPtr = color; @@ -639,7 +787,7 @@ void GfxScreen::dither(bool addToFlag) { memset(&_ditheredPicColors, 0, sizeof(_ditheredPicColors)); // Do dithering on visual screen and put decoded but undithered byte onto display-screen for (y = 0; y < _height; y++) { - for (x = 0; x < _pitch; x++) { + for (x = 0; x < _width; x++) { color = *visualPtr; if (color & 0xF0) { color ^= color << 4; @@ -654,10 +802,11 @@ void GfxScreen::dither(bool addToFlag) { } switch (_upscaledHires) { case GFX_SCREEN_UPSCALED_DISABLED: + case GFX_SCREEN_UPSCALED_480x300: *displayPtr = ditheredColor; break; default: - putScaledPixelOnDisplay(x, y, ditheredColor); + putScaledPixelOnScreen(_displayScreen, x, y, ditheredColor); break; } color = ((x^y) & 1) ? color >> 4 : color & 0x0F; @@ -685,8 +834,8 @@ int16 *GfxScreen::unditherGetDitheredBgColors() { } void GfxScreen::debugShowMap(int mapNo) { - // We cannot really support changing maps when in upscaledHires mode - if (_upscaledHires) + // We cannot really support changing maps when display screen has a different resolution than visual screen + if ((_width != _displayWidth) || (_height != _displayHeight)) return; switch (mapNo) { @@ -779,8 +928,8 @@ void GfxScreen::adjustBackUpscaledCoordinates(int16 &y, int16 &x, Sci32ViewNativ switch (_upscaledHires) { case GFX_SCREEN_UPSCALED_480x300: - x = (x << 1) / 3; - y = (y << 1) / 3; + x = (x * 4) / 6; + y = (y * 4) / 6; break; case GFX_SCREEN_UPSCALED_640x400: x /= 2; @@ -816,26 +965,4 @@ int16 GfxScreen::kernelPicNotValid(int16 newPicNotValid) { return oldPicNotValid; } -uint16 GfxScreen::getLowResScreenHeight() { - // Some Mac SCI1/1.1 games only take up 190 rows and do not - // have the menu bar. - // TODO: Verify that LSL1 and LSL5 use height 190 - if (g_sci->getPlatform() == Common::kPlatformMacintosh) { - switch (g_sci->getGameId()) { - case GID_FREDDYPHARKAS: - case GID_KQ5: - case GID_KQ6: - case GID_LSL1: - case GID_LSL5: - case GID_SQ1: - return 190; - default: - break; - } - } - - // Everything else is 200 - return 200; -} - } // End of namespace Sci diff --git a/engines/sci/graphics/screen.h b/engines/sci/graphics/screen.h index e266a4ed16..766e32614a 100644 --- a/engines/sci/graphics/screen.h +++ b/engines/sci/graphics/screen.h @@ -69,6 +69,8 @@ public: uint16 getWidth() { return _width; } uint16 getHeight() { return _height; } + uint16 getScriptWidth() { return _scriptWidth; } + uint16 getScriptHeight() { return _scriptHeight; } uint16 getDisplayWidth() { return _displayWidth; } uint16 getDisplayHeight() { return _displayHeight; } byte getColorWhite() { return _colorWhite; } @@ -81,11 +83,51 @@ public: void copyDisplayRectToScreen(const Common::Rect &rect); void copyRectToScreen(const Common::Rect &rect, int16 x, int16 y); + // calls to code pointers + void inline vectorAdjustCoordinate (int16 *x, int16 *y) { + (this->*_vectorAdjustCoordinatePtr)(x, y); + } + void inline vectorAdjustLineCoordinates (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control) { + (this->*_vectorAdjustLineCoordinatesPtr)(left, top, right, bottom, drawMask, color, priority, control); + } + byte inline vectorIsFillMatch (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA) { + return (this->*_vectorIsFillMatchPtr)(x, y, screenMask, t_color, t_pri, t_con, isEGA); + } + void inline vectorPutPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + (this->*_vectorPutPixelPtr)(x, y, drawMask, color, priority, control); + } + void inline vectorPutLinePixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + (this->*_vectorPutLinePixelPtr)(x, y, drawMask, color, priority, control); + } + byte inline vectorGetVisual(int16 x, int16 y) { + return (this->*_vectorGetPixelPtr)(_visualScreen, x, y); + } + byte inline vectorGetPriority(int16 x, int16 y) { + return (this->*_vectorGetPixelPtr)(_priorityScreen, x, y); + } + byte inline vectorGetControl(int16 x, int16 y) { + return (this->*_vectorGetPixelPtr)(_controlScreen, x, y); + } + + + void inline putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority, byte control) { + (this->*_putPixelPtr)(x, y, drawMask, color, priority, control); + } + + byte inline getVisual(int16 x, int16 y) { + return (this->*_getPixelPtr)(_visualScreen, x, y); + } + byte inline getPriority(int16 x, int16 y) { + return (this->*_getPixelPtr)(_priorityScreen, x, y); + } + byte inline getControl(int16 x, int16 y) { + return (this->*_getPixelPtr)(_controlScreen, x, y); + } + byte getDrawingMask(byte color, byte prio, byte control); - void putPixel(int x, int y, byte drawMask, byte color, byte prio, byte control); - void putFontPixel(int startingY, int x, int y, byte color); - void putPixelOnDisplay(int x, int y, byte color); - void putScaledPixelOnDisplay(int x, int y, byte color); + //void putPixel(int16 x, int16 y, byte drawMask, byte color, byte prio, byte control); + void putFontPixel(int16 startingY, int16 x, int16 y, byte color); + void putPixelOnDisplay(int16 x, int16 y, byte color); void drawLine(Common::Point startPoint, Common::Point endPoint, byte color, byte prio, byte control); void drawLine(int16 left, int16 top, int16 right, int16 bottom, byte color, byte prio, byte control) { drawLine(Common::Point(left, top), Common::Point(right, bottom), color, prio, control); @@ -101,10 +143,6 @@ public: void enableUndithering(bool flag); void putKanjiChar(Graphics::FontSJIS *commonFont, int16 x, int16 y, uint16 chr, byte color); - byte getVisual(int x, int y); - byte getPriority(int x, int y); - byte getControl(int x, int y); - byte isFillMatch(int16 x, int16 y, byte drawMask, byte t_color, byte t_pri, byte t_con, bool isEGA); int bitsGetDataSize(Common::Rect rect, byte mask); void bitsSave(Common::Rect rect, byte mask, byte *memoryPtr); @@ -135,9 +173,10 @@ public: private: uint16 _width; - uint16 _pitch; uint16 _height; uint _pixels; + uint16 _scriptWidth; + uint16 _scriptHeight; uint16 _displayWidth; uint16 _displayHeight; uint _displayPixels; @@ -190,8 +229,8 @@ private: * This here holds a translation for vertical+horizontal coordinates between native * (visual) and actual (display) screen. */ - int _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1]; - int _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1]; + int16 _upscaledHeightMapping[SCI_SCREEN_UPSCALEDMAXHEIGHT + 1]; + int16 _upscaledWidthMapping[SCI_SCREEN_UPSCALEDMAXWIDTH + 1]; /** * This defines whether or not the font we're drawing is already scaled @@ -199,7 +238,38 @@ private: */ bool _fontIsUpscaled; - uint16 getLowResScreenHeight(); + // dynamic code + void (GfxScreen::*_vectorAdjustCoordinatePtr) (int16 *x, int16 *y); + void vectorAdjustCoordinateNOP (int16 *x, int16 *y); + void vectorAdjustCoordinate480x300Mac (int16 *x, int16 *y); + + void (GfxScreen::*_vectorAdjustLineCoordinatesPtr) (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control); + void vectorAdjustLineCoordinatesNOP (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control); + void vectorAdjustLineCoordinates480x300Mac (int16 *left, int16 *top, int16 *right, int16 *bottom, byte drawMask, byte color, byte priority, byte control); + + byte (GfxScreen::*_vectorIsFillMatchPtr) (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA); + byte vectorIsFillMatchNormal (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA); + byte vectorIsFillMatch480x300Mac (int16 x, int16 y, byte screenMask, byte t_color, byte t_pri, byte t_con, bool isEGA); + + void (GfxScreen::*_vectorPutPixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + void vectorPutPixel480x300Mac (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + + void (GfxScreen::*_vectorPutLinePixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + void vectorPutLinePixel480x300Mac (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + + byte (GfxScreen::*_vectorGetPixelPtr) (byte *screen, int16 x, int16 y); + + void (GfxScreen::*_putPixelPtr) (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + void putPixelNormal (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + void putPixelDisplayUpscaled (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + void putPixelAllUpscaled (int16 x, int16 y, byte drawMask, byte color, byte priority, byte control); + + byte (GfxScreen::*_getPixelPtr) (byte *screen, int16 x, int16 y); + byte getPixelNormal (byte *screen, int16 x, int16 y); + byte getPixelUpscaled (byte *screen, int16 x, int16 y); + + // pixel helper + void putScaledPixelOnScreen(byte *screen, int16 x, int16 y, byte color); }; } // End of namespace Sci diff --git a/engines/sci/graphics/transitions.cpp b/engines/sci/graphics/transitions.cpp index 5e7dbc6c15..ccc7a4389a 100644 --- a/engines/sci/graphics/transitions.cpp +++ b/engines/sci/graphics/transitions.cpp @@ -339,10 +339,10 @@ void GfxTransitions::pixelation(bool blackoutFlag) { do { mask = (mask & 1) ? (mask >> 1) ^ 0xB400 : mask >> 1; - if (mask >= _screen->getWidth() * _screen->getHeight()) + if (mask >= _screen->getScriptWidth() * _screen->getScriptHeight()) continue; - pixelRect.left = mask % _screen->getWidth(); pixelRect.right = pixelRect.left + 1; - pixelRect.top = mask / _screen->getWidth(); pixelRect.bottom = pixelRect.top + 1; + pixelRect.left = mask % _screen->getScriptWidth(); pixelRect.right = pixelRect.left + 1; + pixelRect.top = mask / _screen->getScriptWidth(); pixelRect.bottom = pixelRect.top + 1; pixelRect.clip(_picRect); if (!pixelRect.isEmpty()) copyRectToScreen(pixelRect, blackoutFlag); -- cgit v1.2.3 From 5594feff2a7a209d62b5ecfba02262680fd27d97 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 9 Nov 2014 17:33:17 +0100 Subject: SCI: Phantasmagoria actually outputs 630x450 now clipping of video output was required --- engines/sci/graphics/frameout.cpp | 10 +++++++++- engines/sci/graphics/screen.cpp | 25 +++++++++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index fafc734895..ccc362dc37 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -524,6 +524,10 @@ void GfxFrameout::showVideo() { RobotDecoder *videoDecoder = g_sci->_robotDecoder; uint16 x = videoDecoder->getPos().x; uint16 y = videoDecoder->getPos().y; + uint16 screenWidth = _screen->getWidth(); + uint16 screenHeight = _screen->getHeight(); + uint16 outputWidth; + uint16 outputHeight; if (videoDecoder->hasDirtyPalette()) g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256); @@ -532,7 +536,11 @@ void GfxFrameout::showVideo() { if (videoDecoder->needsUpdate()) { const Graphics::Surface *frame = videoDecoder->decodeNextFrame(); if (frame) { - g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h); + // We need to clip here + // At least Phantasmagoria shows a 640x390 video on a 630x450 screen during the intro + outputWidth = frame->w > screenWidth ? screenWidth : frame->w; + outputHeight = frame->h > screenHeight ? screenHeight : frame->h; + g_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, outputWidth, outputHeight); if (videoDecoder->hasDirtyPalette()) g_system->getPaletteManager()->setPalette(videoDecoder->getPalette(), 0, 256); diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 594c4b3442..8b0e76332f 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -43,6 +43,8 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { _scriptHeight = 200; _width = 0; _height = 0; + _displayWidth = 0; + _displayHeight = 0; // King's Quest 6 and Gabriel Knight 1 have hires content, gk1/cd was able // to provide that under DOS as well, but as gk1/floppy does support @@ -93,19 +95,20 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { } #endif -#ifdef ENABLE_SCI32 - // Phantasmagoria 1 sets a window area of 630x450 - //if (g_sci->getGameId() == GID_PHANTASMAGORIA) { - // _width = 630; - // _height = 450; - //} -#endif - if (_resMan->detectHires()) { _scriptWidth = 640; _scriptHeight = 480; } +#ifdef ENABLE_SCI32 + // Phantasmagoria 1 effectively outputs 630x450 + // Coordinate translation has to use this resolution as well + if (g_sci->getGameId() == GID_PHANTASMAGORIA) { + _width = 630; + _height = 450; + } +#endif + // if not yet set, set those to script-width/height if (!_width) _width = _scriptWidth; @@ -152,8 +155,10 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { _upscaledWidthMapping[i] = i * 2; break; default: - _displayWidth = _width; - _displayHeight = _height; + if (!_displayWidth) + _displayWidth = _width; + if (!_displayHeight) + _displayHeight = _height; memset(&_upscaledHeightMapping, 0, sizeof(_upscaledHeightMapping) ); memset(&_upscaledWidthMapping, 0, sizeof(_upscaledWidthMapping) ); break; -- cgit v1.2.3 From 54a4b2fa863b5fd9469e360ecd7c4b0717b373fe Mon Sep 17 00:00:00 2001 From: lukaslw Date: Sun, 9 Nov 2014 22:19:20 +0100 Subject: PRINCE: Double animation of bird after 'throw a rock' mini-game fix --- engines/prince/script.cpp | 11 +++++++++++ engines/prince/script.h | 1 + 2 files changed, 12 insertions(+) diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp index 1e50fe5ec4..4ed3cee6f3 100644 --- a/engines/prince/script.cpp +++ b/engines/prince/script.cpp @@ -722,6 +722,17 @@ void Interpreter::O_PUTBACKANIM() { _vm->_script->installSingleBackAnim(_vm->_backAnimList, slot, room->_backAnim); } delete room; + + // WALKAROUND: fix for turning on 'walking bird' background animation too soon, + // after completing 'throw a rock' mini-game in Silmaniona location. + // Second bird shouldn't appear when normal animation is still in use + // in script lines 13814 and 13848 + if (_currentInstruction == kSecondBirdAnimationScriptFix) { + if (_vm->_normAnimList[1]._state == 0) { + _vm->_backAnimList[0].backAnims[0]._state = 1; + } + } + debugInterpreter("O_PUTBACKANIM roomId %d, slot %d, animId %d", roomId, slot, animId); } diff --git a/engines/prince/script.h b/engines/prince/script.h index 23c0468d15..fe79cf5f96 100644 --- a/engines/prince/script.h +++ b/engines/prince/script.h @@ -242,6 +242,7 @@ private: static OpcodeFunc _opcodes[]; static const uint kGiveLetterScriptFix = 79002; + static const uint kSecondBirdAnimationScriptFix = 45658; // Keep opcode handlers names as they are in original code // making it easier to switch back and forth -- cgit v1.2.3 From d0f2e20b62392dc040a61036237cef37e13e6d19 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:25:39 +0600 Subject: ZVISION: Fix rlf backward seek and rename class field --- engines/zvision/animation/rlf_animation.cpp | 45 +++++++++++++++++------------ engines/zvision/animation/rlf_animation.h | 4 +-- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp index 2bb0271966..5972bdb3ef 100644 --- a/engines/zvision/animation/rlf_animation.cpp +++ b/engines/zvision/animation/rlf_animation.cpp @@ -44,7 +44,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) _height(0), _frameTime(0), _frames(0), - _currentFrame(0), + _nextFrame(0), _frameBufferByteSize(0) { Common::File *_file = new Common::File; @@ -82,7 +82,7 @@ RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream) _height(0), _frameTime(0), _frames(0), - _currentFrame(0), + _nextFrame(0), _frameBufferByteSize(0) { if (!readHeader()) { @@ -193,23 +193,32 @@ void RlfAnimation::seekToFrame(int frameNumber) { assert(!_stream); assert(frameNumber < (int)_frameCount || frameNumber >= -1); - if (_currentFrame == frameNumber) + if (_nextFrame == frameNumber) return; if (frameNumber < 0) { - _currentFrame = 0; + _nextFrame = 0; return; } - int closestFrame = _currentFrame; - int distance = (int)frameNumber - _currentFrame; - for (uint i = 0; i < _completeFrames.size(); ++i) { - int newDistance = (int)frameNumber - (int)(_completeFrames[i]); - if (newDistance < 0) - break; - if (newDistance > 0 && newDistance < distance) { + int closestFrame = _nextFrame; + int distance = (int)frameNumber - _nextFrame; + + if (distance < 0) { + for (uint i = 0; i < _completeFrames.size(); ++i) { + if ((int)_completeFrames[i] > frameNumber) + break; closestFrame = _completeFrames[i]; - distance = newDistance; + } + } else { + for (uint i = 0; i < _completeFrames.size(); ++i) { + int newDistance = (int)frameNumber - (int)(_completeFrames[i]); + if (newDistance < 0) + break; + if (newDistance < distance) { + closestFrame = _completeFrames[i]; + distance = newDistance; + } } } @@ -217,7 +226,7 @@ void RlfAnimation::seekToFrame(int frameNumber) { applyFrameToCurrent(i); } - _currentFrame = frameNumber; + _nextFrame = frameNumber; } const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { @@ -226,9 +235,9 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { // Since this method is so expensive, first check to see if we can use // decodeNextFrame() it's cheap. - if ((int)frameNumber == _currentFrame - 1) { + if ((int)frameNumber == _nextFrame - 1) { return &_currentFrameBuffer; - } else if (_currentFrame == (int)frameNumber) { + } else if (_nextFrame == (int)frameNumber) { return decodeNextFrame(); } @@ -237,15 +246,15 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { } const Graphics::Surface *RlfAnimation::decodeNextFrame() { - assert(_currentFrame < (int)_frameCount); + assert(_nextFrame < (int)_frameCount); if (_stream) { applyFrameToCurrent(readNextFrame()); } else { - applyFrameToCurrent(_currentFrame); + applyFrameToCurrent(_nextFrame); } - _currentFrame++; + _nextFrame++; return &_currentFrameBuffer; } diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h index dfb2a60109..00c2e9b3d5 100644 --- a/engines/zvision/animation/rlf_animation.h +++ b/engines/zvision/animation/rlf_animation.h @@ -64,7 +64,7 @@ private: Frame *_frames; Common::Array _completeFrames; - int _currentFrame; + int _nextFrame; Graphics::Surface _currentFrameBuffer; uint32 _frameBufferByteSize; @@ -113,7 +113,7 @@ public: * @return Is the currentFrame is the last frame in the animation? */ bool endOfAnimation() { - return _currentFrame == (int)_frameCount; + return _nextFrame == (int)_frameCount; } private: -- cgit v1.2.3 From 51a9ec80df468757902cd85a5ab2a32856148d29 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:30:13 +0600 Subject: ZVISION: Implement ZeroPoint for panorama renderer --- engines/zvision/graphics/render_table.cpp | 9 +++++++++ engines/zvision/graphics/render_table.h | 3 +++ engines/zvision/scripting/control.cpp | 4 +++- engines/zvision/zvision.cpp | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index aeba729196..bb095f0c9a 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -52,6 +52,7 @@ void RenderTable::setRenderState(RenderState newState) { _panoramaOptions.fieldOfView = 27.0f; _panoramaOptions.linearScale = 0.55f; _panoramaOptions.reverse = false; + _panoramaOptions.zeroPoint = 0; break; case TILT: _tiltOptions.fieldOfView = 27.0f; @@ -244,6 +245,14 @@ void RenderTable::setPanoramaReverse(bool reverse) { _panoramaOptions.reverse = reverse; } +void RenderTable::setPanoramaZeroPoint(uint16 point) { + _panoramaOptions.zeroPoint = point; +} + +uint16 RenderTable::getPanoramaZeroPoint() { + return _panoramaOptions.zeroPoint; +} + void RenderTable::setTiltFoV(float fov) { assert(fov > 0.0f); diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h index 7153738c6f..2e3fd8ec33 100644 --- a/engines/zvision/graphics/render_table.h +++ b/engines/zvision/graphics/render_table.h @@ -50,6 +50,7 @@ private: float fieldOfView; float linearScale; bool reverse; + uint16 zeroPoint; } _panoramaOptions; // TODO: See if tilt and panorama need to have separate options @@ -75,6 +76,8 @@ public: void setPanoramaFoV(float fov); void setPanoramaScale(float scale); void setPanoramaReverse(bool reverse); + void setPanoramaZeroPoint(uint16 point); + uint16 getPanoramaZeroPoint(); void setTiltFoV(float fov); void setTiltScale(float scale); diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index ae717d6f8d..4567495725 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -61,7 +61,9 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream & renderTable->setPanoramaReverse(true); } } else if (line.matchString("zeropoint*", true)) { - // TODO: Implement + uint point; + sscanf(line.c_str(), "zeropoint(%u)", &point); + renderTable->setPanoramaZeroPoint(point); } line = stream.readLine(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 4f05edaefd..606e712cd0 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -370,7 +370,7 @@ void ZVision::updateRotation() { int16 new_pos = st_pos + _velocity * (1 - 2 * 0); - int16 zero_point = 0; + int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint(); if (st_pos >= zero_point && new_pos < zero_point) _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1); if (st_pos <= zero_point && new_pos > zero_point) -- cgit v1.2.3 From 54917582eb60c28c093cf84d78f5641a8ea02ea8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:31:48 +0600 Subject: ZVISION: Implement missing action - cursor --- engines/zvision/scripting/actions.cpp | 33 +++++++++++++++++++++++++ engines/zvision/scripting/actions.h | 9 +++++++ engines/zvision/scripting/scr_file_handling.cpp | 2 ++ 3 files changed, 44 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 04f318b84e..f27427caa9 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -43,6 +43,7 @@ #include "zvision/graphics/effects/light.h" #include "zvision/graphics/effects/wave.h" #include "zvision/core/save_manager.h" +#include "zvision/cursors/cursor_manager.h" #include "common/file.h" @@ -161,6 +162,38 @@ bool ActionCrossfade::execute() { return true; } +////////////////////////////////////////////////////////////////////////////// +// ActionCursor +////////////////////////////////////////////////////////////////////////////// + +ActionCursor::ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line) : + ResultAction(engine, slotkey) { + Common::String up = line; + up.toUppercase(); + _action = 0; + + if (up[0] == 'B') + _action = 2; + else if (up[0] == 'I') + _action = 3; + else if (up[0] == 'U') + _action = 0; + else if (up[0] == 'H') + _action = 1; +} + +bool ActionCursor::execute() { + switch (_action) { + case 1: + _engine->getCursorManager()->showMouse(false); + break; + default: + _engine->getCursorManager()->showMouse(true); + break; + } + return true; +} + ////////////////////////////////////////////////////////////////////////////// // ActionDelayRender ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index a6b5aa1290..5401af0876 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -148,6 +148,15 @@ private: int32 _timeInMillis; }; +class ActionCursor : public ResultAction { +public: + ActionCursor(ZVision *engine, int32 slotkey, const Common::String &line); + bool execute(); + +private: + uint8 _action; +}; + class ActionDebug : public ResultAction { public: ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index de092183c6..5e0387f0d9 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -229,6 +229,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis actionList.push_back(new ActionChangeLocation(_engine, slot, args)); } else if (act.matchString("crossfade", true)) { actionList.push_back(new ActionCrossfade(_engine, slot, args)); + } else if (act.matchString("cursor", true)) { + actionList.push_back(new ActionCursor(_engine, slot, args)); } else if (act.matchString("debug", true)) { // Not used. Purposely left empty } else if (act.matchString("delay_render", true)) { -- cgit v1.2.3 From 6f6d5fc24eb66b893f9871e773b9bd2632ab5ca5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:34:01 +0600 Subject: ZVISION: Hide mouse cursor while streamvideo is working --- engines/zvision/scripting/actions.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index f27427caa9..eb6b09308b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -899,6 +899,8 @@ bool ActionStreamVideo::execute() { return true; } + _engine->getCursorManager()->showMouse(false); + Common::Rect destRect = Common::Rect(_x1, _y1, _x2 + 1, _y2 + 1); Common::String subname = _fileName; @@ -913,6 +915,8 @@ bool ActionStreamVideo::execute() { _engine->playVideo(decoder, destRect, _skippable, sub); + _engine->getCursorManager()->showMouse(true); + if (sub) delete sub; } -- cgit v1.2.3 From 7d92b44e09809f559db96ec029a6258d23d84fd0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:36:30 +0600 Subject: ZVISION: Nemesis and GI has difference in set_partial_screen color mask --- engines/zvision/graphics/render_manager.cpp | 10 ++++++++++ engines/zvision/graphics/render_manager.h | 2 ++ engines/zvision/scripting/actions.cpp | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 8411f190a7..3e146939e3 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -149,6 +149,16 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1 surface.free(); } +void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY) { + Graphics::Surface surface; + readImageToSurface(fileName, surface); + + uint16 keycolor = *(uint16 *)surface.getBasePtr(keyX, keyY); + + blitSurfaceToBkg(surface, destX, destY, keycolor); + surface.free(); +} + void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) { Common::File file; diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index ae24ce4f58..d34ecf8ce0 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -185,6 +185,8 @@ public: */ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey); + void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY); + /** * Sets the current background image to be used by the RenderManager and immediately * blits it to the screen. (It won't show up until the end of the frame) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index eb6b09308b..31f68d7953 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -815,10 +815,20 @@ ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, c bool ActionSetPartialScreen::execute() { RenderManager *renderManager = _engine->getRenderManager(); - if (_backgroundColor >= 0) - renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor); - else - renderManager->renderImageToBackground(_fileName, _x, _y); + + if (_engine->getGameId() == GID_NEMESIS) { + if (_backgroundColor) + renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0); + else + renderManager->renderImageToBackground(_fileName, _x, _y); + } else { + if (_backgroundColor >= 0) + renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor); + else if (_backgroundColor == -2) + renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0); + else + renderManager->renderImageToBackground(_fileName, _x, _y); + } return true; } -- cgit v1.2.3 From 42bc6c5daf132b3656f04759aa1fa615fe7b26f6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:37:57 +0600 Subject: ZVISION: Fix incorrect usage of Common::String::format --- engines/zvision/core/save_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 6e8b6b5ff3..2797b940a0 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -219,9 +219,9 @@ Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { // Try to load standart save file Common::String filename; if (_engine->getGameId() == GID_GRANDINQUISITOR) - filename.format("inqsav%u.sav", slot); + filename = Common::String::format("inqsav%u.sav", slot); else if (_engine->getGameId() == GID_NEMESIS) - filename.format("nemsav%u.sav", slot); + filename = Common::String::format("nemsav%u.sav", slot); saveFile = _engine->getSearchManager()->openFile(filename); if (saveFile == NULL) { -- cgit v1.2.3 From f55f4af2937f77c3dc9760b000d2e4806477c1a0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:38:29 +0600 Subject: ZVISION: Fix code style in save_manager.h --- engines/zvision/core/save_manager.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index c7c1297062..5cd61c7aa9 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -49,7 +49,9 @@ struct SaveGameHeader { class SaveManager { public: SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} - ~SaveManager() { flushSaveBuffer(); } + ~SaveManager() { + flushSaveBuffer(); + } private: ZVision *_engine; -- cgit v1.2.3 From 9b88ab15dfff651007f9c6bcad1f5e646a4fa662 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:40:29 +0600 Subject: ZVISION: Make strings const in functions declaration --- engines/zvision/cursors/cursor_manager.cpp | 2 +- engines/zvision/cursors/cursor_manager.h | 2 +- engines/zvision/scripting/control.cpp | 2 +- engines/zvision/scripting/control.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp index cfb4baf636..564ffd25c5 100644 --- a/engines/zvision/cursors/cursor_manager.cpp +++ b/engines/zvision/cursors/cursor_manager.cpp @@ -140,7 +140,7 @@ void CursorManager::changeCursor(int id) { } } -int CursorManager::getCursorId(Common::String &name) { +int CursorManager::getCursorId(const Common::String &name) { for (int i = 0; i < NUM_CURSORS; i++) if (name.equals(_cursorNames[i])) return i; diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h index 5392fd5e03..a6f77cec64 100644 --- a/engines/zvision/cursors/cursor_manager.h +++ b/engines/zvision/cursors/cursor_manager.h @@ -97,7 +97,7 @@ public: * @return Id of cursor or idle cursor id if not found */ - int getCursorId(Common::String &name); + int getCursorId(const Common::String &name); /** * Load cursor for item by id, and try to change cursor to item cursor if it's not 0 diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index 4567495725..c746f00831 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -105,7 +105,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre renderTable->generateRenderTable(); } -void Control::getParams(Common::String &input_str, Common::String ¶meter, Common::String &values) { +void Control::getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { const char *chrs = input_str.c_str(); uint lbr; diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 8708f033af..28c7348d98 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -127,7 +127,7 @@ protected: uint32 _key; int32 _venus_id; - void getParams(Common::String &input_str, Common::String ¶meter, Common::String &values); + void getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); // Static member functions public: static void parseFlatControl(ZVision *engine); -- cgit v1.2.3 From 9e9b89071f9a07e2784bf52ef976d6560bf56e67 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:43:04 +0600 Subject: ZVISION: Implement function for convertion of scummvm KeyCode to win vkKey --- engines/zvision/module.mk | 1 + engines/zvision/utility/win_keys.cpp | 129 +++++++++++++++++++++++++++++++++++ engines/zvision/utility/win_keys.h | 32 +++++++++ 3 files changed, 162 insertions(+) create mode 100644 engines/zvision/utility/win_keys.cpp create mode 100644 engines/zvision/utility/win_keys.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 1730bbc512..199f96bf47 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -50,6 +50,7 @@ MODULE_OBJS := \ utility/lzss_read_stream.o \ utility/single_value_container.o \ utility/utility.o \ + utility/win_keys.o \ video/video.o \ video/zork_avi_decoder.o \ zvision.o diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp new file mode 100644 index 0000000000..3441fb8bf0 --- /dev/null +++ b/engines/zvision/utility/win_keys.cpp @@ -0,0 +1,129 @@ +/* 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 "common/keyboard.h" + +namespace ZVision { + +uint8 VKkey(Common::KeyCode scumm_key) { + if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z) + return 0x41 + scumm_key - Common::KEYCODE_a; + if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9) + return 0x30 + scumm_key - Common::KEYCODE_0; + if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15) + return 0x70 + scumm_key - Common::KEYCODE_F1; + if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9) + return 0x60 + scumm_key - Common::KEYCODE_KP0; + + switch (scumm_key) { + case Common::KEYCODE_BACKSPACE: + return 0x8; + case Common::KEYCODE_TAB: + return 0x9; + case Common::KEYCODE_CLEAR: + return 0xC; + case Common::KEYCODE_RETURN: + return 0xD; + case Common::KEYCODE_CAPSLOCK: + return 0x14; + case Common::KEYCODE_ESCAPE: + return 0x1B; + case Common::KEYCODE_SPACE: + return 0x20; + case Common::KEYCODE_PAGEUP: + return 0x21; + case Common::KEYCODE_PAGEDOWN: + return 0x22; + case Common::KEYCODE_END: + return 0x23; + case Common::KEYCODE_HOME: + return 0x24; + case Common::KEYCODE_LEFT: + return 0x25; + case Common::KEYCODE_UP: + return 0x26; + case Common::KEYCODE_RIGHT: + return 0x27; + case Common::KEYCODE_DOWN: + return 0x28; + case Common::KEYCODE_PRINT: + return 0x2A; + case Common::KEYCODE_INSERT: + return 0x2D; + case Common::KEYCODE_DELETE: + return 0x2E; + case Common::KEYCODE_HELP: + return 0x2F; + case Common::KEYCODE_KP_MULTIPLY: + return 0x6A; + case Common::KEYCODE_KP_PLUS: + return 0x6B; + case Common::KEYCODE_KP_MINUS: + return 0x6D; + case Common::KEYCODE_KP_PERIOD: + return 0x6E; + case Common::KEYCODE_KP_DIVIDE: + return 0x6F; + case Common::KEYCODE_NUMLOCK: + return 0x90; + case Common::KEYCODE_SCROLLOCK: + return 0x91; + case Common::KEYCODE_LSHIFT: + return 0xA0; + case Common::KEYCODE_RSHIFT: + return 0xA1; + case Common::KEYCODE_LCTRL: + return 0xA2; + case Common::KEYCODE_RCTRL: + return 0xA3; + case Common::KEYCODE_MENU: + return 0xA5; + case Common::KEYCODE_LEFTBRACKET: + return 0xDB; + case Common::KEYCODE_RIGHTBRACKET: + return 0xDD; + case Common::KEYCODE_SEMICOLON: + return 0xBA; + case Common::KEYCODE_BACKSLASH: + return 0xDC; + case Common::KEYCODE_QUOTE: + return 0xDE; + case Common::KEYCODE_SLASH: + return 0xBF; + case Common::KEYCODE_TILDE: + return 0xC0; + case Common::KEYCODE_COMMA: + return 0xBC; + case Common::KEYCODE_PERIOD: + return 0xBE; + case Common::KEYCODE_MINUS: + return 0xBD; + case Common::KEYCODE_PLUS: + return 0xBB; + default: + return 0; + } + + return 0; +} + +} diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h new file mode 100644 index 0000000000..a79a03a07b --- /dev/null +++ b/engines/zvision/utility/win_keys.h @@ -0,0 +1,32 @@ +/* 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 ZVISION_WINKEY_H +#define ZVISION_WINKEY_H + +#include "common/keyboard.h" + +namespace ZVision { +uint8 VKkey(Common::KeyCode scumm_key); +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From c79ac80b0c73b86fa665dd439fa30cb3ca709785 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:47:12 +0600 Subject: ZVISION: Implement quit function with reminder --- engines/zvision/zvision.cpp | 7 +++++++ engines/zvision/zvision.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 606e712cd0..b697405c63 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -459,4 +459,11 @@ void ZVision::menuBarEnable(uint16 menus) { _menu->setEnable(menus); } +bool ZVision::ifQuit() { + if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { + quitGame(); + return true; + } + return false; +} } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index def9bbbdfb..e1a94db618 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -187,6 +187,8 @@ public: void menuBarEnable(uint16 menus); + bool ifQuit(); + private: void initialize(); void initFonts(); -- cgit v1.2.3 From fcbb3d0307d8423399a41cef8f8cbaec062018db Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:48:32 +0600 Subject: ZVISION: Use ifQuit for menu bars --- engines/zvision/core/menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index bf311c4577..57a1983784 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -174,7 +174,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { scrollPos[menu_MAIN], 320 + 135 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - // ifquit(); + _engine->ifQuit(); } // Settings @@ -591,7 +591,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { scrollPos, buts[3][0] + buts[3][1], scrollPos + 32).contains(Pos)) { - // ifquit(); + _engine->ifQuit(); frm = 5; redraw = true; } -- cgit v1.2.3 From f658a5c8e6a92341efc7ec15ec0f875b1cc7eb93 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:34:55 +0600 Subject: ZVISION: Implement methods for get state of menu items --- engines/zvision/core/menu.h | 3 +++ engines/zvision/zvision.cpp | 6 ++++++ engines/zvision/zvision.h | 1 + 3 files changed, 10 insertions(+) diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7e6acf325c..c2ea822dd9 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -52,6 +52,9 @@ public: void setEnable(uint16 flags) { menu_bar_flag = flags; } + uint16 getEnable() { + return menu_bar_flag; + } protected: uint16 menu_bar_flag; ZVision *_engine; diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b697405c63..c5d5fdc58b 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -459,6 +459,12 @@ void ZVision::menuBarEnable(uint16 menus) { _menu->setEnable(menus); } +uint16 ZVision::getMenuBarEnable() { + if (_menu) + return _menu->getEnable(); + return 0; +} + bool ZVision::ifQuit() { if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { quitGame(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index e1a94db618..8b9b67303e 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -186,6 +186,7 @@ public: void saveSettings(); void menuBarEnable(uint16 menus); + uint16 getMenuBarEnable(); bool ifQuit(); -- cgit v1.2.3 From db5e2adc5828a4bf888959ebd520bb43e89996fe Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:40:54 +0600 Subject: ZVISION: Implement method for visual output of some info --- engines/zvision/zvision.cpp | 6 ++++++ engines/zvision/zvision.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index c5d5fdc58b..0b03cc351d 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -472,4 +472,10 @@ bool ZVision::ifQuit() { } return false; } +void ZVision::showDebugMsg(const Common::String &msg, int16 delay) { + uint16 msgid = _renderManager->createSubArea(); + _renderManager->updateSubArea(msgid, msg); + _renderManager->deleteSubArea(msgid, delay); +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8b9b67303e..3c9e26b5ec 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -190,6 +190,8 @@ public: bool ifQuit(); + void showDebugMsg(const Common::String &msg, int16 delay = 3000); + private: void initialize(); void initFonts(); -- cgit v1.2.3 From 8e112edb1a7d8d1d579a235bda18b58ffcc18b8c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:47:27 +0600 Subject: ZVISION: Implement Easter eggs and debug cheats --- engines/zvision/core/events.cpp | 92 ++++++++++++++++++++++++++++++++++++++++- engines/zvision/zvision.cpp | 30 ++++++++++++++ engines/zvision/zvision.h | 11 ++++- 3 files changed, 130 insertions(+), 3 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index c977125f55..97565dd4d7 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,6 +30,8 @@ #include "zvision/scripting/script_manager.h" #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" +#include "zvision/utility/win_keys.h" +#include "zvision/sound/zork_raw.h" #include "common/events.h" #include "common/system.h" @@ -40,6 +42,86 @@ namespace ZVision { +void ZVision::cheatCodes(uint8 key) { + pushKeyToCheatBuf(key); + + if (getGameId() == GID_GRANDINQUISITOR) { + + if (checkCode("IMNOTDEAF")) { + // Unknow cheat + showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); + } + + if (checkCode("3100OPB")) { + showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _scriptManager->getStateValue(StateKey_World), + _scriptManager->getStateValue(StateKey_Room), + _scriptManager->getStateValue(StateKey_Node), + _scriptManager->getStateValue(StateKey_View))); + } + + if (checkCode("KILLMENOW")) { + _scriptManager->changeLocation('g', 'j', 'd', 'e', 0); + _scriptManager->setStateValue(2201, 35); + } + + if (checkCode("MIKESPANTS")) { + _scriptManager->changeLocation('g', 'j', 't', 'm', 0); + } + } else if (getGameId() == GID_NEMESIS) { + + if (checkCode("CHLOE")) { + _scriptManager->changeLocation('t', 'm', '2', 'g', 0); + _scriptManager->setStateValue(224, 1); + } + + if (checkCode("77MASSAVE")) { + showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _scriptManager->getStateValue(StateKey_World), + _scriptManager->getStateValue(StateKey_Room), + _scriptManager->getStateValue(StateKey_Node), + _scriptManager->getStateValue(StateKey_View))); + } + + if (checkCode("IDKFA")) { + _scriptManager->changeLocation('t', 'w', '3', 'f', 0); + _scriptManager->setStateValue(249, 1); + } + + if (checkCode("309NEWDORMA")) { + _scriptManager->changeLocation('g', 'j', 'g', 'j', 0); + } + + if (checkCode("HELLOSAILOR")) { + Location loc = _scriptManager->getCurrentLocation(); + Audio::AudioStream *soundStream; + if (loc.world == 'v' && loc.room == 'b' && loc.node == '1' && loc.view == '0') { + soundStream = makeRawZorkStream("v000hpta.raw", this); + } else { + soundStream = makeRawZorkStream("v000hnta.raw", this); + } + Audio::SoundHandle handle; + _mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream); + } + } + + if (checkCode("FRAME")) + showDebugMsg(Common::String::format("FPS: ???, not implemented")); + + if (checkCode("XYZZY")) + _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); + + if (checkCode("COMPUTERARCH")) + showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); + + if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) + if (checkCode("GO????")) + _scriptManager->changeLocation(getBufferedKey(3), + getBufferedKey(2), + getBufferedKey(1), + getBufferedKey(0), 0); +} + void ZVision::processEvents() { while (_eventMan->pollEvent(_event)) { switch (_event.type) { @@ -72,7 +154,7 @@ void ZVision::processEvents() { onMouseMove(_event.mouse); break; - case Common::EVENT_KEYDOWN: + case Common::EVENT_KEYDOWN: { switch (_event.kbd.keycode) { case Common::KEYCODE_d: if (_event.kbd.hasFlags(Common::KBD_CTRL)) { @@ -89,8 +171,14 @@ void ZVision::processEvents() { break; } + uint8 vkKey = VKkey(_event.kbd.keycode); + + _scriptManager->setStateValue(StateKey_KeyPress, vkKey); + _scriptManager->addEvent(_event); - break; + cheatCodes(vkKey); + } + break; case Common::EVENT_KEYUP: _scriptManager->addEvent(_event); break; diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 0b03cc351d..3518e01d68 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -100,6 +100,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _velocity(0) { debug(1, "ZVision::ZVision"); + + memset(_cheatBuff, 0, sizeof(_cheatBuff)); } ZVision::~ZVision() { @@ -472,6 +474,34 @@ bool ZVision::ifQuit() { } return false; } + +void ZVision::pushKeyToCheatBuf(uint8 key) { + for (int i = 0; i < KEYBUF_SIZE - 1; i++) + _cheatBuff[i] = _cheatBuff[i + 1]; + + _cheatBuff[KEYBUF_SIZE - 1] = key; +} + +bool ZVision::checkCode(const char *code) { + int codeLen = strlen(code); + + if (codeLen > KEYBUF_SIZE) + return false; + + for (int i = 0; i < codeLen; i++) + if (code[i] != _cheatBuff[KEYBUF_SIZE - codeLen + i] && code[i] != '?') + return false; + + return true; +} + +uint8 ZVision::getBufferedKey(uint8 pos) { + if (pos >= KEYBUF_SIZE) + return 0; + else + return _cheatBuff[KEYBUF_SIZE - pos - 1]; +} + void ZVision::showDebugMsg(const Common::String &msg, int16 delay) { uint16 msgid = _renderManager->createSubArea(); _renderManager->updateSubArea(msgid, msg); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 3c9e26b5ec..041a8574a6 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -85,7 +85,9 @@ private: WORKING_WINDOW_HEIGHT = 344, ROTATION_SCREEN_EDGE_OFFSET = 60, - MAX_ROTATION_SPEED = 400 // Pixels per second + MAX_ROTATION_SPEED = 400, // Pixels per second + + KEYBUF_SIZE = 20 }; Console *_console; @@ -122,6 +124,8 @@ private: int _rendDelay; int16 _velocity; bool _halveDelay; + + uint8 _cheatBuff[KEYBUF_SIZE]; public: uint32 getFeatures() const; Common::Language getLanguage() const; @@ -205,6 +209,11 @@ private: void updateRotation(); void registerDefaultSettings(); + + void cheatCodes(uint8 key); + void pushKeyToCheatBuf(uint8 key); + bool checkCode(const char *code); + uint8 getBufferedKey(uint8 pos); }; } // End of namespace ZVision -- cgit v1.2.3 From c4911135c152b9f7eb082dee1af79d82932e72c0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:50:18 +0600 Subject: ZVISION: Implement keyboard hotkeys --- engines/zvision/core/events.cpp | 27 +++++++++++++++++++++++++++ engines/zvision/zvision.h | 1 + 2 files changed, 28 insertions(+) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 97565dd4d7..72e3fa6d34 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -31,6 +31,7 @@ #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" #include "zvision/utility/win_keys.h" +#include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" @@ -42,6 +43,31 @@ namespace ZVision { +void ZVision::shortKeys(Common::Event event) { + if (event.kbd.hasFlags(Common::KBD_CTRL)) { + switch (event.kbd.keycode) { + case Common::KEYCODE_s: + if (getMenuBarEnable() & menuBar_Save) + _scriptManager->changeLocation('g', 'j', 's', 'e', 0); + break; + case Common::KEYCODE_r: + if (getMenuBarEnable() & menuBar_Restore) + _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); + break; + case Common::KEYCODE_p: + if (getMenuBarEnable() & menuBar_Settings) + _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); + break; + case Common::KEYCODE_q: + if (getMenuBarEnable() & menuBar_Exit) + ifQuit(); + break; + default: + break; + } + } +} + void ZVision::cheatCodes(uint8 key) { pushKeyToCheatBuf(key); @@ -176,6 +202,7 @@ void ZVision::processEvents() { _scriptManager->setStateValue(StateKey_KeyPress, vkKey); _scriptManager->addEvent(_event); + shortKeys(_event); cheatCodes(vkKey); } break; diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 041a8574a6..8564e4e26b 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -209,6 +209,7 @@ private: void updateRotation(); void registerDefaultSettings(); + void shortKeys(Common::Event); void cheatCodes(uint8 key); void pushKeyToCheatBuf(uint8 key); -- cgit v1.2.3 From e57c358cead20cbf75332a15c4961ff6c15abf6a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:52:20 +0600 Subject: ZVISION: Implement method for getting panorama reverse flag --- engines/zvision/graphics/render_table.cpp | 4 ++++ engines/zvision/graphics/render_table.h | 1 + 2 files changed, 5 insertions(+) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index bb095f0c9a..629cbde3cf 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -245,6 +245,10 @@ void RenderTable::setPanoramaReverse(bool reverse) { _panoramaOptions.reverse = reverse; } +bool RenderTable::getPanoramaReverse() { + return _panoramaOptions.reverse; +} + void RenderTable::setPanoramaZeroPoint(uint16 point) { _panoramaOptions.zeroPoint = point; } diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h index 2e3fd8ec33..f061b3b0d6 100644 --- a/engines/zvision/graphics/render_table.h +++ b/engines/zvision/graphics/render_table.h @@ -78,6 +78,7 @@ public: void setPanoramaReverse(bool reverse); void setPanoramaZeroPoint(uint16 point); uint16 getPanoramaZeroPoint(); + bool getPanoramaReverse(); void setTiltFoV(float fov); void setTiltScale(float scale); -- cgit v1.2.3 From 1f0bf5ecf2f3eb1c65019d196f7327a0874f93bb Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:55:10 +0600 Subject: ZVISION: Implement code for pan from keyboard and mouse --- engines/zvision/core/events.cpp | 46 ++++++++++++++++++++++++++++++++++------- engines/zvision/zvision.cpp | 12 ++++++++--- engines/zvision/zvision.h | 3 ++- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e3fa6d34..38ceb5ceb4 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -189,10 +189,26 @@ void ZVision::processEvents() { _console->onFrame(); } break; + + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; case Common::KEYCODE_q: if (_event.kbd.hasFlags(Common::KBD_CTRL)) quitGame(); break; + + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + break; + default: break; } @@ -208,6 +224,20 @@ void ZVision::processEvents() { break; case Common::EVENT_KEYUP: _scriptManager->addEvent(_event); + switch (_event.kbd.keycode) { + case Common::KEYCODE_LEFT: + case Common::KEYCODE_RIGHT: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) + _kbdVelocity = 0; + break; + case Common::KEYCODE_UP: + case Common::KEYCODE_DOWN: + if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) + _kbdVelocity = 0; + break; + default: + break; + } break; default: break; @@ -261,7 +291,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; @@ -270,12 +300,12 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else if (renderState == RenderTable::TILT) { if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { @@ -283,7 +313,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -292,18 +322,18 @@ void ZVision::onMouseMove(const Common::Point &pos) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _velocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } } else { - _velocity = 0; + _mouseVelocity = 0; } if (!cursorWasChanged) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 3518e01d68..f2f713dac0 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -97,7 +97,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _midiManager(nullptr), _aud_id(0), _rendDelay(2), - _velocity(0) { + _kbdVelocity(0), + _mouseVelocity(0) { debug(1, "ZVision::ZVision"); @@ -365,12 +366,17 @@ bool ZVision::canRender() { } void ZVision::updateRotation() { + int16 _velocity = _mouseVelocity + _kbdVelocity; + + if (_halveDelay) + _velocity /= 2; + if (_velocity) { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + int16 new_pos = st_pos + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity); int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint(); if (st_pos >= zero_point && new_pos < zero_point) @@ -389,7 +395,7 @@ void ZVision::updateRotation() { } else if (renderState == RenderTable::TILT) { int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + _velocity * (1 - 2 * 0); + int16 new_pos = st_pos + _velocity; int16 scr_height = _renderManager->getBkgSize().y; int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8564e4e26b..549ea9bcdf 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -122,7 +122,8 @@ private: const Common::Rect _workingWindow_ZNM; int _rendDelay; - int16 _velocity; + int16 _mouseVelocity; + int16 _kbdVelocity; bool _halveDelay; uint8 _cheatBuff[KEYBUF_SIZE]; -- cgit v1.2.3 From 418b5f6dd28931ef8c7a0a05ae90dde3b36015b7 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 15:58:35 +0600 Subject: ZVISION: Passive borders check for tilt and panorama for changelocation --- engines/zvision/scripting/script_manager.cpp | 2 ++ engines/zvision/zvision.cpp | 35 ++++++++++++++++++++++++++++ engines/zvision/zvision.h | 1 + 3 files changed, 38 insertions(+) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 457b491042..a5cb81b957 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -628,6 +628,8 @@ void ScriptManager::do_changeLocation() { _currentLocation = _nextLocation; execScope(nodeview); } + + _engine->checkBorders(); } void ScriptManager::serialize(Common::WriteStream *stream) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index f2f713dac0..d8b0f209e3 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -410,6 +410,41 @@ void ZVision::updateRotation() { } } +void ZVision::checkBorders() { + RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); + if (renderState == RenderTable::PANORAMA) { + int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + + int16 new_pos = st_pos; + + int16 scr_width = _renderManager->getBkgSize().x; + + if (scr_width) + new_pos %= scr_width; + + if (new_pos < 0) + new_pos += scr_width; + + if (st_pos != new_pos) + _renderManager->setBackgroundPosition(new_pos); + } else if (renderState == RenderTable::TILT) { + int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + + int16 new_pos = st_pos; + + int16 scr_height = _renderManager->getBkgSize().y; + int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); + + if (new_pos >= (scr_height - tilt_gap)) + new_pos = scr_height - tilt_gap; + if (new_pos <= tilt_gap) + new_pos = tilt_gap; + + if (st_pos != new_pos) + _renderManager->setBackgroundPosition(new_pos); + } +} + void ZVision::rotateTo(int16 _toPos, int16 _time) { if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA) return; diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 549ea9bcdf..8cf9dbf107 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -195,6 +195,7 @@ public: bool ifQuit(); + void checkBorders(); void showDebugMsg(const Common::String &msg, int16 delay = 3000); private: -- cgit v1.2.3 From 2d7af4bab7e8c298373307d77d4a3e98cab1b575 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:00:02 +0600 Subject: ZVISION: Add call of inventory cycling for Nemesis --- engines/zvision/core/events.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 38ceb5ceb4..5f8f8e243f 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -168,7 +168,9 @@ void ZVision::processEvents() { case Common::EVENT_RBUTTONDOWN: _cursorManager->cursorDown(true); _scriptManager->setStateValue(StateKey_RMouse, 1); - // TODO: Inventory logic + + if (getGameId() == GID_NEMESIS) + _scriptManager->invertory_cycle(); break; case Common::EVENT_RBUTTONUP: -- cgit v1.2.3 From bb06ecf798682959bc9e31e92a6624e391e8429d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:01:23 +0600 Subject: ZVISION: Make menu bar fully enabled after changelocation called --- engines/zvision/scripting/script_manager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index a5cb81b957..7df48183bd 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -562,6 +562,8 @@ void ScriptManager::do_changeLocation() { _referenceTable.clear(); addPuzzlesToReferenceTable(universe); + _engine->menuBarEnable(0xFFFF); + if (_nextLocation.world != _currentLocation.world) { cleanScriptScope(nodeview); cleanScriptScope(room); -- cgit v1.2.3 From 960bbe53b2160de3747678bd877c532d49c7d147 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:02:35 +0600 Subject: ZVISION: Fix delays with halveDelay option --- engines/zvision/zvision.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index d8b0f209e3..4d9830a0e3 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -300,7 +300,10 @@ bool ZVision::askQuestion(const Common::String &str) { } } _system->updateScreen(); - _system->delayMillis(66); + if (_halveDelay) + _system->delayMillis(33); + else + _system->delayMillis(66); } _renderManager->deleteSubArea(msgid); _clock.start(); @@ -325,7 +328,10 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { break; } _system->updateScreen(); - _system->delayMillis(66); + if (_halveDelay) + _system->delayMillis(33); + else + _system->delayMillis(66); } _renderManager->deleteSubArea(msgid); _clock.start(); -- cgit v1.2.3 From e970d121ff1acbe426e652a4ac17deebaf351821 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:05:48 +0600 Subject: ZVISION: Lead code of all controls to the same style --- .../zvision/scripting/controls/fist_control.cpp | 80 ++++++++++++++------- engines/zvision/scripting/controls/fist_control.h | 1 + .../zvision/scripting/controls/input_control.cpp | 34 +++++---- .../zvision/scripting/controls/lever_control.cpp | 82 ++++++++++++++-------- engines/zvision/scripting/controls/lever_control.h | 3 +- .../scripting/controls/push_toggle_control.cpp | 48 ++++++------- .../scripting/controls/push_toggle_control.h | 2 +- .../zvision/scripting/controls/save_control.cpp | 15 ++-- 8 files changed, 161 insertions(+), 104 deletions(-) diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 89aeb53be6..4779c5db74 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -187,54 +187,58 @@ void FistControl::readDescFile(const Common::String &fileName) { } Common::String line; + Common::String param; + Common::String values; while (!file.eos()) { line = file.readLine(); + getFistParams(line, param, values); - for (int i = line.size() - 1; i >= 0; i--) - if (line[i] == '~') - line.deleteChar(i); - - if (line.matchString("*animation_id*", true)) { + if (param.matchString("animation_id", true)) { // Not used - } else if (line.matchString("*animation*", true)) { - char filename[64]; - sscanf(line.c_str(), "animation:%s", filename); - _animation = new MetaAnimation(Common::String(filename), _engine); - } else if (line.matchString("*anim_rect*", true)) { + } else if (param.matchString("animation", true)) { + _animation = new MetaAnimation(values, _engine); + } else if (param.matchString("anim_rect", true)) { int left, top, right, bottom; - sscanf(line.c_str(), "anim_rect:%d %d %d %d", &left, &top, &right, &bottom); + sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom); _anmRect = Common::Rect(left, top, right, bottom); - } else if (line.matchString("*num_fingers*", true)) { - sscanf(line.c_str(), "num_fingers:%d", &_fistnum); + } else if (param.matchString("num_fingers", true)) { + sscanf(values.c_str(), "%d", &_fistnum); _fistsUp.resize(_fistnum); _fistsDwn.resize(_fistnum); - } else if (line.matchString("*entries*", true)) { - sscanf(line.c_str(), "entries:%d", &_numEntries); + } else if (param.matchString("entries", true)) { + sscanf(values.c_str(), "%d", &_numEntries); _entries.resize(_numEntries); - } else if (line.matchString("*eval_order_ascending*", true)) { - sscanf(line.c_str(), "eval_order_ascending:%d", &_order); - } else if (line.matchString("*up_hs_num_*", true)) { + } else if (param.matchString("eval_order_ascending", true)) { + sscanf(values.c_str(), "%d", &_order); + } else if (param.matchString("up_hs_num_*", true)) { int fist, num; - sscanf(line.c_str(), "up_hs_num_%d:%d", &fist, &num); + num = atoi(values.c_str()); + + sscanf(param.c_str(), "up_hs_num_%d", &fist); _fistsUp[fist].resize(num); - } else if (line.matchString("*up_hs_*", true)) { + } else if (param.matchString("up_hs_*", true)) { int16 fist, box, x1, y1, x2, y2; - sscanf(line.c_str(), "up_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2); + sscanf(param.c_str(), "up_hs_%hd_%hd", &fist, &box); + sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2); (_fistsUp[fist])[box] = Common::Rect(x1, y1, x2, y2); - } else if (line.matchString("*down_hs_num_*", true)) { + } else if (param.matchString("down_hs_num_*", true)) { int fist, num; - sscanf(line.c_str(), "down_hs_num_%d:%d", &fist, &num); + num = atoi(values.c_str()); + + sscanf(param.c_str(), "down_hs_num_%d", &fist); _fistsDwn[fist].resize(num); - } else if (line.matchString("*down_hs_*", true)) { + } else if (param.matchString("down_hs_*", true)) { int16 fist, box, x1, y1, x2, y2; - sscanf(line.c_str(), "down_hs_%hd_%hd:%hd %hd %hd %hd", &fist, &box, &x1, &y1, &x2, &y2); + sscanf(param.c_str(), "down_hs_%hd_%hd", &fist, &box); + sscanf(values.c_str(), "%hd %hd %hd %hd", &x1, &y1, &x2, &y2); (_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2); } else { int entry, start, end, sound; char bits_start[33]; char bits_end[33]; - if (sscanf(line.c_str(), "%d:%s %s %d %d (%d)", &entry, bits_start, bits_end, &start, &end, &sound) == 6) { + entry = atoi(param.c_str()); + if (sscanf(values.c_str(), "%s %s %d %d (%d)", bits_start, bits_end, &start, &end, &sound) == 5) { _entries[entry]._bitsStrt = readBits(bits_start); _entries[entry]._bitsEnd = readBits(bits_end); _entries[entry]._anmStrt = start; @@ -291,4 +295,28 @@ int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Poin return -1; } +void FistControl::getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { + const char *chrs = input_str.c_str(); + uint lbr; + + for (lbr = 0; lbr < input_str.size(); lbr++) + if (chrs[lbr] == ':') + break; + + if (lbr >= input_str.size()) + return; + + uint rbr; + + for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + if (chrs[rbr] == '~') + break; + + if (rbr >= input_str.size()) + return; + + parameter = Common::String(chrs, chrs + lbr); + values = Common::String(chrs + lbr + 1, chrs + rbr); +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index 940bc96d69..8b229f964a 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -79,6 +79,7 @@ private: void clearFistArray(Common::Array< Common::Array > &arr); uint32 readBits(const char *str); int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); + void getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index e35b300cb9..f8acdbda73 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -51,59 +51,63 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); while (!stream.eos() && !line.contains('}')) { - if (line.matchString("*rectangle*", true)) { + if (param.matchString("rectangle", true)) { int x1; int y1; int x2; int y2; - sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2); + sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2); _textRectangle = Common::Rect(x1, y1, x2, y2); - } else if (line.matchString("*aux_hotspot*", true)) { + } else if (param.matchString("aux_hotspot", true)) { int x1; int y1; int x2; int y2; - sscanf(line.c_str(), "%*[^(](%d %d %d %d)", &x1, &y1, &x2, &y2); + sscanf(values.c_str(), "%d %d %d %d", &x1, &y1, &x2, &y2); _headerRectangle = Common::Rect(x1, y1, x2, y2); - } else if (line.matchString("*string_init*", true)) { + } else if (param.matchString("string_init", true)) { uint fontFormatNumber; - sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber); + sscanf(values.c_str(), "%u", &fontFormatNumber); _string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); - } else if (line.matchString("*chooser_init_string*", true)) { + } else if (param.matchString("chooser_init_string", true)) { uint fontFormatNumber; - sscanf(line.c_str(), "%*[^(](%u)", &fontFormatNumber); + sscanf(values.c_str(), "%u", &fontFormatNumber); _string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); - } else if (line.matchString("*next_tabstop*", true)) { - sscanf(line.c_str(), "%*[^(](%u)", &_nextTabstop); - } else if (line.matchString("*cursor_dimensions*", true)) { + } else if (param.matchString("next_tabstop", true)) { + sscanf(values.c_str(), "%u", &_nextTabstop); + } else if (param.matchString("cursor_dimensions", true)) { // Ignore, use the dimensions in the animation file - } else if (line.matchString("*cursor_animation_frames*", true)) { + } else if (param.matchString("cursor_animation_frames", true)) { // Ignore, use the frame count in the animation file - } else if (line.matchString("*cursor_animation*", true)) { + } else if (param.matchString("cursor_animation", true)) { char fileName[25]; - sscanf(line.c_str(), "%*[^(](%25s %*u)", fileName); + sscanf(values.c_str(), "%25s %*u", fileName); _animation = new MetaAnimation(fileName, _engine); _frame = -1; _frameDelay = 0; - } else if (line.matchString("*focus*", true)) { + } else if (param.matchString("focus", true)) { _focused = true; _engine->getScriptManager()->setFocusControlKey(_key); } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); } } diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 84cd6fa598..9b665ff033 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -57,21 +57,26 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); + while (!stream.eos() && !line.contains('}')) { - if (line.matchString("*descfile*", true)) { + if (param.matchString("descfile", true)) { char levFileName[25]; - sscanf(line.c_str(), "%*[^(](%25[^)])", levFileName); + sscanf(values.c_str(), "%25s", levFileName); parseLevFile(levFileName); - } else if (line.matchString("*cursor*", true)) { + } else if (param.matchString("cursor", true)) { char cursorName[25]; - sscanf(line.c_str(), "%*[^(](%25[^)])", cursorName); + sscanf(values.c_str(), "%25s", cursorName); - _cursorName = Common::String(cursorName); + _cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName)); } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); } renderFrame(_currentFrame); @@ -92,50 +97,47 @@ void LeverControl::parseLevFile(const Common::String &fileName) { } Common::String line; + Common::String param; + Common::String values; while (!file.eos()) { line = file.readLine(); + getLevParams(line, param, values); - if (line.matchString("*animation_id*", true)) { + if (param.matchString("animation_id", true)) { // Not used - } else if (line.matchString("*filename*", true)) { - char fileNameBuffer[25]; - sscanf(line.c_str(), "%*[^:]:%25[^~]~", fileNameBuffer); - - Common::String animationFileName(fileNameBuffer); - - _animation = new MetaAnimation(animationFileName, _engine); - - } else if (line.matchString("*skipcolor*", true)) { + } else if (param.matchString("filename", true)) { + _animation = new MetaAnimation(values, _engine); + } else if (param.matchString("skipcolor", true)) { // Not used - } else if (line.matchString("*anim_coords*", true)) { + } else if (param.matchString("anim_coords", true)) { int left, top, right, bottom; - sscanf(line.c_str(), "%*[^:]:%d %d %d %d~", &left, &top, &right, &bottom); + sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom); _animationCoords.left = left; _animationCoords.top = top; _animationCoords.right = right; _animationCoords.bottom = bottom; - } else if (line.matchString("*mirrored*", true)) { + } else if (param.matchString("mirrored", true)) { uint mirrored; - sscanf(line.c_str(), "%*[^:]:%u~", &mirrored); + sscanf(values.c_str(), "%u", &mirrored); _mirrored = mirrored == 0 ? false : true; - } else if (line.matchString("*frames*", true)) { - sscanf(line.c_str(), "%*[^:]:%u~", &_frameCount); + } else if (param.matchString("frames", true)) { + sscanf(values.c_str(), "%u", &_frameCount); _frameInfo = new FrameInfo[_frameCount]; - } else if (line.matchString("*elsewhere*", true)) { + } else if (param.matchString("elsewhere", true)) { // Not used - } else if (line.matchString("*out_of_control*", true)) { + } else if (param.matchString("out_of_control", true)) { // Not used - } else if (line.matchString("*start_pos*", true)) { - sscanf(line.c_str(), "%*[^:]:%u~", &_startFrame); + } else if (param.matchString("start_pos", true)) { + sscanf(values.c_str(), "%u", &_startFrame); _currentFrame = _startFrame; - } else if (line.matchString("*hotspot_deltas*", true)) { + } else if (param.matchString("hotspot_deltas", true)) { uint x; uint y; - sscanf(line.c_str(), "%*[^:]:%u %u~", &x, &y); + sscanf(values.c_str(), "%u %u", &x, &y); _hotspotDelta.x = x; _hotspotDelta.y = y; @@ -233,7 +235,7 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common } } } else if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_cursorName)); + _engine->getCursorManager()->changeCursor(_cursor); cursorWasChanged = true; } @@ -376,4 +378,28 @@ void LeverControl::renderFrame(uint frameNumber) { _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords); } +void LeverControl::getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { + const char *chrs = input_str.c_str(); + uint lbr; + + for (lbr = 0; lbr < input_str.size(); lbr++) + if (chrs[lbr] == ':') + break; + + if (lbr >= input_str.size()) + return; + + uint rbr; + + for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + if (chrs[rbr] == '~') + break; + + if (rbr >= input_str.size()) + return; + + parameter = Common::String(chrs, chrs + lbr); + values = Common::String(chrs + lbr + 1, chrs + rbr); +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h index 712d688523..22789f777b 100644 --- a/engines/zvision/scripting/controls/lever_control.h +++ b/engines/zvision/scripting/controls/lever_control.h @@ -62,7 +62,7 @@ private: private: MetaAnimation *_animation; - Common::String _cursorName; + int _cursor; Common::Rect _animationCoords; bool _mirrored; uint _frameCount; @@ -112,6 +112,7 @@ private: */ static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo); void renderFrame(uint frameNumber); + void getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index bf74a22051..03df4b722e 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -38,56 +38,52 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab : Control(engine, key, CONTROL_PUSHTGL), _countTo(2), _event(Common::EVENT_LBUTTONUP) { + + _hotspots.clear(); + // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); - line.toLowercase(); - _hotspots.clear(); + Common::String param; + Common::String values; + getParams(line, param, values); while (!stream.eos() && !line.contains('}')) { - if (line.matchString("*_hotspot*", true)) { + if (param.matchString("*_hotspot", true)) { uint x; uint y; uint width; uint height; - sscanf(line.c_str(), "%*[^(](%u,%u,%u,%u)", &x, &y, &width, &height); + sscanf(values.c_str(), "%u,%u,%u,%u", &x, &y, &width, &height); _hotspots.push_back(Common::Rect(x, y, x + width + 1, y + height + 1)); - } else if (line.matchString("cursor*", true)) { - char nameBuffer[25]; - - sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer); - - _hoverCursor = Common::String(nameBuffer); - } else if (line.matchString("animation*", true)) { + } else if (param.matchString("cursor", true)) { + _cursor = _engine->getCursorManager()->getCursorId(values); + } else if (param.matchString("animation", true)) { // Not used - } else if (line.matchString("sound*", true)) { + } else if (param.matchString("sound", true)) { // Not used - } else if (line.matchString("count_to*", true)) { - sscanf(line.c_str(), "%*[^(](%u)", &_countTo); - } else if (line.matchString("mouse_event*", true)) { - char nameBuffer[25]; - - sscanf(line.c_str(), "%*[^(](%25[^)])", nameBuffer); - - Common::String evntStr(nameBuffer); - if (evntStr.equalsIgnoreCase("up")) { + } else if (param.matchString("count_to", true)) { + sscanf(values.c_str(), "%u", &_countTo); + } else if (param.matchString("mouse_event", true)) { + if (values.equalsIgnoreCase("up")) { _event = Common::EVENT_LBUTTONUP; - } else if (evntStr.equalsIgnoreCase("down")) { + } else if (values.equalsIgnoreCase("down")) { _event = Common::EVENT_LBUTTONDOWN; - } else if (evntStr.equalsIgnoreCase("double")) { + } else if (values.equalsIgnoreCase("double")) { // Not used } - } else if (line.matchString("venus_id*", true)) { + } else if (param.matchString("venus_id*", true)) { // Not used } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); } - if (_hotspots.size() == 0 || _hoverCursor.empty()) { + if (_hotspots.size() == 0) { warning("Push_toggle %u was parsed incorrectly", key); } } @@ -133,7 +129,7 @@ bool PushToggleControl::onMouseMove(const Common::Point &screenSpacePos, const C return false; if (contain(backgroundImageSpacePos)) { - _engine->getCursorManager()->changeCursor(_engine->getCursorManager()->getCursorId(_hoverCursor)); + _engine->getCursorManager()->changeCursor(_cursor); return true; } diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h index 7b45fb4831..6d68b8f162 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.h +++ b/engines/zvision/scripting/controls/push_toggle_control.h @@ -68,7 +68,7 @@ private: */ Common::Array _hotspots; /** The cursor to use when hovering over _hotspot */ - Common::String _hoverCursor; + int _cursor; /** Button maximal values count */ uint _countTo; diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index fda8a70114..a0b19db513 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -44,23 +44,23 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream // Loop until we find the closing brace Common::String line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + Common::String param; + Common::String values; + getParams(line, param, values); while (!stream.eos() && !line.contains('}')) { - if (line.matchString("*savebox*", true)) { + if (param.matchString("savebox", true)) { int save_id; int input_id; - sscanf(line.c_str(), "%*[^(](%d %d)", &save_id, &input_id); + sscanf(values.c_str(), "%d %d", &save_id, &input_id); save_elmnt elmnt; elmnt.input_key = input_id; elmnt.save_id = save_id; elmnt.exist = false; _inputs.push_back(elmnt); - } else if (line.matchString("*control_type*", true)) { - char buf[32]; - - sscanf(line.c_str(), "%*[^(](%s)", buf); - if (Common::String(buf).contains("save")) + } else if (param.matchString("control_type", true)) { + if (values.contains("save")) _saveControl = true; else _saveControl = false; @@ -68,6 +68,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream line = stream.readLine(); trimCommentsAndWhiteSpace(&line); + getParams(line, param, values); } for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) { -- cgit v1.2.3 From f43326a533faec014fb1987f9ba3729127c46487 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 16:06:31 +0600 Subject: ZVISION: Clean of useless code --- engines/zvision/core/events.cpp | 3 --- engines/zvision/zvision.cpp | 27 --------------------------- 2 files changed, 30 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 5f8f8e243f..0d38e08b88 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -198,9 +198,6 @@ void ZVision::processEvents() { _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; - case Common::KEYCODE_q: - if (_event.kbd.hasFlags(Common::KBD_CTRL)) - quitGame(); break; case Common::KEYCODE_UP: diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 4d9830a0e3..84856429e9 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -170,33 +170,6 @@ void ZVision::initialize() { _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); } else if (_gameDescription->gameId == GID_NEMESIS) _searchManager->loadZix("NEMESIS.ZIX"); - // TODO: There are 10 file clashes when we flatten the directories. - // From a quick look, the files are exactly the same, so it shouldn't matter. - // But I'm noting it here just in-case it does become a problem. - SearchMan.addSubDirectoryMatching(gameDataDir, "data1", 0, 4, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "data2", 0, 4, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "data3", 0, 4, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "zassets1", 0, 2, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "zassets2", 0, 2, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "znemmx", 0, 1, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "zgi", 0, 4, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "zgi_mx", 0, 1, true); - SearchMan.addSubDirectoryMatching(gameDataDir, "fonts", 0, 1, true); - - // Find zfs archive files - Common::ArchiveMemberList list; - SearchMan.listMatchingMembers(list, "*.zfs"); - - // Register the file entries within the zfs archives with the SearchMan - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String name = (*iter)->getName(); - Common::SeekableReadStream *stream = (*iter)->createReadStream(); - ZfsArchive *archive = new ZfsArchive(name, stream); - - delete stream; - - SearchMan.add(name, archive); - } initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat); -- cgit v1.2.3 From b577da29b569a9ea4d74f4b8ea0d7e4fa3cae587 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sat, 15 Nov 2014 09:15:54 -0500 Subject: ANDROID: Delay deleting a local ref until it's no longer used Should fix bug #6741 --- backends/platform/android/asset-archive.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index 52c2c084bd..6680081c16 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -295,7 +295,6 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) : jclass cls = env->GetObjectClass(_assetfd); MID_close = env->GetMethodID(cls, "close", "()V"); assert(MID_close); - env->DeleteLocalRef(cls); jmethodID MID_getStartOffset = env->GetMethodID(cls, "getStartOffset", "()J"); @@ -321,6 +320,8 @@ AssetFdReadStream::AssetFdReadStream(JNIEnv *env, jobject assetfd) : _fd = env->GetIntField(javafd, FID_descriptor); env->DeleteLocalRef(javafd); + + env->DeleteLocalRef(cls); } AssetFdReadStream::~AssetFdReadStream() { -- cgit v1.2.3 From 244da223bd44759febbc8d5ff3044c1bbc61ae07 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 16 Nov 2014 11:30:08 +0100 Subject: CREDITS: Add Tobia Tesan --- AUTHORS | 1 + devtools/credits.pl | 1 + gui/credits.h | 1 + 3 files changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 5f19af4612..983f2524e4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -257,6 +257,7 @@ ScummVM Team Wintermute: Einar Johan T. Somaaen + Tobia Tesan ZVision: Adrian Astley diff --git a/devtools/credits.pl b/devtools/credits.pl index 9a3cd5c9ac..c8d9e538d8 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -786,6 +786,7 @@ begin_credits("Credits"); begin_section("Wintermute"); add_person("Einar Johan T. Sømåen", "somaen", ""); + add_person("Tobia Tesan", "t0by", ""); end_section(); begin_section("ZVision"); diff --git a/gui/credits.h b/gui/credits.h index 38287ebdf9..d908a730b7 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -320,6 +320,7 @@ static const char *credits[] = { "C1""Wintermute", "A0""Einar Johan T. Somaaen", "C0""Einar Johan T. S\370m\345en", +"C0""Tobia Tesan", "", "C1""ZVision", "C0""Adrian Astley", -- cgit v1.2.3 From f7b2cd0a7d067e39ed7973de75d5ce68c5464bc4 Mon Sep 17 00:00:00 2001 From: Kevin Becker Date: Wed, 19 Nov 2014 07:44:03 -0500 Subject: ZVISION: Added detection for Zork Grand Inquisitor English Demo. --- engines/zvision/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 1492ade639..bd45b39756 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -86,6 +86,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_GRANDINQUISITOR }, + { + // Zork Grand Inquisitor English demo version + { + "zgi", + "Demo", + AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_DEMO, + GUIO1(GUIO_NONE) + }, + GID_GRANDINQUISITOR + }, + { AD_TABLE_END_MARKER, GID_NONE -- cgit v1.2.3 From b12b1e1d256219364860db51977dd6bca7424ed1 Mon Sep 17 00:00:00 2001 From: Kevin Becker Date: Wed, 19 Nov 2014 07:44:23 -0500 Subject: ZVISION: Added detection for Zork Nemesis English Demo. --- engines/zvision/detection.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index bd45b39756..4f1d7fed3f 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -72,6 +72,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_NEMESIS }, + { + // Zork Nemesis English demo version + { + "znemesis", + "Demo", + AD_ENTRY1s("SCRIPTS.ZFS", "64f1e881394e9462305104f99513c833", 380539), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_DEMO, + GUIO1(GUIO_NONE) + }, + GID_NEMESIS + }, + { // Zork Grand Inquisitor English version { -- cgit v1.2.3 From deeeb0646f5c374d0f7635cb5897e2df2962ad37 Mon Sep 17 00:00:00 2001 From: Kevin Becker Date: Wed, 19 Nov 2014 07:44:44 -0500 Subject: ZVISION: Added detection for Zork Grand Inquisitor English DVD version. --- engines/zvision/detection.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 4f1d7fed3f..cd696557d9 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -87,10 +87,10 @@ static const ZVisionGameDescription gameDescriptions[] = { }, { - // Zork Grand Inquisitor English version + // Zork Grand Inquisitor English CD version { "zgi", - 0, + "CD", AD_ENTRY1s("SCRIPTS.ZFS", "81efd40ecc3d22531e211368b779f17f", 8336944), Common::EN_ANY, Common::kPlatformWindows, @@ -114,6 +114,20 @@ static const ZVisionGameDescription gameDescriptions[] = { GID_GRANDINQUISITOR }, + { + // Zork Grand Inquisitor English DVD version + { + "zgi", + "DVD", + AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + GID_GRANDINQUISITOR + }, + { AD_TABLE_END_MARKER, GID_NONE -- cgit v1.2.3 From 74509eb8ac390d04d76e464a6b50173ee720e40d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 19 Nov 2014 20:39:27 +0100 Subject: AGOS: Added detection for Simon the Sorcerer 1 CD32 demo I have verified that the demo is completable, though it doesn't actually seems to end. You're just told that there is nothing more for you to do. --- engines/agos/detection_tables.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/engines/agos/detection_tables.h b/engines/agos/detection_tables.h index 77fc88c6bb..2f4709c49e 100644 --- a/engines/agos/detection_tables.h +++ b/engines/agos/detection_tables.h @@ -1259,6 +1259,32 @@ static const AGOSGameDescription gameDescriptions[] = { GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR }, + // Simon the Sorcerer 1 - English Amiga CD32 demo, from the cover disc of + // issue 5 (October 1994) of Amiga CD32 Gamer + { + { + "simon1", + "CD32 Demo", + + { + { "gameamiga", GAME_BASEFILE, "e243f9229f9728b3476e54d2cf5f18a1", 27998}, + { "icon.pkd", GAME_ICONFILE, "565ef7a98dcc21ef526a2bb10b6f42ed", 18979}, + { "stripped.txt", GAME_STRFILE, "94413c71c86c32ed9baaa1c74a151cb3", 243}, + { "tbllist", GAME_TBLFILE, "f9d5bf2ce09f82289c791c3ca26e1e4b", 696}, + { NULL, 0, NULL, 0} + }, + Common::EN_ANY, + Common::kPlatformAmiga, + ADGF_CD | ADGF_DEMO, + GUIO2(GUIO_NOSUBTITLES, GUIO_NOMIDI) + }, + + GType_SIMON1, + GID_SIMON1CD32, + GF_TALKIE | GF_OLD_BUNDLE | GF_PLANAR + }, + + // Simon the Sorcerer 1 - English DOS Floppy Demo { { -- cgit v1.2.3 From f94f48ae2bdd3ad596c6bdf6a9875461079d4a7b Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Wed, 19 Nov 2014 22:59:34 +0100 Subject: AGOS: Fix invisibility in Amiga CD32 Simon the Sorcerer 1 demo This probably affects the full version as well, but I haven't verified that. Either way, the old code was obviously wrong while the new makes it look right to me. --- engines/agos/gfx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/agos/gfx.cpp b/engines/agos/gfx.cpp index 33145b7d0d..5a1f9f1917 100644 --- a/engines/agos/gfx.cpp +++ b/engines/agos/gfx.cpp @@ -547,7 +547,7 @@ void AGOSEngine_Simon1::drawMaskedImage(VC10_state *state) { if ((dst[count * 2] & 0xF0) == 0x20) dst[count * 2] = src[count * 2]; if (mask[count + state->x_skip] & 0x0F) - if ((dst[count * 2 + 1] & 0x0F) == 0x20) + if ((dst[count * 2 + 1] & 0xF0) == 0x20) dst[count * 2 + 1] = src[count * 2 + 1]; } else { /* no transparency */ -- cgit v1.2.3 From d5f7a1dc03f2a38774ad1c8dd6741bb9c6fb9848 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 20 Nov 2014 14:02:08 +0600 Subject: ZVISION: Implement forgotten setVenus for controls --- engines/zvision/scripting/control.cpp | 7 +++++++ engines/zvision/scripting/control.h | 4 ++-- engines/zvision/scripting/controls/fist_control.cpp | 4 +--- engines/zvision/scripting/controls/hotmov_control.cpp | 1 + engines/zvision/scripting/controls/input_control.cpp | 7 ++++++- engines/zvision/scripting/controls/lever_control.cpp | 3 +++ engines/zvision/scripting/controls/paint_control.cpp | 1 + engines/zvision/scripting/controls/push_toggle_control.cpp | 6 ++++-- engines/zvision/scripting/controls/safe_control.cpp | 1 + engines/zvision/scripting/controls/slot_control.cpp | 2 +- 10 files changed, 27 insertions(+), 9 deletions(-) diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index c746f00831..9c8156961c 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -23,6 +23,7 @@ #include "common/scummsys.h" #include "zvision/scripting/control.h" +#include "zvision/scripting/script_manager.h" #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" @@ -129,4 +130,10 @@ void Control::getParams(const Common::String &input_str, Common::String ¶met values = Common::String(chrs + lbr + 1, chrs + rbr); } +void Control::setVenus() { + if (_venus_id >= 0) + if (_engine->getScriptManager()->getStateValue(_venus_id) > 0) + _engine->getScriptManager()->setStateValue(StateKey_Venus, _venus_id); +} + } // End of namespace ZVision diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 28c7348d98..b784a66913 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -54,8 +54,7 @@ public: CONTROL_PAINT }; - Control() : _engine(0), _key(0) {} - Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type) {} + Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venus_id(-1) {} virtual ~Control() {} uint32 getKey() { @@ -121,6 +120,7 @@ public: virtual bool process(uint32 deltaTimeInMillis) { return false; } + void setVenus(); protected: ZVision *_engine; diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 4779c5db74..185bea09d2 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -155,7 +155,7 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos); if (n_fist >= 0) { - //ctrl_setvenus(ct); + setVenus(); uint32 oldStatus = _fiststatus; _fiststatus ^= (1 << n_fist); @@ -172,8 +172,6 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P } _engine->getScriptManager()->setStateValue(_key, _fiststatus); - - //_engine->getScriptManager()->FlushMouseBtn(SDL_BUTTON_LEFT); } return false; diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index b39292f1c5..6969ee1bfe 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -158,6 +158,7 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common: if (_cycle < _num_cycles) { if (_frames[_cur_frame].contains(backgroundImageSpacePos)) { + setVenus(); _engine->getScriptManager()->setStateValue(_key, 1); return true; } diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index f8acdbda73..442c6cbc6a 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -103,6 +103,8 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } else if (param.matchString("focus", true)) { _focused = true; _engine->getScriptManager()->setFocusControlKey(_key); + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); } line = stream.readLine(); @@ -119,10 +121,13 @@ bool InputControl::onMouseUp(const Common::Point &screenSpacePos, const Common:: if (!_readOnly) { // Save _engine->getScriptManager()->focusControl(_key); + setVenus(); } else { // Restore - if (_currentInputText.size()) + if (_currentInputText.size()) { + setVenus(); _enterPressed = true; + } } } return false; diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 9b665ff033..a9836b388e 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -141,6 +141,8 @@ void LeverControl::parseLevFile(const Common::String &fileName) { _hotspotDelta.x = x; _hotspotDelta.y = y; + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); } else { uint frameNumber; uint x, y; @@ -191,6 +193,7 @@ bool LeverControl::onMouseDown(const Common::Point &screenSpacePos, const Common return false; if (_frameInfo[_currentFrame].hotspot.contains(backgroundImageSpacePos)) { + setVenus(); _mouseIsCaptured = true; _lastMousePos = backgroundImageSpacePos; } diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index 2891f1b1f9..54c02a2568 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -142,6 +142,7 @@ bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); if (eligeblity(mouse_item)) { + setVenus(); _mouseDown = true; } } diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 03df4b722e..561dd1dd20 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -74,8 +74,8 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab } else if (values.equalsIgnoreCase("double")) { // Not used } - } else if (param.matchString("venus_id*", true)) { - // Not used + } else if (param.matchString("venus_id", true)) { + _venus_id = atoi(values.c_str()); } line = stream.readLine(); @@ -100,6 +100,7 @@ bool PushToggleControl::onMouseUp(const Common::Point &screenSpacePos, const Com return false; if (contain(backgroundImageSpacePos)) { + setVenus(); int32 val = _engine->getScriptManager()->getStateValue(_key); val = (val + 1) % _countTo; _engine->getScriptManager()->setStateValue(_key, val); @@ -116,6 +117,7 @@ bool PushToggleControl::onMouseDown(const Common::Point &screenSpacePos, const C return false; if (contain(backgroundImageSpacePos)) { + setVenus(); int32 val = _engine->getScriptManager()->getStateValue(_key); val = (val + 1) % _countTo; _engine->getScriptManager()->setStateValue(_key, val); diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index ba809148a3..9df61ce341 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -179,6 +179,7 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P if (_rectangle.contains(backgroundImageSpacePos)) { int32 mR = backgroundImageSpacePos.sqrDist(_center); if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) { + setVenus(); Common::Point tmp = backgroundImageSpacePos - _center; diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index f78061ac13..46ee320eb5 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -121,7 +121,7 @@ bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P return false; if (_hotspot.contains(backgroundImageSpacePos)) { - //ctrl_setvenus(ct); + setVenus(); int item = _engine->getScriptManager()->getStateValue(_key); int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); -- cgit v1.2.3 From 5b352da304931bafcfcddbe08461488335c7ad57 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 20 Nov 2014 14:48:24 +0600 Subject: ZVISION: More CamelCase and a bit of comments cleanup --- engines/zvision/animation/meta_animation.cpp | 16 +- engines/zvision/animation/meta_animation.h | 4 +- engines/zvision/core/events.cpp | 2 +- engines/zvision/core/menu.cpp | 282 ++++++++++----------- engines/zvision/core/menu.h | 34 +-- engines/zvision/core/midi.cpp | 18 +- engines/zvision/core/midi.h | 6 +- engines/zvision/core/save_manager.cpp | 3 +- engines/zvision/core/search_manager.cpp | 103 ++++---- engines/zvision/core/search_manager.h | 38 ++- engines/zvision/fonts/truetype_font.cpp | 28 +- engines/zvision/fonts/truetype_font.h | 6 +- engines/zvision/graphics/effects/fog.h | 6 +- engines/zvision/graphics/effects/wave.cpp | 148 +++++------ engines/zvision/graphics/effects/wave.h | 6 +- engines/zvision/graphics/render_manager.cpp | 89 ++++--- engines/zvision/graphics/render_manager.h | 120 ++++++--- engines/zvision/module.mk | 12 +- engines/zvision/scripting/actions.cpp | 104 ++++---- engines/zvision/scripting/actions.h | 48 +--- engines/zvision/scripting/control.cpp | 18 +- engines/zvision/scripting/control.h | 16 +- .../zvision/scripting/controls/fist_control.cpp | 30 +-- engines/zvision/scripting/controls/fist_control.h | 2 +- .../zvision/scripting/controls/hotmov_control.cpp | 46 ++-- .../zvision/scripting/controls/hotmov_control.h | 8 +- .../zvision/scripting/controls/input_control.cpp | 16 +- engines/zvision/scripting/controls/input_control.h | 4 +- .../zvision/scripting/controls/lever_control.cpp | 14 +- engines/zvision/scripting/controls/lever_control.h | 2 +- .../zvision/scripting/controls/paint_control.cpp | 52 ++-- engines/zvision/scripting/controls/paint_control.h | 4 +- .../scripting/controls/push_toggle_control.cpp | 2 +- .../zvision/scripting/controls/safe_control.cpp | 85 +++---- engines/zvision/scripting/controls/safe_control.h | 22 +- .../zvision/scripting/controls/save_control.cpp | 22 +- engines/zvision/scripting/controls/save_control.h | 8 +- .../zvision/scripting/controls/slot_control.cpp | 54 ++-- engines/zvision/scripting/controls/slot_control.h | 8 +- engines/zvision/scripting/inventory.cpp | 68 ++--- engines/zvision/scripting/scr_file_handling.cpp | 12 +- engines/zvision/scripting/script_manager.cpp | 108 ++++---- engines/zvision/scripting/script_manager.h | 60 ++--- .../zvision/scripting/sidefx/animation_node.cpp | 22 +- engines/zvision/scripting/sidefx/animation_node.h | 4 +- engines/zvision/scripting/sidefx/distort_node.cpp | 16 +- engines/zvision/scripting/sidefx/distort_node.h | 14 +- engines/zvision/scripting/sidefx/music_node.cpp | 60 ++--- engines/zvision/scripting/sidefx/music_node.h | 16 +- engines/zvision/scripting/sidefx/ttytext_node.h | 9 +- engines/zvision/subtitles/subtitles.cpp | 10 +- engines/zvision/text/text.cpp | 104 ++++---- engines/zvision/text/text.h | 14 +- engines/zvision/utility/win_keys.cpp | 20 +- engines/zvision/utility/win_keys.h | 6 +- engines/zvision/zvision.cpp | 94 +++---- engines/zvision/zvision.h | 22 +- 57 files changed, 1081 insertions(+), 1064 deletions(-) diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp index 1ea6df6481..2e549ec838 100644 --- a/engines/zvision/animation/meta_animation.cpp +++ b/engines/zvision/animation/meta_animation.cpp @@ -39,7 +39,7 @@ namespace ZVision { MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) : _fileType(RLF), - _cur_frame(NULL) { + _curFrame(NULL) { Common::String tmpFileName = fileName; tmpFileName.toLowercase(); if (tmpFileName.hasSuffix(".rlf")) { @@ -102,11 +102,11 @@ void MetaAnimation::seekToFrame(int frameNumber) { const Graphics::Surface *MetaAnimation::decodeNextFrame() { if (_fileType == RLF) - _cur_frame = _animation.rlf->decodeNextFrame(); + _curFrame = _animation.rlf->decodeNextFrame(); else - _cur_frame = _animation.avi->decodeNextFrame(); + _curFrame = _animation.avi->decodeNextFrame(); - return _cur_frame; + return _curFrame; } const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { @@ -114,12 +114,12 @@ const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { frameNumber = frameCount() - 1; if (_fileType == RLF) { - _cur_frame = _animation.rlf->getFrameData(frameNumber); - return _cur_frame; + _curFrame = _animation.rlf->getFrameData(frameNumber); + return _curFrame; } else { _animation.avi->seekToFrame(frameNumber); - _cur_frame = _animation.avi->decodeNextFrame(); - return _cur_frame; + _curFrame = _animation.avi->decodeNextFrame(); + return _curFrame; } } diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h index 2ea00310f9..4795a388e4 100644 --- a/engines/zvision/animation/meta_animation.h +++ b/engines/zvision/animation/meta_animation.h @@ -57,7 +57,7 @@ public: int32 start; int32 stop; int32 loop; - int32 _cur_frm; + int32 _curFrame; int32 _delay; Graphics::Surface *_scaled; }; @@ -77,7 +77,7 @@ private: FileType _fileType; int32 _frmDelay; - const Graphics::Surface *_cur_frame; + const Graphics::Surface *_curFrame; public: diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 0d38e08b88..873cdb0df7 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -170,7 +170,7 @@ void ZVision::processEvents() { _scriptManager->setStateValue(StateKey_RMouse, 1); if (getGameId() == GID_NEMESIS) - _scriptManager->invertory_cycle(); + _scriptManager->inventoryCycle(); break; case Common::EVENT_RBUTTONUP: diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index 57a1983784..5816b3f364 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -43,14 +43,14 @@ enum { menu_MAIN_EXIT = 3 }; -menuHandler::menuHandler(ZVision *engine) { +MenuHandler::MenuHandler(ZVision *engine) { _engine = engine; - menu_bar_flag = 0xFFFF; + menuBarFlag = 0xFFFF; } -menuZgi::menuZgi(ZVision *engine) : - menuHandler(engine) { - menu_mousefocus = -1; +MenuZGI::MenuZGI(ZVision *engine) : + MenuHandler(engine) { + menuMouseFocus = -1; inmenu = false; scrolled[0] = false; scrolled[1] = false; @@ -58,7 +58,7 @@ menuZgi::menuZgi(ZVision *engine) : scrollPos[0] = 0.0; scrollPos[1] = 0.0; scrollPos[2] = 0.0; - mouse_on_item = -1; + mouseOnItem = -1; char buf[24]; for (int i = 1; i < 4; i++) { @@ -77,17 +77,17 @@ menuZgi::menuZgi(ZVision *engine) : for (int i = 0; i < 50; i++) { items[i][0] = NULL; items[i][1] = NULL; - item_id[i] = 0; + itemId[i] = 0; } for (int i = 0; i < 12; i++) { magic[i][0] = NULL; magic[i][1] = NULL; - magic_id[i] = 0; + magicId[i] = 0; } } -menuZgi::~menuZgi() { +MenuZGI::~MenuZGI() { for (int i = 0; i < 3; i++) { menuback[i][0].free(); menuback[i][1].free(); @@ -118,25 +118,25 @@ menuZgi::~menuZgi() { } } -void menuZgi::onMouseUp(const Common::Point &Pos) { +void MenuZGI::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - int32 mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (mouse_item >= 0 && mouse_item < 0xE0) { - _engine->getScriptManager()->invertory_drop(mouse_item); - _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouse_item); + int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouseItem >= 0 && mouseItem < 0xE0) { + _engine->getScriptManager()->inventoryDrop(mouseItem); + _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); redraw = true; } @@ -146,7 +146,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { + if (menuBarFlag & menuBar_Magic) { for (int i = 0; i < 12; i++) { uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); @@ -169,7 +169,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { case menu_MAIN: // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(320 + 135, scrollPos[menu_MAIN], 320 + 135 + 135, @@ -178,7 +178,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(320 , scrollPos[menu_MAIN], 320 + 135, @@ -187,7 +187,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(320 - 135, scrollPos[menu_MAIN], 320, @@ -196,7 +196,7 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(320 - 135 * 2, scrollPos[menu_MAIN], 320 - 135, @@ -208,133 +208,133 @@ void menuZgi::onMouseUp(const Common::Point &Pos) { } } -void menuZgi::onMouseMove(const Common::Point &Pos) { +void MenuZGI::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { if (!inmenu) redraw = true; inmenu = true; - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) { - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; - int last_item = mouse_on_item; + int lastItem = mouseOnItem; - mouse_on_item = -1; + mouseOnItem = -1; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - mouse_on_item = i; + mouseOnItem = i; break; } } - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + last_item)) + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) redraw = true; } break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) { - int last_item = mouse_on_item; - mouse_on_item = -1; + if (menuBarFlag & menuBar_Magic) { + int lastItem = mouseOnItem; + mouseOnItem = -1; for (int i = 0; i < 12; i++) { if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { - mouse_on_item = i; + mouseOnItem = i; break; } } - if (last_item != mouse_on_item) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouse_on_item) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + last_item)) + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) redraw = true; } break; case menu_MAIN: { - int last_item = mouse_on_item; - mouse_on_item = -1; + int lastItem = mouseOnItem; + mouseOnItem = -1; // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(320 + 135, scrollPos[menu_MAIN], 320 + 135 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; + mouseOnItem = menu_MAIN_EXIT; } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(320 , scrollPos[menu_MAIN], 320 + 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; + mouseOnItem = menu_MAIN_PREF; } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(320 - 135, scrollPos[menu_MAIN], 320, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; + mouseOnItem = menu_MAIN_REST; } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(320 - 135 * 2, scrollPos[menu_MAIN], 320 - 135, scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; + mouseOnItem = menu_MAIN_SAVE; } - if (last_item != mouse_on_item) + if (lastItem != mouseOnItem) redraw = true; } break; default: - int cur_menu = menu_mousefocus; + int cur_menu = menuMouseFocus; if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menu_mousefocus = menu_MAIN; + menuMouseFocus = menu_MAIN; scrolled[menu_MAIN] = false; scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); } - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menu_mousefocus = menu_MAGIC; + menuMouseFocus = menu_MAGIC; scrolled[menu_MAGIC] = false; scrollPos[menu_MAGIC] = 28; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); } - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menu_mousefocus = menu_ITEM; + menuMouseFocus = menu_ITEM; scrolled[menu_ITEM] = false; scrollPos[menu_ITEM] = 28 - 600; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); } - if (cur_menu != menu_mousefocus) + if (cur_menu != menuMouseFocus) clean = true; break; @@ -345,18 +345,18 @@ void menuZgi::onMouseMove(const Common::Point &Pos) { inmenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - menu_mousefocus = -1; + menuMouseFocus = -1; } } -void menuZgi::process(uint32 deltatime) { +void MenuZGI::process(uint32 deltatime) { if (clean) { _engine->getRenderManager()->clearMenuSurface(); clean = false; } - switch (menu_mousefocus) { + switch (menuMouseFocus) { case menu_ITEM: - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) if (!scrolled[menu_ITEM]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); @@ -374,31 +374,31 @@ void menuZgi::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); - int item_count = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (item_count == 0) - item_count = 20; - else if (item_count > 50) - item_count = 50; + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; - for (int i = 0; i < item_count; i++) { - int itemspace = (600 - 28) / item_count; + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; bool inrect = false; - if (mouse_on_item == i) + if (mouseOnItem == i) inrect = true; - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { + if (curItemId != 0) { + if (itemId[i] != curItemId) { char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); items[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); items[i][1] = _engine->getRenderManager()->loadImage(buf, false); - item_id[i] = cur_item_id; + itemId[i] = curItemId; } if (inrect) @@ -417,7 +417,7 @@ void menuZgi::process(uint32 deltatime) { delete items[i][1]; items[i][1] = NULL; } - item_id[i] = 0; + itemId[i] = 0; } } @@ -426,7 +426,7 @@ void menuZgi::process(uint32 deltatime) { break; case menu_MAGIC: - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) if (!scrolled[menu_MAGIC]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); @@ -447,25 +447,25 @@ void menuZgi::process(uint32 deltatime) { for (int i = 0; i < 12; i++) { bool inrect = false; - if (mouse_on_item == i) + if (mouseOnItem == i) inrect = true; - uint cur_item_id = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (cur_item_id) { + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (curItemId) { if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - cur_item_id = 0xEE + i; + curItemId = 0xEE + i; else - cur_item_id = 0xE0 + i; + curItemId = 0xE0 + i; } - if (cur_item_id != 0) { - if (item_id[i] != cur_item_id) { + if (curItemId != 0) { + if (itemId[i] != curItemId) { char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", cur_item_id); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); - magic_id[i] = cur_item_id; + magicId[i] = curItemId; } if (inrect) @@ -484,7 +484,7 @@ void menuZgi::process(uint32 deltatime) { delete magic[i][1]; magic[i][1] = NULL; } - magic_id[i] = 0; + magicId[i] = 0; } } redraw = false; @@ -509,26 +509,26 @@ void menuZgi::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - if (menu_bar_flag & menuBar_Exit) { - if (mouse_on_item == menu_MAIN_EXIT) + if (menuBarFlag & menuBar_Exit) { + if (mouseOnItem == menu_MAIN_EXIT) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Settings) { - if (mouse_on_item == menu_MAIN_PREF) + if (menuBarFlag & menuBar_Settings) { + if (mouseOnItem == menu_MAIN_PREF) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Restore) { - if (mouse_on_item == menu_MAIN_REST) + if (menuBarFlag & menuBar_Restore) { + if (mouseOnItem == menu_MAIN_REST) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); } - if (menu_bar_flag & menuBar_Save) { - if (mouse_on_item == menu_MAIN_SAVE) + if (menuBarFlag & menuBar_Save) { + if (mouseOnItem == menu_MAIN_SAVE) _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); else _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); @@ -541,10 +541,10 @@ void menuZgi::process(uint32 deltatime) { if (inmenu) { _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); - if (menu_bar_flag & menuBar_Items) + if (menuBarFlag & menuBar_Items) _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); - if (menu_bar_flag & menuBar_Magic) + if (menuBarFlag & menuBar_Magic) _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); } redraw = false; @@ -554,12 +554,12 @@ void menuZgi::process(uint32 deltatime) { } -menuNem::menuNem(ZVision *engine) : - menuHandler(engine) { +MenuNemesis::MenuNemesis(ZVision *engine) : + MenuHandler(engine) { inmenu = false; scrolled = false; scrollPos = 0.0; - mouse_on_item = -1; + mouseOnItem = -1; char buf[24]; for (int i = 0; i < 4; i++) @@ -573,7 +573,7 @@ menuNem::menuNem(ZVision *engine) : frm = 0; } -menuNem::~menuNem() { +MenuNemesis::~MenuNemesis() { for (int i = 0; i < 4; i++) for (int j = 0; j < 6; j++) but[i][j].free(); @@ -583,10 +583,10 @@ menuNem::~menuNem() { static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; -void menuNem::onMouseUp(const Common::Point &Pos) { +void MenuNemesis::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], @@ -597,7 +597,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], @@ -608,7 +608,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], @@ -619,7 +619,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], @@ -631,7 +631,7 @@ void menuNem::onMouseUp(const Common::Point &Pos) { } } -void menuNem::onMouseMove(const Common::Point &Pos) { +void MenuNemesis::onMouseMove(const Common::Point &Pos) { if (Pos.y < 40) { inmenu = true; @@ -639,46 +639,46 @@ void menuNem::onMouseMove(const Common::Point &Pos) { if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - int last_item = mouse_on_item; - mouse_on_item = -1; + int lastItem = mouseOnItem; + mouseOnItem = -1; // Exit - if (menu_bar_flag & menuBar_Exit) + if (menuBarFlag & menuBar_Exit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_EXIT; + mouseOnItem = menu_MAIN_EXIT; } // Settings - if (menu_bar_flag & menuBar_Settings) + if (menuBarFlag & menuBar_Settings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_PREF; + mouseOnItem = menu_MAIN_PREF; } // Load - if (menu_bar_flag & menuBar_Restore) + if (menuBarFlag & menuBar_Restore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_REST; + mouseOnItem = menu_MAIN_REST; } // Save - if (menu_bar_flag & menuBar_Save) + if (menuBarFlag & menuBar_Save) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], scrollPos + 32).contains(Pos)) { - mouse_on_item = menu_MAIN_SAVE; + mouseOnItem = menu_MAIN_SAVE; } - if (last_item != mouse_on_item) { + if (lastItem != mouseOnItem) { redraw = true; frm = 0; delay = 200; @@ -687,11 +687,11 @@ void menuNem::onMouseMove(const Common::Point &Pos) { inmenu = false; if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - mouse_on_item = -1; + mouseOnItem = -1; } } -void menuNem::process(uint32 deltatime) { +void MenuNemesis::process(uint32 deltatime) { if (inmenu) { if (!scrolled) { float scrl = 32.0 * 2.0 * (deltatime / 1000.0); @@ -708,7 +708,7 @@ void menuNem::process(uint32 deltatime) { scrollPos = 0; } - if (mouse_on_item != -1) { + if (mouseOnItem != -1) { delay -= deltatime; if (delay <= 0 && frm < 4) { delay = 200; @@ -720,20 +720,20 @@ void menuNem::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - if (menu_bar_flag & menuBar_Exit) - if (mouse_on_item == menu_MAIN_EXIT) + if (menuBarFlag & menuBar_Exit) + if (mouseOnItem == menu_MAIN_EXIT) _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - if (menu_bar_flag & menuBar_Settings) - if (mouse_on_item == menu_MAIN_PREF) + if (menuBarFlag & menuBar_Settings) + if (mouseOnItem == menu_MAIN_PREF) _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - if (menu_bar_flag & menuBar_Restore) - if (mouse_on_item == menu_MAIN_REST) + if (menuBarFlag & menuBar_Restore) + if (mouseOnItem == menu_MAIN_REST) _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - if (menu_bar_flag & menuBar_Save) - if (mouse_on_item == menu_MAIN_SAVE) + if (menuBarFlag & menuBar_Save) + if (mouseOnItem == menu_MAIN_SAVE) _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); redraw = false; diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index c2ea822dd9..62683de912 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -40,30 +40,30 @@ enum menuBar { menuBar_Magic = 0x200 }; -class menuHandler { +class MenuHandler { public: - menuHandler(ZVision *engine); - virtual ~menuHandler() {}; + MenuHandler(ZVision *engine); + virtual ~MenuHandler() {}; virtual void onMouseMove(const Common::Point &Pos) {}; virtual void onMouseDown(const Common::Point &Pos) {}; virtual void onMouseUp(const Common::Point &Pos) {}; virtual void process(uint32 deltaTimeInMillis) {}; void setEnable(uint16 flags) { - menu_bar_flag = flags; + menuBarFlag = flags; } uint16 getEnable() { - return menu_bar_flag; + return menuBarFlag; } protected: - uint16 menu_bar_flag; + uint16 menuBarFlag; ZVision *_engine; }; -class menuZgi: public menuHandler { +class MenuZGI: public MenuHandler { public: - menuZgi(ZVision *engine); - ~menuZgi(); + MenuZGI(ZVision *engine); + ~MenuZGI(); void onMouseMove(const Common::Point &Pos); void onMouseUp(const Common::Point &Pos); void process(uint32 deltaTimeInMillis); @@ -73,15 +73,15 @@ private: Graphics::Surface *items[50][2]; - uint item_id[50]; + uint itemId[50]; Graphics::Surface *magic[12][2]; - uint magic_id[12]; + uint magicId[12]; - int menu_mousefocus; + int menuMouseFocus; bool inmenu; - int mouse_on_item; + int mouseOnItem; bool scrolled[3]; float scrollPos[3]; @@ -97,10 +97,10 @@ private: }; -class menuNem: public menuHandler { +class MenuNemesis: public MenuHandler { public: - menuNem(ZVision *engine); - ~menuNem(); + MenuNemesis(ZVision *engine); + ~MenuNemesis(); void onMouseMove(const Common::Point &Pos); void onMouseUp(const Common::Point &Pos); void process(uint32 deltaTimeInMillis); @@ -110,7 +110,7 @@ private: bool inmenu; - int mouse_on_item; + int mouseOnItem; bool scrolled; float scrollPos; diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp index 5cc8cd0402..736be1311d 100644 --- a/engines/zvision/core/midi.cpp +++ b/engines/zvision/core/midi.cpp @@ -26,25 +26,25 @@ namespace ZVision { -midiManager::midiManager() { +MidiManager::MidiManager() { MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); _driver = MidiDriver::createMidi(dev); _driver->open(); } -midiManager::~midiManager() { +MidiManager::~MidiManager() { stop(); _driver->close(); delete _driver; } -void midiManager::stop() { +void MidiManager::stop() { for (int8 i = 0; i < 16; i++) if (_playChannels[i].playing) noteOff(i); } -void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { +void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) { assert(channel <= 15); _playChannels[channel].playing = true; @@ -52,7 +52,7 @@ void midiManager::noteOn(int8 channel, int8 note, int8 velocity) { _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); } -void midiManager::noteOff(int8 channel) { +void MidiManager::noteOff(int8 channel) { assert(channel <= 15); if (_playChannels[channel].playing) { @@ -61,26 +61,26 @@ void midiManager::noteOff(int8 channel) { } } -int8 midiManager::getFreeChannel() { +int8 MidiManager::getFreeChannel() { for (int8 i = 0; i < 16; i++) if (!_playChannels[i].playing) return i; return -1; } -void midiManager::setPan(int8 channel, int8 pan) { +void MidiManager::setPan(int8 channel, int8 pan) { assert(channel <= 15); _driver->send(channel | (pan << 16) | 0xAB0); } -void midiManager::setVolume(int8 channel, int8 volume) { +void MidiManager::setVolume(int8 channel, int8 volume) { assert(channel <= 15); _driver->send(channel | (volume << 16) | 0x7B0); } -void midiManager::setProgram(int8 channel, int8 prog) { +void MidiManager::setProgram(int8 channel, int8 prog) { assert(channel <= 15); _driver->send(channel | (prog << 8) | 0xC0); diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h index 79f8ea3d04..a3bac19636 100644 --- a/engines/zvision/core/midi.h +++ b/engines/zvision/core/midi.h @@ -27,10 +27,10 @@ namespace ZVision { -class midiManager { +class MidiManager { public: - midiManager(); - ~midiManager(); + MidiManager(); + ~MidiManager(); void stop(); void noteOn(int8 channel, int8 noteNumber, int8 velocity); diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 2797b940a0..9b36824c3b 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -165,6 +165,7 @@ Common::Error SaveManager::loadGame(const Common::String &saveName) { bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { uint32 tag = in->readUint32BE(); + // Check if it's original savegame than fill header structure if (tag == MKTAG('Z', 'N', 'S', 'G')) { header.saveYear = 0; header.saveMonth = 0; @@ -216,7 +217,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); if (saveFile == NULL) { - // Try to load standart save file + // Try to load standard save file Common::String filename; if (_engine->getGameId() == GID_GRANDINQUISITOR) filename = Common::String::format("inqsav%u.sav", slot); diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index fe99772b9b..8350189566 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + #include "common/debug.h" #include "zvision/core/search_manager.h" @@ -29,18 +30,18 @@ namespace ZVision { -sManager::sManager(const Common::String &root_path, int depth) { - _root = root_path; +SearchManager::SearchManager(const Common::String &rootPath, int depth) { + _root = rootPath; if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') _root.deleteLastChar(); - Common::FSNode fs_node(_root); + Common::FSNode fsNode(_root); - list_dir_recursive(dir_list, fs_node, depth); + listDirRecursive(dirList, fsNode, depth); - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end();) + for (Common::List::iterator it = dirList.begin(); it != dirList.end();) if (it->size() == _root.size()) - it = dir_list.erase(it); + it = dirList.erase(it); else if (it->size() > _root.size()) { *it = Common::String(it->c_str() + _root.size() + 1); it++; @@ -48,7 +49,7 @@ sManager::sManager(const Common::String &root_path, int depth) { it++; } -sManager::~sManager() { +SearchManager::~SearchManager() { Common::List::iterator it = archList.begin(); while (it != archList.end()) { delete *it; @@ -58,20 +59,20 @@ sManager::~sManager() { archList.clear(); } -void sManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lw_name = dst; - lw_name.toLowercase(); +void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lowerCaseName = dst; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator it = files.find(lw_name); + SearchManager::MatchList::iterator it = files.find(lowerCaseName); if (it != files.end()) { - lw_name = src; - lw_name.toLowercase(); - files[lw_name] = it->_value; + lowerCaseName = src; + lowerCaseName.toLowercase(); + files[lowerCaseName] = it->_value; } } -void sManager::addFile(const Common::String &name, Common::Archive *arch) { +void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { bool addArch = true; Common::List::iterator it = archList.begin(); while (it != archList.end()) { @@ -84,17 +85,17 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) { if (addArch) archList.push_back(arch); - Common::String lw_name = name; - lw_name.toLowercase(); + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::Node nod; - nod.name = lw_name; + SearchManager::Node nod; + nod.name = lowerCaseName; nod.arch = arch; - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit == files.end()) { - files[lw_name] = nod; + files[lowerCaseName] = nod; } else { Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); if (stream) { @@ -102,16 +103,16 @@ void sManager::addFile(const Common::String &name, Common::Archive *arch) { fit->_value.arch = arch; delete stream; } else { - files[lw_name] = nod; + files[lowerCaseName] = nod; } } } -Common::File *sManager::openFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +Common::File *SearchManager::openFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) { Common::File *tmp = new Common::File(); @@ -121,29 +122,29 @@ Common::File *sManager::openFile(const Common::String &name) { return NULL; } -bool sManager::openFile(Common::File &file, const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +bool SearchManager::openFile(Common::File &file, const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) return file.open(fit->_value.name, *fit->_value.arch); return false; } -bool sManager::hasFile(const Common::String &name) { - Common::String lw_name = name; - lw_name.toLowercase(); +bool SearchManager::hasFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); - sManager::MatchList::iterator fit = files.find(lw_name); + SearchManager::MatchList::iterator fit = files.find(lowerCaseName); if (fit != files.end()) return true; return false; } -void sManager::loadZix(const Common::String &name) { +void SearchManager::loadZix(const Common::String &name) { Common::File file; file.open(name); @@ -168,13 +169,13 @@ void sManager::loadZix(const Common::String &name) { else if (line.matchString("DIR:*", true)) { Common::String path(line.c_str() + 5); Common::Archive *arc; - char n_path[128]; - strcpy(n_path, path.c_str()); + char tempPath[128]; + strcpy(tempPath, path.c_str()); for (uint i = 0; i < path.size(); i++) - if (n_path[i] == '\\') - n_path[i] = '/'; + if (tempPath[i] == '\\') + tempPath[i] = '/'; - path = Common::String(n_path); + path = Common::String(tempPath); if (path.size() && path[0] == '.') path.deleteChar(0); if (path.size() && path[0] == '/') @@ -187,7 +188,7 @@ void sManager::loadZix(const Common::String &name) { if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') path.deleteLastChar(); if (path.size()) - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) if (path.equalsIgnoreCase(*it)) { path = *it; break; @@ -218,9 +219,9 @@ void sManager::loadZix(const Common::String &name) { } } -void sManager::addDir(const Common::String &name) { +void SearchManager::addDir(const Common::String &name) { Common::String path; - for (Common::List::iterator it = dir_list.begin(); it != dir_list.end(); ++it) + for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) if (name.equalsIgnoreCase(*it)) { path = *it; break; @@ -246,8 +247,8 @@ void sManager::addDir(const Common::String &name) { zfs->listMembers(zfslist); for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { - Common::String z_name = (*ziter)->getName(); - addFile(z_name, zfs); + Common::String zfsFileName = (*ziter)->getName(); + addFile(zfsFileName, zfs); } } @@ -260,15 +261,15 @@ void sManager::addDir(const Common::String &name) { } } -void sManager::list_dir_recursive(Common::List &_list, const Common::FSNode &fs_node, int depth) { - Common::FSList fs_list; - fs_node.getChildren(fs_list); +void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { + Common::FSList fsList; + fsNode.getChildren(fsList); - _list.push_back(fs_node.getPath()); + _list.push_back(fsNode.getPath()); if (depth > 1) - for (Common::FSList::const_iterator it = fs_list.begin(); it != fs_list.end(); ++it) - list_dir_recursive(_list, *it, depth - 1); + for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) + listDirRecursive(_list, *it, depth - 1); } } // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h index c768cb8b00..180102eac6 100644 --- a/engines/zvision/core/search_manager.h +++ b/engines/zvision/core/search_manager.h @@ -1,5 +1,27 @@ -#ifndef SEARCH_MANAGER_H_INCLUDED -#define SEARCH_MANAGER_H_INCLUDED +/* 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 ZVISION_SEARCH_MANAGER_H +#define ZVISION_SEARCH_MANAGER_H #include "common/str.h" #include "common/hash-str.h" @@ -10,10 +32,10 @@ namespace ZVision { -class sManager { +class SearchManager { public: - sManager(const Common::String &root_path, int depth); - ~sManager(); + SearchManager(const Common::String &rootPath, int depth); + ~SearchManager(); void addFile(const Common::String &name, Common::Archive *arch); void addDir(const Common::String &name); @@ -27,14 +49,14 @@ public: private: - void list_dir_recursive(Common::List &dir_list, const Common::FSNode &fs_node, int depth); + void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); struct Node { Common::String name; Common::Archive *arch; }; - Common::List dir_list; + Common::List dirList; typedef Common::HashMap MatchList; @@ -48,4 +70,4 @@ private: } -#endif // SEARCH_MANAGER_H_INCLUDED +#endif // ZVISION_SEARCH_MANAGER_H diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp index 22aa16f52f..638a8ed233 100644 --- a/engines/zvision/fonts/truetype_font.cpp +++ b/engines/zvision/fonts/truetype_font.cpp @@ -116,24 +116,24 @@ Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, u return surface; } -sTTFont::sTTFont(ZVision *engine) { +StyledTTFont::StyledTTFont(ZVision *engine) { _engine = engine; _style = 0; _font = NULL; _lineHeight = 0; } -sTTFont::~sTTFont() { +StyledTTFont::~StyledTTFont() { if (_font) delete _font; } -bool sTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { _style = style; return loadFont(fontName, point); } -bool sTTFont::loadFont(const Common::String &fontName, int32 point) { +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { Common::String newFontName; if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) @@ -205,7 +205,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { } } } - if (!themeFile) { // Fallback 2.5: Search for ScummModern.zip in SearchMan. + if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan. themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); } if (themeFile) { @@ -243,7 +243,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) { return false; } -void sTTFont::setStyle(uint newStyle) { +void StyledTTFont::setStyle(uint newStyle) { if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { _style = newStyle; loadFont(_fntName, _lineHeight); @@ -252,31 +252,31 @@ void sTTFont::setStyle(uint newStyle) { } } -int sTTFont::getFontHeight() { +int StyledTTFont::getFontHeight() { if (_font) return _font->getFontHeight(); return 0; } -int sTTFont::getMaxCharWidth() { +int StyledTTFont::getMaxCharWidth() { if (_font) return _font->getMaxCharWidth(); return 0; } -int sTTFont::getCharWidth(byte chr) { +int StyledTTFont::getCharWidth(byte chr) { if (_font) return _font->getCharWidth(chr); return 0; } -int sTTFont::getKerningOffset(byte left, byte right) { +int StyledTTFont::getKerningOffset(byte left, byte right) { if (_font) return _font->getKerningOffset(left, right); return 0; } -void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { +void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { if (_font) { _font->drawChar(dst, chr, x, y, color); if (_style & STTF_UNDERLINE) { @@ -292,7 +292,7 @@ void sTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 co } } -void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { +void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { if (_font) { _font->drawString(dst, str, x, y, w, color, align); if (_style & STTF_UNDERLINE) { @@ -324,13 +324,13 @@ void sTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int } } -int sTTFont::getStringWidth(const Common::String &str) { +int StyledTTFont::getStringWidth(const Common::String &str) { if (_font) return _font->getStringWidth(str); return 0; } -Graphics::Surface *sTTFont::renderSolidText(const Common::String &str, uint32 color) { +Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { Graphics::Surface *tmp = new Graphics::Surface; if (_font) { int16 w = _font->getStringWidth(str); diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h index 0fed3ccbc4..771c02a6dc 100644 --- a/engines/zvision/fonts/truetype_font.h +++ b/engines/zvision/fonts/truetype_font.h @@ -77,10 +77,10 @@ public: }; // Styled TTF -class sTTFont { +class StyledTTFont { public: - sTTFont(ZVision *engine); - ~sTTFont(); + StyledTTFont(ZVision *engine); + ~StyledTTFont(); enum { STTF_BOLD = 1, diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h index 62dd1f9473..45d6f9596d 100644 --- a/engines/zvision/graphics/effects/fog.h +++ b/engines/zvision/graphics/effects/fog.h @@ -20,8 +20,8 @@ * */ -#ifndef FOGFX_H_INCLUDED -#define FOGFX_H_INCLUDED +#ifndef ZVISION_FOG_H +#define ZVISION_FOG_H #include "zvision/graphics/effect.h" @@ -49,4 +49,4 @@ private: }; } // End of namespace ZVision -#endif // FOGFX_H_INCLUDED +#endif // ZVISION_FOG_H diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp index 88239f3cad..9f2fbb285c 100644 --- a/engines/zvision/graphics/effects/wave.cpp +++ b/engines/zvision/graphics/effects/wave.cpp @@ -30,32 +30,32 @@ namespace ZVision { -WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd): +WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd): Effect(engine, key, region, ported) { _frame = 0; - _frame_cnt = frames; + _frameCount = frames; - _ampls.resize(_frame_cnt); - _hw = _region.width() / 2; - _hh = _region.height() / 2; + _ampls.resize(_frameCount); + _halfWidth = _region.width() / 2; + _halfHeight = _region.height() / 2; - int32 frmsize = _hw * _hh; + int32 frmsize = _halfWidth * _halfHeight; float phase = 0; - int16 w_4 = _hw / 2; - int16 h_4 = _hh / 2; + int16 quarterWidth = _halfWidth / 2; + int16 quarterHeight = _halfHeight / 2; - for (int16 i = 0; i < _frame_cnt; i++) { + for (int16 i = 0; i < _frameCount; i++) { _ampls[i].resize(frmsize); - for (int16 y = 0; y < _hh; y++) - for (int16 x = 0; x < _hw; x++) { - int16 dx = (x - w_4); - int16 dy = (y - h_4); + for (int16 y = 0; y < _halfHeight; y++) + for (int16 x = 0; x < _halfWidth; x++) { + int16 dx = (x - quarterWidth); + int16 dy = (y - quarterHeight); - _ampls[i][x + y * _hw] = ampl * sin(sqrt(dx * dx / (float)s_x + dy * dy / (float)s_y) / (-waveln * 3.1415926) + phase); + _ampls[i][x + y * _halfWidth] = ampl * sin(sqrt(dx * dx / (float)centerX + dy * dy / (float)centerY) / (-waveln * 3.1415926) + phase); } phase += spd; } @@ -68,66 +68,66 @@ WaveFx::~WaveFx() { } const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) { - for (int16 y = 0; y < _hh; y++) { + for (int16 y = 0; y < _halfHeight; y++) { uint16 *abc = (uint16 *)_surface.getBasePtr(0, y); - uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _hh + y); - uint16 *abc3 = (uint16 *)_surface.getBasePtr(_hw, y); - uint16 *abc4 = (uint16 *)_surface.getBasePtr(_hw, _hh + y); - - for (int16 x = 0; x < _hw; x++) { - int8 amnt = _ampls[_frame][x + _hw * y]; - - int16 n_x = x + amnt; - int16 n_y = y + amnt; - - if (n_x < 0) - n_x = 0; - if (n_x >= _region.width()) - n_x = _region.width() - 1; - if (n_y < 0) - n_y = 0; - if (n_y >= _region.height()) - n_y = _region.height() - 1; - *abc = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); - - n_x = x + amnt + _hw; - n_y = y + amnt; - - if (n_x < 0) - n_x = 0; - if (n_x >= _region.width()) - n_x = _region.width() - 1; - if (n_y < 0) - n_y = 0; - if (n_y >= _region.height()) - n_y = _region.height() - 1; - *abc3 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); - - n_x = x + amnt; - n_y = y + amnt + _hh; - - if (n_x < 0) - n_x = 0; - if (n_x >= _region.width()) - n_x = _region.width() - 1; - if (n_y < 0) - n_y = 0; - if (n_y >= _region.height()) - n_y = _region.height() - 1; - *abc2 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); - - n_x = x + amnt + _hw; - n_y = y + amnt + _hh; - - if (n_x < 0) - n_x = 0; - if (n_x >= _region.width()) - n_x = _region.width() - 1; - if (n_y < 0) - n_y = 0; - if (n_y >= _region.height()) - n_y = _region.height() - 1; - *abc4 = *(const uint16 *)srcSubRect.getBasePtr(n_x, n_y); + uint16 *abc2 = (uint16 *)_surface.getBasePtr(0, _halfHeight + y); + uint16 *abc3 = (uint16 *)_surface.getBasePtr(_halfWidth, y); + uint16 *abc4 = (uint16 *)_surface.getBasePtr(_halfWidth, _halfHeight + y); + + for (int16 x = 0; x < _halfWidth; x++) { + int8 amnt = _ampls[_frame][x + _halfWidth * y]; + + int16 nX = x + amnt; + int16 nY = y + amnt; + + if (nX < 0) + nX = 0; + if (nX >= _region.width()) + nX = _region.width() - 1; + if (nY < 0) + nY = 0; + if (nY >= _region.height()) + nY = _region.height() - 1; + *abc = *(const uint16 *)srcSubRect.getBasePtr(nX, nY); + + nX = x + amnt + _halfWidth; + nY = y + amnt; + + if (nX < 0) + nX = 0; + if (nX >= _region.width()) + nX = _region.width() - 1; + if (nY < 0) + nY = 0; + if (nY >= _region.height()) + nY = _region.height() - 1; + *abc3 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY); + + nX = x + amnt; + nY = y + amnt + _halfHeight; + + if (nX < 0) + nX = 0; + if (nX >= _region.width()) + nX = _region.width() - 1; + if (nY < 0) + nY = 0; + if (nY >= _region.height()) + nY = _region.height() - 1; + *abc2 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY); + + nX = x + amnt + _halfWidth; + nY = y + amnt + _halfHeight; + + if (nX < 0) + nX = 0; + if (nX >= _region.width()) + nX = _region.width() - 1; + if (nY < 0) + nY = 0; + if (nY >= _region.height()) + nY = _region.height() - 1; + *abc4 = *(const uint16 *)srcSubRect.getBasePtr(nX, nY); abc++; abc2++; @@ -140,7 +140,7 @@ const Graphics::Surface *WaveFx::draw(const Graphics::Surface &srcSubRect) { } void WaveFx::update() { - _frame = (_frame + 1) % _frame_cnt; + _frame = (_frame + 1) % _frameCount; } } // End of namespace ZVision diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h index 0046dfceec..2e813ed5b6 100644 --- a/engines/zvision/graphics/effects/wave.h +++ b/engines/zvision/graphics/effects/wave.h @@ -33,7 +33,7 @@ class ZVision; class WaveFx : public Effect { public: - WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 s_x, int16 s_y, float ampl, float waveln, float spd); + WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd); ~WaveFx(); const Graphics::Surface *draw(const Graphics::Surface &srcSubRect); @@ -42,8 +42,8 @@ public: private: int16 _frame; - int16 _frame_cnt; - int16 _hw, _hh; + int16 _frameCount; + int16 _halfWidth, _halfHeight; Common::Array< Common::Array< int8 > > _ampls; }; } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 3e146939e3..05f8dec937 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -78,6 +78,7 @@ RenderManager::~RenderManager() { void RenderManager::renderBackbufferToScreen() { Graphics::Surface *out = &_outWnd; Graphics::Surface *in = &_wrkWnd; + Common::Rect outWndDirtyRect; if (!_effects.empty()) { bool copied = false; @@ -114,22 +115,20 @@ void RenderManager::renderBackbufferToScreen() { if (!_wrkWndDirtyRect.isEmpty()) { _renderTable.mutateImage(&_outWnd, in); out = &_outWnd; - _outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight); + outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight); } } else { out = in; - _outWndDirtyRect = _wrkWndDirtyRect; + outWndDirtyRect = _wrkWndDirtyRect; } - if (!_outWndDirtyRect.isEmpty()) { - _system->copyRectToScreen(out->getBasePtr(_outWndDirtyRect.left, _outWndDirtyRect.top), out->pitch, - _outWndDirtyRect.left + _workingWindow.left, - _outWndDirtyRect.top + _workingWindow.top, - _outWndDirtyRect.width(), - _outWndDirtyRect.height()); - - _outWndDirtyRect = Common::Rect(); + if (!outWndDirtyRect.isEmpty()) { + _system->copyRectToScreen(out->getBasePtr(outWndDirtyRect.left, outWndDirtyRect.top), out->pitch, + outWndDirtyRect.left + _workingWindow.left, + outWndDirtyRect.top + _workingWindow.top, + outWndDirtyRect.width(), + outWndDirtyRect.height()); } } @@ -472,7 +471,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com return; // Copy srcRect from src surface to dst surface - const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); int xx = _x; int yy = _y; @@ -485,15 +484,15 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (_x >= dst.w || _y >= dst.h) return; - byte *dst_buf = (byte *)dst.getBasePtr(xx, yy); + byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy); int32 w = srcRect.width(); int32 h = srcRect.height(); for (int32 y = 0; y < h; y++) { - memcpy(dst_buf, src_buf, w * src.format.bytesPerPixel); - src_buf += src.pitch; - dst_buf += dst.pitch; + memcpy(dstBuffer, srcBuffer, w * src.format.bytesPerPixel); + srcBuffer += src.pitch; + dstBuffer += dst.pitch; } } @@ -517,7 +516,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1); // Copy srcRect from src surface to dst surface - const byte *src_buf = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); int xx = _x; int yy = _y; @@ -530,7 +529,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (_x >= dst.w || _y >= dst.h) return; - byte *dst_buf = (byte *)dst.getBasePtr(xx, yy); + byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy); int32 w = srcRect.width(); int32 h = srcRect.height(); @@ -538,37 +537,37 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com for (int32 y = 0; y < h; y++) { switch (src.format.bytesPerPixel) { case 1: { - const uint *src_tmp = (const uint *)src_buf; - uint *dst_tmp = (uint *)dst_buf; + const uint *srcTemp = (const uint *)srcBuffer; + uint *dstTemp = (uint *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; + if (*srcTemp != _keycolor) + *dstTemp = *srcTemp; + srcTemp++; + dstTemp++; } } break; case 2: { - const uint16 *src_tmp = (const uint16 *)src_buf; - uint16 *dst_tmp = (uint16 *)dst_buf; + const uint16 *srcTemp = (const uint16 *)srcBuffer; + uint16 *dstTemp = (uint16 *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; + if (*srcTemp != _keycolor) + *dstTemp = *srcTemp; + srcTemp++; + dstTemp++; } } break; case 4: { - const uint32 *src_tmp = (const uint32 *)src_buf; - uint32 *dst_tmp = (uint32 *)dst_buf; + const uint32 *srcTemp = (const uint32 *)srcBuffer; + uint32 *dstTemp = (uint32 *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*src_tmp != _keycolor) - *dst_tmp = *src_tmp; - src_tmp++; - dst_tmp++; + if (*srcTemp != _keycolor) + *dstTemp = *srcTemp; + srcTemp++; + dstTemp++; } } break; @@ -576,8 +575,8 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com default: break; } - src_buf += src.pitch; - dst_buf += dst.pitch; + srcBuffer += src.pitch; + dstBuffer += dst.pitch; } } @@ -796,7 +795,7 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { sub.redraw = false; sub.timer = -1; sub.todelete = false; - sub._r = area; + sub.r = area; _subsList[_subid] = sub; @@ -810,8 +809,8 @@ uint16 RenderManager::createSubArea() { sub.redraw = false; sub.timer = -1; sub.todelete = false; - sub._r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom); - sub._r.translate(-_workingWindow.left, -_workingWindow.top); + sub.r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom); + sub.r.translate(-_workingWindow.left, -_workingWindow.top); _subsList[_subid] = sub; @@ -831,7 +830,7 @@ void RenderManager::deleteSubArea(uint16 id, int16 delay) { void RenderManager::updateSubArea(uint16 id, const Common::String &txt) { if (_subsList.contains(id)) { oneSub *sub = &_subsList[id]; - sub->_txt = txt; + sub->txt = txt; sub->redraw = true; } } @@ -857,11 +856,11 @@ void RenderManager::processSubs(uint16 deltatime) { for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { oneSub *sub = &it->_value; - if (sub->_txt.size()) { + if (sub->txt.size()) { Graphics::Surface *rndr = new Graphics::Surface(); - rndr->create(sub->_r.width(), sub->_r.height(), _pixelFormat); - _engine->getTextRenderer()->drawTxtInOneLine(sub->_txt, *rndr); - blitSurfaceToSurface(*rndr, _subWnd, sub->_r.left - _subWndRect.left + _workingWindow.left, sub->_r.top - _subWndRect.top + _workingWindow.top); + rndr->create(sub->r.width(), sub->r.height(), _pixelFormat); + _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); + blitSurfaceToSurface(*rndr, _subWnd, sub->r.left - _subWndRect.left + _workingWindow.left, sub->r.top - _subWndRect.top + _workingWindow.top); rndr->free(); delete rndr; } diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index d34ecf8ce0..7723c3d0f3 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -54,21 +54,13 @@ public: private: struct oneSub { - Common::Rect _r; - Common::String _txt; + Common::Rect r; + Common::String txt; int16 timer; bool todelete; bool redraw; }; -// struct AlphaDataEntry { -// Graphics::Surface *data; -// uint16 alphaColor; -// uint16 destX; -// uint16 destY; -// uint16 width; -// uint16 height; -// }; -// + typedef Common::HashMap subMap; typedef Common::List effectsList; @@ -82,37 +74,25 @@ private: Common::Rect _wrkWndDirtyRect; + // A buffer for mutate image by tilt or panorama renderers Graphics::Surface _outWnd; - Common::Rect _outWndDirtyRect; - Common::Rect _bkgDirtyRect; + // A buffer for subtitles Graphics::Surface _subWnd; Common::Rect _subWndDirtyRect; + // A buffer for menu drawing Graphics::Surface _menuWnd; Common::Rect _menuWndDirtyRect; + // A buffer used for apply graphics effects Graphics::Surface _effectWnd; - // A buffer the exact same size as the workingWindow - // This buffer stores everything un-warped, then does a warp at the end of the frame - //Graphics::Surface _workingWindowBuffer; - // A buffer representing the entire screen. Any graphical updates are first done with this buffer - // before actually being blitted to the screen - //Graphics::Surface _backBuffer; - // A list of Alpha Entries that need to be blitted to the backbuffer - //AlphaEntryMap _alphaDataEntries; - - // A rectangle representing the portion of the working window where the pixels have been changed since last frame - //Common::Rect _workingWindowDirtyRect; - // A rectangle representing the portion of the backbuffer where the pixels have been changed since last frame - //Common::Rect _backBufferDirtyRect; - /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */ const int _wrkWidth; /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */ @@ -129,13 +109,16 @@ private: */ const Common::Rect _workingWindow; + // Recatangle for subtitles area Common::Rect _subWndRect; + // Recatangle for menu area Common::Rect _menuWndRect; /** Used to warp the background image */ RenderTable _renderTable; + // A buffer for background image Graphics::Surface _curBkg; /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */ int16 _bkgOff; @@ -144,18 +127,13 @@ private: /** The height of the current background image */ uint16 _bkgHeight; + // Internal subtitles counter uint16 _subid; + // Subtitle list subMap _subsList; - /** - * The "velocity" at which the background image is panning. We actually store the inverse of velocity (ms/pixel instead of pixels/ms) - * because it allows you to accumulate whole pixels 'steps' instead of rounding pixels every frame - */ - //int _backgroundInverseVelocity; - /** Holds any 'leftover' milliseconds between frames */ - //uint _accumulatedVelocityMilliseconds; - + // Visual effects list effectsList _effects; public: @@ -178,13 +156,22 @@ public: /** * Blits the image or a portion of the image to the background. * - * @param fileName Name of the image file - * @param destinationX X position where the image should be put. Coords are in working window space, not screen space! - * @param destinationY Y position where the image should be put. Coords are in working window space, not screen space! + * @param fileName Name of the image file + * @param destX X position where the image should be put. Coords are in working window space, not screen space! + * @param destY Y position where the image should be put. Coords are in working window space, not screen space! * @param colorkey Transparent color */ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, uint32 colorkey); + /** + * Blits the image or a portion of the image to the background. + * + * @param fileName Name of the image file + * @param destX X position where the image should be put. Coords are in working window space, not screen space! + * @param destY Y position where the image should be put. Coords are in working window space, not screen space! + * @param keyX X position of transparent color + * @param keyY Y position of transparent color + */ void renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY, int16 keyX, int16 keyY); /** @@ -215,7 +202,10 @@ public: */ const Common::Point screenSpaceToImageSpace(const Common::Point &point); + // Return pointer of RenderTable object RenderTable *getRenderTable(); + + // Return current background offset uint32 getCurrentBackgroundOffset(); /** @@ -229,39 +219,64 @@ public: */ static Graphics::Surface *tranposeSurface(const Graphics::Surface *surface); + // Scale buffer (nearest) void scaleBuffer(const void *src, void *dst, uint32 srcWidth, uint32 srcHeight, byte bytesPerPixel, uint32 dstWidth, uint32 dstHeight); - + // Blitting surface-to-surface methods void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y); void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey); void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y); void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); + + // Blitting surface-to-background methods void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y); void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey); + + // Blitting surface-to-background methods with scale void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect); void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey); + + // Blitting surface-to-menu methods void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y); void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); + // Subtitles methods + + // Create subtitle area and return ID uint16 createSubArea(const Common::Rect &area); uint16 createSubArea(); + + // Delete subtitle by ID void deleteSubArea(uint16 id); void deleteSubArea(uint16 id, int16 delay); + + // Update subtitle area void updateSubArea(uint16 id, const Common::String &txt); + + // Processing subtitles void processSubs(uint16 deltatime); + + // Return background size Common::Point getBkgSize(); + // Return portion of background as new surface Graphics::Surface *getBkgRect(Common::Rect &rect); + + // Load image into new surface Graphics::Surface *loadImage(const char *file); Graphics::Surface *loadImage(Common::String &file); Graphics::Surface *loadImage(const char *file, bool transposed); Graphics::Surface *loadImage(Common::String &file, bool transposed); + // Clear whole/area of menu surface void clearMenuSurface(); void clearMenuSurface(const Common::Rect &r); + + // Copy menu buffer to screen void renderMenuToScreen(); + // Copy needed portion of background surface to workingWindow surface void prepareBkg(); /** @@ -275,17 +290,44 @@ public: * @param destination A reference to the Surface to store the pixel data in */ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination); + + /** + * Reads an image file pixel data into a Surface buffer. In the process + * it converts the pixel data from RGB 555 to RGB 565. Also, if the image + * is transposed, it will un-transpose the pixel data. The function will + * call destination::create() if the dimensions of destination do not match + * up with the dimensions of the image. + * + * @param fileName The name of a .tga file + * @param destination A reference to the Surface to store the pixel data in + * @param transposed Transpose flag + */ void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed); + // Add visual effect to effects list void addEffect(Effect *_effect); + + // Delete effect(s) by ID (ID equal to slot of action:region that create this effect) void deleteEffect(uint32 ID); + + // Create "mask" for effects - (color +/- depth) will be selected as not transparent. Like color selection + // xy - base color + // depth - +/- of base color + // rect - rectangle where select pixels + // minD - if not NULL will recieve real bottom border of depth + // maxD - if not NULL will recieve real top border of depth EffectMap *makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *minD, int8 *maxD); + + // Create "mask" for effects by simple transparent color EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp); + // Return background rectangle in screen coordinates Common::Rect bkgRectToScreen(const Common::Rect &src); + // Mark whole background surface as dirty void markDirty(); + // Fille background surface by color void bkgFill(uint8 r, uint8 g, uint8 b); }; diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 199f96bf47..f7927650d9 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -1,5 +1,5 @@ MODULE := engines/zvision - + MODULE_OBJS := \ animation/meta_animation.o \ animation/rlf_animation.o \ @@ -53,15 +53,15 @@ MODULE_OBJS := \ utility/win_keys.o \ video/video.o \ video/zork_avi_decoder.o \ - zvision.o - + zvision.o + MODULE_DIRS += \ engines/zvision - + # This module can be built as a plugin ifeq ($(ENABLE_ZVISION), DYNAMIC_PLUGIN) PLUGIN := 1 endif - -# Include common rules + +# Include common rules include $(srcdir)/rules.mk diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 31f68d7953..8ff6bd0496 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -275,7 +275,7 @@ bool ActionDissolve::execute() { ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { - sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_st_angl, &_en_angl, &_st_lin, &_en_lin); + sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_startAngle, &_endAngle, &_startLineScale, &_endLineScale); } ActionDistort::~ActionDistort() { @@ -286,7 +286,7 @@ bool ActionDistort::execute() { if (_engine->getScriptManager()->getSideFX(_distSlot)) return true; - _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _st_angl, _en_angl, _st_lin, _en_lin)); + _engine->getScriptManager()->addSideFX(new DistortNode(_engine, _distSlot, _speed, _startAngle, _endAngle, _startLineScale, _endLineScale)); return true; } @@ -345,22 +345,22 @@ ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::S bool ActionInventory::execute() { switch (_type) { case 0: // add - _engine->getScriptManager()->invertory_add(_key); + _engine->getScriptManager()->inventoryAdd(_key); break; case 1: // addi - _engine->getScriptManager()->invertory_add(_engine->getScriptManager()->getStateValue(_key)); + _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(_key)); break; case 2: // drop if (_key >= 0) - _engine->getScriptManager()->invertory_drop(_key); + _engine->getScriptManager()->inventoryDrop(_key); else - _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem)); + _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(StateKey_InventoryItem)); break; case 3: // dropi - _engine->getScriptManager()->invertory_drop(_engine->getScriptManager()->getStateValue(_key)); + _engine->getScriptManager()->inventoryDrop(_engine->getScriptManager()->getStateValue(_key)); break; case 4: // cycle - _engine->getScriptManager()->invertory_cycle(); + _engine->getScriptManager()->inventoryCycle(); break; default: break; @@ -463,20 +463,20 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l ActionMusic::~ActionMusic() { if (!_universe) - _engine->getScriptManager()->killSideFx(_slotkey); + _engine->getScriptManager()->killSideFx(_slotKey); } bool ActionMusic::execute() { - if (_engine->getScriptManager()->getSideFX(_slotkey)) + if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; if (_midi) { - _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotkey, _prog, _note, _volume)); + _engine->getScriptManager()->addSideFX(new MusicMidiNode(_engine, _slotKey, _prog, _note, _volume)); } else { if (!_engine->getSearchManager()->hasFile(_fileName)) return true; - _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotkey, _fileName, _loop, _volume)); + _engine->getScriptManager()->addSideFX(new MusicNode(_engine, _slotKey, _fileName, _loop, _volume)); } return true; @@ -489,20 +489,20 @@ bool ActionMusic::execute() { ActionPanTrack::ActionPanTrack(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey), _pos(0), - _mus_slot(0) { + _musicSlot(0) { - sscanf(line.c_str(), "%u %d", &_mus_slot, &_pos); + sscanf(line.c_str(), "%u %d", &_musicSlot, &_pos); } ActionPanTrack::~ActionPanTrack() { - _engine->getScriptManager()->killSideFx(_slotkey); + _engine->getScriptManager()->killSideFx(_slotKey); } bool ActionPanTrack::execute() { - if (_engine->getScriptManager()->getSideFX(_slotkey)) + if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotkey, _mus_slot, _pos)); + _engine->getScriptManager()->addSideFX(new PanTrackNode(_engine, _slotKey, _musicSlot, _pos)); return true; } @@ -549,18 +549,18 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c } ActionPreloadAnimation::~ActionPreloadAnimation() { - _engine->getScriptManager()->deleteSideFx(_slotkey); + _engine->getScriptManager()->deleteSideFx(_slotKey); } bool ActionPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey); if (!nod) { - nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate, false); + nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate, false); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); - _engine->getScriptManager()->setStateValue(_slotkey, 2); + _engine->getScriptManager()->setStateValue(_slotKey, 2); return true; } @@ -607,20 +607,20 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C } ActionPlayAnimation::~ActionPlayAnimation() { - _engine->getScriptManager()->deleteSideFx(_slotkey); + _engine->getScriptManager()->deleteSideFx(_slotKey); } bool ActionPlayAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotkey); + AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey); if (!nod) { - nod = new AnimationNode(_engine, _slotkey, _fileName, _mask, _framerate); + nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); if (nod) - nod->addPlayNode(_slotkey, _x, _y, _x2, _y2, _start, _end, _loopCount); + nod->addPlayNode(_slotKey, _x, _y, _x2, _y2, _start, _end, _loopCount); return true; } @@ -641,7 +641,7 @@ bool ActionPlayPreloadAnimation::execute() { AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey); if (nod) - nod->addPlayNode(_slotkey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); + nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); return true; } @@ -676,20 +676,20 @@ ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String } ActionRegion::~ActionRegion() { - _engine->getScriptManager()->killSideFx(_slotkey); + _engine->getScriptManager()->killSideFx(_slotKey); } bool ActionRegion::execute() { - if (_engine->getScriptManager()->getSideFX(_slotkey)) + if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; Effect *effct = NULL; switch (_type) { case 0: { - uint16 s_x, s_y, frames; + uint16 centerX, centerY, frames; double amplitude, waveln, speed; - sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", &s_x, &s_y, &frames, &litude, &waveln, &speed); - effct = new WaveFx(_engine, _slotkey, _rect, _unk1, frames, s_x, s_y, amplitude, waveln, speed); + sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", ¢erX, ¢erY, &frames, &litude, &waveln, &speed); + effct = new WaveFx(_engine, _slotKey, _rect, _unk1, frames, centerX, centerY, amplitude, waveln, speed); } break; case 1: { @@ -701,7 +701,7 @@ bool ActionRegion::execute() { int8 minD; int8 maxD; EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD); - effct = new LightFx(_engine, _slotkey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD); + effct = new LightFx(_engine, _slotKey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD); } break; case 9: { @@ -717,7 +717,7 @@ bool ActionRegion::execute() { _rect.setHeight(tempMask.h); EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0); - effct = new FogFx(_engine, _slotkey, _rect, _unk1, _map, Common::String(buf)); + effct = new FogFx(_engine, _slotKey, _rect, _unk1, _map, Common::String(buf)); } break; default: @@ -725,7 +725,7 @@ bool ActionRegion::execute() { } if (effct) { - _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotkey, effct, _delay)); + _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effct, _delay)); _engine->getRenderManager()->addEffect(effct); } @@ -738,10 +738,10 @@ bool ActionRegion::execute() { ActionRandom::ActionRandom(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { - char max_buf[64]; - memset(max_buf, 0, 64); - sscanf(line.c_str(), "%s", max_buf); - _max = new ValueSlot(_engine->getScriptManager(), max_buf); + char maxBuffer[64]; + memset(maxBuffer, 0, 64); + sscanf(line.c_str(), "%s", maxBuffer); + _max = new ValueSlot(_engine->getScriptManager(), maxBuffer); } ActionRandom::~ActionRandom() { @@ -751,7 +751,7 @@ ActionRandom::~ActionRandom() { bool ActionRandom::execute() { uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); - _engine->getScriptManager()->setStateValue(_slotkey, randNumber); + _engine->getScriptManager()->setStateValue(_slotKey, randNumber); return true; } @@ -941,9 +941,9 @@ bool ActionStreamVideo::execute() { ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { char fileName[25]; - int not_used; + int notUsed; - sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬_used, fileName); + sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬Used, fileName); _fileName = Common::String(fileName); } @@ -960,7 +960,7 @@ bool ActionSyncSound::execute() { if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload animnode->setNewFrameDelay(66); // ~15fps - _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotkey, _fileName, _syncto)); + _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); return true; } @@ -970,22 +970,22 @@ bool ActionSyncSound::execute() { ActionTimer::ActionTimer(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { - char time_buf[64]; - memset(time_buf, 0, 64); - sscanf(line.c_str(), "%s", time_buf); - _time = new ValueSlot(_engine->getScriptManager(), time_buf); + char timeBuffer[64]; + memset(timeBuffer, 0, 64); + sscanf(line.c_str(), "%s", timeBuffer); + _time = new ValueSlot(_engine->getScriptManager(), timeBuffer); } ActionTimer::~ActionTimer() { if (_time) delete _time; - _engine->getScriptManager()->killSideFx(_slotkey); + _engine->getScriptManager()->killSideFx(_slotKey); } bool ActionTimer::execute() { - if (_engine->getScriptManager()->getSideFX(_slotkey)) + if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotkey, _time->getValue())); + _engine->getScriptManager()->addSideFX(new TimerNode(_engine, _slotKey, _time->getValue())); return true; } @@ -1003,13 +1003,13 @@ ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::Strin } ActionTtyText::~ActionTtyText() { - _engine->getScriptManager()->killSideFx(_slotkey); + _engine->getScriptManager()->killSideFx(_slotKey); } bool ActionTtyText::execute() { - if (_engine->getScriptManager()->getSideFX(_slotkey)) + if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; - _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotkey, _filename, _r, _delay)); + _engine->getScriptManager()->addSideFX(new ttyTextNode(_engine, _slotKey, _filename, _r, _delay)); return true; } diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 5401af0876..03a249e580 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -41,7 +41,7 @@ class ValueSlot; */ class ResultAction { public: - ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotkey(slotkey) {} + ResultAction(ZVision *engine, int32 slotkey) : _engine(engine), _slotKey(slotkey) {} virtual ~ResultAction() {} /** * This is called by the script system whenever a Puzzle's criteria are found to be true. @@ -54,40 +54,8 @@ public: virtual bool execute() = 0; protected: ZVision *_engine; - int32 _slotkey; -}; - - -// The different types of actions -// DEBUG, -// DISABLE_CONTROL, -// DISABLE_VENUS, -// DISPLAY_MESSAGE, -// DISSOLVE, -// DISTORT, -// ENABLE_CONTROL, -// FLUSH_MOUSE_EVENTS, -// INVENTORY, -// KILL, -// MENU_BAR_ENABLE, -// MUSIC, -// PAN_TRACK, -// PLAY_PRELOAD, -// PREFERENCES, -// QUIT, -// RANDOM, -// REGION, -// RESTORE_GAME, -// ROTATE_TO, -// SAVE_GAME, -// SET_PARTIAL_SCREEN, -// SET_SCREEN, -// SET_VENUS, -// STOP, -// STREAM_VIDEO, -// SYNC_SOUND, -// TTY_TEXT, -// UNIVERSE_MUSIC, + int32 _slotKey; +}; class ActionAdd : public ResultAction { public: @@ -217,10 +185,10 @@ public: private: int16 _distSlot; int16 _speed; - float _st_angl; - float _en_angl; - float _st_lin; - float _en_lin; + float _startAngle; + float _endAngle; + float _startLineScale; + float _endLineScale; }; class ActionEnableControl : public ResultAction { @@ -290,7 +258,7 @@ public: private: int32 _pos; - uint32 _mus_slot; + uint32 _musicSlot; }; class ActionPlayAnimation : public ResultAction { diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index 9c8156961c..e69d57f75c 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -106,24 +106,24 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre renderTable->generateRenderTable(); } -void Control::getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { - const char *chrs = input_str.c_str(); +void Control::getParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) { + const char *chrs = inputStr.c_str(); uint lbr; - for (lbr = 0; lbr < input_str.size(); lbr++) + for (lbr = 0; lbr < inputStr.size(); lbr++) if (chrs[lbr] == '(') break; - if (lbr >= input_str.size()) + if (lbr >= inputStr.size()) return; uint rbr; - for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + for (rbr = lbr + 1; rbr < inputStr.size(); rbr++) if (chrs[rbr] == ')') break; - if (rbr >= input_str.size()) + if (rbr >= inputStr.size()) return; parameter = Common::String(chrs, chrs + lbr); @@ -131,9 +131,9 @@ void Control::getParams(const Common::String &input_str, Common::String ¶met } void Control::setVenus() { - if (_venus_id >= 0) - if (_engine->getScriptManager()->getStateValue(_venus_id) > 0) - _engine->getScriptManager()->setStateValue(StateKey_Venus, _venus_id); + if (_venusId >= 0) + if (_engine->getScriptManager()->getStateValue(_venusId) > 0) + _engine->getScriptManager()->setStateValue(StateKey_Venus, _venusId); } } // End of namespace ZVision diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index b784a66913..5814c9e419 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -54,7 +54,7 @@ public: CONTROL_PAINT }; - Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venus_id(-1) {} + Control(ZVision *engine, uint32 key, ControlType type) : _engine(engine), _key(key), _type(type), _venusId(-1) {} virtual ~Control() {} uint32 getKey() { @@ -120,14 +120,15 @@ public: virtual bool process(uint32 deltaTimeInMillis) { return false; } + void setVenus(); protected: ZVision *_engine; uint32 _key; - int32 _venus_id; + int32 _venusId; - void getParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); + void getParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values); // Static member functions public: static void parseFlatControl(ZVision *engine); @@ -137,15 +138,6 @@ private: ControlType _type; }; -// TODO: Implement InputControl -// TODO: Implement SaveControl -// TODO: Implement SlotControl -// TODO: Implement SafeControl -// TODO: Implement FistControl -// TODO: Implement HotMovieControl -// TODO: Implement PaintControl -// TODO: Implement TilterControl - } // End of namespace ZVision #endif diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 185bea09d2..9bb03cba51 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -80,7 +80,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream } else if (param.matchString("animation_id", true)) { _animationId = atoi(values.c_str()); } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } line = stream.readLine(); @@ -152,13 +152,13 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - int n_fist = mouseIn(screenSpacePos, backgroundImageSpacePos); + int fistNumber = mouseIn(screenSpacePos, backgroundImageSpacePos); - if (n_fist >= 0) { + if (fistNumber >= 0) { setVenus(); uint32 oldStatus = _fiststatus; - _fiststatus ^= (1 << n_fist); + _fiststatus ^= (1 << fistNumber); for (int i = 0; i < _numEntries; i++) if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) { @@ -233,12 +233,12 @@ void FistControl::readDescFile(const Common::String &fileName) { (_fistsDwn[fist])[box] = Common::Rect(x1, y1, x2, y2); } else { int entry, start, end, sound; - char bits_start[33]; - char bits_end[33]; + char bitsStart[33]; + char bitsEnd[33]; entry = atoi(param.c_str()); - if (sscanf(values.c_str(), "%s %s %d %d (%d)", bits_start, bits_end, &start, &end, &sound) == 5) { - _entries[entry]._bitsStrt = readBits(bits_start); - _entries[entry]._bitsEnd = readBits(bits_end); + if (sscanf(values.c_str(), "%s %s %d %d (%d)", bitsStart, bitsEnd, &start, &end, &sound) == 5) { + _entries[entry]._bitsStrt = readBits(bitsStart); + _entries[entry]._bitsEnd = readBits(bitsEnd); _entries[entry]._anmStrt = start; _entries[entry]._anmEnd = end; _entries[entry]._sound = sound; @@ -293,24 +293,24 @@ int FistControl::mouseIn(const Common::Point &screenSpacePos, const Common::Poin return -1; } -void FistControl::getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { - const char *chrs = input_str.c_str(); +void FistControl::getFistParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) { + const char *chrs = inputStr.c_str(); uint lbr; - for (lbr = 0; lbr < input_str.size(); lbr++) + for (lbr = 0; lbr < inputStr.size(); lbr++) if (chrs[lbr] == ':') break; - if (lbr >= input_str.size()) + if (lbr >= inputStr.size()) return; uint rbr; - for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + for (rbr = lbr + 1; rbr < inputStr.size(); rbr++) if (chrs[rbr] == '~') break; - if (rbr >= input_str.size()) + if (rbr >= inputStr.size()) return; parameter = Common::String(chrs, chrs + lbr); diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index 8b229f964a..33c3c7b579 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -79,7 +79,7 @@ private: void clearFistArray(Common::Array< Common::Array > &arr); uint32 readBits(const char *str); int mouseIn(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); - void getFistParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); + void getFistParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index 6969ee1bfe..fd7afb92d1 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -44,12 +44,12 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt : Control(engine, key, CONTROL_HOTMOV) { _animation = NULL; _cycle = 0; - _cur_frame = -1; + _curFrame = -1; _lastRenderedFrame = -1; _frames.clear(); - _frame_time = 0; - _num_cycles = 0; - _num_frames = 0; + _frameTime = 0; + _cyclesCount = 0; + _framesCount = 0; _engine->getScriptManager()->setStateValue(_key, 0); @@ -73,16 +73,16 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt _rectangle = Common::Rect(x, y, width, height); } else if (param.matchString("num_frames", true)) { - _num_frames = atoi(values.c_str()); + _framesCount = atoi(values.c_str()); } else if (param.matchString("num_cycles", true)) { - _num_cycles = atoi(values.c_str()); + _cyclesCount = atoi(values.c_str()); } else if (param.matchString("animation", true)) { char filename[64]; sscanf(values.c_str(), "%s", filename); values = Common::String(filename); _animation = new MetaAnimation(values, _engine); } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } line = stream.readLine(); @@ -117,21 +117,21 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_cycle < _num_cycles) { - _frame_time -= deltaTimeInMillis; + if (_cycle < _cyclesCount) { + _frameTime -= deltaTimeInMillis; - if (_frame_time <= 0) { - _cur_frame++; - if (_cur_frame >= _num_frames) { - _cur_frame = 0; + if (_frameTime <= 0) { + _curFrame++; + if (_curFrame >= _framesCount) { + _curFrame = 0; _cycle++; } - if (_cycle != _num_cycles) - renderFrame(_cur_frame); + if (_cycle != _cyclesCount) + renderFrame(_curFrame); else _engine->getScriptManager()->setStateValue(_key, 2); - _frame_time = _animation->frameTime(); + _frameTime = _animation->frameTime(); } } @@ -142,8 +142,8 @@ bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Commo if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_cycle < _num_cycles) { - if (_frames[_cur_frame].contains(backgroundImageSpacePos)) { + if (_cycle < _cyclesCount) { + if (_frames[_curFrame].contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(CursorIndex_Active); return true; } @@ -156,8 +156,8 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common: if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_cycle < _num_cycles) { - if (_frames[_cur_frame].contains(backgroundImageSpacePos)) { + if (_cycle < _cyclesCount) { + if (_frames[_curFrame].contains(backgroundImageSpacePos)) { setVenus(); _engine->getScriptManager()->setStateValue(_key, 1); return true; @@ -168,7 +168,7 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common: } void HotMovControl::readHsFile(const Common::String &fileName) { - if (_num_frames == 0) + if (_framesCount == 0) return; Common::File file; @@ -179,7 +179,7 @@ void HotMovControl::readHsFile(const Common::String &fileName) { Common::String line; - _frames.resize(_num_frames); + _frames.resize(_framesCount); while (!file.eos()) { line = file.readLine(); @@ -192,7 +192,7 @@ void HotMovControl::readHsFile(const Common::String &fileName) { sscanf(line.c_str(), "%d:%d %d %d %d~", &frame, &x, &y, &width, &height); - if (frame >= 0 && frame < _num_frames) + if (frame >= 0 && frame < _framesCount) _frames[frame] = Common::Rect(x, y, width, height); } file.close(); diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index ea12bab82b..9e01b40bab 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -39,12 +39,12 @@ public: ~HotMovControl(); private: - int32 _num_frames; - int32 _frame_time; - int32 _cur_frame; + int32 _framesCount; + int32 _frameTime; + int32 _curFrame; int32 _lastRenderedFrame; int32 _cycle; - int32 _num_cycles; + int32 _cyclesCount; MetaAnimation *_animation; Common::Rect _rectangle; Common::Array _frames; diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 442c6cbc6a..8af436bb40 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -79,13 +79,13 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(values.c_str(), "%u", &fontFormatNumber); - _string_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("chooser_init_string", true)) { uint fontFormatNumber; sscanf(values.c_str(), "%u", &fontFormatNumber); - _string_chooser_init.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("next_tabstop", true)) { sscanf(values.c_str(), "%u", &_nextTabstop); } else if (param.matchString("cursor_dimensions", true)) { @@ -104,7 +104,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _focused = true; _engine->getScriptManager()->setFocusControlKey(_key); } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } line = stream.readLine(); @@ -201,9 +201,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) { txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat); if (!_readOnly || !_focused) - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_init, txt); + _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); else - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _string_chooser_init, txt); + _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt); _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); @@ -211,15 +211,15 @@ bool InputControl::process(uint32 deltaTimeInMillis) { } if (_animation && !_readOnly && _focused) { - bool need_draw = true;// = _textChanged; + bool needDraw = true;// = _textChanged; _frameDelay -= deltaTimeInMillis; if (_frameDelay <= 0) { _frame = (_frame + 1) % _animation->frameCount(); _frameDelay = _animation->frameTime(); - need_draw = true; + needDraw = true; } - if (need_draw) { + if (needDraw) { const Graphics::Surface *srf = _animation->getFrameData(_frame); uint32 xx = _textRectangle.left + _txtWidth; if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width())) diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 5e2190f369..9a829d30f6 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -40,8 +40,8 @@ public: private: Common::Rect _textRectangle; Common::Rect _headerRectangle; - cTxtStyle _string_init; - cTxtStyle _string_chooser_init; + cTxtStyle _stringInit; + cTxtStyle _stringChooserInit; uint32 _nextTabstop; bool _focused; diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index a9836b388e..1f176ef9d0 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -142,7 +142,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { _hotspotDelta.x = x; _hotspotDelta.y = y; } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } else { uint frameNumber; uint x, y; @@ -381,24 +381,24 @@ void LeverControl::renderFrame(uint frameNumber) { _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords); } -void LeverControl::getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values) { - const char *chrs = input_str.c_str(); +void LeverControl::getLevParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values) { + const char *chrs = inputStr.c_str(); uint lbr; - for (lbr = 0; lbr < input_str.size(); lbr++) + for (lbr = 0; lbr < inputStr.size(); lbr++) if (chrs[lbr] == ':') break; - if (lbr >= input_str.size()) + if (lbr >= inputStr.size()) return; uint rbr; - for (rbr = lbr + 1; rbr < input_str.size(); rbr++) + for (rbr = lbr + 1; rbr < inputStr.size(); rbr++) if (chrs[rbr] == '~') break; - if (rbr >= input_str.size()) + if (rbr >= inputStr.size()) return; parameter = Common::String(chrs, chrs + lbr); diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h index 22789f777b..8de6d1e5c9 100644 --- a/engines/zvision/scripting/controls/lever_control.h +++ b/engines/zvision/scripting/controls/lever_control.h @@ -112,7 +112,7 @@ private: */ static int calculateVectorAngle(const Common::Point &pointOne, const Common::Point &pointTwo); void renderFrame(uint frameNumber); - void getLevParams(const Common::String &input_str, Common::String ¶meter, Common::String &values); + void getLevParams(const Common::String &inputStr, Common::String ¶meter, Common::String &values); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index 54c02a2568..cb3c17e0fd 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -64,7 +64,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre } else if (param.matchString("brush_file", true)) { _brush = _engine->getRenderManager()->loadImage(values, false); } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } else if (param.matchString("paint_file", true)) { _paint = _engine->getRenderManager()->loadImage(values, false); } else if (param.matchString("eligible_objects", true)) { @@ -88,7 +88,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre int obj = atoi(st); - _eligible_objects.push_back(obj); + _eligibleObjects.push_back(obj); } } @@ -139,9 +139,9 @@ bool PaintControl::onMouseDown(const Common::Point &screenSpacePos, const Common return false; if (_rectangle.contains(backgroundImageSpacePos)) { - int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (eligeblity(mouse_item)) { + if (eligeblity(mouseItem)) { setVenus(); _mouseDown = true; } @@ -155,9 +155,9 @@ bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common return false; if (_rectangle.contains(backgroundImageSpacePos)) { - int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (eligeblity(mouse_item)) { + if (eligeblity(mouseItem)) { _engine->getCursorManager()->changeCursor(_cursor); if (_mouseDown) { @@ -178,30 +178,30 @@ bool PaintControl::onMouseMove(const Common::Point &screenSpacePos, const Common return false; } -bool PaintControl::eligeblity(int item_id) { - for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) - if (*it == item_id) +bool PaintControl::eligeblity(int itemId) { + for (Common::List::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++) + if (*it == itemId) return true; return false; } Common::Rect PaintControl::paint(const Common::Point &point) { - Common::Rect paint_rect = Common::Rect(_brush->w, _brush->h); - paint_rect.moveTo(point); - paint_rect.clip(_rectangle); - - if (!paint_rect.isEmpty()) { - Common::Rect brush_rect = paint_rect; - brush_rect.translate(-point.x, -point.y); - - Common::Rect bkg_rect = paint_rect; - bkg_rect.translate(-_rectangle.left, -_rectangle.top); - - for (int yy = 0; yy < brush_rect.height(); yy++) { - uint16 *mask = (uint16 *)_brush->getBasePtr(brush_rect.left, brush_rect.top + yy); - uint16 *from = (uint16 *)_paint->getBasePtr(bkg_rect.left, bkg_rect.top + yy); - uint16 *to = (uint16 *)_bkg->getBasePtr(bkg_rect.left, bkg_rect.top + yy); - for (int xx = 0; xx < brush_rect.width(); xx++) { + Common::Rect paintRect = Common::Rect(_brush->w, _brush->h); + paintRect.moveTo(point); + paintRect.clip(_rectangle); + + if (!paintRect.isEmpty()) { + Common::Rect brushRect = paintRect; + brushRect.translate(-point.x, -point.y); + + Common::Rect bkgRect = paintRect; + bkgRect.translate(-_rectangle.left, -_rectangle.top); + + for (int yy = 0; yy < brushRect.height(); yy++) { + uint16 *mask = (uint16 *)_brush->getBasePtr(brushRect.left, brushRect.top + yy); + uint16 *from = (uint16 *)_paint->getBasePtr(bkgRect.left, bkgRect.top + yy); + uint16 *to = (uint16 *)_bkg->getBasePtr(bkgRect.left, bkgRect.top + yy); + for (int xx = 0; xx < brushRect.width(); xx++) { if (*mask != 0) *(to + xx) = *(from + xx); @@ -210,7 +210,7 @@ Common::Rect PaintControl::paint(const Common::Point &point) { } } - return paint_rect; + return paintRect; } } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h index 54b96e8e4e..aac4755fcd 100644 --- a/engines/zvision/scripting/controls/paint_control.h +++ b/engines/zvision/scripting/controls/paint_control.h @@ -75,14 +75,14 @@ private: Graphics::Surface *_bkg; Graphics::Surface *_brush; - Common::List _eligible_objects; + Common::List _eligibleObjects; int _cursor; Common::Rect _rectangle; bool _mouseDown; - bool eligeblity(int item_id); + bool eligeblity(int itemId); Common::Rect paint(const Common::Point &point); }; diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 561dd1dd20..ea4e947abe 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -75,7 +75,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab // Not used } } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } line = stream.readLine(); diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 9df61ce341..de1ece5b19 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -43,18 +43,18 @@ namespace ZVision { SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) : Control(engine, key, CONTROL_SAFE) { - _num_states = 0; - _cur_state = 0; + _statesCount = 0; + _curState = 0; _animation = NULL; - _radius_inner = 0; - _radius_inner_sq = 0; - _radius_outer = 0; - _radius_outer_sq = 0; - _zero_pointer = 0; - _start_pointer = 0; - _cur_frame = -1; - _to_frame = 0; - _frame_time = 0; + _innerRaduis = 0; + _innerRadiusSqr = 0; + _outerRadius = 0; + _outerRadiusSqr = 0; + _zeroPointer = 0; + _startPointer = 0; + _curFrame = -1; + _targetFrame = 0; + _frameTime = 0; _lastRenderedFrame = -1; // Loop until we find the closing brace @@ -77,7 +77,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream _rectangle = Common::Rect(x, y, width, height); } else if (param.matchString("num_states", true)) { - _num_states = atoi(values.c_str()); + _statesCount = atoi(values.c_str()); } else if (param.matchString("center", true)) { int x; int y; @@ -85,29 +85,29 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream sscanf(values.c_str(), "%d %d", &x, &y); _center = Common::Point(x, y); } else if (param.matchString("dial_inner_radius", true)) { - _radius_inner = atoi(values.c_str()); - _radius_inner_sq = _radius_inner * _radius_inner; + _innerRaduis = atoi(values.c_str()); + _innerRadiusSqr = _innerRaduis * _innerRaduis; } else if (param.matchString("radius", true)) { - _radius_outer = atoi(values.c_str()); - _radius_outer_sq = _radius_outer * _radius_outer; + _outerRadius = atoi(values.c_str()); + _outerRadiusSqr = _outerRadius * _outerRadius; } else if (param.matchString("zero_radians_offset", true)) { - _zero_pointer = atoi(values.c_str()); + _zeroPointer = atoi(values.c_str()); } else if (param.matchString("pointer_offset", true)) { - _start_pointer = atoi(values.c_str()); - _cur_state = _start_pointer; + _startPointer = atoi(values.c_str()); + _curState = _startPointer; } else if (param.matchString("cursor", true)) { // Not used } else if (param.matchString("mirrored", true)) { // Not used } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } line = stream.readLine(); trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } - renderFrame(_cur_state); + renderFrame(_curState); } SafeControl::~SafeControl() { @@ -121,7 +121,7 @@ void SafeControl::renderFrame(uint frameNumber) { _lastRenderedFrame = frameNumber; } else if ((int16)frameNumber < _lastRenderedFrame) { _lastRenderedFrame = frameNumber; - frameNumber = (_num_states * 2) - frameNumber; + frameNumber = (_statesCount * 2) - frameNumber; } else { _lastRenderedFrame = frameNumber; } @@ -139,21 +139,20 @@ bool SafeControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_cur_frame != _to_frame) { - _frame_time -= deltaTimeInMillis; + if (_curFrame != _targetFrame) { + _frameTime -= deltaTimeInMillis; - if (_frame_time <= 0) { - if (_cur_frame < _to_frame) { - _cur_frame++; - renderFrame(_cur_frame); - } else if (_cur_frame > _to_frame) { - _cur_frame--; - renderFrame(_cur_frame); + if (_frameTime <= 0) { + if (_curFrame < _targetFrame) { + _curFrame++; + renderFrame(_curFrame); + } else if (_curFrame > _targetFrame) { + _curFrame--; + renderFrame(_curFrame); } - _frame_time = _animation->frameTime(); + _frameTime = _animation->frameTime(); } } - return false; } @@ -163,12 +162,11 @@ bool SafeControl::onMouseMove(const Common::Point &screenSpacePos, const Common: if (_rectangle.contains(backgroundImageSpacePos)) { int32 mR = backgroundImageSpacePos.sqrDist(_center); - if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) { + if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) { _engine->getCursorManager()->changeCursor(CursorIndex_Active); return true; } } - return false; } @@ -178,30 +176,29 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P if (_rectangle.contains(backgroundImageSpacePos)) { int32 mR = backgroundImageSpacePos.sqrDist(_center); - if (mR <= _radius_outer_sq && mR >= _radius_inner_sq) { + if (mR <= _outerRadiusSqr && mR >= _innerRadiusSqr) { setVenus(); Common::Point tmp = backgroundImageSpacePos - _center; float dd = atan2(tmp.x, tmp.y) * 57.29578; - int16 dp_state = 360 / _num_states; + int16 dp_state = 360 / _statesCount; - int16 m_state = (_num_states - ((((int16)dd + 540) % 360) / dp_state)) % _num_states; + int16 m_state = (_statesCount - ((((int16)dd + 540) % 360) / dp_state)) % _statesCount; - int16 tmp2 = (m_state + _cur_state - _zero_pointer + _num_states - 1) % _num_states; + int16 tmp2 = (m_state + _curState - _zeroPointer + _statesCount - 1) % _statesCount; - _cur_frame = (_cur_state + _num_states - _start_pointer) % _num_states; + _curFrame = (_curState + _statesCount - _startPointer) % _statesCount; - _cur_state = (_num_states * 2 + tmp2) % _num_states; + _curState = (_statesCount * 2 + tmp2) % _statesCount; - _to_frame = (_cur_state + _num_states - _start_pointer) % _num_states; + _targetFrame = (_curState + _statesCount - _startPointer) % _statesCount; - _engine->getScriptManager()->setStateValue(_key, _cur_state); + _engine->getScriptManager()->setStateValue(_key, _curState); return true; } } - return false; } diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h index 2477d8c26d..e682e35050 100644 --- a/engines/zvision/scripting/controls/safe_control.h +++ b/engines/zvision/scripting/controls/safe_control.h @@ -40,20 +40,20 @@ public: ~SafeControl(); private: - int16 _num_states; - int16 _cur_state; + int16 _statesCount; + int16 _curState; MetaAnimation *_animation; Common::Point _center; Common::Rect _rectangle; - int16 _radius_inner; - int32 _radius_inner_sq; - int16 _radius_outer; - int32 _radius_outer_sq; - int16 _zero_pointer; - int16 _start_pointer; - int16 _cur_frame; - int16 _to_frame; - int32 _frame_time; + int16 _innerRaduis; + int32 _innerRadiusSqr; + int16 _outerRadius; + int32 _outerRadiusSqr; + int16 _zeroPointer; + int16 _startPointer; + int16 _curFrame; + int16 _targetFrame; + int32 _frameTime; int16 _lastRenderedFrame; diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index a0b19db513..7e1a65a9cc 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -50,13 +50,13 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream while (!stream.eos() && !line.contains('}')) { if (param.matchString("savebox", true)) { - int save_id; - int input_id; + int saveId; + int inputId; - sscanf(values.c_str(), "%d %d", &save_id, &input_id); - save_elmnt elmnt; - elmnt.input_key = input_id; - elmnt.save_id = save_id; + sscanf(values.c_str(), "%d %d", &saveId, &inputId); + saveElement elmnt; + elmnt.inputKey = inputId; + elmnt.saveId = saveId; elmnt.exist = false; _inputs.push_back(elmnt); } else if (param.matchString("control_type", true)) { @@ -72,11 +72,11 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream } for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) { - Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key); + Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey); if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) { InputControl *inp = (InputControl *)ctrl; inp->setReadOnly(!_saveControl); - Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->save_id); + Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->saveId); if (save) { SaveGameHeader header; _engine->getSaveManager()->readSaveGameHeader(save, header); @@ -90,7 +90,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream bool SaveControl::process(uint32 deltaTimeInMillis) { for (saveElmntList::iterator iter = _inputs.begin(); iter != _inputs.end(); ++iter) { - Control *ctrl = _engine->getScriptManager()->getControl(iter->input_key); + Control *ctrl = _engine->getScriptManager()->getControl(iter->inputKey); if (ctrl && ctrl->getType() == Control::CONTROL_INPUT) { InputControl *inp = (InputControl *)ctrl; if (inp->enterPress()) { @@ -102,7 +102,7 @@ bool SaveControl::process(uint32 deltaTimeInMillis) { toSave = false; if (toSave) { - _engine->getSaveManager()->saveGameBuffered(iter->save_id, inp->getText()); + _engine->getSaveManager()->saveGameBuffered(iter->saveId, inp->getText()); _engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000); _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation()); } @@ -110,7 +110,7 @@ bool SaveControl::process(uint32 deltaTimeInMillis) { _engine->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000); } } else { - _engine->getSaveManager()->loadGame(iter->save_id); + _engine->getSaveManager()->loadGame(iter->saveId); return true; } break; diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h index 942b9c9269..fefb0e0ce2 100644 --- a/engines/zvision/scripting/controls/save_control.h +++ b/engines/zvision/scripting/controls/save_control.h @@ -35,12 +35,12 @@ public: SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); private: - struct save_elmnt { - int save_id; - int input_key; + struct saveElement { + int saveId; + int inputKey; bool exist; }; - typedef Common::List saveElmntList; + typedef Common::List saveElmntList; saveElmntList _inputs; bool _saveControl; diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 46ee320eb5..074d1905b4 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -38,7 +38,7 @@ namespace ZVision { SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) : Control(engine, key, CONTROL_SLOT) { - _rendered_item = 0; + _renderedItem = 0; _bkg = NULL; // Loop until we find the closing brace @@ -70,9 +70,9 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream } else if (param.matchString("cursor", true)) { _cursor = _engine->getCursorManager()->getCursorId(values); } else if (param.matchString("distance_id", true)) { - sscanf(values.c_str(), "%c", &_distance_id); + sscanf(values.c_str(), "%c", &_distanceId); } else if (param.matchString("venus_id", true)) { - _venus_id = atoi(values.c_str()); + _venusId = atoi(values.c_str()); } else if (param.matchString("eligible_objects", true)) { char buf[256]; memset(buf, 0, 256); @@ -94,7 +94,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream int obj = atoi(st); - _eligible_objects.push_back(obj); + _eligibleObjects.push_back(obj); } } @@ -124,26 +124,26 @@ bool SlotControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P setVenus(); int item = _engine->getScriptManager()->getStateValue(_key); - int mouse_item = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + int mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); if (item != 0) { - if (mouse_item != 0) { - if (eligeblity(mouse_item)) { - _engine->getScriptManager()->invertory_drop(mouse_item); - _engine->getScriptManager()->invertory_add(item); - _engine->getScriptManager()->setStateValue(_key, mouse_item); + if (mouseItem != 0) { + if (eligeblity(mouseItem)) { + _engine->getScriptManager()->inventoryDrop(mouseItem); + _engine->getScriptManager()->inventoryAdd(item); + _engine->getScriptManager()->setStateValue(_key, mouseItem); } } else { - _engine->getScriptManager()->invertory_add(item); + _engine->getScriptManager()->inventoryAdd(item); _engine->getScriptManager()->setStateValue(_key, 0); } - } else if (mouse_item == 0) { + } else if (mouseItem == 0) { if (eligeblity(0)) { - _engine->getScriptManager()->invertory_drop(0); + _engine->getScriptManager()->inventoryDrop(0); _engine->getScriptManager()->setStateValue(_key, 0); } - } else if (eligeblity(mouse_item)) { - _engine->getScriptManager()->setStateValue(_key, mouse_item); - _engine->getScriptManager()->invertory_drop(mouse_item); + } else if (eligeblity(mouseItem)) { + _engine->getScriptManager()->setStateValue(_key, mouseItem); + _engine->getScriptManager()->inventoryDrop(mouseItem); } } return false; @@ -166,13 +166,13 @@ bool SlotControl::process(uint32 deltaTimeInMillis) { return false; if (_engine->canRender()) { - int cur_item = _engine->getScriptManager()->getStateValue(_key); - if (cur_item != _rendered_item) { - if (_rendered_item != 0 && cur_item == 0) { + int curItem = _engine->getScriptManager()->getStateValue(_key); + if (curItem != _renderedItem) { + if (_renderedItem != 0 && curItem == 0) { _engine->getRenderManager()->blitSurfaceToBkg(*_bkg, _rectangle.left, _rectangle.top); - _rendered_item = cur_item; + _renderedItem = curItem; } else { - if (_rendered_item == 0) { + if (_renderedItem == 0) { if (_bkg) delete _bkg; @@ -183,9 +183,9 @@ bool SlotControl::process(uint32 deltaTimeInMillis) { char buf[16]; if (_engine->getGameId() == GID_NEMESIS) - sprintf(buf, "%d%cobj.tga", cur_item, _distance_id); + sprintf(buf, "%d%cobj.tga", curItem, _distanceId); else - sprintf(buf, "g0z%cu%2.2x1.tga", _distance_id, cur_item); + sprintf(buf, "g0z%cu%2.2x1.tga", _distanceId, curItem); Graphics::Surface *srf = _engine->getRenderManager()->loadImage(buf); @@ -202,16 +202,16 @@ bool SlotControl::process(uint32 deltaTimeInMillis) { delete srf; - _rendered_item = cur_item; + _renderedItem = curItem; } } } return false; } -bool SlotControl::eligeblity(int item_id) { - for (Common::List::iterator it = _eligible_objects.begin(); it != _eligible_objects.end(); it++) - if (*it == item_id) +bool SlotControl::eligeblity(int itemId) { + for (Common::List::iterator it = _eligibleObjects.begin(); it != _eligibleObjects.end(); it++) + if (*it == itemId) return true; return false; } diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h index 7799785aa5..86fd261f25 100644 --- a/engines/zvision/scripting/controls/slot_control.h +++ b/engines/zvision/scripting/controls/slot_control.h @@ -66,13 +66,13 @@ private: Common::Rect _hotspot; int _cursor; - char _distance_id; + char _distanceId; - int _rendered_item; + int _renderedItem; - Common::List _eligible_objects; + Common::List _eligibleObjects; - bool eligeblity(int item_id); + bool eligeblity(int itemId); Graphics::Surface *_bkg; diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp index f8b22970c4..98d063395b 100644 --- a/engines/zvision/scripting/inventory.cpp +++ b/engines/zvision/scripting/inventory.cpp @@ -27,95 +27,95 @@ namespace ZVision { -int8 ScriptManager::invertory_getCount() { +int8 ScriptManager::inventoryGetCount() { return getStateValue(StateKey_Inv_Cnt_Slot); } -void ScriptManager::invertory_setCount(int8 cnt) { +void ScriptManager::inventorySetCount(int8 cnt) { setStateValue(StateKey_Inv_Cnt_Slot, cnt); } -int16 ScriptManager::invertory_getItem(int8 id) { +int16 ScriptManager::inventoryGetItem(int8 id) { if (id < 49 && id >= 0) return getStateValue(StateKey_Inv_1_Slot + id); return -1; } -void ScriptManager::invertory_setItem(int8 id, int16 item) { +void ScriptManager::inventorySetItem(int8 id, int16 item) { if (id < 49 && id >= 0) setStateValue(StateKey_Inv_1_Slot + id, item); } -void ScriptManager::invertory_add(int16 item) { - int8 cnt = invertory_getCount(); +void ScriptManager::inventoryAdd(int16 item) { + int8 cnt = inventoryGetCount(); if (cnt < 49) { - bool not_exist = true; + bool notExist = true; if (cnt == 0) { - invertory_setItem(0, 0); - invertory_setCount(1); // we needed empty item for cycle code + inventorySetItem(0, 0); + inventorySetCount(1); // we needed empty item for cycle code cnt = 1; } for (int8 cur = 0; cur < cnt; cur++) - if (invertory_getItem(cur) == item) { - not_exist = false; + if (inventoryGetItem(cur) == item) { + notExist = false; break; } - if (not_exist) { + if (notExist) { for (int8 i = cnt; i > 0; i--) - invertory_setItem(i, invertory_getItem(i - 1)); + inventorySetItem(i, inventoryGetItem(i - 1)); - invertory_setItem(0, item); + inventorySetItem(0, item); setStateValue(StateKey_InventoryItem, item); - invertory_setCount(cnt + 1); + inventorySetCount(cnt + 1); } } } -void ScriptManager::invertory_drop(int16 item) { - int8 items_cnt = invertory_getCount(); +void ScriptManager::inventoryDrop(int16 item) { + int8 itemCount = inventoryGetCount(); // if items in inventory > 0 - if (items_cnt != 0) { + if (itemCount != 0) { int8 index = 0; // finding needed item - while (index < items_cnt) { - if (invertory_getItem(index) == item) + while (index < itemCount) { + if (inventoryGetItem(index) == item) break; index++; } // if item in the inventory - if (items_cnt != index) { + if (itemCount != index) { // shift all items left with rewrite founded item - for (int8 v = index; v < items_cnt - 1 ; v++) - invertory_setItem(v, invertory_getItem(v + 1)); + for (int8 v = index; v < itemCount - 1 ; v++) + inventorySetItem(v, inventoryGetItem(v + 1)); // del last item - invertory_setItem(items_cnt - 1, 0); - invertory_setCount(invertory_getCount() - 1); + inventorySetItem(itemCount - 1, 0); + inventorySetCount(inventoryGetCount() - 1); - setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + setStateValue(StateKey_InventoryItem, inventoryGetItem(0)); } } } -void ScriptManager::invertory_cycle() { - int8 item_cnt = invertory_getCount(); - int8 cur_item = invertory_getItem(0); - if (item_cnt > 1) { - for (int8 i = 0; i < item_cnt - 1; i++) - invertory_setItem(i, invertory_getItem(i + 1)); +void ScriptManager::inventoryCycle() { + int8 itemCount = inventoryGetCount(); + int8 curItem = inventoryGetItem(0); + if (itemCount > 1) { + for (int8 i = 0; i < itemCount - 1; i++) + inventorySetItem(i, inventoryGetItem(i + 1)); - invertory_setItem(item_cnt - 1, cur_item); + inventorySetItem(itemCount - 1, curItem); - setStateValue(StateKey_InventoryItem, invertory_getItem(0)); + setStateValue(StateKey_InventoryItem, inventoryGetItem(0)); } } diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 5e0387f0d9..697de58ed8 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -46,7 +46,7 @@ namespace ZVision { -void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &scope) { +void ScriptManager::parseScrFile(const Common::String &fileName, ScriptScope &scope) { Common::File file; if (!_engine->getSearchManager()->openFile(file, fileName)) { warning("Script file not found: %s", fileName.c_str()); @@ -70,15 +70,15 @@ void ScriptManager::parseScrFile(const Common::String &fileName, script_scope &s if (getStateFlag(puzzle->key) & Puzzle::ONCE_PER_INST) setStateValue(puzzle->key, 0); parsePuzzle(puzzle, file); - scope._puzzles.push_back(puzzle); + scope.puzzles.push_back(puzzle); } else if (line.matchString("control:*", true)) { Control *ctrl = parseControl(line, file); if (ctrl) - scope._controls.push_back(ctrl); + scope.controls.push_back(ctrl); } } - scope.proc_count = 0; + scope.procCount = 0; } void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stream) { @@ -196,8 +196,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis for (pos = startpos; pos < line.size(); pos++) if (chrs[pos] == '(') break; - Common::String s_slot(chrs + startpos, chrs + pos); - slot = atoi(s_slot.c_str()); + Common::String strSlot(chrs + startpos, chrs + pos); + slot = atoi(strSlot.c_str()); startpos = pos + 1; } diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 7df48183bd..2a54cc4314 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -76,7 +76,7 @@ void ScriptManager::update(uint deltaTimeMillis) { _currentLocation.room != _nextLocation.room || _currentLocation.view != _nextLocation.view || _currentLocation.world != _nextLocation.world) - do_changeLocation(); + ChangeLocationReal(); updateNodes(deltaTimeMillis); if (! execScope(nodeview)) @@ -90,35 +90,35 @@ void ScriptManager::update(uint deltaTimeMillis) { updateControls(deltaTimeMillis); } -bool ScriptManager::execScope(script_scope &scope) { +bool ScriptManager::execScope(ScriptScope &scope) { // Swap queues - PuzzleList *tmp = scope.exec_queue; - scope.exec_queue = scope.scope_queue; - scope.scope_queue = tmp; - scope.scope_queue->clear(); + PuzzleList *tmp = scope.execQueue; + scope.execQueue = scope.scopeQueue; + scope.scopeQueue = tmp; + scope.scopeQueue->clear(); - for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) + for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) (*PuzzleIter)->addedBySetState = 0; - if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) { - for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) - if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count)) + if (scope.procCount < 2 || getStateValue(StateKey_ExecScopeStyle)) { + for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) + if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) return false; } else { - for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter) - if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count)) + for (PuzzleList::iterator PuzzleIter = scope.execQueue->begin(); PuzzleIter != scope.execQueue->end(); ++PuzzleIter) + if (!checkPuzzleCriteria(*PuzzleIter, scope.procCount)) return false; } - if (scope.proc_count < 2) { - scope.proc_count++; + if (scope.procCount < 2) { + scope.procCount++; } return true; } -void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) { +void ScriptManager::referenceTableAddPuzzle(uint32 key, PuzzleRef ref) { if (_referenceTable.contains(key)) { - Common::Array *arr = &_referenceTable[key]; + Common::Array *arr = &_referenceTable[key]; for (uint32 i = 0; i < arr->size(); i++) if ((*arr)[i].puz == ref.puz) return; @@ -127,12 +127,12 @@ void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) { _referenceTable[key].push_back(ref); } -void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { +void ScriptManager::addPuzzlesToReferenceTable(ScriptScope &scope) { // Iterate through each local Puzzle - for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) { + for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) { Puzzle *puzzlePtr = (*PuzzleIter); - puzzle_ref ref; + PuzzleRef ref; ref.scope = &scope; ref.puz = puzzlePtr; @@ -270,22 +270,22 @@ void ScriptManager::cleanStateTable() { } } -void ScriptManager::cleanScriptScope(script_scope &scope) { - scope._priv_queue_one.clear(); - scope._priv_queue_two.clear(); - scope.scope_queue = &scope._priv_queue_one; - scope.exec_queue = &scope._priv_queue_two; - for (PuzzleList::iterator iter = scope._puzzles.begin(); iter != scope._puzzles.end(); ++iter) +void ScriptManager::cleanScriptScope(ScriptScope &scope) { + scope.privQueueOne.clear(); + scope.privQueueTwo.clear(); + scope.scopeQueue = &scope.privQueueOne; + scope.execQueue = &scope.privQueueTwo; + for (PuzzleList::iterator iter = scope.puzzles.begin(); iter != scope.puzzles.end(); ++iter) delete(*iter); - scope._puzzles.clear(); + scope.puzzles.clear(); - for (ControlList::iterator iter = scope._controls.begin(); iter != scope._controls.end(); ++iter) + for (ControlList::iterator iter = scope.controls.begin(); iter != scope.controls.end(); ++iter) delete(*iter); - scope._controls.clear(); + scope.controls.clear(); - scope.proc_count = 0; + scope.procCount = 0; } int ScriptManager::getStateValue(uint32 key) { @@ -297,10 +297,10 @@ int ScriptManager::getStateValue(uint32 key) { void ScriptManager::queuePuzzles(uint32 key) { if (_referenceTable.contains(key)) { - Common::Array *arr = &_referenceTable[key]; + Common::Array *arr = &_referenceTable[key]; for (int32 i = arr->size() - 1; i >= 0; i--) if (!(*arr)[i].puz->addedBySetState) { - (*arr)[i].scope->scope_queue->push_back((*arr)[i].puz); + (*arr)[i].scope->scopeQueue->push_back((*arr)[i].puz); (*arr)[i].puz->addedBySetState = true; } } @@ -518,7 +518,7 @@ void ScriptManager::changeLocation(char _world, char _room, char _node, char _vi } } -void ScriptManager::do_changeLocation() { +void ScriptManager::ChangeLocationReal() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); @@ -605,7 +605,7 @@ void ScriptManager::do_changeLocation() { addPuzzlesToReferenceTable(nodeview); } - _activeControls = &nodeview._controls; + _activeControls = &nodeview.controls; // Revert to the idle cursor _engine->getCursorManager()->changeCursor(CursorIndex_Idle); @@ -701,19 +701,17 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { return; } - Location next_loc; + Location nextLocation; - next_loc.world = stream->readByte(); - next_loc.room = stream->readByte(); - next_loc.node = stream->readByte(); - next_loc.view = stream->readByte(); - next_loc.offset = stream->readUint32LE() & 0x0000FFFF; + nextLocation.world = stream->readByte(); + nextLocation.room = stream->readByte(); + nextLocation.node = stream->readByte(); + nextLocation.view = stream->readByte(); + nextLocation.offset = stream->readUint32LE() & 0x0000FFFF; - // What the fck, eos is not 'return pos >= size' - // while (!stream->eos()) {*/ while (stream->pos() < stream->size()) { uint32 tag = stream->readUint32BE(); - uint32 tag_size = stream->readUint32LE(); + uint32 tagSize = stream->readUint32LE(); switch (tag) { case MKTAG('T', 'I', 'M', 'R'): { uint32 key = stream->readUint32LE(); @@ -726,22 +724,22 @@ void ScriptManager::deserialize(Common::SeekableReadStream *stream) { } break; case MKTAG('F', 'L', 'A', 'G'): - for (uint32 i = 0; i < tag_size / 2; i++) + for (uint32 i = 0; i < tagSize / 2; i++) setStateFlagSilent(i, stream->readUint16LE()); break; case MKTAG('P', 'U', 'Z', 'Z'): - for (uint32 i = 0; i < tag_size / 2; i++) + for (uint32 i = 0; i < tagSize / 2; i++) setStateValueSilent(i, stream->readUint16LE()); break; default: - stream->seek(tag_size, SEEK_CUR); + stream->seek(tagSize, SEEK_CUR); } } - _nextLocation = next_loc; + _nextLocation = nextLocation; + + ChangeLocationReal(); - do_changeLocation(); - // Place for read prefs _engine->setRenderDelay(10); setStateValue(StateKey_RestoreFlag, 1); @@ -792,23 +790,23 @@ void ScriptManager::flushEvent(Common::EventType type) { } } -ValueSlot::ValueSlot(ScriptManager *sc_man, const char *slot_val): - _sc_man(sc_man) { +ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue): + _scriptManager(scriptManager) { value = 0; slot = false; - const char *is_slot = strstr(slot_val, "["); - if (is_slot) { + const char *isSlot = strstr(slotValue, "["); + if (isSlot) { slot = true; - value = atoi(is_slot + 1); + value = atoi(isSlot + 1); } else { slot = false; - value = atoi(slot_val); + value = atoi(slotValue); } } int16 ValueSlot::getValue() { if (slot) { if (value >= 0) - return _sc_man->getStateValue(value); + return _scriptManager->getStateValue(value); else return 0; } else diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index ddb8c885aa..5701cde6d0 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -123,24 +123,24 @@ public: private: ZVision *_engine; - struct script_scope { - uint32 proc_count; + struct ScriptScope { + uint32 procCount; - PuzzleList *scope_queue; // For adding puzzles to queue - PuzzleList *exec_queue; // Switch to it when execute - PuzzleList _priv_queue_one; - PuzzleList _priv_queue_two; + PuzzleList *scopeQueue; // For adding puzzles to queue + PuzzleList *execQueue; // Switch to it when execute + PuzzleList privQueueOne; + PuzzleList privQueueTwo; - PuzzleList _puzzles; - ControlList _controls; + PuzzleList puzzles; + ControlList controls; }; - struct puzzle_ref { + struct PuzzleRef { Puzzle *puz; - script_scope *scope; + ScriptScope *scope; }; - typedef Common::HashMap > PuzzleMap; + typedef Common::HashMap > PuzzleMap; /** * Holds the global state variable. Do NOT directly modify this. Use the accessors and @@ -157,10 +157,10 @@ private: EventList _controlEvents; - script_scope universe; - script_scope world; - script_scope room; - script_scope nodeview; + ScriptScope universe; + ScriptScope world; + ScriptScope room; + ScriptScope nodeview; /** Holds the currently active timers, musics, other */ SideFXList _activeSideFx; @@ -249,30 +249,30 @@ public: Location getLastMenuLocation(); private: - void referenceTableAddPuzzle(uint32 key, puzzle_ref ref); - void addPuzzlesToReferenceTable(script_scope &scope); + void referenceTableAddPuzzle(uint32 key, PuzzleRef ref); + void addPuzzlesToReferenceTable(ScriptScope &scope); void updateNodes(uint deltaTimeMillis); void updateControls(uint deltaTimeMillis); bool checkPuzzleCriteria(Puzzle *puzzle, uint counter); void cleanStateTable(); - void cleanScriptScope(script_scope &scope); - bool execScope(script_scope &scope); + void cleanScriptScope(ScriptScope &scope); + bool execScope(ScriptScope &scope); /** Perform change location */ - void do_changeLocation(); + void ChangeLocationReal(); - int8 invertory_getCount(); - void invertory_setCount(int8 cnt); - int16 invertory_getItem(int8 id); - void invertory_setItem(int8 id, int16 item); + int8 inventoryGetCount(); + void inventorySetCount(int8 cnt); + int16 inventoryGetItem(int8 id); + void inventorySetItem(int8 id, int16 item); void setStateFlagSilent(uint32 key, uint value); void setStateValueSilent(uint32 key, int value); public: - void invertory_add(int16 item); - void invertory_drop(int16 item); - void invertory_cycle(); + void inventoryAdd(int16 item); + void inventoryDrop(int16 item); + void inventoryCycle(); // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it /** @@ -281,7 +281,7 @@ public: * @param fileName Name of the .scr file * @param isGlobal Are the puzzles included in the file global (true). AKA, the won't be purged during location changes */ - void parseScrFile(const Common::String &fileName, script_scope &scope); + void parseScrFile(const Common::String &fileName, ScriptScope &scope); private: /** @@ -332,12 +332,12 @@ private: class ValueSlot { public: - ValueSlot(ScriptManager *sc_man, const char *slot_val); + ValueSlot(ScriptManager *scriptManager, const char *slotValue); int16 getValue(); private: int16 value; bool slot; - ScriptManager *_sc_man; + ScriptManager *_scriptManager; }; diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index bd9c543d52..98ac4e3b37 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -75,19 +75,19 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { const Graphics::Surface *frame = NULL; - if (nod->_cur_frm == -1) { // Start of new playlist node - nod->_cur_frm = nod->start; + if (nod->_curFrame == -1) { // Start of new playlist node + nod->_curFrame = nod->start; - _animation->seekToFrame(nod->_cur_frm); + _animation->seekToFrame(nod->_curFrame); frame = _animation->decodeNextFrame(); nod->_delay = _frmDelay; if (nod->slot) _engine->getScriptManager()->setStateValue(nod->slot, 1); } else { - nod->_cur_frm++; + nod->_curFrame++; - if (nod->_cur_frm > nod->stop) { + if (nod->_curFrame > nod->stop) { nod->loop--; if (nod->loop == 0) { @@ -99,8 +99,8 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { return _DisposeAfterUse; } - nod->_cur_frm = nod->start; - _animation->seekToFrame(nod->_cur_frm); + nod->_curFrame = nod->start; + _animation->seekToFrame(nod->_curFrame); } frame = _animation->decodeNextFrame(); @@ -156,18 +156,18 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { -void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops) { +void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) { playnode nod; nod.loop = loops; nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); - nod.start = start_frame; - nod.stop = end_frame; + nod.start = startFrame; + nod.stop = endFrame; if (nod.stop >= (int)_animation->frameCount()) nod.stop = _animation->frameCount() - 1; nod.slot = slot; - nod._cur_frm = -1; + nod._curFrame = -1; nod._delay = 0; nod._scaled = NULL; _playList.push_back(nod); diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 4d1c74bccf..dab3d88d80 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -52,7 +52,7 @@ public: int32 start; int32 stop; int32 loop; - int32 _cur_frm; + int32 _curFrame; int32 _delay; Graphics::Surface *_scaled; }; @@ -71,7 +71,7 @@ private: public: bool process(uint32 deltaTimeInMillis); - void addPlayNode(int32 slot, int x, int y, int x2, int y2, int start_frame, int end_frame, int loops = 1); + void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1); bool stop(); diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp index 576a1f8592..9be6b29413 100644 --- a/engines/zvision/scripting/sidefx/distort_node.cpp +++ b/engines/zvision/scripting/sidefx/distort_node.cpp @@ -34,7 +34,7 @@ namespace ZVision { -DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin) +DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale) : SideFX(engine, key, SIDEFX_DISTORT) { _angle = _engine->getRenderManager()->getRenderTable()->getAngle(); @@ -42,15 +42,15 @@ DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl _speed = speed; _incr = true; - _st_angl = st_angl; - _en_angl = en_angl; - _st_lin = st_lin; - _en_lin = en_lin; + _startAngle = startAngle; + _endAngle = endAngle; + _startLineScale = startLineScale; + _endLineScale = endLineScale; _curFrame = 1.0; - _diff_angl = en_angl - st_angl; - _diff_lin = en_lin - st_lin; + _diffAngle = endAngle - startAngle; + _diffLinScale = endLineScale - startLineScale; _frmSpeed = (float)speed / 15.0; _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); @@ -85,7 +85,7 @@ bool DistortNode::process(uint32 deltaTimeInMillis) { float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed); - setParams(_st_angl + diff * _diff_angl, _st_lin + diff * _diff_lin); + setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale); return false; } diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h index cba9c5eff2..787a69bdde 100644 --- a/engines/zvision/scripting/sidefx/distort_node.h +++ b/engines/zvision/scripting/sidefx/distort_node.h @@ -31,21 +31,21 @@ class ZVision; class DistortNode : public SideFX { public: - DistortNode(ZVision *engine, uint32 key, int16 speed, float st_angl, float en_angl, float st_lin, float en_lin); + DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale); ~DistortNode(); bool process(uint32 deltaTimeInMillis); private: int16 _speed; - float _st_angl; - float _en_angl; - float _st_lin; - float _en_lin; + float _startAngle; + float _endAngle; + float _startLineScale; + float _endLineScale; float _frmSpeed; - float _diff_angl; - float _diff_lin; + float _diffAngle; + float _diffLinScale; bool _incr; int16 _frames; diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index 4420da3e96..e9baadb011 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -38,15 +38,15 @@ namespace ZVision { MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) - : MusicNode_BASE(engine, key, SIDEFX_AUDIO) { + : MusicNodeBASE(engine, key, SIDEFX_AUDIO) { _loop = loop; _volume = volume; _crossfade = false; - _crossfade_target = 0; - _crossfade_time = 0; + _crossfadeTarget = 0; + _crossfadeTime = 0; _attenuate = 0; _pantrack = false; - _pantrack_X = 0; + _pantrackPosition = 0; _sub = NULL; Audio::RewindableAudioStream *audioStream; @@ -93,7 +93,7 @@ MusicNode::~MusicNode() { void MusicNode::setPanTrack(int16 pos) { if (!_stereo) { _pantrack = true; - _pantrack_X = pos; + _pantrackPosition = pos; setVolume(_volume); } } @@ -104,8 +104,8 @@ void MusicNode::unsetPanTrack() { } void MusicNode::setFade(int32 time, uint8 target) { - _crossfade_target = target; - _crossfade_time = time; + _crossfadeTarget = target; + _crossfadeTime = time; _crossfade = true; } @@ -116,14 +116,14 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { uint8 _newvol = _volume; if (_crossfade) { - if (_crossfade_time > 0) { - if ((int32)deltaTimeInMillis > _crossfade_time) - deltaTimeInMillis = _crossfade_time; - _newvol += floor(((float)(_crossfade_target - _newvol) / (float)_crossfade_time)) * (float)deltaTimeInMillis; - _crossfade_time -= deltaTimeInMillis; + if (_crossfadeTime > 0) { + if ((int32)deltaTimeInMillis > _crossfadeTime) + deltaTimeInMillis = _crossfadeTime; + _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis; + _crossfadeTime -= deltaTimeInMillis; } else { _crossfade = false; - _newvol = _crossfade_target; + _newvol = _crossfadeTarget; } } @@ -136,17 +136,17 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { return false; } -void MusicNode::setVolume(uint8 new_volume) { +void MusicNode::setVolume(uint8 newVolume) { if (_pantrack) { - int cur_x = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); - cur_x -= _pantrack_X; + int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + curX -= _pantrackPosition; int32 _width = _engine->getRenderManager()->getBkgSize().x; - if (cur_x < (-_width) / 2) - cur_x += _width; - else if (cur_x >= _width / 2) - cur_x -= _width; + if (curX < (-_width) / 2) + curX += _width; + else if (curX >= _width / 2) + curX -= _width; - float norm = (float)cur_x / ((float)_width / 2.0); + float norm = (float)curX / ((float)_width / 2.0); float lvl = fabs(norm); if (lvl > 0.5) lvl = (lvl - 0.5) * 1.7; @@ -157,16 +157,16 @@ void MusicNode::setVolume(uint8 new_volume) { if (_engine->_mixer->isSoundHandleActive(_handle)) { _engine->_mixer->setChannelBalance(_handle, bal); - _engine->_mixer->setChannelVolume(_handle, new_volume * lvl); + _engine->_mixer->setChannelVolume(_handle, newVolume * lvl); } } else { if (_engine->_mixer->isSoundHandleActive(_handle)) { _engine->_mixer->setChannelBalance(_handle, 0); - _engine->_mixer->setChannelVolume(_handle, new_volume); + _engine->_mixer->setChannelVolume(_handle, newVolume); } } - _volume = new_volume; + _volume = newVolume; } PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) @@ -175,7 +175,7 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) SideFX *fx = _engine->getScriptManager()->getSideFX(slot); if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode_BASE *mus = (MusicNode_BASE *)fx; + MusicNodeBASE *mus = (MusicNodeBASE *)fx; mus->setPanTrack(pos); } } @@ -183,14 +183,14 @@ PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) PanTrackNode::~PanTrackNode() { SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNode_BASE *mus = (MusicNode_BASE *)fx; + MusicNodeBASE *mus = (MusicNodeBASE *)fx; mus->unsetPanTrack(); } } MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) - : MusicNode_BASE(engine, key, SIDEFX_AUDIO) { + : MusicNodeBASE(engine, key, SIDEFX_AUDIO) { _volume = volume; _prog = program; _noteNumber = note; @@ -230,11 +230,11 @@ bool MusicMidiNode::process(uint32 deltaTimeInMillis) { return false; } -void MusicMidiNode::setVolume(uint8 new_volume) { +void MusicMidiNode::setVolume(uint8 newVolume) { if (_chan >= 0) { - _engine->getMidiManager()->setVolume(_chan, new_volume); + _engine->getMidiManager()->setVolume(_chan, newVolume); } - _volume = new_volume; + _volume = newVolume; } } // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index 262b13085e..954e2f474e 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -33,10 +33,10 @@ class String; namespace ZVision { -class MusicNode_BASE : public SideFX { +class MusicNodeBASE : public SideFX { public: - MusicNode_BASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {} - ~MusicNode_BASE() {} + MusicNodeBASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {} + ~MusicNodeBASE() {} /** * Decrement the timer by the delta time. If the timer is finished, set the status @@ -55,7 +55,7 @@ public: virtual void setFade(int32 time, uint8 target) = 0; }; -class MusicNode : public MusicNode_BASE { +class MusicNode : public MusicNodeBASE { public: MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); ~MusicNode(); @@ -79,19 +79,19 @@ public: private: int32 _timeLeft; bool _pantrack; - int32 _pantrack_X; + int32 _pantrackPosition; int32 _attenuate; uint8 _volume; bool _loop; bool _crossfade; - uint8 _crossfade_target; - int32 _crossfade_time; + uint8 _crossfadeTarget; + int32 _crossfadeTime; bool _stereo; Audio::SoundHandle _handle; Subtitle *_sub; }; -class MusicMidiNode : public MusicNode_BASE { +class MusicMidiNode : public MusicNodeBASE { public: MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); ~MusicMidiNode(); diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h index a6326c733b..a229129b9d 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.h +++ b/engines/zvision/scripting/sidefx/ttytext_node.h @@ -50,15 +50,12 @@ public: bool process(uint32 deltaTimeInMillis); private: Common::Rect _r; - //int16 x; - //int16 y; - //uint16 w; - //uint16 h; + cTxtStyle _style; - sTTFont _fnt; + StyledTTFont _fnt; Common::String _txtbuf; uint32 _txtpos; - //int32 txtsize; + int32 _delay; int32 _nexttime; Graphics::Surface _img; diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp index 4ca48f7b42..1f68b2435f 100644 --- a/engines/zvision/subtitles/subtitles.cpp +++ b/engines/zvision/subtitles/subtitles.cpp @@ -52,12 +52,12 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : if (_engine->getSearchManager()->openFile(txt, filename)) { while (!txt.eos()) { Common::String txtline = readWideLine(txt); - sub cur_sub; - cur_sub.start = -1; - cur_sub.stop = -1; - cur_sub.sub = txtline; + sub curSubtitle; + curSubtitle.start = -1; + curSubtitle.stop = -1; + curSubtitle.sub = txtline; - _subs.push_back(cur_sub); + _subs.push_back(curSubtitle); } txt.close(); } diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index efb0fb42f9..872d6875b7 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -233,71 +233,71 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { } void cTxtStyle::readAllStyle(const Common::String &txt) { - int16 strt = -1; - int16 endt = -1; + int16 startTextPosition = -1; + int16 endTextPosition = -1; for (uint16 i = 0; i < txt.size(); i++) { if (txt[i] == '<') - strt = i; + startTextPosition = i; else if (txt[i] == '>') { - endt = i; - if (strt != -1) - if ((endt - strt - 1) > 0) - parseStyle(Common::String(txt.c_str() + strt + 1), endt - strt - 1); + endTextPosition = i; + if (startTextPosition != -1) + if ((endTextPosition - startTextPosition - 1) > 0) + parseStyle(Common::String(txt.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1); } } } -void cTxtStyle::setFontStyle(sTTFont &font) { - uint temp_stl = 0; +void cTxtStyle::setFontStyle(StyledTTFont &font) { + uint tempStyle = 0; if (bold) - temp_stl |= sTTFont::STTF_BOLD; + tempStyle |= StyledTTFont::STTF_BOLD; if (italic) - temp_stl |= sTTFont::STTF_ITALIC; + tempStyle |= StyledTTFont::STTF_ITALIC; if (underline) - temp_stl |= sTTFont::STTF_UNDERLINE; + tempStyle |= StyledTTFont::STTF_UNDERLINE; if (strikeout) - temp_stl |= sTTFont::STTF_STRIKEOUT; + tempStyle |= StyledTTFont::STTF_STRIKEOUT; if (sharp) - temp_stl |= sTTFont::STTF_SHARP; + tempStyle |= StyledTTFont::STTF_SHARP; - font.setStyle(temp_stl); + font.setStyle(tempStyle); } -void cTxtStyle::setFont(sTTFont &font) { - uint temp_stl = 0; +void cTxtStyle::setFont(StyledTTFont &font) { + uint tempStyle = 0; if (bold) - temp_stl |= sTTFont::STTF_BOLD; + tempStyle |= StyledTTFont::STTF_BOLD; if (italic) - temp_stl |= sTTFont::STTF_ITALIC; + tempStyle |= StyledTTFont::STTF_ITALIC; if (underline) - temp_stl |= sTTFont::STTF_UNDERLINE; + tempStyle |= StyledTTFont::STTF_UNDERLINE; if (strikeout) - temp_stl |= sTTFont::STTF_STRIKEOUT; + tempStyle |= StyledTTFont::STTF_STRIKEOUT; if (sharp) - temp_stl |= sTTFont::STTF_SHARP; + tempStyle |= StyledTTFont::STTF_SHARP; - font.loadFont(fontname, size, temp_stl); + font.loadFont(fontname, size, tempStyle); } -Graphics::Surface *textRenderer::render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style) { +Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) { style.setFontStyle(fnt); uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue); return fnt.renderSolidText(txt, clr); } -void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { +void TextRenderer::drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify) { if (justify == TXT_JUSTIFY_LEFT) fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignLeft); else if (justify == TXT_JUSTIFY_CENTER) @@ -306,33 +306,33 @@ void textRenderer::drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, u fnt.drawString(&dst, txt, 0, lineY, dst.w, color, Graphics::kTextAlignRight); } -int32 textRenderer::drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst) { - sTTFont font(_engine); - fnt_stl.setFont(font); +int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst) { + StyledTTFont font(_engine); + fontStyle.setFont(font); dst.fillRect(Common::Rect(dst.w, dst.h), 0); - uint32 clr = _engine->_pixelFormat.RGBToColor(fnt_stl.red, fnt_stl.green, fnt_stl.blue); + uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle.red, fontStyle.green, fontStyle.blue); int16 w; w = font.getStringWidth(txt); - drawTxtWithJustify(txt, font, clr, dst, 0, fnt_stl.justify); + drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle.justify); return w; } -void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { +void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surface &dst) { const int16 TXT_CFG_TEXTURES_LINES = 256; // For now I don't want remake it const int TXT_CFG_TEXTURES_PER_LINE = 6; cTxtStyle style, style2; - int16 strt = -1; - int16 endt = -1; + int16 startTextPosition = -1; + int16 endTextPosition = -1; int16 i = 0; int16 dx = 0, dy = 0; - int16 txt_w; - int16 txtpos = 0; + int16 textPixelWidth; + int16 textPosition = 0; Common::String buf; Common::String buf2; @@ -350,7 +350,7 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac int16 stringlen = text.size(); - sTTFont font(_engine); + StyledTTFont font(_engine); style.setFont(font); @@ -361,19 +361,19 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac if (text[i] == '<') { int16 ret = 0; - strt = i; + startTextPosition = i; while (i < stringlen && text[i] != '>') i++; - endt = i; - if (strt != -1) - if ((endt - strt - 1) > 0) { + endTextPosition = i; + if (startTextPosition != -1) + if ((endTextPosition - startTextPosition - 1) > 0) { style2 = style; - ret = style.parseStyle(Common::String(text.c_str() + strt + 1), endt - strt - 1); + ret = style.parseStyle(Common::String(text.c_str() + startTextPosition + 1), endTextPosition - startTextPosition - 1); } if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { if (buf.size() > 0) { - txt_w = font.getStringWidth(buf); + textPixelWidth = font.getStringWidth(buf); TxtSurfaces[currentline][currentlineitm] = render(font, buf, style2); TxtPoint[currentline] = MAX(font.getFontHeight(), TxtPoint[currentline]); @@ -382,8 +382,8 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac buf.clear(); prevbufspace = 0; - txtpos = 0; - dx += txt_w; + textPosition = 0; + dx += textPixelWidth; } if (ret & TXT_RET_FNTCHG) { @@ -403,25 +403,25 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac Common::String buf3; buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); buf += buf3; - txtpos += buf3.size(); + textPosition += buf3.size(); } } else { buf += text[i]; - txtpos++; + textPosition++; if (text[i] == ' ') { - prevbufspace = txtpos - 1; + prevbufspace = textPosition - 1; prevtxtspace = i; } if (font.isLoaded()) { - txt_w = font.getStringWidth(buf); - if (txt_w + dx > dst.w) { + textPixelWidth = font.getStringWidth(buf); + if (textPixelWidth + dx > dst.w) { if (prevbufspace == 0) { prevtxtspace = i; - prevbufspace = txtpos - 1; + prevbufspace = textPosition - 1; } buf2 = Common::String(buf.c_str(), prevbufspace + 1); @@ -433,7 +433,7 @@ void textRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac buf.clear(); i = prevtxtspace; prevbufspace = 0; - txtpos = 0; + textPosition = 0; currentline++; currentlineitm = 0; dx = 0; @@ -494,7 +494,7 @@ Common::String readWideLine(Common::SeekableReadStream &stream) { break; } - // Crush each octet pair to a single octet with a simple cast + // Crush each octet pair to a UTF-8 sequence if (value < 0x80) { asciiString += (char)(value & 0x7F); } else if (value >= 0x80 && value < 0x800) { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index 4b318fdef0..c2468383d3 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -56,8 +56,8 @@ public: cTxtStyle(); txtReturn parseStyle(const Common::String &strin, int16 len); void readAllStyle(const Common::String &txt); - void setFontStyle(sTTFont &font); - void setFont(sTTFont &font); + void setFontStyle(StyledTTFont &font); + void setFont(StyledTTFont &font); public: Common::String fontname; @@ -78,13 +78,13 @@ public: // char image ?? }; -class textRenderer { +class TextRenderer { public: - textRenderer(ZVision *engine): _engine(engine) {}; + TextRenderer(ZVision *engine): _engine(engine) {}; - void drawTxtWithJustify(const Common::String &txt, sTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); - int32 drawTxt(const Common::String &txt, cTxtStyle &fnt_stl, Graphics::Surface &dst); - Graphics::Surface *render(sTTFont &fnt, const Common::String &txt, cTxtStyle &style); + void drawTxtWithJustify(const Common::String &txt, StyledTTFont &fnt, uint32 color, Graphics::Surface &dst, int lineY, txtJustify justify); + int32 drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Graphics::Surface &dst); + Graphics::Surface *render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style); void drawTxtInOneLine(const Common::String &txt, Graphics::Surface &dst); private: diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp index 3441fb8bf0..86ed7c596f 100644 --- a/engines/zvision/utility/win_keys.cpp +++ b/engines/zvision/utility/win_keys.cpp @@ -24,17 +24,17 @@ namespace ZVision { -uint8 VKkey(Common::KeyCode scumm_key) { - if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z) - return 0x41 + scumm_key - Common::KEYCODE_a; - if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9) - return 0x30 + scumm_key - Common::KEYCODE_0; - if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15) - return 0x70 + scumm_key - Common::KEYCODE_F1; - if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9) - return 0x60 + scumm_key - Common::KEYCODE_KP0; +uint8 VKkey(Common::KeyCode scummKeyCode) { + if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z) + return 0x41 + scummKeyCode - Common::KEYCODE_a; + if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9) + return 0x30 + scummKeyCode - Common::KEYCODE_0; + if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15) + return 0x70 + scummKeyCode - Common::KEYCODE_F1; + if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9) + return 0x60 + scummKeyCode - Common::KEYCODE_KP0; - switch (scumm_key) { + switch (scummKeyCode) { case Common::KEYCODE_BACKSPACE: return 0x8; case Common::KEYCODE_TAB: diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h index a79a03a07b..53d76c4d5f 100644 --- a/engines/zvision/utility/win_keys.h +++ b/engines/zvision/utility/win_keys.h @@ -20,13 +20,13 @@ * */ -#ifndef ZVISION_WINKEY_H -#define ZVISION_WINKEY_H +#ifndef ZVISION_WIN_KEYS_H +#define ZVISION_WIN_KEYS_H #include "common/keyboard.h" namespace ZVision { -uint8 VKkey(Common::KeyCode scumm_key); +uint8 VKkey(Common::KeyCode scummKeyCode); } // End of namespace ZVision #endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 84856429e9..62342f02b9 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -95,7 +95,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _stringManager(nullptr), _cursorManager(nullptr), _midiManager(nullptr), - _aud_id(0), + _audioId(0), _rendDelay(2), _kbdVelocity(0), _mouseVelocity(0) { @@ -147,7 +147,7 @@ void ZVision::saveSettings() { void ZVision::initialize() { const Common::FSNode gameDataDir(ConfMan.get("path")); - _searchManager = new sManager(ConfMan.get("path"), 6); + _searchManager = new SearchManager(ConfMan.get("path"), 6); _searchManager->addDir("FONTS"); _searchManager->addDir("addon"); @@ -182,13 +182,13 @@ void ZVision::initialize() { _saveManager = new SaveManager(this); _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, &_pixelFormat); - _textRenderer = new textRenderer(this); - _midiManager = new midiManager(); + _textRenderer = new TextRenderer(this); + _midiManager = new MidiManager(); if (_gameDescription->gameId == GID_GRANDINQUISITOR) - _menu = new menuZgi(this); + _menu = new MenuZGI(this); else - _menu = new menuNem(this); + _menu = new MenuNemesis(this); // Initialize the managers _cursorManager->initialize(); @@ -290,8 +290,8 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { _renderManager->renderBackbufferToScreen(); _clock.stop(); - uint32 stop_time = _system->getMillis() + milsecs; - while (_system->getMillis() < stop_time) { + uint32 stopTime = _system->getMillis() + milsecs; + while (_system->getMillis() < stopTime) { Common::Event evnt; while (_eventMan->pollEvent(evnt)) { if (evnt.type == Common::EVENT_KEYDOWN && @@ -353,38 +353,38 @@ void ZVision::updateRotation() { if (_velocity) { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { - int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity); + int16 newPosition = startPosition + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity); - int16 zero_point = _renderManager->getRenderTable()->getPanoramaZeroPoint(); - if (st_pos >= zero_point && new_pos < zero_point) + int16 zeroPoint = _renderManager->getRenderTable()->getPanoramaZeroPoint(); + if (startPosition >= zeroPoint && newPosition < zeroPoint) _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1); - if (st_pos <= zero_point && new_pos > zero_point) + if (startPosition <= zeroPoint && newPosition > zeroPoint) _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1); - int16 scr_width = _renderManager->getBkgSize().x; - if (scr_width) - new_pos %= scr_width; + int16 screenWidth = _renderManager->getBkgSize().x; + if (screenWidth) + newPosition %= screenWidth; - if (new_pos < 0) - new_pos += scr_width; + if (newPosition < 0) + newPosition += screenWidth; - _renderManager->setBackgroundPosition(new_pos); + _renderManager->setBackgroundPosition(newPosition); } else if (renderState == RenderTable::TILT) { - int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos + _velocity; + int16 newPosition = startPosition + _velocity; - int16 scr_height = _renderManager->getBkgSize().y; - int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); + int16 screenHeight = _renderManager->getBkgSize().y; + int16 tiltGap = _renderManager->getRenderTable()->getTiltGap(); - if (new_pos >= (scr_height - tilt_gap)) - new_pos = scr_height - tilt_gap; - if (new_pos <= tilt_gap) - new_pos = tilt_gap; + if (newPosition >= (screenHeight - tiltGap)) + newPosition = screenHeight - tiltGap; + if (newPosition <= tiltGap) + newPosition = tiltGap; - _renderManager->setBackgroundPosition(new_pos); + _renderManager->setBackgroundPosition(newPosition); } } } @@ -392,35 +392,35 @@ void ZVision::updateRotation() { void ZVision::checkBorders() { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { - int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos; + int16 newPosition = startPosition; - int16 scr_width = _renderManager->getBkgSize().x; + int16 screenWidth = _renderManager->getBkgSize().x; - if (scr_width) - new_pos %= scr_width; + if (screenWidth) + newPosition %= screenWidth; - if (new_pos < 0) - new_pos += scr_width; + if (newPosition < 0) + newPosition += screenWidth; - if (st_pos != new_pos) - _renderManager->setBackgroundPosition(new_pos); + if (startPosition != newPosition) + _renderManager->setBackgroundPosition(newPosition); } else if (renderState == RenderTable::TILT) { - int16 st_pos = _scriptManager->getStateValue(StateKey_ViewPos); + int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - int16 new_pos = st_pos; + int16 newPosition = startPosition; - int16 scr_height = _renderManager->getBkgSize().y; - int16 tilt_gap = _renderManager->getRenderTable()->getTiltGap(); + int16 screenHeight = _renderManager->getBkgSize().y; + int16 tiltGap = _renderManager->getRenderTable()->getTiltGap(); - if (new_pos >= (scr_height - tilt_gap)) - new_pos = scr_height - tilt_gap; - if (new_pos <= tilt_gap) - new_pos = tilt_gap; + if (newPosition >= (screenHeight - tiltGap)) + newPosition = screenHeight - tiltGap; + if (newPosition <= tiltGap) + newPosition = tiltGap; - if (st_pos != new_pos) - _renderManager->setBackgroundPosition(new_pos); + if (startPosition != newPosition) + _renderManager->setBackgroundPosition(newPosition); } } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8cf9dbf107..8b14cfa178 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -52,10 +52,10 @@ class CursorManager; class StringManager; class SaveManager; class RlfAnimation; -class menuHandler; -class textRenderer; +class MenuHandler; +class TextRenderer; class Subtitle; -class midiManager; +class MidiManager; class ZVision : public Engine { public: @@ -104,16 +104,16 @@ private: CursorManager *_cursorManager; SaveManager *_saveManager; StringManager *_stringManager; - menuHandler *_menu; - sManager *_searchManager; - textRenderer *_textRenderer; - midiManager *_midiManager; + MenuHandler *_menu; + SearchManager *_searchManager; + TextRenderer *_textRenderer; + MidiManager *_midiManager; // Clock Clock _clock; // Audio ID - int _aud_id; + int _audioId; // To prevent allocation every time we process events Common::Event _event; @@ -148,13 +148,13 @@ public: StringManager *getStringManager() const { return _stringManager; } - sManager *getSearchManager() const { + SearchManager *getSearchManager() const { return _searchManager; } - textRenderer *getTextRenderer() const { + TextRenderer *getTextRenderer() const { return _textRenderer; } - midiManager *getMidiManager() const { + MidiManager *getMidiManager() const { return _midiManager; } Common::RandomSource *getRandomSource() const { -- cgit v1.2.3 From 596a904a0c6aedba5bbe45cdfa931425450626c8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 20 Nov 2014 14:55:35 +0600 Subject: ZVISION: Remove wrong TODO from scripting/sidefx.h --- engines/zvision/scripting/sidefx.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h index 2c53467559..5bb14f0cdd 100644 --- a/engines/zvision/scripting/sidefx.h +++ b/engines/zvision/scripting/sidefx.h @@ -109,16 +109,6 @@ protected: public: }; - -// TODO: Implement InputControl -// TODO: Implement SaveControl -// TODO: Implement SlotControl -// TODO: Implement SafeControl -// TODO: Implement FistControl -// TODO: Implement HotMovieControl -// TODO: Implement PaintControl -// TODO: Implement TilterControl - } // End of namespace ZVision #endif // SIDEFX_H_INCLUDED -- cgit v1.2.3 From 3fb4ab1377d15bb0fca78c5964531d3f2d49f986 Mon Sep 17 00:00:00 2001 From: Stefan Kristiansson Date: Sat, 22 Nov 2014 10:01:27 +0200 Subject: COMMON: make XMLParser::loadStream() fail when stream is null Some users of this method relies on it to fail when an invalid stream is passed to it (E.g. VirtualKeyboard::openPack). --- common/xmlparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 common/xmlparser.cpp diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp old mode 100644 new mode 100755 index c80d5e15be..67a3d36cec --- a/common/xmlparser.cpp +++ b/common/xmlparser.cpp @@ -69,7 +69,7 @@ bool XMLParser::loadBuffer(const byte *buffer, uint32 size, DisposeAfterUse::Fla bool XMLParser::loadStream(SeekableReadStream *stream) { _stream = stream; _fileName = "File Stream"; - return true; + return _stream != nullptr; } void XMLParser::close() { -- cgit v1.2.3 From daefdc315bdcb8a62f6e69d45a1f0b535fff46d5 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Sat, 22 Nov 2014 10:21:32 +1100 Subject: SCUMM: Fix bug #2034 - MANIAC V2: Early Collision with Green Tentacle --- engines/scumm/script_v0.cpp | 6 +++--- engines/scumm/script_v2.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index a7999a2695..af39fdaad8 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -589,9 +589,9 @@ void ScummEngine_v0::o_loadRoomWithEgo() { return; } - // The original interpreter seems to set the actors new room X/Y to the last rooms X/Y - // This fixes a problem with MM: script 158 in room 12, the 'Oompf!' script - // This scripts runs before the actor position is set to the correct location + // The original interpreter sets the actors new room X/Y to the last rooms X/Y + // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script + // This scripts runs before the actor position is set to the correct room entry location a->putActor(a->getPos().x, a->getPos().y, room); _egoPositioned = false; diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp index 74d0aa2483..a7ec2e644f 100644 --- a/engines/scumm/script_v2.cpp +++ b/engines/scumm/script_v2.cpp @@ -1390,7 +1390,14 @@ void ScummEngine_v2::o2_loadRoomWithEgo() { a = derefActor(VAR(VAR_EGO), "o2_loadRoomWithEgo"); - a->putActor(0, 0, room); + // The original interpreter sets the actors new room X/Y to the last rooms X/Y + // This fixes a problem with MM: script 161 in room 12, the 'Oomph!' script + // This scripts runs before the actor position is set to the correct room entry location + if ((_game.id == GID_MANIAC) && (_game.platform != Common::kPlatformNES)) { + a->putActor(a->getPos().x, a->getPos().y, room); + } else { + a->putActor(0, 0, room); + } _egoPositioned = false; x = (int8)fetchScriptByte(); -- cgit v1.2.3 From c76f21747fddd0688732c7115f2a5307777a6fad Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Sun, 23 Nov 2014 10:58:48 +1100 Subject: SCUMM: MANIAC V1 Demo: GF_DEMO was not being set --- engines/scumm/detection.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 10482ba1fc..c0db0d6d37 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -502,6 +502,7 @@ static void computeGameSettingsFromMD5(const Common::FSList &fslist, const GameF // (since they have identical MD5): if (dr.game.id == GID_MANIAC && !strcmp(gfp->pattern, "%02d.MAN")) { dr.extra = "V1 Demo"; + dr.game.features = GF_DEMO; } // HACK: Try to detect languages for translated games -- cgit v1.2.3 From 26fc4be311f5e0cf9a92a64ca412b8b12858e324 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 23 Nov 2014 12:07:58 +0100 Subject: DOCS: Add CONTRIBUTING.md This will be displayed on github as "guidelines for contributing". --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..3a6672b0cb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ +Thank you for considering contributing to ScummVM. + +Please make sure to read our guidelines for contributions on our +[wiki](http://wiki.scummvm.org/index.php/Developer_Central). In particular: + +* [Coding style](http://wiki.scummvm.org/index.php/Code_Formatting_Conventions) +* [Portability](http://wiki.scummvm.org/index.php/Coding_Conventions) +* [Commit message style](http://wiki.scummvm.org/index.php/Commit_Guidelines) +* License: GPLv2+ + +If you have any questions about code, style, procedure, or anything else, feel +free to contact us on our mailing list at scummvm-devel@lists.sourceforge.net. -- cgit v1.2.3 From 7ff41ae9027ffe3186a0c0f471069d656dbda91b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 23 Nov 2014 17:51:13 +0100 Subject: COMMON: Remove executable bit --- common/xmlparser.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 common/xmlparser.cpp diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp old mode 100755 new mode 100644 -- cgit v1.2.3 From 2dbd99d57264bab012cebd064eadfc34050832b1 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Fri, 28 Nov 2014 22:24:45 +1100 Subject: SCUMM: Maniac V0: Implement the original Walk Code (to fix some anim glitches), fix opcode to use _moving correctly (as V0 is different) --- engines/scumm/actor.cpp | 440 +++++++++++++++++++++++++++++++++++++++++++- engines/scumm/actor.h | 40 +++- engines/scumm/script.cpp | 2 +- engines/scumm/script_v0.cpp | 12 +- engines/scumm/verbs.cpp | 1 - 5 files changed, 473 insertions(+), 22 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 116a953b0b..1ea1f6eb54 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -250,8 +250,11 @@ void Actor::stopActorMoving() { _vm->stopScript(_walkScript); _moving = 0; - if (_vm->_game.version == 0) + + if (_vm->_game.version == 0) { + _moving = 2; setDirection(_facing); + } } void Actor::setActorWalkSpeed(uint newSpeedX, uint newSpeedY) { @@ -447,7 +450,11 @@ void Actor::startWalkActor(int destX, int destY, int dir) { _walkdata.dest.y = abr.y; _walkdata.destbox = abr.box; _walkdata.destdir = dir; - _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; + if(_vm->_game.version != 0 ) { + _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; + } else { + ((Actor_v0*)this)->unk_FDE1 = 1; + } _walkdata.point3.x = 32000; _walkdata.curbox = _walkbox; @@ -651,6 +658,403 @@ bool Actor_v0::checkWalkboxesHaveDirectPath(Common::Point &foundPath) { return false; } +bool Actor_v0::sub_2F6F() { + _walkDirX = 0; + _walkDirY = 0; + _walkYCountGreaterThanXCount = 0; + uint16 A = 0; + + if (_CurrentWalkTo.x >= _tmp_Dest.x ) { + A = _CurrentWalkTo.x - _tmp_Dest.x; + _walkDirX = 1; + } else { + A = _tmp_Dest.x - _CurrentWalkTo.x; + } + + _walkXCountInc = A; + + if (_CurrentWalkTo.y >= _tmp_Dest.y ) { + A = _CurrentWalkTo.y - _tmp_Dest.y; + _walkDirY = 1; + } else { + A = _tmp_Dest.y - _CurrentWalkTo.y; + } + + _walkYCountInc = A; + if ( !_walkXCountInc && !_walkYCountInc ) + return true; + + if( _walkXCountInc <= _walkYCountInc ) + _walkYCountGreaterThanXCount = 1; + + // 2FCC + A = _walkXCountInc; + if( A <= _walkYCountInc ) + A = _walkYCountInc; + + _walkMaxXYCountInc = A; + _walkXCount = _walkXCountInc; + _walkYCount = _walkYCountInc; + _walkCountModulo = _walkMaxXYCountInc; + + return false; +} + +byte Actor_v0::updateWalkbox() { + if( _vm->checkXYInBoxBounds( _walkbox, _pos.x, _pos.y ) ) + return 0; + + int numBoxes = _vm->getNumBoxes() - 1; + for (int i = 0; i <= numBoxes; i++) { + if (_vm->checkXYInBoxBounds( i, _pos.x, _pos.y ) == true ) { + if (_walkdata.curbox == i ) { + setBox(i); + + unk_FDE1 = 1; + return i; + } + } + } + + return 0xFF; +} + +void Actor_v0::setTmpFromActor() { + _tmp_Pos = _pos; + _pos = _tmp_Dest; + _tmp_WalkBox = _walkbox; + _tmp_CB5F = unk_FDE1; +} + +void Actor_v0::setActorFromTmp() { + _pos = _tmp_Pos; + _tmp_Dest = _tmp_Pos; + _walkbox = _tmp_WalkBox; + unk_FDE1 = _tmp_CB5F; +} + +byte Actor_v0::actorWalkX() { + byte A = _walkXCount; + A += _walkXCountInc; + if (A >= _walkCountModulo) { + if (!_walkDirX ) { + _tmp_Dest.x--; + } else { + _tmp_Dest.x++; + } + + A -= _walkCountModulo; + } + // 2EAC + _walkXCount = A; + setTmpFromActor(); + if( updateWalkbox() == 0xFF ) { + // 2EB9 + setActorFromTmp(); + + return 3; + } + // 2EBF + if( _tmp_Dest.x == _CurrentWalkTo.x ) + return 1; + + return 0; +} + +byte Actor_v0::actorWalkY() { + + byte A = _walkYCount; + A += _walkYCountInc; + if (A >= _walkCountModulo) { + if (!_walkDirY ) { + _tmp_Dest.y--; + } else { + _tmp_Dest.y++; + } + + A -= _walkCountModulo; + } + // 2EEB + _walkYCount = A; + setTmpFromActor(); + if (updateWalkbox() == 0xFF) { + // 2EF8 + setActorFromTmp(); + return 4; + } + + // 2EFE + if (_walkYCountInc != 0) { + if (_walkYCountInc == 0xFF ) { + setActorFromTmp(); + return 4; + } + } + + // 2F0D + if (_CurrentWalkTo.y == _tmp_Dest.y) + return 1; + + return 0; +} + +byte Actor_v0::walkboxFindTarget() { + return 0xff; +} + +void Actor_v0::actorSetWalkTo() { + + if (unk_FDE1 == 0 ) + return; + + unk_FDE1 = 0; + byte nextBox = _vm->getNextBox(_walkbox, _walkdata.destbox); + + if (nextBox != 0xFF && nextBox != _walkbox ) { + Common::Point tmp; + _walkdata.curbox = nextBox; + + getClosestPtOnBox(_vm->getBoxCoordinates(nextBox), _pos.x, _pos.y, _NewWalkTo.x, _NewWalkTo.y); + //getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, _NewWalkTo.x, _NewWalkTo.y); + + + } else { + if( _walkdata.dest.x == -1 ) + _NewWalkTo = _CurrentWalkTo; + else + _NewWalkTo = _walkdata.dest; + } +} + +void Actor_v0::walkActor() { + actorSetWalkTo(); + + _needRedraw = true; + if (_NewWalkTo != _CurrentWalkTo) { + + // 2A27 + _CurrentWalkTo = _NewWalkTo; + +loc_2A33:; + _moving &= 0xF0; + _tmp_Dest = _pos; + + byte tmp = sub_2F6F(); + _moving &= 0xF0; + _moving |= tmp; + + if (!_walkYCountGreaterThanXCount) { + if (_walkDirX) { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*1, V12_Y_MULTIPLIER*0, false); + } else { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*-1, V12_Y_MULTIPLIER*0, false); + } + } else { + if (_walkDirY) { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*1, false); + } else { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*-1, false); + } + } + + directionUpdate(); + + if (_moving & 0x80 ) + return; + + animateActor(newDirToOldDir(_facing)); + + } else { + // 2A0A + if ((_moving & 0x7F) != 1) { + + if (_NewWalkTo == _pos) { + return; + } + } + } + + + // 2A9A + if (_moving == 2 ) + return; + + if ((_moving & 0x0F) == 1 ) + return stopActorMoving(); + + // 2AAD + if (_moving & 0x80) { + directionUpdate(); + + if ((_moving & 0x80) ) + return; + + // 2AC2 + animateActor(newDirToOldDir(_facing)); + } + + // 2ACE + if ((_moving & 0x0F) == 3 ) { +loc_2C36:; + // 2C36 + setTmpFromActor(); + + if (!_walkDirX ) { + _pos.x--; + } else { + _pos.x++; + } + + // 2C51 + if (updateWalkbox() != 0xFF) { + //2C66 + setActorFromTmp(); + goto loc_2A33; + } + + // 2C6C + setActorFromTmp(); + + if (_CurrentWalkTo.y == _tmp_Dest.y) { + stopActorMoving(); + return; + } + + if (!_walkDirY) { + _tmp_Dest.y--; + } else { + _tmp_Dest.y++; + } + setTmpFromActor(); + //2C8B + byte A = updateWalkbox(); + if (A == 0xFF) { + setActorFromTmp(); + stopActorMoving(); + return; + } + // 2C98: Yes, an exact copy of what just occured.. the original does this, so im doing it... + // Just to keep me sane when going over it :) + if (A == 0xFF) { + setActorFromTmp(); + stopActorMoving(); + return; + } + return; + } + + // 2ADA + if ((_moving & 0x0F) == 4 ) { + // 2CA3 +loc_2CA3:; + setTmpFromActor(); + + if (!_walkDirY) { + _pos.y--; + } else { + _pos.y++; + } + if (updateWalkbox() == 0xFF ) { + // 2CC7 + setActorFromTmp(); + if( _CurrentWalkTo.x == _tmp_Dest.x ) { + stopActorMoving(); + return; + } + // 2CD5 + if (!_walkDirX ) { + _tmp_Dest.x--; + } else { + _tmp_Dest.x++; + } + setTmpFromActor(); + + if (updateWalkbox() == 0xFF ) { + setActorFromTmp(); + stopActorMoving(); + } + + return; + } else { + setActorFromTmp(); + goto loc_2A33; + } + } + + if ((_moving & 0x0F) == 0 ) { + // 2AE8 + byte A = actorWalkX(); + + if( A == 1 ) { + A = actorWalkY(); + if( A == 1 ) { + // 2AF6 + _moving &= 0xF0; + _moving |= A; + } else { + // 2B04 + if( A == 4 ) + stopActorMoving(); + } + + return; + + } else { + // 2B0C + if (A == 3) { + _moving &= 0xF0; + _moving |= A; + + if (_walkDirY) { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*1, false); + } else { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*0, V12_Y_MULTIPLIER*-1, false); + } + + directionUpdate(); + animateActor(newDirToOldDir(_facing)); + goto loc_2C36; + + } else { + // 2B39 + A = actorWalkY(); + if (A != 4 ) + return; + + // 2B46 + _moving &= 0xF0; + _moving |= A; + + if (_walkDirX) { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*1, V12_Y_MULTIPLIER*0, false); + } else { + _targetFacing = getAngleFromPos(V12_X_MULTIPLIER*-1, V12_Y_MULTIPLIER*0, false); + } + + directionUpdate(); + animateActor(newDirToOldDir(_facing)); + goto loc_2CA3; + } + } + } +} + +void Actor_v0::directionUpdate() { + + int nextFacing = updateActorDirection(true); + if (_facing != nextFacing) { + // 2A89 + setDirection(nextFacing); + + if (_facing != _targetFacing ) { + _moving |= 0x80; + } else { + _moving &= ~0x80; + } + } else + _moving &= ~0x80; +} + void Actor_v2::walkActor() { Common::Point foundPath, tmp; int new_dir, next_box; @@ -985,18 +1389,16 @@ void Actor_v0::setDirection(int direction) { break; case 2: - res = 6; // Face Away + res = 6; // Face Camera break; default: - res = 7; // Face Camera + res = 7; // Face Away break; } _animFrameRepeat = -1; animateActor(res); - if (_moving) - animateCostume(); } void Actor::faceToObject(int obj) { @@ -1017,8 +1419,14 @@ void Actor::turnToDirection(int newdir) { return; if (_vm->_game.version <= 6) { - _moving = MF_TURN; _targetFacing = newdir; + + if (_vm->_game.version == 0 ) { + setDirection( newdir ); + return; + } + _moving = MF_TURN; + } else { _moving &= ~MF_TURN; if (newdir != _facing) { @@ -1085,8 +1493,14 @@ void Actor::putActor(int dstX, int dstY, int newRoom) { } // V0 always sets the actor to face the camera upon entering a room - if (_vm->_game.version == 0) + if (_vm->_game.version == 0) { + _walkdata.dest = _pos; + + ((Actor_v0*)this)->unk_FDE1 = 1; + ((Actor_v0*)this)->_CurrentWalkTo = _pos; + setDirection(oldDirToNewDir(2)); + } } static bool inBoxQuickReject(const BoxCoords &box, int x, int y, int threshold) { @@ -1410,6 +1824,7 @@ void Actor::showActor() { Actor_v0 *a = ((Actor_v0 *)this); a->_costCommand = a->_costCommandNew = 0xFF; + for (int i = 0; i < 8; ++i) { a->_limbFrameRepeat[i] = 0; @@ -1659,8 +2074,15 @@ void ScummEngine::processActors() { // would hence cause regressions. See also the other big // comment further up in this method for some details. if (a->_costume) { + + if (_game.version == 0) + a->animateCostume(); + a->drawActorCostume(); - a->animateCostume(); + + if (_game.version != 0) + a->animateCostume(); + } } } diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index 46dc7d0295..b2245da3d2 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -354,6 +354,27 @@ public: byte _miscflags; byte _speaking; + Common::Point _CurrentWalkTo, _NewWalkTo; + + byte _walkDirX; + byte _walkDirY; + + byte _walkYCountGreaterThanXCount; + byte _walkXCount; + byte _walkXCountInc; + byte _walkYCount; + byte _walkYCountInc; + byte _walkCountModulo; + + byte _walkMaxXYCountInc; + + byte unk_FDE1; + + Common::Point _tmp_Pos; + Common::Point _tmp_Dest; + byte _tmp_WalkBox; + byte _tmp_CB5F; + int8 _animFrameRepeat; int8 _limbFrameRepeatNew[8]; int8 _limbFrameRepeat[8]; @@ -363,16 +384,27 @@ public: public: Actor_v0(ScummEngine *scumm, int id) : Actor_v2(scumm, id) {} - virtual void initActor(int mode); - virtual void animateActor(int anim); - virtual void animateCostume(); + void initActor(int mode); + void animateActor(int anim); + void animateCostume(); void limbFrameCheck(int limb); + void directionUpdate(); void speakCheck(); - virtual void setDirection(int direction); + void setDirection(int direction); void startAnimActor(int f); + bool sub_2F6F(); + void walkActor(); + void actorSetWalkTo(); + byte actorWalkX(); + byte actorWalkY(); + byte updateWalkbox(); + byte walkboxFindTarget(); + void setTmpFromActor(); + void setActorFromTmp(); + // Used by the save/load system: virtual void saveLoadWithSerializer(Serializer *ser); diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index 2fe5333bfc..efd5e7bd2c 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -1179,7 +1179,7 @@ bool ScummEngine_v0::checkPendingWalkAction() { Actor_v0 *a = (Actor_v0 *)derefActor(actor, "checkPendingWalkAction"); // wait until walking or turning action is finished - if (a->_moving) + if (a->_moving!=2) return true; // after walking and turning finally execute the script diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index af39fdaad8..6cbfbf45b3 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -589,9 +589,9 @@ void ScummEngine_v0::o_loadRoomWithEgo() { return; } - // The original interpreter sets the actors new room X/Y to the last rooms X/Y - // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script - // This scripts runs before the actor position is set to the correct room entry location + // The original interpreter seems to set the actors new room X/Y to the last rooms X/Y + // This fixes a problem with MM: script 158 in room 12, the 'Oompf!' script + // This scripts runs before the actor position is set to the correct location a->putActor(a->getPos().x, a->getPos().y, room); _egoPositioned = false; @@ -714,10 +714,8 @@ void ScummEngine_v0::o_getActorMoving() { getResultPos(); int act = getVarOrDirectByte(PARAM_1); Actor *a = derefActor(act, "o_getActorMoving"); - if (a->_moving) - setResult(1); - else - setResult(2); + + setResult(a->_moving); } void ScummEngine_v0::o_putActorAtObject() { diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index fdb98a8019..c1bafe1e0f 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -717,7 +717,6 @@ void ScummEngine_v0::verbExec() { if (a->_miscflags & kActorMiscFlagFreeze) return; - a->stopActorMoving(); a->startWalkActor(VAR(6), VAR(7), -1); } -- cgit v1.2.3 From 29d46e8a10b7fae45d833bee0e7d3e4e62d75c5c Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Sat, 29 Nov 2014 07:12:57 +1100 Subject: SCUMM: Maniac V0: If boxes are neighbors, walk directly to the new box. Remove extra call to 'animateCostume'. Remove now unnecessary V0 walk calc functions --- engines/scumm/actor.cpp | 211 ++++++++++++-------------------------------- engines/scumm/actor.h | 20 ++--- engines/scumm/boxes.cpp | 24 +++++ engines/scumm/script_v0.cpp | 7 +- engines/scumm/scumm_v0.h | 4 +- engines/scumm/verbs.cpp | 1 - 6 files changed, 92 insertions(+), 175 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 1ea1f6eb54..636f718582 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -33,6 +33,7 @@ #include "scumm/resource.h" #include "scumm/saveload.h" #include "scumm/scumm_v7.h" +#include "scumm/scumm_v0.h" #include "scumm/he/sound_he.h" #include "scumm/he/sprite_he.h" #include "scumm/usage_bits.h" @@ -453,7 +454,7 @@ void Actor::startWalkActor(int destX, int destY, int dir) { if(_vm->_game.version != 0 ) { _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; } else { - ((Actor_v0*)this)->unk_FDE1 = 1; + ((Actor_v0*)this)->_newWalkBoxEntered = 1; } _walkdata.point3.x = 32000; @@ -574,91 +575,7 @@ void Actor::walkActor() { calcMovementFactor(_walkdata.dest); } -bool Actor_v2::checkWalkboxesHaveDirectPath(Common::Point &foundPath) { - // only MM v0 supports walking in direct line between walkboxes. - // MM v1 already does not support it anymore. - return false; -} - -bool Actor_v0::intersectLineSegments(const Common::Point &line1Start, const Common::Point &line1End, - const Common::Point &line2Start, const Common::Point &line2End, Common::Point &result) -{ - const Common::Point v1 = line1End - line1Start; // line1(n1) = line1Start + n1 * v1 - const Common::Point v2 = line2End - line2Start; // line2(n2) = line2Start + n2 * v2 - - double det = v2.x * v1.y - v1.x * v2.y; - if (det == 0) - return false; - - double n1 = ((double)v2.x * (line2Start.y - line1Start.y) - - (double)v2.y * (line2Start.x - line1Start.x)) / det; - double n2 = ((double)v1.x * (line2Start.y - line1Start.y) - - (double)v1.y * (line2Start.x - line1Start.x)) / det; - - // both coefficients have to be in [0, 1], otherwise the intersection is - // not inside of at least one of the two line segments - if (n1 < 0.0 || n1 > 1.0 || n2 < 0.0 || n2 > 1.0) - return false; - - result.x = line1Start.x + (int)(n1 * v1.x); - result.y = line1Start.y + (int)(n1 * v1.y); - return true; -} - -/* - * MM v0 allows the actor to walk in a direct line between boxes to the target - * if actor and target share a horizontal or vertical corridor. - * If such a corridor is found the actor is not forced to go horizontally or - * vertically from one box to the next but can also walk diagonally. - * - * Note: the original v0 interpreter sets the target destination for diagonal - * walking only once and then rechecks whenever the actor reaches a new box if the - * walk destination is still suitable for the current box. - * ScummVM does not perform such a check, so it is possible to leave the walkboxes - * in some cases, for example L-shaped rooms like the swimming pool (actor walks over water) - * or the medical room (actor walks over examination table). - * To solve this we intersect the new walk destination with the actor's walkbox borders, - * so a recheck is done when the actor leaves his box. This is done by the - * intersectLineSegments() routine calls. - */ -bool Actor_v0::checkWalkboxesHaveDirectPath(Common::Point &foundPath) { - BoxCoords boxCoords = _vm->getBoxCoordinates(_walkbox); - BoxCoords curBoxCoords = _vm->getBoxCoordinates(_walkdata.curbox); - - // check if next walkbox is left or right to actor's box - if (boxCoords.ll.x > curBoxCoords.lr.x || boxCoords.lr.x < curBoxCoords.ll.x) { - // determine horizontal corridor gates - int gateUpper = MAX(boxCoords.ul.y, curBoxCoords.ul.y); - int gateLower = MIN(boxCoords.ll.y, curBoxCoords.ll.y); - - // check if actor and target are in the same horizontal corridor between the boxes - if ((_pos.y >= gateUpper && _pos.y <= gateLower) && - (_walkdata.dest.y >= gateUpper && _walkdata.dest.y <= gateLower)) { - if (boxCoords.ll.x > curBoxCoords.lr.x) // next box is left - return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ll, boxCoords.ul, foundPath); - else // next box is right - return intersectLineSegments(_pos, _walkdata.dest, boxCoords.lr, boxCoords.ur, foundPath); - } - // check if next walkbox is above or below actor's box - } else if (boxCoords.ul.y > curBoxCoords.ll.y || boxCoords.ll.y < curBoxCoords.ul.y) { - // determine vertical corridor gates - int gateLeft = MAX(boxCoords.ll.x, curBoxCoords.ll.x); - int gateRight = MIN(boxCoords.lr.x, curBoxCoords.lr.x); - - // check if actor and target are in the same vertical corridor between the boxes - if ((_pos.x >= gateLeft && _pos.x <= gateRight) && - (_walkdata.dest.x >= gateLeft && _walkdata.dest.x <= gateRight)) { - if (boxCoords.ul.y > curBoxCoords.ll.y) // next box is above - return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ul, boxCoords.ur, foundPath); - else // next box is below - return intersectLineSegments(_pos, _walkdata.dest, boxCoords.ll, boxCoords.lr, foundPath); - } - } - - return false; -} - -bool Actor_v0::sub_2F6F() { +bool Actor_v0::calcWalkDistances() { _walkDirX = 0; _walkDirY = 0; _walkYCountGreaterThanXCount = 0; @@ -710,7 +627,7 @@ byte Actor_v0::updateWalkbox() { if (_walkdata.curbox == i ) { setBox(i); - unk_FDE1 = 1; + _newWalkBoxEntered = 1; return i; } } @@ -723,14 +640,14 @@ void Actor_v0::setTmpFromActor() { _tmp_Pos = _pos; _pos = _tmp_Dest; _tmp_WalkBox = _walkbox; - _tmp_CB5F = unk_FDE1; + _tmp_NewWalkBoxEntered = _newWalkBoxEntered; } void Actor_v0::setActorFromTmp() { _pos = _tmp_Pos; _tmp_Dest = _tmp_Pos; _walkbox = _tmp_WalkBox; - unk_FDE1 = _tmp_CB5F; + _newWalkBoxEntered = _tmp_NewWalkBoxEntered; } byte Actor_v0::actorWalkX() { @@ -748,21 +665,20 @@ byte Actor_v0::actorWalkX() { // 2EAC _walkXCount = A; setTmpFromActor(); - if( updateWalkbox() == 0xFF ) { + if (updateWalkbox() == 0xFF) { // 2EB9 setActorFromTmp(); return 3; } // 2EBF - if( _tmp_Dest.x == _CurrentWalkTo.x ) + if (_tmp_Dest.x == _CurrentWalkTo.x) return 1; return 0; } byte Actor_v0::actorWalkY() { - byte A = _walkYCount; A += _walkYCountInc; if (A >= _walkCountModulo) { @@ -782,15 +698,13 @@ byte Actor_v0::actorWalkY() { setActorFromTmp(); return 4; } - // 2EFE if (_walkYCountInc != 0) { - if (_walkYCountInc == 0xFF ) { + if (_walkYCountInc == 0xFF) { setActorFromTmp(); return 4; } } - // 2F0D if (_CurrentWalkTo.y == _tmp_Dest.y) return 1; @@ -798,31 +712,33 @@ byte Actor_v0::actorWalkY() { return 0; } -byte Actor_v0::walkboxFindTarget() { - return 0xff; -} +void Actor_v0::directionUpdate() { + + int nextFacing = updateActorDirection(true); + if (_facing != nextFacing) { + // 2A89 + setDirection(nextFacing); + + // Still need to turn? + if (_facing != _targetFacing ) { + _moving |= 0x80; + return; + } + } + + _moving &= ~0x80; +} void Actor_v0::actorSetWalkTo() { - if (unk_FDE1 == 0 ) + if (_newWalkBoxEntered == 0) return; - unk_FDE1 = 0; - byte nextBox = _vm->getNextBox(_walkbox, _walkdata.destbox); + _newWalkBoxEntered = 0; - if (nextBox != 0xFF && nextBox != _walkbox ) { - Common::Point tmp; + int nextBox = ((ScummEngine_v0*)_vm)->walkboxFindTarget( this, _walkdata.destbox, _walkdata.dest ); + if (nextBox != 0xFF) { _walkdata.curbox = nextBox; - - getClosestPtOnBox(_vm->getBoxCoordinates(nextBox), _pos.x, _pos.y, _NewWalkTo.x, _NewWalkTo.y); - //getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, _NewWalkTo.x, _NewWalkTo.y); - - - } else { - if( _walkdata.dest.x == -1 ) - _NewWalkTo = _CurrentWalkTo; - else - _NewWalkTo = _walkdata.dest; } } @@ -839,7 +755,7 @@ loc_2A33:; _moving &= 0xF0; _tmp_Dest = _pos; - byte tmp = sub_2F6F(); + byte tmp = calcWalkDistances(); _moving &= 0xF0; _moving |= tmp; @@ -859,7 +775,7 @@ loc_2A33:; directionUpdate(); - if (_moving & 0x80 ) + if (_moving & 0x80) return; animateActor(newDirToOldDir(_facing)); @@ -876,17 +792,17 @@ loc_2A33:; // 2A9A - if (_moving == 2 ) + if (_moving == 2) return; - if ((_moving & 0x0F) == 1 ) + if ((_moving & 0x0F) == 1) return stopActorMoving(); // 2AAD if (_moving & 0x80) { directionUpdate(); - if ((_moving & 0x80) ) + if (_moving & 0x80) return; // 2AC2 @@ -899,7 +815,7 @@ loc_2C36:; // 2C36 setTmpFromActor(); - if (!_walkDirX ) { + if (!_walkDirX) { _pos.x--; } else { _pos.x++; @@ -944,7 +860,7 @@ loc_2C36:; } // 2ADA - if ((_moving & 0x0F) == 4 ) { + if ((_moving & 0x0F) == 4) { // 2CA3 loc_2CA3:; setTmpFromActor(); @@ -954,22 +870,22 @@ loc_2CA3:; } else { _pos.y++; } - if (updateWalkbox() == 0xFF ) { + if (updateWalkbox() == 0xFF) { // 2CC7 setActorFromTmp(); - if( _CurrentWalkTo.x == _tmp_Dest.x ) { + if( _CurrentWalkTo.x == _tmp_Dest.x) { stopActorMoving(); return; } // 2CD5 - if (!_walkDirX ) { + if (!_walkDirX) { _tmp_Dest.x--; } else { _tmp_Dest.x++; } setTmpFromActor(); - if (updateWalkbox() == 0xFF ) { + if (updateWalkbox() == 0xFF) { setActorFromTmp(); stopActorMoving(); } @@ -981,19 +897,19 @@ loc_2CA3:; } } - if ((_moving & 0x0F) == 0 ) { + if ((_moving & 0x0F) == 0) { // 2AE8 byte A = actorWalkX(); - if( A == 1 ) { + if (A == 1) { A = actorWalkY(); - if( A == 1 ) { + if (A == 1) { // 2AF6 _moving &= 0xF0; _moving |= A; } else { // 2B04 - if( A == 4 ) + if (A == 4) stopActorMoving(); } @@ -1018,7 +934,7 @@ loc_2CA3:; } else { // 2B39 A = actorWalkY(); - if (A != 4 ) + if (A != 4) return; // 2B46 @@ -1039,22 +955,6 @@ loc_2CA3:; } } -void Actor_v0::directionUpdate() { - - int nextFacing = updateActorDirection(true); - if (_facing != nextFacing) { - // 2A89 - setDirection(nextFacing); - - if (_facing != _targetFacing ) { - _moving |= 0x80; - } else { - _moving &= ~0x80; - } - } else - _moving &= ~0x80; -} - void Actor_v2::walkActor() { Common::Point foundPath, tmp; int new_dir, next_box; @@ -1101,10 +1001,8 @@ void Actor_v2::walkActor() { _walkdata.curbox = next_box; - if (!checkWalkboxesHaveDirectPath(foundPath)) { - getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), _pos.x, _pos.y, tmp.x, tmp.y); - getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, foundPath.x, foundPath.y); - } + getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), _pos.x, _pos.y, tmp.x, tmp.y); + getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, foundPath.x, foundPath.y); } calcMovementFactor(foundPath); } @@ -1496,7 +1394,7 @@ void Actor::putActor(int dstX, int dstY, int newRoom) { if (_vm->_game.version == 0) { _walkdata.dest = _pos; - ((Actor_v0*)this)->unk_FDE1 = 1; + ((Actor_v0*)this)->_newWalkBoxEntered = 1; ((Actor_v0*)this)->_CurrentWalkTo = _pos; setDirection(oldDirToNewDir(2)); @@ -2075,14 +1973,15 @@ void ScummEngine::processActors() { // comment further up in this method for some details. if (a->_costume) { - if (_game.version == 0) + // Unfortunately in V0, the 'animateCostume' call happens right after the call to 'walkActor', before drawing the actor... doing it the + // other way with V0, causes graphic glitches + if (_game.version == 0) { a->animateCostume(); - - a->drawActorCostume(); - - if (_game.version != 0) + a->drawActorCostume(); + } else { + a->drawActorCostume(); a->animateCostume(); - + } } } } diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index b2245da3d2..c554cad040 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -333,7 +333,6 @@ public: protected: virtual bool isPlayer(); virtual void prepareDrawActorCostume(BaseCostumeRenderer *bcr); - virtual bool checkWalkboxesHaveDirectPath(Common::Point &foundPath); }; enum ActorV0MiscFlags { @@ -349,12 +348,15 @@ enum ActorV0MiscFlags { class Actor_v0 : public Actor_v2 { public: + Common::Point _CurrentWalkTo, _NewWalkTo; + byte _costCommandNew; byte _costCommand; byte _miscflags; byte _speaking; - Common::Point _CurrentWalkTo, _NewWalkTo; + byte _walkCountModulo; + byte _newWalkBoxEntered; byte _walkDirX; byte _walkDirY; @@ -364,16 +366,13 @@ public: byte _walkXCountInc; byte _walkYCount; byte _walkYCountInc; - byte _walkCountModulo; byte _walkMaxXYCountInc; - byte unk_FDE1; - Common::Point _tmp_Pos; Common::Point _tmp_Dest; byte _tmp_WalkBox; - byte _tmp_CB5F; + byte _tmp_NewWalkBoxEntered; int8 _animFrameRepeat; int8 _limbFrameRepeatNew[8]; @@ -395,23 +394,18 @@ public: void setDirection(int direction); void startAnimActor(int f); - bool sub_2F6F(); + bool calcWalkDistances(); void walkActor(); void actorSetWalkTo(); byte actorWalkX(); byte actorWalkY(); byte updateWalkbox(); - byte walkboxFindTarget(); + void setTmpFromActor(); void setActorFromTmp(); // Used by the save/load system: virtual void saveLoadWithSerializer(Serializer *ser); - -protected: - bool intersectLineSegments(const Common::Point &line1Start, const Common::Point &line1End, - const Common::Point &line2Start, const Common::Point &line2End, Common::Point &result); - virtual bool checkWalkboxesHaveDirectPath(Common::Point &foundPath); }; diff --git a/engines/scumm/boxes.cpp b/engines/scumm/boxes.cpp index 70c8f2e032..087d8425ac 100644 --- a/engines/scumm/boxes.cpp +++ b/engines/scumm/boxes.cpp @@ -1158,6 +1158,30 @@ bool ScummEngine::areBoxesNeighbors(int box1nr, int box2nr) { return false; } +byte ScummEngine_v0::walkboxFindTarget(Actor *a, int destbox, Common::Point walkdest) { + Actor_v0 *Actor = (Actor_v0*)a; + + byte nextBox = getNextBox(a->_walkbox, destbox); + + if (nextBox != 0xFF && nextBox == destbox && areBoxesNeighbors(a->_walkbox, nextBox)) { + + Actor->_NewWalkTo = walkdest; + return nextBox; + } + + if (nextBox != 0xFF && nextBox != a->_walkbox) { + + getClosestPtOnBox(getBoxCoordinates(nextBox), a->getPos().x, a->getPos().y, Actor->_NewWalkTo.x, Actor->_NewWalkTo.y); + + } else { + if (walkdest.x == -1) + Actor->_NewWalkTo = Actor->_CurrentWalkTo; + else + Actor->_NewWalkTo = walkdest; + } + return nextBox; +} + bool ScummEngine_v0::areBoxesNeighbors(int box1nr, int box2nr) { int i; const int numOfBoxes = getNumBoxes(); diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index 6cbfbf45b3..90291535fd 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -589,9 +589,9 @@ void ScummEngine_v0::o_loadRoomWithEgo() { return; } - // The original interpreter seems to set the actors new room X/Y to the last rooms X/Y - // This fixes a problem with MM: script 158 in room 12, the 'Oompf!' script - // This scripts runs before the actor position is set to the correct location + // The original interpreter sets the actors new room X/Y to the last rooms X/Y + // This fixes a problem with MM: script 158 in room 12, the 'Oomph!' script + // This scripts runs before the actor position is set to the correct room entry location a->putActor(a->getPos().x, a->getPos().y, room); _egoPositioned = false; @@ -707,7 +707,6 @@ void ScummEngine_v0::o_animateActor() { } a->animateActor(anim); - a->animateCostume(); } void ScummEngine_v0::o_getActorMoving() { diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index 80d047ab9f..83e0e32e15 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -67,6 +67,8 @@ public: virtual void resetScumm(); + byte walkboxFindTarget(Actor *a, int destbox, Common::Point walkdest); + protected: virtual void resetRoomObject(ObjectData *od, const byte *room, const byte *searchptr = NULL); @@ -116,7 +118,7 @@ protected: void resetSentence(); - virtual bool areBoxesNeighbors(int box1nr, int box2nr); + bool areBoxesNeighbors(int box1nr, int box2nr); bool ifEqualActiveObject2Common(bool checkType); diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index c1bafe1e0f..bf0a693467 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -708,7 +708,6 @@ void ScummEngine_v0::verbExec() { Actor_v0 *a = (Actor_v0 *)derefActor(VAR(VAR_EGO), "verbExec"); int x = _virtualMouse.x / V12_X_MULTIPLIER; int y = _virtualMouse.y / V12_Y_MULTIPLIER; - //actorSetPosInBox(); // 0xB31 VAR(6) = x; -- cgit v1.2.3 From aa70e73e2526073129ab3dc942037bc57631ef7c Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Wed, 26 Nov 2014 17:52:51 +0100 Subject: I18N: Update/improve Dutch translation --- po/nl_NL.po | 100 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/po/nl_NL.po b/po/nl_NL.po index 43ac274ac5..3a9e6d8172 100644 --- a/po/nl_NL.po +++ b/po/nl_NL.po @@ -1,21 +1,21 @@ # LANGUAGE translation for ScummVM. # Copyright (C) YEAR ScummVM Team # This file is distributed under the same license as the ScummVM package. -# FIRST AUTHOR , YEAR. +# FIRST AUTHOR scummvm@bencastricum.nl, 2014. # msgid "" msgstr "" "Project-Id-Version: ScummVM 1.8.0git\n" "Report-Msgid-Bugs-To: scummvm-devel@lists.sf.net\n" -"POT-Creation-Date: 2014-10-04 00:58+0100\n" -"PO-Revision-Date: 2014-09-03 07:42+0100\n" +"POT-Creation-Date: 2014-11-25 20:41+0100\n" +"PO-Revision-Date: 2014-11-25 20:46+0100\n" "Last-Translator: Ben Castricum \n" "Language-Team: Ben Castricum \n" "Language: Nederlands\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.5.3\n" +"X-Generator: Poedit 1.6.10\n" "X-Poedit-SourceCharset: iso-8859-1\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" @@ -34,11 +34,11 @@ msgstr "Beschikbare engines:" #: gui/browser.cpp:68 msgid "Show hidden files" -msgstr "Verborgen bestanden weergeven" +msgstr "Toon verborgen bestanden" #: gui/browser.cpp:68 msgid "Show files marked with the hidden attribute" -msgstr "Toon de bestanden die met het verborgen kenmerk hebben." +msgstr "Toon bestanden die het verborgen kenmerk hebben." #: gui/browser.cpp:72 msgid "Go up" @@ -108,7 +108,7 @@ msgstr "Koppel" #: backends/platform/wii/options.cpp:47 #: backends/platform/wince/CELauncherDialog.cpp:54 #: engines/agos/animation.cpp:558 engines/drascula/saveload.cpp:49 -#: engines/groovie/script.cpp:399 engines/parallaction/saveload.cpp:274 +#: engines/groovie/script.cpp:408 engines/parallaction/saveload.cpp:274 #: engines/scumm/dialogs.cpp:193 engines/scumm/scumm.cpp:1825 #: engines/scumm/players/player_v3m.cpp:130 #: engines/scumm/players/player_v5m.cpp:108 engines/sky/compact.cpp:131 @@ -214,7 +214,7 @@ msgstr "Engine" #: gui/launcher.cpp:245 gui/options.cpp:1073 gui/options.cpp:1090 msgid "Graphics" -msgstr "Grafisch" +msgstr "Beeld" #: gui/launcher.cpp:245 gui/options.cpp:1073 gui/options.cpp:1090 msgid "GFX" @@ -231,7 +231,7 @@ msgstr "Negeer algemene grafische instellingen" #: gui/launcher.cpp:257 gui/options.cpp:1096 msgid "Audio" -msgstr "Audio" +msgstr "Geluid" #: gui/launcher.cpp:260 msgid "Override global audio settings" @@ -319,7 +319,7 @@ msgstr "Extra Pad:" #: gui/launcher.cpp:339 gui/options.cpp:1134 msgid "Save Path:" -msgstr "Save Pad:" +msgstr "Bewaar Pad:" #: gui/launcher.cpp:339 gui/launcher.cpp:341 gui/launcher.cpp:342 #: gui/options.cpp:1134 gui/options.cpp:1136 gui/options.cpp:1137 @@ -329,7 +329,7 @@ msgstr "Bepaalt waar opgeslagen spellen worden bewaard." #: gui/launcher.cpp:341 gui/options.cpp:1136 msgctxt "lowres" msgid "Save Path:" -msgstr "Save Pad:" +msgstr "Bewaar Pad:" #: gui/launcher.cpp:360 gui/launcher.cpp:459 gui/launcher.cpp:517 #: gui/launcher.cpp:571 gui/options.cpp:1145 gui/options.cpp:1153 @@ -604,8 +604,7 @@ msgstr "Geen" #: gui/options.cpp:389 msgid "Failed to apply some of the graphic options changes:" -msgstr "" -"Het is niet gelukt om enkele veranderingen in grafische opties toe te passen:" +msgstr "Sommige grafische opties konden niet worden toegepast:" #: gui/options.cpp:401 msgid "the video mode could not be changed." @@ -781,7 +780,7 @@ msgstr "Geen Roland MT-32 muziek gebruiken" #: gui/options.cpp:927 msgid "Text and Speech:" -msgstr "Spraak en/of ondertitels:" +msgstr "Spraak en/of tekst:" #: gui/options.cpp:931 gui/options.cpp:941 msgid "Speech" @@ -789,7 +788,7 @@ msgstr "Spraak" #: gui/options.cpp:932 gui/options.cpp:942 msgid "Subtitles" -msgstr "Ondertitels" +msgstr "Tekst" #: gui/options.cpp:933 msgid "Both" @@ -797,7 +796,7 @@ msgstr "Beide" #: gui/options.cpp:935 msgid "Subtitle speed:" -msgstr "Snelheid ondertitels:" +msgstr "Snelheid tekst:" #: gui/options.cpp:937 msgctxt "lowres" @@ -819,7 +818,7 @@ msgstr "Beide" #: gui/options.cpp:943 msgid "Show subtitles and play speech" -msgstr "Toon ondertitels en speel spraak af" +msgstr "Toon tekst en speel spraak af" #: gui/options.cpp:945 msgctxt "lowres" @@ -1277,17 +1276,17 @@ msgstr "O~v~er" #: engines/dialogs.cpp:105 engines/dialogs.cpp:181 msgid "~R~eturn to Launcher" -msgstr "~T~erug naar het startmenu" +msgstr "Terug naar s~t~artmenu" #: engines/dialogs.cpp:107 engines/dialogs.cpp:183 msgctxt "lowres" msgid "~R~eturn to Launcher" -msgstr "~T~erug naar startmenu" +msgstr "S~t~artmenu" #: engines/dialogs.cpp:116 engines/agi/saveload.cpp:803 #: engines/cruise/menu.cpp:212 engines/drascula/saveload.cpp:336 #: engines/dreamweb/saveload.cpp:261 engines/neverhood/menumodule.cpp:873 -#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:758 +#: engines/pegasus/pegasus.cpp:377 engines/sci/engine/kfile.cpp:759 #: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598 msgid "Save game:" msgstr "Spel opslaan:" @@ -1300,7 +1299,7 @@ msgstr "Spel opslaan:" #: engines/agi/saveload.cpp:803 engines/cruise/menu.cpp:212 #: engines/drascula/saveload.cpp:336 engines/dreamweb/saveload.cpp:261 #: engines/neverhood/menumodule.cpp:873 engines/pegasus/pegasus.cpp:377 -#: engines/sci/engine/kfile.cpp:758 engines/scumm/dialogs.cpp:188 +#: engines/sci/engine/kfile.cpp:759 engines/scumm/dialogs.cpp:188 #: engines/toltecs/menu.cpp:281 engines/tsage/scenes.cpp:598 msgid "Save" msgstr "Opslaan" @@ -1540,7 +1539,7 @@ msgstr "~I~ndy vecht besturing" #: backends/platform/ds/arm9/source/dsoptions.cpp:65 msgid "Show mouse cursor" -msgstr "Toon muis wijzer" +msgstr "Toon muiswijzer" #: backends/platform/ds/arm9/source/dsoptions.cpp:66 msgid "Snap to edges" @@ -1769,7 +1768,7 @@ msgstr "Video" #: backends/platform/wii/options.cpp:54 msgid "Current video mode:" -msgstr "Huidige video modus:" +msgstr "Huidige videomodus:" #: backends/platform/wii/options.cpp:56 msgid "Double-strike" @@ -2113,13 +2112,13 @@ msgstr "" #: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349 #: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886 -#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256 +#: engines/sci/engine/kfile.cpp:858 engines/toltecs/menu.cpp:256 msgid "Restore game:" msgstr "Laad opgeslagen spel:" #: engines/agi/saveload.cpp:816 engines/drascula/saveload.cpp:349 #: engines/dreamweb/saveload.cpp:169 engines/neverhood/menumodule.cpp:886 -#: engines/sci/engine/kfile.cpp:857 engines/toltecs/menu.cpp:256 +#: engines/sci/engine/kfile.cpp:858 engines/toltecs/menu.cpp:256 msgid "Restore" msgstr "Laad" @@ -2161,14 +2160,13 @@ msgstr "" msgid "Cutscene file '%s' not found!" msgstr "Cutscene bestand '%s' niet gevonden!" -#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:81 -#, fuzzy +#: engines/cge/detection.cpp:105 engines/cge2/detection.cpp:91 msgid "Color Blind Mode" -msgstr "Klik Modus" +msgstr "Kleurenblind Modus" -#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:82 +#: engines/cge/detection.cpp:106 engines/cge2/detection.cpp:92 msgid "Enable Color Blind Mode by default" -msgstr "" +msgstr "Schakel Kleurenblind modus standaard in" #: engines/drascula/saveload.cpp:47 msgid "" @@ -2218,17 +2216,17 @@ msgstr "Film snel afspelen" msgid "Play movies at an increased speed" msgstr "Speel films sneller af" -#: engines/groovie/script.cpp:399 +#: engines/groovie/script.cpp:408 msgid "Failed to save game" msgstr "Opslaan van spel mislukt." #: engines/hopkins/detection.cpp:76 engines/hopkins/detection.cpp:86 msgid "Gore Mode" -msgstr "" +msgstr "Gore Modus" #: engines/hopkins/detection.cpp:77 engines/hopkins/detection.cpp:87 msgid "Enable Gore Mode when available" -msgstr "" +msgstr "Gore modus inschakelen waar mogelijk" #. I18N: Studio audience adds an applause and cheering sounds whenever #. Malcolm makes a joke. @@ -2359,6 +2357,12 @@ msgid "" "Do you wish to use this save game file with ScummVM?\n" "\n" msgstr "" +"Het volgende originele opgeslagen spel was gevonden in uw spel pad:\n" +"\n" +"%s %s\n" +"\n" +"Wilt u dit opgeslagen spel gebruiken in ScummVM?\n" +"\n" #: engines/kyra/saveload_eob.cpp:590 #, c-format @@ -2366,6 +2370,8 @@ msgid "" "A save game file was found in the specified slot %d. Overwrite?\n" "\n" msgstr "" +"Er is al een opgeslagen spel in slot %d. Deze overschrijven?\n" +"\n" #: engines/kyra/saveload_eob.cpp:623 #, c-format @@ -2377,6 +2383,12 @@ msgid "" "'import_savefile'.\n" "\n" msgstr "" +"%d origneel opgeslagen spellen zijn succesvol geimporteerd in ScummVM.\n" +"Als u later handmatig origineel opgeslagen spellen wilt importeren dan zult " +"u de\n" +"ScummVM debug console moeten openen en het commando 'import_savefile' " +"gebruiken.\n" +"\n" #. I18N: Option for fast scene switching #: engines/mohawk/dialogs.cpp:92 engines/mohawk/dialogs.cpp:167 @@ -2433,7 +2445,7 @@ msgstr "" #: engines/parallaction/saveload.cpp:204 msgid "Loading game..." -msgstr "Laden spel..." +msgstr "Spel laden..." #: engines/parallaction/saveload.cpp:219 msgid "Saving game..." @@ -2510,12 +2522,12 @@ msgstr "Toon/Verberg Pauze-Menu" #: engines/queen/detection.cpp:56 msgid "Alternative intro" -msgstr "" +msgstr "Alternatieve intro" #: engines/queen/detection.cpp:57 -#, fuzzy msgid "Use an alternative game intro (CD version only)" -msgstr "Gebruik de floppy versie van de intro (alleen voor de CD versie)" +msgstr "" +"Gebruik een alternatieve versie van de intro (alleen voor de CD versie)" #: engines/sci/detection.cpp:374 msgid "EGA undithering" @@ -2598,12 +2610,12 @@ msgstr "Spel is gepauzeerd. Druk op de spatiebalk om verder te gaan." #. "Moechten Sie wirklich neu starten? (J/N)J" #. Will react to J as 'Yes' #: engines/scumm/dialogs.cpp:183 -msgid "Are you sure you want to restart? (Y/N)" +msgid "Are you sure you want to restart? (Y/N)Y" msgstr "Weet u zeker dat u opnieuw wilt beginnen? (J/N)J" #. I18N: you may specify 'Yes' symbol at the end of the line. See previous comment #: engines/scumm/dialogs.cpp:185 -msgid "Are you sure you want to quit? (Y/N)" +msgid "Are you sure you want to quit? (Y/N)Y" msgstr "Weet u zeker dat u wilt stoppen? (J/N)J" #: engines/scumm/dialogs.cpp:190 @@ -3224,12 +3236,16 @@ msgid "" "Could not find the 'Loom' Macintosh executable to read the\n" "instruments from. Music will be disabled." msgstr "" +"De 'Loom' Macintosh executable is niet gevonden om de instrumenten van te " +"laden. Muziek wordt uitgeschakeld." #: engines/scumm/players/player_v5m.cpp:107 msgid "" "Could not find the 'Monkey Island' Macintosh executable to read the\n" "instruments from. Music will be disabled." msgstr "" +"De 'Monkey Island' Macintosh executable is niet gevonden om de instrumenten " +"van te laden. Muziek wordt uitgeschakeld." #: engines/sky/compact.cpp:130 msgid "" @@ -3312,7 +3328,7 @@ msgstr "Houd de nieuwe" #: engines/sword1/logic.cpp:1633 msgid "This is the end of the Broken Sword 1 Demo" -msgstr "Dit is het einde van de Broken Sword 1 Demo" +msgstr "Dit is het einde van de Broken Sword 1 demo." #: engines/sword2/animation.cpp:425 msgid "" @@ -3346,8 +3362,8 @@ msgstr "" #: engines/wintermute/detection.cpp:58 msgid "Show FPS-counter" -msgstr "" +msgstr "Toon FPS-teller" #: engines/wintermute/detection.cpp:59 msgid "Show the current number of frames per second in the upper left corner" -msgstr "" +msgstr "Toon de huidige Frames Per Second teller in de linkerbovenhoek" -- cgit v1.2.3 From 235f299db5af6f82bf2b644dea768734c381d09f Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Tue, 25 Nov 2014 21:15:17 +0100 Subject: I18N: Fix missing translation entries The last translation entry of a .po file was not properly handled. --- devtools/create_translations/po_parser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/devtools/create_translations/po_parser.cpp b/devtools/create_translations/po_parser.cpp index 7882502ca4..ecc3ba540c 100644 --- a/devtools/create_translations/po_parser.cpp +++ b/devtools/create_translations/po_parser.cpp @@ -332,6 +332,13 @@ PoMessageEntryList *parsePoFile(const char *file, PoMessageList& messages) { strcat(currentBuf, stripLine(line)); } } + if (currentBuf == msgstrBuf) { + // add last entry + if (*msgstrBuf != '\0' && !fuzzy) { + messages.insert(msgidBuf); + list->addMessageEntry(msgstrBuf, msgidBuf, msgctxtBuf); + } + } fclose(inFile); return list; -- cgit v1.2.3 From ea420adbadf553545e41f6d45c18948f3576abf7 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sat, 29 Nov 2014 13:44:01 +0000 Subject: I18N: Update translations data file --- gui/themes/translations.dat | Bin 468258 -> 470115 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gui/themes/translations.dat b/gui/themes/translations.dat index abd745bb2b..bfa33d4feb 100644 Binary files a/gui/themes/translations.dat and b/gui/themes/translations.dat differ -- cgit v1.2.3 From 30b6a479e5b1510cb5157c72decdb24aa4c24ed1 Mon Sep 17 00:00:00 2001 From: Rodrigo Rebello Date: Sun, 2 Nov 2014 15:07:09 -0200 Subject: SCUMM: Fix bug #6679 - INDY3 DOS-EGA: book of maps graphic glitch Force correct width value for room 64 (book of maps) in Indy3. This works around the wrong value stored in the data files of a specific version of the game (DOS/EGA v1.0, according to scumm-md5.txt). --- engines/scumm/room.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index 3828629997..4b59e22408 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -614,6 +614,15 @@ void ScummEngine_v3old::setupRoomSubBlocks() { } } else { _roomWidth = READ_LE_UINT16(&(rmhd->old.width)); + + // WORKAROUND: Fix bad width value for room 64 (book of maps) in + // Indy3. A specific version of this game (DOS/EGA v1.0, according to + // scumm-md5.txt) has a wrong width of 1793 stored in the data files, + // which causes a strange situation in which the book view may scroll + // towards the right depending on Indy's position from the previous room. + // Fixes bug #6679. + if (_game.id == GID_INDY3 && _roomResource == 64 && _roomWidth == 1793) + _roomWidth = 320; _roomHeight = READ_LE_UINT16(&(rmhd->old.height)); } _numObjectsInRoom = roomptr[20]; -- cgit v1.2.3 From 0aba59b4602b7a76d91e9e4daef31222df38c3f1 Mon Sep 17 00:00:00 2001 From: uruk Date: Mon, 1 Dec 2014 14:45:18 +0100 Subject: CGE2: Add support for Sfinx. --- AUTHORS | 4 ++-- NEWS | 4 +++- engines/cge2/configure.engine | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/AUTHORS b/AUTHORS index 983f2524e4..9470217230 100644 --- a/AUTHORS +++ b/AUTHORS @@ -701,8 +701,8 @@ Special thanks to of Dreamweb and for their tremendous support. Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe - Avalon for providing full source code for Soltys and letting us - redistribute the game. + Avalon for providing full source code for Soltys and Sfinx and letting us + redistribute the games. Jan Nedoma for providing the sources to the Wintermute-engine, and for his support while porting the engine to ScummVM. diff --git a/NEWS b/NEWS index bb23bb37ff..762af70962 100644 --- a/NEWS +++ b/NEWS @@ -2,8 +2,10 @@ For a more comprehensive changelog of the latest experimental code, see: https://github.com/scummvm/scummvm/commits/ 1.8.0 (????-??-??) + New Games: + - Added support for Sfinx. -Broken Sword 1: + Broken Sword 1: - Fix speech endianness detection on big endian systems for the mac version (bug #6720). - Fix crash when reloading a game from the Main Menu while in the bull's diff --git a/engines/cge2/configure.engine b/engines/cge2/configure.engine index 6ccbfee088..79d091fec5 100644 --- a/engines/cge2/configure.engine +++ b/engines/cge2/configure.engine @@ -1,3 +1,3 @@ # This file is included from the main "configure" script # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] -add_engine cge2 "CGE2" no +add_engine cge2 "CGE2" yes -- cgit v1.2.3 From b1f7603263c368658a3b9b7e30a929bd77d895af Mon Sep 17 00:00:00 2001 From: uruk Date: Mon, 1 Dec 2014 15:11:54 +0100 Subject: CGE2: Update credits the right way. --- devtools/credits.pl | 2 +- gui/credits.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devtools/credits.pl b/devtools/credits.pl index c8d9e538d8..1c2ece80ed 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -1267,7 +1267,7 @@ begin_credits("Credits"); add_paragraph( "Janusz Wiśniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon ". - "for providing full source code for Sołtys and letting us redistribute the game."); + "for providing full source code for Sołtys and Sfinx and letting us redistribute the games."); add_paragraph( "Jan Nedoma for providing the sources to the Wintermute-engine, and for his ". diff --git a/gui/credits.h b/gui/credits.h index d908a730b7..5b33797a63 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -851,7 +851,7 @@ static const char *credits[] = { "C0""", "C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.", "C0""", -"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us redistribute the game.", +"C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and Sfinx and letting us redistribute the games.", "C0""", "C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for his support while porting the engine to ScummVM.", "C0""", -- cgit v1.2.3 From 814d9b1153df417c184be2b1a9072d0c7b37b201 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Sun, 30 Nov 2014 22:01:23 +1100 Subject: SCUMM: Maniac V0: Correctly handle 'slanted' walk-boxes, Add new variables to save-games, Bump the SaveGame Version number, remove obsolete V0 code in V2 functions --- engines/scumm/actor.cpp | 504 +++++++++++++++++++++++++++-------------------- engines/scumm/actor.h | 7 +- engines/scumm/saveload.h | 2 +- engines/scumm/script.cpp | 6 +- 4 files changed, 296 insertions(+), 223 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 636f718582..90ee5bf368 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -51,6 +51,12 @@ static const byte v0ActorTalkArray[0x19] = { 0xC0, 0xC0, 0x00, 0x06, 0x06 }; +static const byte v0WalkboxSlantedModifier[0x16] = { + 0x00,0x01,0x02,0x03,0x03,0x04,0x05,0x06, + 0x06,0x07,0x08,0x09,0x09,0x0A,0x0B, + 0x0C,0x0C,0x0D,0x0E,0x0F,0x10,0x10 +}; + Actor::Actor(ScummEngine *scumm, int id) : _vm(scumm), _number(id) { assert(_vm != 0); @@ -183,6 +189,20 @@ void Actor_v0::initActor(int mode) { _costCommand = 0xFF; _miscflags = 0; _speaking = 0; + + _walkCountModulo = 0; + _newWalkBoxEntered = false; + _walkDirX = 0; + _walkDirY = 0; + _walkYCountGreaterThanXCount = 0; + _walkXCount = 0; + _walkXCountInc = 0; + _walkYCount = 0; + _walkYCountInc = 0; + _walkMaxXYCountInc = 0; + + _tmp_WalkBox = 0; + _tmp_NewWalkBoxEntered = 0; _animFrameRepeat = 0; for (int i = 0; i < 8; ++i) { @@ -250,11 +270,11 @@ void Actor::stopActorMoving() { if (_walkScript) _vm->stopScript(_walkScript); - _moving = 0; - if (_vm->_game.version == 0) { _moving = 2; setDirection(_facing); + } else { + _moving = 0; } } @@ -343,9 +363,6 @@ int Actor::actorWalkStep() { int distX, distY; int nextFacing; - if (_vm->_game.version == 0) - ((Actor_v0 *)this)->_animFrameRepeat = -1; - _needRedraw = true; nextFacing = updateActorDirection(true); @@ -354,10 +371,6 @@ int Actor::actorWalkStep() { startWalkAnim(1, nextFacing); } _moving |= MF_IN_LEG; - - // V0: Don't move during the turn - if (_vm->_game.version == 0) - return 0; } if (_walkbox != _walkdata.curbox && _vm->checkXYInBoxBounds(_walkdata.curbox, _pos.x, _pos.y)) { @@ -393,12 +406,113 @@ int Actor::actorWalkStep() { return 0; } - if (_vm->_game.version == 0) - ((Actor_v0 *)this)->animateActor(newDirToOldDir(_facing)); - return 1; } +bool Actor_v0::calcWalkDistances() { + _walkDirX = 0; + _walkDirY = 0; + _walkYCountGreaterThanXCount = 0; + uint16 A = 0; + + if (_CurrentWalkTo.x >= _tmp_Dest.x ) { + A = _CurrentWalkTo.x - _tmp_Dest.x; + _walkDirX = 1; + } else { + A = _tmp_Dest.x - _CurrentWalkTo.x; + } + + _walkXCountInc = A; + + if (_CurrentWalkTo.y >= _tmp_Dest.y ) { + A = _CurrentWalkTo.y - _tmp_Dest.y; + _walkDirY = 1; + } else { + A = _tmp_Dest.y - _CurrentWalkTo.y; + } + + _walkYCountInc = A; + if ( !_walkXCountInc && !_walkYCountInc ) + return true; + + if( _walkXCountInc <= _walkYCountInc ) + _walkYCountGreaterThanXCount = 1; + + // 2FCC + A = _walkXCountInc; + if( A <= _walkYCountInc ) + A = _walkYCountInc; + + _walkMaxXYCountInc = A; + _walkXCount = _walkXCountInc; + _walkYCount = _walkYCountInc; + _walkCountModulo = _walkMaxXYCountInc; + + return false; +} + +byte Actor_v0::actorWalkX() { + byte A = _walkXCount; + A += _walkXCountInc; + if (A >= _walkCountModulo) { + if (!_walkDirX ) { + _tmp_Dest.x--; + } else { + _tmp_Dest.x++; + } + + A -= _walkCountModulo; + } + // 2EAC + _walkXCount = A; + setTmpFromActor(); + if (updateWalkbox() == kInvalidBox) { + // 2EB9 + setActorFromTmp(); + + return 3; + } + // 2EBF + if (_tmp_Dest.x == _CurrentWalkTo.x) + return 1; + + return 0; +} + +byte Actor_v0::actorWalkY() { + byte A = _walkYCount; + A += _walkYCountInc; + if (A >= _walkCountModulo) { + if (!_walkDirY ) { + _tmp_Dest.y--; + } else { + _tmp_Dest.y++; + } + + A -= _walkCountModulo; + } + // 2EEB + _walkYCount = A; + setTmpFromActor(); + if (updateWalkbox() == kInvalidBox) { + // 2EF8 + setActorFromTmp(); + return 4; + } + // 2EFE + if (_walkYCountInc != 0) { + if (_walkYCountInc == 0xFF) { + setActorFromTmp(); + return 4; + } + } + // 2F0D + if (_CurrentWalkTo.y == _tmp_Dest.y) + return 1; + + return 0; +} + void Actor::startWalkActor(int destX, int destY, int dir) { AdjustBoxResult abr; @@ -451,14 +565,14 @@ void Actor::startWalkActor(int destX, int destY, int dir) { _walkdata.dest.y = abr.y; _walkdata.destbox = abr.box; _walkdata.destdir = dir; - if(_vm->_game.version != 0 ) { - _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; - } else { - ((Actor_v0*)this)->_newWalkBoxEntered = 1; - } _walkdata.point3.x = 32000; - _walkdata.curbox = _walkbox; + + if(_vm->_game.version == 0 ) { + ((Actor_v0*)this)->_newWalkBoxEntered = true; + } else { + _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; + } } void Actor::startWalkAnim(int cmd, int angle) { @@ -575,183 +689,14 @@ void Actor::walkActor() { calcMovementFactor(_walkdata.dest); } -bool Actor_v0::calcWalkDistances() { - _walkDirX = 0; - _walkDirY = 0; - _walkYCountGreaterThanXCount = 0; - uint16 A = 0; - - if (_CurrentWalkTo.x >= _tmp_Dest.x ) { - A = _CurrentWalkTo.x - _tmp_Dest.x; - _walkDirX = 1; - } else { - A = _tmp_Dest.x - _CurrentWalkTo.x; - } - - _walkXCountInc = A; - - if (_CurrentWalkTo.y >= _tmp_Dest.y ) { - A = _CurrentWalkTo.y - _tmp_Dest.y; - _walkDirY = 1; - } else { - A = _tmp_Dest.y - _CurrentWalkTo.y; - } - - _walkYCountInc = A; - if ( !_walkXCountInc && !_walkYCountInc ) - return true; - - if( _walkXCountInc <= _walkYCountInc ) - _walkYCountGreaterThanXCount = 1; - - // 2FCC - A = _walkXCountInc; - if( A <= _walkYCountInc ) - A = _walkYCountInc; - - _walkMaxXYCountInc = A; - _walkXCount = _walkXCountInc; - _walkYCount = _walkYCountInc; - _walkCountModulo = _walkMaxXYCountInc; - - return false; -} - -byte Actor_v0::updateWalkbox() { - if( _vm->checkXYInBoxBounds( _walkbox, _pos.x, _pos.y ) ) - return 0; - - int numBoxes = _vm->getNumBoxes() - 1; - for (int i = 0; i <= numBoxes; i++) { - if (_vm->checkXYInBoxBounds( i, _pos.x, _pos.y ) == true ) { - if (_walkdata.curbox == i ) { - setBox(i); - - _newWalkBoxEntered = 1; - return i; - } - } - } - - return 0xFF; -} - -void Actor_v0::setTmpFromActor() { - _tmp_Pos = _pos; - _pos = _tmp_Dest; - _tmp_WalkBox = _walkbox; - _tmp_NewWalkBoxEntered = _newWalkBoxEntered; -} - -void Actor_v0::setActorFromTmp() { - _pos = _tmp_Pos; - _tmp_Dest = _tmp_Pos; - _walkbox = _tmp_WalkBox; - _newWalkBoxEntered = _tmp_NewWalkBoxEntered; -} - -byte Actor_v0::actorWalkX() { - byte A = _walkXCount; - A += _walkXCountInc; - if (A >= _walkCountModulo) { - if (!_walkDirX ) { - _tmp_Dest.x--; - } else { - _tmp_Dest.x++; - } - - A -= _walkCountModulo; - } - // 2EAC - _walkXCount = A; - setTmpFromActor(); - if (updateWalkbox() == 0xFF) { - // 2EB9 - setActorFromTmp(); - - return 3; - } - // 2EBF - if (_tmp_Dest.x == _CurrentWalkTo.x) - return 1; - - return 0; -} - -byte Actor_v0::actorWalkY() { - byte A = _walkYCount; - A += _walkYCountInc; - if (A >= _walkCountModulo) { - if (!_walkDirY ) { - _tmp_Dest.y--; - } else { - _tmp_Dest.y++; - } - - A -= _walkCountModulo; - } - // 2EEB - _walkYCount = A; - setTmpFromActor(); - if (updateWalkbox() == 0xFF) { - // 2EF8 - setActorFromTmp(); - return 4; - } - // 2EFE - if (_walkYCountInc != 0) { - if (_walkYCountInc == 0xFF) { - setActorFromTmp(); - return 4; - } - } - // 2F0D - if (_CurrentWalkTo.y == _tmp_Dest.y) - return 1; - - return 0; -} - -void Actor_v0::directionUpdate() { - - int nextFacing = updateActorDirection(true); - if (_facing != nextFacing) { - // 2A89 - setDirection(nextFacing); - - // Still need to turn? - if (_facing != _targetFacing ) { - _moving |= 0x80; - return; - } - } - - _moving &= ~0x80; -} - -void Actor_v0::actorSetWalkTo() { - - if (_newWalkBoxEntered == 0) - return; - - _newWalkBoxEntered = 0; - - int nextBox = ((ScummEngine_v0*)_vm)->walkboxFindTarget( this, _walkdata.destbox, _walkdata.dest ); - if (nextBox != 0xFF) { - _walkdata.curbox = nextBox; - } -} - void Actor_v0::walkActor() { actorSetWalkTo(); _needRedraw = true; if (_NewWalkTo != _CurrentWalkTo) { - - // 2A27 _CurrentWalkTo = _NewWalkTo; -loc_2A33:; +L2A33:; _moving &= 0xF0; _tmp_Dest = _pos; @@ -784,13 +729,11 @@ loc_2A33:; // 2A0A if ((_moving & 0x7F) != 1) { - if (_NewWalkTo == _pos) { + if (_NewWalkTo == _pos) return; - } } } - // 2A9A if (_moving == 2) return; @@ -805,14 +748,11 @@ loc_2A33:; if (_moving & 0x80) return; - // 2AC2 animateActor(newDirToOldDir(_facing)); } - // 2ACE if ((_moving & 0x0F) == 3 ) { -loc_2C36:; - // 2C36 +L2C36:; setTmpFromActor(); if (!_walkDirX) { @@ -822,13 +762,12 @@ loc_2C36:; } // 2C51 - if (updateWalkbox() != 0xFF) { - //2C66 + if (updateWalkbox() != kInvalidBox) { + setActorFromTmp(); - goto loc_2A33; + goto L2A33; } - // 2C6C setActorFromTmp(); if (_CurrentWalkTo.y == _tmp_Dest.y) { @@ -841,8 +780,9 @@ loc_2C36:; } else { _tmp_Dest.y++; } + setTmpFromActor(); - //2C8B + byte A = updateWalkbox(); if (A == 0xFF) { setActorFromTmp(); @@ -861,8 +801,7 @@ loc_2C36:; // 2ADA if ((_moving & 0x0F) == 4) { - // 2CA3 -loc_2CA3:; +L2CA3:; setTmpFromActor(); if (!_walkDirY) { @@ -870,14 +809,14 @@ loc_2CA3:; } else { _pos.y++; } - if (updateWalkbox() == 0xFF) { + if (updateWalkbox() == kInvalidBox) { // 2CC7 setActorFromTmp(); if( _CurrentWalkTo.x == _tmp_Dest.x) { stopActorMoving(); return; } - // 2CD5 + if (!_walkDirX) { _tmp_Dest.x--; } else { @@ -885,7 +824,7 @@ loc_2CA3:; } setTmpFromActor(); - if (updateWalkbox() == 0xFF) { + if (updateWalkbox() == kInvalidBox) { setActorFromTmp(); stopActorMoving(); } @@ -893,22 +832,20 @@ loc_2CA3:; return; } else { setActorFromTmp(); - goto loc_2A33; + goto L2A33; } } if ((_moving & 0x0F) == 0) { - // 2AE8 + // 2AE8 byte A = actorWalkX(); if (A == 1) { A = actorWalkY(); - if (A == 1) { - // 2AF6 + if (A == 1) { _moving &= 0xF0; _moving |= A; } else { - // 2B04 if (A == 4) stopActorMoving(); } @@ -929,7 +866,7 @@ loc_2CA3:; directionUpdate(); animateActor(newDirToOldDir(_facing)); - goto loc_2C36; + goto L2C36; } else { // 2B39 @@ -937,7 +874,6 @@ loc_2CA3:; if (A != 4) return; - // 2B46 _moving &= 0xF0; _moving |= A; @@ -949,7 +885,7 @@ loc_2CA3:; directionUpdate(); animateActor(newDirToOldDir(_facing)); - goto loc_2CA3; + goto L2CA3; } } } @@ -1394,7 +1330,7 @@ void Actor::putActor(int dstX, int dstY, int newRoom) { if (_vm->_game.version == 0) { _walkdata.dest = _pos; - ((Actor_v0*)this)->_newWalkBoxEntered = 1; + ((Actor_v0*)this)->_newWalkBoxEntered = true; ((Actor_v0*)this)->_CurrentWalkTo = _pos; setDirection(oldDirToNewDir(2)); @@ -1512,6 +1448,59 @@ static int checkXYInBoxBounds(int boxnum, int x, int y, int &destX, int &destY) return dist; } +AdjustBoxResult Actor_v0::adjustPosInBorderWalkbox(AdjustBoxResult box) { + AdjustBoxResult Result = box; + BoxCoords BoxCoord = _vm->getBoxCoordinates(box.box); + + byte boxMask = _vm->getMaskFromBox(box.box); + if (!(boxMask & 0x80)) + return Result; + + char A; + boxMask &= 0x7C; + if (boxMask == 0x0C) + A = 2; + else { + if (boxMask != 0x08) + return Result; + + A = 1; + } + + // 1BC6 + byte Modifier = box.y - BoxCoord.ul.y; + assert(Modifier < 0x16); + + if (A == 1) { + // 1BCF + A = BoxCoord.ur.x - v0WalkboxSlantedModifier[ Modifier ]; + if (A < box.x) + return box; + + if (A < 0xA0 || A == 0xA0) + A = 0; + + Result.x = A; + } else { + // 1BED + A = BoxCoord.ul.x + v0WalkboxSlantedModifier[ Modifier ]; + + if (A < box.x || A == box.x) + Result.x = A; + } + + return Result; +} + +AdjustBoxResult Actor_v0::adjustXYToBeInBox(int dstX, int dstY) { + AdjustBoxResult Result = Actor_v2::adjustXYToBeInBox(dstX, dstY); + + if( Result.box == kInvalidBox ) + return Result; + + return adjustPosInBorderWalkbox(Result); +} + AdjustBoxResult Actor_v2::adjustXYToBeInBox(const int dstX, const int dstY) { AdjustBoxResult abr; @@ -1722,7 +1711,7 @@ void Actor::showActor() { Actor_v0 *a = ((Actor_v0 *)this); a->_costCommand = a->_costCommandNew = 0xFF; - + _walkdata.dest = a->_CurrentWalkTo; for (int i = 0; i < 8; ++i) { a->_limbFrameRepeat[i] = 0; @@ -1955,7 +1944,7 @@ void ScummEngine::processActors() { continue; // Sound - if (a0->_moving && _currentRoom != 1 && _currentRoom != 44) { + if (a0->_moving != 2 && _currentRoom != 1 && _currentRoom != 44) { if (a0->_cost.soundPos == 0) a0->_cost.soundCounter++; @@ -1973,8 +1962,9 @@ void ScummEngine::processActors() { // comment further up in this method for some details. if (a->_costume) { - // Unfortunately in V0, the 'animateCostume' call happens right after the call to 'walkActor', before drawing the actor... doing it the - // other way with V0, causes graphic glitches + // Unfortunately in V0, the 'animateCostume' call happens right after the call to 'walkActor' (which is before drawing the actor)... + // doing it the other way with V0, causes animation glitches (when beginnning to walk, as the costume hasnt been updated). + // Updating the costume directly after 'walkActor' and again, after drawing... causes frame skipping if (_game.version == 0) { a->animateCostume(); a->drawActorCostume(); @@ -3218,6 +3208,70 @@ void Actor_v0::animateActor(int anim) { } } +byte Actor_v0::updateWalkbox() { + if( _vm->checkXYInBoxBounds( _walkbox, _pos.x, _pos.y ) ) + return 0; + + int numBoxes = _vm->getNumBoxes() - 1; + for (int i = 0; i <= numBoxes; i++) { + if (_vm->checkXYInBoxBounds( i, _pos.x, _pos.y ) == true ) { + if (_walkdata.curbox == i) { + setBox(i); + directionUpdate(); + + _newWalkBoxEntered = true; + return i; + } + } + } + + return kInvalidBox; +} + +void Actor_v0::directionUpdate() { + + int nextFacing = updateActorDirection(true); + if (_facing != nextFacing) { + // 2A89 + setDirection(nextFacing); + + // Still need to turn? + if (_facing != _targetFacing) { + _moving |= 0x80; + return; + } + } + + _moving &= ~0x80; +} + +void Actor_v0::setTmpFromActor() { + _tmp_Pos = _pos; + _pos = _tmp_Dest; + _tmp_WalkBox = _walkbox; + _tmp_NewWalkBoxEntered = _newWalkBoxEntered; +} + +void Actor_v0::setActorFromTmp() { + _pos = _tmp_Pos; + _tmp_Dest = _tmp_Pos; + _walkbox = _tmp_WalkBox; + _newWalkBoxEntered = _tmp_NewWalkBoxEntered; +} + +void Actor_v0::actorSetWalkTo() { + + if (_newWalkBoxEntered == false) + return; + + _newWalkBoxEntered = false; + + int nextBox = ((ScummEngine_v0*)_vm)->walkboxFindTarget(this, _walkdata.destbox, _walkdata.dest); + if (nextBox != kInvalidBox) { + _walkdata.curbox = nextBox; + } +} + void Actor_v0::saveLoadWithSerializer(Serializer *ser) { Actor::saveLoadWithSerializer(ser); @@ -3231,6 +3285,20 @@ void Actor_v0::saveLoadWithSerializer(Serializer *ser) { MKLINE(Actor_v0, _animFrameRepeat, sleByte, VER(89)), MKARRAY(Actor_v0, _limbFrameRepeatNew[0], sleInt8, 8, VER(89)), MKARRAY(Actor_v0, _limbFrameRepeat[0], sleInt8, 8, VER(90)), + MKLINE(Actor_v0, _CurrentWalkTo.x, sleInt16, VER(97)), + MKLINE(Actor_v0, _CurrentWalkTo.y, sleInt16, VER(97)), + MKLINE(Actor_v0, _NewWalkTo.x, sleInt16, VER(97)), + MKLINE(Actor_v0, _NewWalkTo.y, sleInt16, VER(97)), + MKLINE(Actor_v0, _walkCountModulo, sleInt8, VER(97)), + MKLINE(Actor_v0, _newWalkBoxEntered, sleByte, VER(97)), + MKLINE(Actor_v0, _walkDirX, sleByte, VER(97)), + MKLINE(Actor_v0, _walkDirY, sleByte, VER(97)), + MKLINE(Actor_v0, _walkYCountGreaterThanXCount, sleByte, VER(97)), + MKLINE(Actor_v0, _walkXCount, sleByte, VER(97)), + MKLINE(Actor_v0, _walkXCountInc, sleByte, VER(97)), + MKLINE(Actor_v0, _walkYCount, sleByte, VER(97)), + MKLINE(Actor_v0, _walkYCountInc, sleByte, VER(97)), + MKLINE(Actor_v0, _walkMaxXYCountInc, sleByte, VER(97)), MKEND() }; diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index c554cad040..c1a3f23318 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -356,7 +356,7 @@ public: byte _speaking; byte _walkCountModulo; - byte _newWalkBoxEntered; + bool _newWalkBoxEntered; byte _walkDirX; byte _walkDirY; @@ -372,7 +372,7 @@ public: Common::Point _tmp_Pos; Common::Point _tmp_Dest; byte _tmp_WalkBox; - byte _tmp_NewWalkBoxEntered; + bool _tmp_NewWalkBoxEntered; int8 _animFrameRepeat; int8 _limbFrameRepeatNew[8]; @@ -401,6 +401,9 @@ public: byte actorWalkY(); byte updateWalkbox(); + AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY); + AdjustBoxResult adjustPosInBorderWalkbox(AdjustBoxResult box); + void setTmpFromActor(); void setActorFromTmp(); diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index 01ed21ece5..753287e217 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -47,7 +47,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 96 +#define CURRENT_VER 97 /** * An auxillary macro, used to specify savegame versions. We use this instead diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index efd5e7bd2c..c9b37d43b1 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -1164,8 +1164,10 @@ void ScummEngine_v0::walkToActorOrObject(int object) { VAR(7) = y; // actor must not move if frozen - if (a->_miscflags & kActorMiscFlagFreeze) + if (a->_miscflags & kActorMiscFlagFreeze) { a->stopActorMoving(); + a->_newWalkBoxEntered = false; + } } bool ScummEngine_v0::checkPendingWalkAction() { @@ -1179,7 +1181,7 @@ bool ScummEngine_v0::checkPendingWalkAction() { Actor_v0 *a = (Actor_v0 *)derefActor(actor, "checkPendingWalkAction"); // wait until walking or turning action is finished - if (a->_moving!=2) + if (a->_moving != 2) return true; // after walking and turning finally execute the script -- cgit v1.2.3 From 4b1b9ec66f5889fd20d88f8f7f565e8448ac8389 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Tue, 2 Dec 2014 16:40:46 +1100 Subject: SCUMM: Maniac V0: Remove workaround for bug #2971126 (this issue no longer occurs as walking is handled the same as the original) --- engines/scumm/script_v5.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/scumm/script_v5.cpp b/engines/scumm/script_v5.cpp index 91afa859a9..4a53ca3fed 100644 --- a/engines/scumm/script_v5.cpp +++ b/engines/scumm/script_v5.cpp @@ -2497,10 +2497,6 @@ void ScummEngine_v5::walkActorToActor(int actor, int toActor, int dist) { y = abr.y; } a->startWalkActor(x, y, -1); - - // WORKAROUND: See bug #2971126 for details on why this is here. - if (_game.version == 0) - o5_breakHere(); } void ScummEngine_v5::o5_walkActorToActor() { -- cgit v1.2.3 From 11d41ace02ce84ab40de2ae315a106950579e2bd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 00:52:11 +0200 Subject: ZVISION: Use the ScummVM defined type int32, instead of int32_t --- engines/zvision/text/text.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 872d6875b7..3cfc5b2f89 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -457,7 +457,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac j++; } dx = 0; - for (int32_t jj = 0; jj < j; jj++) { + for (int32 jj = 0; jj < j; jj++) { if (TxtJustify[i] == TXT_JUSTIFY_LEFT) _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); @@ -474,7 +474,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac } for (i = 0; i < TXT_CFG_TEXTURES_LINES; i++) - for (int32_t j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) + for (int32 j = 0; j < TXT_CFG_TEXTURES_PER_LINE; j++) if (TxtSurfaces[i][j] != NULL) { TxtSurfaces[i][j]->free(); delete TxtSurfaces[i][j]; -- cgit v1.2.3 From 61f654e4eee90d761c06583a67dc9631db9d0d29 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 00:53:36 +0200 Subject: ZVISION: Explicitly define which version of atan2() to use This is needed by MSVC --- engines/zvision/graphics/render_table.cpp | 2 +- engines/zvision/scripting/controls/safe_control.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 629cbde3cf..5500b50ba8 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -200,7 +200,7 @@ void RenderTable::generateTiltLookupTable() { float fovInRadians = (_tiltOptions.fieldOfView * M_PI / 180.0f); float cylinderRadius = halfWidth / tan(fovInRadians); - _tiltOptions.gap = cylinderRadius * atan2(halfHeight / cylinderRadius, 1.0) * _tiltOptions.linearScale; + _tiltOptions.gap = cylinderRadius * atan2((float)(halfHeight / cylinderRadius), 1.0f) * _tiltOptions.linearScale; for (uint y = 0; y < _numRows; ++y) { diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index de1ece5b19..66ab53085f 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -181,7 +181,7 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P Common::Point tmp = backgroundImageSpacePos - _center; - float dd = atan2(tmp.x, tmp.y) * 57.29578; + float dd = atan2((float)tmp.x, (float)tmp.y) * 57.29578; int16 dp_state = 360 / _statesCount; -- cgit v1.2.3 From daeb1ea288ee8ae9742f0a0fa41aeaea8c41bc9e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 00:54:19 +0200 Subject: ZVISION: Silence some false positive warnings by MSVC --- engines/zvision/scripting/sidefx/music_node.cpp | 2 +- engines/zvision/scripting/sidefx/syncsound_node.cpp | 2 +- engines/zvision/sound/zork_raw.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index e9baadb011..b1e16e71ef 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -49,7 +49,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool _pantrackPosition = 0; _sub = NULL; - Audio::RewindableAudioStream *audioStream; + Audio::RewindableAudioStream *audioStream = NULL; if (filename.contains(".wav")) { Common::File *file = new Common::File(); diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp index 2bfdc349d1..39542675eb 100644 --- a/engines/zvision/scripting/sidefx/syncsound_node.cpp +++ b/engines/zvision/scripting/sidefx/syncsound_node.cpp @@ -41,7 +41,7 @@ SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filena _syncto = syncto; _sub = NULL; - Audio::RewindableAudioStream *audioStream; + Audio::RewindableAudioStream *audioStream = NULL; if (filename.contains(".wav")) { Common::File *file = new Common::File(); diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index a0f660f65f..1581210c86 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -259,7 +259,7 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, Common::String fileName = getFileName(filePath); fileName.toLowercase(); - SoundParams soundParams; + SoundParams soundParams = {}; if (engine->getGameId() == GID_NEMESIS) { for (int i = 0; i < 32; ++i) { -- cgit v1.2.3 From 7976a34bbfbece2686712d80b1efa3612cb2b441 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 00:55:14 +0200 Subject: ZVISION: Rename struct member to fix compilation with MSVC A struct member can't have the same name as the struct itself --- engines/zvision/subtitles/subtitles.cpp | 6 +++--- engines/zvision/subtitles/subtitles.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp index 1f68b2435f..d36eb24923 100644 --- a/engines/zvision/subtitles/subtitles.cpp +++ b/engines/zvision/subtitles/subtitles.cpp @@ -55,7 +55,7 @@ Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : sub curSubtitle; curSubtitle.start = -1; curSubtitle.stop = -1; - curSubtitle.sub = txtline; + curSubtitle.subStr = txtline; _subs.push_back(curSubtitle); } @@ -98,9 +98,9 @@ void Subtitle::process(int32 time) { } if (j != -1 && j != _subId) { - if (_subs[j].sub.size()) + if (_subs[j].subStr.size()) if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].sub); + _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr); _subId = j; } } diff --git a/engines/zvision/subtitles/subtitles.h b/engines/zvision/subtitles/subtitles.h index 09e079bba4..c3da6583a4 100644 --- a/engines/zvision/subtitles/subtitles.h +++ b/engines/zvision/subtitles/subtitles.h @@ -43,7 +43,7 @@ private: struct sub { int start; int stop; - Common::String sub; + Common::String subStr; }; Common::Array _subs; -- cgit v1.2.3 From 2a4a6df5f2ae89132fd93d26b03599b6cc5c5fb7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:12:35 +0200 Subject: ZVISION: Remove superfluous spacing and reorder some includes --- engines/zvision/animation/meta_animation.cpp | 1 - engines/zvision/animation/meta_animation.h | 1 - engines/zvision/animation/rlf_animation.cpp | 1 - engines/zvision/animation/rlf_animation.h | 1 - engines/zvision/archives/zfs_archive.cpp | 2 -- engines/zvision/archives/zfs_archive.h | 1 - engines/zvision/core/console.cpp | 1 - engines/zvision/core/events.cpp | 1 - engines/zvision/core/menu.cpp | 4 ---- engines/zvision/core/menu.h | 2 -- engines/zvision/core/save_manager.cpp | 1 - engines/zvision/core/search_manager.cpp | 2 -- engines/zvision/cursors/cursor.cpp | 1 - engines/zvision/cursors/cursor.h | 1 - engines/zvision/cursors/cursor_manager.cpp | 2 -- engines/zvision/cursors/cursor_manager.h | 1 - engines/zvision/detection.cpp | 3 --- engines/zvision/detection.h | 1 - engines/zvision/fonts/truetype_font.cpp | 1 - engines/zvision/fonts/truetype_font.h | 1 - engines/zvision/graphics/effects/fog.cpp | 1 - engines/zvision/graphics/effects/light.cpp | 1 - engines/zvision/graphics/effects/wave.cpp | 1 - engines/zvision/graphics/render_manager.cpp | 4 ---- engines/zvision/graphics/render_manager.h | 3 --- engines/zvision/graphics/render_table.cpp | 4 ---- engines/zvision/graphics/render_table.h | 1 - engines/zvision/scripting/actions.cpp | 15 --------------- engines/zvision/scripting/actions.h | 1 - engines/zvision/scripting/control.cpp | 1 - engines/zvision/scripting/control.h | 1 - engines/zvision/scripting/controls/fist_control.cpp | 1 - engines/zvision/scripting/controls/fist_control.h | 1 - engines/zvision/scripting/controls/hotmov_control.cpp | 1 - engines/zvision/scripting/controls/hotmov_control.h | 1 - engines/zvision/scripting/controls/input_control.cpp | 1 - engines/zvision/scripting/controls/input_control.h | 1 - engines/zvision/scripting/controls/lever_control.cpp | 1 - engines/zvision/scripting/controls/lever_control.h | 1 - engines/zvision/scripting/controls/paint_control.cpp | 2 -- engines/zvision/scripting/controls/paint_control.h | 1 - .../zvision/scripting/controls/push_toggle_control.cpp | 1 - engines/zvision/scripting/controls/push_toggle_control.h | 1 - engines/zvision/scripting/controls/safe_control.cpp | 1 - engines/zvision/scripting/controls/safe_control.h | 1 - engines/zvision/scripting/controls/save_control.cpp | 1 - engines/zvision/scripting/controls/save_control.h | 1 - engines/zvision/scripting/controls/slot_control.cpp | 1 - engines/zvision/scripting/controls/slot_control.h | 1 - engines/zvision/scripting/controls/titler_control.cpp | 1 - engines/zvision/scripting/controls/titler_control.h | 1 - engines/zvision/scripting/inventory.cpp | 1 - engines/zvision/scripting/puzzle.h | 1 - engines/zvision/scripting/scr_file_handling.cpp | 3 --- engines/zvision/scripting/script_manager.cpp | 1 - engines/zvision/scripting/script_manager.h | 2 -- engines/zvision/scripting/sidefx.cpp | 1 - engines/zvision/scripting/sidefx/animation_node.cpp | 3 --- engines/zvision/scripting/sidefx/animation_node.h | 1 - engines/zvision/scripting/sidefx/distort_node.cpp | 4 ---- engines/zvision/scripting/sidefx/music_node.cpp | 2 -- engines/zvision/scripting/sidefx/syncsound_node.cpp | 1 - engines/zvision/scripting/sidefx/timer_node.cpp | 1 - engines/zvision/scripting/sidefx/ttytext_node.cpp | 1 - engines/zvision/sound/zork_raw.cpp | 1 - engines/zvision/sound/zork_raw.h | 2 -- engines/zvision/text/string_manager.cpp | 1 - engines/zvision/text/string_manager.h | 1 - engines/zvision/text/text.cpp | 1 - engines/zvision/text/text.h | 1 - engines/zvision/utility/clock.cpp | 1 - engines/zvision/utility/lzss_read_stream.cpp | 1 - engines/zvision/utility/lzss_read_stream.h | 1 - engines/zvision/utility/single_value_container.cpp | 6 +----- engines/zvision/utility/utility.cpp | 1 - engines/zvision/utility/utility.h | 1 - engines/zvision/video/video.cpp | 15 ++++----------- engines/zvision/video/zork_avi_decoder.cpp | 1 - engines/zvision/zvision.cpp | 1 - engines/zvision/zvision.h | 1 - 80 files changed, 5 insertions(+), 136 deletions(-) diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp index 2e549ec838..857a0dd688 100644 --- a/engines/zvision/animation/meta_animation.cpp +++ b/engines/zvision/animation/meta_animation.cpp @@ -34,7 +34,6 @@ #include "graphics/surface.h" - namespace ZVision { MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h index 4795a388e4..93b69587c4 100644 --- a/engines/zvision/animation/meta_animation.h +++ b/engines/zvision/animation/meta_animation.h @@ -28,7 +28,6 @@ #include "common/rect.h" #include "common/list.h" - namespace Common { class String; } diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp index 5972bdb3ef..d9b8fa3894 100644 --- a/engines/zvision/animation/rlf_animation.cpp +++ b/engines/zvision/animation/rlf_animation.cpp @@ -32,7 +32,6 @@ #include "graphics/colormasks.h" - namespace ZVision { RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h index 00c2e9b3d5..c8b2930676 100644 --- a/engines/zvision/animation/rlf_animation.h +++ b/engines/zvision/animation/rlf_animation.h @@ -27,7 +27,6 @@ #include "graphics/surface.h" - namespace Common { class String; } diff --git a/engines/zvision/archives/zfs_archive.cpp b/engines/zvision/archives/zfs_archive.cpp index ed4dcec1fe..416719b8f2 100644 --- a/engines/zvision/archives/zfs_archive.cpp +++ b/engines/zvision/archives/zfs_archive.cpp @@ -153,5 +153,3 @@ void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const { } } // End of namespace ZVision - - diff --git a/engines/zvision/archives/zfs_archive.h b/engines/zvision/archives/zfs_archive.h index 44e2c4b240..571591a6d1 100644 --- a/engines/zvision/archives/zfs_archive.h +++ b/engines/zvision/archives/zfs_archive.h @@ -27,7 +27,6 @@ #include "common/hashmap.h" #include "common/hash-str.h" - namespace Common { class String; } diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index aac4e7b2bc..201d1c9360 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -41,7 +41,6 @@ #include "audio/mixer.h" - namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 873cdb0df7..e3bcf6f09a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -40,7 +40,6 @@ #include "engines/util.h" - namespace ZVision { void ZVision::shortKeys(Common::Event event) { diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index 5816b3f364..c7898a4fbd 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -26,7 +26,6 @@ #include "zvision/graphics/render_manager.h" - namespace ZVision { enum { @@ -380,7 +379,6 @@ void MenuZGI::process(uint32 deltatime) { else if (itemCount > 50) itemCount = 50; - for (int i = 0; i < itemCount; i++) { int itemspace = (600 - 28) / itemCount; @@ -553,7 +551,6 @@ void MenuZGI::process(uint32 deltatime) { } } - MenuNemesis::MenuNemesis(ZVision *engine) : MenuHandler(engine) { inmenu = false; @@ -761,5 +758,4 @@ void MenuNemesis::process(uint32 deltatime) { } } - } // End of namespace ZVision diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 62683de912..7301323173 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -70,8 +70,6 @@ public: private: Graphics::Surface menuback[3][2]; Graphics::Surface menubar[4][2]; - - Graphics::Surface *items[50][2]; uint itemId[50]; diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 9b36824c3b..11d3dd391a 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -35,7 +35,6 @@ #include "gui/message.h" - namespace ZVision { const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 8350189566..1e9643ddbb 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -27,7 +27,6 @@ #include "common/fs.h" #include "common/stream.h" - namespace ZVision { SearchManager::SearchManager(const Common::String &rootPath, int depth) { @@ -237,7 +236,6 @@ void SearchManager::addDir(const Common::String &name) { Common::ArchiveMemberList list; dir->listMatchingMembers(list, "*.zfs"); - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { Common::String flname = (*iter)->getName(); diff --git a/engines/zvision/cursors/cursor.cpp b/engines/zvision/cursors/cursor.cpp index 8c6027a1bb..b07220df92 100644 --- a/engines/zvision/cursors/cursor.cpp +++ b/engines/zvision/cursors/cursor.cpp @@ -27,7 +27,6 @@ #include "common/str.h" #include "common/file.h" - namespace ZVision { ZorkCursor::ZorkCursor() diff --git a/engines/zvision/cursors/cursor.h b/engines/zvision/cursors/cursor.h index 57db561655..0c1e99411f 100644 --- a/engines/zvision/cursors/cursor.h +++ b/engines/zvision/cursors/cursor.h @@ -26,7 +26,6 @@ #include "graphics/surface.h" #include "zvision/zvision.h" - namespace Common { class String; } diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp index 564ffd25c5..33fb55515b 100644 --- a/engines/zvision/cursors/cursor_manager.cpp +++ b/engines/zvision/cursors/cursor_manager.cpp @@ -31,7 +31,6 @@ #include "graphics/pixelformat.h" #include "graphics/cursorman.h" - namespace ZVision { const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft", @@ -46,7 +45,6 @@ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" }; - CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h index a6f77cec64..460f6fade6 100644 --- a/engines/zvision/cursors/cursor_manager.h +++ b/engines/zvision/cursors/cursor_manager.h @@ -27,7 +27,6 @@ #include "common/str.h" - namespace Graphics { struct PixelFormat; } diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index cd696557d9..4d210abe86 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -32,7 +32,6 @@ #include "common/str-array.h" #include "common/system.h" - namespace ZVision { uint32 ZVision::getFeatures() const { @@ -45,7 +44,6 @@ Common::Language ZVision::getLanguage() const { } // End of namespace ZVision - static const PlainGameDescriptor zVisionGames[] = { {"zvision", "ZVision Game"}, {"znemesis", "Zork Nemesis: The Forbidden Lands"}, @@ -53,7 +51,6 @@ static const PlainGameDescriptor zVisionGames[] = { {0, 0} }; - namespace ZVision { static const ZVisionGameDescription gameDescriptions[] = { diff --git a/engines/zvision/detection.h b/engines/zvision/detection.h index a788e710b7..f80cac79ec 100644 --- a/engines/zvision/detection.h +++ b/engines/zvision/detection.h @@ -25,7 +25,6 @@ #include "engines/advancedDetector.h" - namespace ZVision { enum ZVisionGameId { diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp index 638a8ed233..a9363d8923 100644 --- a/engines/zvision/fonts/truetype_font.cpp +++ b/engines/zvision/fonts/truetype_font.cpp @@ -37,7 +37,6 @@ #include "graphics/fonts/ttf.h" #include "graphics/surface.h" - namespace ZVision { TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h index 771c02a6dc..30ef1c73a3 100644 --- a/engines/zvision/fonts/truetype_font.h +++ b/engines/zvision/fonts/truetype_font.h @@ -28,7 +28,6 @@ #include "graphics/font.h" #include "graphics/pixelformat.h" - namespace Graphics { struct Surface; } diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp index b6c5e7b011..f59e82a4a0 100644 --- a/engines/zvision/graphics/effects/fog.cpp +++ b/engines/zvision/graphics/effects/fog.cpp @@ -28,7 +28,6 @@ #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" - namespace ZVision { FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds): diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp index 9bff077051..00b3811d65 100644 --- a/engines/zvision/graphics/effects/light.cpp +++ b/engines/zvision/graphics/effects/light.cpp @@ -27,7 +27,6 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" - namespace ZVision { LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD): diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp index 9f2fbb285c..1b3aa040e8 100644 --- a/engines/zvision/graphics/effects/wave.cpp +++ b/engines/zvision/graphics/effects/wave.cpp @@ -27,7 +27,6 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" - namespace ZVision { WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd): diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 05f8dec937..97d47e3920 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -37,7 +37,6 @@ #include "image/tga.h" - namespace ZVision { RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) @@ -122,7 +121,6 @@ void RenderManager::renderBackbufferToScreen() { outWndDirtyRect = _wrkWndDirtyRect; } - if (!outWndDirtyRect.isEmpty()) { _system->copyRectToScreen(out->getBasePtr(outWndDirtyRect.left, outWndDirtyRect.top), out->pitch, outWndDirtyRect.left + _workingWindow.left, @@ -511,8 +509,6 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (srcRect.isEmpty() || !srcRect.isValidRect()) return; - - uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1); // Copy srcRect from src surface to dst surface diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 7723c3d0f3..39809c65a4 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -33,7 +33,6 @@ #include "effect.h" - class OSystem; namespace Common { @@ -92,7 +91,6 @@ private: // A buffer used for apply graphics effects Graphics::Surface _effectWnd; - /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */ const int _wrkWidth; /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */ @@ -256,7 +254,6 @@ public: // Processing subtitles void processSubs(uint16 deltatime); - // Return background size Common::Point getBkgSize(); diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 5500b50ba8..54faecfa8b 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -21,14 +21,10 @@ */ #include "common/scummsys.h" - #include "zvision/graphics/render_table.h" - #include "common/rect.h" - #include "graphics/colormasks.h" - namespace ZVision { RenderTable::RenderTable(uint numColumns, uint numRows) diff --git a/engines/zvision/graphics/render_table.h b/engines/zvision/graphics/render_table.h index f061b3b0d6..7455d9ba39 100644 --- a/engines/zvision/graphics/render_table.h +++ b/engines/zvision/graphics/render_table.h @@ -26,7 +26,6 @@ #include "common/rect.h" #include "graphics/surface.h" - namespace ZVision { class RenderTable { diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 8ff6bd0496..c8c82063f7 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -49,7 +49,6 @@ #include "audio/decoders/wave.h" - namespace ZVision { ////////////////////////////////////////////////////////////////////////////// @@ -66,7 +65,6 @@ bool ActionAdd::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionAssign ////////////////////////////////////////////////////////////////////////////// @@ -89,7 +87,6 @@ bool ActionAssign::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionAttenuate ////////////////////////////////////////////////////////////////////////////// @@ -108,7 +105,6 @@ bool ActionAttenuate::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionChangeLocation ////////////////////////////////////////////////////////////////////////////// @@ -125,7 +121,6 @@ bool ActionChangeLocation::execute() { return false; } - ////////////////////////////////////////////////////////////////////////////// // ActionCrossfade ////////////////////////////////////////////////////////////////////////////// @@ -368,7 +363,6 @@ bool ActionInventory::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionKill ////////////////////////////////////////////////////////////////////////////// @@ -457,8 +451,6 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l _volume = volume * 255 / 100; } } - - } ActionMusic::~ActionMusic() { @@ -583,7 +575,6 @@ bool ActionUnloadAnimation::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionPlayAnimation ////////////////////////////////////////////////////////////////////////////// @@ -625,7 +616,6 @@ bool ActionPlayAnimation::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionPlayPreloadAnimation ////////////////////////////////////////////////////////////////////////////// @@ -646,7 +636,6 @@ bool ActionPlayPreloadAnimation::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionQuit ////////////////////////////////////////////////////////////////////////////// @@ -786,7 +775,6 @@ bool ActionRotateTo::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionSetPartialScreen ////////////////////////////////////////////////////////////////////////////// @@ -833,7 +821,6 @@ bool ActionSetPartialScreen::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionSetScreen ////////////////////////////////////////////////////////////////////////////// @@ -852,7 +839,6 @@ bool ActionSetScreen::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionSetVenus ////////////////////////////////////////////////////////////////////////////// @@ -884,7 +870,6 @@ bool ActionStop::execute() { return true; } - ////////////////////////////////////////////////////////////////////////////// // ActionStreamVideo ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 03a249e580..f9e4ee8167 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -28,7 +28,6 @@ #include "audio/mixer.h" - namespace ZVision { // Forward declaration of ZVision. This file is included before ZVision is declared diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index e69d57f75c..5469106928 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -31,7 +31,6 @@ #include "common/stream.h" - namespace ZVision { void Control::parseFlatControl(ZVision *engine) { diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 5814c9e419..803d0cf1ce 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -26,7 +26,6 @@ #include "common/keyboard.h" #include "common/str.h" - namespace Common { class SeekableReadStream; struct Point; diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 9bb03cba51..dd6a7f11a9 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -37,7 +37,6 @@ #include "graphics/surface.h" - namespace ZVision { FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index 33c3c7b579..cb765c429a 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -28,7 +28,6 @@ #include "common/array.h" #include "common/rect.h" - namespace ZVision { class MetaAnimation; diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index fd7afb92d1..68861dc221 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -37,7 +37,6 @@ #include "graphics/surface.h" - namespace ZVision { HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index 9e01b40bab..86600d65dc 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -28,7 +28,6 @@ #include "common/array.h" #include "common/rect.h" - namespace ZVision { class MetaAnimation; diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 8af436bb40..c541693ec3 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -35,7 +35,6 @@ #include "common/stream.h" #include "common/rect.h" - namespace ZVision { InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 9a829d30f6..410caf6d49 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -30,7 +30,6 @@ #include "common/rect.h" - namespace ZVision { class InputControl : public Control { diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 1f176ef9d0..12b07d7584 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -38,7 +38,6 @@ #include "graphics/surface.h" - namespace ZVision { LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h index 8de6d1e5c9..37d4d3bd8d 100644 --- a/engines/zvision/scripting/controls/lever_control.h +++ b/engines/zvision/scripting/controls/lever_control.h @@ -28,7 +28,6 @@ #include "common/list.h" #include "common/rect.h" - namespace ZVision { class ZorkAVIDecoder; diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index cb3c17e0fd..9bad6f2c58 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -110,8 +110,6 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre delete _paint; _paint = tmp; } - - } PaintControl::~PaintControl() { diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h index aac4755fcd..8097290ac2 100644 --- a/engines/zvision/scripting/controls/paint_control.h +++ b/engines/zvision/scripting/controls/paint_control.h @@ -30,7 +30,6 @@ #include "common/rect.h" #include "common/list.h" - namespace ZVision { class PaintControl : public Control { diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index ea4e947abe..c5ec070899 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -31,7 +31,6 @@ #include "common/stream.h" - namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/push_toggle_control.h b/engines/zvision/scripting/controls/push_toggle_control.h index 6d68b8f162..9444c77cb6 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.h +++ b/engines/zvision/scripting/controls/push_toggle_control.h @@ -29,7 +29,6 @@ #include "common/events.h" #include "common/array.h" - namespace ZVision { class PushToggleControl : public Control { diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 66ab53085f..3ad5d3a8ae 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -38,7 +38,6 @@ #include "graphics/surface.h" - namespace ZVision { SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h index e682e35050..e32ca97b70 100644 --- a/engines/zvision/scripting/controls/safe_control.h +++ b/engines/zvision/scripting/controls/safe_control.h @@ -28,7 +28,6 @@ #include "common/list.h" #include "common/rect.h" - namespace ZVision { class ZorkAVIDecoder; diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index 7e1a65a9cc..ad01257e6b 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -35,7 +35,6 @@ #include "common/str.h" #include "common/stream.h" - namespace ZVision { SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/save_control.h b/engines/zvision/scripting/controls/save_control.h index fefb0e0ce2..cdc50eb54d 100644 --- a/engines/zvision/scripting/controls/save_control.h +++ b/engines/zvision/scripting/controls/save_control.h @@ -27,7 +27,6 @@ #include "common/list.h" - namespace ZVision { class SaveControl : public Control { diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 074d1905b4..1d83b44392 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -32,7 +32,6 @@ #include "common/stream.h" - namespace ZVision { SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/slot_control.h b/engines/zvision/scripting/controls/slot_control.h index 86fd261f25..e776d99311 100644 --- a/engines/zvision/scripting/controls/slot_control.h +++ b/engines/zvision/scripting/controls/slot_control.h @@ -30,7 +30,6 @@ #include "common/rect.h" #include "common/list.h" - namespace ZVision { class SlotControl : public Control { diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index b803501033..f0126bebc2 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -32,7 +32,6 @@ #include "common/stream.h" - namespace ZVision { TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h index ee230afa97..075e47c9e9 100644 --- a/engines/zvision/scripting/controls/titler_control.h +++ b/engines/zvision/scripting/controls/titler_control.h @@ -30,7 +30,6 @@ #include "common/rect.h" #include "common/array.h" - namespace ZVision { class TitlerControl : public Control { diff --git a/engines/zvision/scripting/inventory.cpp b/engines/zvision/scripting/inventory.cpp index 98d063395b..76d43b200b 100644 --- a/engines/zvision/scripting/inventory.cpp +++ b/engines/zvision/scripting/inventory.cpp @@ -24,7 +24,6 @@ #include "zvision/scripting/script_manager.h" - namespace ZVision { int8 ScriptManager::inventoryGetCount() { diff --git a/engines/zvision/scripting/puzzle.h b/engines/zvision/scripting/puzzle.h index ab38c5fc5d..4123880835 100644 --- a/engines/zvision/scripting/puzzle.h +++ b/engines/zvision/scripting/puzzle.h @@ -28,7 +28,6 @@ #include "common/list.h" #include "common/ptr.h" - namespace ZVision { struct Puzzle { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 697de58ed8..f97eed6b75 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -43,7 +43,6 @@ #include "common/file.h" #include "common/tokenizer.h" - namespace ZVision { void ScriptManager::parseScrFile(const Common::String &fileName, ScriptScope &scope) { @@ -210,8 +209,6 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis args = Common::String(chrs + startpos, chrs + pos); } - - // Parse for the action type if (act.matchString("add", true)) { actionList.push_back(new ActionAdd(_engine, slot, args)); diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 2a54cc4314..7904817156 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -37,7 +37,6 @@ #include "common/debug.h" #include "common/stream.h" - namespace ZVision { ScriptManager::ScriptManager(ZVision *engine) diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 5701cde6d0..89b961634b 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -31,7 +31,6 @@ #include "common/queue.h" #include "common/events.h" - namespace Common { class String; class SeekableReadStream; @@ -340,7 +339,6 @@ private: ScriptManager *_scriptManager; }; - } // End of namespace ZVision #endif diff --git a/engines/zvision/scripting/sidefx.cpp b/engines/zvision/scripting/sidefx.cpp index c0b8a4d12f..9a658817c9 100644 --- a/engines/zvision/scripting/sidefx.cpp +++ b/engines/zvision/scripting/sidefx.cpp @@ -32,5 +32,4 @@ namespace ZVision { - } // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 98ac4e3b37..549aacba7f 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -31,7 +31,6 @@ #include "graphics/surface.h" - namespace ZVision { AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) @@ -154,8 +153,6 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { return false; } - - void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) { playnode nod; nod.loop = loops; diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index dab3d88d80..94428d2542 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -27,7 +27,6 @@ #include "common/rect.h" #include "common/list.h" - namespace Common { class String; } diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp index 9be6b29413..0d5c8b1ed5 100644 --- a/engines/zvision/scripting/sidefx/distort_node.cpp +++ b/engines/zvision/scripting/sidefx/distort_node.cpp @@ -31,7 +31,6 @@ #include "common/stream.h" - namespace ZVision { DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale) @@ -83,8 +82,6 @@ bool DistortNode::process(uint32 deltaTimeInMillis) { } float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed); - - setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale); return false; @@ -105,5 +102,4 @@ void DistortNode::setParams(float angl, float linScale) { } } - } // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index b1e16e71ef..a76d3b4e8d 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -34,7 +34,6 @@ #include "common/file.h" #include "audio/decoders/wave.h" - namespace ZVision { MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) @@ -188,7 +187,6 @@ PanTrackNode::~PanTrackNode() { } } - MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) : MusicNodeBASE(engine, key, SIDEFX_AUDIO) { _volume = volume; diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp index 39542675eb..c1f139694b 100644 --- a/engines/zvision/scripting/sidefx/syncsound_node.cpp +++ b/engines/zvision/scripting/sidefx/syncsound_node.cpp @@ -33,7 +33,6 @@ #include "common/file.h" #include "audio/decoders/wave.h" - namespace ZVision { SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp index 6e71101acd..abf2c90b04 100644 --- a/engines/zvision/scripting/sidefx/timer_node.cpp +++ b/engines/zvision/scripting/sidefx/timer_node.cpp @@ -29,7 +29,6 @@ #include "common/stream.h" - namespace ZVision { TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp index 68636eb422..1fb7c10792 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.cpp +++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp @@ -32,7 +32,6 @@ #include "common/stream.h" #include "common/file.h" - namespace ZVision { ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 1581210c86..485e0b8a49 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -38,7 +38,6 @@ #include "audio/audiostream.h" #include "audio/decoders/raw.h" - namespace ZVision { const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12}; diff --git a/engines/zvision/sound/zork_raw.h b/engines/zvision/sound/zork_raw.h index a5e346dfbb..0b408d818c 100644 --- a/engines/zvision/sound/zork_raw.h +++ b/engines/zvision/sound/zork_raw.h @@ -25,7 +25,6 @@ #include "audio/audiostream.h" - namespace Common { class SeekableReadStream; } @@ -42,7 +41,6 @@ struct SoundParams { bool bits16; }; - /** * This is a ADPCM stream-reader, this class holds context for multi-chunk reading and no buffers. */ diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index 114f298505..f88f9eaddd 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -35,7 +35,6 @@ #include "graphics/fontman.h" #include "graphics/colormasks.h" - namespace ZVision { StringManager::StringManager(ZVision *engine) diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index 5420e1f3ee..61c0d95f51 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -26,7 +26,6 @@ #include "zvision/detection.h" #include "zvision/fonts/truetype_font.h" - namespace Graphics { class FontManager; } diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 3cfc5b2f89..6f41416015 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -40,7 +40,6 @@ #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" - namespace ZVision { cTxtStyle::cTxtStyle() { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index c2468383d3..6b916860f0 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -28,7 +28,6 @@ #include "zvision/fonts/truetype_font.h" #include "zvision/zvision.h" - namespace Graphics { class FontManager; } diff --git a/engines/zvision/utility/clock.cpp b/engines/zvision/utility/clock.cpp index 45ab23ab65..0e800a2031 100644 --- a/engines/zvision/utility/clock.cpp +++ b/engines/zvision/utility/clock.cpp @@ -26,7 +26,6 @@ #include "common/system.h" - namespace ZVision { Clock::Clock(OSystem *system) diff --git a/engines/zvision/utility/lzss_read_stream.cpp b/engines/zvision/utility/lzss_read_stream.cpp index 14613a6fb2..bbe6e35f76 100644 --- a/engines/zvision/utility/lzss_read_stream.cpp +++ b/engines/zvision/utility/lzss_read_stream.cpp @@ -24,7 +24,6 @@ #include "zvision/utility/lzss_read_stream.h" - namespace ZVision { LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) diff --git a/engines/zvision/utility/lzss_read_stream.h b/engines/zvision/utility/lzss_read_stream.h index b7ae5ac2cb..1420621f13 100644 --- a/engines/zvision/utility/lzss_read_stream.h +++ b/engines/zvision/utility/lzss_read_stream.h @@ -26,7 +26,6 @@ #include "common/stream.h" #include "common/array.h" - namespace Common { class SeekableReadStream; } diff --git a/engines/zvision/utility/single_value_container.cpp b/engines/zvision/utility/single_value_container.cpp index e609474285..774f4b72ee 100644 --- a/engines/zvision/utility/single_value_container.cpp +++ b/engines/zvision/utility/single_value_container.cpp @@ -21,12 +21,10 @@ */ #include "common/scummsys.h" - -#include "zvision/utility/single_value_container.h" - #include "common/textconsole.h" #include "common/str.h" +#include "zvision/utility/single_value_container.h" namespace ZVision { @@ -114,7 +112,6 @@ void SingleValueContainer::deleteCharPointer() { delete[] _value.stringVal; } - SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) { if (_objectType == BOOL) { _value.boolVal = rhs; @@ -270,7 +267,6 @@ SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer return *this; } - bool SingleValueContainer::getBoolValue(bool *returnValue) const { if (_objectType != BOOL) { warning("'Object' is not storing a bool."); diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp index 537f525bd4..517c89afbd 100644 --- a/engines/zvision/utility/utility.cpp +++ b/engines/zvision/utility/utility.cpp @@ -30,7 +30,6 @@ #include "common/tokenizer.h" #include "common/file.h" - namespace ZVision { void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) { diff --git a/engines/zvision/utility/utility.h b/engines/zvision/utility/utility.h index 380034404a..0741cc044c 100644 --- a/engines/zvision/utility/utility.h +++ b/engines/zvision/utility/utility.h @@ -25,7 +25,6 @@ #include "common/array.h" - namespace Common { class String; } diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 7a120df76b..25125ec2fb 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -21,21 +21,15 @@ */ #include "common/scummsys.h" - -#include "zvision/zvision.h" - -#include "zvision/utility/clock.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/subtitles/subtitles.h" - #include "common/system.h" - #include "video/video_decoder.h" - #include "engines/util.h" - #include "graphics/surface.h" +#include "zvision/zvision.h" +#include "zvision/utility/clock.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/subtitles/subtitles.h" namespace ZVision { @@ -52,7 +46,6 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, scaled->create(dst.width(), dst.height(), vid.getPixelFormat()); } - uint16 x = _workingWindow.left + dst.left; uint16 y = _workingWindow.top + dst.top; uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width(); diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 415a20d3f2..67fab0a114 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -31,7 +31,6 @@ #include "audio/audiostream.h" #include "audio/decoders/raw.h" - namespace ZVision { Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 62342f02b9..7a5e50f491 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -51,7 +51,6 @@ #include "audio/mixer.h" - namespace ZVision { #define ZVISION_SETTINGS_KEYS_COUNT 17 diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 8b14cfa178..ae49f0640f 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -37,7 +37,6 @@ #include "gui/debugger.h" - namespace Video { class VideoDecoder; } -- cgit v1.2.3 From 0f55a7faf72b6cb0327236e9fb8f2ec8bd6d91a3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:15:33 +0200 Subject: ZVISION: Remove empty file --- engines/zvision/module.mk | 1 - engines/zvision/scripting/sidefx.cpp | 35 ----------------------------------- 2 files changed, 36 deletions(-) delete mode 100644 engines/zvision/scripting/sidefx.cpp diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index f7927650d9..f2455a5d9c 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -34,7 +34,6 @@ MODULE_OBJS := \ scripting/inventory.o \ scripting/scr_file_handling.o \ scripting/script_manager.o \ - scripting/sidefx.o \ scripting/sidefx/animation_node.o \ scripting/sidefx/distort_node.o \ scripting/sidefx/music_node.o \ diff --git a/engines/zvision/scripting/sidefx.cpp b/engines/zvision/scripting/sidefx.cpp deleted file mode 100644 index 9a658817c9..0000000000 --- a/engines/zvision/scripting/sidefx.cpp +++ /dev/null @@ -1,35 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" - -#include "common/stream.h" - -namespace ZVision { - -} // End of namespace ZVision -- cgit v1.2.3 From fd2750a71152d09557709a49f055b50937919326 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:41:06 +0200 Subject: ZVISION: Remove dead code --- engines/zvision/module.mk | 1 - engines/zvision/utility/single_value_container.cpp | 344 --------------------- engines/zvision/utility/single_value_container.h | 183 ----------- 3 files changed, 528 deletions(-) delete mode 100644 engines/zvision/utility/single_value_container.cpp delete mode 100644 engines/zvision/utility/single_value_container.h diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index f2455a5d9c..140074c326 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -47,7 +47,6 @@ MODULE_OBJS := \ text/text.o \ utility/clock.o \ utility/lzss_read_stream.o \ - utility/single_value_container.o \ utility/utility.o \ utility/win_keys.o \ video/video.o \ diff --git a/engines/zvision/utility/single_value_container.cpp b/engines/zvision/utility/single_value_container.cpp deleted file mode 100644 index 774f4b72ee..0000000000 --- a/engines/zvision/utility/single_value_container.cpp +++ /dev/null @@ -1,344 +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 "common/scummsys.h" -#include "common/textconsole.h" -#include "common/str.h" - -#include "zvision/utility/single_value_container.h" - -namespace ZVision { - -SingleValueContainer::SingleValueContainer(ValueType type) : _objectType(type) { } - -SingleValueContainer::SingleValueContainer(bool value) : _objectType(BOOL) { - _value.boolVal = value; -} - -SingleValueContainer::SingleValueContainer(byte value) : _objectType(BYTE) { - _value.byteVal = value; -} - -SingleValueContainer::SingleValueContainer(int16 value) : _objectType(INT16) { - _value.int16Val = value; -} - -SingleValueContainer::SingleValueContainer(uint16 value) : _objectType(UINT16) { - _value.uint16Val = value; -} - -SingleValueContainer::SingleValueContainer(int32 value) : _objectType(INT32) { - _value.int32Val = value; -} - -SingleValueContainer::SingleValueContainer(uint32 value) : _objectType(UINT32) { - _value.uint32Val = value; -} - -SingleValueContainer::SingleValueContainer(float value) : _objectType(FLOAT) { - _value.floatVal = value; -} - -SingleValueContainer::SingleValueContainer(double value) : _objectType(DOUBLE) { - _value.doubleVal = value; -} - -SingleValueContainer::SingleValueContainer(Common::String value) : _objectType(BYTE) { - _value.stringVal = new char[value.size() + 1]; - memcpy(_value.stringVal, value.c_str(), value.size() + 1); -} - -SingleValueContainer::SingleValueContainer(const SingleValueContainer &other) { - _objectType = other._objectType; - - switch (_objectType) { - case BOOL: - _value.boolVal = other._value.boolVal; - break; - case BYTE: - _value.byteVal = other._value.byteVal; - break; - case INT16: - _value.int16Val = other._value.int16Val; - break; - case UINT16: - _value.uint16Val = other._value.uint16Val; - break; - case INT32: - _value.int32Val = other._value.int32Val; - break; - case UINT32: - _value.uint32Val = other._value.uint32Val; - break; - case FLOAT: - _value.floatVal = other._value.floatVal; - break; - case DOUBLE: - _value.doubleVal = other._value.doubleVal; - break; - case STRING: - uint32 length = strlen(other._value.stringVal); - _value.stringVal = new char[length + 1]; - memcpy(_value.stringVal, other._value.stringVal, length + 1); - break; - } -} - -SingleValueContainer::~SingleValueContainer() { - deleteCharPointer(); -} - -void SingleValueContainer::deleteCharPointer() { - if (_objectType == STRING) - delete[] _value.stringVal; -} - -SingleValueContainer &SingleValueContainer::operator=(const bool &rhs) { - if (_objectType == BOOL) { - _value.boolVal = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = BOOL; - _value.boolVal = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const byte &rhs) { - if (_objectType == BYTE) { - _value.byteVal = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = BYTE; - _value.byteVal = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const int16 &rhs) { - if (_objectType == INT16) { - _value.int16Val = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = INT16; - _value.int16Val = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const uint16 &rhs) { - if (_objectType == UINT16) { - _value.uint16Val = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = UINT16; - _value.uint16Val = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const int32 &rhs) { - if (_objectType == INT32) { - _value.int32Val = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = INT32; - _value.int32Val = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const uint32 &rhs) { - if (_objectType == UINT32) { - _value.uint32Val = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = UINT32; - _value.uint32Val = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const float &rhs) { - if (_objectType == FLOAT) { - _value.floatVal = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = FLOAT; - _value.floatVal = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const double &rhs) { - if (_objectType == DOUBLE) { - _value.doubleVal = rhs; - return *this; - } - - deleteCharPointer(); - _objectType = DOUBLE; - _value.doubleVal = rhs; - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const Common::String &rhs) { - if (_objectType != STRING) { - _objectType = STRING; - _value.stringVal = new char[rhs.size() + 1]; - memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1); - - return *this; - } - - uint32 length = strlen(_value.stringVal); - if (length <= rhs.size() + 1) { - memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1); - } else { - delete[] _value.stringVal; - _value.stringVal = new char[rhs.size() + 1]; - memcpy(_value.stringVal, rhs.c_str(), rhs.size() + 1); - } - - return *this; -} - -SingleValueContainer &SingleValueContainer::operator=(const SingleValueContainer &rhs) { - switch (_objectType) { - case BOOL: - return operator=(rhs._value.boolVal); - case BYTE: - return operator=(rhs._value.byteVal); - case INT16: - return operator=(rhs._value.int16Val); - case UINT16: - return operator=(rhs._value.uint16Val); - case INT32: - return operator=(rhs._value.int32Val); - case UINT32: - return operator=(rhs._value.uint32Val); - case FLOAT: - return operator=(rhs._value.floatVal); - case DOUBLE: - return operator=(rhs._value.doubleVal); - case STRING: - uint32 length = strlen(rhs._value.stringVal); - - _value.stringVal = new char[length + 1]; - memcpy(_value.stringVal, rhs._value.stringVal, length + 1); - - return *this; - } - - return *this; -} - -bool SingleValueContainer::getBoolValue(bool *returnValue) const { - if (_objectType != BOOL) { - warning("'Object' is not storing a bool."); - return false; - } - - *returnValue = _value.boolVal; - return true; -} - -bool SingleValueContainer::getByteValue(byte *returnValue) const { - if (_objectType != BYTE) - warning("'Object' is not storing a byte."); - - *returnValue = _value.byteVal; - return true; -} - -bool SingleValueContainer::getInt16Value(int16 *returnValue) const { - if (_objectType != INT16) - warning("'Object' is not storing an int16."); - - *returnValue = _value.int16Val; - return true; -} - -bool SingleValueContainer::getUInt16Value(uint16 *returnValue) const { - if (_objectType != UINT16) - warning("'Object' is not storing a uint16."); - - *returnValue = _value.uint16Val; - return true; -} - -bool SingleValueContainer::getInt32Value(int32 *returnValue) const { - if (_objectType != INT32) - warning("'Object' is not storing an int32."); - - *returnValue = _value.int32Val; - return true; -} - -bool SingleValueContainer::getUInt32Value(uint32 *returnValue) const { - if (_objectType != UINT32) - warning("'Object' is not storing a uint32."); - - *returnValue = _value.uint32Val; - return true; -} - -bool SingleValueContainer::getFloatValue(float *returnValue) const { - if (_objectType != FLOAT) - warning("'Object' is not storing a float."); - - *returnValue = _value.floatVal; - return true; -} - -bool SingleValueContainer::getDoubleValue(double *returnValue) const { - if (_objectType != DOUBLE) - warning("'Object' is not storing a double."); - - *returnValue = _value.doubleVal; - return true; -} - -bool SingleValueContainer::getStringValue(Common::String *returnValue) const { - if (_objectType != STRING) - warning("'Object' is not storing a Common::String."); - - *returnValue = _value.stringVal; - return true; -} - -} // End of namespace ZVision diff --git a/engines/zvision/utility/single_value_container.h b/engines/zvision/utility/single_value_container.h deleted file mode 100644 index ac6e99039a..0000000000 --- a/engines/zvision/utility/single_value_container.h +++ /dev/null @@ -1,183 +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 ZVISION_SINGLE_VALUE_CONTAINER_H -#define ZVISION_SINGLE_VALUE_CONTAINER_H - -namespace Common { -class String; -} - -namespace ZVision { - -/** - * A generic single value storage class. It is useful for storing different - * value types in a single List, Hashmap, etc. - */ -class SingleValueContainer { -public: - enum ValueType { - BOOL, - BYTE, - INT16, - UINT16, - INT32, - UINT32, - FLOAT, - DOUBLE, - STRING - }; - - // Constructors - explicit SingleValueContainer(ValueType type); - explicit SingleValueContainer(bool value); - explicit SingleValueContainer(byte value); - explicit SingleValueContainer(int16 value); - explicit SingleValueContainer(uint16 value); - explicit SingleValueContainer(int32 value); - explicit SingleValueContainer(uint32 value); - explicit SingleValueContainer(float value); - explicit SingleValueContainer(double value); - explicit SingleValueContainer(Common::String value); - - // Copy constructor - explicit SingleValueContainer(const SingleValueContainer &other); - - // Destructor - ~SingleValueContainer(); - -private: - ValueType _objectType; - - union { - bool boolVal; - byte byteVal; - int16 int16Val; - uint16 uint16Val; - int32 int32Val; - uint32 uint32Val; - float floatVal; - double doubleVal; - char *stringVal; - } _value; - -public: - SingleValueContainer &operator=(const bool &rhs); - SingleValueContainer &operator=(const byte &rhs); - SingleValueContainer &operator=(const int16 &rhs); - SingleValueContainer &operator=(const uint16 &rhs); - SingleValueContainer &operator=(const int32 &rhs); - SingleValueContainer &operator=(const uint32 &rhs); - SingleValueContainer &operator=(const float &rhs); - SingleValueContainer &operator=(const double &rhs); - SingleValueContainer &operator=(const Common::String &rhs); - - SingleValueContainer &operator=(const SingleValueContainer &rhs); - - /** - * Retrieve a bool from the container. If the container is not storing a - * bool, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getBoolValue(bool *returnValue) const; - /** - * Retrieve a byte from the container. If the container is not storing a - * byte, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getByteValue(byte *returnValue) const; - /** - * Retrieve an int16 from the container. If the container is not storing an - * int16, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getInt16Value(int16 *returnValue) const; - /** - * Retrieve a uint16 from the container. If the container is not storing a - * uint16, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getUInt16Value(uint16 *returnValue) const; - /** - * Retrieve an int32 from the container. If the container is not storing an - * int32, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getInt32Value(int32 *returnValue) const; - /** - * Retrieve a uint32 from the container. If the container is not storing a - * uint32, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getUInt32Value(uint32 *returnValue) const; - /** - * Retrieve a float from the container. If the container is not storing a - * float, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getFloatValue(float *returnValue) const; - /** - * Retrieve a double from the container. If the container is not storing a - * double, this will return false and display a warning(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getDoubleValue(double *returnValue) const; - /** - * Retrieve a String from the container. If the container is not storing a - * string, this will return false and display a warning(). - * - * Caution: Strings are internally stored as char[]. getStringValue uses - * Common::String::operator=(char *) to do the assigment, which uses both - * strlen() AND memmove(). - * - * @param returnValue Pointer to where you want the value stored - * @return Value indicating whether the value assignment was successful - */ - bool getStringValue(Common::String *returnValue) const; - -private: - /** - * Helper method for destruction and assignment. It checks to see - * if the char pointer is being used, and if so calls delete on it - */ - void deleteCharPointer(); -}; - -} // End of namespace ZVision - -#endif -- cgit v1.2.3 From 10444ef5683f420f08cfc276349a5771dd0d04e5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:42:04 +0200 Subject: ZVISION: Use integers for rectangles in the menu code --- engines/zvision/core/menu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h index 7301323173..ebe0bb50ac 100644 --- a/engines/zvision/core/menu.h +++ b/engines/zvision/core/menu.h @@ -82,7 +82,7 @@ private: int mouseOnItem; bool scrolled[3]; - float scrollPos[3]; + int16 scrollPos[3]; enum { menu_ITEM = 0, @@ -111,7 +111,7 @@ private: int mouseOnItem; bool scrolled; - float scrollPos; + int16 scrollPos; bool redraw; -- cgit v1.2.3 From bb31c435bf6502f4e1f94b3de9f046c054031a98 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:43:51 +0200 Subject: ZVISION: Remove more dead code, and move some debugger functions --- engines/zvision/core/console.cpp | 79 ++++++++++------ engines/zvision/core/console.h | 2 - engines/zvision/sound/zork_raw.cpp | 22 +++-- engines/zvision/utility/utility.cpp | 176 ------------------------------------ engines/zvision/utility/utility.h | 66 -------------- 5 files changed, 65 insertions(+), 280 deletions(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 201d1c9360..f8e28333f1 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -44,7 +44,6 @@ namespace ZVision { Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { - registerCmd("loadimage", WRAP_METHOD(Console, cmdLoadImage)); registerCmd("loadvideo", WRAP_METHOD(Console, cmdLoadVideo)); registerCmd("loadsound", WRAP_METHOD(Console, cmdLoadSound)); registerCmd("raw2wav", WRAP_METHOD(Console, cmdRawToWav)); @@ -55,18 +54,6 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); - registerCmd("rendertext", WRAP_METHOD(Console, cmdRenderText)); -} - -bool Console::cmdLoadImage(int argc, const char **argv) { -// if (argc == 4) -// _engine->getRenderManager()->renderImageToScreen(argv[1], atoi(argv[2]), atoi(argv[3])); -// else { -// DebugPrintf("Use loadimage to load an image to the screen\n"); -// return true; -// } - - return true; } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -117,7 +104,42 @@ bool Console::cmdRawToWav(int argc, const char **argv) { return true; } - convertRawToWav(argv[1], _engine, argv[2]); + Common::File file; + if (!file.open(argv[1])) + return true; + + Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine); + + Common::DumpFile output; + output.open(argv[2]); + + output.writeUint32BE(MKTAG('R', 'I', 'F', 'F')); + output.writeUint32LE(file.size() * 2 + 36); + output.writeUint32BE(MKTAG('W', 'A', 'V', 'E')); + output.writeUint32BE(MKTAG('f', 'm', 't', ' ')); + output.writeUint32LE(16); + output.writeUint16LE(1); + uint16 numChannels; + if (audioStream->isStereo()) { + numChannels = 2; + output.writeUint16LE(2); + } else { + numChannels = 1; + output.writeUint16LE(1); + } + output.writeUint32LE(audioStream->getRate()); + output.writeUint32LE(audioStream->getRate() * numChannels * 2); + output.writeUint16LE(numChannels * 2); + output.writeUint16LE(16); + output.writeUint32BE(MKTAG('d', 'a', 't', 'a')); + output.writeUint32LE(file.size() * 2); + int16 *buffer = new int16[file.size()]; + audioStream->readBuffer(buffer, file.size()); + output.write(buffer, file.size() * 2); + + delete[] buffer; + + return true; } @@ -186,7 +208,22 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - writeFileContentsToFile(argv[1], argv[1]); + Common::File f; + if (!f.open(argv[1])) { + return true; + } + + byte *buffer = new byte[f.size()]; + f.read(buffer, f.size()); + + Common::DumpFile dumpFile; + dumpFile.open(argv[1]); + + dumpFile.write(buffer, f.size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; return true; } @@ -201,16 +238,4 @@ bool Console::cmdParseAllScrFiles(int argc, const char **argv) { return true; } -bool Console::cmdRenderText(int argc, const char **argv) { - if (argc != 7) { - debugPrintf("Use rendertext <1 or 0: wrap> to render text\n"); - return true; - } - - //StringManager::TextStyle style = _engine->getStringManager()->getTextStyle(atoi(argv[2])); - //_engine->getRenderManager()->renderTextToWorkingWindow(333, Common::String(argv[1]), style.font, atoi(argv[3]), atoi(argv[4]), style.color, atoi(argv[5]), -1, Graphics::kTextAlignLeft, atoi(argv[6]) == 0 ? false : true); - - return true; -} - } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 29523c57ee..994e05ba35 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -37,7 +37,6 @@ public: private: ZVision *_engine; - bool cmdLoadImage(int argc, const char **argv); bool cmdLoadVideo(int argc, const char **argv); bool cmdLoadSound(int argc, const char **argv); bool cmdRawToWav(int argc, const char **argv); @@ -48,7 +47,6 @@ private: bool cmdChangeLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); bool cmdParseAllScrFiles(int argc, const char **argv); - bool cmdRenderText(int argc, const char **argv); }; } // End of namespace ZVision diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 485e0b8a49..c26c33a392 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -21,23 +21,21 @@ */ #include "common/scummsys.h" - -#include "zvision/sound/zork_raw.h" - -#include "zvision/zvision.h" -#include "zvision/detection.h" -#include "zvision/utility/utility.h" - #include "common/file.h" #include "common/str.h" #include "common/stream.h" #include "common/memstream.h" #include "common/bufferedstream.h" #include "common/util.h" - +#include "common/tokenizer.h" #include "audio/audiostream.h" #include "audio/decoders/raw.h" +#include "zvision/sound/zork_raw.h" +#include "zvision/zvision.h" +#include "zvision/detection.h" +#include "zvision/utility/utility.h" + namespace ZVision { const int16 RawChunkStream::_stepAdjustmentTable[8] = { -1, -1, -1, 1, 4, 7, 10, 12}; @@ -255,7 +253,13 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, Common::File *file = new Common::File(); assert(engine->getSearchManager()->openFile(*file, filePath)); - Common::String fileName = getFileName(filePath); + // Get the file name + Common::StringTokenizer tokenizer(filePath, "/\\"); + Common::String fileName; + while (!tokenizer.empty()) { + fileName = tokenizer.nextToken(); + } + fileName.toLowercase(); SoundParams soundParams = {}; diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp index 517c89afbd..2388fe826e 100644 --- a/engines/zvision/utility/utility.cpp +++ b/engines/zvision/utility/utility.cpp @@ -32,25 +32,6 @@ namespace ZVision { -void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile) { - Common::File f; - if (!f.open(sourceFile)) { - return; - } - - byte *buffer = new byte[f.size()]; - f.read(buffer, f.size()); - - Common::DumpFile dumpFile; - dumpFile.open(destFile); - - dumpFile.write(buffer, f.size()); - dumpFile.flush(); - dumpFile.close(); - - delete[] buffer; -} - void trimCommentsAndWhiteSpace(Common::String *string) { for (int i = string->size() - 1; i >= 0; i--) { if ((*string)[i] == '#') { @@ -76,161 +57,4 @@ void tryToDumpLine(const Common::String &key, } } -void dumpEveryResultAction(const Common::String &destFile) { - Common::HashMap count; - Common::HashMap fileAlreadyUsed; - - Common::DumpFile output; - output.open(destFile); - - // Find scr files - Common::ArchiveMemberList list; - SearchMan.listMatchingMembers(list, "*.scr"); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::SeekableReadStream *stream = (*iter)->createReadStream(); - - Common::String line = stream->readLine(); - trimCommentsAndWhiteSpace(&line); - - while (!stream->eos()) { - if (line.matchString("*:add*", true)) { - tryToDumpLine("add", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:animplay*", true)) { - tryToDumpLine("animplay", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:animpreload*", true)) { - tryToDumpLine("animpreload", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:animunload*", true)) { - tryToDumpLine("animunload", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:attenuate*", true)) { - tryToDumpLine("attenuate", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:assign*", true)) { - tryToDumpLine("assign", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:change_location*", true)) { - tryToDumpLine("change_location", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:crossfade*", true) && !fileAlreadyUsed["add"]) { - tryToDumpLine("crossfade", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:debug*", true)) { - tryToDumpLine("debug", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:delay_render*", true)) { - tryToDumpLine("delay_render", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:disable_control*", true)) { - tryToDumpLine("disable_control", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:disable_venus*", true)) { - tryToDumpLine("disable_venus", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:display_message*", true)) { - tryToDumpLine("display_message", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:dissolve*", true)) { - tryToDumpLine("dissolve", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:distort*", true)) { - tryToDumpLine("distort", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:enable_control*", true)) { - tryToDumpLine("enable_control", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:flush_mouse_events*", true)) { - tryToDumpLine("flush_mouse_events", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:inventory*", true)) { - tryToDumpLine("inventory", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:kill*", true)) { - tryToDumpLine("kill", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:menu_bar_enable*", true)) { - tryToDumpLine("menu_bar_enable", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:music*", true)) { - tryToDumpLine("music", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:pan_track*", true)) { - tryToDumpLine("pan_track", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:playpreload*", true)) { - tryToDumpLine("playpreload", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:preferences*", true)) { - tryToDumpLine("preferences", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:quit*", true)) { - tryToDumpLine("quit", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:random*", true)) { - tryToDumpLine("random", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:region*", true)) { - tryToDumpLine("region", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:restore_game*", true)) { - tryToDumpLine("restore_game", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:rotate_to*", true)) { - tryToDumpLine("rotate_to", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:save_game*", true)) { - tryToDumpLine("save_game", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:set_partial_screen*", true)) { - tryToDumpLine("set_partial_screen", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:set_screen*", true)) { - tryToDumpLine("set_screen", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:set_venus*", true)) { - tryToDumpLine("set_venus", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:stop*", true)) { - tryToDumpLine("stop", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:streamvideo*", true)) { - tryToDumpLine("streamvideo", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:syncsound*", true)) { - tryToDumpLine("syncsound", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:timer*", true)) { - tryToDumpLine("timer", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:ttytext*", true)) { - tryToDumpLine("ttytext", line, &count, &fileAlreadyUsed, output); - } else if (line.matchString("*:universe_music*", true)) { - tryToDumpLine("universe_music", line, &count, &fileAlreadyUsed, output); - } - - line = stream->readLine(); - trimCommentsAndWhiteSpace(&line); - } - - for (Common::HashMap::iterator fileUsedIter = fileAlreadyUsed.begin(); fileUsedIter != fileAlreadyUsed.end(); ++fileUsedIter) { - fileUsedIter->_value = false; - } - } - - output.close(); -} - -Common::String getFileName(const Common::String &fullPath) { - Common::StringTokenizer tokenizer(fullPath, "/\\"); - Common::String token; - while (!tokenizer.empty()) { - token = tokenizer.nextToken(); - } - - return token; -} - -void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile) { - Common::File file; - if (!file.open(inputFile)) - return; - - Audio::AudioStream *audioStream = makeRawZorkStream(inputFile, engine); - - Common::DumpFile output; - output.open(outputFile); - - output.writeUint32BE(MKTAG('R', 'I', 'F', 'F')); - output.writeUint32LE(file.size() * 2 + 36); - output.writeUint32BE(MKTAG('W', 'A', 'V', 'E')); - output.writeUint32BE(MKTAG('f', 'm', 't', ' ')); - output.writeUint32LE(16); - output.writeUint16LE(1); - uint16 numChannels; - if (audioStream->isStereo()) { - numChannels = 2; - output.writeUint16LE(2); - } else { - numChannels = 1; - output.writeUint16LE(1); - } - output.writeUint32LE(audioStream->getRate()); - output.writeUint32LE(audioStream->getRate() * numChannels * 2); - output.writeUint16LE(numChannels * 2); - output.writeUint16LE(16); - output.writeUint32BE(MKTAG('d', 'a', 't', 'a')); - output.writeUint32LE(file.size() * 2); - int16 *buffer = new int16[file.size()]; - audioStream->readBuffer(buffer, file.size()); - output.write(buffer, file.size() * 2); - - delete[] buffer; -} - } // End of namespace ZVision diff --git a/engines/zvision/utility/utility.h b/engines/zvision/utility/utility.h index 0741cc044c..0ca26b968d 100644 --- a/engines/zvision/utility/utility.h +++ b/engines/zvision/utility/utility.h @@ -33,15 +33,6 @@ namespace ZVision { class ZVision; -/** - * Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the - * contents to destFile. destFile is created in the working directory - * - * @param sourceFile The 'file' you want the contents of - * @param destFile The name of the file where the content will be written to - */ -void writeFileContentsToFile(const Common::String &sourceFile, const Common::String &destFile); - /** * Removes any line comments using '#' as a sequence start. * Then removes any trailing and leading 'whitespace' using String::trim() @@ -51,63 +42,6 @@ void writeFileContentsToFile(const Common::String &sourceFile, const Common::Str */ void trimCommentsAndWhiteSpace(Common::String *string); -/** - * Searches through all the .scr files and dumps 'numberOfExamplesPerType' examples of each type of ResultAction - * ZVision::initialize() must have been called before this function can be used. - * - * @param destFile Where to write the examples - */ -void dumpEveryResultAction(const Common::String &destFile); - -/** - * Removes all duplicate entries from container. Relative order will be preserved. - * - * @param container The Array to remove duplicate entries from - */ -template -void removeDuplicateEntries(Common::Array &container) { - // Length of modified array - uint newLength = 1; - uint j; - - for (uint i = 1; i < container.size(); i++) { - for (j = 0; j < newLength; j++) { - if (container[i] == container[j]) { - break; - } - } - - // If none of the values in index[0..j] of container are the same as array[i], - // then copy the current value to corresponding new position in array - if (j == newLength) { - container[newLength++] = container[i]; - } - } - - // Actually remove the unneeded space - while (container.size() < newLength) { - container.pop_back(); - } -} - -/** - * Gets the name of the file (including extension). Forward or back slashes - * are interpreted as directory changes - * - * @param fullPath A full or partial path to the file. Ex: folderOne/folderTwo/file.txt - * @return The name of the file without any preceding directories. Ex: file.txt - */ -Common::String getFileName(const Common::String &fullPath); - -/** - * Converts a ZVision .RAW file to a .WAV - * The .WAV will be created in the working directory and will overwrite any existing file - * - * @param inputFile The path to the input .RAW file - * @param outputFile The name of the output .WAV file - */ -void convertRawToWav(const Common::String &inputFile, ZVision *engine, const Common::String &outputFile); - } // End of namespace ZVision #endif -- cgit v1.2.3 From bbec6c913ac6ad4279e3549fc903b9c6e4521f50 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 01:58:07 +0200 Subject: ZVISION: Document some more cheats for ZGI Thanks to marisa-chan for providing the location of those in pull request #532 --- engines/zvision/core/events.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index e3bcf6f09a..2c0e63bf5c 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -71,9 +71,8 @@ void ZVision::cheatCodes(uint8 key) { pushKeyToCheatBuf(key); if (getGameId() == GID_GRANDINQUISITOR) { - if (checkCode("IMNOTDEAF")) { - // Unknow cheat + // Unknown cheat showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); } @@ -93,8 +92,12 @@ void ZVision::cheatCodes(uint8 key) { if (checkCode("MIKESPANTS")) { _scriptManager->changeLocation('g', 'j', 't', 'm', 0); } - } else if (getGameId() == GID_NEMESIS) { + // There are 3 more cheats in script files: + // - "EAT ME": gjcr.scr + // - "WHOAMI": hp1e.scr + // - "HUISOK": uh1f.scr + } else if (getGameId() == GID_NEMESIS) { if (checkCode("CHLOE")) { _scriptManager->changeLocation('t', 'm', '2', 'g', 0); _scriptManager->setStateValue(224, 1); -- cgit v1.2.3 From f578a1b3342578594d9940894a525bf3983641ff Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:11:50 +0200 Subject: ZVISION: Move the key mapper function --- engines/zvision/core/events.cpp | 106 +++++++++++++++++++++++++++- engines/zvision/module.mk | 1 - engines/zvision/utility/win_keys.cpp | 129 ----------------------------------- engines/zvision/utility/win_keys.h | 32 --------- engines/zvision/zvision.h | 3 +- 5 files changed, 105 insertions(+), 166 deletions(-) delete mode 100644 engines/zvision/utility/win_keys.cpp delete mode 100644 engines/zvision/utility/win_keys.h diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 2c0e63bf5c..52d71c92f6 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,8 +30,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" -#include "zvision/utility/win_keys.h" -#include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" @@ -214,7 +212,7 @@ void ZVision::processEvents() { break; } - uint8 vkKey = VKkey(_event.kbd.keycode); + uint8 vkKey = getZvisionKey(_event.kbd.keycode); _scriptManager->setStateValue(StateKey_KeyPress, vkKey); @@ -342,4 +340,106 @@ void ZVision::onMouseMove(const Common::Point &pos) { } } +uint8 ZVision::getZvisionKey(Common::KeyCode scummKeyCode) { + if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z) + return 0x41 + scummKeyCode - Common::KEYCODE_a; + if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9) + return 0x30 + scummKeyCode - Common::KEYCODE_0; + if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15) + return 0x70 + scummKeyCode - Common::KEYCODE_F1; + if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9) + return 0x60 + scummKeyCode - Common::KEYCODE_KP0; + + switch (scummKeyCode) { + case Common::KEYCODE_BACKSPACE: + return 0x8; + case Common::KEYCODE_TAB: + return 0x9; + case Common::KEYCODE_CLEAR: + return 0xC; + case Common::KEYCODE_RETURN: + return 0xD; + case Common::KEYCODE_CAPSLOCK: + return 0x14; + case Common::KEYCODE_ESCAPE: + return 0x1B; + case Common::KEYCODE_SPACE: + return 0x20; + case Common::KEYCODE_PAGEUP: + return 0x21; + case Common::KEYCODE_PAGEDOWN: + return 0x22; + case Common::KEYCODE_END: + return 0x23; + case Common::KEYCODE_HOME: + return 0x24; + case Common::KEYCODE_LEFT: + return 0x25; + case Common::KEYCODE_UP: + return 0x26; + case Common::KEYCODE_RIGHT: + return 0x27; + case Common::KEYCODE_DOWN: + return 0x28; + case Common::KEYCODE_PRINT: + return 0x2A; + case Common::KEYCODE_INSERT: + return 0x2D; + case Common::KEYCODE_DELETE: + return 0x2E; + case Common::KEYCODE_HELP: + return 0x2F; + case Common::KEYCODE_KP_MULTIPLY: + return 0x6A; + case Common::KEYCODE_KP_PLUS: + return 0x6B; + case Common::KEYCODE_KP_MINUS: + return 0x6D; + case Common::KEYCODE_KP_PERIOD: + return 0x6E; + case Common::KEYCODE_KP_DIVIDE: + return 0x6F; + case Common::KEYCODE_NUMLOCK: + return 0x90; + case Common::KEYCODE_SCROLLOCK: + return 0x91; + case Common::KEYCODE_LSHIFT: + return 0xA0; + case Common::KEYCODE_RSHIFT: + return 0xA1; + case Common::KEYCODE_LCTRL: + return 0xA2; + case Common::KEYCODE_RCTRL: + return 0xA3; + case Common::KEYCODE_MENU: + return 0xA5; + case Common::KEYCODE_LEFTBRACKET: + return 0xDB; + case Common::KEYCODE_RIGHTBRACKET: + return 0xDD; + case Common::KEYCODE_SEMICOLON: + return 0xBA; + case Common::KEYCODE_BACKSLASH: + return 0xDC; + case Common::KEYCODE_QUOTE: + return 0xDE; + case Common::KEYCODE_SLASH: + return 0xBF; + case Common::KEYCODE_TILDE: + return 0xC0; + case Common::KEYCODE_COMMA: + return 0xBC; + case Common::KEYCODE_PERIOD: + return 0xBE; + case Common::KEYCODE_MINUS: + return 0xBD; + case Common::KEYCODE_PLUS: + return 0xBB; + default: + return 0; + } + + return 0; +} + } // End of namespace ZVision diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 140074c326..5efd6d4a29 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -48,7 +48,6 @@ MODULE_OBJS := \ utility/clock.o \ utility/lzss_read_stream.o \ utility/utility.o \ - utility/win_keys.o \ video/video.o \ video/zork_avi_decoder.o \ zvision.o diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp deleted file mode 100644 index 86ed7c596f..0000000000 --- a/engines/zvision/utility/win_keys.cpp +++ /dev/null @@ -1,129 +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 "common/keyboard.h" - -namespace ZVision { - -uint8 VKkey(Common::KeyCode scummKeyCode) { - if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z) - return 0x41 + scummKeyCode - Common::KEYCODE_a; - if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9) - return 0x30 + scummKeyCode - Common::KEYCODE_0; - if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15) - return 0x70 + scummKeyCode - Common::KEYCODE_F1; - if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9) - return 0x60 + scummKeyCode - Common::KEYCODE_KP0; - - switch (scummKeyCode) { - case Common::KEYCODE_BACKSPACE: - return 0x8; - case Common::KEYCODE_TAB: - return 0x9; - case Common::KEYCODE_CLEAR: - return 0xC; - case Common::KEYCODE_RETURN: - return 0xD; - case Common::KEYCODE_CAPSLOCK: - return 0x14; - case Common::KEYCODE_ESCAPE: - return 0x1B; - case Common::KEYCODE_SPACE: - return 0x20; - case Common::KEYCODE_PAGEUP: - return 0x21; - case Common::KEYCODE_PAGEDOWN: - return 0x22; - case Common::KEYCODE_END: - return 0x23; - case Common::KEYCODE_HOME: - return 0x24; - case Common::KEYCODE_LEFT: - return 0x25; - case Common::KEYCODE_UP: - return 0x26; - case Common::KEYCODE_RIGHT: - return 0x27; - case Common::KEYCODE_DOWN: - return 0x28; - case Common::KEYCODE_PRINT: - return 0x2A; - case Common::KEYCODE_INSERT: - return 0x2D; - case Common::KEYCODE_DELETE: - return 0x2E; - case Common::KEYCODE_HELP: - return 0x2F; - case Common::KEYCODE_KP_MULTIPLY: - return 0x6A; - case Common::KEYCODE_KP_PLUS: - return 0x6B; - case Common::KEYCODE_KP_MINUS: - return 0x6D; - case Common::KEYCODE_KP_PERIOD: - return 0x6E; - case Common::KEYCODE_KP_DIVIDE: - return 0x6F; - case Common::KEYCODE_NUMLOCK: - return 0x90; - case Common::KEYCODE_SCROLLOCK: - return 0x91; - case Common::KEYCODE_LSHIFT: - return 0xA0; - case Common::KEYCODE_RSHIFT: - return 0xA1; - case Common::KEYCODE_LCTRL: - return 0xA2; - case Common::KEYCODE_RCTRL: - return 0xA3; - case Common::KEYCODE_MENU: - return 0xA5; - case Common::KEYCODE_LEFTBRACKET: - return 0xDB; - case Common::KEYCODE_RIGHTBRACKET: - return 0xDD; - case Common::KEYCODE_SEMICOLON: - return 0xBA; - case Common::KEYCODE_BACKSLASH: - return 0xDC; - case Common::KEYCODE_QUOTE: - return 0xDE; - case Common::KEYCODE_SLASH: - return 0xBF; - case Common::KEYCODE_TILDE: - return 0xC0; - case Common::KEYCODE_COMMA: - return 0xBC; - case Common::KEYCODE_PERIOD: - return 0xBE; - case Common::KEYCODE_MINUS: - return 0xBD; - case Common::KEYCODE_PLUS: - return 0xBB; - default: - return 0; - } - - return 0; -} - -} diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h deleted file mode 100644 index 53d76c4d5f..0000000000 --- a/engines/zvision/utility/win_keys.h +++ /dev/null @@ -1,32 +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 ZVISION_WIN_KEYS_H -#define ZVISION_WIN_KEYS_H - -#include "common/keyboard.h" - -namespace ZVision { -uint8 VKkey(Common::KeyCode scummKeyCode); -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index ae49f0640f..ca6c8e10e4 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -163,6 +163,8 @@ public: return _gameDescription->gameId; } + uint8 getZvisionKey(Common::KeyCode scummKeyCode); + /** * Play a video until it is finished. This is a blocking call. It will call * _clock.stop() when the video starts and _clock.start() when the video finishes. @@ -196,7 +198,6 @@ public: void checkBorders(); void showDebugMsg(const Common::String &msg, int16 delay = 3000); - private: void initialize(); void initFonts(); -- cgit v1.2.3 From f2eee1759f922640b08ac3420f50f0a9c05e0588 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:16:14 +0200 Subject: ZVISION: Move the ZfsArchive class --- engines/zvision/archives/zfs_archive.cpp | 155 ------------------------------- engines/zvision/archives/zfs_archive.h | 125 ------------------------- engines/zvision/core/search_manager.cpp | 6 +- engines/zvision/module.mk | 2 +- engines/zvision/utility/zfs_archive.cpp | 154 ++++++++++++++++++++++++++++++ engines/zvision/utility/zfs_archive.h | 125 +++++++++++++++++++++++++ engines/zvision/zvision.cpp | 3 +- 7 files changed, 284 insertions(+), 286 deletions(-) delete mode 100644 engines/zvision/archives/zfs_archive.cpp delete mode 100644 engines/zvision/archives/zfs_archive.h create mode 100644 engines/zvision/utility/zfs_archive.cpp create mode 100644 engines/zvision/utility/zfs_archive.h diff --git a/engines/zvision/archives/zfs_archive.cpp b/engines/zvision/archives/zfs_archive.cpp deleted file mode 100644 index 416719b8f2..0000000000 --- a/engines/zvision/archives/zfs_archive.cpp +++ /dev/null @@ -1,155 +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 "common/scummsys.h" - -#include "zvision/archives/zfs_archive.h" - -#include "common/memstream.h" -#include "common/debug.h" -#include "common/file.h" - -namespace ZVision { - -ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { - Common::File zfsFile; - - if (!zfsFile.open(_fileName)) { - warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); - return; - } - - readHeaders(&zfsFile); - - debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); -} - -ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) { - readHeaders(stream); - - debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); -} - -ZfsArchive::~ZfsArchive() { - debug(1, "ZfsArchive Destructor Called"); - ZfsEntryHeaderMap::iterator it = _entryHeaders.begin(); - for (; it != _entryHeaders.end(); ++it) { - delete it->_value; - } -} - -void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { - // Don't do a straight struct cast since we can't guarantee endianness - _header.magic = stream->readUint32LE(); - _header.unknown1 = stream->readUint32LE(); - _header.maxNameLength = stream->readUint32LE(); - _header.filesPerBlock = stream->readUint32LE(); - _header.fileCount = stream->readUint32LE(); - _header.xorKey[0] = stream->readByte(); - _header.xorKey[1] = stream->readByte(); - _header.xorKey[2] = stream->readByte(); - _header.xorKey[3] = stream->readByte(); - _header.fileSectionOffset = stream->readUint32LE(); - - uint32 nextOffset; - - do { - // Read the offset to the next block - nextOffset = stream->readUint32LE(); - - // Read in each entry header - for (uint32 i = 0; i < _header.filesPerBlock; ++i) { - ZfsEntryHeader entryHeader; - - entryHeader.name = readEntryName(stream); - entryHeader.offset = stream->readUint32LE(); - entryHeader.id = stream->readUint32LE(); - entryHeader.size = stream->readUint32LE(); - entryHeader.time = stream->readUint32LE(); - entryHeader.unknown = stream->readUint32LE(); - - if (entryHeader.size != 0) - _entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader); - } - - // Seek to the next block of headers - stream->seek(nextOffset); - } while (nextOffset != 0); -} - -Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const { - // Entry Names are at most 16 bytes and are null padded - char buffer[16]; - stream->read(buffer, 16); - - return Common::String(buffer); -} - -bool ZfsArchive::hasFile(const Common::String &name) const { - return _entryHeaders.contains(name); -} - -int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const { - int matches = 0; - - for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) { - list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this))); - matches++; - } - - return matches; -} - -const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const { - if (!_entryHeaders.contains(name)) - return Common::ArchiveMemberPtr(); - - return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); -} - -Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const { - if (!_entryHeaders.contains(name)) { - return 0; - } - - ZfsEntryHeader *entryHeader = _entryHeaders[name]; - - Common::File zfsArchive; - zfsArchive.open(_fileName); - zfsArchive.seek(entryHeader->offset); - - // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory - byte *buffer = (byte *)malloc(entryHeader->size); - zfsArchive.read(buffer, entryHeader->size); - // Decrypt the data in place - if (_header.xorKey != 0) - unXor(buffer, entryHeader->size, _header.xorKey); - - return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); -} - -void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const { - for (uint32 i = 0; i < length; ++i) - buffer[i] ^= xorKey[i % 4]; -} - -} // End of namespace ZVision diff --git a/engines/zvision/archives/zfs_archive.h b/engines/zvision/archives/zfs_archive.h deleted file mode 100644 index 571591a6d1..0000000000 --- a/engines/zvision/archives/zfs_archive.h +++ /dev/null @@ -1,125 +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 ZVISION_ZFS_ARCHIVE_H -#define ZVISION_ZFS_ARCHIVE_H - -#include "common/archive.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Common { -class String; -} - -namespace ZVision { - -struct ZfsHeader { - uint32 magic; - uint32 unknown1; - uint32 maxNameLength; - uint32 filesPerBlock; - uint32 fileCount; - byte xorKey[4]; - uint32 fileSectionOffset; -}; - -struct ZfsEntryHeader { - Common::String name; - uint32 offset; - uint32 id; - uint32 size; - uint32 time; - uint32 unknown; -}; - -typedef Common::HashMap ZfsEntryHeaderMap; - -class ZfsArchive : public Common::Archive { -public: - ZfsArchive(const Common::String &fileName); - ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream); - ~ZfsArchive(); - - /** - * Check if a member with the given name is present in the Archive. - * Patterns are not allowed, as this is meant to be a quick File::exists() - * replacement. - */ - bool hasFile(const Common::String &fileName) const; - - /** - * Add all members of the Archive to list. - * Must only append to list, and not remove elements from it. - * - * @return The number of names added to list - */ - int listMembers(Common::ArchiveMemberList &list) const; - - /** - * Returns a ArchiveMember representation of the given file. - */ - const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - - /** - * Create a stream bound to a member with the specified name in the - * archive. If no member with this name exists, 0 is returned. - * - * @return The newly created input stream - */ - Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - -private: - const Common::String _fileName; - ZfsHeader _header; - ZfsEntryHeaderMap _entryHeaders; - - /** - * Parses the zfs file into file entry headers that can be used later - * to get the entry data. - * - * @param stream The contents of the zfs file - */ - void readHeaders(Common::SeekableReadStream *stream); - - /** - * Entry names are contained within a 16 byte block. This reads the block - * and converts it the name to a Common::String - * - * @param stream The zfs file stream - * @return The entry file name - */ - Common::String readEntryName(Common::SeekableReadStream *stream) const; - - /** - * ZFS file entries can be encrypted using XOR encoding. This method - * decodes the buffer in place using the supplied xorKey. - * - * @param buffer The data to decode - * @param length Length of buffer - */ - void unXor(byte *buffer, uint32 length, const byte *xorKey) const; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 1e9643ddbb..9c5d8fb323 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -21,12 +21,12 @@ */ #include "common/debug.h" - -#include "zvision/core/search_manager.h" -#include "zvision/archives/zfs_archive.h" #include "common/fs.h" #include "common/stream.h" +#include "zvision/core/search_manager.h" +#include "zvision/utility/zfs_archive.h" + namespace ZVision { SearchManager::SearchManager(const Common::String &rootPath, int depth) { diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 5efd6d4a29..607a9be4ed 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -3,7 +3,6 @@ MODULE := engines/zvision MODULE_OBJS := \ animation/meta_animation.o \ animation/rlf_animation.o \ - archives/zfs_archive.o \ core/console.o \ core/events.o \ core/menu.o \ @@ -48,6 +47,7 @@ MODULE_OBJS := \ utility/clock.o \ utility/lzss_read_stream.o \ utility/utility.o \ + utility/zfs_archive.o \ video/video.o \ video/zork_avi_decoder.o \ zvision.o diff --git a/engines/zvision/utility/zfs_archive.cpp b/engines/zvision/utility/zfs_archive.cpp new file mode 100644 index 0000000000..13b0168e1c --- /dev/null +++ b/engines/zvision/utility/zfs_archive.cpp @@ -0,0 +1,154 @@ +/* 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 "common/scummsys.h" +#include "common/memstream.h" +#include "common/debug.h" +#include "common/file.h" + +#include "zvision/utility/zfs_archive.h" + +namespace ZVision { + +ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { + Common::File zfsFile; + + if (!zfsFile.open(_fileName)) { + warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); + return; + } + + readHeaders(&zfsFile); + + debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); +} + +ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) { + readHeaders(stream); + + debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); +} + +ZfsArchive::~ZfsArchive() { + debug(1, "ZfsArchive Destructor Called"); + ZfsEntryHeaderMap::iterator it = _entryHeaders.begin(); + for (; it != _entryHeaders.end(); ++it) { + delete it->_value; + } +} + +void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { + // Don't do a straight struct cast since we can't guarantee endianness + _header.magic = stream->readUint32LE(); + _header.unknown1 = stream->readUint32LE(); + _header.maxNameLength = stream->readUint32LE(); + _header.filesPerBlock = stream->readUint32LE(); + _header.fileCount = stream->readUint32LE(); + _header.xorKey[0] = stream->readByte(); + _header.xorKey[1] = stream->readByte(); + _header.xorKey[2] = stream->readByte(); + _header.xorKey[3] = stream->readByte(); + _header.fileSectionOffset = stream->readUint32LE(); + + uint32 nextOffset; + + do { + // Read the offset to the next block + nextOffset = stream->readUint32LE(); + + // Read in each entry header + for (uint32 i = 0; i < _header.filesPerBlock; ++i) { + ZfsEntryHeader entryHeader; + + entryHeader.name = readEntryName(stream); + entryHeader.offset = stream->readUint32LE(); + entryHeader.id = stream->readUint32LE(); + entryHeader.size = stream->readUint32LE(); + entryHeader.time = stream->readUint32LE(); + entryHeader.unknown = stream->readUint32LE(); + + if (entryHeader.size != 0) + _entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader); + } + + // Seek to the next block of headers + stream->seek(nextOffset); + } while (nextOffset != 0); +} + +Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const { + // Entry Names are at most 16 bytes and are null padded + char buffer[16]; + stream->read(buffer, 16); + + return Common::String(buffer); +} + +bool ZfsArchive::hasFile(const Common::String &name) const { + return _entryHeaders.contains(name); +} + +int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const { + int matches = 0; + + for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) { + list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this))); + matches++; + } + + return matches; +} + +const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const { + if (!_entryHeaders.contains(name)) + return Common::ArchiveMemberPtr(); + + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + +Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const { + if (!_entryHeaders.contains(name)) { + return 0; + } + + ZfsEntryHeader *entryHeader = _entryHeaders[name]; + + Common::File zfsArchive; + zfsArchive.open(_fileName); + zfsArchive.seek(entryHeader->offset); + + // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory + byte *buffer = (byte *)malloc(entryHeader->size); + zfsArchive.read(buffer, entryHeader->size); + // Decrypt the data in place + if (_header.xorKey != 0) + unXor(buffer, entryHeader->size, _header.xorKey); + + return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); +} + +void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const { + for (uint32 i = 0; i < length; ++i) + buffer[i] ^= xorKey[i % 4]; +} + +} // End of namespace ZVision diff --git a/engines/zvision/utility/zfs_archive.h b/engines/zvision/utility/zfs_archive.h new file mode 100644 index 0000000000..571591a6d1 --- /dev/null +++ b/engines/zvision/utility/zfs_archive.h @@ -0,0 +1,125 @@ +/* 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 ZVISION_ZFS_ARCHIVE_H +#define ZVISION_ZFS_ARCHIVE_H + +#include "common/archive.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace Common { +class String; +} + +namespace ZVision { + +struct ZfsHeader { + uint32 magic; + uint32 unknown1; + uint32 maxNameLength; + uint32 filesPerBlock; + uint32 fileCount; + byte xorKey[4]; + uint32 fileSectionOffset; +}; + +struct ZfsEntryHeader { + Common::String name; + uint32 offset; + uint32 id; + uint32 size; + uint32 time; + uint32 unknown; +}; + +typedef Common::HashMap ZfsEntryHeaderMap; + +class ZfsArchive : public Common::Archive { +public: + ZfsArchive(const Common::String &fileName); + ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream); + ~ZfsArchive(); + + /** + * Check if a member with the given name is present in the Archive. + * Patterns are not allowed, as this is meant to be a quick File::exists() + * replacement. + */ + bool hasFile(const Common::String &fileName) const; + + /** + * Add all members of the Archive to list. + * Must only append to list, and not remove elements from it. + * + * @return The number of names added to list + */ + int listMembers(Common::ArchiveMemberList &list) const; + + /** + * Returns a ArchiveMember representation of the given file. + */ + const Common::ArchiveMemberPtr getMember(const Common::String &name) const; + + /** + * Create a stream bound to a member with the specified name in the + * archive. If no member with this name exists, 0 is returned. + * + * @return The newly created input stream + */ + Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + +private: + const Common::String _fileName; + ZfsHeader _header; + ZfsEntryHeaderMap _entryHeaders; + + /** + * Parses the zfs file into file entry headers that can be used later + * to get the entry data. + * + * @param stream The contents of the zfs file + */ + void readHeaders(Common::SeekableReadStream *stream); + + /** + * Entry names are contained within a 16 byte block. This reads the block + * and converts it the name to a Common::String + * + * @param stream The zfs file stream + * @return The entry file name + */ + Common::String readEntryName(Common::SeekableReadStream *stream) const; + + /** + * ZFS file entries can be encrypted using XOR encoding. This method + * decodes the buffer in place using the supplied xorKey. + * + * @param buffer The data to decode + * @param length Length of buffer + */ + void unXor(byte *buffer, uint32 length, const byte *xorKey) const; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 7a5e50f491..d981d14838 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -23,20 +23,19 @@ #include "common/scummsys.h" #include "zvision/zvision.h" - #include "zvision/core/console.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" #include "zvision/text/string_manager.h" -#include "zvision/archives/zfs_archive.h" #include "zvision/detection.h" #include "zvision/core/menu.h" #include "zvision/core/search_manager.h" #include "zvision/text/text.h" #include "zvision/fonts/truetype_font.h" #include "zvision/core/midi.h" +#include "zvision/utility/zfs_archive.h" #include "common/config-manager.h" #include "common/str.h" -- cgit v1.2.3 From f0ce0b498fe62fa97428ebcd36caa2ae883eb775 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:29:08 +0200 Subject: ZVISION: Move the TruetypeFont class --- engines/zvision/fonts/truetype_font.cpp | 344 ------------------------ engines/zvision/fonts/truetype_font.h | 123 --------- engines/zvision/graphics/render_manager.h | 2 +- engines/zvision/graphics/truetype_font.cpp | 341 +++++++++++++++++++++++ engines/zvision/graphics/truetype_font.h | 123 +++++++++ engines/zvision/module.mk | 2 +- engines/zvision/scripting/sidefx/ttytext_node.h | 2 +- engines/zvision/text/string_manager.cpp | 13 +- engines/zvision/text/string_manager.h | 2 +- engines/zvision/text/text.cpp | 8 +- engines/zvision/text/text.h | 2 +- engines/zvision/zvision.cpp | 2 +- 12 files changed, 477 insertions(+), 487 deletions(-) delete mode 100644 engines/zvision/fonts/truetype_font.cpp delete mode 100644 engines/zvision/fonts/truetype_font.h create mode 100644 engines/zvision/graphics/truetype_font.cpp create mode 100644 engines/zvision/graphics/truetype_font.h diff --git a/engines/zvision/fonts/truetype_font.cpp b/engines/zvision/fonts/truetype_font.cpp deleted file mode 100644 index a9363d8923..0000000000 --- a/engines/zvision/fonts/truetype_font.cpp +++ /dev/null @@ -1,344 +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 "common/scummsys.h" - -#include "zvision/fonts/truetype_font.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" - -#include "common/config-manager.h" -#include "common/debug.h" -#include "common/file.h" -#include "common/system.h" -#include "common/unzip.h" - -#include "graphics/font.h" -#include "graphics/fonts/ttf.h" -#include "graphics/surface.h" - -namespace ZVision { - -TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) - : _engine(engine), - _fontHeight(fontHeight), - _font(0), - _lineHeight(0), - _maxCharWidth(0), - _maxCharHeight(0) { -} - -TruetypeFont::~TruetypeFont(void) { - delete _font; -} - -bool TruetypeFont::loadFile(const Common::String &filename) { - Common::File file; - - bool fileOpened = false; - if (!Common::File::exists(filename)) { - debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str()); - fileOpened = file.open("arial.ttf"); - } else { - fileOpened = file.open(filename); - } - - if (!fileOpened) { - debug("TTF file could not be opened"); - return false; - } - - _font = Graphics::loadTTFFont(file, _fontHeight); - _lineHeight = _font->getFontHeight(); - - return true; -} - -Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) { - if (text.equals("")) { - return nullptr; - } - - Graphics::Surface *surface = new Graphics::Surface(); - - if (!wrap) { - int width = MIN(_font->getStringWidth(text), maxWidth); - surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); - // TODO: Add better alpha support by getting the pixels from the backbuffer. - // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background. - surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); - - _font->drawString(surface, text, 0, 0, maxWidth, textColor, align); - return surface; - } - - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - - while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) { - lines.pop_back(); - } - if (lines.size() == 0) { - delete surface; - return nullptr; - } - - surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); - surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); - - int heightOffset = 0; - for (Common::Array::iterator it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align); - heightOffset += _lineHeight; - } - - return surface; -} - -StyledTTFont::StyledTTFont(ZVision *engine) { - _engine = engine; - _style = 0; - _font = NULL; - _lineHeight = 0; -} - -StyledTTFont::~StyledTTFont() { - if (_font) - delete _font; -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { - _style = style; - return loadFont(fontName, point); -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { - Common::String newFontName; - if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "timesbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "timesbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "timesi.ttf"; - else - newFontName = "times.ttf"; - - } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "courbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "courbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "couri.ttf"; - else - newFontName = "cour.ttf"; - - } else if (fontName.matchString("*century schoolbook*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "censcbkbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "censcbkbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "censcbki.ttf"; - else - newFontName = "censcbk.ttf"; - - } else if (fontName.matchString("*garamond*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "garabi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "garabd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "garai.ttf"; - else - newFontName = "gara.ttf"; - - } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "arialbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "arialbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "ariali.ttf"; - else - newFontName = "arial.ttf"; - - } else { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - newFontName = "arial.ttf"; - } - - bool sharp = (_style & STTF_SHARP) == STTF_SHARP; - - Common::File *file = _engine->getSearchManager()->openFile(newFontName); - - if (!file) { - Common::SeekableReadStream *themeFile = nullptr; - if (ConfMan.hasKey("themepath")) { - Common::FSNode themePath(ConfMan.get("themepath")); - if (themePath.exists()) { - Common::FSNode scummModern = themePath.getChild("scummmodern.zip"); - if (scummModern.exists()) { - themeFile = scummModern.createReadStream(); - } - } - } - if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan. - themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); - } - if (themeFile) { - Common::Archive *themeArchive = Common::makeZipArchive(themeFile); - if (themeArchive->hasFile("FreeSans.ttf")) { - Common::SeekableReadStream *stream = nullptr; - stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); - Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - if (stream) - delete stream; - } - delete themeArchive; - themeArchive = nullptr; - } - } else { - Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - delete file; - } - - _fntName = fontName; - _lineHeight = point; - - if (_font) - return true; - return false; -} - -void StyledTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { - _style = newStyle; - loadFont(_fntName, _lineHeight); - } else { - _style = newStyle; - } -} - -int StyledTTFont::getFontHeight() { - if (_font) - return _font->getFontHeight(); - return 0; -} - -int StyledTTFont::getMaxCharWidth() { - if (_font) - return _font->getMaxCharWidth(); - return 0; -} - -int StyledTTFont::getCharWidth(byte chr) { - if (_font) - return _font->getCharWidth(chr); - return 0; -} - -int StyledTTFont::getKerningOffset(byte left, byte right) { - if (_font) - return _font->getKerningOffset(left, right); - return 0; -} - -void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { - if (_font) { - _font->drawChar(dst, chr, x, y, color); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - } -} - -void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { - if (_font) { - _font->drawString(dst, str, x, y, w, color, align); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - } -} - -int StyledTTFont::getStringWidth(const Common::String &str) { - if (_font) - return _font->getStringWidth(str); - return 0; -} - -Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { - Graphics::Surface *tmp = new Graphics::Surface; - if (_font) { - int16 w = _font->getStringWidth(str); - if (w && w < 1024) { - tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); - drawString(tmp, str, 0, 0, w, color); - } - } - return tmp; -} - -} // End of namespace ZVision diff --git a/engines/zvision/fonts/truetype_font.h b/engines/zvision/fonts/truetype_font.h deleted file mode 100644 index 30ef1c73a3..0000000000 --- a/engines/zvision/fonts/truetype_font.h +++ /dev/null @@ -1,123 +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. - * - */ - -// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp - -#ifndef ZVISION_TRUETYPE_FONT_H -#define ZVISION_TRUETYPE_FONT_H - -#include "graphics/font.h" -#include "graphics/pixelformat.h" - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; - -class TruetypeFont { -public: - TruetypeFont(ZVision *engine, int32 fontHeight); - ~TruetypeFont(); - -private: - ZVision *_engine; - Graphics::Font *_font; - int _lineHeight; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - int32 _fontHeight; - -public: - /** - * Loads a .ttf file into memory. This must be called - * before any calls to drawTextToSurface - * - * @param filename The file name of the .ttf file to load - */ - bool loadFile(const Common::String &filename); - /** - * Renders the supplied text to a Surface using 0x0 as the - * background color. - * - * @param text The to render - * @param textColor The color to render the text with - * @param maxWidth The max width the text should take up. - * @param maxHeight The max height the text should take up. - * @param align The alignment of the text within the bounds of maxWidth - * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit - * @return A Surface containing the rendered text - */ - Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap); -}; - -// Styled TTF -class StyledTTFont { -public: - StyledTTFont(ZVision *engine); - ~StyledTTFont(); - - enum { - STTF_BOLD = 1, - STTF_ITALIC = 2, - STTF_UNDERLINE = 4, - STTF_STRIKEOUT = 8, - STTF_SHARP = 16 - }; - -private: - ZVision *_engine; - Graphics::Font *_font; - int _lineHeight; - uint _style; - Common::String _fntName; - -public: - bool loadFont(const Common::String &fontName, int32 point); - bool loadFont(const Common::String &fontName, int32 point, uint style); - void setStyle(uint newStyle); - - int getFontHeight(); - int getMaxCharWidth(); - int getCharWidth(byte chr); - int getKerningOffset(byte left, byte right); - - void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); - - void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); - int getStringWidth(const Common::String &str); - - Graphics::Surface *renderSolidText(const Common::String &str, uint32 color); - - bool isLoaded() { - return _font != NULL; - }; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 39809c65a4..879a8643ce 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -24,7 +24,7 @@ #define ZVISION_RENDER_MANAGER_H #include "zvision/graphics/render_table.h" -#include "zvision/fonts/truetype_font.h" +#include "zvision/graphics/truetype_font.h" #include "common/rect.h" #include "common/hashmap.h" diff --git a/engines/zvision/graphics/truetype_font.cpp b/engines/zvision/graphics/truetype_font.cpp new file mode 100644 index 0000000000..1a0e92087c --- /dev/null +++ b/engines/zvision/graphics/truetype_font.cpp @@ -0,0 +1,341 @@ +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/system.h" +#include "common/unzip.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/graphics/truetype_font.h" + +namespace ZVision { + +TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) + : _engine(engine), + _fontHeight(fontHeight), + _font(0), + _lineHeight(0), + _maxCharWidth(0), + _maxCharHeight(0) { +} + +TruetypeFont::~TruetypeFont(void) { + delete _font; +} + +bool TruetypeFont::loadFile(const Common::String &filename) { + Common::File file; + + bool fileOpened = false; + if (!Common::File::exists(filename)) { + debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str()); + fileOpened = file.open("arial.ttf"); + } else { + fileOpened = file.open(filename); + } + + if (!fileOpened) { + debug("TTF file could not be opened"); + return false; + } + + _font = Graphics::loadTTFFont(file, _fontHeight); + _lineHeight = _font->getFontHeight(); + + return true; +} + +Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) { + if (text.equals("")) { + return nullptr; + } + + Graphics::Surface *surface = new Graphics::Surface(); + + if (!wrap) { + int width = MIN(_font->getStringWidth(text), maxWidth); + surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); + // TODO: Add better alpha support by getting the pixels from the backbuffer. + // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background. + surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); + + _font->drawString(surface, text, 0, 0, maxWidth, textColor, align); + return surface; + } + + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + + while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) { + lines.pop_back(); + } + if (lines.size() == 0) { + delete surface; + return nullptr; + } + + surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); + surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); + + int heightOffset = 0; + for (Common::Array::iterator it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align); + heightOffset += _lineHeight; + } + + return surface; +} + +StyledTTFont::StyledTTFont(ZVision *engine) { + _engine = engine; + _style = 0; + _font = NULL; + _lineHeight = 0; +} + +StyledTTFont::~StyledTTFont() { + if (_font) + delete _font; +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { + _style = style; + return loadFont(fontName, point); +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + Common::String newFontName; + if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "timesbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "timesbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "timesi.ttf"; + else + newFontName = "times.ttf"; + + } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "courbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "courbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "couri.ttf"; + else + newFontName = "cour.ttf"; + + } else if (fontName.matchString("*century schoolbook*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "censcbkbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "censcbkbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "censcbki.ttf"; + else + newFontName = "censcbk.ttf"; + + } else if (fontName.matchString("*garamond*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "garabi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "garabd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "garai.ttf"; + else + newFontName = "gara.ttf"; + + } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) { + if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) + newFontName = "arialbi.ttf"; + else if (_style & STTF_BOLD) + newFontName = "arialbd.ttf"; + else if (_style & STTF_ITALIC) + newFontName = "ariali.ttf"; + else + newFontName = "arial.ttf"; + + } else { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + newFontName = "arial.ttf"; + } + + bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + + Common::File *file = _engine->getSearchManager()->openFile(newFontName); + + if (!file) { + Common::SeekableReadStream *themeFile = nullptr; + if (ConfMan.hasKey("themepath")) { + Common::FSNode themePath(ConfMan.get("themepath")); + if (themePath.exists()) { + Common::FSNode scummModern = themePath.getChild("scummmodern.zip"); + if (scummModern.exists()) { + themeFile = scummModern.createReadStream(); + } + } + } + if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan. + themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); + } + if (themeFile) { + Common::Archive *themeArchive = Common::makeZipArchive(themeFile); + if (themeArchive->hasFile("FreeSans.ttf")) { + Common::SeekableReadStream *stream = nullptr; + stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); + Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + if (stream) + delete stream; + } + delete themeArchive; + themeArchive = nullptr; + } + } else { + Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + delete file; + } + + _fntName = fontName; + _lineHeight = point; + + if (_font) + return true; + return false; +} + +void StyledTTFont::setStyle(uint newStyle) { + if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { + _style = newStyle; + loadFont(_fntName, _lineHeight); + } else { + _style = newStyle; + } +} + +int StyledTTFont::getFontHeight() { + if (_font) + return _font->getFontHeight(); + return 0; +} + +int StyledTTFont::getMaxCharWidth() { + if (_font) + return _font->getMaxCharWidth(); + return 0; +} + +int StyledTTFont::getCharWidth(byte chr) { + if (_font) + return _font->getCharWidth(chr); + return 0; +} + +int StyledTTFont::getKerningOffset(byte left, byte right) { + if (_font) + return _font->getKerningOffset(left, right); + return 0; +} + +void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { + if (_font) { + _font->drawChar(dst, chr, x, y, color); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + } +} + +void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { + if (_font) { + _font->drawString(dst, str, x, y, w, color, align); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + } +} + +int StyledTTFont::getStringWidth(const Common::String &str) { + if (_font) + return _font->getStringWidth(str); + return 0; +} + +Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { + Graphics::Surface *tmp = new Graphics::Surface; + if (_font) { + int16 w = _font->getStringWidth(str); + if (w && w < 1024) { + tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); + drawString(tmp, str, 0, 0, w, color); + } + } + return tmp; +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/truetype_font.h b/engines/zvision/graphics/truetype_font.h new file mode 100644 index 0000000000..30ef1c73a3 --- /dev/null +++ b/engines/zvision/graphics/truetype_font.h @@ -0,0 +1,123 @@ +/* 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. + * + */ + +// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp + +#ifndef ZVISION_TRUETYPE_FONT_H +#define ZVISION_TRUETYPE_FONT_H + +#include "graphics/font.h" +#include "graphics/pixelformat.h" + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; + +class TruetypeFont { +public: + TruetypeFont(ZVision *engine, int32 fontHeight); + ~TruetypeFont(); + +private: + ZVision *_engine; + Graphics::Font *_font; + int _lineHeight; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + int32 _fontHeight; + +public: + /** + * Loads a .ttf file into memory. This must be called + * before any calls to drawTextToSurface + * + * @param filename The file name of the .ttf file to load + */ + bool loadFile(const Common::String &filename); + /** + * Renders the supplied text to a Surface using 0x0 as the + * background color. + * + * @param text The to render + * @param textColor The color to render the text with + * @param maxWidth The max width the text should take up. + * @param maxHeight The max height the text should take up. + * @param align The alignment of the text within the bounds of maxWidth + * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit + * @return A Surface containing the rendered text + */ + Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap); +}; + +// Styled TTF +class StyledTTFont { +public: + StyledTTFont(ZVision *engine); + ~StyledTTFont(); + + enum { + STTF_BOLD = 1, + STTF_ITALIC = 2, + STTF_UNDERLINE = 4, + STTF_STRIKEOUT = 8, + STTF_SHARP = 16 + }; + +private: + ZVision *_engine; + Graphics::Font *_font; + int _lineHeight; + uint _style; + Common::String _fntName; + +public: + bool loadFont(const Common::String &fontName, int32 point); + bool loadFont(const Common::String &fontName, int32 point, uint style); + void setStyle(uint newStyle); + + int getFontHeight(); + int getMaxCharWidth(); + int getCharWidth(byte chr); + int getKerningOffset(byte left, byte right); + + void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); + + void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); + int getStringWidth(const Common::String &str); + + Graphics::Surface *renderSolidText(const Common::String &str, uint32 color); + + bool isLoaded() { + return _font != NULL; + }; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 607a9be4ed..e2beeb593d 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -12,12 +12,12 @@ MODULE_OBJS := \ cursors/cursor_manager.o \ cursors/cursor.o \ detection.o \ - fonts/truetype_font.o \ graphics/effects/fog.o \ graphics/effects/light.o \ graphics/effects/wave.o \ graphics/render_manager.o \ graphics/render_table.o \ + graphics/truetype_font.o \ scripting/actions.o \ scripting/control.o \ scripting/controls/fist_control.o \ diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h index a229129b9d..b6cbed3e34 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.h +++ b/engines/zvision/scripting/sidefx/ttytext_node.h @@ -28,7 +28,7 @@ #include "zvision/scripting/sidefx.h" #include "zvision/text/text.h" -#include "zvision/fonts/truetype_font.h" +#include "zvision/graphics/truetype_font.h" namespace Common { class String; diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index f88f9eaddd..1a04c67988 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -21,20 +21,17 @@ */ #include "common/scummsys.h" - -#include "zvision/zvision.h" -#include "zvision/core/search_manager.h" -#include "zvision/text/string_manager.h" - -#include "zvision/fonts/truetype_font.h" - #include "common/file.h" #include "common/tokenizer.h" #include "common/debug.h" - #include "graphics/fontman.h" #include "graphics/colormasks.h" +#include "zvision/zvision.h" +#include "zvision/core/search_manager.h" +#include "zvision/text/string_manager.h" +#include "zvision/graphics/truetype_font.h" + namespace ZVision { StringManager::StringManager(ZVision *engine) diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index 61c0d95f51..8d6fbe67a6 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -24,7 +24,7 @@ #define ZVISION_STRING_MANAGER_H #include "zvision/detection.h" -#include "zvision/fonts/truetype_font.h" +#include "zvision/graphics/truetype_font.h" namespace Graphics { class FontManager; diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 6f41416015..0ccca214d7 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -21,23 +21,19 @@ */ #include "common/scummsys.h" - -#include "zvision/text/text.h" - -#include "zvision/fonts/truetype_font.h" - #include "common/file.h" #include "common/tokenizer.h" #include "common/debug.h" #include "common/rect.h" - #include "graphics/fontman.h" #include "graphics/colormasks.h" #include "graphics/surface.h" #include "graphics/font.h" #include "graphics/fonts/ttf.h" +#include "zvision/text/text.h" #include "zvision/graphics/render_manager.h" +#include "zvision/graphics/truetype_font.h" #include "zvision/scripting/script_manager.h" namespace ZVision { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index 6b916860f0..01c3fd760c 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -25,7 +25,7 @@ #define ZVISION_TEXT_H #include "zvision/detection.h" -#include "zvision/fonts/truetype_font.h" +#include "zvision/graphics/truetype_font.h" #include "zvision/zvision.h" namespace Graphics { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index d981d14838..af9d26a350 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -33,7 +33,7 @@ #include "zvision/core/menu.h" #include "zvision/core/search_manager.h" #include "zvision/text/text.h" -#include "zvision/fonts/truetype_font.h" +#include "zvision/graphics/truetype_font.h" #include "zvision/core/midi.h" #include "zvision/utility/zfs_archive.h" -- cgit v1.2.3 From dab4ce1f7bc5c72f9f90bc0de8553e4b4e945624 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 3 Dec 2014 02:38:06 +0200 Subject: ZVISION: Move the subtitle class --- engines/zvision/graphics/subtitles.cpp | 108 ++++++++++++++++++++++ engines/zvision/graphics/subtitles.h | 54 +++++++++++ engines/zvision/module.mk | 2 +- engines/zvision/scripting/sidefx/music_node.h | 2 +- engines/zvision/scripting/sidefx/syncsound_node.h | 2 +- engines/zvision/subtitles/subtitles.cpp | 108 ---------------------- engines/zvision/subtitles/subtitles.h | 54 ----------- engines/zvision/video/video.cpp | 2 +- 8 files changed, 166 insertions(+), 166 deletions(-) create mode 100644 engines/zvision/graphics/subtitles.cpp create mode 100644 engines/zvision/graphics/subtitles.h delete mode 100644 engines/zvision/subtitles/subtitles.cpp delete mode 100644 engines/zvision/subtitles/subtitles.h diff --git a/engines/zvision/graphics/subtitles.cpp b/engines/zvision/graphics/subtitles.cpp new file mode 100644 index 0000000000..784721562a --- /dev/null +++ b/engines/zvision/graphics/subtitles.cpp @@ -0,0 +1,108 @@ +/* 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 "zvision/graphics/render_manager.h" +#include "zvision/graphics/subtitles.h" +#include "zvision/core/search_manager.h" +#include "zvision/text/text.h" + +namespace ZVision { + +Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : + _engine(engine), + _areaId(-1), + _subId(-1) { + Common::File file; + if (_engine->getSearchManager()->openFile(file, subname)) { + while (!file.eos()) { + Common::String str = file.readLine(); + if (str.lastChar() == '~') + str.deleteLastChar(); + + if (str.matchString("*Initialization*", true)) { + // Not used + } else if (str.matchString("*Rectangle*", true)) { + int32 x1, y1, x2, y2; + sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); + Common::Rect rct = Common::Rect(x1, y1, x2, y2); + _areaId = _engine->getRenderManager()->createSubArea(rct); + } else if (str.matchString("*TextFile*", true)) { + char filename[64]; + sscanf(str.c_str(), "%*[^:]:%s", filename); + Common::File txt; + if (_engine->getSearchManager()->openFile(txt, filename)) { + while (!txt.eos()) { + Common::String txtline = readWideLine(txt); + sub curSubtitle; + curSubtitle.start = -1; + curSubtitle.stop = -1; + curSubtitle.subStr = txtline; + + _subs.push_back(curSubtitle); + } + txt.close(); + } + } else { + int32 st; + int32 en; + int32 sb; + if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { + if (sb <= (int32)_subs.size()) { + _subs[sb].start = st; + _subs[sb].stop = en; + } + } + } + } + } +} + +Subtitle::~Subtitle() { + if (_areaId != -1) + _engine->getRenderManager()->deleteSubArea(_areaId); + + _subs.clear(); +} + +void Subtitle::process(int32 time) { + int16 j = -1; + for (uint16 i = 0; i < _subs.size(); i++) + if (time >= _subs[i].start && time <= _subs[i].stop) { + j = i; + break; + } + + if (j == -1 && _subId != -1) { + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, ""); + _subId = -1; + } + + if (j != -1 && j != _subId) { + if (_subs[j].subStr.size()) + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr); + _subId = j; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/subtitles.h b/engines/zvision/graphics/subtitles.h new file mode 100644 index 0000000000..c3da6583a4 --- /dev/null +++ b/engines/zvision/graphics/subtitles.h @@ -0,0 +1,54 @@ +/* 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 ZVISION_SUBTITLES_H +#define ZVISION_SUBTITLES_H + +#include "zvision/zvision.h" + +namespace ZVision { + +class ZVision; + +class Subtitle { +public: + Subtitle(ZVision *engine, const Common::String &subname); + ~Subtitle(); + + void process(int32 time); +private: + ZVision *_engine; + int32 _areaId; + int16 _subId; + + struct sub { + int start; + int stop; + Common::String subStr; + }; + + Common::Array _subs; +}; + +} + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index e2beeb593d..045eb5264a 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -17,6 +17,7 @@ MODULE_OBJS := \ graphics/effects/wave.o \ graphics/render_manager.o \ graphics/render_table.o \ + graphics/subtitles.o \ graphics/truetype_font.o \ scripting/actions.o \ scripting/control.o \ @@ -41,7 +42,6 @@ MODULE_OBJS := \ scripting/sidefx/timer_node.o \ scripting/sidefx/ttytext_node.o \ sound/zork_raw.o \ - subtitles/subtitles.o \ text/string_manager.o \ text/text.o \ utility/clock.o \ diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index 954e2f474e..c89345f0d0 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/scripting/sidefx.h" -#include "zvision/subtitles/subtitles.h" +#include "zvision/graphics/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h index c16ffebe7f..7cd02a8aef 100644 --- a/engines/zvision/scripting/sidefx/syncsound_node.h +++ b/engines/zvision/scripting/sidefx/syncsound_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/scripting/sidefx.h" -#include "zvision/subtitles/subtitles.h" +#include "zvision/graphics/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/subtitles/subtitles.cpp b/engines/zvision/subtitles/subtitles.cpp deleted file mode 100644 index d36eb24923..0000000000 --- a/engines/zvision/subtitles/subtitles.cpp +++ /dev/null @@ -1,108 +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 "zvision/subtitles/subtitles.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/core/search_manager.h" -#include "zvision/text/text.h" - -namespace ZVision { - -Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : - _engine(engine), - _areaId(-1), - _subId(-1) { - Common::File file; - if (_engine->getSearchManager()->openFile(file, subname)) { - while (!file.eos()) { - Common::String str = file.readLine(); - if (str.lastChar() == '~') - str.deleteLastChar(); - - if (str.matchString("*Initialization*", true)) { - // Not used - } else if (str.matchString("*Rectangle*", true)) { - int32 x1, y1, x2, y2; - sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); - Common::Rect rct = Common::Rect(x1, y1, x2, y2); - _areaId = _engine->getRenderManager()->createSubArea(rct); - } else if (str.matchString("*TextFile*", true)) { - char filename[64]; - sscanf(str.c_str(), "%*[^:]:%s", filename); - Common::File txt; - if (_engine->getSearchManager()->openFile(txt, filename)) { - while (!txt.eos()) { - Common::String txtline = readWideLine(txt); - sub curSubtitle; - curSubtitle.start = -1; - curSubtitle.stop = -1; - curSubtitle.subStr = txtline; - - _subs.push_back(curSubtitle); - } - txt.close(); - } - } else { - int32 st; - int32 en; - int32 sb; - if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { - if (sb <= (int32)_subs.size()) { - _subs[sb].start = st; - _subs[sb].stop = en; - } - } - } - } - } -} - -Subtitle::~Subtitle() { - if (_areaId != -1) - _engine->getRenderManager()->deleteSubArea(_areaId); - - _subs.clear(); -} - -void Subtitle::process(int32 time) { - int16 j = -1; - for (uint16 i = 0; i < _subs.size(); i++) - if (time >= _subs[i].start && time <= _subs[i].stop) { - j = i; - break; - } - - if (j == -1 && _subId != -1) { - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, ""); - _subId = -1; - } - - if (j != -1 && j != _subId) { - if (_subs[j].subStr.size()) - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr); - _subId = j; - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/subtitles/subtitles.h b/engines/zvision/subtitles/subtitles.h deleted file mode 100644 index c3da6583a4..0000000000 --- a/engines/zvision/subtitles/subtitles.h +++ /dev/null @@ -1,54 +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 ZVISION_SUBTITLES_H -#define ZVISION_SUBTITLES_H - -#include "zvision/zvision.h" - -namespace ZVision { - -class ZVision; - -class Subtitle { -public: - Subtitle(ZVision *engine, const Common::String &subname); - ~Subtitle(); - - void process(int32 time); -private: - ZVision *_engine; - int32 _areaId; - int16 _subId; - - struct sub { - int start; - int stop; - Common::String subStr; - }; - - Common::Array _subs; -}; - -} - -#endif diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 25125ec2fb..36b5f9b921 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -29,7 +29,7 @@ #include "zvision/zvision.h" #include "zvision/utility/clock.h" #include "zvision/graphics/render_manager.h" -#include "zvision/subtitles/subtitles.h" +#include "zvision/graphics/subtitles.h" namespace ZVision { -- cgit v1.2.3 From e0d008a9ca83cc9f1bfae0d089f90f2c3b39fa0f Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Wed, 5 Nov 2014 20:36:33 +0100 Subject: SCUMM: puttrace - Add suport for a dutch demo variant. Found on Spy Fox 2 CD, Mac partition (EAN 5400646050646) --- devtools/scumm-md5.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index eef50003d2..361595670b 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -722,6 +722,7 @@ puttrace Putt-Putt Enters the Race 62050da376483d8edcbd98cd26b6cb57 -1 ru Windows HE 99 - - sev 0ac41e2e3d2174e5a042a6b565328dba 13110 us All HE 98 Demo - sev + ee8cfeb76e55d43a01c25e0865a9db76 13135 nl Mac HE 98 Demo - Ben Castricum 6af2419fe3db5c2fdb091ae4e5833770 -1 nl All HE 98.5 Demo - Kirben 663743c03ae0c007f3d665cf631c0e6b 13135 de All HE 99 Demo - Joachim Eberhard aaa587701cde7e74692c68c1024b85eb -1 nl All HE 99 Demo - joostp -- cgit v1.2.3 From 2e497bb9f83d0435e88bcd283b636c4e2c9043e3 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Sat, 15 Nov 2014 13:26:16 +0100 Subject: SCUMM: farm - Add support for a dutch Macintosh variant. Found on CD with EAN8714902148334. --- devtools/scumm-md5.txt | 1 + engines/scumm/detection_tables.h | 1 + 2 files changed, 2 insertions(+) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 361595670b..1f1f75affd 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -622,6 +622,7 @@ farm Let's Explore the Farm with Buzzy a5c5388da9bf0e6662fdca8813a79d13 86962 en Windows - - - George Kormendi a85856675429fe88051744f755b72f93 -1 en Windows - - - Kirben a2386da005672cbd5136f4f27a626c5f 87061 nl Windows - - - George Kormendi + eeb606c2d2ec877a712a9f20c10bcdda 87034 nl Mac - - - Ben Castricum 5dda73606533d66a4c3f4f9ea6e842af 87061 ru Windows - - - sev 39fd6db10d0222d817025c4d3346e3b4 -1 en Mac - Demo - Joachim Eberhard diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 3f08f17aff..42b5f4ce97 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -664,6 +664,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "dog", "Springparadijs", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "farm", "farm", kGenHEPC, UNK_LANG, UNK, 0 }, + { "farm", "farm", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "farm", "farmdemo", kGenHEPC, UNK_LANG, UNK, 0 }, { "farm", "Farm Demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, -- cgit v1.2.3 From 50b904ee94eb5640f90c01981daf660d2187a35b Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Wed, 5 Nov 2014 20:48:11 +0100 Subject: SCUMM: Add support for the "Mini Games" from Kellogg's complimentary CD --- devtools/scumm-md5.txt | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 1f1f75affd..3edb53c598 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -561,7 +561,11 @@ freddi4 Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch fa84cb1018103a4ee4e5fa8041c1d0d1 13609 de Windows - Demo - George Kormendi ebd324dcf06a4c49e1ba5c231eee1060 -1 us All HE 99 Demo - sev 688328c5bdc4c8ec4145688dfa077bf2 -1 de All HE 99 Demo - Joachim Eberhard - 03d3b18ee3fd68114e2a687c871e38d5 -1 us Windows HE 99 Mini Game - eriktorbjorn + 03d3b18ee3fd68114e2a687c871e38d5 13609 us Windows HE 99 Mini Game - eriktorbjorn + 9340b552b0f2dffe6d4f3d13ebebe832 13609 nl Windows HE 99 Mini Game - Ben Castricum + c486e4cfa7bd6f8efcd0740f96f7dde3 13609 fr Windows HE 99 Mini Game - Ben Castricum + 7a2b6d8e8a645c9d534c8c4edc38a9c9 13609 it Windows HE 99 Mini Game - Ben Castricum + 09b0be55c16cd9e88b5080bf89ff281d 13609 de Windows HE 99 Mini Game - Ben Castricum 16effd200aa6b8abe9c569c3e578814d -1 nl All HE 99 Demo - joostp 499c958affc394f2a3868f1eb568c3ee -1 nl All HE 99 Demo - adutchguy 5fdb2ac2483908b065c6e77988338a54 -1 nl Windows HE 99 Demo - Ben @@ -686,7 +690,11 @@ pajama3 Pajama Sam 3: You Are What You Eat From Your Head to Your Feet a654fb60c3b67d6317a7894ffd9f25c5 -1 us All - Demo - sev a9f2f04b1ecaab9495b59befffe9bf88 -1 us All - Demo - sev 0c45eb4baff0c12c3d9dfa889c8070ab 13884 de All - Demo - Joachim Eberhard - 4fe6a2e8df3c4536b278fdd2fbcb181e -1 en Windows - Mini Game - Trekky + 4fe6a2e8df3c4536b278fdd2fbcb181e 13911 en Windows - Mini Game - Trekky + 24942a4200d99bdb4bdb78f9c7e07027 13911 nl Windows - Mini Game - Ben Castricum + faa89ab5e67ba4eebb4399f584f7490c 13911 fr Windows - Mini Game - Ben Castricum + d1a73e87564477c7c2dcc2b8f616ad0b 13911 it Windows - Mini Game - Ben Castricum + a8fcc3084ad5e3e569722755f205b1ef 13911 de Windows - Mini Game - Ben Castricum 679855cf61932f9bf995c8f3677380ed -1 fr Windows - Demo - Mevi c8c5baadcbfc8d0372ed4335abace8a7 -1 fr Windows - Demo - Mevi 784b499c98d07260a30952685758636b 13911 de Windows - Demo - George Kormendi @@ -813,7 +821,10 @@ PuttTime Putt-Putt Travels Through Time 59d5cfcc5e672a6e07baae01328b918b -1 fr All HE 90 Demo - Kirben fbb697d89d2beca87360a145f467bdae -1 de All HE 90 Demo - Joachim Eberhard 6b19d0e25cbf720d05822379b8b90ed9 -1 nl All HE 90 Demo - adutchguy - 0a6d7b81b850ed4a77811c60c9b5c555 -1 us Windows HE 99 Mini Game - eriktorbjorn + 0a6d7b81b850ed4a77811c60c9b5c555 18458 us Windows HE 99 Mini Game - eriktorbjorn + a71014c53a6d18c66ef2ea0ee42328e9 18458 nl Windows HE 99 Mini Game - Ben Castricum + 8dd4d590685c19bf651b5016e749ead2 18458 fr Windows HE 99 Mini Game - Ben Castricum + aef415cc5dc063e3668359c2657169f3 18458 de Windows HE 99 Mini Game - Ben Castricum 0ab19be9e2a3f6938226638b2a3744fe -1 us All HE 100 Demo - khalek balloon Putt-Putt and Pep's Balloon-O-Rama @@ -882,7 +893,11 @@ spyfox2 SPY Fox 2: Some Assembly Required 1c792d28376d45e145cb916bca0400a2 -1 nl All - Demo - joostp 7222f260253f325c21fcfa68b5bfab67 -1 us All - Demo - Kirben 732845548b1d6c2da572cb6a1bf81b07 -1 de All - Demo - Joachim Eberhard - e62056ba675ad65d8854ab3c5ad4b3c0 -1 en Windows - Mini Game - Trekky + e62056ba675ad65d8854ab3c5ad4b3c0 14689 en Windows - Mini Game - Trekky + 22c7432dc97a821fcfccd480e93e3911 14689 nl Windows - Mini Game - Ben Castricum + 6b10c9977cad9de503642059359792b1 14689 fr Windows - Mini Game - Ben Castricum + 9684c161258d68e0d464d6cab7024b9c 14689 it Windows - Mini Game - Ben Castricum + 7f2578d8d33a9ff525488a2d9ba617e4 14689 de Windows - Mini Game - Ben Castricum 22de86b2f7ec6e5db745ed1123310b44 15832 fr Windows - Demo - George Kormendi 204453e33456c4faa26e276229fe5b76 14689 de Windows - Demo - George Kormendi 19bf6938a94698296bcb0c99c31c91a7 -1 gb Windows - Demo - eriktorbjorn -- cgit v1.2.3 From 75408c1cb860d143076460ea4c42dc0acd1ced03 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Sun, 9 Nov 2014 16:39:25 +0100 Subject: SCUMM: More detection fixes. --- devtools/scumm-md5.txt | 6 +++--- engines/scumm/detection_tables.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 3edb53c598..37d7e7a5e1 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -480,9 +480,9 @@ fbpack Fatty Bear's Fun Pack freddi Freddi Fish 1: The Case of the Missing Kelp Seeds d4cccb5af88f3e77f370896e9ba8c5f9 -1 All Windows HE 71 - - sev - c0039ad982999c92d0de81910d640fa0 -1 nl Windows HE 71 - - adutchguy + c0039ad982999c92d0de81910d640fa0 26159 nl Windows HE 71 - - adutchguy 68530d2e15f339fbbf3150b78b4d2ffb -1 en Mac HE 73 - - satz - 6d1baa1065ac5f7b210be8ebe4235e49 -1 nl Mac HE 73 - - daniel9 + 6d1baa1065ac5f7b210be8ebe4235e49 26384 nl Mac HE 73 - - daniel9 c782fbbe74a987c3df8ac73cd3e289ed -1 se Mac HE 73 - - Torbjrn Andersson 5ebb57234b2fe5c5dff641e00184ad81 -1 fr Windows HE 73 - - gist974 cf8ef3a1fb483c5c4b1c584d1167b2c4 -1 de Windows HE 73 - - Oncer @@ -888,7 +888,7 @@ spyfox2 SPY Fox 2: Some Assembly Required bc4700bc0e12879f6d25d14d6be6cfdd -1 de All - - - Joachim Eberhard cea91e3dd47f2518ea418e41611aa77f -1 ru All - - - sev 9fd66fb3b04703bd50da4356e4202558 51295 en Mac - - - pix_climber - 71fe97c3108678cf604f14abe342341b -1 nl Windows - - - adutchguy + 71fe97c3108678cf604f14abe342341b 51286 nl All - - - adutchguy 1c792d28376d45e145cb916bca0400a2 -1 nl All - Demo - joostp 7222f260253f325c21fcfa68b5bfab67 -1 us All - Demo - Kirben diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 42b5f4ce97..f72e552fa6 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -856,7 +856,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "putttime", "PuttTijd", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "putttime", "Putt Time", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, { "putttime", "PuttTTT", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, - { "putttime", "PuttTTT", kGenHEPC, UNK_LANG, UNK, 0 }, + { "putttime", "PuttTTT", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "putttime", "TIJDDEMO", kGenHEPC, Common::NL_NLD, Common::kPlatformWindows, 0 }, { "putttime", "TijdDemo", kGenHEMac, Common::NL_NLD, Common::kPlatformMacintosh, 0 }, { "putttime", "timedemo", kGenHEPC, UNK_LANG, UNK, 0 }, @@ -918,7 +918,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "spyfox", "JR-Demo", kGenHEMac, Common::FR_FRA, Common::kPlatformMacintosh, 0 }, { "spyfox", "game", kGenHEIOS, Common::EN_ANY, Common::kPlatformIOS, 0 }, - { "spyfox2", "spyfox2", kGenHEPC, UNK_LANG, UNK, 0 }, + { "spyfox2", "spyfox2", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "spyfox2", "sf2-demo", kGenHEPC, UNK_LANG, UNK, 0 }, { "spyfox2", "sf2demo", kGenHEPC, UNK_LANG, Common::kPlatformWindows, 0 }, { "spyfox2", "Sf2demo", kGenHEMac, UNK_LANG, Common::kPlatformMacintosh, 0 }, -- cgit v1.2.3 From 30038ef789791512529ce13af4d72940efbbb563 Mon Sep 17 00:00:00 2001 From: Ben Castricum Date: Sat, 15 Nov 2014 13:56:11 +0100 Subject: SCUMM: Update scumm-md5.h --- engines/scumm/scumm-md5.h | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 878b2eeef3..4a34894506 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Sat Nov 01 11:52:16 2014 + This file was generated by the md5table tool on Sat Nov 29 19:54:41 2014 DO NOT EDIT MANUALLY! */ @@ -20,7 +20,7 @@ static const MD5Table md5table[] = { { "0354ee0d14cde1264ec762261c04c14a", "loom", "Steam", "Steam", 585728, Common::EN_ANY, Common::kPlatformWindows }, { "035deab53b47bc43abc763560d0f8d4b", "atlantis", "Floppy", "Demo", -1, Common::EN_ANY, Common::kPlatformDOS }, { "037385a953789190298494d92b89b3d0", "catalog", "HE 72", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, - { "03d3b18ee3fd68114e2a687c871e38d5", "freddi4", "HE 99", "Mini Game", -1, Common::EN_USA, Common::kPlatformWindows }, + { "03d3b18ee3fd68114e2a687c871e38d5", "freddi4", "HE 99", "Mini Game", 13609, Common::EN_USA, Common::kPlatformWindows }, { "0425954a9db5c340861672892c3e678d", "samnmax", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "04401d747f1a2c1c4b388daff71ed378", "ft", "", "", 535405461, Common::DE_DEU, Common::kPlatformMacintosh }, { "04687cdf7f975a89d2474929f7b80946", "indy3", "FM-TOWNS", "", 7552, Common::EN_ANY, Common::kPlatformFMTowns }, @@ -37,10 +37,11 @@ static const MD5Table md5table[] = { { "08656dd9698ddf1023ba9bf8a195e37b", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformDOS }, { "08cc5c3eedaf72ebe12734eee94f7fa2", "balloon", "HE 80", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "09820417db26687bb7fe0c83cc4c553b", "ft", "", "Version A", 19697, Common::EN_ANY, Common::kPlatformUnknown }, + { "09b0be55c16cd9e88b5080bf89ff281d", "freddi4", "HE 99", "Mini Game", 13609, Common::DE_DEU, Common::kPlatformWindows }, { "0a212fa35fa8421f31c1f3961272caf0", "monkey", "VGA", "VGA", -1, Common::DE_DEU, Common::kPlatformAmiga }, { "0a295b80f9a9edf818e8e161a0e83830", "freddi2", "HE 80", "", -1, Common::FR_FRA, Common::kPlatformUnknown }, { "0a41311d462b6639fc45297b9044bf16", "monkey", "No AdLib", "EGA", -1, Common::ES_ESP, Common::kPlatformAtariST }, - { "0a6d7b81b850ed4a77811c60c9b5c555", "PuttTime", "HE 99", "Mini Game", -1, Common::EN_USA, Common::kPlatformWindows }, + { "0a6d7b81b850ed4a77811c60c9b5c555", "PuttTime", "HE 99", "Mini Game", 18458, Common::EN_USA, Common::kPlatformWindows }, { "0aa050f4ad79402fbe9c4f78fb8ac494", "loom", "PC-Engine", "", 6532, Common::EN_ANY, Common::kPlatformPCEngine }, { "0ab19be9e2a3f6938226638b2a3744fe", "PuttTime", "HE 100", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown }, { "0ac41e2e3d2174e5a042a6b565328dba", "puttrace", "HE 98", "Demo", 13110, Common::EN_USA, Common::kPlatformUnknown }, @@ -114,10 +115,12 @@ static const MD5Table md5table[] = { { "21abe302e1b1e2b66d6f5c12e241ebfd", "freddicove", "unenc", "Unencrypted", -1, Common::RU_RUS, Common::kPlatformWindows }, { "2232b0b9411575b1f9961713ebc9de61", "balloon", "HE 80", "", -1, Common::NL_NLD, Common::kPlatformWindows }, { "225e18566e810c634bf7de63e7568e3e", "mustard", "", "", -1, Common::EN_USA, Common::kPlatformUnknown }, + { "22c7432dc97a821fcfccd480e93e3911", "spyfox2", "", "Mini Game", 14689, Common::NL_NLD, Common::kPlatformWindows }, { "22c9eb04455440131ffc157aeb8d40a8", "fbear", "HE 70", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "22de86b2f7ec6e5db745ed1123310b44", "spyfox2", "", "Demo", 15832, Common::FR_FRA, Common::kPlatformWindows }, { "22f4ea88a09da12df9308ba30bcb7d0f", "loom", "EGA", "EGA", -1, Common::EN_ANY, Common::kPlatformDOS }, { "23394c8d29cc63c61313959431a12476", "spyfox", "HE 100", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows }, + { "24942a4200d99bdb4bdb78f9c7e07027", "pajama3", "", "Mini Game", 13911, Common::NL_NLD, Common::kPlatformWindows }, { "254fede2f15dbb32a23760d601b01816", "zak", "V1", "", -1, Common::EN_ANY, Common::kPlatformC64 }, { "2723fea3dae0cb47768c424b145ae0e7", "tentacle", "Floppy", "Floppy", 7932, Common::EN_ANY, Common::kPlatformDOS }, { "27b2ef1653089fe5b897d9cc89ce784f", "balloon", "HE 80", "", -1, Common::RU_RUS, Common::kPlatformWindows }, @@ -230,7 +233,7 @@ static const MD5Table md5table[] = { { "4f580a021eee026f3b4589e17d130d78", "freddi4", "", "", -1, Common::UNK_LANG, Common::kPlatformUnknown }, { "4fa6870d9bc8c313b65d54b1da5a1891", "pajama", "", "", -1, Common::NL_NLD, Common::kPlatformUnknown }, { "4fbbe9f64b8bc547503a379a301183ce", "tentacle", "", "CD", -1, Common::IT_ITA, Common::kPlatformUnknown }, - { "4fe6a2e8df3c4536b278fdd2fbcb181e", "pajama3", "", "Mini Game", -1, Common::EN_ANY, Common::kPlatformWindows }, + { "4fe6a2e8df3c4536b278fdd2fbcb181e", "pajama3", "", "Mini Game", 13911, Common::EN_ANY, Common::kPlatformWindows }, { "5057fb0e99e5aa29df1836329232f101", "freddi2", "HE 80", "", -1, Common::UNK_LANG, Common::kPlatformWindows }, { "507bb360688dc4180fdf0d7597352a69", "freddi", "HE 73", "", 26402, Common::SE_SWE, Common::kPlatformWindows }, { "50b831f11b8c4b83784cf81f4dcc69ea", "spyfox", "HE 101", "", -1, Common::EN_ANY, Common::kPlatformWii }, @@ -302,6 +305,7 @@ static const MD5Table md5table[] = { { "6a60d395b78b205c93a956100b1bf5ae", "pajama2", "HE 98.5", "", -1, Common::DE_DEU, Common::kPlatformUnknown }, { "6a8133b63d46f6663fbcbb49d5a2edb1", "atlantis", "Steam", "Steam", 520548, Common::EN_ANY, Common::kPlatformMacintosh }, { "6af2419fe3db5c2fdb091ae4e5833770", "puttrace", "HE 98.5", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown }, + { "6b10c9977cad9de503642059359792b1", "spyfox2", "", "Mini Game", 14689, Common::FR_FRA, Common::kPlatformWindows }, { "6b19d0e25cbf720d05822379b8b90ed9", "PuttTime", "HE 90", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown }, { "6b257bb2827dd894b8109a50a1a18b5a", "freddicove", "HE 100", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown }, { "6b27dbcd8d5697d5c918eeca0f68ef6a", "puttrace", "HE CUP", "Preview", 3901484, Common::UNK_LANG, Common::kPlatformUnknown }, @@ -311,7 +315,7 @@ static const MD5Table md5table[] = { { "6bf70eee5de3d24d2403e0dd3d267e8a", "spyfox", "", "", 49221, Common::UNK_LANG, Common::kPlatformWindows }, { "6c2bff0e327f2962e809c2e1a82d7309", "monkey", "VGA", "VGA", -1, Common::EN_ANY, Common::kPlatformAmiga }, { "6c375c2236d99f56e6c2cf540e74e474", "farm", "", "Demo", 34333, Common::NL_NLD, Common::kPlatformWindows }, - { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, + { "6d1baa1065ac5f7b210be8ebe4235e49", "freddi", "HE 73", "", 26384, Common::NL_NLD, Common::kPlatformMacintosh }, { "6dead580b0ff14d5f7b33b4219f04159", "samnmax", "", "Demo", 16556335, Common::EN_ANY, Common::kPlatformMacintosh }, { "6df20c50c1ab19799de9be7ae7716881", "fbear", "HE 62", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh }, { "6e959d65358eedf9b68b81e304b97fa4", "tentacle", "", "CD", 7932, Common::DE_DEU, Common::kPlatformUnknown }, @@ -325,7 +329,7 @@ static const MD5Table md5table[] = { { "70b0719ac3a5b47ae233c561823d5b96", "puttzoo", "", "", -1, Common::NL_NLD, Common::kPlatformMacintosh }, { "71523b539491527d9860f4407faf0411", "monkey", "Demo", "EGA Demo", 7607, Common::EN_ANY, Common::kPlatformDOS }, { "71d384e7676c53d513ddd333eae1d82c", "Blues123time", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, - { "71fe97c3108678cf604f14abe342341b", "spyfox2", "", "", -1, Common::NL_NLD, Common::kPlatformWindows }, + { "71fe97c3108678cf604f14abe342341b", "spyfox2", "", "", 51286, Common::NL_NLD, Common::kPlatformUnknown }, { "7222f260253f325c21fcfa68b5bfab67", "spyfox2", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown }, { "72ac6bc980d5101c2142189d746bd62f", "spyfox", "HE 99", "", -1, Common::RU_RUS, Common::kPlatformWindows }, { "732845548b1d6c2da572cb6a1bf81b07", "spyfox2", "", "Demo", -1, Common::DE_DEU, Common::kPlatformUnknown }, @@ -349,6 +353,7 @@ static const MD5Table md5table[] = { { "78c07ca088526d8d4446a4c2cb501203", "freddi3", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformUnknown }, { "7974365d3dc0f43a2748c975f91ff042", "monkey2", "", "", -1, Common::ES_ESP, Common::kPlatformDOS }, { "79b05f628586837e7166e82b2279bb50", "loom", "PC-Engine", "", -1, Common::JA_JPN, Common::kPlatformPCEngine }, + { "7a2b6d8e8a645c9d534c8c4edc38a9c9", "freddi4", "HE 99", "Mini Game", 13609, Common::IT_ITA, Common::kPlatformWindows }, { "7b4ee071eecadc2d8cd0c3509110825c", "puttzoo", "HE 100", "Remastered", -1, Common::EN_ANY, Common::kPlatformWindows }, { "7bad72e332a59f9fcc1d437f4edad32a", "puttcircus", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown }, { "7c2e76087027eeee9c8f8985f93a1cc5", "freddi4", "", "Demo", 13584, Common::EN_ANY, Common::kPlatformUnknown }, @@ -358,6 +363,7 @@ static const MD5Table md5table[] = { { "7e151c17adf624f1966c8fc5827c95e9", "puttputt", "HE 61", "", -1, Common::EN_ANY, Common::kPlatform3DO }, { "7ea2da67ebabea4ac20cee9f4f9d2934", "airport", "", "Demo", -1, Common::EN_ANY, Common::kPlatformMacintosh }, { "7edd665bbede7ea8b7233f8e650be6f8", "samnmax", "", "CD", -1, Common::FR_FRA, Common::kPlatformUnknown }, + { "7f2578d8d33a9ff525488a2d9ba617e4", "spyfox2", "", "Mini Game", 14689, Common::DE_DEU, Common::kPlatformWindows }, { "7f45ddd6dbfbf8f80c0c0efea4c295bc", "maniac", "V1", "V1", 1972, Common::EN_ANY, Common::kPlatformDOS }, { "7f945525abcd48015adf1632637a44a1", "pajama", "", "Demo", -1, Common::FR_FRA, Common::kPlatformUnknown }, { "7fbcff27c323499beaedd605e1ebd47d", "indy3", "Steam", "Steam", 561152, Common::EN_ANY, Common::kPlatformWindows }, @@ -390,6 +396,7 @@ static const MD5Table md5table[] = { { "8afb3cf9f95abf208358e984f0c9e738", "funpack", "", "", -1, Common::EN_ANY, Common::kPlatform3DO }, { "8bdb0bf87b5e303dd35693afb9351215", "ft", "", "", -1, Common::DE_DEU, Common::kPlatformUnknown }, { "8d479e36f35e80257dfc102cf4b8a912", "farm", "HE 72", "Demo", 34333, Common::EN_ANY, Common::kPlatformWindows }, + { "8dd4d590685c19bf651b5016e749ead2", "PuttTime", "HE 99", "Mini Game", 18458, Common::FR_FRA, Common::kPlatformWindows }, { "8de13897f0121c79d29a2377159f9ad0", "socks", "HE 99", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows }, { "8e3241ddd6c8dadf64305e8740d45e13", "balloon", "HE 100", "Updated", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "8e4ee4db46954bfe2912e259a16fad82", "monkey2", "", "", -1, Common::FR_FRA, Common::kPlatformDOS }, @@ -411,11 +418,13 @@ static const MD5Table md5table[] = { { "92b078d9d6d9d751da9c26b8b3075779", "tentacle", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS }, { "92e7727e67f5cd979d8a1070e4eb8cb3", "puttzoo", "HE 98.5", "Updated", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "92fc0073a4cf259ff36070ecb8628ba8", "thinkerk", "", "", -1, Common::EN_USA, Common::kPlatformUnknown }, + { "9340b552b0f2dffe6d4f3d13ebebe832", "freddi4", "HE 99", "Mini Game", 13609, Common::NL_NLD, Common::kPlatformWindows }, { "94aaedbb8f26d71ed3ad6dd34490e29e", "tentacle", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS }, { "94db6519da85b8d08c976d8e9a858ea7", "baseball", "HE CUP", "Preview", 10044774, Common::UNK_LANG, Common::kPlatformUnknown }, { "95818b178d473c989ac753574e8892aa", "readtime", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "95b3806e043be08668c54c3ffe98650f", "BluesABCTime", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "95be99181bd0f10fef4872c2d4a771cb", "zak", "V1", "", -1, Common::DE_DEU, Common::kPlatformC64 }, + { "9684c161258d68e0d464d6cab7024b9c", "spyfox2", "", "Mini Game", 14689, Common::IT_ITA, Common::kPlatformWindows }, { "96a3069a3c63caa7329588ce1fef41ee", "spyozon", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown }, { "9708cf716ed8bcc9ff3fcfc69413b746", "puttputt", "HE 62", "", -1, Common::EN_ANY, Common::kPlatformDOS }, { "9778341eefc6feb447ca07e7be21791c", "puttrace", "HE 99", "Demo", -1, Common::IT_ITA, Common::kPlatformWindows }, @@ -461,9 +470,11 @@ static const MD5Table md5table[] = { { "a59a438cb182124c30c4447d8ed469e9", "freddi", "HE 100", "", 34837, Common::NB_NOR, Common::kPlatformWii }, { "a5c5388da9bf0e6662fdca8813a79d13", "farm", "", "", 86962, Common::EN_ANY, Common::kPlatformWindows }, { "a654fb60c3b67d6317a7894ffd9f25c5", "pajama3", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown }, + { "a71014c53a6d18c66ef2ea0ee42328e9", "PuttTime", "HE 99", "Mini Game", 18458, Common::NL_NLD, Common::kPlatformWindows }, { "a7cacad9c40c4dc9e1812abf6c8af9d5", "puttcircus", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "a85856675429fe88051744f755b72f93", "farm", "", "", -1, Common::EN_ANY, Common::kPlatformWindows }, { "a86f9c49355579c30d4a55b477c0d869", "baseball2001", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, + { "a8fcc3084ad5e3e569722755f205b1ef", "pajama3", "", "Mini Game", 13911, Common::DE_DEU, Common::kPlatformWindows }, { "a9543ef0d79bcb47cd76ec197ad0a967", "puttmoon", "", "", -1, Common::EN_ANY, Common::kPlatform3DO }, { "a99c39ba65b6086be28aef576da69595", "spyozon", "", "Demo", -1, Common::FR_FRA, Common::kPlatformWindows }, { "a9f2f04b1ecaab9495b59befffe9bf88", "pajama3", "", "Demo", -1, Common::EN_USA, Common::kPlatformUnknown }, @@ -480,6 +491,7 @@ static const MD5Table md5table[] = { { "acad97ab1c6fc2a5b2d98abf6db4a190", "tentacle", "Floppy", "Floppy", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "ae94f110a14ce71fc515d5b648827a8f", "tentacle", "Floppy", "Floppy", -1, Common::ES_ESP, Common::kPlatformDOS }, { "aeec382acef62e122bf0d5b14581cfa4", "zak", "V1", "", -1, Common::IT_ITA, Common::kPlatformC64 }, + { "aef415cc5dc063e3668359c2657169f3", "PuttTime", "HE 99", "Mini Game", 18458, Common::DE_DEU, Common::kPlatformWindows }, { "aefa244ea034b7cd2041f0a44be7d9ba", "pajama3", "", "", -1, Common::EN_ANY, Common::kPlatformMacintosh }, { "af2bd1a43b50b55915d87994e093203d", "freddi", "HE 99", "Updated", 34829, Common::DE_DEU, Common::kPlatformWindows }, { "b100abf7ff83146df50db78dbd5e9cfa", "freddicove", "HE 100", "", -1, Common::FR_FRA, Common::kPlatformUnknown }, @@ -507,7 +519,7 @@ static const MD5Table md5table[] = { { "be83e882b44f2767bc08d4f766ebc347", "maniac", "V2", "V2", -1, Common::DE_DEU, Common::kPlatformAtariST }, { "bf8b52fdd9a69c67f34e8e9fec72661c", "farm", "HE 71", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "bfdf584b01503f0762baded581f6a0a2", "SoccerMLS", "", "", -1, Common::EN_ANY, Common::kPlatformWindows }, - { "c0039ad982999c92d0de81910d640fa0", "freddi", "HE 71", "", -1, Common::NL_NLD, Common::kPlatformWindows }, + { "c0039ad982999c92d0de81910d640fa0", "freddi", "HE 71", "", 26159, Common::NL_NLD, Common::kPlatformWindows }, { "c13225cb1bbd3bc9fe578301696d8021", "monkey", "SEGA", "", -1, Common::EN_ANY, Common::kPlatformSegaCD }, { "c20848f53c2d48bfacdc840993843765", "freddi2", "HE 80", "Demo", -1, Common::NL_NLD, Common::kPlatformUnknown }, { "c225bec1b6c0798a2b8c89ac226dc793", "pajama", "HE 101", "", -1, Common::EN_ANY, Common::kPlatformWii }, @@ -518,6 +530,7 @@ static const MD5Table md5table[] = { { "c3b22fa4654bb580b20325ebf4174841", "puttzoo", "", "", -1, Common::NL_NLD, Common::kPlatformWindows }, { "c3df37df9d3b481b45f75283a9907c47", "loom", "EGA", "EGA", -1, Common::IT_ITA, Common::kPlatformDOS }, { "c4787c3e8b5e2dfda90850ee800af00f", "zak", "V2", "V2", -1, Common::FR_FRA, Common::kPlatformDOS }, + { "c486e4cfa7bd6f8efcd0740f96f7dde3", "freddi4", "HE 99", "Mini Game", 13609, Common::FR_FRA, Common::kPlatformWindows }, { "c4ffae9fac495475d6bc3343ccc8faf9", "Soccer2004", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "c5cc7cba02a2fbd539c4439e775b0536", "puttzoo", "HE 99", "Updated", 43470, Common::DE_DEU, Common::kPlatformWindows }, { "c5d10e190d4b4d59114b824f2fdbd00e", "loom", "FM-TOWNS", "", 7540, Common::EN_ANY, Common::kPlatformFMTowns }, @@ -557,6 +570,7 @@ static const MD5Table md5table[] = { { "d06fbe28818fef7bfc45c2cdf0c0849d", "zak", "V2", "V2", -1, Common::DE_DEU, Common::kPlatformDOS }, { "d0ad929def3e9cfe39dea55bd12098d4", "puttcircus", "", "", -1, Common::FR_FRA, Common::kPlatformWindows }, { "d0b531227a27c6662018d2bd05aac52a", "monkey", "VGA", "VGA", 8357, Common::DE_DEU, Common::kPlatformDOS }, + { "d1a73e87564477c7c2dcc2b8f616ad0b", "pajama3", "", "Mini Game", 13911, Common::IT_ITA, Common::kPlatformWindows }, { "d220d154aafbfa12bd6f3ab1b2dae420", "puttzoo", "", "Demo", -1, Common::DE_DEU, Common::kPlatformMacintosh }, { "d2cc8e31bce61e6cf2951249e10638fe", "basketball", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, { "d37c55388294b66e53e7ced3af88fa68", "freddi2", "HE 100", "Updated Demo", -1, Common::EN_ANY, Common::kPlatformUnknown }, @@ -604,7 +618,7 @@ static const MD5Table md5table[] = { { "e534d29afb3c6e0ee9dc3d53c5956714", "atlantis", "Floppy", "Floppy", -1, Common::DE_DEU, Common::kPlatformAmiga }, { "e5563c8358443c4352fcddf7402a5e0a", "pajama2", "HE 98.5", "", -1, Common::FR_FRA, Common::kPlatformWindows }, { "e5c112140ad6574997de033a8e2a2964", "readtime", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown }, - { "e62056ba675ad65d8854ab3c5ad4b3c0", "spyfox2", "", "Mini Game", -1, Common::EN_ANY, Common::kPlatformWindows }, + { "e62056ba675ad65d8854ab3c5ad4b3c0", "spyfox2", "", "Mini Game", 14689, Common::EN_ANY, Common::kPlatformWindows }, { "e63a0b9249b5ca4cc4d3ac34305ae360", "freddi", "HE 99", "", -1, Common::NB_NOR, Common::kPlatformWindows }, { "e689bdf67f98b1d760ce4487ec0e8d06", "indy3", "EGA", "EGA", -1, Common::FR_FRA, Common::kPlatformAmiga }, { "e6cd81b25ab1453a8a6d3482118c391e", "pass", "", "", 7857, Common::EN_ANY, Common::kPlatformDOS }, @@ -626,7 +640,9 @@ static const MD5Table md5table[] = { { "edfdb24a499d92c59f824c52987c0eec", "atlantis", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS }, { "ee41f6afbc5b26fa475754b56fe92048", "puttputt", "HE 61", "", 8032, Common::JA_JPN, Common::kPlatform3DO }, { "ee785fe2569bc9965526e774f7ab86f1", "spyfox", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformMacintosh }, + { "ee8cfeb76e55d43a01c25e0865a9db76", "puttrace", "HE 98", "Demo", 13135, Common::NL_NLD, Common::kPlatformMacintosh }, { "eea4d9ac2fb6f145945a308e8866915b", "maniac", "C64", "", -1, Common::EN_ANY, Common::kPlatformC64 }, + { "eeb606c2d2ec877a712a9f20c10bcdda", "farm", "", "", 87034, Common::NL_NLD, Common::kPlatformMacintosh }, { "ef347474f3c7be3b29584eaa133cca05", "samnmax", "Floppy", "Floppy", -1, Common::FR_FRA, Common::kPlatformDOS }, { "ef71a322b6530ac45b1a070f7c0795f7", "moonbase", "Demo", "Demo", -1, Common::EN_ANY, Common::kPlatformWindows }, { "ef74d9071d4e564b037cb44bd6774de7", "fbear", "HE 62", "", -1, Common::HE_ISR, Common::kPlatformDOS }, @@ -651,6 +667,7 @@ static const MD5Table md5table[] = { { "fa30c4a7a806629626269b6dcab59a15", "BluesBirthday", "HE CUP", "Preview", 7819264, Common::UNK_LANG, Common::kPlatformUnknown }, { "fa3cb1541f9d7cf99ccbae6249bc150c", "maniac", "NES", "", -1, Common::IT_ITA, Common::kPlatformNES }, { "fa84cb1018103a4ee4e5fa8041c1d0d1", "freddi4", "", "Demo", 13609, Common::DE_DEU, Common::kPlatformWindows }, + { "faa89ab5e67ba4eebb4399f584f7490c", "pajama3", "", "Mini Game", 13911, Common::FR_FRA, Common::kPlatformWindows }, { "fb66aa42de21675116346213f176a366", "monkey", "VGA", "VGA", -1, Common::IT_ITA, Common::kPlatformAmiga }, { "fbb697d89d2beca87360a145f467bdae", "PuttTime", "HE 90", "Demo", -1, Common::DE_DEU, Common::kPlatformUnknown }, { "fbbbb38a81fc9d6a61d509278390a290", "farm", "", "", -1, Common::EN_ANY, Common::kPlatformMacintosh }, -- cgit v1.2.3 From be489328dd40a188094ce7371d1b5f41e4bf1f6f Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Fri, 5 Dec 2014 19:37:45 +0100 Subject: GUI: remove not used const --- gui/EventRecorder.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp index ab284aaa6e..d0371f5e78 100644 --- a/gui/EventRecorder.cpp +++ b/gui/EventRecorder.cpp @@ -49,7 +49,6 @@ namespace GUI { const int kMaxRecordsNames = 0x64; const int kDefaultScreenshotPeriod = 60000; -const int kDefaultBPP = 2; uint32 readTime(Common::ReadStream *inFile) { uint32 d = inFile->readByte(); -- cgit v1.2.3 From 9649e919e31343d8f91acafede84caa547cee678 Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Fri, 5 Dec 2014 19:45:10 +0100 Subject: GUI: use newer define for OS X 10.10+ --- gui/browser_osx.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gui/browser_osx.mm b/gui/browser_osx.mm index 0e80410032..18cbd134f3 100644 --- a/gui/browser_osx.mm +++ b/gui/browser_osx.mm @@ -154,7 +154,11 @@ int BrowserDialog::runModal() { [showHiddenFilesButton setAction:@selector(showHiddenFiles:)]; } +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1090 if ([panel runModal] == NSOKButton) { +#else + if ([panel runModal] == NSModalResponseOK) { +#endif NSURL *url = [panel URL]; if ([url isFileURL]) { const char *filename = [[url path] UTF8String]; -- cgit v1.2.3 From d8af639dfcbdae3c99f72c4c4ec4f07410d5915c Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 6 Dec 2014 11:11:32 +0100 Subject: BUILD: sync config.guess and config.sub from GNU --- config.guess | 364 ++++++++++++++++++++++------------------------------------- config.sub | 158 ++++++++++++++++---------- 2 files changed, 232 insertions(+), 290 deletions(-) diff --git a/config.guess b/config.guess index 43f0cdbcfd..6c32c8645c 100755 --- a/config.guess +++ b/config.guess @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011 Free Software Foundation, Inc. +# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2011-10-01' +timestamp='2014-11-04' # This file 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 +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -17,26 +15,22 @@ timestamp='2011-10-01' # 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. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to . + me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,9 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -140,12 +132,33 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -202,6 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -304,7 +321,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -562,8 +579,9 @@ EOF else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi @@ -803,9 +821,15 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 @@ -851,15 +875,22 @@ EOF exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -871,59 +902,54 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-unknown-linux-gnueabihf + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) - echo hexagon-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build @@ -942,54 +968,63 @@ EOF #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1193,6 +1228,9 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1219,19 +1257,31 @@ EOF exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) @@ -1248,7 +1298,7 @@ EOF NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; - NSE-?:NONSTOP_KERNEL:*:*) + NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) @@ -1317,158 +1367,10 @@ EOF i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; -esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi +esac cat >&2 <. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -75,9 +68,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free -Software Foundation, Inc. +Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -125,13 +116,17 @@ esac maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] @@ -154,7 +149,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; @@ -223,6 +218,12 @@ case $os in -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; -lynx*) os=-lynxos ;; @@ -247,13 +248,16 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ @@ -261,10 +265,11 @@ case $basic_machine in | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -278,24 +283,27 @@ case $basic_machine in | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ - | nios | nios2 \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | open8 \ - | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | rx \ + | riscv32 | riscv64 \ + | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ @@ -305,6 +313,7 @@ case $basic_machine in | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -319,8 +328,10 @@ case $basic_machine in c6x) basic_machine=tic6x-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -333,7 +344,10 @@ case $basic_machine in strongarm | thumb | xscale) basic_machine=arm-unknown ;; - + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; xscaleeb) basic_machine=armeb-unknown ;; @@ -356,15 +370,16 @@ case $basic_machine in # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ @@ -373,11 +388,13 @@ case $basic_machine in | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -391,23 +408,27 @@ case $basic_machine in | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ @@ -420,6 +441,7 @@ case $basic_machine in | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -719,7 +741,6 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -758,6 +779,9 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux @@ -777,11 +801,15 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze*) basic_machine=microblaze-xilinx ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -809,6 +837,10 @@ case $basic_machine in basic_machine=powerpc-unknown os=-morphos ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; msdos) basic_machine=i386-pc os=-msdos @@ -816,6 +848,10 @@ case $basic_machine in ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i686-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -1004,7 +1040,11 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -1331,29 +1371,29 @@ case $os in -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ + | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-android* \ - | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1477,9 +1517,6 @@ case $os in -aros*) os=-aros ;; - -kaos*) - os=-kaos - ;; -zvmoe) os=-zvmoe ;; @@ -1528,6 +1565,12 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; tic54x-*) os=-coff ;; @@ -1555,9 +1598,6 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout -- cgit v1.2.3 From c9e6db6571bd1c69d1a08bcc7d371cc68c3b53a0 Mon Sep 17 00:00:00 2001 From: Kirben Date: Sun, 7 Dec 2014 15:24:21 +1100 Subject: SCUMM: Correct spacing and warning in last Maniac V0 merge. --- engines/scumm/actor.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 90ee5bf368..59a1009789 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -415,7 +415,7 @@ bool Actor_v0::calcWalkDistances() { _walkYCountGreaterThanXCount = 0; uint16 A = 0; - if (_CurrentWalkTo.x >= _tmp_Dest.x ) { + if (_CurrentWalkTo.x >= _tmp_Dest.x) { A = _CurrentWalkTo.x - _tmp_Dest.x; _walkDirX = 1; } else { @@ -424,7 +424,7 @@ bool Actor_v0::calcWalkDistances() { _walkXCountInc = A; - if (_CurrentWalkTo.y >= _tmp_Dest.y ) { + if (_CurrentWalkTo.y >= _tmp_Dest.y) { A = _CurrentWalkTo.y - _tmp_Dest.y; _walkDirY = 1; } else { @@ -432,15 +432,15 @@ bool Actor_v0::calcWalkDistances() { } _walkYCountInc = A; - if ( !_walkXCountInc && !_walkYCountInc ) + if (!_walkXCountInc && !_walkYCountInc) return true; - if( _walkXCountInc <= _walkYCountInc ) + if (_walkXCountInc <= _walkYCountInc) _walkYCountGreaterThanXCount = 1; // 2FCC A = _walkXCountInc; - if( A <= _walkYCountInc ) + if (A <= _walkYCountInc) A = _walkYCountInc; _walkMaxXYCountInc = A; @@ -455,7 +455,7 @@ byte Actor_v0::actorWalkX() { byte A = _walkXCount; A += _walkXCountInc; if (A >= _walkCountModulo) { - if (!_walkDirX ) { + if (!_walkDirX) { _tmp_Dest.x--; } else { _tmp_Dest.x++; @@ -483,7 +483,7 @@ byte Actor_v0::actorWalkY() { byte A = _walkYCount; A += _walkYCountInc; if (A >= _walkCountModulo) { - if (!_walkDirY ) { + if (!_walkDirY) { _tmp_Dest.y--; } else { _tmp_Dest.y++; @@ -568,7 +568,7 @@ void Actor::startWalkActor(int destX, int destY, int dir) { _walkdata.point3.x = 32000; _walkdata.curbox = _walkbox; - if(_vm->_game.version == 0 ) { + if (_vm->_game.version == 0) { ((Actor_v0*)this)->_newWalkBoxEntered = true; } else { _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; @@ -751,7 +751,7 @@ L2A33:; animateActor(newDirToOldDir(_facing)); } - if ((_moving & 0x0F) == 3 ) { + if ((_moving & 0x0F) == 3) { L2C36:; setTmpFromActor(); @@ -812,7 +812,7 @@ L2CA3:; if (updateWalkbox() == kInvalidBox) { // 2CC7 setActorFromTmp(); - if( _CurrentWalkTo.x == _tmp_Dest.x) { + if (_CurrentWalkTo.x == _tmp_Dest.x) { stopActorMoving(); return; } @@ -1210,7 +1210,7 @@ void Actor::setDirection(int direction) { } void Actor_v0::setDirection(int direction) { - int dir = newDirToOldDir( direction ); + int dir = newDirToOldDir(direction); int res = 0; switch (dir) { @@ -1255,8 +1255,8 @@ void Actor::turnToDirection(int newdir) { if (_vm->_game.version <= 6) { _targetFacing = newdir; - if (_vm->_game.version == 0 ) { - setDirection( newdir ); + if (_vm->_game.version == 0) { + setDirection(newdir); return; } _moving = MF_TURN; @@ -1456,7 +1456,7 @@ AdjustBoxResult Actor_v0::adjustPosInBorderWalkbox(AdjustBoxResult box) { if (!(boxMask & 0x80)) return Result; - char A; + byte A; boxMask &= 0x7C; if (boxMask == 0x0C) A = 2; @@ -1495,7 +1495,7 @@ AdjustBoxResult Actor_v0::adjustPosInBorderWalkbox(AdjustBoxResult box) { AdjustBoxResult Actor_v0::adjustXYToBeInBox(int dstX, int dstY) { AdjustBoxResult Result = Actor_v2::adjustXYToBeInBox(dstX, dstY); - if( Result.box == kInvalidBox ) + if (Result.box == kInvalidBox) return Result; return adjustPosInBorderWalkbox(Result); @@ -3209,12 +3209,12 @@ void Actor_v0::animateActor(int anim) { } byte Actor_v0::updateWalkbox() { - if( _vm->checkXYInBoxBounds( _walkbox, _pos.x, _pos.y ) ) + if (_vm->checkXYInBoxBounds(_walkbox, _pos.x, _pos.y)) return 0; int numBoxes = _vm->getNumBoxes() - 1; for (int i = 0; i <= numBoxes; i++) { - if (_vm->checkXYInBoxBounds( i, _pos.x, _pos.y ) == true ) { + if (_vm->checkXYInBoxBounds(i, _pos.x, _pos.y) == true) { if (_walkdata.curbox == i) { setBox(i); directionUpdate(); -- cgit v1.2.3 From 6ec077e1b9f766da0a74bfb85b4ee2cc891cb348 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 14:37:51 +0200 Subject: AGI: Set the correct palette to use for each Amiga game The Amiga palettes were added in 16529e58e6, but were never used. A new game-specific option has been added for the old Amiga palette --- engines/agi/agi.cpp | 1 + engines/agi/detection.cpp | 9 +++++++++ engines/agi/graphics.cpp | 21 ++++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 6bdbabd33e..73233d4f4c 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -500,6 +500,7 @@ static const GameSettings agiSettings[] = { AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { // Assign default values to the config manager, in case settings are missing ConfMan.registerDefault("originalsaveload", "false"); + ConfMan.registerDefault("altamigapalette", "false"); _noSaveLoadAllowed = false; diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 1d58900056..e7285d8112 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -145,6 +145,13 @@ static const ExtraGuiOption agiExtraGuiOption = { false }; +static const ExtraGuiOption agiExtraGuiOptionAmiga = { + _s("Use an alternative palette"), + _s("Use an alternative palette, common for all Amiga games. This was the old behavior"), + "altamigapalette", + false +}; + #include "agi/detection_tables.h" using namespace Agi; @@ -230,6 +237,8 @@ bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD const ExtraGuiOptions AgiMetaEngine::getExtraGuiOptions(const Common::String &target) const { ExtraGuiOptions options; options.push_back(agiExtraGuiOption); + if (target.contains("-amiga")) + options.push_back(agiExtraGuiOptionAmiga); return options; } diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 34651c70b2..317e747cdd 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -20,6 +20,7 @@ * */ +#include "common/config-manager.h" #include "common/file.h" #include "common/textconsole.h" @@ -220,7 +221,7 @@ static const uint8 amigaAgiPaletteV3[16 * 3] = { /** * 16 color amiga-ish palette. */ -static const uint8 newPalette[16 * 3] = { +static const uint8 altAmigaPalette[16 * 3] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x2A, 0x00, @@ -1030,8 +1031,22 @@ int GfxMgr::initVideo() { initPalette(vgaPalette, 256, 8); else if (_vm->_renderMode == Common::kRenderEGA) initPalette(egaPalette); - else - initPalette(newPalette); + else if (_vm->_renderMode == Common::kRenderAmiga) { + if (!ConfMan.getBool("altamigapalette")) { + // Set the correct Amiga palette + if (_vm->getVersion() < 0x2936) + // TODO: This palette isn't used for Apple IIGS games yet, as + // we don't set a separate render mode for them yet + initPalette(amigaAgiPaletteV1, 16, 4); + else if (_vm->getVersion() == 0x2936) + initPalette(amigaAgiPaletteV2, 16, 4); + else if (_vm->getVersion() > 0x2936) + initPalette(amigaAgiPaletteV3, 16, 4); + } else + // Set the old common alternative Amiga palette + initPalette(altAmigaPalette); + } else + error("initVideo: Unhandled render mode"); if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL) return errNotEnoughMemory; -- cgit v1.2.3 From b3e45ccc6854c93e73fcda0f9daa67ffad76a3a1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 14:40:21 +0200 Subject: AGI: Disable/remove unused code This is code that isn't used currently. Thanks to fingolfin for pointing out these parts of the code --- engines/agi/agi.cpp | 5 ----- engines/agi/graphics.cpp | 2 ++ engines/agi/preagi_mickey.cpp | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 73233d4f4c..1e663ec29a 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -492,11 +492,6 @@ struct GameSettings { const char *detectname; }; -static const GameSettings agiSettings[] = { - {"agi", "AGI game", GID_AGI, MDT_ADLIB, "OBJECT"}, - {NULL, NULL, 0, 0, NULL} -}; - AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { // Assign default values to the config manager, in case settings are missing ConfMan.registerDefault("originalsaveload", "false"); diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 317e747cdd..2b1bd8c829 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -905,6 +905,7 @@ static const byte sciMouseCursor[] = { 0,0,0,0,0,0,1,2,2,1,0 }; +#if 0 /** * A black and white Apple IIGS style arrow cursor (9x11). * 0 = Transparent. @@ -924,6 +925,7 @@ static const byte appleIIgsMouseCursor[] = { 2,2,2,0,2,1,1,2,0, 0,0,0,0,0,2,2,2,0 }; +#endif /** * RGB-palette for the black and white SCI and Apple IIGS arrow cursors. diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp index 4ca8d00824..a1572d7f1f 100644 --- a/engines/agi/preagi_mickey.cpp +++ b/engines/agi/preagi_mickey.cpp @@ -892,6 +892,7 @@ void MickeyEngine::drawRoom() { drawRoomAnimation(); } +#if 0 const uint8 colorBCG[16][2] = { { 0x00, 0x00 }, // 0 (black, black) { 0, 0 }, @@ -910,6 +911,7 @@ const uint8 colorBCG[16][2] = { { 0, 0 }, { 0xFF, 0xFF } // F (white, white) }; +#endif void MickeyEngine::drawLogo() { // TODO: clean this up and make it work properly, the logo is drawn way off to the right -- cgit v1.2.3 From 815851e959bb46b2b9fd0de7ff9d04c9097d6908 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 15:39:11 +0200 Subject: MADS: Remove unused reference to MADSEngine Thanks to fingolfin for finding out the unused reference --- engines/mads/msurface.h | 4 +--- engines/mads/scene.cpp | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h index ebfb1f437a..650d7fdaee 100644 --- a/engines/mads/msurface.h +++ b/engines/mads/msurface.h @@ -223,8 +223,6 @@ public: }; class DepthSurface : public MSurface { -private: - MADSEngine *_vm; public: /** * Depth style @@ -234,7 +232,7 @@ public: /** * Constructor */ - DepthSurface(MADSEngine *vm) : _vm(vm), _depthStyle(0) {} + DepthSurface() : _depthStyle(0) {} /** * Returns the depth at a given position diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp index 18ceb3c813..d2b4b29622 100644 --- a/engines/mads/scene.cpp +++ b/engines/mads/scene.cpp @@ -31,7 +31,7 @@ namespace MADS { Scene::Scene(MADSEngine *vm) - : _vm(vm), _action(_vm), _depthSurface(vm), + : _vm(vm), _action(_vm), _depthSurface(), _dirtyAreas(_vm), _dynamicHotspots(vm), _hotspots(vm), _kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), _textDisplay(vm), _userInterface(vm) { @@ -182,7 +182,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) { flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY; _animationData = Animation::init(_vm, this); - DepthSurface depthSurface(_vm); + DepthSurface depthSurface; _animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr); _vm->_palette->_paletteUsage.load(&_scenePaletteUsage); @@ -611,7 +611,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger) { if (_activeAnimation) freeAnimation(); - DepthSurface depthSurface(_vm); + DepthSurface depthSurface; UserInterface interfaceSurface(_vm); _activeAnimation = Animation::init(_vm, this); -- cgit v1.2.3 From 2325183751e14a50b59f4a9cf5950396f52fed2a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 15:45:43 +0200 Subject: NEVERHOOD: Remove duplicate defines These have been left behind after the split of the scenes and the scene sprites. Thanks to fingolfin for pointing out the duplicate defines --- engines/neverhood/modules/module2700_sprites.cpp | 56 ------------------------ engines/neverhood/modules/module2800.cpp | 15 ------- engines/neverhood/modules/module2800_sprites.cpp | 10 ----- engines/neverhood/modules/module3000.cpp | 12 ----- engines/neverhood/modules/module3000_sprites.cpp | 36 --------------- 5 files changed, 129 deletions(-) diff --git a/engines/neverhood/modules/module2700_sprites.cpp b/engines/neverhood/modules/module2700_sprites.cpp index e17cddc834..079e0b7afe 100644 --- a/engines/neverhood/modules/module2700_sprites.cpp +++ b/engines/neverhood/modules/module2700_sprites.cpp @@ -24,62 +24,6 @@ namespace Neverhood { -static const NRect kScene2710ClipRect = { 0, 0, 626, 480 }; - -static const uint32 kScene2710StaticSprites[] = { - 0x0D2016C0, - 0 -}; - -static const NRect kScene2711ClipRect = { 0, 0, 521, 480 }; - -static const uint32 kScene2711FileHashes1[] = { - 0, - 0x100801A1, - 0x201081A0, - 0x006800A4, - 0x40390120, - 0x000001B1, - 0x001000A1, - 0 -}; - -static const uint32 kScene2711FileHashes2[] = { - 0, - 0x40403308, - 0x71403168, - 0x80423928, - 0x224131A8, - 0x50401328, - 0x70423328, - 0 -}; - -static const uint32 kScene2711FileHashes3[] = { - 0, - 0x1088A021, - 0x108120E5, - 0x18A02321, - 0x148221A9, - 0x10082061, - 0x188820E1, - 0 -}; - -static const NRect kScene2724ClipRect = { 0, 141, 640, 480 }; - -static const uint32 kScene2724StaticSprites[] = { - 0xC20D00A5, - 0 -}; - -static const NRect kScene2725ClipRect = { 0, 0, 640, 413 }; - -static const uint32 kScene2725StaticSprites[] = { - 0xC20E00A5, - 0 -}; - static const NPoint kCarShadowOffsets[] = { {-63, 3}, {-48, 40}, {-33, 58}, { 0, 65}, { 40, 53}, { 56, 27}, diff --git a/engines/neverhood/modules/module2800.cpp b/engines/neverhood/modules/module2800.cpp index a59c3f8156..ab22390c7d 100644 --- a/engines/neverhood/modules/module2800.cpp +++ b/engines/neverhood/modules/module2800.cpp @@ -1477,21 +1477,6 @@ static const uint32 kScene2808FileHashes2[] = { 0xB0196098 }; -static const uint32 kClass428FileHashes[] = { - 0x140022CA, - 0x4C30A602, - 0xB1633402, - 0x12982135, - 0x0540B728, - 0x002A81E3, - 0x08982841, - 0x10982841, - 0x20982841, - 0x40982841, - 0x80982841, - 0x40800711 -}; - Scene2808::Scene2808(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _countdown(0), _testTubeSetNum(which), _leaveResult(0), _isFlowing(false) { diff --git a/engines/neverhood/modules/module2800_sprites.cpp b/engines/neverhood/modules/module2800_sprites.cpp index f9a58de92d..ad814d2b5b 100644 --- a/engines/neverhood/modules/module2800_sprites.cpp +++ b/engines/neverhood/modules/module2800_sprites.cpp @@ -574,16 +574,6 @@ uint32 AsScene2806Spew::handleMessage(int messageNum, const MessageParam ¶m, return messageResult; } -static const uint32 kScene2808FileHashes1[] = { - 0x90B0392, - 0x90B0192 -}; - -static const uint32 kScene2808FileHashes2[] = { - 0xB0396098, - 0xB0196098 -}; - static const uint32 kClass428FileHashes[] = { 0x140022CA, 0x4C30A602, diff --git a/engines/neverhood/modules/module3000.cpp b/engines/neverhood/modules/module3000.cpp index d4809611ad..0f84dbd18d 100644 --- a/engines/neverhood/modules/module3000.cpp +++ b/engines/neverhood/modules/module3000.cpp @@ -666,18 +666,6 @@ static const uint32 kScene3010ButtonNameHashes[] = { 0x01180951 }; -static const uint32 kScene3010DeadBoltButtonFileHashes1[] = { - 0x301024C2, - 0x20280580, - 0x30200452 -}; - -static const uint32 kScene3010DeadBoltButtonFileHashes2[] = { - 0x50C025A8, - 0x1020A0A0, - 0x5000A7E8 -}; - Scene3010::Scene3010(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _countdown(0), _doorUnlocked(false), _checkUnlocked(false) { diff --git a/engines/neverhood/modules/module3000_sprites.cpp b/engines/neverhood/modules/module3000_sprites.cpp index 3f883eaa72..23a388efe4 100644 --- a/engines/neverhood/modules/module3000_sprites.cpp +++ b/engines/neverhood/modules/module3000_sprites.cpp @@ -46,42 +46,6 @@ enum { kCTSCount = 14 }; -static const uint32 kScene3009CannonScopeVideos[] = { - 0x1010000D, - 0x340A0049, - 0x340A0049, - 0x0282081D, - 0x0082080D, - 0x0882080D, - 0x0882080D, - 0x0282081D, - 0x004B000B, - 0x014B000B, - 0x044B000B, - 0x0282081D, - 0x0282081D, - 0x0282081D, - 0x340A0049 -}; - -static const uint32 kScene3009CannonActionVideos[] = { - 0x00000000, - 0x8004001B, // 1 Fire cannon at wall, it breaks (lowered) - 0x0004001A, // 2 Fire cannon at wall, nothing happens (lowered) - 0x1048404B, // 3 Fire cannon at emptyness (raised) - 0x50200109, // 4 Fire cannon, robot missed (raised) - 0x12032109, // 5 Fire cannon, robot hit (raised) - 0x10201109, // 6 Fire cannon, no robot (raised) - 0x000A2030, // 7 Raise the cannon - 0x000A0028, // 8 - 0x000A0028, // 9 - 0x000A0028, // 10 - 0x040A1069, // 11 - 0x040A1069, // 12 - 0x040A1069, // 13 - 0x240A1101 // 14 Lower the cannon -}; - static const uint32 kSsScene3009SymbolEdgesFileHashes[] = { 0x618827A0, 0xB1A92322 -- cgit v1.2.3 From 0e763f6aa209613cbbbb4d4e3e2c1b8938c4f865 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 15:46:08 +0200 Subject: NEVERHOOD: Remove duplicate file hash definition --- engines/neverhood/modules/module2400.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/engines/neverhood/modules/module2400.cpp b/engines/neverhood/modules/module2400.cpp index 3acb952db9..4bfc10abbf 100644 --- a/engines/neverhood/modules/module2400.cpp +++ b/engines/neverhood/modules/module2400.cpp @@ -168,11 +168,6 @@ static const uint32 kScene2401FileHashes2[] = { 0xD0910068, 0xD09100A8, 0 }; -static const uint32 kScene2401FileHashes3[] = { - 0xD0910020, 0xD0910038, 0xD0910008, - 0xD0910068, 0xD09100A8, 0 -}; - static const NRect kScene2401Rects[] = { { 369, 331, 394, 389 }, { 395, 331, 419, 389 }, @@ -264,11 +259,11 @@ void Scene2401::update() { } else if (_pipeStatus >= 5) { _ssWaterPipes[_pipeStatus]->setVisible(true); _countdown1 = 8; - playPipeSound(kScene2401FileHashes3[getSubVar(VA_CURR_WATER_PIPES_LEVEL, _pipeStatus - 5)]); + playPipeSound(kScene2401FileHashes2[getSubVar(VA_CURR_WATER_PIPES_LEVEL, _pipeStatus - 5)]); } else { _ssWaterPipes[_pipeStatus]->setVisible(true); _countdown1 = _pipeStatus == 4 ? 16 : 8; - playPipeSound(kScene2401FileHashes3[getSubVar(VA_GOOD_WATER_PIPES_LEVEL, _pipeStatus)]); + playPipeSound(kScene2401FileHashes2[getSubVar(VA_GOOD_WATER_PIPES_LEVEL, _pipeStatus)]); } _pipeStatus++; } -- cgit v1.2.3 From ce40801f5b80aaf8786b7ac790588bd83250372b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 15:48:11 +0200 Subject: MOHAWK: Comment out unused constant Thanks to fingolfin for finding this unused code --- engines/mohawk/riven_external.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/mohawk/riven_external.cpp b/engines/mohawk/riven_external.cpp index 3d0bccc47f..cda0683028 100644 --- a/engines/mohawk/riven_external.cpp +++ b/engines/mohawk/riven_external.cpp @@ -2513,7 +2513,7 @@ void RivenExternal::xthideinventory(uint16 argc, uint16 *argv) { static const uint32 kMarbleCount = 6; static const int kSmallMarbleWidth = 4; static const int kSmallMarbleHeight = 2; -static const int kLargeMarbleSize = 8; +//static const int kLargeMarbleSize = 8; static const int kMarbleHotspotSize = 13; static const char *s_marbleNames[] = { "tred", "torange", "tyellow", "tgreen", "tblue", "tviolet" }; -- cgit v1.2.3 From fa9e2f7b29a487d0bcfc697b3f4a71c9387fe7ba Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 17:38:16 +0200 Subject: SWORD25: Disable unused code Thanks to fingolfin for pointing out this unused code --- engines/sword25/sword25.cpp | 1 - engines/sword25/util/lua/lapi.cpp | 3 ++- engines/sword25/util/lua/liolib.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp index bb0aab3ad4..76142c2534 100644 --- a/engines/sword25/sword25.cpp +++ b/engines/sword25/sword25.cpp @@ -57,7 +57,6 @@ DECLARE_SINGLETON(Sword25::RenderObjectRegistry); namespace Sword25 { -const char *const PACKAGE_MANAGER = "archiveFS"; const char *const DEFAULT_SCRIPT_FILE = "/system/boot.lua"; Sword25Engine::Sword25Engine(OSystem *syst, const ADGameDescription *gameDesc): diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp index b97e90012c..d7ebdcbe12 100644 --- a/engines/sword25/util/lua/lapi.cpp +++ b/engines/sword25/util/lua/lapi.cpp @@ -30,11 +30,12 @@ #include "common/textconsole.h" +#if 0 const char lua_ident[] = "Lua: " LUA_RELEASE " " LUA_COPYRIGHT " \n" "Authors: " LUA_AUTHORS " \n" "URL: www.lua.org\n"; - +#endif #define api_checknelems(L, n) api_check(L, (n) <= (L->top - L->base)) diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp index 0d27f9677f..403dea2ec2 100644 --- a/engines/sword25/util/lua/liolib.cpp +++ b/engines/sword25/util/lua/liolib.cpp @@ -24,7 +24,7 @@ #define IO_OUTPUT 2 -static const char *const fnames[] = {"input", "output"}; +//static const char *const fnames[] = {"input", "output"}; static int pushresult (lua_State *L, int i, const char *filename) { -- cgit v1.2.3 From bb120d0fd4f6b32f9b9d76d9d3b334eef58cbfb8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 17:42:49 +0200 Subject: COMMON: Disable unused string --- common/unzip.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/unzip.cpp b/common/unzip.cpp index 716c8c2d5e..1f4e601989 100644 --- a/common/unzip.cpp +++ b/common/unzip.cpp @@ -334,8 +334,10 @@ int unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len); #define SIZEZIPLOCALHEADER (0x1e) +#if 0 const char unz_copyright[] = " unzip 0.15 Copyright 1998 Gilles Vollant "; +#endif /* unz_file_info_interntal contain internal info about a file in zipfile*/ typedef struct { -- cgit v1.2.3 From f2511e5a9ecfebdf5c03319acb9466e070fa3d06 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 7 Dec 2014 17:43:49 +0200 Subject: IMAGE: Disable unused MJPEG array Thanks to fingolfin for pointing that out --- image/codecs/mjpeg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/image/codecs/mjpeg.cpp b/image/codecs/mjpeg.cpp index 4ad72f259d..6e7faf1045 100644 --- a/image/codecs/mjpeg.cpp +++ b/image/codecs/mjpeg.cpp @@ -87,9 +87,11 @@ static const byte s_mjpegValDC[12] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; +#if 0 static const byte s_mjpegBitsDCChrominance[17] = { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; +#endif static const byte s_mjpegBitsACLuminance[17] = { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d -- cgit v1.2.3 From ec1fdeb25ad6b2d9aae69a544f45eb7fc5e189b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:08:27 +0200 Subject: ZVISION: Implement several advanced engine features and ScummVM dialogs The functionality to return to launcher, list saves, delete saves, load games from the launcher and load and save games during runtime has been implemented. Also, ScummVM save/load dialogs have been implemented. Saved games now have three numbers in their file extension, bumping the possible save game slots up to 999 --- engines/zvision/core/save_manager.cpp | 40 +++++++++++++++++- engines/zvision/core/save_manager.h | 1 + engines/zvision/detection.cpp | 61 +++++++++++++++++++--------- engines/zvision/scripting/script_manager.cpp | 23 +++++++++++ engines/zvision/video/video.cpp | 2 + engines/zvision/zvision.cpp | 9 +++- engines/zvision/zvision.h | 8 ++++ 7 files changed, 121 insertions(+), 23 deletions(-) diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 11d3dd391a..20bd39fde5 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -23,22 +23,60 @@ #include "common/scummsys.h" #include "zvision/core/save_manager.h" - #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "common/system.h" +#include "common/translation.h" #include "graphics/surface.h" #include "graphics/thumbnail.h" #include "gui/message.h" +#include "gui/saveload.h" namespace ZVision { const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); +bool SaveManager::scummVMSaveLoadDialog(bool isSave) { + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + if (isSave) { + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + slot = dialog->runModalWithCurrentTarget(); + desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didnt enter it + desc = dialog->createDefaultSaveDescription(slot); + } + + if (desc.size() > 28) + desc = Common::String(desc.c_str(), 28); + } else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return false; + + if (isSave) { + saveGame(slot, desc); + return true; + } else { + Common::ErrorCode result = loadGame(slot).getCode(); + return (result == Common::kNoError); + } +} + void SaveManager::saveGame(uint slot, const Common::String &saveName) { // The games only support 20 slots //assert(slot <= 1 && slot <= 20); diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h index 5cd61c7aa9..75841331e7 100644 --- a/engines/zvision/core/save_manager.h +++ b/engines/zvision/core/save_manager.h @@ -96,6 +96,7 @@ public: void prepareSaveBuffer(); void flushSaveBuffer(); + bool scummVMSaveLoadDialog(bool isSave); private: void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); }; diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 4d210abe86..a60ef6040d 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -26,6 +26,8 @@ #include "zvision/zvision.h" #include "zvision/detection.h" +#include "zvision/core/save_manager.h" +#include "zvision/scripting/script_manager.h" #include "common/translation.h" #include "common/savefile.h" @@ -178,24 +180,40 @@ public: }; bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; - /* + return (f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail) || - (f == kSavesSupportCreationDate) || - (f == kSavesSupportPlayTime); - */ + (f == kSupportsDeleteSave); + //(f == kSavesSupportMetaInfo) || + //(f == kSavesSupportThumbnail) || + //(f == kSavesSupportCreationDate) || + //(f == kSavesSupportPlayTime); } -/*bool ZVision::ZVision::hasFeature(EngineFeature f) const { +bool ZVision::ZVision::hasFeature(EngineFeature f) const { return (f == kSupportsRTL) || (f == kSupportsLoadingDuringRuntime) || (f == kSupportsSavingDuringRuntime); -}*/ +} + +Common::Error ZVision::ZVision::loadGameState(int slot) { + return _saveManager->loadGame(slot); +} + +Common::Error ZVision::ZVision::saveGameState(int slot, const Common::String &desc) { + _saveManager->saveGame(slot, desc); + return Common::kNoError; +} + +bool ZVision::ZVision::canLoadGameStateCurrently() { + return !_videoIsPlaying; +} + +bool ZVision::ZVision::canSaveGameStateCurrently() { + Location currentLocation = _scriptManager->getCurrentLocation(); + return !_videoIsPlaying && currentLocation.world != 'g' && !(currentLocation.room == 'j' || currentLocation.room == 'a'); +} bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc; @@ -213,8 +231,8 @@ const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String } SaveStateList ZVisionMetaEngine::listSaves(const char *target) const { - //Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - /*ZVision::ZVision::SaveHeader header; + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + ZVision::SaveGameHeader header; Common::String pattern = target; pattern += ".???"; @@ -223,20 +241,25 @@ SaveStateList ZVisionMetaEngine::listSaves(const char *target) const { Common::sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)*/ SaveStateList saveList; - /* for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) { + // We only use readSaveGameHeader() here, which doesn't need an engine callback + ZVision::SaveManager *zvisionSaveMan = new ZVision::SaveManager(NULL); + + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) { // Obtain the last 3 digits of the filename, since they correspond to the save slot int slotNum = atoi(file->c_str() + file->size() - 3); if (slotNum >= 0 && slotNum <= 999) { Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str()); if (in) { - if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) { - saveList.push_back(SaveStateDescriptor(slotNum, header.description)); + if (zvisionSaveMan->readSaveGameHeader(in, header)) { + saveList.push_back(SaveStateDescriptor(slotNum, header.saveName)); } delete in; } } - }*/ + } + + delete zvisionSaveMan; return saveList; } @@ -246,9 +269,8 @@ int ZVisionMetaEngine::getMaximumSaveSlot() const { } void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const { - /* Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); - Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot); + Common::String filename = Common::String::format("%s.%03u", target, slot); saveFileMan->removeSavefile(filename.c_str()); @@ -265,10 +287,9 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const { // Rename every slot greater than the deleted slot, if (slotNum > slot) { saveFileMan->renameSavefile(file->c_str(), filename.c_str()); - filename = ZVision::ZVision::getSavegameFilename(target, ++slot); + filename = Common::String::format("%s.%03u", target, ++slot); } } - */ } SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 7904817156..c532a2b15d 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -36,6 +36,7 @@ #include "common/hashmap.h" #include "common/debug.h" #include "common/stream.h" +#include "common/config-manager.h" namespace ZVision { @@ -521,6 +522,28 @@ void ScriptManager::ChangeLocationReal() { assert(_nextLocation.world != 0); debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset); + if (_nextLocation.world == 'g' && _nextLocation.room == 'j' && !ConfMan.getBool("originalsaveload")) { + if ((_nextLocation.node == 's' || _nextLocation.node == 'r') && _nextLocation.view == 'e') { + // Hook up the ScummVM save/restore dialog + bool isSave = (_nextLocation.node == 's'); + bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSave); + if (!gameSavedOrLoaded || isSave) { + // Reload the current room + _nextLocation.world = _currentLocation.world; + _nextLocation.room = _currentLocation.room; + _nextLocation.node = _currentLocation.node; + _nextLocation.view = _currentLocation.view; + _nextLocation.offset = _currentLocation.offset; + _currentLocation.world = '0'; + _currentLocation.room = '0'; + _currentLocation.node = '0'; + _currentLocation.view = '0'; + _currentLocation.offset = 0; + } else + return; + } + } + _engine->setRenderDelay(2); if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') { diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 36b5f9b921..db6161bf0c 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -53,6 +53,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, _clock.stop(); vid.start(); + _videoIsPlaying = true; // Only continue while the video is still playing while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) { @@ -99,6 +100,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, _system->delayMillis(vid.getTimeToNextFrame() / 2); } + _videoIsPlaying = false; _clock.start(); if (scaled) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index af9d26a350..8a44ccebea 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -96,7 +96,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _audioId(0), _rendDelay(2), _kbdVelocity(0), - _mouseVelocity(0) { + _mouseVelocity(0), + _videoIsPlaying(false) { debug(1, "ZVision::ZVision"); @@ -205,6 +206,10 @@ void ZVision::initialize() { Common::Error ZVision::run() { initialize(); + // Check if a saved game is to be loaded from the launcher + if (ConfMan.hasKey("save_slot")) + _saveManager->loadGame(ConfMan.getInt("save_slot")); + // Main loop while (!shouldQuit()) { _clock.update(); @@ -327,7 +332,7 @@ void ZVision::pauseEngineIntern(bool pause) { } Common::String ZVision::generateSaveFileName(uint slot) { - return Common::String::format("%s.%02u", _targetName.c_str(), slot); + return Common::String::format("%s.%03u", _targetName.c_str(), slot); } Common::String ZVision::generateAutoSaveFileName() { diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index ca6c8e10e4..5850bf66cd 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -124,6 +124,7 @@ private: int16 _mouseVelocity; int16 _kbdVelocity; bool _halveDelay; + bool _videoIsPlaying; uint8 _cheatBuff[KEYBUF_SIZE]; public: @@ -198,6 +199,13 @@ public: void checkBorders(); void showDebugMsg(const Common::String &msg, int16 delay = 3000); + + // Engine features + bool hasFeature(EngineFeature f) const; + bool canLoadGameStateCurrently(); + bool canSaveGameStateCurrently(); + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const Common::String &desc); private: void initialize(); void initFonts(); -- cgit v1.2.3 From 9ebfa3e4f93bd3af0b8170bbb718e4e9a120e776 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:09:04 +0200 Subject: ZVISION: Add some spacing --- engines/zvision/utility/clock.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/utility/clock.h b/engines/zvision/utility/clock.h index 9a50116a8c..cbf52be560 100644 --- a/engines/zvision/utility/clock.h +++ b/engines/zvision/utility/clock.h @@ -47,6 +47,7 @@ public: * when the last update() was called. */ void update(); + /** * Get the delta time since the last frame. (The time between update() calls) * @@ -55,6 +56,7 @@ public: uint32 getDeltaTime() const { return _deltaTime; } + /** * Get the time from the program starting to the last update() call * @@ -69,6 +71,7 @@ public: * Has no effect if the clock is already paused. */ void start(); + /** * Un-pause the clock. * Has no effect if the clock is already un-paused. -- cgit v1.2.3 From a2eaf78255d6a92f8d93e2a3e8907f60c2e6e699 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:09:27 +0200 Subject: ZVISION: Remove unused code --- engines/zvision/utility/utility.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp index 2388fe826e..e09545a90d 100644 --- a/engines/zvision/utility/utility.cpp +++ b/engines/zvision/utility/utility.cpp @@ -42,19 +42,4 @@ void trimCommentsAndWhiteSpace(Common::String *string) { string->trim(); } -void tryToDumpLine(const Common::String &key, - Common::String &line, - Common::HashMap *count, - Common::HashMap *fileAlreadyUsed, - Common::DumpFile &output) { - const byte numberOfExamplesPerType = 8; - - if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) { - output.writeString(line); - output.writeByte('\n'); - (*count)[key]++; - (*fileAlreadyUsed)[key] = true; - } -} - } // End of namespace ZVision -- cgit v1.2.3 From d83438225e40f513a43b2c9b5d9b71a3afbc375e Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Sun, 7 Dec 2014 19:53:27 +1100 Subject: SCUMM: Maniac V0: Add support for D64 Demo Disk, Cleanup duplicate 'Talk' array --- devtools/scumm-md5.txt | 1 + engines/scumm/actor.cpp | 102 ++++++++++++++++++++++++--------------- engines/scumm/detection.cpp | 2 + engines/scumm/detection_tables.h | 2 + engines/scumm/file.cpp | 26 ++++++++-- engines/scumm/resource_v2.cpp | 10 +++- engines/scumm/script_v0.cpp | 15 ++++++ engines/scumm/scumm-md5.h | 3 +- engines/scumm/scumm.cpp | 16 ++++-- engines/scumm/scumm_v0.h | 3 ++ engines/scumm/verbs.cpp | 55 +++++++++++++++++++++ 11 files changed, 187 insertions(+), 48 deletions(-) diff --git a/devtools/scumm-md5.txt b/devtools/scumm-md5.txt index 37d7e7a5e1..62925e98fa 100644 --- a/devtools/scumm-md5.txt +++ b/devtools/scumm-md5.txt @@ -52,6 +52,7 @@ maniac Maniac Mansion 2d624d1b214f7faf0094daea65c6d1a6 -1 en 2gs Apple II - - + 2cb46375dd5cdfd023e2f07e0a21b530 -1 en C64 C64 Demo - Robert Crossfield eea4d9ac2fb6f145945a308e8866915b -1 en C64 C64 - - 439a7f4adf510489981ac52308e7d7a2 -1 de C64 C64 - - diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 59a1009789..d07f175c78 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -43,12 +43,60 @@ namespace Scumm { byte Actor::kInvalidBox = 0; -static const byte v0ActorTalkArray[0x19] = { - 0x00, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x00, 0x46, 0x06, - 0x06, 0x06, 0x06, 0xFF, 0xFF, - 0x06, 0xC0, 0x06, 0x06, 0x00, - 0xC0, 0xC0, 0x00, 0x06, 0x06 +static const byte v0ActorDemoTalk[25] = { + 0x00, + 0x06, // Syd + 0x06, // Razor + 0x06, // Dave + 0x06, // Michael + 0x06, // Bernard + 0x06, // Wendy + 0x00, // Jeff + 0x46, // Radiation Suit + 0x06, // Dr Fred + 0x06, // Nurse Edna + 0x06, // Weird Ed + 0x06, // Dead Cousin Ted + 0xE2, // Purple Tentacle + 0xE2, // Green Tentacle + 0x06, // Meteor police + 0xC0, // Meteor + 0x06, // Mark Eteer + 0x06, // Talkshow Host + 0x00, // Plant + 0xC0, // Meteor Radiation + 0xC0, // Edsel (small, outro) + 0x00, // Meteor (small, intro) + 0x06, // Sandy (Lab) + 0x06, // Sandy (Cut-Scene) +}; + +static const byte v0ActorTalk[25] = { + 0x00, + 0x06, // Syd + 0x06, // Razor + 0x06, // Dave + 0x06, // Michael + 0x06, // Bernard + 0x06, // Wendy + 0x00, // Jeff + 0x46, // Radiation Suit + 0x06, // Dr Fred + 0x06, // Nurse Edna + 0x06, // Weird Ed + 0x06, // Dead Cousin Ted + 0xFF, // Purple Tentacle + 0xFF, // Green Tentacle + 0x06, // Meteor police + 0xC0, // Meteor + 0x06, // Mark Eteer + 0x06, // Talkshow Host + 0x00, // Plant + 0xC0, // Meteor Radiation + 0xC0, // Edsel (small, outro) + 0x00, // Meteor (small, intro) + 0x06, // Sandy (Lab) + 0x06, // Sandy (Cut-Scene) }; static const byte v0WalkboxSlantedModifier[0x16] = { @@ -210,6 +258,12 @@ void Actor_v0::initActor(int mode) { _limbFrameRepeat[i] = 0; _limb_flipped[i] = false; } + + if (_vm->_game.features & GF_DEMO) { + _sound[0] = v0ActorDemoTalk[_number]; + } else { + _sound[0] = v0ActorTalk[_number]; + } } void Actor::setBox(int box) { @@ -1753,34 +1807,6 @@ void ScummEngine::showActors() { } } -// bits 0..5: sound, bit 6: ??? -static const byte v0ActorSounds[24] = { - 0x06, // Syd - 0x06, // Razor - 0x06, // Dave - 0x06, // Michael - 0x06, // Bernard - 0x06, // Wendy - 0x00, // Jeff - 0x46, // Radiation Suit - 0x06, // Dr Fred - 0x06, // Nurse Edna - 0x06, // Weird Ed - 0x06, // Dead Cousin Ted - 0xFF, // Purple Tentacle - 0xFF, // Green Tentacle - 0x06, // Meteor police - 0xC0, // Meteor - 0x06, // Mark Eteer - 0x06, // Talkshow Host - 0x00, // Plant - 0xC0, // Meteor Radiation - 0xC0, // Edsel (small, outro) - 0x00, // Meteor (small, intro) - 0x06, // Sandy (Lab) - 0x06, // Sandy (Cut-Scene) -}; - /* Used in Scumm v5 only. Play sounds associated with actors */ void ScummEngine::playActorSounds() { int i, j; @@ -1790,7 +1816,7 @@ void ScummEngine::playActorSounds() { if (_actors[i]->_cost.soundCounter && _actors[i]->isInCurrentRoom()) { _currentScript = 0xFF; if (_game.version == 0) { - sound = v0ActorSounds[i - 1] & 0x3F; + sound = _actors[i]->_sound[0] & 0x3F; } else { sound = _actors[i]->_sound[0]; } @@ -1950,7 +1976,7 @@ void ScummEngine::processActors() { // Is this the correct location? // 0x073C - if (v0ActorTalkArray[a0->_number] & 0x3F) + if (a0->_sound[0] & 0x3F) a0->_cost.soundPos = (a0->_cost.soundPos + 1) % 3; } } @@ -2259,7 +2285,7 @@ void Actor::startAnimActor(int f) { void Actor_v0::startAnimActor(int f) { if (f == _talkStartFrame) { - if (v0ActorTalkArray[_number] & 0x40) + if (_sound[0] & 0x40) return; _speaking = 1; @@ -2365,7 +2391,7 @@ void Actor_v0::animateCostume() { } void Actor_v0::speakCheck() { - if (v0ActorTalkArray[_number] & 0x80) + if (_sound[0] & 0x80) return; int cmd = newDirToOldDir(_facing); diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index c0db0d6d37..45647c9bed 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -323,6 +323,8 @@ static BaseScummFile *openDiskImage(const Common::FSNode &node, const GameFilena gs.gameid = gfp->gameid; gs.id = (Common::String(gfp->gameid) == "maniac" ? GID_MANIAC : GID_ZAK); gs.platform = gfp->platform; + if (strcmp(gfp->pattern, "maniacdemo.d64") == 0) + gs.features |= GF_DEMO; // determine second disk file name Common::String disk2(disk1); diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index f72e552fa6..82a8b4452b 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -207,6 +207,7 @@ static const Engines::ObsoleteGameID obsoleteGameIDsTable[] = { static const GameSettings gameVariantsTable[] = { {"maniac", "Apple II", 0, GID_MANIAC, 0, 0, MDT_APPLEIIGS, 0, Common::kPlatformApple2GS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)}, {"maniac", "C64", 0, GID_MANIAC, 0, 0, MDT_C64, 0, Common::kPlatformC64, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI) }, + {"maniac", "C64 Demo", 0, GID_MANIAC, 0, 0, MDT_C64, GF_DEMO, Common::kPlatformC64, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI) }, {"maniac", "V1", "v1", GID_MANIAC, 1, 0, MDT_PCSPK | MDT_PCJR, 0, Common::kPlatformDOS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)}, {"maniac", "V1 Demo", "v1", GID_MANIAC, 1, 0, MDT_PCSPK | MDT_PCJR, GF_DEMO, Common::kPlatformDOS, GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI)}, {"maniac", "NES", 0, GID_MANIAC, 1, 0, MDT_NONE, 0, Common::kPlatformNES, GUIO3(GUIO_NOSPEECH, GUIO_NOMIDI, GUIO_NOASPECT)}, @@ -448,6 +449,7 @@ static const GameFilenamePattern gameFilenamesTable[] = { { "maniac", "%02d.MAN", kGenRoomNum, UNK_LANG, UNK, "V1 Demo" }, { "maniac", "maniac1.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, "C64" }, // ... and maniac2.d64 { "maniac", "maniac1.dsk", kGenUnchanged, UNK_LANG, Common::kPlatformApple2GS, "Apple II" }, // ... and maniac2.dsk + { "maniac", "maniacdemo.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, "C64 Demo" }, { "maniac", "Maniac Mansion (E).prg", kGenUnchanged, Common::EN_GRB, Common::kPlatformNES, "NES" }, { "maniac", "Maniac Mansion (F).prg", kGenUnchanged, Common::FR_FRA, Common::kPlatformNES, "NES" }, { "maniac", "Maniac Mansion (SW).prg", kGenUnchanged, Common::SE_SWE, Common::kPlatformNES, "NES" }, diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp index 475ffa3238..7ead4c25b5 100644 --- a/engines/scumm/file.cpp +++ b/engines/scumm/file.cpp @@ -221,6 +221,15 @@ static const int maniacResourcesPerFile[55] = { 3, 10, 1, 0, 0 }; +static const int maniacDemoResourcesPerFile[55] = { + 0, 12, 0, 2, 1, 12, 1, 13, 6, 0, + 31, 0, 1, 0, 0, 0, 0, 1, 1, 1, + 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, + 2, 7, 1, 11, 0, 0, 5, 1, 0, 0, + 1, 0, 1, 3, 4, 3, 1, 0, 0, 1, + 1, 2, 0, 0, 0 +}; + static const int zakResourcesPerFile[59] = { 0, 29, 12, 14, 13, 4, 4, 10, 7, 4, 14, 19, 5, 4, 7, 6, 11, 9, 4, 4, @@ -253,9 +262,17 @@ ScummDiskImage::ScummDiskImage(const char *disk1, const char *disk2, GameSetting _numGlobalObjects = 256; _numRooms = 55; _numCostumes = 25; - _numScripts = 160; - _numSounds = 70; - _resourcesPerFile = maniacResourcesPerFile; + + if (_game.features & GF_DEMO) { + _numScripts = 55; + _numSounds = 40; + _resourcesPerFile = maniacDemoResourcesPerFile; + } else { + _numScripts = 160; + _numSounds = 70; + _resourcesPerFile = maniacResourcesPerFile; + } + } else { _numGlobalObjects = 775; _numRooms = 59; @@ -327,6 +344,9 @@ bool ScummDiskImage::open(const Common::String &filename) { extractIndex(0); // Fill in resource arrays + if (_game.features & GF_DEMO) + return true; + openDisk(2); if (_game.platform == Common::kPlatformApple2GS) { diff --git a/engines/scumm/resource_v2.cpp b/engines/scumm/resource_v2.cpp index 7ccdfa4780..87dc132ff0 100644 --- a/engines/scumm/resource_v2.cpp +++ b/engines/scumm/resource_v2.cpp @@ -34,8 +34,14 @@ void ScummEngine_v2::readClassicIndexFile() { _numGlobalObjects = 256; _numRooms = 55; _numCostumes = 25; - _numScripts = 160; - _numSounds = 70; + if (_game.features & GF_DEMO) { + _numScripts = 55; + _numSounds = 40; + } else { + _numScripts = 160; + _numSounds = 70; + } + } else if (_game.platform == Common::kPlatformNES) { _numGlobalObjects = 775; _numRooms = 55; diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index 90291535fd..8d9d196b62 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -633,12 +633,21 @@ void ScummEngine_v0::setMode(byte mode) { switch (_currentMode) { case kModeCutscene: + if (_game.features & GF_DEMO) { + if (VAR(11) != 0) + _drawDemo = true; + } _redrawSentenceLine = false; // Note: do not change freeze state here state = USERSTATE_SET_IFACE | USERSTATE_SET_CURSOR; + break; case kModeKeypad: + if (_game.features & GF_DEMO) { + if (VAR(11) != 0) + _drawDemo = true; + } _redrawSentenceLine = false; state = USERSTATE_SET_IFACE | USERSTATE_SET_CURSOR | USERSTATE_CURSOR_ON | @@ -646,6 +655,12 @@ void ScummEngine_v0::setMode(byte mode) { break; case kModeNormal: case kModeNoNewKid: + if (_game.features & GF_DEMO) { + resetVerbs(); + _activeVerb = kVerbWalkTo; + _redrawSentenceLine = true; + _drawDemo = false; + } state = USERSTATE_SET_IFACE | USERSTATE_IFACE_ALL | USERSTATE_SET_CURSOR | USERSTATE_CURSOR_ON | USERSTATE_SET_FREEZE; diff --git a/engines/scumm/scumm-md5.h b/engines/scumm/scumm-md5.h index 4a34894506..5be18fb990 100644 --- a/engines/scumm/scumm-md5.h +++ b/engines/scumm/scumm-md5.h @@ -1,5 +1,5 @@ /* - This file was generated by the md5table tool on Sat Nov 29 19:54:41 2014 + This file was generated by the md5table tool on Sun Dec 7 23:09:10 2014 DO NOT EDIT MANUALLY! */ @@ -135,6 +135,7 @@ static const MD5Table md5table[] = { { "2a446817ffcabfef8716e0c456ecaf81", "puttzoo", "", "Demo", -1, Common::DE_DEU, Common::kPlatformWindows }, { "2a8658dbd13d84d1bce64a71a35995eb", "pajama2", "HE 99", "Demo", -1, Common::HE_ISR, Common::kPlatformWindows }, { "2c04aacffb8428f30ccf4f734fbe3adc", "activity", "", "", -1, Common::EN_ANY, Common::kPlatformDOS }, + { "2cb46375dd5cdfd023e2f07e0a21b530", "maniac", "C64", "Demo", -1, Common::EN_ANY, Common::kPlatformC64 }, { "2ccd8891ce4d3f1a334d21bff6a88ca2", "monkey", "CD", "", 9455, Common::EN_ANY, Common::kPlatformMacintosh }, { "2d1e891fe52df707c30185e52c50cd92", "monkey", "CD", "CD", 8955, Common::EN_ANY, Common::kPlatformDOS }, { "2d388339d6050d8ccaa757b64633954e", "indyloom", "FM-TOWNS", "Demo", 7520, Common::EN_ANY, Common::kPlatformFMTowns }, diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 475b146a7b..6040344c2c 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -716,7 +716,7 @@ ScummEngine_v2::ScummEngine_v2(OSystem *syst, const DetectorResult &dr) ScummEngine_v0::ScummEngine_v0(OSystem *syst, const DetectorResult &dr) : ScummEngine_v2(syst, dr) { - + _drawDemo = false; _currentMode = 0; _currentLights = 0; @@ -731,6 +731,9 @@ ScummEngine_v0::ScummEngine_v0(OSystem *syst, const DetectorResult &dr) VAR_ACTIVE_OBJECT2 = 0xFF; VAR_IS_SOUND_RUNNING = 0xFF; VAR_ACTIVE_VERB = 0xFF; + + if (strcmp(dr.fp.pattern, "maniacdemo.d64") == 0 ) + _game.features |= GF_DEMO; } ScummEngine_v6::ScummEngine_v6(OSystem *syst, const DetectorResult &dr) @@ -1091,8 +1094,13 @@ Common::Error ScummEngine::init() { const char *tmpBuf1, *tmpBuf2; assert(_game.id == GID_MANIAC || _game.id == GID_ZAK); if (_game.id == GID_MANIAC) { - tmpBuf1 = "maniac1.d64"; - tmpBuf2 = "maniac2.d64"; + if (_game.features & GF_DEMO) { + tmpBuf1 = "maniacdemo.d64"; + tmpBuf2 = "maniacdemo.d64"; + } else { + tmpBuf1 = "maniac1.d64"; + tmpBuf2 = "maniac2.d64"; + } } else { tmpBuf1 = "zak1.d64"; tmpBuf2 = "zak2.d64"; @@ -2572,7 +2580,7 @@ void ScummEngine::runBootscript() { int args[NUM_SCRIPT_LOCAL]; memset(args, 0, sizeof(args)); args[0] = _bootParam; - if (_game.id == GID_MANIAC && (_game.features & GF_DEMO)) + if (_game.id == GID_MANIAC && (_game.features & GF_DEMO) && (_game.platform != Common::kPlatformC64)) runScript(9, 0, 0, args); else runScript(1, 0, 0, args); diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index 83e0e32e15..e2f4a2ffbf 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -46,6 +46,7 @@ protected: }; protected: + bool _drawDemo; byte _currentMode; byte _currentLights; @@ -101,6 +102,8 @@ protected: virtual void handleMouseOver(bool updateInventory); int verbPrepIdType(int verbid); void resetVerbs(); + void verbDemoMode(); + void verbDrawDemoString(int VerbDemoNumber); void clearSentenceLine(); void flushSentenceLine(); diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index bf0a693467..fe936b550c 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -80,6 +80,19 @@ static const VerbSettings v0VerbTable_German[] = { {kVerbWhatIs, 13, 2, "Was ist"} }; +struct VerbDemo { + int color; + const char *str; +}; +static VerbDemo v0DemoStr[] = { + {7, " MANIAC MANSION DEMO DISK "}, + {5, " from Lucasfilm Games "}, + {5, " Copyright = 1987 by Lucasfilm Ltd. "}, + {5, " All Rights Reserved. "}, + {0, " "}, + {16, " Press F7 to return to menu. "} +}; + int ScummEngine_v0::verbPrepIdType(int verbid) { switch (verbid) { case kVerbUse: // depends on object1 @@ -93,6 +106,44 @@ int ScummEngine_v0::verbPrepIdType(int verbid) { } } +void ScummEngine_v0::verbDemoMode() { + int i; + + for (i = 1; i < 16; i++) + killVerb(i); + + for (i = 0; i < 6; i++) { + verbDrawDemoString(i); + } +} + +void ScummEngine_v0::verbDrawDemoString(int VerbDemoNumber) { + byte string[80]; + const char *ptr = v0DemoStr[VerbDemoNumber].str; + int i = 0, len = 0; + + // Maximum length of printable characters + int maxChars = 40; + while (*ptr) { + if (*ptr != '@') + len++; + if (len > maxChars) { + break; + } + + string[i++] = *ptr++; + + } + string[i] = 0; + + _string[2].charset = 1; + _string[2].ypos = _virtscr[kVerbVirtScreen].topline + (8 * VerbDemoNumber); + _string[2].xpos = 0; + _string[2].right = _virtscr[kVerbVirtScreen].w - 1; + _string[2].color = v0DemoStr[VerbDemoNumber].color; + drawString(2, (byte *)string); +} + void ScummEngine_v0::resetVerbs() { VirtScreen *virt = &_virtscr[kVerbVirtScreen]; VerbSlot *vs; @@ -854,6 +905,10 @@ void ScummEngine_v0::checkExecVerbs() { } } } + + if (_drawDemo && _game.features & GF_DEMO) { + verbDemoMode(); + } if (_redrawSentenceLine) drawSentenceLine(); -- cgit v1.2.3 From ecb1979245fb6695a68286a59f5eaf2c3677b579 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 8 Dec 2014 01:25:27 +0200 Subject: ZVISION: Implement more advanced engine features Save game thumbnails and save game creation date have now been implemented --- engines/zvision/detection.cpp | 36 +++++++++++----------- .../zvision/scripting/controls/save_control.cpp | 2 ++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index a60ef6040d..ebf5bdcfdd 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -183,10 +183,10 @@ bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup) || - (f == kSupportsDeleteSave); - //(f == kSavesSupportMetaInfo) || - //(f == kSavesSupportThumbnail) || - //(f == kSavesSupportCreationDate) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate); //(f == kSavesSupportPlayTime); } @@ -293,41 +293,41 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const { } SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - /* - Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot); + Common::String filename = Common::String::format("%s.%03u", target, slot); Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str()); if (in) { - ZVision::ZVision::SaveHeader header; - ZVision::ZVision::kReadSaveHeaderError error; + ZVision::SaveGameHeader header; - error = ZVision::ZVision::readSaveHeader(in, true, header); + // We only use readSaveGameHeader() here, which doesn't need an engine callback + ZVision::SaveManager *zvisionSaveMan = new ZVision::SaveManager(NULL); + bool successfulRead = zvisionSaveMan->readSaveGameHeader(in, header); + delete zvisionSaveMan; delete in; - if (error == ZVision::ZVision::kRSHENoError) { - SaveStateDescriptor desc(slot, header.description); + if (successfulRead) { + SaveStateDescriptor desc(slot, header.saveName); desc.setThumbnail(header.thumbnail); if (header.version > 0) { - int day = (header.saveDate >> 24) & 0xFF; - int month = (header.saveDate >> 16) & 0xFF; - int year = header.saveDate & 0xFFFF; + int day = header.saveDay; + int month = header.saveMonth; + int year = header.saveYear; desc.setSaveDate(year, month, day); - int hour = (header.saveTime >> 16) & 0xFF; - int minutes = (header.saveTime >> 8) & 0xFF; + int hour = header.saveHour; + int minutes = header.saveMinutes; desc.setSaveTime(hour, minutes); - desc.setPlayTime(header.playTime * 1000); + //desc.setPlayTime(header.playTime * 1000); } return desc; } } - */ return SaveStateDescriptor(); } diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index ad01257e6b..d773b5fc6f 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -101,6 +101,8 @@ bool SaveControl::process(uint32 deltaTimeInMillis) { toSave = false; if (toSave) { + // FIXME: At this point, the screen shows the save control, so the save game thumbnails will always + // show the save control _engine->getSaveManager()->saveGameBuffered(iter->saveId, inp->getText()); _engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000); _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation()); -- cgit v1.2.3 From d92e47f4e6ff7187ac0dca9ad1c54b2c96fda1b9 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Mon, 8 Dec 2014 10:29:23 +1100 Subject: SCUMM V1-V2: Fix actor walk behavior (transitions between walk boxes, and changing destination issue) --- engines/scumm/actor.cpp | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 59a1009789..07c8f84be7 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -385,13 +385,28 @@ int Actor::actorWalkStep() { return 0; } - tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex; - _walkdata.xfrac = (uint16)tmpX; - _pos.x = (tmpX >> 16); + if (_vm->_game.version <= 2) { + if (_walkdata.deltaXFactor != 0) { + if (_walkdata.deltaXFactor > 0) + _pos.x += 1; + else + _pos.x -= 1; + } + if (_walkdata.deltaYFactor != 0) { + if (_walkdata.deltaYFactor > 0) + _pos.y += 1; + else + _pos.y -= 1; + } + } else { + tmpX = (_pos.x << 16) + _walkdata.xfrac + (_walkdata.deltaXFactor >> 8) * _scalex; + _walkdata.xfrac = (uint16)tmpX; + _pos.x = (tmpX >> 16); - tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley; - _walkdata.yfrac = (uint16)tmpY; - _pos.y = (tmpY >> 16); + tmpY = (_pos.y << 16) + _walkdata.yfrac + (_walkdata.deltaYFactor >> 8) * _scaley; + _walkdata.yfrac = (uint16)tmpY; + _pos.y = (tmpY >> 16); + } if (ABS(_pos.x - _walkdata.cur.x) > distX) { _pos.x = _walkdata.next.x; @@ -401,7 +416,7 @@ int Actor::actorWalkStep() { _pos.y = _walkdata.next.y; } - if (_vm->_game.version >= 4 && _vm->_game.version <= 6 && _pos == _walkdata.next) { + if ((_vm->_game.version <= 2 || (_vm->_game.version >= 4 && _vm->_game.version <= 6)) && _pos == _walkdata.next) { _moving &= ~MF_IN_LEG; return 0; } @@ -565,14 +580,17 @@ void Actor::startWalkActor(int destX, int destY, int dir) { _walkdata.dest.y = abr.y; _walkdata.destbox = abr.box; _walkdata.destdir = dir; - _walkdata.point3.x = 32000; - _walkdata.curbox = _walkbox; - + if (_vm->_game.version == 0) { ((Actor_v0*)this)->_newWalkBoxEntered = true; - } else { - _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; - } + } else if (_vm->_game.version <= 2) { + _moving = (_moving & ~(MF_LAST_LEG | MF_IN_LEG)) | MF_NEW_LEG; + } else { + _moving = (_moving & MF_IN_LEG) | MF_NEW_LEG; + } + + _walkdata.point3.x = 32000; + _walkdata.curbox = _walkbox; } void Actor::startWalkAnim(int cmd, int angle) { -- cgit v1.2.3 From 962c8b4524f46bbc2394d7a80972db0a474221a3 Mon Sep 17 00:00:00 2001 From: Robert Crossfield Date: Mon, 8 Dec 2014 19:04:17 +1100 Subject: SCUMM: Maniac V0 Demo: Allow F7 to restart, Add handler for opcode 0x6e (o_screenPrepare) --- engines/scumm/file.cpp | 2 +- engines/scumm/input.cpp | 12 ++++++++++-- engines/scumm/script_v0.cpp | 6 +++++- engines/scumm/scumm_v0.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp index 7ead4c25b5..96b46aa21a 100644 --- a/engines/scumm/file.cpp +++ b/engines/scumm/file.cpp @@ -227,7 +227,7 @@ static const int maniacDemoResourcesPerFile[55] = { 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 7, 1, 11, 0, 0, 5, 1, 0, 0, 1, 0, 1, 3, 4, 3, 1, 0, 0, 1, - 1, 2, 0, 0, 0 + 2, 2, 0, 0, 0 }; static const int zakResourcesPerFile[59] = { diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 824dfec144..86048af57c 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -452,8 +452,16 @@ void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) { lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); // F7 is used to skip cutscenes in the Commodote 64 version of Maniac Mansion } else if (_game.id == GID_MANIAC &&_game.platform == Common::kPlatformC64) { - if (lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0)) - lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); + // Demo always F7 to be pressed to restart + if (_game.features & GF_DEMO) { + if (_roomResource != 0x2D && lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0)) { + restart(); + return; + } + } else { + if (lastKeyHit.keycode == Common::KEYCODE_F7 && lastKeyHit.hasFlags(0)) + lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE); + } // 'B' is used to skip cutscenes in the NES version of Maniac Mansion } else if (_game.id == GID_MANIAC &&_game.platform == Common::kPlatformNES) { if (lastKeyHit.keycode == Common::KEYCODE_b && lastKeyHit.hasFlags(Common::KBD_SHIFT)) diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index 8d9d196b62..609cbd1e89 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -172,7 +172,7 @@ void ScummEngine_v0::setupOpcodes() { /* 6C */ OPCODE(0x6c, o_stopCurrentScript); OPCODE(0x6d, o2_putActorInRoom); - OPCODE(0x6e, o2_dummy); + OPCODE(0x6e, o_screenPrepare); OPCODE(0x6f, o2_ifState08); /* 70 */ OPCODE(0x70, o_lights); @@ -982,6 +982,10 @@ void ScummEngine_v0::o_setOwnerOf() { setOwnerOf(obj, owner); } +void ScummEngine_v0::o_screenPrepare() { + +} + void ScummEngine_v0::resetSentence() { _activeVerb = kVerbWalkTo; _activeObject = 0; diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index e2f4a2ffbf..4098d639c4 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -166,6 +166,7 @@ protected: void o_cutscene(); void o_endCutscene(); void o_setOwnerOf(); + void o_screenPrepare(); byte VAR_ACTIVE_OBJECT2; byte VAR_IS_SOUND_RUNNING; -- cgit v1.2.3 From 0a6904c4abc242125532fb797290820834cbb2cf Mon Sep 17 00:00:00 2001 From: Kirben Date: Mon, 8 Dec 2014 23:31:59 +1100 Subject: SCUMM: Correct variable type in Actor_v0::adjustPosInBorderWalkbox, since variable can have negative value. --- engines/scumm/actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 6cbb2a4e45..0d7ea39ec2 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -1528,7 +1528,7 @@ AdjustBoxResult Actor_v0::adjustPosInBorderWalkbox(AdjustBoxResult box) { if (!(boxMask & 0x80)) return Result; - byte A; + int16 A; boxMask &= 0x7C; if (boxMask == 0x0C) A = 2; -- cgit v1.2.3 From 68693f996dc9b66ecbdfda9c38e07765ba0a70df Mon Sep 17 00:00:00 2001 From: D G Turner Date: Tue, 9 Dec 2014 10:51:00 +0000 Subject: CONFIGURE: Add likely fix for AmigaOS4 linker relocation build failure. --- configure | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure b/configure index ebca8322dc..eba1ebcb32 100755 --- a/configure +++ b/configure @@ -2763,6 +2763,9 @@ if test -n "$_host"; then _port_mk="backends/platform/openpandora/op-bundle.mk" ;; ppc-amigaos) + # PPC Linker requires this to fix relocation errors + CXXFLAGS="$CXXFLAGS -mlongcall" + # Only static builds link successfully on buildbot LDFLAGS=`echo $LDFLAGS | sed 's/-use-dynld//'` LDFLAGS="$LDFLAGS -static" -- cgit v1.2.3 From ea8db1969a7f975103d26f6a6a7eaa54835db7c1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 9 Dec 2014 19:36:38 +0200 Subject: ZVISION: Fix the 'dumpfile' console command --- engines/zvision/core/console.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index f8e28333f1..e641783338 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -209,7 +209,8 @@ bool Console::cmdDumpFile(int argc, const char **argv) { } Common::File f; - if (!f.open(argv[1])) { + if (!_engine->getSearchManager()->openFile(f, argv[1])) { + warning("File not found: %s", argv[1]); return true; } -- cgit v1.2.3 From 1f80e1389fca2fc86d7176730115c48f4e503474 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 9 Dec 2014 19:37:33 +0200 Subject: ZVISION: Fix the responsiveness of level controls to mouse movement This fixes the responsiveness of the levers in the planet screen of Zork: Nemesis --- engines/zvision/scripting/controls/lever_control.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 12b07d7584..1e4087963e 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -221,10 +221,9 @@ bool LeverControl::onMouseMove(const Common::Point &screenSpacePos, const Common bool cursorWasChanged = false; if (_mouseIsCaptured) { - // Make sure the square distance between the last point and the current point is greater than 64 + // Make sure the square distance between the last point and the current point is greater than 16 // This is a heuristic. This determines how responsive the lever is to mouse movement. - // TODO: Fiddle with the heuristic to get a good lever responsiveness 'feel' - if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 64) { + if (_lastMousePos.sqrDist(backgroundImageSpacePos) >= 16) { int angle = calculateVectorAngle(_lastMousePos, backgroundImageSpacePos); _lastMousePos = backgroundImageSpacePos; -- cgit v1.2.3 From e670196c6266100000e16fc3c368bfdce8a6d558 Mon Sep 17 00:00:00 2001 From: Alexander Reim Date: Wed, 10 Dec 2014 14:27:10 +0100 Subject: SCI: Add detection entries for the German versions of Phantasmagoria 1+2 --- engines/sci/detection_tables.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index 0fddaa51b4..d6bdef946b 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -2603,6 +2603,29 @@ static const struct ADGameDescription SciGameDescriptions[] = { AD_LISTEND}, Common::EN_ANY, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Phantasmagoria - German DOS/Windows + // Windows executable scanning reports "unknown" - "Sep 19 1995 09:39:48" + // DOS executable scanning reports "unknown" - "Sep 19 1995 16:18:34" + // VERSION file reports "1.100.000" + // Supplied by AReim1982 + {"phantasmagoria", "", { + {"resmap.001", 0, "d5048f972d2e1abd5f6b6a3ea8a466b0", 11524}, + {"ressci.001", 0, "3aae6559aa1df273bc542d5ac6330d75", 71063082}, + {"resmap.002", 0, "ae0105261e04826324daf7dd2d534465", 12064}, + {"ressci.002", 0, "3aae6559aa1df273bc542d5ac6330d75", 80283368}, + {"resmap.003", 0, "50786a4f54c6432ec31b52be90b3a8ba", 12340}, + {"ressci.003", 0, "3aae6559aa1df273bc542d5ac6330d75", 82360370}, + {"resmap.004", 0, "4cd3bbff8b81bad85db52c0c8407bd81", 12562}, + {"ressci.004", 0, "3aae6559aa1df273bc542d5ac6330d75", 84453560}, + {"resmap.005", 0, "779bd12802da6cfe54ce482140824a46", 12616}, + {"ressci.005", 0, "3aae6559aa1df273bc542d5ac6330d75", 85113663}, + {"resmap.006", 0, "2299f97876493cc29b6a48e1cfe9619d", 12538}, + {"ressci.006", 0, "3aae6559aa1df273bc542d5ac6330d75", 87602346}, + {"resmap.007", 0, "06309b8043aecb85bd507b15d16cb544", 7984}, + //{"ressci.007", 0, "3aae6559aa1df273bc542d5ac6330d75", 26898681}, + AD_LISTEND}, + Common::DE_DEU, Common::kPlatformDOS, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Phantasmagoria - French DOS // Supplied by Kervala in bug #6574 {"phantasmagoria", "", { @@ -2674,6 +2697,25 @@ static const struct ADGameDescription SciGameDescriptions[] = { AD_LISTEND}, Common::EN_ANY, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Phantasmagoria 2 - German DOS/Windows + // Windows executable scanning reports "unknown" - "Dec 07 1996 15:42:02" + // DOS executable scanning reports "unknown" - "Dec 07 1996 08:35:12" + // VERSION file reports "000.1.0vu" (HEX: 30 30 30 2E 31 00 2E 30 76 FA 0D 0A) + // Supplied by AReim1982 + {"phantasmagoria2", "", { + {"resmap.001", 0, "d62f48ff8bddb39503b97e33439482c9", 1114}, + {"ressci.001", 0, "4ebc2b8455c74ad205ae592eec27313a", 24590716}, + {"resmap.002", 0, "642a1f85ad8a4ce1d3850b10ad082200", 1138}, + {"ressci.002", 0, "4ebc2b8455c74ad205ae592eec27313a", 34681672}, + {"resmap.003", 0, "e08316864ef77735bb7f8f208110c43b", 1174}, + {"ressci.003", 0, "4ebc2b8455c74ad205ae592eec27313a", 38930933}, + {"resmap.004", 0, "875cf07df77fbaa1518a06ffed616c5f", 1300}, + {"ressci.004", 0, "4ebc2b8455c74ad205ae592eec27313a", 42750325}, + {"resmap.005", 0, "2fc48a4a5a73b726994f189da51a8b2a", 1954}, + {"ressci.005", 0, "e94005890d22dd3b7f605a2a7c025803", 68232146}, + AD_LISTEND}, + Common::DE_DEU, Common::kPlatformWindows, ADGF_UNSTABLE, GUIO5(GUIO_NOSPEECH, GUIO_NOASPECT, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Phantasmagoria 2 - English DOS (GOG version) - ressci.* merged in ressci.000 // Executable scanning reports "3.000.000" - "Dec 07 1996 09:29:03" // VERSION file reports "001.0.06" -- cgit v1.2.3 From c98e9fa6f7702b81fa15667e58854de95cb4a5f6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 11 Dec 2014 13:24:27 +0200 Subject: ZVISION: Add a comment in the music code --- engines/zvision/scripting/sidefx/music_node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index a76d3b4e8d..8316c1a76b 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -71,6 +71,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 1); + // Change filename.raw into filename.sub Common::String subname = filename; subname.setChar('s', subname.size() - 3); subname.setChar('u', subname.size() - 2); -- cgit v1.2.3 From 2644d084480d537388cc7f585338ff2bf0490b38 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 11 Dec 2014 13:25:37 +0200 Subject: ZVISION: Add functionality to show the current location. Some cleanup --- engines/zvision/core/console.cpp | 38 ++++++++++++++++---------------------- engines/zvision/core/console.h | 3 +-- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index e641783338..0f6cbfc96f 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -51,14 +51,13 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("generaterendertable", WRAP_METHOD(Console, cmdGenerateRenderTable)); registerCmd("setpanoramafov", WRAP_METHOD(Console, cmdSetPanoramaFoV)); registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); - registerCmd("changelocation", WRAP_METHOD(Console, cmdChangeLocation)); + registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - registerCmd("parseallscrfiles", WRAP_METHOD(Console, cmdParseAllScrFiles)); } bool Console::cmdLoadVideo(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use loadvideo to load a video to the screen\n"); + debugPrintf("Use %s to load a video to the screen\n", argv[0]); return true; } @@ -91,7 +90,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); } else { - debugPrintf("Use loadsound [ ] to load a sound\n"); + debugPrintf("Use %s [ ] to load a sound\n", argv[0]); return true; } @@ -100,7 +99,7 @@ bool Console::cmdLoadSound(int argc, const char **argv) { bool Console::cmdRawToWav(int argc, const char **argv) { if (argc != 3) { - debugPrintf("Use raw2wav to dump a .RAW file to .WAV\n"); + debugPrintf("Use %s to dump a .RAW file to .WAV\n", argv[0]); return true; } @@ -145,7 +144,7 @@ bool Console::cmdRawToWav(int argc, const char **argv) { bool Console::cmdSetRenderState(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use %s to change the current render state\n", argv[0]); return true; } @@ -158,7 +157,7 @@ bool Console::cmdSetRenderState(int argc, const char **argv) { else if (renderState.matchString("flat", true)) _engine->getRenderManager()->getRenderTable()->setRenderState(RenderTable::FLAT); else - debugPrintf("Use setrenderstate to change the current render state\n"); + debugPrintf("Use %s to change the current render state\n", argv[0]); return true; } @@ -171,7 +170,7 @@ bool Console::cmdGenerateRenderTable(int argc, const char **argv) { bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setpanoramafov to change the current panorama field of view\n"); + debugPrintf("Use %s to change the current panorama field of view\n", argv[0]); return true; } @@ -182,7 +181,7 @@ bool Console::cmdSetPanoramaFoV(int argc, const char **argv) { bool Console::cmdSetPanoramaScale(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use setpanoramascale to change the current panorama scale\n"); + debugPrintf("Use %s to change the current panorama scale\n", argv[0]); return true; } @@ -191,9 +190,14 @@ bool Console::cmdSetPanoramaScale(int argc, const char **argv) { return true; } -bool Console::cmdChangeLocation(int argc, const char **argv) { +bool Console::cmdLocation(int argc, const char **argv) { + Location curLocation = _engine->getScriptManager()->getCurrentLocation(); + Common::String scrFile = Common::String::format("%c%c%c%c.scr", curLocation.world, curLocation.room, curLocation.node, curLocation.view); + debugPrintf("Current location: world '%c', room '%c', node '%c', view '%c', offset %d, script %s\n", + curLocation.world, curLocation.room, curLocation.node, curLocation.view, curLocation.offset, scrFile.c_str()); + if (argc != 6) { - debugPrintf("Use changelocation to change your location\n"); + debugPrintf("Use %s to change your location\n", argv[0]); return true; } @@ -204,7 +208,7 @@ bool Console::cmdChangeLocation(int argc, const char **argv) { bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { - debugPrintf("Use dumpfile to dump a file\n"); + debugPrintf("Use %s to dump a file\n", argv[0]); return true; } @@ -229,14 +233,4 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } -bool Console::cmdParseAllScrFiles(int argc, const char **argv) { - Common::ArchiveMemberList list; - SearchMan.listMatchingMembers(list, "*.scr"); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - } - - return true; -} - } // End of namespace ZVision diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 994e05ba35..299bd6127f 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -44,9 +44,8 @@ private: bool cmdGenerateRenderTable(int argc, const char **argv); bool cmdSetPanoramaFoV(int argc, const char **argv); bool cmdSetPanoramaScale(int argc, const char **argv); - bool cmdChangeLocation(int argc, const char **argv); + bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); - bool cmdParseAllScrFiles(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From fd6731c9b6f3977b2d03d1e6db2522e0769d8f33 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 12 Dec 2014 22:53:52 +0200 Subject: ZVISION: Only scale down animations to fit their frame, not up This fixes the animations in two locations in Zork: Nemesis (the armor visor in location cz1e, and the planet in location aa10). --- engines/zvision/scripting/sidefx/animation_node.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 549aacba7f..74e4cadbe9 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -117,7 +117,11 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { dsth = nod->pos.height(); } - if (frame->w != dstw || frame->h != dsth) { + // We only scale down the animation to fit its frame, not up, otherwise we + // end up with distorted animations - e.g. the armor visor in location cz1e + // in Nemesis (one of the armors inside Irondune), or the planet in location + // aa10 in Nemesis (Juperon, outside the asylum). + if (frame->w > dstw || frame->h > dsth) { if (nod->_scaled) if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { delete nod->_scaled; -- cgit v1.2.3 From 374669d7c3d8b9d3b7207925c90417a4e82f7ed2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 19 Oct 2014 22:03:20 -0400 Subject: ACCESS: Fix scene establishment paging when there are multiple pages --- engines/access/access.cpp | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 28847370a2..a97bd6d322 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -239,29 +239,34 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); if ((s->_printOrg.y > _printEnd) && (!lastLine)) { - while (true) { - _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundPriority[0] = 1; - _sound->playSound(0); - _scripts->cmdFreeSound(); - - _events->pollEvents(); - - if (_events->_leftButton) { - _events->debounceLeft(); - _sndSubFile += soundsLeft; - break; - } else if (_events->_keypresses.size() != 0) { - _sndSubFile += soundsLeft; - break; - } else { - ++_sndSubFile; - --soundsLeft; - if (soundsLeft == 0) + if (!_sound->_isVoice) { + _events->waitKeyMouse(); + } else { + for (;;) { + _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundPriority[0] = 1; + _sound->playSound(0); + _scripts->cmdFreeSound(); + + _events->pollEvents(); + + if (_events->_leftButton) { + _events->debounceLeft(); + _sndSubFile += soundsLeft; + break; + } else if (_events->_keypresses.size() != 0) { + _sndSubFile += soundsLeft; break; + } else { + ++_sndSubFile; + --soundsLeft; + if (soundsLeft == 0) + break; + } } } - _buffer2.copyBuffer(s); + + s->copyBuffer(&_buffer2); s->_printOrg.y = s->_printStart.y; ++curPage; soundsLeft = _countTbl[curPage]; -- cgit v1.2.3 From e9c003f30648936e58253dca2e72173757d2ff80 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Oct 2014 19:44:45 -0400 Subject: ACCESS: Fix display of paged text in doEstablish calls --- engines/access/access.cpp | 17 +++++++++++------ engines/access/access.h | 4 ++-- engines/access/amazon/amazon_game.cpp | 11 +++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a97bd6d322..051884c704 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -218,17 +218,20 @@ void AccessEngine::freeInactiveData() { _inactive._spritesPtr = nullptr; } -void AccessEngine::speakText(ASurface *s, Common::Array msgArr) { +void AccessEngine::speakText(ASurface *s, const Common::String &msg) { + Common::String lines = msg; + Common::String line; int curPage = 0; int soundsLeft = 0; - while(true) { + for (;;) { soundsLeft = _countTbl[curPage]; _events->zeroKeys(); Common::String line; int width = 0; - bool lastLine = _fonts._font2.getLine(msgArr[curPage], s->_maxChars * 6, line, width); + bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width); + // Set font colors _fonts._font2._fontColors[0] = 0; _fonts._font2._fontColors[1] = 28; @@ -308,11 +311,13 @@ void AccessEngine::speakText(ASurface *s, Common::Array msgArr) } } -void AccessEngine::printText(ASurface *s, Common::String &msg) { +void AccessEngine::printText(ASurface *s, const Common::String &msg) { + Common::String lines = msg; Common::String line; int width = 0; - while (true) { - bool lastLine = _fonts._font2.getLine(msg, s->_maxChars * 6, line, width); + + for (;;) { + bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width); // Set font colors _fonts._font2._fontColors[0] = 0; diff --git a/engines/access/access.h b/engines/access/access.h index 157a33c723..bec1dacb4c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -271,8 +271,8 @@ public: /** * Draw a string on a given surface and update text positioning */ - void printText(ASurface *s, Common::String &msg); - void speakText(ASurface *s, Common::ArraymsgArr); + void printText(ASurface *s, const Common::String &msg); + void speakText(ASurface *s, const Common::String &msg); /** * Load a savegame diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 66b77d66d2..187b38c497 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -282,17 +282,12 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2); _printEnd = 155; + Common::String msg((const char *)_eseg->data() + msgOffset); + if (_txtPages == 0) { - Common::String msg((const char *)_eseg->data() + msgOffset); printText(_screen, msg); } else { - Common::Array msgArr; - for (int i = 0; i < _txtPages; ++i) { - Common::String msg((const char *)_eseg->data() + msgOffset); - msgOffset += msg.size() + 1; - msgArr.push_back(msg); - } - speakText(_screen, msgArr); + speakText(_screen, msg); } _screen->forceFadeOut(); -- cgit v1.2.3 From 59c4c93c005896389915c1022634e5dd041e268a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Oct 2014 20:34:32 -0400 Subject: ACCESS: Add needed event polling to cmdCheckTimer --- engines/access/scripts.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 0b2150a5a6..85c714f4a8 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -414,6 +414,7 @@ void Scripts::cmdSetTimer() { void Scripts::cmdCheckTimer() { int idx = _data->readUint16LE(); + _vm->_events->pollEvents(); if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { _vm->_events->zeroKeys(); _vm->_timers[9]._timer = 0; -- cgit v1.2.3 From 3627ff51aaad803f611b2e5f3072914d0170ed9c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 31 Oct 2014 23:01:47 -0400 Subject: ACCESS: Implemented code for cmdChapter --- engines/access/access.cpp | 11 ++ engines/access/access.h | 5 + engines/access/amazon/amazon_game.cpp | 158 ++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 6 ++ engines/access/amazon/amazon_resources.cpp | 38 +++++++ engines/access/amazon/amazon_resources.h | 6 ++ engines/access/amazon/amazon_scripts.cpp | 7 +- engines/access/amazon/amazon_scripts.h | 2 +- engines/access/files.cpp | 2 +- engines/access/files.h | 3 +- engines/access/scripts.h | 3 +- engines/access/video.cpp | 2 +- engines/access/video.h | 2 +- 13 files changed, 235 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 051884c704..1e3e3a7754 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -432,6 +432,17 @@ void AccessEngine::copyBF2Vid() { } } +void AccessEngine::playVideo(int fileNum, const Common::Point &pt) { + _video->setVideo(_screen, pt, FileIdent(fileNum, 96), 10); + + while (!shouldQuit() && !_video->_videoEnd) { + _video->playVideo(); + + g_system->delayMillis(10); + _events->pollEvents(); + } +} + void AccessEngine::doLoadSave() { error("TODO: doLoadSave"); } diff --git a/engines/access/access.h b/engines/access/access.h index bec1dacb4c..a12a63212d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -119,6 +119,11 @@ protected: */ Common::String AccessEngine::generateSaveName(int slot); + /** + * Play back an entire video + */ + void playVideo(int fileNum, const Common::Point &pt); + // Engine APIs virtual Common::Error run(); virtual bool hasFeature(EngineFeature f) const; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 187b38c497..3af07edaf3 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -55,11 +55,13 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _rawInactiveY = 0; _inactiveYOff = 0; _tilePos = Common::Point(0, 0); + _hintLevel = 0; Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); + + _chapterCells.push_back(CellIdent(0, 96, 17)); - _hintLevel = 0; } AmazonEngine::~AmazonEngine() { @@ -380,6 +382,160 @@ void AmazonEngine::drawHelp() { error("TODO: drawHelp"); } +void AmazonEngine::startChapter(int chapter) { + _chapter = chapter; + assert(_chapter <= 14); + + if (chapter != 1) { + _room->clearRoom(); + freeChar(); + + _sound->newMusic(32, 0); + playVideo(0, Common::Point()); + if (shouldQuit()) + return; + + _events->debounceLeft(); + _events->zeroKeys(); + playVideo(_chapter, Common::Point(4, 113)); + if (shouldQuit()) + return; + + _timers[20]._timer = 500; + _timers[20]._initTm = 500; + _timers[20]._flag++; + + _sound->_soundTable[0] = _sound->loadSound(115, 0); + _sound->_soundPriority[0] = 1; + _sound->playSound(0); + _sound->freeSounds(); + + _sound->_soundTable[0] = _sound->loadSound(115, 1); + _sound->_soundPriority[0] = 1; + _sound->playSound(0); + _sound->freeSounds(); + + // Wait loop + while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton + && _events->_keypresses.size() == 0 && _timers[20]._flag) { + _events->pollEvents(); + g_system->delayMillis(10); + } + } + + _screen->forceFadeOut(); + _events->debounceLeft(); + _events->zeroKeys(); + _screen->clearScreen(); + + _screen->setPanel(3); + + // Set up cells for the chapter display + Common::Array chapterCells; + chapterCells.push_back(CellIdent(0, 96, 17)); + const int *chapCell = &CHAPTER_CELLS[_chapter - 1][0]; + chapterCells.push_back(CellIdent(chapCell[0], chapCell[1], chapCell[2])); + loadCells(chapterCells); + + // Show chapter screen + _files->loadScreen(96, 15); + _buffer2.copyFrom(*_screen); + + const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0]; + _screen->plotImage(_objectsTable[0], _chapter - 1, + Common::Point(chapImg[1], chapImg[2])); + _screen->plotImage(_objectsTable[_chapter - 1], 0, + Common::Point(chapImg[3], chapImg[4])); + if (chapter == 14) + _screen->plotImage(_objectsTable[_chapter - 1], 1, Common::Point(169, 76)); + + _sound->newMusic(chapImg[4], 1); + _sound->newMusic(33, 0); + _screen->forceFadeIn(); + + _timers[20]._timer = 950; + _timers[20]._initTm = 950; + _timers[20]._flag++; + + // Wait loop + while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton + && _events->_keypresses.size() == 0 && _timers[20]._flag) { + _events->pollEvents(); + g_system->delayMillis(10); + } + if (shouldQuit()) + return; + + _screen->forceFadeOut(); + _events->debounceLeft(); + _events->zeroKeys(); + + _screen->clearBuffer(); + _files->loadScreen(96, 16); + _buffer2.copyFrom(*_screen); + _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7)); + + _sound->newMusic(7, 1); + _sound->newMusic(34, 0); + + _screen->forceFadeIn(); + _buffer2.copyFrom(*_screen); + + _fonts._charSet._lo = 1; + _fonts._charSet._hi = 10; + _fonts._charFor._lo = 55; + _fonts._charFor._hi = 0xFF; + _screen->_printOrg = Common::Point(31, 77); + _screen->_printStart = Common::Point(31, 77); + + _establishGroup = 1; + loadEstablish(0x40 + _chapter); + uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (_chapter * 2) + 2); + _printEnd = 170; + + _printEnd = 155; + Common::String msg((const char *)_eseg->data() + msgOffset); + + if (_txtPages == 0) { + printText(_screen, msg); + } else { + speakText(_screen, msg); + } + if (shouldQuit()) + return; + + _screen->forceFadeOut(); + _screen->clearBuffer(); + freeCells(); + + _sound->newMusic(_chapter * 2, 1); + + if (chapter != 1 && chapter != 14) { + _room->init4Quads(); + } + + if (chapter == 14) { + _conversation = 31; + _char->loadChar(_conversation); + _events->setCursor(CURSOR_ARROW); + + _images.clear(); + _oldRects.clear(); + _scripts->_sequence = 0; + _scripts->searchForSequence(); + + if (_screen->_vesaMode) { + _converseMode = 1; + } + } else if (chapter != 1) { + _player->_roomNumber = CHAPTER_JUMP[_chapter - 1]; + _room->_function = 1; + _converseMode = 0; + + _scripts->cmdRetPos(); + } +} + void AmazonEngine::synchronize(Common::Serializer &s) { AccessEngine::synchronize(s); diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 0275ceec17..2dc0c058fb 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -70,6 +70,7 @@ private: // Other fields Common::Point _tilePos; byte _tileData[1455]; + Common::Array _chapterCells; /** * Do the game introduction @@ -161,6 +162,11 @@ public: void tileScreen(); void updateSummary(int chap); + + /** + * Show the start of a chapter + */ + void startChapter(int chapter); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index a51457522e..05af0c116b 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1314,6 +1314,44 @@ const int DEATH_CELLS[12][3] = { { 0, 94, 14 } }; +const int CHAPTER_CELLS[17][3] = { + { 1, 96, 18 }, + { 2, 96, 19 }, + { 3, 96, 20 }, + { 4, 96, 21 }, + { 5, 96, 22 }, + { 6, 96, 23 }, + { 7, 96, 24 }, + { 8, 96, 25 }, + { 9, 96, 26 }, + { 10, 96, 27 }, + { 11, 96, 28 }, + { 12, 96, 29 }, + { 13, 96, 30 }, + { 14, 96, 31 } +}; + +const int CHAPTER_TABLE[14][5] = { + { 18, 136, 27, 76, 49 }, + { 16, 134, 27, 53, 74 }, + { 16, 136, 27, 52, 56 }, + { 16, 135, 26, 46, 75 }, + { 16, 135, 27, 54, 66 }, + { 16, 137, 27, 67, 79 }, + { 14, 136, 27, 82, 52 }, + { 15, 136, 26, 65, 73 }, + { 15, 137, 26, 48, 75 }, + { 17, 135, 27, 52, 66 }, + { 15, 135, 27, 62, 65 }, + { 16, 135, 28, 45, 66 }, + { 16, 135, 28, 36, 67 }, + { 15, 135, 27, 34, 63 } +}; + +const int CHAPTER_JUMP[14] = { + 0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0 +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 17cca2a0b4..d8d37b5a5f 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -58,6 +58,12 @@ extern const char *const DEATH_TEXT[58]; extern const int DEATH_CELLS[12][3]; +extern const int CHAPTER_CELLS[17][3]; + +extern const int CHAPTER_TABLE[14][5]; + +extern const int CHAPTER_JUMP[14]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index a932dad216..7ad68bd5bc 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -414,7 +414,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)(); void AmazonScripts::executeCommand(int commandIndex) { static const AmazonScriptMethodPtr COMMAND_LIST[] = { &AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK, - &AmazonScripts::CMDCHAPTER, &AmazonScripts::cmdSetHelp, + &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp, &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, &AmazonScripts::CMDRETFLASH }; @@ -452,8 +452,9 @@ void AmazonScripts::cmdHelp() { void AmazonScripts::CMDCYCLEBACK() { error("TODO CMDCYCLEBACK"); } -void AmazonScripts::CMDCHAPTER() { - error("TODO CMDCHAPTER"); +void AmazonScripts::cmdChapter() { + int chapter = _data->readByte(); + _game->startChapter(chapter); } void AmazonScripts::cmdSetHelp() { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 50bd2ac9b1..edb8843da3 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -53,7 +53,7 @@ protected: void cmdHelp(); void CMDCYCLEBACK(); - void CMDCHAPTER(); + void cmdChapter(); void cmdSetHelp(); void cmdCenterPanel(); void cmdMainPanel(); diff --git a/engines/access/files.cpp b/engines/access/files.cpp index d8823c0510..a4ec16ad61 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -101,7 +101,7 @@ Resource *FileManager::loadFile(int fileNum, int subfile) { return res; } -Resource *FileManager::loadFile(FileIdent &fileIdent) { +Resource *FileManager::loadFile(const FileIdent &fileIdent) { return loadFile(fileIdent._fileNum, fileIdent._subfile); } diff --git a/engines/access/files.h b/engines/access/files.h index a32ebbf88c..720d4fb2ba 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -38,6 +38,7 @@ struct FileIdent { int _subfile; FileIdent(); + FileIdent(int fileNum, int subfile) { _fileNum = fileNum; _subfile = subfile; } void load(Common::SeekableReadStream &s); }; @@ -112,7 +113,7 @@ public: /** * Loads a resource specified by a file identifier */ - Resource *loadFile(FileIdent &fileIdent); + Resource *loadFile(const FileIdent &fileIdent); /** * Load a given file by name diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 003f441234..e6faa46dde 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -66,7 +66,6 @@ protected: void cmdJumpTalk(); void cmdNull(); void cmdPrint(); - void cmdRetPos(); void cmdAnim(); void cmdSetFlag(); void cmdCheckFlag(); @@ -145,7 +144,9 @@ public: void findNull(); + // Script commands that need to be public void cmdFreeSound(); + void cmdRetPos(); }; } // End of namespace Access diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 4b9a875931..b46bdf240f 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -38,7 +38,7 @@ VideoPlayer::~VideoPlayer() { } -void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate) { +void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate) { _vidSurface = vidSurface; vidSurface->_orgX1 = pt.x; vidSurface->_orgY1 = pt.y; diff --git a/engines/access/video.h b/engines/access/video.h index bb9656b296..b49c876a07 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -62,7 +62,7 @@ public: /** * Start up a video */ - void setVideo(ASurface *vidSurface, const Common::Point &pt, FileIdent &videoFile, int rate); + void setVideo(ASurface *vidSurface, const Common::Point &pt, const FileIdent &videoFile, int rate); /** * Decodes a frame of the video -- cgit v1.2.3 From fb6d9230dc24d68b888ed4cefbf99bbf2fb60e3d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 13:43:11 -0400 Subject: ACCESS: Add missing table to savegames --- engines/access/access.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 1e3e3a7754..9b49b9f55c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -539,6 +539,9 @@ void AccessEngine::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_mapOffset); s.syncAsUint16LE(_screenVirtX); + for (int i = 0; i < 100; ++i) + s.syncAsByte(_establishTable[i]); + // Synchronize sub-objects _timers.synchronize(s); _inventory->synchronize(s); -- cgit v1.2.3 From 386aae3ffa60c9ef44181cb730ab947544b2e761 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 13:55:52 -0400 Subject: ACCESS: Workaround for background column rendering bug in original --- engines/access/room.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 2c597609e1..181dcd6c5b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -309,7 +309,10 @@ void Room::buildColumn(int playX, int screenX) { const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; - for (int y = 0; y <= _vm->_screen->_vWindowHeight; ++y) { + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int h = MIN(_vm->_screen->_vWindowHeight + 1, _playFieldHeight); + + for (int y = 0; y < h; ++y) { byte *pTile = _tile + (*pSrc << 8); byte *pDest = (byte *)_vm->_buffer1.getBasePtr(screenX, y * TILE_HEIGHT); -- cgit v1.2.3 From 21c1d0f920a530b310a68376e9aa8836ed43471b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 14:13:29 -0400 Subject: ACCESS: Workaround for background rendering bug in original --- engines/access/room.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 181dcd6c5b..9b830770af 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -289,14 +289,16 @@ void Room::setWallCodes() { void Room::buildScreen() { int scrollCol = _vm->_screen->_scrollCol; - int cnt = _vm->_screen->_vWindowWidth + 1; int offset = 0; // Clear current background buffer _vm->_buffer1.clearBuffer(); + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); + // Loop through drawing each column of tiles forming the background - for (int idx = 0; idx < cnt; offset += TILE_WIDTH, ++idx) { + for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) { buildColumn(_vm->_screen->_scrollCol, offset); ++_vm->_screen->_scrollCol; } -- cgit v1.2.3 From ae24bf54b43ab682f4e057c117810c1506b58d4d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 16:07:52 -0400 Subject: ACCESS: Fixes for startChapter --- engines/access/access.cpp | 4 ++-- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 7 ++++--- engines/access/amazon/amazon_resources.cpp | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 9b49b9f55c..fab66c3b6c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -432,8 +432,8 @@ void AccessEngine::copyBF2Vid() { } } -void AccessEngine::playVideo(int fileNum, const Common::Point &pt) { - _video->setVideo(_screen, pt, FileIdent(fileNum, 96), 10); +void AccessEngine::playVideo(int videoNum, const Common::Point &pt) { + _video->setVideo(_screen, pt, FileIdent(96, videoNum), 10); while (!shouldQuit() && !_video->_videoEnd) { _video->playVideo(); diff --git a/engines/access/access.h b/engines/access/access.h index a12a63212d..fcac69d56e 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -122,7 +122,7 @@ protected: /** * Play back an entire video */ - void playVideo(int fileNum, const Common::Point &pt); + void playVideo(int videoNum, const Common::Point &pt); // Engine APIs virtual Common::Error run(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 3af07edaf3..8270eaee6b 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -444,10 +444,10 @@ void AmazonEngine::startChapter(int chapter) { const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0]; _screen->plotImage(_objectsTable[0], _chapter - 1, Common::Point(chapImg[1], chapImg[2])); - _screen->plotImage(_objectsTable[_chapter - 1], 0, + _screen->plotImage(_objectsTable[_chapter], 0, Common::Point(chapImg[3], chapImg[4])); if (chapter == 14) - _screen->plotImage(_objectsTable[_chapter - 1], 1, Common::Point(169, 76)); + _screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76)); _sound->newMusic(chapImg[4], 1); _sound->newMusic(33, 0); @@ -485,12 +485,13 @@ void AmazonEngine::startChapter(int chapter) { _fonts._charSet._hi = 10; _fonts._charFor._lo = 55; _fonts._charFor._hi = 0xFF; + _screen->_maxChars = 43; _screen->_printOrg = Common::Point(31, 77); _screen->_printStart = Common::Point(31, 77); _establishGroup = 1; loadEstablish(0x40 + _chapter); - uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (_chapter * 2) + 2); + uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2); _printEnd = 170; _printEnd = 155; diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 05af0c116b..0807a979cc 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -48,7 +48,7 @@ const char *const FILENAMES[] = { "NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP", "NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP", "NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP", - "NARATE13.AP", "NARATE14.AP" + "NARATE13.AP", "NARATE14.AP", "S00.AP", "TAG.AP" }; const byte MOUSE0[] = { -- cgit v1.2.3 From 48edbf1e34993ee8eda7902197e1e6cdb33dce7b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 20:57:39 -0400 Subject: ACCESS: Fixed clearing talk bubbles during conversations --- engines/access/bubble_box.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index c4272b607a..d865d5c9b3 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -47,6 +47,15 @@ void BubbleBox::load(Common::SeekableReadStream *stream) { } void BubbleBox::clearBubbles() { + // Loop through the bubble list to restore the screen areas + for (uint i = 0; i < _bubbles.size(); ++i) { + _vm->_screen->_screenYOff = 0; + Common::Rect r = _bubbles[i]; + r.left -= 2; + _vm->_screen->copyBlock(&_vm->_buffer2, r); + } + + // Clear the list _bubbles.clear(); } @@ -56,7 +65,7 @@ void BubbleBox::placeBubble(const Common::String &msg) { } void BubbleBox::placeBubble1(const Common::String &msg) { - BubbleBox::clearBubbles(); + clearBubbles(); _vm->_fonts._charSet._lo = 1; _vm->_fonts._charSet._hi = 8; _vm->_fonts._charFor._lo = 29; -- cgit v1.2.3 From 7e4d76b1fb41662cd48e21d775322d2a0ad3325e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 20:58:13 -0400 Subject: ACCESS: Implemented cmdWait --- engines/access/scripts.cpp | 23 +++++++++++++++++++++-- engines/access/scripts.h | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 85c714f4a8..bed1a775f6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -127,7 +127,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, - &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::CMDWAIT, + &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, @@ -655,7 +655,26 @@ void Scripts::cmdTexChoice() { _vm->_bubbleBox->clearBubbles(); } -void Scripts::CMDWAIT() { error("TODO CMDWAIT"); } +void Scripts::cmdWait() { + int time = _data->readSint16LE(); + _vm->_timers[3]._timer = time; + _vm->_timers[3]._initTm = time; + _vm->_timers[3]._flag++; + _vm->_events->_keypresses.clear(); + + while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() && + !_vm->_events->_leftButton && !_vm->_events->_rightButton && + _vm->_timers[3]._flag) { + _vm->_sound->midiRepeat(); + charLoop(); + + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + _vm->_events->debounceLeft(); + _vm->_events->zeroKeys(); +} void Scripts::cmdSetConPos() { int x = _data->readSint16LE(); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index e6faa46dde..49c3b562b9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -106,7 +106,7 @@ protected: void cmdCharSpeak(); void cmdTexSpeak(); void cmdTexChoice(); - void CMDWAIT(); + void cmdWait(); void cmdSetConPos(); void CMDCHECKVFRAME(); void cmdJumpChoice(); -- cgit v1.2.3 From f3063a13f08a2b085d92d0a79231e568671501b3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 22:20:23 -0400 Subject: ACCESS: Implement palette cycling script commands --- engines/access/amazon/amazon_scripts.cpp | 6 ++--- engines/access/amazon/amazon_scripts.h | 2 +- engines/access/screen.cpp | 38 ++++++++++++++++++++++++++++++++ engines/access/screen.h | 9 ++++++++ engines/access/scripts.cpp | 14 +++++++++--- engines/access/scripts.h | 4 ++-- 6 files changed, 64 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7ad68bd5bc..0ea9ee5ebe 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -413,7 +413,7 @@ typedef void(AmazonScripts::*AmazonScriptMethodPtr)(); void AmazonScripts::executeCommand(int commandIndex) { static const AmazonScriptMethodPtr COMMAND_LIST[] = { - &AmazonScripts::cmdHelp, &AmazonScripts::CMDCYCLEBACK, + &AmazonScripts::cmdHelp, &AmazonScripts::cmdCycleBack, &AmazonScripts::cmdChapter, &AmazonScripts::cmdSetHelp, &AmazonScripts::cmdCenterPanel, &AmazonScripts::cmdMainPanel, &AmazonScripts::CMDRETFLASH @@ -449,8 +449,8 @@ void AmazonScripts::cmdHelp() { error("TODO: more cmdHelp"); } -void AmazonScripts::CMDCYCLEBACK() { - error("TODO CMDCYCLEBACK"); +void AmazonScripts::cmdCycleBack() { + _vm->_screen->cyclePaletteBackwards(); } void AmazonScripts::cmdChapter() { int chapter = _data->readByte(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index edb8843da3..694260ddcb 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -52,7 +52,7 @@ protected: void boatWalls(int param1, int param2); void cmdHelp(); - void CMDCYCLEBACK(); + void cmdCycleBack(); void cmdChapter(); void cmdSetHelp(); void cmdCenterPanel(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 227d9d7d0c..17f36fc072 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -59,6 +59,9 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _vWindowLinesTall = this->h; _clipWidth = _vWindowBytesWide - 1; _clipHeight = _vWindowLinesTall - 1; + _startCycle = 0; + _cycleStart = 0; + _endCycle = 0; } void Screen::clearScreen() { @@ -244,4 +247,39 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); } +void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { + _startCycle = _cycleStart = startCycle; + _endCycle = endCycle; + + TimerEntry &te = _vm->_timers[6]; + te._timer = te._initTm = timer; + te._flag++; +} + +void Screen::cyclePaletteForward() { + cyclePaletteBackwards(); +} + +void Screen::cyclePaletteBackwards() { + if (!_vm->_timers[6]._flag) { + _vm->_timers[6]._flag++; + byte *pStart = &_rawPalette[_cycleStart * 3]; + byte *pEnd = &_rawPalette[_endCycle * 3]; + + for (int idx = _startCycle; idx < _endCycle; ++idx) { + g_system->getPaletteManager()->setPalette(pStart, idx, 1); + + pStart += 3; + if (pStart == pEnd) + pStart = &_rawPalette[_cycleStart * 3]; + } + + if (--_cycleStart <= _startCycle) + _cycleStart = _endCycle - 1; + + g_system->updateScreen(); + g_system->delayMillis(10); + } +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index b278062d13..2db05a5f9d 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -60,6 +60,9 @@ private: Common::Point _virtualOffsetsTable[4]; bool _hideFlag; ScreenSave _screenSave; + int _startCycle; + int _cycleStart; + int _endCycle; void updatePalette(); public: @@ -150,6 +153,12 @@ public: * Restores previously saved screen display state variables */ void restoreScreen(); + + void setPaletteCycle(int startCycle, int endCycle, int timer); + + void cyclePaletteForward(); + + void cyclePaletteBackwards(); }; } // End of namespace Access diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bed1a775f6..2aa10b6b4a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -126,7 +126,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, - &Scripts::CMDSETCYCLE, &Scripts::CMDCYCLE, &Scripts::cmdCharSpeak, + &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, @@ -514,8 +514,16 @@ void Scripts::cmdSpecial() { } } -void Scripts::CMDSETCYCLE() { error("TODO CMDSETCYCLE"); } -void Scripts::CMDCYCLE() { error("TODO CMDCYCLE"); } +void Scripts::cmdSetCycle() { + int startCycle = _data->readUint16LE(); + int endCycle = _data->readUint16LE(); + int timer = _data->readUint16LE(); + _vm->_screen->setPaletteCycle(startCycle, endCycle, timer); +} + +void Scripts::cmdCycle() { + _vm->_screen->cyclePaletteForward(); +} void Scripts::cmdCharSpeak() { _vm->_screen->_printOrg = _charsOrg; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 49c3b562b9..f4128f4e31 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -101,8 +101,8 @@ protected: void CMDPLAYBUFVID(); void cmdRemoveLast(); void cmdSpecial(); - void CMDSETCYCLE(); - void CMDCYCLE(); + void cmdSetCycle(); + void cmdCycle(); void cmdCharSpeak(); void cmdTexSpeak(); void cmdTexChoice(); -- cgit v1.2.3 From c03845258843a7b0d1db792ea42a986bf79c917a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 1 Nov 2014 22:25:41 -0400 Subject: ACCESS: Add missing _startup checks to palette cycling opcodes --- engines/access/amazon/amazon_scripts.cpp | 5 +++-- engines/access/scripts.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 0ea9ee5ebe..3e7fd4e84e 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -449,8 +449,9 @@ void AmazonScripts::cmdHelp() { error("TODO: more cmdHelp"); } -void AmazonScripts::cmdCycleBack() { - _vm->_screen->cyclePaletteBackwards(); +void AmazonScripts::cmdCycleBack() { + if (_vm->_startup == -1) + _vm->_screen->cyclePaletteBackwards(); } void AmazonScripts::cmdChapter() { int chapter = _data->readByte(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2aa10b6b4a..c46d7b972f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -522,7 +522,8 @@ void Scripts::cmdSetCycle() { } void Scripts::cmdCycle() { - _vm->_screen->cyclePaletteForward(); + if (_vm->_startup == -1) + _vm->_screen->cyclePaletteForward(); } void Scripts::cmdCharSpeak() { -- cgit v1.2.3 From 335acfac892ab071d791db46161d5ca4c8868109 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Nov 2014 12:00:50 +0100 Subject: ACCESS: Implement newMusic() --- engines/access/sound.cpp | 18 +++++++++++++++++- engines/access/sound.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 90818ed5d3..072261dbf2 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -30,6 +30,7 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _music = nullptr; + _tempMusic = nullptr; _musicRepeat = false; _playingSound = false; _isVoice = false; @@ -37,6 +38,8 @@ SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : SoundManager::~SoundManager() { clearSounds(); + delete _music; + delete _tempMusic; } void SoundManager::clearSounds() { @@ -95,7 +98,20 @@ void SoundManager::freeSounds() { } void SoundManager::newMusic(int musicId, int mode) { - warning("TODO: newMusic"); + if (mode == 1) { + stopSong(); + freeMusic(); + _music = _tempMusic; + _tempMusic = nullptr; + _musicRepeat = true; + if (_music) + midiPlay(); + } else { + _musicRepeat = (mode == 2); + _tempMusic = _music; + stopSong(); + _music = loadSound(97, musicId); + } } void SoundManager::freeMusic() { diff --git a/engines/access/sound.h b/engines/access/sound.h index cc02229b3b..5c130661a7 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -46,6 +46,7 @@ public: Common::Array _soundTable; Common::Array _soundPriority; Resource *_music; + Resource *_tempMusic; bool _musicRepeat; bool _playingSound; bool _isVoice; -- cgit v1.2.3 From 2805dcaa7bcb315e124e0f2bab7218d834a05d99 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Nov 2014 14:42:16 +0100 Subject: ACCESS: Implement freeSounds --- engines/access/sound.cpp | 7 ++++++- engines/access/sound.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 072261dbf2..dd8cf16189 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -93,8 +93,13 @@ void SoundManager::stopSong() { // TODO } +void SoundManager::stopSound() { + // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG +} + void SoundManager::freeSounds() { - // TODO + stopSound(); + clearSounds(); } void SoundManager::newMusic(int musicId, int mode) { diff --git a/engines/access/sound.h b/engines/access/sound.h index 5c130661a7..c1b3981997 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -42,6 +42,8 @@ private: void clearSounds(); void playSound(Resource *res, int priority); + void stopSound(); + public: Common::Array _soundTable; Common::Array _soundPriority; -- cgit v1.2.3 From 7a178098a7139ee593872d551057a9892158158c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Nov 2014 14:43:02 +0100 Subject: ACCESS: Remove a useless check, comment out some code related to original debugging --- engines/access/player.cpp | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index b8eb08acd8..869467a590 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -259,9 +259,10 @@ void Player::walkUp() { _rawPlayerLow.y = _rawYTempL; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) { - warning("TODO: walkUp - si = 0?"); - } + + // This code looks totally useless as 'si' is unconditionally set in plotCom + //if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) + // warning("TODO: walkUp - si = 0?"); if (++_frame > _upWalkMax) _frame = _upWalkMin; @@ -288,9 +289,10 @@ void Player::walkDown() { _rawPlayerLow.y = _rawYTempL; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) { - warning("TODO: walkDown - si = 0?"); - } + + // This code looks totally useless as 'si' is unconditionally set in plotCom + //if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) + // warning("TODO: walkDown - si = 0?"); if (++_frame > _downWalkMax) _frame = _downWalkMin; @@ -329,9 +331,9 @@ void Player::walkLeft() { _rawPlayerLow.x = _rawTempL; ++_frame; - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkLeft - si = 0?"); - } + // This code looks totally useless as 'si' is unconditionally set in plotCom1 + //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) + // warning("TODO: walkLeft - si = 0?"); if (_frame > _sideWalkMax) _frame = _sideWalkMin; @@ -370,10 +372,7 @@ void Player::walkRight() { _rawPlayerLow.x = _rawTempL; ++_frame; - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkRight - si = 0?"); - } - + // Useless check removed if (_frame > _sideWalkMax) _frame = _sideWalkMin; @@ -421,9 +420,9 @@ void Player::walkUpLeft() { ++_frame; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkUpLeft - si = 0?"); - } + // This code looks totally useless as 'si' is unconditionally set in plotCom1 + //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) + // warning("TODO: walkUpLeft - si = 0?"); if (_frame > _diagUpWalkMax) _frame = _diagUpWalkMin; @@ -472,9 +471,9 @@ void Player::walkDownLeft() { ++_frame; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkDownLeft - si = 0?"); - } + // This code looks totally useless as 'si' is unconditionally set in plotCom1 + //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) + // warning("TODO: walkDownLeft - si = 0?"); if (_frame > _diagDownWalkMax) _frame = _diagDownWalkMin; @@ -523,9 +522,9 @@ void Player::walkUpRight() { ++_frame; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkUpRight - si = 0?"); - } + // This code looks totally useless as 'si' is unconditionally set in plotCom + //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) + // warning("TODO: walkUpRight - si = 0?"); if (_frame > _diagUpWalkMax) _frame = _diagUpWalkMin; @@ -575,9 +574,9 @@ void Player::walkDownRight() { ++_frame; calcManScale(); - if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) { - warning("TODO: walkDownRight - si = 0?"); - } + // This code looks totally useless as 'si' is unconditionally set in plotCom1 + //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) + // warning("TODO: walkDownRight - si = 0?"); if (_frame > _diagDownWalkMax) _frame = _diagDownWalkMin; -- cgit v1.2.3 From 32bbfe3f606b1d02ec9283c92ceb8c74264c3008 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Nov 2014 14:45:35 +0100 Subject: ACCESS: Fix a little bug in walkUpRight() --- engines/access/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 869467a590..ba5ba8924f 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -486,7 +486,7 @@ void Player::walkUpRight() { if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin) _frame = _diagUpWalkMin; - _playerDirection = UPLEFT; + _playerDirection = UPRIGHT; int walkOffset, tempL; bool flag = _scrollEnd == 1; -- cgit v1.2.3 From 958dd0b77bb7becc489d717806bbb96734901217 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 2 Nov 2014 18:02:54 +0100 Subject: ACCESS: Hood newMusic in cmdSpecial --- engines/access/amazon/amazon_scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 3e7fd4e84e..9ecaadd6aa 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -390,7 +390,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { guard(); break; case 10: - warning("TODO NEWMUSIC"); + _vm->_sound->newMusic(param1, param2); break; case 11: plotInactive(); -- cgit v1.2.3 From e46c0ac66a1fc94439264e4a07bbc92b09c03c07 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Nov 2014 16:28:06 -0500 Subject: ACCESS: Fix resetting cursor after conversations --- engines/access/access.cpp | 1 - engines/access/access.h | 1 - engines/access/amazon/amazon_room.cpp | 2 +- engines/access/martian/martian_room.cpp | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index fab66c3b6c..a3cadc1025 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -51,7 +51,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _destIn = nullptr; _current = nullptr; _pCount = 0; - _normalMouse = true; _mouseMode = 0; _currentMan = 0; _currentManOld = -1; diff --git a/engines/access/access.h b/engines/access/access.h index fcac69d56e..36951c7504 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -172,7 +172,6 @@ public: Common::Array _extraCells; ImageEntryList _images; int _pCount; - bool _normalMouse; int _mouseMode; int _currentManOld; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 39cea9ae62..098220ee0c 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -84,7 +84,7 @@ void AmazonRoom::reloadRoom1() { } _selectCommand = -1; - _vm->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_mouseMode = 0; _vm->_boxSelect = true; _vm->_player->_playerOff = false; diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index e624b0abd5..6d4d62f7e9 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -82,7 +82,7 @@ void MartianRoom::reloadRoom1() { } _selectCommand = -1; - _vm->_normalMouse = 1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_mouseMode = 0; _vm->_boxSelect = true; _vm->_player->_playerOff = false; -- cgit v1.2.3 From 38f010f96f3ba2ff1ff217912d196873ecc29877 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 3 Nov 2014 00:18:59 +0100 Subject: ACCESS: Implement mWhileFly --- engines/access/amazon/amazon_scripts.cpp | 87 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 3 ++ engines/access/events.h | 5 +- 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 9ecaadd6aa..a39b8ae6e2 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -205,13 +205,98 @@ void AmazonScripts::mWhile2() { } while (_vm->_flags[52] == 4); } +void AmazonScripts::doFlyCell() { + _game->_destIn = &_game->_buffer2; + if (_game->_plane._pCount <= 40) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 3, Common::Point(70, 74)); + } else if (_game->_plane._pCount <= 80) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 6, Common::Point(70, 74)); + } else if (_game->_plane._pCount <= 120) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 2, Common::Point(50, 76)); + } else if (_game->_plane._pCount <= 160) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 14, Common::Point(63, 78)); + } else if (_game->_plane._pCount <= 200) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 5, Common::Point(86, 74)); + } else if (_game->_plane._pCount <= 240) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 0, Common::Point(103, 76)); + } else if (_game->_plane._pCount <= 280) { + _vm->_screen->plotImage(_vm->_objectsTable[15], 4, Common::Point(119, 77)); + } else { + _vm->_screen->plotImage(_vm->_objectsTable[15], 1, Common::Point(111, 77)); + } +} + +void AmazonScripts::scrollFly() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + doFlyCell(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void AmazonScripts::mWhileFly() { + _vm->_events->hideCursor(); + _vm->_screen->clearScreen(); + _vm->_screen->setBufferScan(); + _vm->_screen->fadeOut(); + _vm->_screen->_scrollX = 0; + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->fadeIn(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + + // KEYFLG = 0; + + _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; + _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; + _vm->_player->_rawPlayer = Common::Point(0, 0); + _vm->_player->_scrollAmount = 1; + + _game->_plane._pCount = 0; + _game->_plane._planeCount = 0; + _game->_plane._propCount = 0; + _game->_plane._xCount = 0; + _game->_plane._position = Common::Point(20, 29); + + warning("FIXME: _vbCount should be handled in NEWTIMER"); + while (true) { + int _vbCount = 4; + if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) { + _vm->_events->showCursor(); + return; + } + + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_screen->_scrollX > TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } + + scrollFly(); + ++_game->_plane._pCount; + g_system->delayMillis(10); + + while(_vbCount > 0) { + // To be rewritten when NEWTIMER is done + _vm->_events->checkForNextFrameCounter(); + _vbCount--; + _vm->_sound->playSound(0); + } + } +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: mWhile1(); break; case 2: - warning("TODO FLY"); + mWhileFly(); break; case 3: warning("TODO FALL"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 694260ddcb..fb2c66f685 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -39,9 +39,12 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); + void doFlyCell(); + void scrollFly(); void cLoop(); void mWhile1(); void mWhile2(); + void mWhileFly(); void mWhile(int param1); void guardSee(); void setGuardFrame(); diff --git a/engines/access/events.h b/engines/access/events.h index 6b46086d9a..313a039831 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -47,9 +47,6 @@ private: uint32 _frameCounter; uint32 _priorFrameTime; Graphics::Surface _invCursor; - - bool checkForNextFrameCounter(); - void nextFrame(); public: CursorType _cursorId; @@ -119,6 +116,8 @@ public: void waitKeyMouse(); + bool checkForNextFrameCounter(); + Common::Point &getMousePos() { return _mousePos; } Common::Point calcRawMouse(); -- cgit v1.2.3 From 43e8e905906ad77f1a98efd255ee7589edff7518 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 2 Nov 2014 21:12:24 -0500 Subject: ACCESS: Don't show inventory items that have been used --- engines/access/inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 25c906056f..bb735d45a9 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -255,7 +255,7 @@ void InventoryManager::getList() { _tempLOff.clear(); for (uint i = 0; i < _inv.size(); ++i) { - if (_inv[i]) { + if (_inv[i] == 1) { _items.push_back(i); _tempLOff.push_back(_names[i]); } -- cgit v1.2.3 From d5ddd2268106d57c8f5cb84d1afd67f26a7a3ccc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 3 Nov 2014 20:29:09 +0100 Subject: ACCESS: Implement mWhileFall --- engines/access/amazon/amazon_scripts.cpp | 81 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 3 ++ 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index a39b8ae6e2..af619cb7e6 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -226,6 +226,27 @@ void AmazonScripts::doFlyCell() { } } +void AmazonScripts::doFallCell() { + if (_vm->_scaleI <= 0) + return; + + _game->_destIn = &_game->_buffer2; + + // 115, 11, i + _vm->_screen->plotImage(_vm->_objectsTable[20], _game->_plane._planeCount / 6, Common::Point(115, 11)); + _vm->_scaleI -= 3; + _vm->_scale = _vm->_scaleI; + _vm->_screen->setScaleTable(_vm->_scale); + ++_game->_plane._xCount; + if (_game->_plane._xCount == 5) + return; + _game->_plane._xCount = 0; + if (_game->_plane._planeCount == 18) + _game->_plane._planeCount = 0; + else + _game->_plane._planeCount += 6; +} + void AmazonScripts::scrollFly() { _vm->copyBF1BF2(); _vm->_newRects.clear(); @@ -234,6 +255,14 @@ void AmazonScripts::scrollFly() { _vm->copyBF2Vid(); } +void AmazonScripts::scrollFall() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + doFallCell(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + void AmazonScripts::mWhileFly() { _vm->_events->hideCursor(); _vm->_screen->clearScreen(); @@ -290,6 +319,56 @@ void AmazonScripts::mWhileFly() { } } +void AmazonScripts::mWhileFall() { + _vm->_events->hideCursor(); + _vm->_screen->clearScreen(); + _vm->_screen->setBufferScan(); + _vm->_screen->fadeOut(); + _vm->_screen->_scrollX = 0; + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->fadeIn(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + + // KEYFLG = 0; + + _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; + _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; + _vm->_player->_scrollAmount = 3; + _vm->_scaleI = 255; + + _game->_plane._xCount = 0; + _game->_plane._planeCount = 0; + + while (true) { + int _vbCount = 4; + if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) { + _vm->_events->showCursor(); + return; + } + + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_screen->_scrollX >= TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } + + scrollFall(); + g_system->delayMillis(10); + + while(_vbCount > 0) { + // To be rewritten when NEWTIMER is done + _vm->_events->checkForNextFrameCounter(); + _vbCount--; + } + } +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: @@ -299,7 +378,7 @@ void AmazonScripts::mWhile(int param1) { mWhileFly(); break; case 3: - warning("TODO FALL"); + mWhileFall(); break; case 4: warning("TODO JWALK"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index fb2c66f685..ca96de60d7 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -40,11 +40,14 @@ protected: virtual void executeCommand(int commandIndex); void doFlyCell(); + void doFallCell(); void scrollFly(); + void scrollFall(); void cLoop(); void mWhile1(); void mWhile2(); void mWhileFly(); + void mWhileFall(); void mWhile(int param1); void guardSee(); void setGuardFrame(); -- cgit v1.2.3 From a7d88af24d0a2c1e37b91f716ad85c8e7eb000c6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 3 Nov 2014 20:30:43 +0100 Subject: ACCESS: Fix tiny bug in mWhileFly --- engines/access/amazon/amazon_scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index af619cb7e6..688dbe0a30 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -298,7 +298,7 @@ void AmazonScripts::mWhileFly() { } _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX > TILE_WIDTH) { + while (_vm->_screen->_scrollX >= TILE_WIDTH) { _vm->_screen->_scrollX -= TILE_WIDTH; ++_vm->_screen->_scrollCol; -- cgit v1.2.3 From fb686191a813c633d215f06ca2aadbf3ad9c64ac Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 3 Nov 2014 21:51:11 -0500 Subject: ACCESS: Fix initialisation of Y positioning in rooms with vertical scrolling --- engines/access/room.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9b830770af..76ad29e21a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -267,14 +267,15 @@ void Room::setupRoom() { screen._scrollRow = 0; } else { screen._scrollY = _vm->_player->_rawPlayer.y - - (_vm->_player->_rawPlayer.y >> 4); - int yp = MAX((_vm->_player->_rawPlayer.y >> 4) - + (_vm->_player->_rawPlayer.y / 16) * 16; + int yc = MAX((_vm->_player->_rawPlayer.y >> 4) - (screen._vWindowHeight / 2), 0); - screen._scrollRow = yp; + screen._scrollRow = yc; - yp = yp + screen._vWindowHeight - _playFieldHeight; - if (yp >= 0) { - screen._scrollRow = yp + 1; + yc = yc + screen._vWindowHeight - _playFieldHeight; + if (yc >= 0) { + screen._scrollRow = _playFieldHeight - screen._vWindowHeight; + screen._scrollY = 0; } } } -- cgit v1.2.3 From 2c700cc6cd633b2a07ae5b10c803fb7b7321413c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 4 Nov 2014 23:57:51 +0100 Subject: ACCESS: Start implementing mWhileJWalk() --- engines/access/amazon/amazon_scripts.cpp | 112 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 22 ++++++ engines/access/player.h | 7 +- 3 files changed, 137 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 688dbe0a30..d2370a2fd1 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -32,6 +32,27 @@ namespace Amazon { AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _game = (AmazonEngine *)_vm; + + _xTrack = 0; + _yTrack = 0; + _zTrack = 0; + _xCam = 0; + _yCam = 0; + _zCam = 0; + + _pNumObj = 0; + for (int i = 0; i < 32; i++) { + _pImgNum[i] = 0; + _pObject[i] = nullptr; + _pObjX[i] = 0; + _pObjY[i] = 0; + _pObjZ[i] = 0; + } + + for (int i = 0; i < 16; i++) { + _pObjXl[i] = 0; + _pObjYl[i] = 0; + } } void AmazonScripts::cLoop() { @@ -247,6 +268,10 @@ void AmazonScripts::doFallCell() { _game->_plane._planeCount += 6; } +void AmazonScripts::PAN() { + warning("TODO: PAN"); +} + void AmazonScripts::scrollFly() { _vm->copyBF1BF2(); _vm->_newRects.clear(); @@ -263,6 +288,14 @@ void AmazonScripts::scrollFall() { _vm->copyBF2Vid(); } +void AmazonScripts::scrollJWalk() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + _game->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + void AmazonScripts::mWhileFly() { _vm->_events->hideCursor(); _vm->_screen->clearScreen(); @@ -369,6 +402,83 @@ void AmazonScripts::mWhileFall() { } } +void AmazonScripts::mWhileJWalk() { + const int jungleObj[7][4] = { + {2, 77, 0, 40}, + {0, 290, 0, 50}, + {1, 210, 0, 70}, + {0, 50, 0, 30}, + {1, 70, 0, 20}, + {0, -280, 0, 60}, + {1, -150, 0, 30}, + }; + + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + _vm->_screen->clearScreen(); + _vm->_buffer2.clearBuffer(); + _vm->_screen->setBufferScan(); + _vm->_screen->_scrollX = 0; + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->fadeIn(); + + // KEYFLG = 0; + _vm->_player->_xFlag = 1; + _vm->_player->_yFlag = 0; + _vm->_player->_moveTo.x = 160; + _vm->_player->_move = UP; + + _game->_plane._xCount = 2; + _xTrack = 10; + _yTrack = _zTrack = 0; + _xCam = 480; + _yCam = 0; + _zCam = 80; + + TimerEntry *te = &_vm->_timers[24]; + te->_initTm = te->_timer = 1; + te->_flag++; + + _pNumObj = 7; + for (int i = 0; i < _pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[24]; + _pImgNum[i] = jungleObj[i][0]; + _pObjX[i] = jungleObj[i][1]; + _pObjY[i] = jungleObj[i][2]; + _pObjZ[i] = jungleObj[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } + + while (true) { + _vm->_images.clear(); + int _vbCount = 6; + if (_vm->_player->_xFlag == 2) { + _vm->_events->showCursor(); + return; + } + + _pImgNum[0] = _game->_plane._xCount; + if (_game->_plane._xCount == 2) + ++_game->_plane._xCount; + else + --_game->_plane._xCount; + + _vm->_player->checkMove(); + _vm->_player->checkScroll(); + PAN(); + scrollJWalk(); + + g_system->delayMillis(10); + while(_vbCount > 0) { + // To be rewritten when NEWTIMER is done + _vm->_events->checkForNextFrameCounter(); + _vbCount--; + } + } +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: @@ -381,7 +491,7 @@ void AmazonScripts::mWhile(int param1) { mWhileFall(); break; case 4: - warning("TODO JWALK"); + mWhileJWalk(); break; case 5: warning("TODO DOOPEN"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index ca96de60d7..50fab5caaf 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -35,6 +35,26 @@ class AmazonEngine; class AmazonScripts: public Scripts { private: AmazonEngine *_game; + + int _xTrack; + int _yTrack; + int _zTrack; + int _xCam; + int _yCam; + int _zCam; + + int _pNumObj; + int _pImgNum[32]; + SpriteResource *_pObject[32]; + + int _pObjX[32]; + int _pObjY[32]; + int _pObjZ[32]; + int _pObjXl[16]; + int _pObjYl[16]; + + void PAN(); + protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); @@ -43,11 +63,13 @@ protected: void doFallCell(); void scrollFly(); void scrollFall(); + void scrollJWalk(); void cLoop(); void mWhile1(); void mWhile2(); void mWhileFly(); void mWhileFall(); + void mWhileJWalk(); void mWhile(int param1); void guardSee(); void setGuardFrame(); diff --git a/engines/access/player.h b/engines/access/player.h index c5c9afa087..ed48af0932 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -49,14 +49,11 @@ private: int _diagUpWalkMin, _diagUpWalkMax; int _diagDownWalkMin, _diagDownWalkMax; Common::Point _guard; - Direction _move; - int _xFlag, _yFlag; SpriteResource *_playerSprites1; byte *_manPal1; int _scrollEnd; int _inactiveYOff; - void checkMove(); void plotCom(int v1); void plotCom1(); void plotCom2(); @@ -97,6 +94,8 @@ public: int _playerYLow; int _playerY; int _frame; + int _xFlag, _yFlag; + Direction _move; // Additional public globals we've added to new Player class bool _playerOff; @@ -129,6 +128,8 @@ public: void checkScroll(); + void checkMove(); + /** * Synchronize savegame data */ -- cgit v1.2.3 From b8c95e653dab6a82926effe772b03eb6770e6083 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 5 Nov 2014 08:34:59 +0100 Subject: ACCESS: Implement pan() --- engines/access/amazon/amazon_scripts.cpp | 30 +++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d2370a2fd1..2b489d678e 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -268,8 +268,32 @@ void AmazonScripts::doFallCell() { _game->_plane._planeCount += 6; } -void AmazonScripts::PAN() { - warning("TODO: PAN"); +void AmazonScripts::pan() { + _zCam += _zTrack; + _xCam += _xTrack; + int tx = (_xCam << 8) / _zCam; + _yCam += _yTrack; + int ty = (_yCam << 8) / _zCam; + + if (_vm->_timers[24]._flag != 1) { + ++_vm->_timers[24]._flag; + for (int i = 0; i < _pNumObj; i++) { + _pObjZ[i] = _zTrack; + _pObjXl[i] += tx * _zTrack; + _pObjX[i] += _pObjXl[i]; + _pObjYl[i] += ty * _zTrack; + _pObjY[i] += _pObjYl[i]; + } + } + + for (int i = 0; i < _pNumObj; i++) { + ImageEntry ie; + ie._flags= 8; + ie._position = Common::Point(_pObjX[i], _pObjY[i]); + ie._offsetY = 0xFF; + ie._spritesPtr = _pObject[i]; + ie._frameNumber = _pImgNum[i]; + } } void AmazonScripts::scrollFly() { @@ -467,7 +491,7 @@ void AmazonScripts::mWhileJWalk() { _vm->_player->checkMove(); _vm->_player->checkScroll(); - PAN(); + pan(); scrollJWalk(); g_system->delayMillis(10); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 50fab5caaf..1ee8b98e05 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -53,7 +53,7 @@ private: int _pObjXl[16]; int _pObjYl[16]; - void PAN(); + void pan(); protected: virtual void executeSpecial(int commandIndex, int param1, int param2); -- cgit v1.2.3 From 6ceda069c7042bc081845d3a52f99e21a58c43d8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Nov 2014 22:32:12 -0500 Subject: ACCESS: Beginnings of inventory dragging for combining items --- engines/access/amazon/amazon_resources.cpp | 88 +++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 2 + engines/access/events.cpp | 13 ++++ engines/access/events.h | 2 + engines/access/inventory.cpp | 100 +++++++++++++++++++++++++++-- engines/access/inventory.h | 18 +++++- engines/access/scripts.cpp | 20 ++---- engines/access/scripts.h | 2 - 8 files changed, 218 insertions(+), 27 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 0807a979cc..c2eab7b5c2 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1352,6 +1352,94 @@ const int CHAPTER_JUMP[14] = { 0, 12, 10, 15, 19, 25, 31, 36, 45, 46, 29, 55, 61, 0 }; +const int COMBO_TABLE[85][4] = { + { -1, -1, -1, -1 }, + { 12, 3, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 24, 25, -1, -1 }, + { 10, 24, -1, -1 }, + { -1, -1, -1, -1 }, + { 8, 24, -1, -1 }, + { -1, -1, -1, -1 }, + { 1, 3, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 7, 25, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 80, 81, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 41, 42, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 39, 40, -1, -1 }, + { 38, 40, -1, -1 }, + { -1, -1, -1, -1 }, + { 32, 42, 77, 78 }, + { -1, -1, -1, -1 }, + { 60, 61, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 73, 72, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 64, 67, -1, -1 }, + { -1, -1, -1, -1 }, + { 59, 60, -1, -1 }, + { 58, 60, -1, -1 }, + { 43, 61, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 56, 67, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 50, 72, -1, -1 }, + { 75, 77, -1, -1 }, + { 74, 77, -1, -1 }, + { -1, -1, -1, -1 }, + { 41, 78, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { 29, 81, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 } +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index d8d37b5a5f..2be9b4dd4b 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -64,6 +64,8 @@ extern const int CHAPTER_TABLE[14][5]; extern const int CHAPTER_JUMP[14]; +extern const int COMBO_TABLE[85][4]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 0a754305b2..0b7a34841e 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -250,5 +250,18 @@ Common::Point EventsManager::calcRawMouse() { return pt; } +int EventsManager::checkMouseBox1(Common::Array &rects) { + int i = 0; + for (i = 0;; i++) { + if (rects[i].left == -1) + return -1; + + if ((_mousePos.x > rects[i].left) && (_mousePos.x < rects[i].right) + && (_mousePos.y > rects[i].top) && (_mousePos.y < rects[i].bottom)) + return i; + } +} + + } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index 313a039831..b29b54159e 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -121,6 +121,8 @@ public: Common::Point &getMousePos() { return _mousePos; } Common::Point calcRawMouse(); + + int checkMouseBox1(Common::Array &rects); }; } // End of namespace Access diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index bb735d45a9..f31379a2fa 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -28,6 +28,26 @@ namespace Access { +void InventoryEntry::load(const Common::String &name, const int *data) { + _value = 0; + _name = name; + _otherItem1 = *data++; + _newItem1 = *data++; + _otherItem2 = *data++; + _newItem2 = *data; +} + +int InventoryEntry::checkItem(int itemId) { + if (_otherItem1 == itemId) + return _newItem1; + else if (_otherItem2 == itemId) + return _newItem2; + else + return -1; +} + +/*------------------------------------------------------------------------*/ + InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _startInvItem = 0; _startInvBox = 0; @@ -39,9 +59,12 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _iconDisplayFlag = true; const char *const *names; + const int *combineP; + switch (vm->getGameID()) { case GType_Amazon: names = Amazon::INVENTORY_NAMES; + combineP = &Amazon::COMBO_TABLE[0][0]; _inv.resize(85); break; case GType_MartianMemorandum: @@ -52,8 +75,9 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { error("Unknown game"); } - for (uint i = 0; i < _inv.size(); ++i) - _names.push_back(names[i]); + for (uint i = 0; i < _inv.size(); ++i, combineP += 4) { + _inv[i].load(names[i], combineP); + } for (uint i = 0; i < 26; ++i) { const int *r = INVCOORDS[i]; @@ -62,7 +86,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { } int &InventoryManager::operator[](int idx) { - return _inv[idx]; + return _inv[idx]._value; } int InventoryManager::useItem() { @@ -255,9 +279,9 @@ void InventoryManager::getList() { _tempLOff.clear(); for (uint i = 0; i < _inv.size(); ++i) { - if (_inv[i] == 1) { + if (_inv[i]._value == 1) { _items.push_back(i); - _tempLOff.push_back(_names[i]); + _tempLOff.push_back(_inv[i]._name); } } } @@ -351,7 +375,69 @@ void InventoryManager::outlineIcon(int itemIndex) { } void InventoryManager::combineItems() { - warning("TODO: combineItems"); + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + screen._leftSkip = screen._rightSkip = 0; + screen._topSkip = screen._bottomSkip = 0; + screen._screenYOff = 0; + + Common::Point tempMouse = events._mousePos; + Common::Point lastMouse = events._mousePos; + + Common::Rect &inv = _invCoords[_boxNum]; + Common::Rect r(inv.left, inv.top, inv.left + 46, inv.top + 35); + Common::Point tempBox(inv.left, inv.top); + Common::Point lastBox(inv.left, inv.top); + + _vm->_buffer2.copyBlock(&_vm->_buffer1, r); + SpriteResource *sprites = _vm->_objectsTable[99]; + int invItem = _items[_boxNum]; + events.pollEvents(); + + // Item drag handling loop + while (!_vm->shouldQuit() && events._leftButton) { + // Poll for events + events.pollEvents(); + g_system->delayMillis(10); + + // Check positioning + if (lastMouse == events._mousePos) + continue; + + lastMouse = events._mousePos; + Common::Rect lastRect(lastBox.x, lastBox.y, lastBox.x + 46, lastBox.y + 35); + screen.copyBlock(&_vm->_buffer2, lastRect); + + int xp = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0); + int yp = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0); + screen.plotImage(sprites, invItem, Common::Point(xp, yp)); + } + + int destBox = events.checkMouseBox1(_invCoords); + if (destBox >= 0 && destBox != _boxNum && destBox < _items.size() + && _items[destBox] != -1) { + int itemA = invItem; + int itemB = _items[destBox]; + + // Check whether the items can be combined + int combinedItem = _inv[itemA].checkItem(itemB); + if (combinedItem != -1) { + _inv[combinedItem]._value = 1; + _inv[itemA]._value = 2; + _inv[itemB]._value = 2; + _items[_boxNum] = -1; + _items[destBox] = combinedItem; + _tempLOff[destBox] = _inv[combinedItem]._name; + + // TODO: zoomIcon calls? + + _boxNum = destBox; + return; + } + } + + _iconDisplayFlag = true; + putInvIcon(_boxNum, invItem); } void InventoryManager::synchronize(Common::Serializer &s) { @@ -362,7 +448,7 @@ void InventoryManager::synchronize(Common::Serializer &s) { _inv.resize(count); for (int i = 0; i < count; ++i) - s.syncAsUint16LE((*this)[i]); + s.syncAsUint16LE(_inv[i]._value); } } // End of namespace Access diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 0ff9020250..eff142c9c9 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -32,6 +32,21 @@ namespace Access { +class InventoryEntry { +public: + Common::String _name; + int _value; + + int _otherItem1; + int _newItem1; + int _otherItem2; + int _newItem2; + + void load(const Common::String &name, const int *data); + + int checkItem(int itemId); +}; + class InventoryManager : public Manager { struct SavedFields { int _vWindowHeight; @@ -58,7 +73,6 @@ private: ASurface _savedScreen; SavedFields _fields; bool _iconDisplayFlag; - Common::StringArray _names; Common::Array _tempLPtr; Common::StringArray _tempLOff; int _boxNum; @@ -89,7 +103,7 @@ private: void combineItems(); public: - Common::Array _inv; + Common::Array _inv; int _startInvItem; int _startInvBox; bool _invChangeFlag; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index c46d7b972f..6c4c37491f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -554,18 +554,6 @@ void Scripts::cmdTexSpeak() { findNull(); } -int Scripts::checkMouseBox1(Common::Rect *rectArr) { - int i = 0; - for (i = 0; ; i++){ - if (rectArr[i].left == -1) - return -1; - - if ((_vm->_events->_mousePos.x > rectArr[i].left) && (_vm->_events->_mousePos.x < rectArr[i].right) - && (_vm->_events->_mousePos.y > rectArr[i].top) && (_vm->_events->_mousePos.y < rectArr[i].bottom)) - return i; - } -} - void Scripts::cmdTexChoice() { static Common::Point cMouse[7] = { Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232), @@ -595,9 +583,9 @@ void Scripts::cmdTexChoice() { _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); - Common::Rect responseCoords[2]; - responseCoords[0] = _vm->_bubbleBox->_bounds; - responseCoords[1] = Common::Rect(0, 0, 0, 0); + Common::Array responseCoords; + responseCoords.push_back(_vm->_bubbleBox->_bounds); + responseCoords.push_back(Common::Rect(0, 0, 0, 0)); _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; findNull(); @@ -655,7 +643,7 @@ void Scripts::cmdTexChoice() { } } else { _vm->_events->debounceLeft(); - choice = checkMouseBox1(responseCoords); + choice = _vm->_events->checkMouseBox1(responseCoords); } } } while ((choice == -1) || ((choice == 2) && choice3Fl)); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index f4128f4e31..ab80c1cd9f 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -44,8 +44,6 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); - int checkMouseBox1(Common::Rect *rectArr); - /** * Print a given message to the screen in a bubble box */ -- cgit v1.2.3 From b0653e1c924650c86edd220a37786c82faaeb11e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 5 Nov 2014 22:40:52 -0500 Subject: ACCESS: Fix redrawing during inventory item dragging --- engines/access/inventory.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index f31379a2fa..86e73c1cec 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -394,7 +394,7 @@ void InventoryManager::combineItems() { int invItem = _items[_boxNum]; events.pollEvents(); - // Item drag handling loop + // Item drag handling loop if left button is held down while (!_vm->shouldQuit() && events._leftButton) { // Poll for events events.pollEvents(); @@ -408,9 +408,12 @@ void InventoryManager::combineItems() { Common::Rect lastRect(lastBox.x, lastBox.y, lastBox.x + 46, lastBox.y + 35); screen.copyBlock(&_vm->_buffer2, lastRect); - int xp = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0); - int yp = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0); - screen.plotImage(sprites, invItem, Common::Point(xp, yp)); + Common::Point newPt; + newPt.x = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0); + newPt.y = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0); + + screen.plotImage(sprites, invItem, newPt); + lastBox = newPt; } int destBox = events.checkMouseBox1(_invCoords); -- cgit v1.2.3 From b5ad2b9db52e4184829c02830a9d2b22b6f85dde Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Nov 2014 21:52:05 -0500 Subject: ACCESS: Inventory item merge zoom partially working --- engines/access/inventory.cpp | 61 +++++++++++++++++++++++++++++++++++++++++--- engines/access/inventory.h | 2 ++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 86e73c1cec..2dc73a2864 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -308,10 +308,11 @@ void InventoryManager::chooseItem() { int selIndex; while (!_vm->shouldQuit()) { + // Check for events + events.pollEvents(); g_system->delayMillis(10); // Poll events and wait for a click on a known area - events.pollEvents(); if (!events._leftButton || ((selIndex = coordIndexOf()) == -1)) continue; @@ -319,7 +320,7 @@ void InventoryManager::chooseItem() { if (selIndex == 25) _vm->_useItem = -1; break; - } else if (selIndex < (int)_items.size()) { + } else if (selIndex < (int)_items.size() && _items[selIndex] != -1) { _boxNum = selIndex; _vm->copyBF2Vid(); combineItems(); @@ -417,7 +418,7 @@ void InventoryManager::combineItems() { } int destBox = events.checkMouseBox1(_invCoords); - if (destBox >= 0 && destBox != _boxNum && destBox < _items.size() + if (destBox >= 0 && destBox != _boxNum && destBox < (int)_items.size() && _items[destBox] != -1) { int itemA = invItem; int itemB = _items[destBox]; @@ -432,9 +433,19 @@ void InventoryManager::combineItems() { _items[destBox] = combinedItem; _tempLOff[destBox] = _inv[combinedItem]._name; - // TODO: zoomIcon calls? + // Zoom out the old two items and zoom in the new combined item + events.hideCursor(); + zoomIcon(itemA, itemB, destBox, true); + Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top, + _invCoords[destBox].left + 46, _invCoords[destBox].top + 35); + _vm->_buffer2.copyBlock(&_vm->_buffer1, destRect); + screen._screenYOff = 0; + + zoomIcon(itemB, -1, destBox, true); + zoomIcon(combinedItem, -1, destBox, false); _boxNum = destBox; + events.showCursor(); return; } } @@ -443,6 +454,48 @@ void InventoryManager::combineItems() { putInvIcon(_boxNum, invItem); } +void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink) { + Screen &screen = *_vm->_screen; + screen._screenYOff = 0; + SpriteResource *sprites = _vm->_objectsTable[99]; + + int8 zoomScale = shrink ? -1 : 1; + int8 zoomInc = shrink ? -1 : 1; + Common::Rect boxRect(_invCoords[zoomBox].left, _invCoords[zoomBox].top, + _invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35); + + while (!_vm->shouldQuit() && zoomScale != 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(5); + + _vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect); + if (backItem != -1) { + _iconDisplayFlag = false; + putInvIcon(zoomBox, backItem); + } + + _vm->_scale = zoomScale; + screen.setScaleTable(zoomScale); + + int xv = screen._scaleTable1[boxRect.width() + 1]; + if (xv) { + int yv = screen._scaleTable1[boxRect.height() + 1]; + if (yv) { + // The zoomed size is positive in both directions, so show zoomed item + Common::Rect scaledBox(xv, yv); + scaledBox.moveTo(boxRect.left + (boxRect.width() - xv + 1) / 2, + boxRect.top + (boxRect.height() - yv + 1) / 2); + + _vm->_buffer2.sPlotF(sprites->getFrame(zoomItem), scaledBox); + } + } + + screen.copyBlock(&_vm->_buffer2, boxRect); + + zoomScale += zoomInc; + } +} + void InventoryManager::synchronize(Common::Serializer &s) { int count = _inv.size(); s.syncAsUint16LE(count); diff --git a/engines/access/inventory.h b/engines/access/inventory.h index eff142c9c9..f2b1f5e182 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -102,6 +102,8 @@ private: void outlineIcon(int itemIndex); void combineItems(); + + void zoomIcon(int zoomItem, int backItem, int zoomBox, bool shrink); public: Common::Array _inv; int _startInvItem; -- cgit v1.2.3 From 0a8b8d9e94bea66834c102edeeb8b6c5374423ed Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 6 Nov 2014 22:33:56 -0500 Subject: ACCESS: Fix inventory item combining zoom logic --- engines/access/inventory.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 2dc73a2864..1b81b6badf 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -432,16 +432,19 @@ void InventoryManager::combineItems() { _items[_boxNum] = -1; _items[destBox] = combinedItem; _tempLOff[destBox] = _inv[combinedItem]._name; - - // Zoom out the old two items and zoom in the new combined item events.hideCursor(); + + // Shrink down the first item on top of the second item zoomIcon(itemA, itemB, destBox, true); + + // Shrink down the second item Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top, _invCoords[destBox].left + 46, _invCoords[destBox].top + 35); _vm->_buffer2.copyBlock(&_vm->_buffer1, destRect); - screen._screenYOff = 0; - + screen._screenYOff = 0; zoomIcon(itemB, -1, destBox, true); + + // Exand up the new combined item from nothing to full size zoomIcon(combinedItem, -1, destBox, false); _boxNum = destBox; @@ -459,12 +462,13 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh screen._screenYOff = 0; SpriteResource *sprites = _vm->_objectsTable[99]; - int8 zoomScale = shrink ? -1 : 1; - int8 zoomInc = shrink ? -1 : 1; + int oldScale = _vm->_scale; + int zoomScale = shrink ? 255 : 1; + int zoomInc = shrink ? -1 : 1; Common::Rect boxRect(_invCoords[zoomBox].left, _invCoords[zoomBox].top, _invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35); - while (!_vm->shouldQuit() && zoomScale != 0) { + while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) { _vm->_events->pollEvents(); g_system->delayMillis(5); @@ -494,6 +498,17 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh zoomScale += zoomInc; } + + if (!shrink) { + // Handle the final full-size version + _vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect); + _vm->_buffer2.plotImage(sprites, zoomItem, + Common::Point(boxRect.left, boxRect.top)); + screen.copyBlock(&_vm->_buffer2, boxRect); + } + + _vm->_scale = oldScale; + screen.setScaleTable(oldScale); } void InventoryManager::synchronize(Common::Serializer &s) { -- cgit v1.2.3 From 8a31fca61efa4a97097a499e1f42e57f631fe678 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 7 Nov 2014 23:38:05 +0100 Subject: ACCESS: Implement mWhileDoOpen --- engines/access/amazon/amazon_game.h | 5 +- engines/access/amazon/amazon_scripts.cpp | 115 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 1 + 3 files changed, 117 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 2dc0c058fb..653deefb96 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -54,8 +54,6 @@ public: class AmazonEngine : public AccessEngine { private: - bool _skipStart; - // Fields that are included in savegames int _canoeLane; int _canoeYPos; @@ -99,7 +97,6 @@ private: void loadEstablish(int estabIndex); void doEstablish(int screenId, int estabIndex); - void establishCenter(int screenId, int esatabIndex); protected: /** @@ -113,6 +110,7 @@ protected: virtual void synchronize(Common::Serializer &s); public: bool _charSegSwitch; + bool _skipStart; int _rawInactiveX; int _rawInactiveY; @@ -162,6 +160,7 @@ public: void tileScreen(); void updateSummary(int chap); + void establishCenter(int screenId, int esatabIndex); /** * Show the start of a chapter diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 2b489d678e..5d9f2d9436 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -503,6 +503,119 @@ void AmazonScripts::mWhileJWalk() { } } +void AmazonScripts::mWhileDoOpen() { + const int openObj[10][4] = { + {8, -80, 120, 30}, + {13, 229, 0, 50}, + {12, 78, 0, 50}, + {11, 10, 0, 50}, + {10, 178, 97, 50}, + {9, 92, 192, 50}, + {14, 38, 0, 100}, + {15, 132, 76, 100}, + {16, 142, 0, 100}, + {4, -280, 40, 120}, + }; + + _vm->_screen->setBufferScan(); + _vm->_events->hideCursor(); + _vm->_screen->forceFadeOut(); + _game->_skipStart = false; + if (_vm->_conversation != 2) { + _vm->_screen->setPanel(3); + _game->startChapter(1); + _game->establishCenter(0, 1); + } + + Resource *data = _vm->_files->loadFile(0, 1); + SpriteResource *spr = new SpriteResource(_vm, data); + delete data; + + _vm->_objectsTable[1] = spr; + _vm->_files->_loadPalFlag = false; + _vm->_files->loadScreen(1, 2); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + warning("TODO _roomInfo = _vm->_files->loadFile(1, 1);"); + + _xTrack = 8; + _yTrack = -3; + _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 270; + _vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + _pNumObj = 10; + + for (int i = 0; i < _pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[1]; + _pImgNum[i] = openObj[i][0]; + _pObjX[i] = openObj[i][1]; + _pObjY[i] = openObj[i][2]; + _pObjZ[i] = openObj[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } + + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + Animation *anim = _vm->_animation->setAnimation(0); + _vm->_animation->setAnimTimer(anim); + anim = _vm->_animation->setAnimation(1); + _vm->_animation->setAnimTimer(anim); + _vm->_sound->newMusic(10, 0); + + bool startFl = false; + while (true) { + _vm->_images.clear(); + _vm->_animation->animate(0); + _vm->_animation->animate(1); + pan(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_newRects.clear(); + _game->plotList(); + _vm->copyBlocks(); + if (!startFl) { + startFl = true; + _vm->_screen->forceFadeIn(); + } + _vm->_events->pollEvents(); + warning("TODO: check on KEYBUFCNT"); + if (_vm->_events->_leftButton || _vm->_events->_rightButton) { + _game->_skipStart = true; + _vm->_sound->newMusic(10, 1); + break; + } + + if (_xCam > 680) { + warning("FIXME: _vbCount should be handled in NEWTIMER"); + int _vbCount = 125; + while(_vbCount > 0) { + // To be rewritten when NEWTIMER is done + _vm->_events->checkForNextFrameCounter(); + _vbCount--; + } + break; + } + } + + _vm->_events->showCursor(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + warning("TODO: delete _roomInfo;"); + _vm->freeCells(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + _vm->_images.clear(); + if (_vm->_conversation == 2) { + Resource *spriteData = _vm->_files->loadFile(28, 37); + _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData); + delete spriteData; + warning("TODO: _roomInfo = _vm->_files->loadFile(28, 38);"); + } +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: @@ -518,7 +631,7 @@ void AmazonScripts::mWhile(int param1) { mWhileJWalk(); break; case 5: - warning("TODO DOOPEN"); + mWhileDoOpen(); break; case 6: warning("TODO DOWNRIVER"); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 1ee8b98e05..06ed6e5d01 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -70,6 +70,7 @@ protected: void mWhileFly(); void mWhileFall(); void mWhileJWalk(); + void mWhileDoOpen(); void mWhile(int param1); void guardSee(); void setGuardFrame(); -- cgit v1.2.3 From 47304849c7c24fd9809f6e854f18354f95773980 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 21:17:00 -0500 Subject: ACCESS: Fix malformed inventory item description --- engines/access/amazon/amazon_resources.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index c2eab7b5c2..e60da5b0ff 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -990,7 +990,7 @@ const char *const INVENTORY_NAMES[] = { "RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM", "VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY", "DARTS", "TAPE", "JUNGLE POTION", "MOVIE", "CABINET KEY", - "DISPLAY CASE KEY", "FLITCH', 27h, 'S CAR KEYS", "COAT HANGER", + "DISPLAY CASE KEY", "FLITCH'S CAR KEYS", "COAT HANGER", "CROWBAR", "COMPASS", "MAP", "LETTER OPENER", "LETTER", "DECODER", "DIPPED DART", "LOADED BLOWGUN", "CARD", "JERRYCAN", "CIGARETTES", "BIKE PUMP", "PARACHUTE", "PESO", "PEPPERS", -- cgit v1.2.3 From 712261f02a84700ed014b2e2e16a0f13e2c6f93c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 21:26:40 -0500 Subject: ACCESS: Fix entire inventory disappearing after combining items --- engines/access/inventory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 1b81b6badf..f465432096 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -287,6 +287,8 @@ void InventoryManager::getList() { } void InventoryManager::showAllItems() { + _iconDisplayFlag = true; + for (uint i = 0; i < _items.size(); ++i) putInvIcon(i, _items[i]); } -- cgit v1.2.3 From 63bacba2d906f650e702ba544c5a49528452b5b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 21:29:21 -0500 Subject: ACCESS: Add enum for inventory item states --- engines/access/inventory.cpp | 4 ++-- engines/access/inventory.h | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index f465432096..45738462df 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -29,7 +29,7 @@ namespace Access { void InventoryEntry::load(const Common::String &name, const int *data) { - _value = 0; + _value = ITEM_NOT_FOUND; _name = name; _otherItem1 = *data++; _newItem1 = *data++; @@ -279,7 +279,7 @@ void InventoryManager::getList() { _tempLOff.clear(); for (uint i = 0; i < _inv.size(); ++i) { - if (_inv[i]._value == 1) { + if (_inv[i]._value == ITEM_IN_INVENTORY) { _items.push_back(i); _tempLOff.push_back(_inv[i]._name); } diff --git a/engines/access/inventory.h b/engines/access/inventory.h index f2b1f5e182..820b15b40f 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -32,6 +32,10 @@ namespace Access { +enum ItemState { + ITEM_NOT_FOUND = 0, ITEM_IN_INVENTORY = 1, ITEM_USED = 2 +}; + class InventoryEntry { public: Common::String _name; -- cgit v1.2.3 From dc218d53ef9d9b6de11e26e1b793204d416fc9db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 22:09:09 -0500 Subject: ACCESS: Merge the sound resource and priority lists --- engines/access/access.cpp | 10 ++++++---- engines/access/amazon/amazon_game.cpp | 10 +++------- engines/access/amazon/amazon_scripts.cpp | 1 - engines/access/martian/martian_game.cpp | 1 - engines/access/scripts.cpp | 14 ++++++-------- engines/access/sound.cpp | 19 +++++++++++-------- engines/access/sound.h | 11 +++++++++-- 7 files changed, 35 insertions(+), 31 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a3cadc1025..f04a5dec88 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -245,8 +245,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->waitKeyMouse(); } else { for (;;) { - _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundPriority[0] = 1; + _sound->freeSounds(); + Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable.push_back(SoundEntry(sound, 1)); _sound->playSound(0); _scripts->cmdFreeSound(); @@ -287,8 +288,9 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { } for (;;) { - _sound->_soundTable[0] = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundPriority[0] = 1; + _sound->freeSounds(); + Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable.push_back(SoundEntry(res, 1)); _sound->playSound(0); _scripts->cmdFreeSound(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8270eaee6b..9801df7f3c 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -132,10 +132,7 @@ void AmazonEngine::doTitle() { _events->hideCursor(); _sound->queueSound(0, 98, 30); - _sound->_soundPriority[0] = 1; - _sound->queueSound(1, 98, 8); - _sound->_soundPriority[1] = 1; _files->_loadPalFlag = false; _files->loadScreen(0, 3); @@ -404,14 +401,13 @@ void AmazonEngine::startChapter(int chapter) { _timers[20]._timer = 500; _timers[20]._initTm = 500; _timers[20]._flag++; + _sound->freeSounds(); - _sound->_soundTable[0] = _sound->loadSound(115, 0); - _sound->_soundPriority[0] = 1; + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); _sound->playSound(0); _sound->freeSounds(); - _sound->_soundTable[0] = _sound->loadSound(115, 1); - _sound->_soundPriority[0] = 1; + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); _sound->playSound(0); _sound->freeSounds(); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 5d9f2d9436..12902081b7 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -116,7 +116,6 @@ void AmazonScripts::mWhile1() { _sequence = 2200; _vm->_sound->queueSound(0, 14, 15); - _vm->_sound->_soundPriority[0] = 1; do { cLoop(); diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 2f11d8b858..1c135930f3 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -96,7 +96,6 @@ void MartianEngine::doTitle() { _events->hideCursor(); _sound->queueSound(0, 98, 30); - _sound->_soundPriority[0] = 1; _files->_loadPalFlag = false; _files->loadScreen(0, 3); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6c4c37491f..bf58a20eef 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -707,15 +707,14 @@ void Scripts::cmdLoadSound() { int idx = _data->readSint16LE(); _vm->_sound->_soundTable.clear(); - _vm->_sound->_soundPriority.clear(); - _vm->_sound->_soundTable.push_back(_vm->_files->loadFile(_vm->_extraCells[idx]._vidSound)); - _vm->_sound->_soundPriority.push_back(1); + Resource *sound = _vm->_files->loadFile(_vm->_extraCells[idx]._vidSound); + _vm->_sound->_soundTable.push_back(SoundEntry(sound, 1)); } void Scripts::cmdFreeSound() { SoundManager &sound = *_vm->_sound; - if (sound._soundTable.size() > 0 && sound._soundTable[0]) { + if (sound._soundTable.size() > 0 && sound._soundTable[0]._res) { // Keep doing char display loop if playing sound for it do { if (_vm->_flags[236] == 1) @@ -725,8 +724,8 @@ void Scripts::cmdFreeSound() { } while (!_vm->shouldQuit() && sound._playingSound); // Free the sound - delete sound._soundTable[0]; - sound._soundTable[0] = nullptr; + delete sound._soundTable[0]._res; + sound._soundTable.remove_at(0); } } @@ -766,8 +765,7 @@ void Scripts::cmdDead() { _vm->_screen->forceFadeOut(); cmdFreeSound(); - _vm->_sound->_soundTable[0] = _vm->_files->loadFile(98, 44); - _vm->_sound->_soundPriority[1] = 1; + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1)); _vm->_screen->clearScreen(); _vm->_screen->setPanel(3); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index dd8cf16189..075bfc005e 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -44,14 +44,17 @@ SoundManager::~SoundManager() { void SoundManager::clearSounds() { for (uint i = 0; i < _soundTable.size(); ++i) - delete _soundTable[i]; + delete _soundTable[i]._res; _soundTable.clear(); - _soundPriority.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { - delete _soundTable[idx]; - _soundTable[idx] = _vm->_files->loadFile(fileNum, subfile); + if (idx >= (int)_soundTable.size()) + _soundTable.resize(idx + 1); + + delete _soundTable[idx]._res; + _soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._priority = 1; } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -59,8 +62,8 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int priority = _soundPriority[soundIndex]; - playSound(_soundTable[soundIndex], priority); + int priority = _soundTable[soundIndex]._priority; + playSound(_soundTable[soundIndex]._res, priority); } void SoundManager::playSound(Resource *res, int priority) { @@ -76,8 +79,8 @@ void SoundManager::loadSounds(Common::Array &sounds) { clearSounds(); for (uint i = 0; i < sounds.size(); ++i) { - _soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile)); - _soundPriority.push_back(sounds[i]._priority); + Resource *sound = loadSound(sounds[i]._fileNum, sounds[i]._subfile); + _soundTable.push_back(SoundEntry(sound, sounds[i]._priority)); } } diff --git a/engines/access/sound.h b/engines/access/sound.h index c1b3981997..2456ba7753 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -33,6 +33,14 @@ namespace Access { class AccessEngine; +struct SoundEntry { + Resource *_res; + int _priority; + + SoundEntry() { _res = nullptr; _priority = 0; } + SoundEntry(Resource *res, int priority) { _res = res; _priority = priority; } +}; + class SoundManager { private: AccessEngine *_vm; @@ -45,8 +53,7 @@ private: void stopSound(); public: - Common::Array _soundTable; - Common::Array _soundPriority; + Common::Array _soundTable; Resource *_music; Resource *_tempMusic; bool _musicRepeat; -- cgit v1.2.3 From 6434ace3b695cc88593547f8079f6abd309b7f72 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 22:11:28 -0500 Subject: ACCESS: Fix not being able to save in room 9 --- engines/access/scripts.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index bf58a20eef..e99af4b2f6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -414,7 +414,10 @@ void Scripts::cmdSetTimer() { void Scripts::cmdCheckTimer() { int idx = _data->readUint16LE(); + _vm->_canSaveLoad = true; _vm->_events->pollEvents(); + _vm->_canSaveLoad = false; + if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { _vm->_events->zeroKeys(); _vm->_timers[9]._timer = 0; -- cgit v1.2.3 From fddff687da7b7f9eb2156a84407794c44978caa8 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 16:34:06 -0500 Subject: ACCESS: Workaround for original game vertical room scrolling --- engines/access/amazon/amazon_room.cpp | 11 +++++++++++ engines/access/amazon/amazon_room.h | 2 ++ engines/access/room.h | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 098220ee0c..96d34e70bb 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -125,6 +125,17 @@ void AmazonRoom::reloadRoom1() { _vm->_newRects.clear(); } +void AmazonRoom::setupRoom() { + Room::setupRoom(); + + // WORKAROUND: The original engine doesn't handle vertical scrolling rooms + Screen &screen = *_vm->_screen; + if (screen._vWindowHeight == (_playFieldHeight - 1)) { + screen._scrollRow = 1; + screen._scrollY = 0; + } +} + void AmazonRoom::roomSet() { _vm->_numAnimTimers = 0; _vm->_scripts->_sequence = 1000; diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 122eed991e..ccace1ea45 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -48,6 +48,8 @@ protected: virtual void reloadRoom1(); + virtual void setupRoom(); + virtual void roomMenu(); virtual void mainAreaClick(); diff --git a/engines/access/room.h b/engines/access/room.h index fdeccc87c8..810082edb4 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -80,7 +80,6 @@ private: bool checkCode(int v1, int v2); protected: void loadRoomData(const byte *roomData); - void setupRoom(); /** * Free the playfield data @@ -115,6 +114,8 @@ protected: virtual void reloadRoom1() = 0; + virtual void setupRoom(); + virtual void doCommands(); virtual void roomMenu() = 0; -- cgit v1.2.3 From e7818639afd72d861c3ed985bb8aeb4f685e5042 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 18:12:52 -0500 Subject: ACCESS: Workaround not being able to leave scene 9 in Amazon to the south --- engines/access/amazon/amazon_room.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 96d34e70bb..ec90fc6295 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -177,6 +177,11 @@ void AmazonRoom::mainAreaClick() { } } + // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due + // to not being able to click a Y position that's high enough + if (pt.y > 178) + pt.y = 200; + _vm->_player->_moveTo = pt; _vm->_player->_playerMove = true; } else if (mousePos.x >= _vm->_screen->_windowXAdd && -- cgit v1.2.3 From aea906f7d3c8959337c24ee4507bb245d9f5f744 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 19:16:14 -0500 Subject: ACCESS: Implemented chapter debug command --- engines/access/access.cpp | 2 +- engines/access/debugger.cpp | 50 ++++++++++++++++++++++++++++++++++++++++----- engines/access/debugger.h | 17 +++++++++++++-- engines/access/files.cpp | 6 ++++++ engines/access/files.h | 1 + engines/access/room.cpp | 2 +- engines/access/scripts.cpp | 2 -- engines/access/scripts.h | 3 +++ 8 files changed, 72 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index f04a5dec88..a1f6430965 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -164,7 +164,7 @@ void AccessEngine::initialize() { _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); _char = new CharManager(this); - _debugger = new Debugger(this); + _debugger = Debugger::init(this); _events = new EventsManager(this); _files = new FileManager(this); _inventory = new InventoryManager(this); diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index d20b5d3e6b..d8f7cfe411 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -23,14 +23,10 @@ #include "common/file.h" #include "access/access.h" #include "access/debugger.h" +#include "access/amazon/amazon_game.h" namespace Access { -Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { - registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); - registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); -} - static int strToInt(const char *s) { if (!*s) // No string at all @@ -47,6 +43,22 @@ static int strToInt(const char *s) { return (int)tmp; } +Debugger *Debugger::init(AccessEngine *vm) { + switch (vm->getGameID()) { + case GType_Amazon: + return new Amazon::AmazonDebugger(vm); + default: + return new Debugger(vm); + } +} + +/*------------------------------------------------------------------------*/ + +Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); +} + bool Debugger::Cmd_LoadScene(int argc, const char **argv) { if (argc != 2) { debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); @@ -66,4 +78,32 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { } } +/*------------------------------------------------------------------------*/ + +namespace Amazon { + +AmazonDebugger::AmazonDebugger(AccessEngine *vm): Debugger(vm) { + registerCmd("chapter", WRAP_METHOD(AmazonDebugger, Cmd_StartChapter)); +} + +bool AmazonDebugger::Cmd_StartChapter(int argc, const char **argv) { + if (argc != 2) { + debugPrintf("Usage: %s \n", argv[0]); + return true; + } + + // Build up a simple one line script to start the given chapter + byte *chapterScript = (byte *)malloc(5); + chapterScript[0] = SCRIPT_START_BYTE; + chapterScript[1] = ROOM_SCRIPT % 256; + chapterScript[2] = ROOM_SCRIPT / 256; + chapterScript[3] = 0x80 + 75; // cmdChapter + chapterScript[4] = strToInt(argv[1]); // chapter number + _vm->_scripts->setScript(new Resource(chapterScript, 5)); + + return false; +} + +} // End of namespace Amazon + } // End of namespace Access diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 6c8424dac4..67425430e2 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -31,16 +31,29 @@ namespace Access { class AccessEngine; class Debugger : public GUI::Debugger { -private: - AccessEngine *_vm; protected: + AccessEngine *_vm; + bool Cmd_LoadScene(int argc, const char **argv); public: + static Debugger *init(AccessEngine *vm); public: Debugger(AccessEngine *vm); virtual ~Debugger() {} }; +namespace Amazon { + +class AmazonDebugger : public Debugger { +protected: + bool Cmd_StartChapter(int argc, const char **argv); +public: + AmazonDebugger(AccessEngine *vm); + virtual ~AmazonDebugger() {} +}; + +} // End of namespace Amazon + } // End of namespace Access #endif /* ACCESS_DEBUGGER_H */ diff --git a/engines/access/files.cpp b/engines/access/files.cpp index a4ec16ad61..bb8dc57c2c 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -59,6 +59,12 @@ Resource::~Resource() { delete _stream; } +Resource::Resource(byte *data, int size) { + _data = data; + _size = size; + _stream = new Common::MemoryReadStream(data, size); +} + byte *Resource::data() { if (_data == nullptr) { _data = new byte[_size]; diff --git a/engines/access/files.h b/engines/access/files.h index 720d4fb2ba..24e2d88456 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -62,6 +62,7 @@ public: int _size; Resource(); + Resource::Resource(byte *data, int size); ~Resource(); byte *data(); }; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 76ad29e21a..c9f4a886a1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -235,7 +235,7 @@ void Room::loadRoomData(const byte *roomData) { } void Room::roomLoop() { - _vm->_scripts->_sequence = 2000; + _vm->_scripts->_sequence = ROOM_SCRIPT; _vm->_scripts->searchForSequence(); _vm->_scripts->executeScript(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index e99af4b2f6..72fc35dc3f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -25,8 +25,6 @@ #include "access/resources.h" #include "access/scripts.h" -#define SCRIPT_START_BYTE 0xE0 - namespace Access { Scripts::Scripts(AccessEngine *vm) : Manager(vm) { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ab80c1cd9f..9860c7cde9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -32,6 +32,9 @@ namespace Access { class AccessEngine; class Scripts; +#define SCRIPT_START_BYTE 0xE0 +#define ROOM_SCRIPT 2000 + class Scripts: public Manager { private: Resource *_resource; -- cgit v1.2.3 From d23d95b9129c0f0b90718630d9d136042821d026 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 22:35:58 -0500 Subject: ACCESS: Fix display of cutscene at the end of chapter 3 --- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/amazon/amazon_scripts.cpp | 7 +++---- engines/access/files.cpp | 8 ++------ engines/access/files.h | 2 +- engines/access/martian/martian_game.cpp | 4 ++-- engines/access/screen.cpp | 5 +++-- engines/access/scripts.cpp | 9 ++++++--- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 9801df7f3c..87aa9358cd 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -134,7 +134,7 @@ void AmazonEngine::doTitle() { _sound->queueSound(0, 98, 30); _sound->queueSound(1, 98, 8); - _files->_loadPalFlag = false; + _files->_setPaletteFlag = false; _files->loadScreen(0, 3); _buffer2.copyFrom(*_screen); @@ -148,7 +148,7 @@ void AmazonEngine::doTitle() { _sound->playSound(1); - _files->_loadPalFlag = false; + _files->_setPaletteFlag = false; _files->loadScreen(0, 4); _sound->playSound(1); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 12902081b7..bb17f86f49 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -531,7 +531,7 @@ void AmazonScripts::mWhileDoOpen() { delete data; _vm->_objectsTable[1] = spr; - _vm->_files->_loadPalFlag = false; + _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(1, 2); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); @@ -714,14 +714,13 @@ void AmazonScripts::guard() { } void AmazonScripts::loadBackground(int param1, int param2) { - _vm->_files->_loadPalFlag = false; + _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(param1, param2); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->forceFadeOut(); - + _vm->_screen->forceFadeIn(); } void AmazonScripts::setInactive() { diff --git a/engines/access/files.cpp b/engines/access/files.cpp index bb8dc57c2c..0705b5d227 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -92,7 +92,7 @@ FileManager::FileManager(AccessEngine *vm): _vm(vm) { } _fileNumber = -1; - _loadPalFlag = true; + _setPaletteFlag = true; } FileManager::~FileManager() { @@ -144,11 +144,7 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) } void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { - if (_loadPalFlag) { - _vm->_screen->loadPalette(res->_stream); - } else { - res->_stream->skip(PALETTE_SIZE); - } + _vm->_screen->loadPalette(res->_stream); // The remainder of the file after the palette may be separately compressed, // so call handleFile to handle it if it is diff --git a/engines/access/files.h b/engines/access/files.h index 24e2d88456..f65f2ba8da 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -96,7 +96,7 @@ private: public: int _fileNumber; Common::Array _fileIndex; - bool _loadPalFlag; + bool _setPaletteFlag; public: FileManager(AccessEngine *vm); ~FileManager(); diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 1c135930f3..81a8ffdf4d 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -97,7 +97,7 @@ void MartianEngine::doTitle() { _sound->queueSound(0, 98, 30); - _files->_loadPalFlag = false; + _files->_setPaletteFlag = false; _files->loadScreen(0, 3); _buffer2.copyFrom(*_screen); @@ -111,7 +111,7 @@ void MartianEngine::doTitle() { _sound->playSound(1); - _files->_loadPalFlag = false; + _files->_setPaletteFlag = false; _files->loadScreen(0, 4); _sound->playSound(1); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 17f36fc072..3e0863cc31 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -101,8 +101,9 @@ void Screen::setInitialPalettte() { void Screen::loadPalette(Common::SeekableReadStream *stream) { loadRawPalette(stream); - setPalette(); - _vm->_files->_loadPalFlag = true; + if (_vm->_files->_setPaletteFlag) + setPalette(); + _vm->_files->_setPaletteFlag = true; } void Screen::loadPalette(int fileNum, int subfile) { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 72fc35dc3f..081fc65f0c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -748,6 +748,9 @@ void Scripts::cmdPlayVideoSound() { _vm->_sound->playSound(0); _vm->_video->_soundFlag = true; } + + _vm->_events->pollEvents(); + g_system->delayMillis(10); } void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } @@ -773,9 +776,9 @@ void Scripts::cmdDead() { if (deathId != 10) { _vm->_sound->newMusic(62, 0); - _vm->_files->_loadPalFlag = false; + _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(94, 0); - _vm->_files->_loadPalFlag = true; + _vm->_files->_setPaletteFlag = true; _vm->_buffer2.copyFrom(*_vm->_screen); for (int i = 0; i < 3; ++i) { @@ -793,7 +796,7 @@ void Scripts::cmdDead() { _vm->loadCells(cells); _vm->_screen->setDisplayScan(); - _vm->_files->_loadPalFlag = false; + _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(&_vm->_buffer2, 94, 1); _vm->_screen->setIconPalette(); -- cgit v1.2.3 From d6963d8d09b9bd5f1fd5cd4c58e90bb4332a5cfe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 22:44:30 -0500 Subject: ACCESS: Simplification of logic for selectively applying loaded palettes --- engines/access/files.cpp | 5 ++++- engines/access/screen.cpp | 7 ------- engines/access/screen.h | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 0705b5d227..dacceb7a09 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -144,7 +144,10 @@ void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) } void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { - _vm->_screen->loadPalette(res->_stream); + _vm->_screen->loadRawPalette(res->_stream); + if (_setPaletteFlag) + _vm->_screen->setPalette(); + _setPaletteFlag = true; // The remainder of the file after the palette may be separately compressed, // so call handleFile to handle it if it is diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3e0863cc31..f98552470c 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -99,13 +99,6 @@ void Screen::setInitialPalettte() { g_system->getPaletteManager()->setPalette(INITIAL_PALETTE, 0, 18); } -void Screen::loadPalette(Common::SeekableReadStream *stream) { - loadRawPalette(stream); - if (_vm->_files->_setPaletteFlag) - setPalette(); - _vm->_files->_setPaletteFlag = true; -} - void Screen::loadPalette(int fileNum, int subfile) { Resource *res = _vm->_files->loadFile(fileNum, subfile); byte *palette = res->data(); diff --git a/engines/access/screen.h b/engines/access/screen.h index 2db05a5f9d..8875ce12b7 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -121,8 +121,6 @@ public: */ void setIconPalette() {} - void loadPalette(Common::SeekableReadStream *stream); - void loadPalette(int fileNum, int subfile); void setPalette(); -- cgit v1.2.3 From 876ce794a1545f04aafc1752d2e25d4379fc72ea Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 8 Nov 2014 22:53:21 -0500 Subject: ACCESS: Fix crash when exiting game in the middle of a chapter start --- engines/access/room.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index c9f4a886a1..02bb3b53c7 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -88,7 +88,10 @@ void Room::doRoom() { _vm->_player->walk(); _vm->_sound->midiRepeat(); _vm->_player->checkScroll(); + doCommands(); + if (_vm->shouldQuit()) + return; // DOROOMFLASHBACK jump point if (_function == FN_CLEAR1) { -- cgit v1.2.3 From 6f39c07324521becc4d12354a27e213b4bc73272 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 09:40:44 -0500 Subject: ACCESS: Fix crash when starting scene 16 --- engines/access/amazon/amazon_room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index ec90fc6295..fb849d27fa 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -93,7 +93,7 @@ void AmazonRoom::reloadRoom1() { _vm->_screen->clearScreen(); roomSet(); - if (!_roomFlag && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) { + if (_roomFlag != 1 && (_vm->_player->_roomNumber != 61 || !_antOutFlag)) { _vm->_player->load(); _vm->_player->calcManScale(); } -- cgit v1.2.3 From 8ef3d551511f2b22c36e2cdbcb50f104eb64871a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 11:19:10 -0500 Subject: ACCESS: Fix scene fade ins --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 02bb3b53c7..e3ac84c231 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -69,12 +69,12 @@ void Room::doRoom() { } reloadFlag = false; - _vm->_startup = 0; + _vm->_startup = 8; _function = 0; while (!_vm->shouldQuit()) { _vm->_images.clear(); - if (_vm->_startup != -1 && --_vm->_startup != 0) { + if (_vm->_startup != -1 && --_vm->_startup == 0) { _vm->_events->showCursor(); _vm->_screen->fadeIn(); } -- cgit v1.2.3 From 985ad555591ebb48ebe3f2bfd711d245bab40f71 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 12:22:38 -0500 Subject: ACCESS: Airplane flight cutscene is now partially working --- engines/access/amazon/amazon_scripts.cpp | 124 +++++++++++++++++++------------ engines/access/events.cpp | 2 + engines/access/events.h | 1 + 3 files changed, 79 insertions(+), 48 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index bb17f86f49..857e4447e6 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -226,24 +226,48 @@ void AmazonScripts::mWhile2() { } void AmazonScripts::doFlyCell() { - _game->_destIn = &_game->_buffer2; - if (_game->_plane._pCount <= 40) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 3, Common::Point(70, 74)); - } else if (_game->_plane._pCount <= 80) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 6, Common::Point(70, 74)); - } else if (_game->_plane._pCount <= 120) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 2, Common::Point(50, 76)); - } else if (_game->_plane._pCount <= 160) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 14, Common::Point(63, 78)); - } else if (_game->_plane._pCount <= 200) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 5, Common::Point(86, 74)); - } else if (_game->_plane._pCount <= 240) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 0, Common::Point(103, 76)); - } else if (_game->_plane._pCount <= 280) { - _vm->_screen->plotImage(_vm->_objectsTable[15], 4, Common::Point(119, 77)); + Plane &plane = _game->_plane; + SpriteResource *sprites = _vm->_objectsTable[15]; + + if (plane._pCount <= 40) { + _vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74)); + } else if (plane._pCount <= 80) { + _vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74)); + } else if (plane._pCount <= 120) { + _vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76)); + } else if (plane._pCount <= 160) { + _vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78)); + } else if (plane._pCount <= 200) { + _vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74)); + } else if (plane._pCount <= 240) { + _vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76)); + } else if (plane._pCount <= 280) { + _vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77)); } else { - _vm->_screen->plotImage(_vm->_objectsTable[15], 1, Common::Point(111, 77)); + _vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77)); } + + if (plane._pCount == 11 || plane._pCount == 12) + ++plane._position.y; + else if (plane._pCount >= 28) + --plane._position.y; + + _vm->_buffer2.plotImage(sprites, 7, plane._position); + _vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point( + plane._position.x + 99, plane._position.y + 10)); + _vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point( + plane._position.x + 104, plane._position.y + 18)); + + if (++plane._planeCount >= 30) + plane._planeCount = 0; + if (++plane._propCount >= 3) + plane._propCount = 0; + + ++plane._xCount; + if (plane._xCount == 1) + ++plane._position.x; + else + plane._xCount = 0; } void AmazonScripts::doFallCell() { @@ -320,59 +344,63 @@ void AmazonScripts::scrollJWalk() { } void AmazonScripts::mWhileFly() { - _vm->_events->hideCursor(); - _vm->_screen->clearScreen(); - _vm->_screen->setBufferScan(); - _vm->_screen->fadeOut(); - _vm->_screen->_scrollX = 0; + Screen &screen = *_vm->_screen; + Player &player = *_vm->_player; + EventsManager &events = *_vm->_events; + Plane &plane = _game->_plane; + + events.hideCursor(); + screen.clearScreen(); + screen.setBufferScan(); + screen.fadeOut(); + screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->fadeIn(); + screen.fadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); // KEYFLG = 0; - _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; - _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; - _vm->_player->_rawPlayer = Common::Point(0, 0); - _vm->_player->_scrollAmount = 1; + screen._scrollRow = screen._scrollCol = 0; + screen._scrollX = screen._scrollY = 0; + player._rawPlayer = Common::Point(0, 0); + player._scrollAmount = 1; - _game->_plane._pCount = 0; - _game->_plane._planeCount = 0; - _game->_plane._propCount = 0; - _game->_plane._xCount = 0; - _game->_plane._position = Common::Point(20, 29); + plane._pCount = 0; + plane._planeCount = 0; + plane._propCount = 0; + plane._xCount = 0; + plane._position = Common::Point(20, 29); - warning("FIXME: _vbCount should be handled in NEWTIMER"); - while (true) { - int _vbCount = 4; - if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) { - _vm->_events->showCursor(); - return; - } + while (!_vm->shouldQuit() && ((screen._scrollCol + screen._vWindowWidth) + != _vm->_room->_playFieldWidth)) { + events._vbCount = 4; + screen._scrollX += player._scrollAmount; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFly(); - ++_game->_plane._pCount; - g_system->delayMillis(10); + ++plane._pCount; - while(_vbCount > 0) { + while (!_vm->shouldQuit() && events._vbCount > 0) { // To be rewritten when NEWTIMER is done - _vm->_events->checkForNextFrameCounter(); - _vbCount--; + events.checkForNextFrameCounter(); _vm->_sound->playSound(0); + + g_system->delayMillis(10); + events.pollEvents(); } } + + events.showCursor(); } void AmazonScripts::mWhileFall() { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 0b7a34841e..7741a87677 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -44,6 +44,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _wheelUp = _wheelDown = false; _mouseCol = _mouseRow = 0; _cursorExitFlag = false; + _vbCount = 0; } EventsManager::~EventsManager() { @@ -184,6 +185,7 @@ bool EventsManager::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { + --_vbCount; ++_frameCounter; _priorFrameTime = milli; diff --git a/engines/access/events.h b/engines/access/events.h index b29b54159e..def04effb8 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -57,6 +57,7 @@ public: Common::Point _mousePos; int _mouseCol, _mouseRow; bool _cursorExitFlag; + int _vbCount; Common::FixedStack _keypresses; public: /** -- cgit v1.2.3 From bbaea32386927c856d22b97c877ddbba41fb142f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 13:54:48 -0500 Subject: ACCESS: Fixes for flying plane cutscene --- engines/access/amazon/amazon_scripts.cpp | 12 ++++++------ engines/access/events.cpp | 7 +++++++ engines/access/events.h | 2 ++ engines/access/room.cpp | 3 +++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 857e4447e6..b79b1c5c64 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -247,15 +247,15 @@ void AmazonScripts::doFlyCell() { _vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77)); } - if (plane._pCount == 11 || plane._pCount == 12) + if (plane._planeCount == 11 || plane._planeCount == 12) ++plane._position.y; - else if (plane._pCount >= 28) + else if (plane._planeCount >= 28) --plane._position.y; _vm->_buffer2.plotImage(sprites, 7, plane._position); - _vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point( + _vm->_buffer2.plotImage(sprites, 8 + plane._propCount, Common::Point( plane._position.x + 99, plane._position.y + 10)); - _vm->_buffer2.plotImage(sprites, plane._propCount, Common::Point( + _vm->_buffer2.plotImage(sprites, 11 + plane._propCount, Common::Point( plane._position.x + 104, plane._position.y + 18)); if (++plane._planeCount >= 30) @@ -374,8 +374,8 @@ void AmazonScripts::mWhileFly() { plane._xCount = 0; plane._position = Common::Point(20, 29); - while (!_vm->shouldQuit() && ((screen._scrollCol + screen._vWindowWidth) - != _vm->_room->_playFieldWidth)) { + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && + ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { events._vbCount = 4; screen._scrollX += player._scrollAmount; diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 7741a87677..0287e8cb03 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -264,6 +264,13 @@ int EventsManager::checkMouseBox1(Common::Array &rects) { } } +bool EventsManager::isKeyMousePressed() { + bool result = _leftButton || _rightButton || _keypresses.size() > 0; + debounceLeft(); + zeroKeys(); + + return result; +} } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index def04effb8..4888a27593 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -124,6 +124,8 @@ public: Common::Point calcRawMouse(); int checkMouseBox1(Common::Array &rects); + + bool isKeyMousePressed(); }; } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3ac84c231..f1e499d1c9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -126,7 +126,10 @@ void Room::doRoom() { _vm->copyBF1BF2(); _vm->_newRects.clear(); _function = 0; + roomLoop(); + if (_vm->shouldQuit()) + return; if (_function == FN_CLEAR1) { clearRoom(); -- cgit v1.2.3 From d7cf5701324eb0e9b69017e596f8577bf9fe14a1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 15:34:05 -0500 Subject: ACCESS: Fix restoring talk bubbles where right edge is a bit over screen edge --- engines/access/bubble_box.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index d865d5c9b3..37b757f8d9 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -52,6 +52,8 @@ void BubbleBox::clearBubbles() { _vm->_screen->_screenYOff = 0; Common::Rect r = _bubbles[i]; r.left -= 2; + r.right = MIN(r.right, (int16)_vm->_screen->w); + _vm->_screen->copyBlock(&_vm->_buffer2, r); } -- cgit v1.2.3 From 4448929812a5b8ca21eebb594e587a582392c9a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 15:34:33 -0500 Subject: ACCESS: Fixes for selecting bottom buttons in conversation screen --- engines/access/scripts.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 081fc65f0c..297118010e 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -555,11 +555,11 @@ void Scripts::cmdTexSpeak() { findNull(); } +#define BTN_COUNT 6 void Scripts::cmdTexChoice() { - static Common::Point cMouse[7] = { - Common::Point(0, 76), Common::Point(77, 154), Common::Point(155, 232), - Common::Point(233, 276), Common::Point(0, 0), Common::Point(277, 319), - Common::Point(297, 319) + static const int BTN_RANGES[BTN_COUNT][2] = { + { 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, + { 277, 319 } }; _vm->_oldRects.clear(); @@ -636,8 +636,8 @@ void Scripts::cmdTexChoice() { if (_vm->_events->_mouseRow >= 22) { _vm->_events->debounceLeft(); int x = _vm->_events->_mousePos.x; - for (int i = 0; i < 7; i++) { - if ((x >= cMouse->x) && (x < cMouse->y)) { + for (int i = 0; i < BTN_COUNT; i++) { + if ((x >= BTN_RANGES[i][0]) && (x < BTN_RANGES[i][1])) { choice = i; break; } @@ -687,7 +687,7 @@ void Scripts::cmdSetConPos() { void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); } void Scripts::cmdJumpChoice() { - int val = (_data->readUint16LE() && 0xFF); + int val = (_data->readUint16LE() & 0xFF); if (val == _choice) { _sequence = _data->readUint16LE(); -- cgit v1.2.3 From 4ce87a51a061c31b0f2db605712ce7e0cab5b5d7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 18:29:15 -0500 Subject: ACCESS: Fix restoring screen after offering a character an inventory item --- engines/access/inventory.cpp | 5 ++++- engines/access/room.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 45738462df..f2c87b2604 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -113,7 +113,7 @@ int InventoryManager::newDisplayInv() { _invModeFlag = true; _vm->_timers.saveTimers(); - if (room._tile && !_invRefreshFlag) { + if (!room._tile && !_invRefreshFlag) { saveScreens(); } @@ -360,6 +360,9 @@ void InventoryManager::restoreScreens() { _vm->_buffer1.w = _vm->_buffer1.pitch; _savedBuffer1.copyTo(&_vm->_buffer1); _savedScreen.copyTo(_vm->_screen); + + _savedBuffer1.free(); + _savedScreen.free(); } void InventoryManager::outlineIcon(int itemIndex) { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f1e499d1c9..e3a46159cf 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -163,6 +163,7 @@ void Room::clearRoom() { _vm->_scripts->freeScriptData(); _vm->freeCells(); freePlayField(); + freeTileData(); _vm->freeInactiveData(); _vm->_player->freeSprites(); } -- cgit v1.2.3 From 6390f54d4b6e191d5b1f85d0a3f86e94bb110228 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 18:39:54 -0500 Subject: ACCESS: Fix crash at end of cmdDead --- engines/access/scripts.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 297118010e..9f321947f2 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -824,9 +824,10 @@ void Scripts::cmdDead() { warning("TODO: restart game"); _vm->quitGame(); - } - else { + _vm->_events->pollEvents(); + } else { _vm->quitGame(); + _vm->_events->pollEvents(); } } -- cgit v1.2.3 From 304db8ee6f963a4f647488623fd30ccb70472962 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Nov 2014 01:02:58 +0100 Subject: ACCESS: Add some code to display scene number & description --- engines/access/amazon/amazon_resources.cpp | 18 +++++++++++++ engines/access/amazon/amazon_resources.h | 2 ++ engines/access/debugger.cpp | 38 ++++++++++++++++++++++++---- engines/access/debugger.h | 4 +++ engines/access/martian/martian_resources.cpp | 15 +++++++++++ engines/access/martian/martian_resources.h | 2 ++ 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index e60da5b0ff..42dc35aa8e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -574,6 +574,24 @@ const byte *ROOM_TABLE[] = { CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr }; +const char *ROOM_DESCR[] = { + "TBD CREDITS", nullptr, nullptr, nullptr, "TBD ALLISTER", + "TBD HALL", "TBD JASONLAB", nullptr, "TBD ALLENLAB", "TBD OUTVAULT", + "TBD VAULT", "TBD LIBRARY", "TBD JASAPT", "TBD RANSACKED", "TBD MEAN1", + "TBD FLYSOUTH", "TBD CUZCO", "TBD INAIR", "TBD GREENMONKEY", "TBD INPLANE", + "TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "TBD JNGLWLK", + "TBD TOWN", "TBD HOTEL", "TBD CANTINA", nullptr, "TBD MASSACRE", + "TBD TRADE", "TBD BRIDGE", "TBD DOCK", "TBD DRIVER", nullptr, + nullptr, "TBD SHORE", "TBD BOAT", "TBD CABIN", "TBD CAPTIVE", + nullptr, nullptr, "TBD VILLAGE", nullptr, "TBD TREE", + "TBD CANOE", "TBD INTREE", "TBD FALLS", nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr, "TBD WATERFALL", + "TBD INWATER", nullptr, "TBD CAVE", nullptr, nullptr, + nullptr, "TBD PIT", nullptr, nullptr +}; + +const int ROOM_NUMB = 63; + const byte ELAINE[] = { 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x41, 0x41, 0x0, 0x1, 0x0, 0xFF, 0x41, 0x0, 0x2, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 2be9b4dd4b..7aee90003e 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -36,6 +36,8 @@ extern const byte *CURSORS[10]; extern const int TRAVEL_POS[][2]; extern const byte *ROOM_TABLE[]; +extern const char *ROOM_DESCR[]; +extern const int ROOM_NUMB; extern const byte *CHARTBL[]; diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index d8f7cfe411..17ab6e101d 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -57,15 +57,38 @@ Debugger *Debugger::init(AccessEngine *vm) { Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); + + switch (vm->getGameID()) { + case GType_Amazon: + _sceneNumb = Amazon::ROOM_NUMB; + _sceneDescr = new Common::String[_sceneNumb]; + for (int i = 0; i < _sceneNumb; i++) + _sceneDescr[i] = Common::String(Amazon::ROOM_DESCR[i]); + break; + case GType_MartianMemorandum: + _sceneNumb = Martian::ROOM_NUMB; + _sceneDescr = new Common::String[_sceneNumb]; + for (int i = 0; i < _sceneNumb; i++) + _sceneDescr[i] = Common::String(Martian::ROOM_DESCR[i]); + break; + default: + _sceneDescr = nullptr; + _sceneNumb = 0; + break; + } } bool Debugger::Cmd_LoadScene(int argc, const char **argv) { - if (argc != 2) { - debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); - debugPrintf("Usage: %s \n", argv[0]); + switch (argc) { + case 1: + debugPrintf("Current scene is: %d\n\n", _vm->_player->_roomNumber); + + for (int i = 0; i < _sceneNumb; i++) + if (_sceneDescr[i].size()) + debugPrintf("%d - %s\n", i, _sceneDescr[i].c_str()); return true; - } - else { + + case 2: _vm->_player->_roomNumber = strToInt(argv[1]); _vm->_room->_function = FN_CLEAR1; @@ -75,6 +98,11 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { _vm->_scripts->_returnCode = 0; return false; + + default: + debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); + debugPrintf("Usage: %s \n", argv[0]); + return true; } } diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 67425430e2..60bd22358a 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -25,6 +25,8 @@ #include "common/scummsys.h" #include "gui/debugger.h" +#include "access/amazon/amazon_resources.h" +#include "access/martian/martian_resources.h" namespace Access { @@ -35,6 +37,8 @@ protected: AccessEngine *_vm; bool Cmd_LoadScene(int argc, const char **argv); + Common::String *_sceneDescr; + int _sceneNumb; public: static Debugger *init(AccessEngine *vm); public: diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp index b596797ab5..5dfb766885 100644 --- a/engines/access/martian/martian_resources.cpp +++ b/engines/access/martian/martian_resources.cpp @@ -421,6 +421,21 @@ const byte *ROOM_TABLE[] = { nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47 }; +const char *ROOM_DESCR[] = { + nullptr, "TBD ROOM_TABLE1", "TBD ROOM_TABLE2", "TBD ROOM_TABLE3", "TBD ROOM_TABLE4", + "TBD ROOM_TABLE5", "TBD ROOM_TABLE6", "TBD ROOM_TABLE7", "TBD ROOM_TABLE8", "TBD ROOM_TABLE9", + nullptr, "TBD ROOM_TABLE11", nullptr, "TBD ROOM_TABLE13", "TBD ROOM_TABLE14", + "TBD ROOM_TABLE15", "TBD ROOM_TABLE16", "TBD ROOM_TABLE17", "TBD ROOM_TABLE18", nullptr, + nullptr, "TBD ROOM_TABLE21", "TBD ROOM_TABLE22", "TBD ROOM_TABLE23", "TBD ROOM_TABLE24", + "TBD ROOM_TABLE25", "TBD ROOM_TABLE26", "TBD ROOM_TABLE27", "TBD ROOM_TABLE28", "TBD ROOM_TABLE29", + "TBD ROOM_TABLE30", "TBD ROOM_TABLE31", "TBD ROOM_TABLE32", "TBD ROOM_TABLE33", nullptr, + "TBD ROOM_TABLE35", nullptr, "TBD ROOM_TABLE37", "TBD ROOM_TABLE38", "TBD ROOM_TABLE39", + nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, "TBD ROOM_TABLE47" +}; + +const int ROOM_NUMB = 48; + const byte CHAR_TABLE0[] = { 0x02, 0x31, 0x00, 0x08, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h index a6ababeec3..ab8dfb4d1a 100644 --- a/engines/access/martian/martian_resources.h +++ b/engines/access/martian/martian_resources.h @@ -38,6 +38,8 @@ extern const int TRAVEL_POS[][2]; extern const char *const INVENTORY_NAMES[]; extern const byte *ROOM_TABLE[]; +extern const char *ROOM_DESCR[]; +extern const int ROOM_NUMB; extern const byte *CHAR_TABLE[]; -- cgit v1.2.3 From dd2bfdd47fb111259f94fbd985513d56c263305d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Nov 2014 01:12:39 +0100 Subject: ACCESS: Fix compilation warning by adding a dummy inventory combo array for Martian --- engines/access/inventory.cpp | 1 + engines/access/martian/martian_resources.cpp | 58 ++++++++++++++++++++++++++++ engines/access/martian/martian_resources.h | 2 + 3 files changed, 61 insertions(+) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index f2c87b2604..34470ace1e 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -69,6 +69,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { break; case GType_MartianMemorandum: names = Martian::INVENTORY_NAMES; + combineP = &Martian::COMBO_TABLE[0][0]; _inv.resize(54); break; default: diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp index 5dfb766885..ae63f66c7c 100644 --- a/engines/access/martian/martian_resources.cpp +++ b/engines/access/martian/martian_resources.cpp @@ -659,6 +659,64 @@ const byte *CHAR_TABLE[] = { CHAR_TABLE26, CHAR_TABLE27 }; +// TODO: Fix that array +const int COMBO_TABLE[54][4] = { + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 }, + { -1, -1, -1, -1 } +}; + } // End of namespace Martian } // End of namespace Access diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h index ab8dfb4d1a..b9584ba2dd 100644 --- a/engines/access/martian/martian_resources.h +++ b/engines/access/martian/martian_resources.h @@ -43,6 +43,8 @@ extern const int ROOM_NUMB; extern const byte *CHAR_TABLE[]; +extern const int COMBO_TABLE[54][4]; + } // End of namespace Martian } // End of namespace Access -- cgit v1.2.3 From 0df4c903c77b3614723bfc183102c89aa071a65f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Nov 2014 01:28:42 +0100 Subject: ACCESS: Add some safeguards in LoadScene debugger command --- engines/access/amazon/amazon_resources.cpp | 14 +++++++------- engines/access/debugger.cpp | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 42dc35aa8e..a1db01d7b3 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -575,19 +575,19 @@ const byte *ROOM_TABLE[] = { }; const char *ROOM_DESCR[] = { - "TBD CREDITS", nullptr, nullptr, nullptr, "TBD ALLISTER", - "TBD HALL", "TBD JASONLAB", nullptr, "TBD ALLENLAB", "TBD OUTVAULT", - "TBD VAULT", "TBD LIBRARY", "TBD JASAPT", "TBD RANSACKED", "TBD MEAN1", - "TBD FLYSOUTH", "TBD CUZCO", "TBD INAIR", "TBD GREENMONKEY", "TBD INPLANE", - "TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "TBD JNGLWLK", + "Credits", nullptr, nullptr, nullptr, "Outside of Allister Center", + "Hall", "Jason's Lab", nullptr, "Allen's Lab", "Outside of the Vault", + "Inside the Vault", "Reader", "Jason's Apartment", "Jason's ransacked apartment", "Cutscene 1", + "TBD FLYSOUTH", "Cuzco Airport", "TBD INAIR", "Green Monkey Club", "In Plane", + "TBD PILFALL", "TBD COCKPIT", "TBD CRASH", "TBD SINKING", "Cutscene Jungle Walk", "TBD TOWN", "TBD HOTEL", "TBD CANTINA", nullptr, "TBD MASSACRE", "TBD TRADE", "TBD BRIDGE", "TBD DOCK", "TBD DRIVER", nullptr, nullptr, "TBD SHORE", "TBD BOAT", "TBD CABIN", "TBD CAPTIVE", nullptr, nullptr, "TBD VILLAGE", nullptr, "TBD TREE", "TBD CANOE", "TBD INTREE", "TBD FALLS", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "TBD WATERFALL", - "TBD INWATER", nullptr, "TBD CAVE", nullptr, nullptr, - nullptr, "TBD PIT", nullptr, nullptr + "TBD INWATER", nullptr, "Cave Bridge", nullptr, nullptr, + nullptr, "Pit with Ants", nullptr, nullptr }; const int ROOM_NUMB = 63; diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 17ab6e101d..9a82168561 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -88,8 +88,18 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { debugPrintf("%d - %s\n", i, _sceneDescr[i].c_str()); return true; - case 2: - _vm->_player->_roomNumber = strToInt(argv[1]); + case 2: { + int newRoom = strToInt(argv[1]); + if (newRoom < 0 || newRoom >= _sceneNumb) { + debugPrintf("Invalid Room Number"); + return true; + } + if (!_sceneDescr[newRoom].size()) { + debugPrintf("Unused Room Number"); + return true; + } + + _vm->_player->_roomNumber = newRoom; _vm->_room->_function = FN_CLEAR1; _vm->freeChar(); @@ -98,7 +108,7 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { _vm->_scripts->_returnCode = 0; return false; - + } default: debugPrintf("Current scene is: %d\n", _vm->_player->_roomNumber); debugPrintf("Usage: %s \n", argv[0]); -- cgit v1.2.3 From ea206330813aff730c7af5f1aec931f8720105d9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 22:30:57 -0500 Subject: ACCESS: Fix cutscene of pilot falling out of plane --- engines/access/amazon/amazon_scripts.cpp | 57 ++++++++++++++++---------------- engines/access/room.cpp | 3 ++ 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index b79b1c5c64..8e33ae614d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -271,13 +271,14 @@ void AmazonScripts::doFlyCell() { } void AmazonScripts::doFallCell() { - if (_vm->_scaleI <= 0) + if (_vm->_scaleI <= 20) return; - _game->_destIn = &_game->_buffer2; + SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_game->_plane._planeCount / 6); + Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w], + 11 + _vm->_screen->_scaleTable1[frame->h]); + _vm->_buffer2.sPlotF(frame, r); - // 115, 11, i - _vm->_screen->plotImage(_vm->_objectsTable[20], _game->_plane._planeCount / 6, Common::Point(115, 11)); _vm->_scaleI -= 3; _vm->_scale = _vm->_scaleI; _vm->_screen->setScaleTable(_vm->_scale); @@ -404,53 +405,53 @@ void AmazonScripts::mWhileFly() { } void AmazonScripts::mWhileFall() { - _vm->_events->hideCursor(); - _vm->_screen->clearScreen(); - _vm->_screen->setBufferScan(); - _vm->_screen->fadeOut(); - _vm->_screen->_scrollX = 0; + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + events.hideCursor(); + screen.clearScreen(); + screen.setBufferScan(); + screen.fadeOut(); + screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->fadeIn(); + screen.fadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); // KEYFLG = 0; - _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; - _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; + screen._scrollRow = screen._scrollCol = 0; + screen._scrollX = screen._scrollY = 0; _vm->_player->_scrollAmount = 3; _vm->_scaleI = 255; _game->_plane._xCount = 0; _game->_plane._planeCount = 0; - while (true) { - int _vbCount = 4; - if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth == _vm->_room->_playFieldWidth) { - _vm->_events->showCursor(); - return; - } + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && + (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + events._vbCount = 4; + screen._scrollX += _vm->_player->_scrollAmount; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFall(); - g_system->delayMillis(10); - while(_vbCount > 0) { - // To be rewritten when NEWTIMER is done - _vm->_events->checkForNextFrameCounter(); - _vbCount--; + while (!_vm->shouldQuit() && events._vbCount > 0) { + events.pollEvents(); + g_system->delayMillis(10); } } + + events.showCursor(); } void AmazonScripts::mWhileJWalk() { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e3a46159cf..513c1596ac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -316,6 +316,9 @@ void Room::buildScreen() { } void Room::buildColumn(int playX, int screenX) { + if (playX < 0 || playX >= _playFieldWidth) + return; + const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; -- cgit v1.2.3 From 7ce1da3ba47bcc7092aa7ff12b9fe1102b707e06 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 22:40:22 -0500 Subject: ACCESS: Some cleanup of remaining game cutscenes code --- engines/access/amazon/amazon_scripts.cpp | 81 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 8e33ae614d..53ac4be869 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -455,6 +455,10 @@ void AmazonScripts::mWhileFall() { } void AmazonScripts::mWhileJWalk() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Player &player = *_vm->_player; + const int jungleObj[7][4] = { {2, 77, 0, 40}, {0, 290, 0, 50}, @@ -465,22 +469,22 @@ void AmazonScripts::mWhileJWalk() { {1, -150, 0, 30}, }; - _vm->_screen->fadeOut(); - _vm->_events->hideCursor(); - _vm->_screen->clearScreen(); + screen.fadeOut(); + events.hideCursor(); + screen.clearScreen(); _vm->_buffer2.clearBuffer(); - _vm->_screen->setBufferScan(); - _vm->_screen->_scrollX = 0; + screen.setBufferScan(); + screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->fadeIn(); + screen.fadeIn(); // KEYFLG = 0; - _vm->_player->_xFlag = 1; - _vm->_player->_yFlag = 0; - _vm->_player->_moveTo.x = 160; - _vm->_player->_move = UP; + player._xFlag = 1; + player._yFlag = 0; + player._moveTo.x = 160; + player._move = UP; _game->_plane._xCount = 2; _xTrack = 10; @@ -503,35 +507,36 @@ void AmazonScripts::mWhileJWalk() { _pObjXl[i] = _pObjYl[i] = 0; } - while (true) { + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) { _vm->_images.clear(); - int _vbCount = 6; - if (_vm->_player->_xFlag == 2) { - _vm->_events->showCursor(); - return; - } - + events._vbCount = 6; + _pImgNum[0] = _game->_plane._xCount; if (_game->_plane._xCount == 2) ++_game->_plane._xCount; else --_game->_plane._xCount; - _vm->_player->checkMove(); - _vm->_player->checkScroll(); + player.checkMove(); + player.checkScroll(); pan(); scrollJWalk(); g_system->delayMillis(10); - while(_vbCount > 0) { - // To be rewritten when NEWTIMER is done - _vm->_events->checkForNextFrameCounter(); - _vbCount--; + while (!_vm->shouldQuit() && events._vbCount > 0) { + events.pollEvents(); + g_system->delayMillis(10); } } + + _vm->_images.clear(); + events.showCursor(); } void AmazonScripts::mWhileDoOpen() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + const int openObj[10][4] = { {8, -80, 120, 30}, {13, 229, 0, 50}, @@ -545,12 +550,12 @@ void AmazonScripts::mWhileDoOpen() { {4, -280, 40, 120}, }; - _vm->_screen->setBufferScan(); - _vm->_events->hideCursor(); - _vm->_screen->forceFadeOut(); + screen.setBufferScan(); + events.hideCursor(); + screen.forceFadeOut(); _game->_skipStart = false; if (_vm->_conversation != 2) { - _vm->_screen->setPanel(3); + screen.setPanel(3); _game->startChapter(1); _game->establishCenter(0, 1); } @@ -594,7 +599,7 @@ void AmazonScripts::mWhileDoOpen() { _vm->_sound->newMusic(10, 0); bool startFl = false; - while (true) { + while (!_vm->shouldQuit()) { _vm->_images.clear(); _vm->_animation->animate(0); _vm->_animation->animate(1); @@ -605,29 +610,28 @@ void AmazonScripts::mWhileDoOpen() { _vm->copyBlocks(); if (!startFl) { startFl = true; - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); } - _vm->_events->pollEvents(); + events.pollEvents(); warning("TODO: check on KEYBUFCNT"); - if (_vm->_events->_leftButton || _vm->_events->_rightButton) { + if (events._leftButton || events._rightButton) { _game->_skipStart = true; _vm->_sound->newMusic(10, 1); break; } if (_xCam > 680) { - warning("FIXME: _vbCount should be handled in NEWTIMER"); - int _vbCount = 125; - while(_vbCount > 0) { - // To be rewritten when NEWTIMER is done - _vm->_events->checkForNextFrameCounter(); - _vbCount--; + events._vbCount = 125; + + while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) { + events.pollEvents(); + g_system->delayMillis(10); } break; } } - _vm->_events->showCursor(); + events.showCursor(); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); warning("TODO: delete _roomInfo;"); @@ -636,6 +640,7 @@ void AmazonScripts::mWhileDoOpen() { _vm->_newRects.clear(); _vm->_numAnimTimers = 0; _vm->_images.clear(); + if (_vm->_conversation == 2) { Resource *spriteData = _vm->_files->loadFile(28, 37); _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData); -- cgit v1.2.3 From 0ed120b9ff380bc59a96214c0e3ea2b60bb71c8f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Nov 2014 23:08:18 -0500 Subject: ACCESS: Fix buffer source when clearing speech bubbles --- engines/access/bubble_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 37b757f8d9..9f47c905bc 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -54,7 +54,7 @@ void BubbleBox::clearBubbles() { r.left -= 2; r.right = MIN(r.right, (int16)_vm->_screen->w); - _vm->_screen->copyBlock(&_vm->_buffer2, r); + _vm->_screen->copyBlock(&_vm->_buffer1, r); } // Clear the list -- cgit v1.2.3 From 38edbfb4bcbdfe819a133ede25bd85b19d12df60 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Nov 2014 10:28:29 +0100 Subject: ACCESS: Little cleanup in roomMenu --- engines/access/amazon/amazon_room.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index fb849d27fa..db46b4836c 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -148,13 +148,14 @@ void AmazonRoom::roomMenu() { SpriteResource *spr = new SpriteResource(_vm, iconData); delete iconData; - _vm->_screen->saveScreen(); - _vm->_screen->setDisplayScan(); - _vm->_destIn = _vm->_screen; // TODO: Redundant - _vm->_screen->plotImage(spr, 0, Common::Point(0, 177)); - _vm->_screen->plotImage(spr, 1, Common::Point(143, 177)); + Screen &screen = *_vm->_screen; + screen.saveScreen(); + screen.setDisplayScan(); + _vm->_destIn = &screen; // TODO: Redundant + screen.plotImage(spr, 0, Common::Point(0, 177)); + screen.plotImage(spr, 1, Common::Point(143, 177)); - _vm->_screen->restoreScreen(); + screen.restoreScreen(); delete spr; } -- cgit v1.2.3 From 26b632a9eb36f8e5e8874b50666b3d739dd1416f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 10 Nov 2014 10:29:39 +0100 Subject: ACCESS: Fix display in cmdDeath() --- engines/access/access.cpp | 13 ++++++------- engines/access/font.cpp | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a1f6430965..b309e92b29 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -325,16 +325,15 @@ void AccessEngine::printText(ASurface *s, const Common::String &msg) { _fonts._font2._fontColors[1] = 28; _fonts._font2._fontColors[2] = 29; _fonts._font2._fontColors[3] = 30; - _fonts._font2.drawString(s, line, s->_printOrg); - s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); - if (lastLine) - break; + s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); - _events->waitKeyMouse(); - _buffer2.copyBuffer(s); - s->_printOrg.y = s->_printStart.y; + if (s->_printOrg.y >_printEnd && !lastLine) { + _events->waitKeyMouse(); + s->copyBuffer(&_buffer2); + s->_printOrg.y = s->_printStart.y; + } if (lastLine) break; diff --git a/engines/access/font.cpp b/engines/access/font.cpp index ffc1715c39..5eaf0b0ca8 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -111,7 +111,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w // Reached maximum allowed size // If this was the last character of the string, let it go if (*src == '\0') - break; + return true; // Work backwards to find space at the start of the current word // as a point to split the line on -- cgit v1.2.3 From 0e01c3623a499fd69acef789bb4c2a6c39091b99 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 12:18:16 -0500 Subject: ACCESS: Fixes to pan method --- engines/access/amazon/amazon_scripts.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 53ac4be869..189f634aa6 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -295,18 +295,18 @@ void AmazonScripts::doFallCell() { void AmazonScripts::pan() { _zCam += _zTrack; _xCam += _xTrack; - int tx = (_xCam << 8) / _zCam; + int tx = (_xTrack << 8) / _zCam; _yCam += _yTrack; - int ty = (_yCam << 8) / _zCam; + int ty = (_yTrack << 8) / _zCam; if (_vm->_timers[24]._flag != 1) { ++_vm->_timers[24]._flag; for (int i = 0; i < _pNumObj; i++) { - _pObjZ[i] = _zTrack; - _pObjXl[i] += tx * _zTrack; - _pObjX[i] += _pObjXl[i]; - _pObjYl[i] += ty * _zTrack; - _pObjY[i] += _pObjYl[i]; + _pObjZ[i] += _zTrack; + _pObjXl[i] += (_pObjZ[i] * tx) & 0xff; + _pObjX[i] += (_pObjZ[i] * tx) >> 8; + _pObjYl[i] += (_pObjZ[i] * ty) & 0xff; + _pObjY[i] += (_pObjZ[i] * ty) >> 8; } } @@ -317,6 +317,8 @@ void AmazonScripts::pan() { ie._offsetY = 0xFF; ie._spritesPtr = _pObject[i]; ie._frameNumber = _pImgNum[i]; + + _vm->_images.addToList(&ie); } } -- cgit v1.2.3 From 878038fe07ed750a4616d4a86dfb2a9f9873d245 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 12:25:13 -0500 Subject: ACCESS: Fix redundant pointer references in adding items to _images list --- engines/access/amazon/amazon_scripts.cpp | 4 ++-- engines/access/animation.cpp | 2 +- engines/access/asurface.cpp | 4 ++-- engines/access/asurface.h | 2 +- engines/access/player.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 189f634aa6..3ccca2bd2d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -318,7 +318,7 @@ void AmazonScripts::pan() { ie._spritesPtr = _pObject[i]; ie._frameNumber = _pImgNum[i]; - _vm->_images.addToList(&ie); + _vm->_images.addToList(ie); } } @@ -810,7 +810,7 @@ void AmazonScripts::plotInactive() { _vm->_inactive._offsetY = _game->_inactiveYOff; _vm->_inactive._frameNumber = 0; - _vm->_images.addToList(&_vm->_inactive); + _vm->_images.addToList(_vm->_inactive); } diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 03f349e34a..de44740c7f 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -232,7 +232,7 @@ void Animation::setFrame1(AnimationFrame *frame) { ie._position = part->_position + _vm->_animation->_base; ie._offsetY = part->_offsetY - ie._position.y; - _vm->_images.addToList(&ie); + _vm->_images.addToList(ie); } } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index cf8bf0766f..d36f6e4ba1 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -90,9 +90,9 @@ static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY); } -void ImageEntryList::addToList(ImageEntry *ie) { +void ImageEntryList::addToList(ImageEntry &ie) { assert(size() < 35); - push_back(*ie); + push_back(ie); Common::sort(begin(), end(), sortImagesY); } diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 5c164f0e59..d066589f84 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -144,7 +144,7 @@ public: class ImageEntryList : public Common::Array { public: - void addToList(ImageEntry *ie); + void addToList(ImageEntry &ie); }; } // End of namespace Access diff --git a/engines/access/player.cpp b/engines/access/player.cpp index ba5ba8924f..2abe9ad097 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -667,7 +667,7 @@ void Player::plotCom1() { void Player::plotCom2() { if (!_playerOff) - _vm->_images.addToList(this); + _vm->_images.addToList(*this); } void Player::plotCom3() { -- cgit v1.2.3 From 340a3fa91bc6168f5e073a33afd48a083fb14d10 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 13:29:24 -0500 Subject: ACCESS: Fix player walking in jungle cutscene --- engines/access/amazon/amazon_scripts.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 3ccca2bd2d..a22f04b0de 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -461,7 +461,7 @@ void AmazonScripts::mWhileJWalk() { EventsManager &events = *_vm->_events; Player &player = *_vm->_player; - const int jungleObj[7][4] = { + static const int JUNGLE_OBJ[7][4] = { {2, 77, 0, 40}, {0, 290, 0, 50}, {1, 210, 0, 70}, @@ -478,15 +478,16 @@ void AmazonScripts::mWhileJWalk() { screen.setBufferScan(); screen._scrollX = 0; + // Build the initial jungle scene and fade it in _vm->_room->buildScreen(); _vm->copyBF2Vid(); screen.fadeIn(); - // KEYFLG = 0; + // Set up the player to walk horizontally player._xFlag = 1; player._yFlag = 0; player._moveTo.x = 160; - player._move = UP; + player._playerMove = true; _game->_plane._xCount = 2; _xTrack = 10; @@ -502,10 +503,10 @@ void AmazonScripts::mWhileJWalk() { _pNumObj = 7; for (int i = 0; i < _pNumObj; i++) { _pObject[i] = _vm->_objectsTable[24]; - _pImgNum[i] = jungleObj[i][0]; - _pObjX[i] = jungleObj[i][1]; - _pObjY[i] = jungleObj[i][2]; - _pObjZ[i] = jungleObj[i][3]; + _pImgNum[i] = JUNGLE_OBJ[i][0]; + _pObjX[i] = JUNGLE_OBJ[i][1]; + _pObjY[i] = JUNGLE_OBJ[i][2]; + _pObjZ[i] = JUNGLE_OBJ[i][3]; _pObjXl[i] = _pObjYl[i] = 0; } -- cgit v1.2.3 From 4d82191f34c2c08f250914f52b183914e26e4df9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 13:35:15 -0500 Subject: ACCESS: Fix crashes for scene debugger command when launched from cmdCheckTimer --- engines/access/scripts.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 9f321947f2..34d5372b56 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -46,6 +46,7 @@ Scripts::~Scripts() { void Scripts::setScript(Resource *res) { _resource = res; _data = res->_stream; + _endFlag = true; } void Scripts::freeScriptData() { @@ -416,6 +417,12 @@ void Scripts::cmdCheckTimer() { _vm->_events->pollEvents(); _vm->_canSaveLoad = false; + // Since the ScummVM debugger can be launched from the above point, we need + // to check whether the script needs to be ended here, since some commands, + // like the scene command, can change the current script + if (_endFlag) + return; + if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { _vm->_events->zeroKeys(); _vm->_timers[9]._timer = 0; -- cgit v1.2.3 From a97bbb86c4c40a10e67b358372743c919a5ee59d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 16:32:16 -0500 Subject: ACCESS: Fix incorrect screen draw during setup of bubble boxes --- engines/access/bubble_box.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 9f47c905bc..ff6c4de53d 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -67,7 +67,7 @@ void BubbleBox::placeBubble(const Common::String &msg) { } void BubbleBox::placeBubble1(const Common::String &msg) { - clearBubbles(); + _bubbles.clear(); _vm->_fonts._charSet._lo = 1; _vm->_fonts._charSet._hi = 8; _vm->_fonts._charFor._lo = 29; -- cgit v1.2.3 From fa46257a77c462c92c6c6c5f7af2ef55dbb0d802 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 10 Nov 2014 18:48:16 -0500 Subject: ACCESS: Fix item Z ordering issue causing flickering in airplane rear scene --- engines/access/asurface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index d36f6e4ba1..dbbf119171 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -87,7 +87,8 @@ ImageEntry::ImageEntry() { /*------------------------------------------------------------------------*/ static bool sortImagesY(const ImageEntry &ie1, const ImageEntry &ie2) { - return (ie1._position.y + ie1._offsetY) < (ie2._position.y + ie2._offsetY); + int v = (ie1._position.y + ie1._offsetY) - (ie2._position.y + ie2._offsetY); + return (v < 0) || (v == 0 && ie1._position.y <= ie2._position.y); } void ImageEntryList::addToList(ImageEntry &ie) { -- cgit v1.2.3 From 2fe5957393d37cbae864327ddefe262cbb789211 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 02:03:07 +0100 Subject: ACCESS: Start working on ANT() --- engines/access/amazon/amazon_game.cpp | 11 ++ engines/access/amazon/amazon_game.h | 12 ++ engines/access/amazon/amazon_resources.cpp | 67 +++++++- engines/access/amazon/amazon_resources.h | 13 ++ engines/access/amazon/amazon_scripts.cpp | 253 ++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 + 6 files changed, 356 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 87aa9358cd..b1a8bbe294 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -57,6 +57,17 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _tilePos = Common::Point(0, 0); _hintLevel = 0; + _antDirection = NONE; + _pitDirection = NONE; + _antCel = 0; + _torchCel = 0; + _pitCel = 0; + _stabCel = 0; + _antPos = Common::Point(0, 0); + _antDieFl = _antEatFl = false; + _stabFl = false; + _pitPos = Common::Point(0, 0); + Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 653deefb96..0c6fb1cb41 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -149,6 +149,18 @@ public: int _canoeVXPos; int _canoeMoveCount; int _canoeFrame; + + Direction _antDirection; + Direction _pitDirection; + int _antCel; + int _torchCel; + int _pitCel; + int _stabCel; + Common::Point _antPos; + bool _antDieFl; + bool _antEatFl; + bool _stabFl; + Common::Point _pitPos; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index a1db01d7b3..5768be3c33 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1458,6 +1458,71 @@ const int COMBO_TABLE[85][4] = { { -1, -1, -1, -1 } }; -} // End of namespace Amazon +const int ANTWALK[24] = { + 0, 3, 0, + 1, 5, 0, + 2, 4, 0, + 3, 2, 0, + 4, 4, 0, + 5, 3, 0, + 6, 4, 0, + -1, -1, -1 +}; + +const int ANTEAT[33] = { + 7, 0, -1, + 8, 0, -5, + 9, 0, -11, + 10, 0, 7, + 11, 0, -3, + 12, 0, 3, + 13, 0, -1, + 9, 0, -6, + 8, 0, 11, + 7, 0, 6, + -1, -1, -1 +}; + +const int ANTDIE[21] = { + 14, 4, 8, + 15, 7, 6, + 16, 6, 7, + 17, 8, 2, + 18, 0, 0, + 19, 0, 0, + -1, -1, -1 +}; + +const int PITWALK[27] = { + 18, 0, -1, + 19, -2, 1, + 20, -2, 1, + 21, -2, 1, + 22, -2, 0, + 23, -3, 0, + 24, -3, -1, + 25, -2, -1, + -1, -1, -1 +}; + +const int PITSTAB[21] = { + 14, -2, 0, + 15, -4, 0, + 16, 3, -13, + 16, 0, 0, + 15, -3, 13, + 14, 4, 0, + -1, -1, -1 +}; + +const int TORCH[12] = { + 26, -11, -7, + 27, -12, -2, + 28, -15, -4, + -1, -1, -1 +}; + +const int SPEAR[3] = {30, -13, 1}; +} // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 7aee90003e..0d65a569c7 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -68,6 +68,19 @@ extern const int CHAPTER_JUMP[14]; extern const int COMBO_TABLE[85][4]; +extern const int ANTWALK[24]; + +extern const int ANTEAT[33]; + +extern const int ANTDIE[21]; + +extern const int PITWALK[27]; + +extern const int PITSTAB[21]; + +extern const int TORCH[12]; + +extern const int SPEAR[3]; } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index a22f04b0de..0074a5d2f5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -768,6 +768,257 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } +void AmazonScripts::PLOTPIT() { + warning("TODO: PLOTPIT"); +} + +void AmazonScripts::ANT() { + _game->_antDirection = NONE; + if (_game->_aniFlag != 1) { + _game->_aniFlag = 1; + _game->_antCel = 0; + _game->_torchCel = 0; + _game->_pitCel = 0; + + _game->_timers[15]._timer = 16; + _game->_timers[15]._initTm = 16; + _game->_timers[15]._flag = 1; + + _game->_timers[13]._timer = 5; + _game->_timers[13]._initTm = 5; + _game->_timers[13]._flag = 1; + + _game->_timers[14]._timer = 10; + _game->_timers[14]._initTm = 10; + _game->_timers[14]._flag = 1; + + _game->_antPos = Common::Point(-40, 123); + _game->_antDieFl = _game->_antEatFl = false; + _game->_stabFl = false; + _game->_pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127); + } + + const int *buf = nullptr; + if (_game->_antDieFl) { + buf = Amazon::ANTDIE; + } else if (_game->_antEatFl) { + buf = Amazon::ANTEAT; + } else if (_game->_antPos.x > 120 && _vm->_flags[198] == 1) { + _game->_antEatFl = true; + _vm->_flags[235] = 1; + _game->_antCel = 0; + buf = Amazon::ANTEAT; + } else { + buf = Amazon::ANTWALK; + if (_vm->_inventory->_inv[76]._value == 1) + _game->_antDirection = UP; + } + + int idx = _game->_antCel; + if (_game->_timers[15]._flag == 0) { + _game->_timers[15]._flag = 1; + if (_game->_antDirection == UP) { + if (_game->_antPos.x > 10) { + if (idx == 0) + idx = 36; + else + idx -= 6; + + _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _game->_antCel = idx; + } + } else { + idx += 6; + if (buf[(idx / 2)] != -1) { + _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _game->_antCel = idx; + } else if (!_game->_antDieFl) { + idx = 0; + _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _game->_antCel = idx; + } else { + idx -= 6; + if (_game->_flags[200] == 0) + _game->_flags[200] = 1; + } + } + } + + ImageEntry ie; + ie._flags = 8; + ie._spritesPtr = _pObject[61]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y); + ie._offsetY = _game->_antPos.y - 70; + _vm->_images.addToList(ie); + _game->_antCel = idx; + + if (_game->_flags[196] != 1) { + idx = _game->_pitCel; + if (_game->_stabFl == 1) { + if (_vm->_inventory->_inv[78]._value == 1) { + PLOTPIT(); + } else { + buf = Amazon::PITSTAB; + idx = _game->_stabCel; + if (_game->_timers[13]._flag == 0) { + PLOTPIT(); + } else { + _game->_timers[13]._flag = 1; + idx += 6; + if (Amazon::PITSTAB[idx] == -1) { + _game->_stabFl = false; + _game->_pitCel = 0; + _game->_pitPos.y = 127; + idx = 0; + buf = Amazon::PITWALK; + PLOTPIT(); + } else { + _game->_pitPos.x += buf[(idx / 2) + 1]; + _game->_pitPos.y += buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } + } + } + } else { + buf = Amazon::PITWALK; + if (_game->_timers[13]._flag != 0) { + PLOTPIT(); + } else { + _game->_timers[13]._flag = 1; + _vm->_events->pollEvents(); + if (_vm->_events->_leftButton) { + Common::Point pt = _vm->_events->calcRawMouse(); + if (pt.x < _game->_pitPos.x) { + if (_game->_pitDirection == UP) { + _game->_pitDirection = NONE; + _game->_pitPos.y = 127; + } + idx = _game->_pitCel; + buf = Amazon::PITWALK; + idx += 6; + if (buf[idx / 2] == -1) { + idx = 0; + _game->_pitPos.y = 127; + } + _game->_pitPos.x += buf[(idx / 2) + 1]; + _game->_pitPos.y += buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } else if (pt.x > _game->_pitPos.x) { + if (_game->_pitDirection == NONE) { + _game->_pitDirection = UP; + _game->_pitPos.y = 127; + idx = _game->_pitCel; + buf = Amazon::PITWALK; + if (_game->_pitPos.x >= 230) + PLOTPIT(); + else { + if (idx == 0) { + idx = 48; + _game->_pitPos.y = 127; + } + idx -= 6; + _game->_pitPos.x -= buf[(idx / 2) + 1]; + _game->_pitPos.y -= buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } + } + } else { + PLOTPIT(); + } + } else { + buf = Amazon::PITWALK; + if (_vm->_player->_playerDirection == UP) { + if (_vm->_inventory->_inv[78]._value == 1) { + PLOTPIT(); + } else { + if (_game->_stabFl) { + buf = Amazon::PITSTAB; + idx = _game->_stabCel; + if (_game->_timers[13]._flag == 0) { + PLOTPIT(); + } else { + _game->_timers[13]._flag = 1; + idx += 6; + if (Amazon::PITSTAB[idx] == -1) { + _game->_stabFl = false; + _game->_pitCel = 0; + _game->_pitPos.y = 127; + idx = 0; + buf = Amazon::PITWALK; + PLOTPIT(); + } else { + _game->_pitPos.x += buf[(idx / 2) + 1]; + _game->_pitPos.y += buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } + } + } else { + _game->_stabFl = true; + _game->_pitCel = 0; + idx = 0; + _game->_stabCel = 0; + int dist = _game->_pitPos.x - _game->_antPos.x; + if (!_game->_antEatFl || _game->_antDieFl || (dist > 80)) + PLOTPIT(); + else { + _game->_antDieFl = true; + _game->_antCel = 0; + _game->_antPos.y = 123; + _vm->_sound->playSound(1); + PLOTPIT(); + } + } + } + } else if (_vm->_player->_playerDirection == LEFT) { + if (_game->_pitDirection == UP) { + _game->_pitDirection = NONE; + _game->_pitPos.y = 127; + } + idx = _game->_pitCel; + buf = Amazon::PITWALK; + idx += 6; + if (buf[idx / 2] == -1) { + idx = 0; + _game->_pitPos.y = 127; + } + _game->_pitPos.x += buf[(idx / 2) + 1]; + _game->_pitPos.y += buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } else if (_vm->_player->_playerDirection == RIGHT) { + if (_game->_pitDirection == NONE) { + _game->_pitDirection = UP; + _game->_pitPos.y = 127; + idx = _game->_pitCel; + buf = Amazon::PITWALK; + if (_game->_pitPos.x >= 230) + PLOTPIT(); + else { + if (idx == 0) { + idx = 48; + _game->_pitPos.y = 127; + } + idx -= 6; + _game->_pitPos.x -= buf[(idx / 2) + 1]; + _game->_pitPos.y -= buf[(idx / 2) + 2]; + _game->_pitCel = idx; + PLOTPIT(); + } + } + } else { + PLOTPIT(); + } + } + } + } + } +} + void AmazonScripts::boatWalls(int param1, int param2) { if (param1 == 1) _vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42); @@ -845,7 +1096,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO RIVER"); break; case 14: - warning("TODO ANT"); + ANT(); break; case 15: boatWalls(param1, param2); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 06ed6e5d01..9733c1c391 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -75,6 +75,8 @@ protected: void guardSee(); void setGuardFrame(); void guard(); + void PLOTPIT(); + void ANT(); void loadBackground(int param1, int param2); void plotInactive(); void setInactive(); -- cgit v1.2.3 From b874ddd31573ee491fd0780e81810913c7a9ff2c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 08:15:50 +0100 Subject: ACCESS: Refactor ANT --- engines/access/amazon/amazon_scripts.cpp | 251 +++++++++++++------------------ engines/access/amazon/amazon_scripts.h | 5 +- 2 files changed, 105 insertions(+), 151 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 0074a5d2f5..8553babccf 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -768,10 +768,89 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } -void AmazonScripts::PLOTPIT() { +void AmazonScripts::PLOTPIT(int idx, const int *buf) { warning("TODO: PLOTPIT"); } +int AmazonScripts::antHandleRight(int indx, const int *buf) { + int retval = indx; + if (_game->_pitDirection == NONE) { + _game->_pitDirection = UP; + _game->_pitPos.y = 127; + } + retval = _game->_pitCel; + buf = Amazon::PITWALK; + if (_game->_pitPos.x < 230) { + if (retval == 0) { + retval = 48; + _game->_pitPos.y = 127; + } + retval -= 6; + _game->_pitPos.x -= buf[(retval / 2) + 1]; + _game->_pitPos.y -= buf[(retval / 2) + 2]; + _game->_pitCel = retval; + } + return retval; +} + +int AmazonScripts::antHandleLeft(int indx, const int *buf) { + int retval = indx; + if (_game->_pitDirection == UP) { + _game->_pitDirection = NONE; + _game->_pitPos.y = 127; + } + retval = _game->_pitCel; + buf = Amazon::PITWALK; + retval += 6; + if (buf[retval / 2] == -1) { + retval = 0; + _game->_pitPos.y = 127; + } + _game->_pitPos.x += buf[(retval / 2) + 1]; + _game->_pitPos.y += buf[(retval / 2) + 2]; + _game->_pitCel = retval; + + return retval; +} + +int AmazonScripts::antHandleStab(int indx, const int *buf) { + int retval = indx; + if (_vm->_inventory->_inv[78]._value != 1) { + if (_game->_stabFl) { + buf = Amazon::PITSTAB; + retval = _game->_stabCel; + if (_game->_timers[13]._flag == 0) { + _game->_timers[13]._flag = 1; + retval += 6; + if (Amazon::PITSTAB[retval] == -1) { + _game->_stabFl = false; + _game->_pitCel = 0; + _game->_pitPos.y = 127; + retval = 0; + buf = Amazon::PITWALK; + } else { + _game->_pitPos.x += buf[(retval / 2) + 1]; + _game->_pitPos.y += buf[(retval / 2) + 2]; + _game->_pitCel = retval; + } + } + } else { + _game->_stabFl = true; + _game->_pitCel = 0; + retval = 0; + _game->_stabCel = 0; + int dist = _game->_pitPos.x - _game->_antPos.x; + if (_game->_antEatFl && !_game->_antDieFl && (dist <= 80)) { + _game->_antDieFl = true; + _game->_antCel = 0; + _game->_antPos.y = 123; + _vm->_sound->playSound(1); + } + } + } + return retval; +} + void AmazonScripts::ANT() { _game->_antDirection = NONE; if (_game->_aniFlag != 1) { @@ -856,166 +935,38 @@ void AmazonScripts::ANT() { if (_game->_flags[196] != 1) { idx = _game->_pitCel; if (_game->_stabFl == 1) { - if (_vm->_inventory->_inv[78]._value == 1) { - PLOTPIT(); - } else { - buf = Amazon::PITSTAB; - idx = _game->_stabCel; - if (_game->_timers[13]._flag == 0) { - PLOTPIT(); - } else { - _game->_timers[13]._flag = 1; - idx += 6; - if (Amazon::PITSTAB[idx] == -1) { - _game->_stabFl = false; - _game->_pitCel = 0; - _game->_pitPos.y = 127; - idx = 0; - buf = Amazon::PITWALK; - PLOTPIT(); - } else { - _game->_pitPos.x += buf[(idx / 2) + 1]; - _game->_pitPos.y += buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } - } - } + idx = antHandleStab(idx, buf); } else { buf = Amazon::PITWALK; - if (_game->_timers[13]._flag != 0) { - PLOTPIT(); - } else { + if (_game->_timers[13]._flag == 0) { _game->_timers[13]._flag = 1; _vm->_events->pollEvents(); if (_vm->_events->_leftButton) { Common::Point pt = _vm->_events->calcRawMouse(); - if (pt.x < _game->_pitPos.x) { - if (_game->_pitDirection == UP) { - _game->_pitDirection = NONE; - _game->_pitPos.y = 127; - } - idx = _game->_pitCel; - buf = Amazon::PITWALK; - idx += 6; - if (buf[idx / 2] == -1) { - idx = 0; - _game->_pitPos.y = 127; - } - _game->_pitPos.x += buf[(idx / 2) + 1]; - _game->_pitPos.y += buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } else if (pt.x > _game->_pitPos.x) { - if (_game->_pitDirection == NONE) { - _game->_pitDirection = UP; - _game->_pitPos.y = 127; - idx = _game->_pitCel; - buf = Amazon::PITWALK; - if (_game->_pitPos.x >= 230) - PLOTPIT(); - else { - if (idx == 0) { - idx = 48; - _game->_pitPos.y = 127; - } - idx -= 6; - _game->_pitPos.x -= buf[(idx / 2) + 1]; - _game->_pitPos.y -= buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } - } - } else { - PLOTPIT(); - } + if (pt.x < _game->_pitPos.x) + idx = antHandleLeft(idx, buf); + else if (pt.x > _game->_pitPos.x) + idx = antHandleRight(idx, buf); } else { buf = Amazon::PITWALK; - if (_vm->_player->_playerDirection == UP) { - if (_vm->_inventory->_inv[78]._value == 1) { - PLOTPIT(); - } else { - if (_game->_stabFl) { - buf = Amazon::PITSTAB; - idx = _game->_stabCel; - if (_game->_timers[13]._flag == 0) { - PLOTPIT(); - } else { - _game->_timers[13]._flag = 1; - idx += 6; - if (Amazon::PITSTAB[idx] == -1) { - _game->_stabFl = false; - _game->_pitCel = 0; - _game->_pitPos.y = 127; - idx = 0; - buf = Amazon::PITWALK; - PLOTPIT(); - } else { - _game->_pitPos.x += buf[(idx / 2) + 1]; - _game->_pitPos.y += buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } - } - } else { - _game->_stabFl = true; - _game->_pitCel = 0; - idx = 0; - _game->_stabCel = 0; - int dist = _game->_pitPos.x - _game->_antPos.x; - if (!_game->_antEatFl || _game->_antDieFl || (dist > 80)) - PLOTPIT(); - else { - _game->_antDieFl = true; - _game->_antCel = 0; - _game->_antPos.y = 123; - _vm->_sound->playSound(1); - PLOTPIT(); - } - } - } - } else if (_vm->_player->_playerDirection == LEFT) { - if (_game->_pitDirection == UP) { - _game->_pitDirection = NONE; - _game->_pitPos.y = 127; - } - idx = _game->_pitCel; - buf = Amazon::PITWALK; - idx += 6; - if (buf[idx / 2] == -1) { - idx = 0; - _game->_pitPos.y = 127; - } - _game->_pitPos.x += buf[(idx / 2) + 1]; - _game->_pitPos.y += buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } else if (_vm->_player->_playerDirection == RIGHT) { - if (_game->_pitDirection == NONE) { - _game->_pitDirection = UP; - _game->_pitPos.y = 127; - idx = _game->_pitCel; - buf = Amazon::PITWALK; - if (_game->_pitPos.x >= 230) - PLOTPIT(); - else { - if (idx == 0) { - idx = 48; - _game->_pitPos.y = 127; - } - idx -= 6; - _game->_pitPos.x -= buf[(idx / 2) + 1]; - _game->_pitPos.y -= buf[(idx / 2) + 2]; - _game->_pitCel = idx; - PLOTPIT(); - } - } - } else { - PLOTPIT(); - } + if (_vm->_player->_playerDirection == UP) + idx = antHandleStab(idx, buf); + else if (_vm->_player->_playerDirection == LEFT) + idx = antHandleLeft(idx, buf); + else if (_vm->_player->_playerDirection == RIGHT) + idx = antHandleRight(idx, buf); } } } + PLOTPIT(idx, buf); + } + + if (!_game->_antDieFl) { + int dist = _game->_pitPos.x - _game->_antPos.x; + if ((_game->_antEatFl && (dist <= 45)) || (!_game->_antEatFl && (dist <= 80))) { + _game->_flags[199] = 1; + _game->_aniFlag = 0; + } } } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 9733c1c391..fc6fb0a7e3 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -75,7 +75,10 @@ protected: void guardSee(); void setGuardFrame(); void guard(); - void PLOTPIT(); + void PLOTPIT(int idx, const int *buf); + int antHandleRight(int indx, const int *buf); + int antHandleLeft(int indx, const int *buf); + int antHandleStab(int indx, const int *buf); void ANT(); void loadBackground(int param1, int param2); void plotInactive(); -- cgit v1.2.3 From c3660acf63e684bdb90efd4cb7fb1fedd3ed1ea0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 08:37:37 +0100 Subject: ACCESS: Implement plotPit() --- engines/access/amazon/amazon_scripts.cpp | 41 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 3 ++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 8553babccf..d0b4d7ae2a 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -768,8 +768,43 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } -void AmazonScripts::PLOTPIT(int idx, const int *buf) { - warning("TODO: PLOTPIT"); +void AmazonScripts::plotTorchSpear(int indx, const int *buf) { + int idx = indx; + + ImageEntry ie; + ie._flags = 8; + ie._spritesPtr = _pObject[62]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]); + ie._offsetY = 255; + _vm->_images.addToList(ie); +} + +void AmazonScripts::plotPit(int indx, const int *buf) { + int idx = indx; + ImageEntry ie; + ie._flags = 8; + ie._spritesPtr = _pObject[62]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y); + ie._offsetY = _game->_pitPos.y; + _vm->_images.addToList(ie); + + _vm->_player->_rawPlayer = _game->_pitPos; + if (_vm->_inventory->_inv[76]._value == 1) { + idx = _game->_torchCel; + buf = Amazon::TORCH; + _vm->_timers[14]._flag = 1; + idx += 6; + if (buf[idx / 2] == -1) + idx = 0; + _game->_torchCel = idx; + plotTorchSpear(idx, buf); + } else if (!_game->_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { + idx = 0; + buf = Amazon::SPEAR; + plotTorchSpear(idx, buf); + } } int AmazonScripts::antHandleRight(int indx, const int *buf) { @@ -958,7 +993,7 @@ void AmazonScripts::ANT() { } } } - PLOTPIT(idx, buf); + plotPit(idx, buf); } if (!_game->_antDieFl) { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index fc6fb0a7e3..7e42c0ca36 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -75,7 +75,8 @@ protected: void guardSee(); void setGuardFrame(); void guard(); - void PLOTPIT(int idx, const int *buf); + void plotTorchSpear(int indx, const int *buf); + void plotPit(int indx, const int *buf); int antHandleRight(int indx, const int *buf); int antHandleLeft(int indx, const int *buf); int antHandleStab(int indx, const int *buf); -- cgit v1.2.3 From 15da1cc639faf09984b1a228a25ad829b98cd331 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 19:28:05 +0100 Subject: ACCESS: Fix some parameters in ANT --- engines/access/amazon/amazon_scripts.cpp | 10 +++++----- engines/access/amazon/amazon_scripts.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d0b4d7ae2a..0642119b9e 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -768,7 +768,7 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } -void AmazonScripts::plotTorchSpear(int indx, const int *buf) { +void AmazonScripts::plotTorchSpear(int indx, const int *&buf) { int idx = indx; ImageEntry ie; @@ -780,7 +780,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *buf) { _vm->_images.addToList(ie); } -void AmazonScripts::plotPit(int indx, const int *buf) { +void AmazonScripts::plotPit(int indx, const int *&buf) { int idx = indx; ImageEntry ie; ie._flags = 8; @@ -807,7 +807,7 @@ void AmazonScripts::plotPit(int indx, const int *buf) { } } -int AmazonScripts::antHandleRight(int indx, const int *buf) { +int AmazonScripts::antHandleRight(int indx, const int *&buf) { int retval = indx; if (_game->_pitDirection == NONE) { _game->_pitDirection = UP; @@ -828,7 +828,7 @@ int AmazonScripts::antHandleRight(int indx, const int *buf) { return retval; } -int AmazonScripts::antHandleLeft(int indx, const int *buf) { +int AmazonScripts::antHandleLeft(int indx, const int *&buf) { int retval = indx; if (_game->_pitDirection == UP) { _game->_pitDirection = NONE; @@ -848,7 +848,7 @@ int AmazonScripts::antHandleLeft(int indx, const int *buf) { return retval; } -int AmazonScripts::antHandleStab(int indx, const int *buf) { +int AmazonScripts::antHandleStab(int indx, const int *&buf) { int retval = indx; if (_vm->_inventory->_inv[78]._value != 1) { if (_game->_stabFl) { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 7e42c0ca36..9d741158a8 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -75,11 +75,11 @@ protected: void guardSee(); void setGuardFrame(); void guard(); - void plotTorchSpear(int indx, const int *buf); - void plotPit(int indx, const int *buf); - int antHandleRight(int indx, const int *buf); - int antHandleLeft(int indx, const int *buf); - int antHandleStab(int indx, const int *buf); + void plotTorchSpear(int indx, const int *&buf); + void plotPit(int indx, const int *&buf); + int antHandleRight(int indx, const int *&buf); + int antHandleLeft(int indx, const int *&buf); + int antHandleStab(int indx, const int *&buf); void ANT(); void loadBackground(int param1, int param2); void plotInactive(); -- cgit v1.2.3 From ba8f4941b5ed387999ec1f30c90e237b048e9d76 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 22:20:46 +0100 Subject: ACCESS: Add missing code in guard() --- engines/access/amazon/amazon_scripts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 0642119b9e..e2fea04960 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -731,7 +731,8 @@ void AmazonScripts::guard() { if (_game->_guard._position.y <= 89) { _game->_guard._position.y = 89; _game->_guardLocation = 4; - warning("CHECME: unused flag121"); + if (_game->_flags[121] == 1) + _game->_guardLocation = 5; } break; default: -- cgit v1.2.3 From 37431dcedfddbac02b450affa9346d6c2581e673 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 23:12:44 +0100 Subject: ACCESS: Implement guardSee and setGuardFrame --- engines/access/amazon/amazon_scripts.cpp | 48 ++++++++++++++++++++++++++++++-- engines/access/amazon/amazon_scripts.h | 2 ++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index e2fea04960..faf2ede386 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -683,12 +683,56 @@ void AmazonScripts::mWhile(int param1) { } } +void AmazonScripts::CHKVLINE() { + warning("TODO: CHKVLINE()"); +} + +void AmazonScripts::CHKHLINE() { + warning("TODO: CHKHLINE()"); +} + void AmazonScripts::guardSee() { - warning("TODO: guardSee()"); + int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; + _game->_flags[140] = 0; + if (tmpY > _game->_guard._position.y) + return; + + tmpY += _vm->_screen->_vWindowLinesTall; + tmpY -= 11; + + if (tmpY < _game->_guard._position.y) + return; + + _game->_guardFind = 1; + _game->_flags[140] = 1; + + for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { + _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; + _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; + _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; + _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; + if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { + CHKVLINE(); + if (_game->_guardFind == 0) + return; + } else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { + CHKHLINE(); + if (_game->_guardFind == 0) + return; + } + } } void AmazonScripts::setGuardFrame() { - warning("TODO: setGuardFrame()"); + ImageEntry ie; + ie._flags = 8; + if (_game->_guardLocation == 4) + ie._flags |= 2; + ie._spritesPtr = _vm->_objectsTable[37]; + ie._frameNumber = _game->_guard._guardCel; + ie._position = _game->_guard._position; + ie._offsetY = 10; + _vm->_images.addToList(ie); } void AmazonScripts::guard() { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 9d741158a8..9d5e4d8db1 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -72,6 +72,8 @@ protected: void mWhileJWalk(); void mWhileDoOpen(); void mWhile(int param1); + void CHKVLINE(); + void CHKHLINE(); void guardSee(); void setGuardFrame(); void guard(); -- cgit v1.2.3 From c74821161b05f27fa4f37afd1f549260fc4d6c90 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 12 Nov 2014 23:26:25 +0100 Subject: ACCESS: Fix some issues in plotTorchSpear(), in plotPit() and in ANT() --- engines/access/amazon/amazon_scripts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index faf2ede386..f75d12fa18 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -818,7 +818,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) { ImageEntry ie; ie._flags = 8; - ie._spritesPtr = _pObject[62]; + ie._spritesPtr = _vm->_objectsTable[62]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]); ie._offsetY = 255; @@ -829,7 +829,7 @@ void AmazonScripts::plotPit(int indx, const int *&buf) { int idx = indx; ImageEntry ie; ie._flags = 8; - ie._spritesPtr = _pObject[62]; + ie._spritesPtr = _vm->_objectsTable[62]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y); ie._offsetY = _game->_pitPos.y; @@ -1005,7 +1005,7 @@ void AmazonScripts::ANT() { ImageEntry ie; ie._flags = 8; - ie._spritesPtr = _pObject[61]; + ie._spritesPtr = _vm->_objectsTable[61]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y); ie._offsetY = _game->_antPos.y - 70; -- cgit v1.2.3 From 4ca5cc5ab4409601ed7458d08bf08c79c96dc8f7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 13 Nov 2014 08:18:18 +0100 Subject: ACCESS: Implement chkVLine and chkHLine --- engines/access/amazon/amazon_scripts.cpp | 94 ++++++++++++++++++++++++++++++-- engines/access/amazon/amazon_scripts.h | 6 +- 2 files changed, 92 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f75d12fa18..4d08047d9c 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -683,12 +683,94 @@ void AmazonScripts::mWhile(int param1) { } } -void AmazonScripts::CHKVLINE() { - warning("TODO: CHKVLINE()"); +void AmazonScripts::VCODE(Common::Rect bounds) { + warning("TODO: VCODE()"); } -void AmazonScripts::CHKHLINE() { - warning("TODO: CHKHLINE()"); +void AmazonScripts::HCODE(Common::Rect bounds) { + warning("TODO: HCODE()"); +} + +void AmazonScripts::chkVLine() { + if (_game->_guard._position.x > _vm->_player->_rawPlayer.x) + _game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y); + else + _game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y); + + if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2) + SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); + + while (true) { + VCODE(_game->_guard._bounds); + int code = _game->_guard._gCode1 | _game->_guard._gCode2; + if (code == 10) { + _game->_guardFind = 0; + return; + } + + int code2 = _game->_guard._gCode1 & _game->_guard._gCode2; + code2 &= 5; + if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0)) + return; + + int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2; + int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2; + + if (midX < _vm->_screen->_orgX1) { + if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top)) + return; + + _game->_guard._bounds.left = midX; + _game->_guard._bounds.top = midY; + } else { + if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom)) + return; + + _game->_guard._bounds.right = midX; + _game->_guard._bounds.bottom = midY; + } + } +} + +void AmazonScripts::chkHLine() { + if (_game->_guard._position.y > _vm->_player->_rawPlayer.y) + _game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y); + else + _game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y); + + if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2) + SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); + + while (true) { + HCODE(_game->_guard._bounds); + int code = _game->_guard._gCode1 | _game->_guard._gCode2; + if (code == 5) { + _game->_guardFind = 0; + return; + } + + int code2 = _game->_guard._gCode1 & _game->_guard._gCode2; + code2 &= 10; + if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0)) + return; + + int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2; + int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2; + + if (midY < _vm->_screen->_orgY1) { + if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top)) + return; + + _game->_guard._bounds.left = midX; + _game->_guard._bounds.top = midY; + } else { + if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom)) + return; + + _game->_guard._bounds.right = midX; + _game->_guard._bounds.bottom = midY; + } + } } void AmazonScripts::guardSee() { @@ -712,11 +794,11 @@ void AmazonScripts::guardSee() { _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { - CHKVLINE(); + chkVLine(); if (_game->_guardFind == 0) return; } else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { - CHKHLINE(); + chkHLine(); if (_game->_guardFind == 0) return; } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 9d5e4d8db1..c4e4869fde 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -72,8 +72,10 @@ protected: void mWhileJWalk(); void mWhileDoOpen(); void mWhile(int param1); - void CHKVLINE(); - void CHKHLINE(); + void VCODE(Common::Rect bounds); + void HCODE(Common::Rect bounds); + void chkVLine(); + void chkHLine(); void guardSee(); void setGuardFrame(); void guard(); -- cgit v1.2.3 From c4a5c36290e59d47272cb47244f294696cc6c5c1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Nov 2014 20:30:41 -0500 Subject: ACCESS: Fix crash when talking to pilot on the plane --- engines/access/debugger.cpp | 2 +- engines/access/scripts.cpp | 4 ++-- engines/access/scripts.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 9a82168561..359b2e73a5 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -137,7 +137,7 @@ bool AmazonDebugger::Cmd_StartChapter(int argc, const char **argv) { chapterScript[2] = ROOM_SCRIPT / 256; chapterScript[3] = 0x80 + 75; // cmdChapter chapterScript[4] = strToInt(argv[1]); // chapter number - _vm->_scripts->setScript(new Resource(chapterScript, 5)); + _vm->_scripts->setScript(new Resource(chapterScript, 5), true); return false; } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 34d5372b56..9f919484ef 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -43,10 +43,10 @@ Scripts::~Scripts() { freeScriptData(); } -void Scripts::setScript(Resource *res) { +void Scripts::setScript(Resource *res, bool restartFlag) { _resource = res; _data = res->_stream; - _endFlag = true; + _endFlag = restartFlag; } void Scripts::freeScriptData() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 9860c7cde9..eaac996d4d 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -135,7 +135,7 @@ public: virtual ~Scripts(); - void setScript(Resource *data); + void setScript(Resource *data, bool restartFlag = false); void freeScriptData(); -- cgit v1.2.3 From 2daa96e2840fd608f8968226ae44715ccf26c977 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 13 Nov 2014 20:31:44 -0500 Subject: ACCESS: Fix crash in conversation screen when clicking outside response boxes --- engines/access/events.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 0287e8cb03..b05aea3025 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -254,7 +254,7 @@ Common::Point EventsManager::calcRawMouse() { int EventsManager::checkMouseBox1(Common::Array &rects) { int i = 0; - for (i = 0;; i++) { + for (i = 0; i < rects.size(); ++i) { if (rects[i].left == -1) return -1; @@ -262,6 +262,8 @@ int EventsManager::checkMouseBox1(Common::Array &rects) { && (_mousePos.y > rects[i].top) && (_mousePos.y < rects[i].bottom)) return i; } + + return -1; } bool EventsManager::isKeyMousePressed() { -- cgit v1.2.3 From 96cc1e3ac9270ca2ce60aedcbae3cca8c7410c1a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 14 Nov 2014 07:49:33 +0100 Subject: ACCESS: Implement setVerticalCode and setHorizontalCode used by the guard scene --- engines/access/amazon/amazon_scripts.cpp | 65 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 4 +- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4d08047d9c..ae7e047fb8 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -683,12 +683,65 @@ void AmazonScripts::mWhile(int param1) { } } -void AmazonScripts::VCODE(Common::Rect bounds) { - warning("TODO: VCODE()"); +void AmazonScripts::setVerticalCode(Common::Rect bounds) { + _game->_guard._gCode1 = 0; + _game->_guard._gCode2 = 0; + if (bounds.left < _vm->_screen->_orgX1) + _game->_guard._gCode1 |= 8; + else if (bounds.left == _vm->_screen->_orgX1) { + _game->_guard._gCode1 |= 8; + _game->_guard._gCode1 |= 2; + } else + _game->_guard._gCode1 |= 2; + + if (bounds.right < _vm->_screen->_orgX1) + _game->_guard._gCode2 |= 8; + else if (bounds.right == _vm->_screen->_orgX1) { + _game->_guard._gCode2 |= 8; + _game->_guard._gCode2 |= 2; + } else + _game->_guard._gCode2 |= 2; + + if (bounds.top < _vm->_screen->_orgY1) + _game->_guard._gCode1 |= 4; + else if (bounds.top > _vm->_screen->_orgY2) + _game->_guard._gCode1 |= 1; + + if (bounds.bottom < _vm->_screen->_orgY1) + _game->_guard._gCode2 |= 4; + else if (bounds.bottom > _vm->_screen->_orgY2) + _game->_guard._gCode2 |= 1; } -void AmazonScripts::HCODE(Common::Rect bounds) { - warning("TODO: HCODE()"); +void AmazonScripts::setHorizontalCode(Common::Rect bounds) { + _game->_guard._gCode1 = 0; + _game->_guard._gCode2 = 0; + + if (bounds.top < _vm->_screen->_orgY1) + _game->_guard._gCode1 |= 4; + else if (bounds.left == _vm->_screen->_orgX1) { + _game->_guard._gCode1 |= 4; + _game->_guard._gCode1 |= 1; + } else + _game->_guard._gCode1 |= 1; + + if (bounds.bottom < _vm->_screen->_orgY1) + _game->_guard._gCode2 |= 4; + else if (bounds.right == _vm->_screen->_orgX1) { + _game->_guard._gCode2 |= 4; + _game->_guard._gCode2 |= 1; + } else + _game->_guard._gCode2 |= 1; + + if (bounds.left < _vm->_screen->_orgX1) + _game->_guard._gCode1 |= 8; + else if (bounds.left > _vm->_screen->_orgX2) + _game->_guard._gCode1 |= 2; + + if (bounds.right < _vm->_screen->_orgX1) + _game->_guard._gCode2 |= 8; + else if (bounds.bottom > _vm->_screen->_orgX2) + _game->_guard._gCode2 |= 2; } void AmazonScripts::chkVLine() { @@ -701,7 +754,7 @@ void AmazonScripts::chkVLine() { SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); while (true) { - VCODE(_game->_guard._bounds); + setVerticalCode(_game->_guard._bounds); int code = _game->_guard._gCode1 | _game->_guard._gCode2; if (code == 10) { _game->_guardFind = 0; @@ -742,7 +795,7 @@ void AmazonScripts::chkHLine() { SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); while (true) { - HCODE(_game->_guard._bounds); + setHorizontalCode(_game->_guard._bounds); int code = _game->_guard._gCode1 | _game->_guard._gCode2; if (code == 5) { _game->_guardFind = 0; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index c4e4869fde..c7b72a651e 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -72,8 +72,8 @@ protected: void mWhileJWalk(); void mWhileDoOpen(); void mWhile(int param1); - void VCODE(Common::Rect bounds); - void HCODE(Common::Rect bounds); + void setVerticalCode(Common::Rect bounds); + void setHorizontalCode(Common::Rect bounds); void chkVLine(); void chkHLine(); void guardSee(); -- cgit v1.2.3 From bacb9badf859ebb4fa6c5b15f1cb46460f57ab5b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 14 Nov 2014 07:53:58 +0100 Subject: ACCESS: Fix compilation warning --- engines/access/events.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index b05aea3025..ac07a7579f 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -253,8 +253,7 @@ Common::Point EventsManager::calcRawMouse() { } int EventsManager::checkMouseBox1(Common::Array &rects) { - int i = 0; - for (i = 0; i < rects.size(); ++i) { + for (uint16 i = 0; i < rects.size(); ++i) { if (rects[i].left == -1) return -1; -- cgit v1.2.3 From 339847872b3d35cf6bec5b4d0360a2e0e815dbbd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 14 Nov 2014 08:33:33 +0100 Subject: ACCESS: Fix the call of doIntroduction --- engines/access/amazon/amazon_game.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index b1a8bbe294..fc5a44f354 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -79,11 +79,11 @@ AmazonEngine::~AmazonEngine() { } void AmazonEngine::playGame() { - // Initialise Amazon game-specific objects + // Initialize Amazon game-specific objects _room = new AmazonRoom(this); _scripts = new AmazonScripts(this); - if (_loadSaveSlot != -1) { + if (_loadSaveSlot == -1) { // Do introduction doIntroduction(); if (shouldQuit()) @@ -111,10 +111,11 @@ void AmazonEngine::doIntroduction() { _events->setCursor(CURSOR_ARROW); _events->showCursor(); _screen->setPanel(0); + _screen->setPalette(); - //TODO: Implement the rest of the intro - return; - + _events->setCursor(CURSOR_ARROW); + _events->showCursor(); + _screen->setPanel(3); doTitle(); if (shouldQuit()) return; @@ -132,6 +133,7 @@ void AmazonEngine::doIntroduction() { } } + warning("TODO - More introduction code"); doTitle(); } -- cgit v1.2.3 From 4e1394c8e34fd1163f2ef54b5cb66e6945110d96 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 15 Nov 2014 23:03:45 +0100 Subject: ACCESS: Fix intro countdown, add splashscreen and loading of scene 0 --- engines/access/amazon/amazon_game.cpp | 74 +++++++++++++++++++++++++++++------ engines/access/room.h | 4 +- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index fc5a44f354..4c2662e146 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -132,9 +132,6 @@ void AmazonEngine::doIntroduction() { return; } } - - warning("TODO - More introduction code"); - doTitle(); } void AmazonEngine::doTitle() { @@ -170,19 +167,70 @@ void AmazonEngine::doTitle() { _sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (_pCount = 0; _pCount <= 3; ++_pCount) { - if (_pCount != 3) { - _buffer2.copyFrom(_buffer1); - int id = READ_LE_UINT16(COUNTDOWN + _pCount * 2); - int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 2 + 1); - _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); - //TODO : more intro - } else { - //TODO : more intro + for (_pCount = 0; _pCount < 3; ++_pCount) { + _buffer2.copyFrom(_buffer1); + int id = COUNTDOWN[_pCount * 2]; + int xp = COUNTDOWN[_pCount * 2 + 1]; + _buffer2.plotImage(_objectsTable[0], id, Common::Point(xp, 71)); + _screen->copyFrom(_buffer2); + + _events->_vbCount = 70; + while (!shouldQuit() && _events->_vbCount > 0) { + _events->pollEvents(); + g_system->delayMillis(10); } } - //TODO : more intro + + _sound->playSound(0); + _screen->forceFadeOut(); + _events->_vbCount = 100; + while (!shouldQuit() && _events->_vbCount > 0) { + _events->pollEvents(); + g_system->delayMillis(10); + } + + _sound->freeSounds(); delete _objectsTable[0]; + _objectsTable[0] = nullptr; + + _files->_setPaletteFlag = false; + _files->loadScreen(0, 5); + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _screen->forceFadeIn(); + _sound->newMusic(1, 0); + _events->_vbCount = 700; + warning("TODO: check on KEYBUFCNT"); + while (!shouldQuit() && (_events->_vbCount > 0) && (!_events->_leftButton) && (!_events->_rightButton)) { + _events->pollEvents(); + g_system->delayMillis(10); + } + if (_events->_rightButton) { + _skipStart = true; + _room->clearRoom(); + _events->showCursor(); + return; + } + + _sound->newMusic(1, 1); + _sound->_musicRepeat = false; + _events->zeroKeys(); + _room->loadRoom(0); + _screen->clearScreen(); + _screen->setBufferScan(); + _screen->_scrollRow = _screen->_scrollCol = 0; + _screen->_scrollX = _screen->_scrollY = 0; + _player->_rawPlayer = Common::Point(0, 0); + _screen->forceFadeOut(); + _screen->_scrollX = 0; + _room->buildScreen(); + copyBF2Vid(); + _screen->forceFadeIn(); + _oldRects.clear(); + _newRects.clear(); + // KEYFLG = 0; + _player->_scrollAmount = 1; + _pCount = 1; } void AmazonEngine::doOpening() { diff --git a/engines/access/room.h b/engines/access/room.h index 810082edb4..6c8b040593 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -108,8 +108,6 @@ protected: */ void executeCommand(int commandId); - virtual void loadRoom(int roomNumber) = 0; - virtual void reloadRoom() = 0; virtual void reloadRoom1() = 0; @@ -141,6 +139,8 @@ public: void doRoom(); + virtual void loadRoom(int roomNumber) = 0; + /** * Clear all the data used by the room */ -- cgit v1.2.3 From 731d7d20394d6cb8852fcc32e9beadc46d724cc7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 16 Nov 2014 00:16:41 +0100 Subject: ACCESS: Add more intro code, including credit scrolling --- engines/access/amazon/amazon_game.cpp | 114 +++++++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 2 + 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 4c2662e146..f10c933d44 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -134,6 +134,42 @@ void AmazonEngine::doIntroduction() { } } +void AmazonEngine::doCredit() { + if (_pCount < 15) + return; + + if (_pCount <= 75) + _buffer2.plotImage(_objectsTable[0], 0, Common::Point(90, 35)); + else if (_pCount <= 210) + _buffer2.plotImage(_objectsTable[0], 1, Common::Point(65, 35)); + else if (_pCount <= 272) + _buffer2.plotImage(_objectsTable[0], 2, Common::Point(96, 45)); + else if (_pCount <= 334) + _buffer2.plotImage(_objectsTable[0], 3, Common::Point(68, 54)); + else if (_pCount <= 396) + _buffer2.plotImage(_objectsTable[0], 4, Common::Point(103, 54)); + else if (_pCount <= 458) { + _buffer2.plotImage(_objectsTable[0], 5, Common::Point(8, 5)); + _buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55)); + _buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98)); + } else if (_pCount <= 520) { + _buffer2.plotImage(_objectsTable[0], 7, Common::Point(90, 35)); + _buffer2.plotImage(_objectsTable[0], 8, Common::Point(90, 35)); + } else if (_pCount <= 580) { + _buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15)); + _buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81)); + } else + _buffer2.plotImage(_objectsTable[0], 11, Common::Point(106, 55)); +} + +void AmazonEngine::scrollTitle() { + copyBF1BF2(); + _newRects.clear(); + doCredit(); + copyRects(); + copyBF2Vid(); +} + void AmazonEngine::doTitle() { _screen->setDisplayScan(); _destIn = &_buffer2; @@ -230,7 +266,83 @@ void AmazonEngine::doTitle() { _newRects.clear(); // KEYFLG = 0; _player->_scrollAmount = 1; - _pCount = 1; + _pCount = 0; + + while(true) { + _events->pollEvents(); + if (_events->_rightButton) { + _skipStart = true; + _room->clearRoom(); + _events->showCursor(); + return; + } + + warning("TODO: check on KEYBUFCNT"); + if (_events->_leftButton) { + _room->clearRoom(); + _events->showCursor(); + return; + } + + _events->_vbCount = 4; + if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) { + _screen->_scrollX += _player->_scrollAmount; + + while (_screen->_scrollX >= TILE_WIDTH && !shouldQuit()) { + _screen->_scrollX -= TILE_WIDTH; + ++_screen->_scrollCol; + + _buffer1.moveBufferLeft(); + _room->buildColumn(_screen->_scrollCol + _screen->_vWindowWidth, _screen->_vWindowBytesWide); + } + scrollTitle(); + ++_pCount; + + while (!shouldQuit() && (_events->_vbCount > 0)) { + _events->pollEvents(); + g_system->delayMillis(10); + } + continue; + } + + _events->_vbCount = 120; + while (!shouldQuit() && (_events->_vbCount > 0)) { + _events->pollEvents(); + g_system->delayMillis(10); + } + + while(true) { + _pCount = 0; + _events->_vbCount = 3; + if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { + _room->clearRoom(); + _events->showCursor(); + return; + } + + _screen->_scrollY = _screen->_scrollY + _player->_scrollAmount; + + while (_screen->_scrollY >= TILE_HEIGHT && !shouldQuit()) { + _screen->_scrollY -= TILE_HEIGHT; + ++_screen->_scrollRow; + _buffer1.moveBufferUp(); + + _room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall * _screen->_bufferBytesWide); + + if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { + _room->clearRoom(); + _events->showCursor(); + return; + } + + scrollTitle(); + while (!shouldQuit() && (_events->_vbCount > 0)) { + _events->pollEvents(); + g_system->delayMillis(10); + } + } + } + } } void AmazonEngine::doOpening() { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 0c6fb1cb41..34a1eef775 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -95,6 +95,8 @@ private: */ void setupGame(); + void doCredit(); + void scrollTitle(); void loadEstablish(int estabIndex); void doEstablish(int screenId, int estabIndex); -- cgit v1.2.3 From 1ad11d091f03aeb437413c328c36bed1c08b73d8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 16 Nov 2014 00:40:13 +0100 Subject: ACCESS: Simplify doIntroduction() --- engines/access/amazon/amazon_game.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f10c933d44..d110a6cf44 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -117,21 +117,17 @@ void AmazonEngine::doIntroduction() { _events->showCursor(); _screen->setPanel(3); doTitle(); - if (shouldQuit()) + + if (shouldQuit() || _skipStart) return; - if (!_skipStart) { - _screen->setPanel(3); - doOpening(); - if (shouldQuit()) - return; + _screen->setPanel(3); + doOpening(); - if (!_skipStart) { - doTent(); - if (shouldQuit()) - return; - } - } + if (shouldQuit() || _skipStart) + return; + + doTent(); } void AmazonEngine::doCredit() { -- cgit v1.2.3 From f70012a115dc963f21ac531d57e593af0e5a1ccf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 16 Nov 2014 18:10:37 +0100 Subject: ACCESS: Replace doOpening by mWhileDoOpen, move openObj to Amazon Resources --- engines/access/amazon/amazon_game.cpp | 6 +----- engines/access/amazon/amazon_game.h | 5 ----- engines/access/amazon/amazon_resources.cpp | 13 +++++++++++++ engines/access/amazon/amazon_resources.h | 2 ++ engines/access/amazon/amazon_scripts.cpp | 13 ------------- engines/access/amazon/amazon_scripts.h | 7 ++++--- 6 files changed, 20 insertions(+), 26 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d110a6cf44..e9c42d0647 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -122,7 +122,7 @@ void AmazonEngine::doIntroduction() { return; _screen->setPanel(3); - doOpening(); + ((AmazonScripts *)_scripts)->mWhileDoOpen(); if (shouldQuit() || _skipStart) return; @@ -341,10 +341,6 @@ void AmazonEngine::doTitle() { } } -void AmazonEngine::doOpening() { - warning("TODO doOpening"); -} - void AmazonEngine::doTent() { warning("TODO doTent"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 34a1eef775..ba81a77658 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -80,11 +80,6 @@ private: */ void doTitle(); - /** - * Do opening sequence - */ - void doOpening(); - /** * Do tent scene of introduction */ diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 5768be3c33..925ea195a5 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1524,5 +1524,18 @@ const int TORCH[12] = { const int SPEAR[3] = {30, -13, 1}; +const int openObj[10][4] = { + {8, -80, 120, 30}, + {13, 229, 0, 50}, + {12, 78, 0, 50}, + {11, 10, 0, 50}, + {10, 178, 97, 50}, + {9, 92, 192, 50}, + {14, 38, 0, 100}, + {15, 132, 76, 100}, + {16, 142, 0, 100}, + {4, -280, 40, 120}, +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 0d65a569c7..434a0f37db 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -81,6 +81,8 @@ extern const int PITSTAB[21]; extern const int TORCH[12]; extern const int SPEAR[3]; + +extern const int openObj[10][4]; } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index ae7e047fb8..f97d789f5f 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -540,19 +540,6 @@ void AmazonScripts::mWhileDoOpen() { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; - const int openObj[10][4] = { - {8, -80, 120, 30}, - {13, 229, 0, 50}, - {12, 78, 0, 50}, - {11, 10, 0, 50}, - {10, 178, 97, 50}, - {9, 92, 192, 50}, - {14, 38, 0, 100}, - {15, 132, 76, 100}, - {16, 142, 0, 100}, - {4, -280, 40, 120}, - }; - screen.setBufferScan(); events.hideCursor(); screen.forceFadeOut(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index c7b72a651e..67e7e77009 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -35,16 +35,16 @@ class AmazonEngine; class AmazonScripts: public Scripts { private: AmazonEngine *_game; - int _xTrack; int _yTrack; int _zTrack; int _xCam; int _yCam; int _zCam; - int _pNumObj; + int _pImgNum[32]; + SpriteResource *_pObject[32]; int _pObjX[32]; @@ -70,7 +70,6 @@ protected: void mWhileFly(); void mWhileFall(); void mWhileJWalk(); - void mWhileDoOpen(); void mWhile(int param1); void setVerticalCode(Common::Rect bounds); void setHorizontalCode(Common::Rect bounds); @@ -99,6 +98,8 @@ protected: void CMDRETFLASH(); public: AmazonScripts(AccessEngine *vm); + + void mWhileDoOpen(); }; } // End of namespace Amazon -- cgit v1.2.3 From a0294b633896dda85d3dee610c4ba2f938f3d731 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 18 Nov 2014 00:36:39 +0100 Subject: ACCESS: Move setupGame before doIntroduction to fix a crash --- engines/access/amazon/amazon_game.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index e9c42d0647..44071753d2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -83,6 +83,9 @@ void AmazonEngine::playGame() { _room = new AmazonRoom(this); _scripts = new AmazonScripts(this); + // Setup the game + setupGame(); + if (_loadSaveSlot == -1) { // Do introduction doIntroduction(); @@ -90,9 +93,6 @@ void AmazonEngine::playGame() { return; } - // Setup the game - setupGame(); - _screen->clearScreen(); _screen->setPanel(0); _screen->forceFadeOut(); -- cgit v1.2.3 From 44e7051b955b7ccf12da6a8bfdbca2155f296a98 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 18 Nov 2014 11:10:34 +0100 Subject: ACCESS: Fix display height of text in chapter introduction --- engines/access/amazon/amazon_game.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 44071753d2..bc26ee3e3f 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -655,7 +655,6 @@ void AmazonEngine::startChapter(int chapter) { uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2); _printEnd = 170; - _printEnd = 155; Common::String msg((const char *)_eseg->data() + msgOffset); if (_txtPages == 0) { -- cgit v1.2.3 From 8e483e037f1851fb96fd2125bf526828cdfa6e98 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 18 Nov 2014 12:10:07 +0100 Subject: ACCESS: Fix the handling of the very last line of a text in getLine --- engines/access/font.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 5eaf0b0ca8..5686cdf3b0 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -110,8 +110,11 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w // Reached maximum allowed size // If this was the last character of the string, let it go - if (*src == '\0') + if (*src == '\0') { + line = Common::String(s.c_str(), src); + s = ""; return true; + } // Work backwards to find space at the start of the current word // as a point to split the line on -- cgit v1.2.3 From 31fc8fdaa1520d57b02c9aeb83fb4a57b4fef16e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 18 Nov 2014 14:10:01 +0100 Subject: ACCESS: Add a hack in order to make the first screen visible --- engines/access/amazon/amazon_game.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index bc26ee3e3f..d7ad12e721 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -184,6 +184,15 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->playSound(1); + // HACK: This delay has been added so that the very first screen is visible. + // The original was using disk loading time to display it, and it's too fast + // nowadays to be visible. + _events->_vbCount = 70; + while (!shouldQuit() && _events->_vbCount > 0) { + _events->pollEvents(); + g_system->delayMillis(10); + } + Resource *spriteData = _files->loadFile(0, 2); _objectsTable[0] = new SpriteResource(this, spriteData); delete spriteData; -- cgit v1.2.3 From 8939d657f701d3e40112b5b19fe49022eca8f18a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Nov 2014 20:21:35 -0500 Subject: ACCESS: Fix loading animation data in mWhileDoOpen --- engines/access/amazon/amazon_scripts.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f97d789f5f..9bb910c2ba 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -560,7 +560,11 @@ void AmazonScripts::mWhileDoOpen() { _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - warning("TODO _roomInfo = _vm->_files->loadFile(1, 1);"); + // Load animation data + _vm->_animation->freeAnimationData(); + Resource *animResource = _vm->_files->loadFile(1, 1); + _vm->_animation->loadAnimations(animResource); + delete animResource; _xTrack = 8; _yTrack = -3; -- cgit v1.2.3 From a01ddaeb1b20d4e512d8418fa2ae9b72dcaca308 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Nov 2014 20:48:53 -0500 Subject: ACCESS: Fix loading correct sprite resource in mWhileDoOpen --- engines/access/amazon/amazon_scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 9bb910c2ba..b4a1568e5a 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -550,7 +550,7 @@ void AmazonScripts::mWhileDoOpen() { _game->establishCenter(0, 1); } - Resource *data = _vm->_files->loadFile(0, 1); + Resource *data = _vm->_files->loadFile(1, 0); SpriteResource *spr = new SpriteResource(_vm, data); delete data; -- cgit v1.2.3 From b2e67a69c6dd53f2ffa720eced127dff97eb856c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Nov 2014 21:42:49 -0500 Subject: ACCESS: Fix incorrect loading of exra cells during room load --- engines/access/room.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 513c1596ac..31d1583c3e 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -796,7 +796,6 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { ExtraCell ec; ec._vid._fileNum = v; ec._vid._subfile = stream.readSint16LE(); - ec._vidSound.load(stream); _extraCells.push_back(ec); } -- cgit v1.2.3 From 8e45582492cab277c5b53884f7ec9c0a22a6e4ca Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 18 Nov 2014 21:47:42 -0500 Subject: ACCESS: Add extra shouldQuit checks during title sequence --- engines/access/amazon/amazon_game.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d7ad12e721..dba1b6fb9c 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -273,8 +273,7 @@ void AmazonEngine::doTitle() { _player->_scrollAmount = 1; _pCount = 0; - while(true) { - _events->pollEvents(); + while (!shouldQuit()) { if (_events->_rightButton) { _skipStart = true; _room->clearRoom(); @@ -293,7 +292,7 @@ void AmazonEngine::doTitle() { if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) { _screen->_scrollX += _player->_scrollAmount; - while (_screen->_scrollX >= TILE_WIDTH && !shouldQuit()) { + while (_screen->_scrollX >= TILE_WIDTH) { _screen->_scrollX -= TILE_WIDTH; ++_screen->_scrollCol; @@ -316,7 +315,7 @@ void AmazonEngine::doTitle() { g_system->delayMillis(10); } - while(true) { + while (!shouldQuit()) { _pCount = 0; _events->_vbCount = 3; if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { -- cgit v1.2.3 From e9e19446d833c784430e2947098df251583f24ce Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 19 Nov 2014 16:19:01 +0100 Subject: ACCESS: Implement doTent --- engines/access/amazon/amazon_game.cpp | 69 ++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index dba1b6fb9c..f663f03b38 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -350,7 +350,74 @@ void AmazonEngine::doTitle() { } void AmazonEngine::doTent() { - warning("TODO doTent"); + int step = 0; + _screen->setDisplayScan(); + _screen->forceFadeOut(); + _events->hideCursor(); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 39), 1)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 14), 1)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 15), 1)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 16), 1)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 31), 2)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 52), 2)); + _sound->playSound(0); + + _files->_setPaletteFlag = false; + _files->loadScreen(2, 0); + _buffer2.copyFrom(*_screen); + _buffer1.copyFrom(*_screen); + _screen->forceFadeIn(); + + _video->setVideo(_screen, Common::Point(126, 73), FileIdent(2, 1), 10); + while (!shouldQuit() && !_video->_videoEnd) { + _video->playVideo(); + if ((_video->_videoFrame == 32) || (_video->_videoFrame == 34)) + _sound->playSound(4); + else if (_video->_videoFrame == 36) { + if (step != 2) { + _sound->playSound(2); + step = 2; + } + } else if (_video->_videoFrame == 18) { + if (step != 1) { + _sound->newMusic(73, 1); + _sound->newMusic(11, 0); + step = 1; + _sound->playSound(1); + } + } + + g_system->delayMillis(10); + _events->pollEvents(); + } + + _sound->playSound(5); + _video->setVideo(_screen, Common::Point(43, 11), FileIdent(2, 2), 10); + while (!shouldQuit() && !_video->_videoEnd) { + _video->playVideo(); + if (_video->_videoFrame == 26) { + _sound->playSound(5); + } else if (_video->_videoFrame == 15) { + if (step !=3) { + _sound->playSound(3); + step = 3; + } + } + + g_system->delayMillis(10); + _events->pollEvents(); + } + + _events->_vbCount = 200; + while (!shouldQuit() && _events->_vbCount > 0) { + _events->pollEvents(); + g_system->delayMillis(10); + } + _events->showCursor(); + _sound->newMusic(11, 1); + _sound->_soundTable.clear(); + + establishCenter(0, 4); } void AmazonEngine::setupGame() { -- cgit v1.2.3 From bc050a549ca43b8571270782bc3b12cc0b31c634 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 19 Nov 2014 20:28:27 -0500 Subject: ACCESS: Implemented cmdCheckVFrame opcode --- engines/access/scripts.cpp | 9 +++++++-- engines/access/scripts.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 9f919484ef..89c8a4d0e6 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -127,7 +127,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, - &Scripts::cmdSetConPos, &Scripts::CMDCHECKVFRAME, &Scripts::cmdJumpChoice, + &Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, @@ -691,7 +691,12 @@ void Scripts::cmdSetConPos() { _texsOrg = Common::Point(x, y); } -void Scripts::CMDCHECKVFRAME() { error("TODO CMDCHECKVFRAME"); } +void Scripts::cmdCheckVFrame() { + if (_vm->_video->_videoFrame == _data->readSint16LE()) + cmdGoto(); + else + _data->skip(2); +} void Scripts::cmdJumpChoice() { int val = (_data->readUint16LE() & 0xFF); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index eaac996d4d..2b527a855a 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -109,7 +109,7 @@ protected: void cmdTexChoice(); void cmdWait(); void cmdSetConPos(); - void CMDCHECKVFRAME(); + void cmdCheckVFrame(); void cmdJumpChoice(); void cmdReturnChoice(); void cmdClearBlock(); -- cgit v1.2.3 From 43f7fe9182a151f070c93dae4550dc022aeb12be Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 20 Nov 2014 13:28:31 +0100 Subject: ACCESS: Implement doCast --- engines/access/amazon/amazon_scripts.cpp | 139 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 1 + engines/access/sound.cpp | 5 ++ engines/access/sound.h | 2 + 4 files changed, 146 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index b4a1568e5a..451c689350 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -931,6 +931,143 @@ void AmazonScripts::loadBackground(int param1, int param2) { _vm->_screen->forceFadeIn(); } +void AmazonScripts::doCast(int param1) { + static const int END_OBJ[26][4] = { + { 0, 118, 210, 10}, + { 1, 38, 250, 10}, + { 2, 38, 280, 10}, + { 3, 38, 310, 10}, + { 4, 38, 340, 10}, + { 5, 38, 370, 10}, + { 6, 38, 400, 10}, + { 7, 38, 430, 10}, + { 8, 38, 460, 10}, + { 9, 38, 490, 10}, + {10, 38, 520, 10}, + {11, 38, 550, 10}, + {12, 38, 580, 10}, + {13, 38, 610, 10}, + {14, 38, 640, 10}, + {15, 38, 670, 10}, + {16, 38, 700, 10}, + {17, 38, 730, 10}, + {18, 38, 760, 10}, + {19, 38, 790, 10}, + {20, 95, 820, 10}, + {21, 94, 850, 10}, + {22, 96, 880, 10}, + {23, 114, 910, 10}, + {24, 114, 940, 10}, + {25, 110, 970, 10} + }; + + static const int END_OBJ1[4][4] = { + {0, 40, 1100, 10}, + {2, 11, 1180, 10}, + {1, 154, 1180, 10}, + {3, 103, 1300, 10} + }; + + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + _vm->_screen->forceFadeOut(); + _vm->_screen->_clipHeight = 173; + _vm->_screen->clearScreen(); + _game->_chapter = 16; + _game->tileScreen(); + _game->updateSummary(param1); + _vm->_screen->setPanel(3); + _game->_chapter = 14; + + Resource *spriteData = _vm->_files->loadFile(91, 0); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + spriteData = _vm->_files->loadFile(91, 1); + _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(58, 1); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + _xTrack = 0; + _yTrack = -6; + _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 60; + + _game->_timers[24]._timer = 1; + _game->_timers[24]._initTm = 1; + ++_game->_timers[24]._flag; + + _pNumObj = 26; + for (int i = 0; i < _pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[0]; + _pImgNum[i] = END_OBJ[i][0]; + _pObjX[i] = END_OBJ[i][1]; + _pObjY[i] = END_OBJ[i][2]; + _pObjZ[i] = END_OBJ[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } + + _pNumObj = 4; + for (int i = 0; i < _pNumObj; i++) { + _pObject[26 + i] = _vm->_objectsTable[1]; + _pImgNum[26 + i] = END_OBJ1[i][0]; + _pObjX[26 + i] = END_OBJ1[i][1]; + _pObjY[26 + i] = END_OBJ1[i][2]; + _pObjZ[26 + i] = END_OBJ1[i][3]; + _pObjXl[26 + i] = _pObjYl[26 + i] = 0; + } + + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + + _vm->_sound->newMusic(58, 0); + _vm->_screen->forceFadeIn(); + + while (!_vm->shouldQuit()) { + _vm->_images.clear(); + pan(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_newRects.clear(); + _game->plotList(); + _vm->copyBlocks(); + + _vm->_events->pollEvents(); + warning("TODO: check on KEYBUFCNT"); + + if (_yCam < -7550) { + _vm->_events->_vbCount = 50; + + while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone()) + _vm->_events->pollEvents(); + + break; + } + } + + _vm->_sound->newMusic(58, 1); + _vm->_events->showCursor(); + warning("TODO: delete _roomInfo;"); + _vm->freeCells(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + _vm->_images.clear(); + _vm->_screen->forceFadeOut(); + + warning("TODO: EXIT"); + +} + void AmazonScripts::setInactive() { _game->_rawInactiveX = _vm->_player->_rawPlayer.x; _game->_rawInactiveY = _vm->_player->_rawPlayer.y; @@ -1232,7 +1369,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { loadBackground(param1, param2); break; case 3: - warning("TODO DOCAST"); + doCast(param1); break; case 4: setInactive(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 67e7e77009..ccf19fab31 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -84,6 +84,7 @@ protected: int antHandleLeft(int indx, const int *&buf); int antHandleStab(int indx, const int *&buf); void ANT(); + void doCast(int param1); void loadBackground(int param1, int param2); void plotInactive(); void setInactive(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 075bfc005e..6d42cd552e 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -88,6 +88,11 @@ void SoundManager::midiPlay() { // TODO } +bool SoundManager::checkMidiDone() { + // TODO + return true; +} + void SoundManager::midiRepeat() { // TODO } diff --git a/engines/access/sound.h b/engines/access/sound.h index 2456ba7753..46e3b23bb1 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -72,6 +72,8 @@ public: void midiPlay(); + bool checkMidiDone(); + void midiRepeat(); void stopSong(); -- cgit v1.2.3 From 690bea4c8831895ec74c022aeda599a9a7d119f6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 20 Nov 2014 13:31:56 +0100 Subject: ACCESS: Trigger quit game at the end of doCast --- engines/access/amazon/amazon_scripts.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 451c689350..4c4f2f376b 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1064,8 +1064,8 @@ void AmazonScripts::doCast(int param1) { _vm->_images.clear(); _vm->_screen->forceFadeOut(); - warning("TODO: EXIT"); - + _vm->quitGame(); + _vm->_events->pollEvents(); } void AmazonScripts::setInactive() { -- cgit v1.2.3 From 7427f29e85dc5988126349b2579d37a0cf3997f1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 21 Nov 2014 00:09:28 +0100 Subject: ACCESS: Implement mWhileJWalk2 (WIP) --- engines/access/amazon/amazon_scripts.cpp | 96 +++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 6 ++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4c4f2f376b..f7d1df5503 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -225,6 +225,100 @@ void AmazonScripts::mWhile2() { } while (_vm->_flags[52] == 4); } +void AmazonScripts::initJWalk2() { + const int JUNGLE1OBJ[7][4] = { + {2, 470, 0, 20}, + {0, 290, 0, 50}, + {1, 210, 0, 40}, + {0, 500, 0, 30}, + {1, 550, 0, 20}, + {0, 580, 0, 60}, + {1, 650, 0, 30} + }; + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + _vm->_screen->clearScreen(); + _vm->_buffer2.clearBuffer(); + _vm->_screen->setBufferScan(); + + _vm->_screen->_scrollX = _vm->_screen->_scrollY; + _vm->_screen->_scrollCol = _vm->_screen->_scrollRow; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->fadeIn(); + // KEYFL = 0; + + _game->_plane._xCount = 2; + _vm->_player->_scrollAmount = 5; + _xTrack = -10; + _yTrack = _zTrack = 0; + _xCam = 480; + _yCam = 0; + _zCam = 80; + + _game->_timers[24]._timer = 1; + _game->_timers[24]._initTm = 1; + ++_game->_timers[24]._flag; + + _pNumObj = 7; + for (int i = 0; i < _pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[24]; + _pImgNum[i] = JUNGLE1OBJ[i][0]; + _pObjX[i] = JUNGLE1OBJ[i][1]; + _pObjY[i] = JUNGLE1OBJ[i][2]; + _pObjZ[i] = JUNGLE1OBJ[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } + + _jCnt[0] = 0; + _jCnt[1] = 3; + _jCnt[2] = 5; + + _jungleX[0] = 50; + _jungleX[1] = 16; + _jungleX[2] = 93; +} + +void AmazonScripts::jungleMove() { + warning("TODO jungleMove"); +} + +void AmazonScripts::mWhileJWalk2() { + Screen &screen = *_vm->_screen; + + initJWalk2(); + + while(true) { + _vm->_images.clear(); + _vm->_events->_vbCount = 6; + _pImgNum[0] = _game->_plane._xCount; + while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { + int scrollX = screen._scrollCol + screen._vWindowWidth; + jungleMove(); + while (scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + } + if (_game->_plane._xCount == 2) + ++_game->_plane._xCount; + else + --_game->_plane._xCount; + + pan(); + scrollJWalk(); + + g_system->delayMillis(10); + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + } + } + _vm->_events->showCursor(); +} + void AmazonScripts::doFlyCell() { Plane &plane = _game->_plane; SpriteResource *sprites = _vm->_objectsTable[15]; @@ -667,7 +761,7 @@ void AmazonScripts::mWhile(int param1) { mWhile2(); break; case 8: - warning("TODO JWALK2"); + mWhileJWalk2(); break; default: break; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index ccf19fab31..d07445b7ef 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -53,6 +53,9 @@ private: int _pObjXl[16]; int _pObjYl[16]; + int _jCnt[3]; + int _jungleX[3]; + void pan(); protected: @@ -70,6 +73,9 @@ protected: void mWhileFly(); void mWhileFall(); void mWhileJWalk(); + void initJWalk2(); + void jungleMove(); + void mWhileJWalk2(); void mWhile(int param1); void setVerticalCode(Common::Rect bounds); void setHorizontalCode(Common::Rect bounds); -- cgit v1.2.3 From 60ee5456c9b7436e0830ba30a30acb53051d2820 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 21 Nov 2014 00:54:13 +0100 Subject: ACCESS: Implement jungleMove --- engines/access/amazon/amazon_scripts.cpp | 33 +++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f7d1df5503..7272564fdb 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -280,7 +280,35 @@ void AmazonScripts::initJWalk2() { } void AmazonScripts::jungleMove() { - warning("TODO jungleMove"); + const static int jungleY[3] = {27, 30, 29}; + int cx = 1; + int dx = 0; + if (_vm->_timers[0]._flag == 0) { + _vm->_timers[0]._flag = 1; + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + for (int i = 0; i <= 3; i++) { + int newJCnt = (_jCnt[i] + 1) % 8; + _jCnt[i] = newJCnt; + _jungleX[i] += 5; + } + dx = 4; + if (_game->_allenFlag != 1) + cx = 2; + else + cx = 3; + } + + for (int i = 0; i <= cx; i++) { + ImageEntry ie; + ie._flags = 8; + ie._spritesPtr = _vm->_objectsTable[24]; + ie._frameNumber = _jCnt[i] + dx; + ie._position = Common::Point(_jungleX[i], jungleY[i]); + ie._offsetY = jungleY[i]; + + _vm->_images.addToList(ie); + dx += 8; + } } void AmazonScripts::mWhileJWalk2() { @@ -293,9 +321,8 @@ void AmazonScripts::mWhileJWalk2() { _vm->_events->_vbCount = 6; _pImgNum[0] = _game->_plane._xCount; while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { - int scrollX = screen._scrollCol + screen._vWindowWidth; jungleMove(); - while (scrollX >= TILE_WIDTH) { + while (screen._scrollX >= TILE_WIDTH) { screen._scrollX -= TILE_WIDTH; ++screen._scrollCol; _vm->_buffer1.moveBufferLeft(); -- cgit v1.2.3 From 968bfec0677c75943fde080c63ab2e265aefa2b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 20 Nov 2014 22:25:01 -0500 Subject: ACCESS: Workaround for original setting animations when none is loaded --- engines/access/animation.cpp | 4 +++- engines/access/scripts.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index de44740c7f..184b015371 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -304,6 +304,8 @@ void AnimationManager::loadAnimations(Resource *res) { Animation *AnimationManager::setAnimation(int animId) { Animation *anim = findAnimation(animId); + if (!anim) + return nullptr; anim->_countdownTicks = anim->_initialTicks; anim->_frameNumber = 0; @@ -320,7 +322,7 @@ void AnimationManager::setAnimTimer(Animation *anim) { } Animation *AnimationManager::findAnimation(int animId) { - _animStart = _animation->getAnimation(animId); + _animStart = (_animation == nullptr) ? nullptr : _animation->getAnimation(animId); return _animStart; } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 89c8a4d0e6..b7ee4d2278 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -391,7 +391,9 @@ void Scripts::cmdCheckLoc() { void Scripts::cmdSetAnim() { int animId = _data->readByte(); Animation *anim = _vm->_animation->setAnimation(animId); - _vm->_animation->setAnimTimer(anim); + + if (anim) + _vm->_animation->setAnimTimer(anim); } void Scripts::cmdDispInv() { -- cgit v1.2.3 From 5de214dfc446a7905d48900f49e1da37871f209c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 21 Nov 2014 12:02:27 +0100 Subject: ACCESS: Implement mWhileDownRiver --- engines/access/amazon/amazon_scripts.cpp | 106 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 + 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7272564fdb..df6b24b3c2 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -764,6 +764,110 @@ void AmazonScripts::mWhileDoOpen() { } } +void AmazonScripts::scrollRiver() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + _vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30)); + _vm->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void AmazonScripts::mWhileDownRiver() { + static const int RIVEROBJ[14][4] = { + {3, 77, 0, 40}, + {2, 30, 0, 30}, + {2, 290, 0, 50}, + {1, 210, 0, 70}, + {2, 350, 0, 30}, + {1, 370, 0, 20}, + {2, 480, 0, 60}, + {3, 395, 0, 10}, + {1, 550, 0, 30}, + {2, 620, 0, 50}, + {1, 690, 0, 10}, + {2, 715, 0, 40}, + {1, 770, 0, 30}, + {3, 700, 0, 20} + }; + + _vm->_events->hideCursor(); + _vm->_screen->setDisplayScan(); + _vm->_screen->clearScreen(); + _vm->_screen->savePalette(); + + _vm->_files->loadScreen(95, 4); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_screen->restorePalette(); + _vm->_screen->setPalette(); + _vm->_screen->setBufferScan(); + _vm->_screen->_scrollX = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + + // KEYFLG = 0; + + _vm->_player->_scrollAmount = 2; + _vm->_destIn = &_vm->_buffer2; + _xTrack = -7; + _yTrack = _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 80; + + _game->_timers[24]._timer = 1; + _game->_timers[24]._initTm = 1; + ++_game->_timers[24]._flag; + + _pNumObj = 14; + for (int i = 0; i <_pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[33]; + _pImgNum[i] = RIVEROBJ[i][0]; + _pObjX[i] = RIVEROBJ[i][1]; + _pObjY[i] = RIVEROBJ[i][2]; + _pObjZ[i] = RIVEROBJ[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } + + _game->_timers[3]._timer = 200; + _game->_timers[3]._initTm = 200; + ++_game->_timers[3]._flag; + _game->_timers[4]._timer = 350; + _game->_timers[4]._initTm = 350; + ++_game->_timers[4]._flag; + + while(true) { + _vm->_images.clear(); + _vm->_events->_vbCount = 6; + while ((_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) && _vm->_events->_vbCount) { + jungleMove(); + while (_vm->_screen->_scrollX >= TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } + + pan(); + scrollRiver(); + + if (_game->_timers[3]._flag == 0) { + _game->_timers[3]._flag = 1; + _vm->_sound->playSound(1); + } else if (_game->_timers[4]._flag == 0) { + _game->_timers[4]._flag = 1; + _vm->_sound->playSound(0); + } + + g_system->delayMillis(10); + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + } + } + _vm->_events->showCursor(); +} + void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: @@ -782,7 +886,7 @@ void AmazonScripts::mWhile(int param1) { mWhileDoOpen(); break; case 6: - warning("TODO DOWNRIVER"); + mWhileDownRiver(); break; case 7: mWhile2(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index d07445b7ef..06fe56a2bb 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -76,6 +76,8 @@ protected: void initJWalk2(); void jungleMove(); void mWhileJWalk2(); + void scrollRiver(); + void mWhileDownRiver(); void mWhile(int param1); void setVerticalCode(Common::Rect bounds); void setHorizontalCode(Common::Rect bounds); -- cgit v1.2.3 From e1e97ec9ff30435bee991133d8adc009d74979e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Nov 2014 00:42:04 +0100 Subject: ACCESS: Start the implementation of RIVER (WIP) --- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_scripts.cpp | 103 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 12 +++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index ba81a77658..f062a28dcd 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -59,7 +59,6 @@ private: int _canoeYPos; int _hitCount; int _saveRiver; - int _hitSafe; int _topList; int _botList; int _riverIndex; @@ -109,6 +108,7 @@ public: bool _charSegSwitch; bool _skipStart; + int _hitSafe; int _rawInactiveX; int _rawInactiveY; int _inactiveYOff; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index df6b24b3c2..a45e6f72bd 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1585,6 +1585,107 @@ void AmazonScripts::plotInactive() { } +void AmazonScripts::initRiver() { + warning("TODO: initRiver()"); +} + +bool AmazonScripts::JUMPTEST() { + warning("TODO: JUMPTEST();"); + return true; +} + +void AmazonScripts::RIVERSOUND() { + warning("TODO: RIVERSOUND();"); +} + +void AmazonScripts::MOVECANOE() { + warning("TODO: MOVECANOE();"); +} + +void AmazonScripts::UPDATEOBSTACLES() { + warning("TODO: UPDATEOBSTACLES()"); +} + +void AmazonScripts::SETPHYSX() { + warning("TODO: SETPHYSX()"); +} + +void AmazonScripts::RIVERCOLLIDE() { + warning("TODO: RIVERCOLLIDE()"); +} + +void AmazonScripts::SCROLLRIVER1() { + warning("TODO: SCROLLRIVER1()"); +} + +void AmazonScripts::RIVER() { + static const int RIVERDEATH[5] = {22, 23, 24, 25, 26}; + + initRiver(); + while (true) { + _vm->_events->_vbCount = 4; + + int bx = _vm->_player->_scrollAmount - _screenVertX; + if (_vm->_screen->_scrollX == 0) { + _vm->_sound->midiRepeat(); + if (JUMPTEST()) { + CHICKENOUTFLG = false; + return; + } + } else { + _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; + } + + if (CHICKENOUTFLG) { + CHICKENOUTFLG = false; + return; + } + + _vm->_images.clear(); + _vm->_animation->animate(0); + + RIVERSOUND(); + pan(); + MOVECANOE(); + + if (_vm->_room->_function == 1) { + CHICKENOUTFLG = false; + return; + } + + UPDATEOBSTACLES(); + SETPHYSX(); + RIVERCOLLIDE(); + if (_game->_hitSafe != 0) + _game->_hitSafe -= 2; + + if (_game->_hitSafe < 0) { + warning("TODO: cmdDead(RIVERDEATH[0]);"); + return; + } + + if (_game->_deathFlag) { + _game->_deathCount--; + if (_game->_deathCount == 0) { + warning("TODO: cmdDead(RIVERDEATH[_game->_deathType]);"); + return; + } + } + + if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) { + _vm->_events->hideCursor(); + SCROLLRIVER1(); + _vm->_events->pollEvents(); + } else + SCROLLRIVER1(); + + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + } +} + void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: @@ -1612,7 +1713,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { plotInactive(); break; case 13: - warning("TODO RIVER"); + RIVER(); break; case 14: ANT(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 06fe56a2bb..5c3fc0fb8c 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -42,7 +42,8 @@ private: int _yCam; int _zCam; int _pNumObj; - + int _screenVertX; + bool CHICKENOUTFLG; int _pImgNum[32]; SpriteResource *_pObject[32]; @@ -94,6 +95,15 @@ protected: void ANT(); void doCast(int param1); void loadBackground(int param1, int param2); + void initRiver(); + bool JUMPTEST(); + void RIVERSOUND(); + void MOVECANOE(); + void UPDATEOBSTACLES(); + void SETPHYSX(); + void RIVERCOLLIDE(); + void SCROLLRIVER1(); + void RIVER(); void plotInactive(); void setInactive(); void boatWalls(int param1, int param2); -- cgit v1.2.3 From 5cfdc983c38c6b470701be46209dacba06e537a0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 21 Nov 2014 21:34:55 -0500 Subject: ACCESS: Fix loading of animation at end of mWhileDoOpen --- engines/access/amazon/amazon_scripts.cpp | 9 +++++++-- engines/access/scripts.cpp | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index a45e6f72bd..bb8f8a9223 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -749,7 +749,7 @@ void AmazonScripts::mWhileDoOpen() { events.showCursor(); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - warning("TODO: delete _roomInfo;"); + _vm->freeCells(); _vm->_oldRects.clear(); _vm->_newRects.clear(); @@ -757,10 +757,15 @@ void AmazonScripts::mWhileDoOpen() { _vm->_images.clear(); if (_vm->_conversation == 2) { + // Cutscene at end of Chapter 6 Resource *spriteData = _vm->_files->loadFile(28, 37); _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData); delete spriteData; - warning("TODO: _roomInfo = _vm->_files->loadFile(28, 38);"); + + _vm->_animation->freeAnimationData(); + animResource = _vm->_files->loadFile(28, 38); + _vm->_animation->loadAnimations(animResource); + delete animResource; } } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index b7ee4d2278..9268b829e7 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -595,7 +595,6 @@ void Scripts::cmdTexChoice() { Common::Array responseCoords; responseCoords.push_back(_vm->_bubbleBox->_bounds); - responseCoords.push_back(Common::Rect(0, 0, 0, 0)); _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; findNull(); @@ -605,13 +604,12 @@ void Scripts::cmdTexChoice() { while ((v = _data->readByte()) != 0) tmpStr += (char)v; - Common::Rect termResponse2 = Common::Rect(-1, 0, 0, 0); if (tmpStr.size() != 0) { choice2Fl = true; _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str(); _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); - responseCoords[1] = _vm->_bubbleBox->_bounds; + responseCoords.push_back(_vm->_bubbleBox->_bounds); _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; } @@ -626,7 +624,7 @@ void Scripts::cmdTexChoice() { _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str(); _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); - termResponse2 = _vm->_bubbleBox->_bounds; + responseCoords.push_back(_vm->_bubbleBox->_bounds); _vm->_screen->_printOrg.y = _vm->_bubbleBox->_bounds.bottom + 11; } -- cgit v1.2.3 From 237404fa70e0aa75c0a9803830915d01bb763d43 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Nov 2014 16:59:51 +0100 Subject: ACCESS: Some more work on RIVER (still WIP) --- engines/access/amazon/amazon_game.cpp | 6 +- engines/access/amazon/amazon_game.h | 15 ++- engines/access/amazon/amazon_resources.cpp | 208 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 15 +++ engines/access/amazon/amazon_room.h | 4 +- engines/access/amazon/amazon_scripts.cpp | 84 ++++++++++++ engines/access/amazon/amazon_scripts.h | 1 + engines/access/events.cpp | 7 + engines/access/events.h | 3 + engines/access/martian/martian_room.h | 3 +- engines/access/room.h | 4 +- 11 files changed, 336 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f663f03b38..396ba42148 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -775,13 +775,15 @@ void AmazonEngine::startChapter(int chapter) { void AmazonEngine::synchronize(Common::Serializer &s) { AccessEngine::synchronize(s); + int dummy = 0; + s.syncAsSint16LE(_canoeLane); s.syncAsSint16LE(_canoeYPos); s.syncAsSint16LE(_hitCount); s.syncAsSint16LE(_saveRiver); s.syncAsSint16LE(_hitSafe); s.syncAsSint16LE(_chapter); - s.syncAsSint16LE(_topList); + s.syncAsSint16LE(dummy); s.syncAsSint16LE(_botList); s.syncAsSint16LE(_riverIndex); s.syncAsSint16LE(_rawInactiveX); @@ -789,6 +791,8 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_inactiveYOff); for (int i = 0; i < 100; ++i) s.syncAsSint16LE(_esTabTable[i]); + + warning("TODO: s.syncAsSint16LE(_topList);"); } /*------------------------------------------------------------------------*/ diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index f062a28dcd..911ec55412 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -55,13 +55,7 @@ public: class AmazonEngine : public AccessEngine { private: // Fields that are included in savegames - int _canoeLane; - int _canoeYPos; - int _hitCount; - int _saveRiver; - int _topList; int _botList; - int _riverIndex; int _esTabTable[100]; // Other fields @@ -108,6 +102,13 @@ public: bool _charSegSwitch; bool _skipStart; + int _canoeLane; + int _canoeYPos; + int _hitCount; + const byte *_topList; + int _riverIndex; + int _saveRiver; + int _canoeDir; int _hitSafe; int _rawInactiveX; int _rawInactiveY; @@ -142,7 +143,7 @@ public: bool _deathFlag; int _deathCount; int _deathType; - int _mapPtr; + byte *_mapPtr; int _canoeVXPos; int _canoeMoveCount; int _canoeFrame; diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 925ea195a5..4df2c0c42e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1537,5 +1537,213 @@ const int openObj[10][4] = { {4, -280, 40, 120}, }; +const byte MAP0[26] = { + 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 4, 0, + 0, 0, 1, 0, 2, 0, 0, 1, 1, 3, 0, 0, + 0, 0xFF +}; + +const byte MAP1[27] = { + 0, 0, 1, 0, 3, 0, 0, 1, 1, 2, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 4, 0, + 0, 0, 0xFF +}; + +const byte MAP2[32] = { + 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 0, + 3, 0, 0, 1, 0, 4, 0, 0, 1, 1, 2, 0, + 0, 1, 0, 1, 0, 0, 0, 0xFF +}; + +const byte *MAPTBL[3] = {MAP0, MAP1, MAP2}; + +const byte RIVER0OBJECTS[450] = { + 16, 31, 0, 0, 25, 0, 0, 4, 12, + 0, 16, 31, 0, 56, 24, 0, 0, 2, + 12, 0, 17, 30, 0, 212, 23, 0, 0, + 3, 15, 0, 16, 31, 0, 82, 23, 0, + 0, 7, 12, 0, 17, 30, 0, 22, 23, + 0, 0, 5, 15, 0, 17, 30, 0, 98, + 22, 0, 0, 3, 15, 0, 16, 31, 0, + 68, 22, 0, 0, 7, 12, 0, 255, 58, + 1, 16, 21, 0, 0, 4, 0, 0, 17, + 30, 0, 35, 20, 0, 0, 1, 15, 0, + 16, 31, 0, 30, 20, 0, 0, 5, 12, + 0, 16, 31, 0, 192, 19, 0, 0, 7, + 12, 0, 17, 30, 0, 36, 19, 0, 0, + 2, 15, 0, 17, 30, 0, 177, 18, 0, + 0, 7, 15, 0, 16, 31, 0, 82, 18, + 0, 0, 4, 12, 0, 16, 31, 0, 52, + 18, 0, 0, 1, 12, 0, 17, 30, 0, + 208, 17, 0, 0, 5, 15, 0, 16, 31, + 0, 113, 17, 0, 0, 2, 12, 0, 255, + 58, 1, 16, 16, 0, 0, 4, 0, 0, + 17, 30, 0, 165, 15, 0, 0, 3, 15, + 0, 16, 31, 0, 25, 15, 0, 0, 6, + 12, 0, 17, 30, 0, 21, 14, 0, 0, + 4, 15, 0, 16, 31, 0, 32, 13, 0, + 0, 1, 12, 0, 17, 30, 0, 33, 12, + 0, 0, 0, 15, 0, 16, 31, 0, 8, + 12, 0, 0, 7, 12, 0, 17, 30, 0, + 198, 11, 0, 0, 4, 15, 0, 16, 31, + 0, 176, 11, 0, 0, 3, 12, 0, 16, + 31, 0, 160, 11, 0, 0, 2, 12, 0, + 17, 30, 0, 64, 11, 0, 0, 7, 15, + 0, 17, 30, 0, 44, 11, 0, 0, 0, + 15, 0, 255, 58, 1, 208, 9, 0, 0, + 4, 0, 0, 17, 30, 0, 222, 8, 0, + 0, 4, 15, 0, 16, 31, 0, 147, 8, + 0, 0, 6, 12, 0, 17, 30, 0, 32, + 7, 0, 0, 1, 15, 0, 16, 31, 0, + 240, 6, 0, 0, 4, 12, 0, 17, 30, + 0, 114, 6, 0, 0, 3, 15, 0, 16, + 31, 0, 80, 6, 0, 0, 7, 12, 0, + 17, 30, 0, 49, 6, 0, 0, 2, 15, + 0, 255, 58, 1, 208, 4, 0, 0, 4, + 0, 0, 17, 30, 0, 166, 4, 0, 0, + 2, 15, 0, 16, 31, 0, 96, 4, 0, + 0, 4, 12, 0, 17, 30, 0, 202, 3, + 0, 0, 7, 15, 0, 16, 31, 0, 142, + 3, 0, 0, 5, 12, 0, 17, 30, 0, + 193, 2, 0, 0, 0, 15, 0, 16, 31, + 0, 38, 2, 0, 0, 4, 12, 0, 17, + 30, 0, 49, 1, 0, 0, 2, 15, 0 +}; + +const byte ENDRIVER0[10] = {16, 31, 0, 4, 1, 0, 0, 7, 12, 0}; + +const byte RIVER1OBJECTS[490] = { + 16, 31, 0, 8, 27, 0, 0, 1, 12, + 0, 16, 31, 0, 84, 26, 0, 0, 4, + 12, 0, 17, 30, 0, 43, 26, 0, 0, + 1, 15, 0, 16, 31, 0, 210, 25, 0, + 0, 2, 12, 0, 17, 30, 0, 95, 25, + 0, 0, 6, 15, 0, 17, 30, 0, 241, + 24, 0, 0, 4, 15, 0, 16, 31, 0, + 206, 24, 0, 0, 1, 12, 0, 17, 30, + 0, 36, 24, 0, 0, 0, 15, 0, 255, + 58, 1, 144, 23, 0, 0, 4, 0, 0, + 16, 31, 0, 168, 22, 0, 0, 3, 12, + 0, 17, 30, 0, 158, 22, 0, 0, 6, + 15, 0, 16, 31, 0, 154, 21, 0, 0, + 4, 12, 0, 16, 31, 0, 124, 21, 0, + 0, 7, 12, 0, 17, 30, 0, 119, 21, + 0, 0, 1, 15, 0, 17, 30, 0, 0, + 21, 0, 0, 0, 15, 0, 16, 31, 0, + 208, 20, 0, 0, 7, 12, 0, 17, 30, + 0, 128, 20, 0, 0, 2, 15, 0, 16, + 31, 0, 128, 20, 0, 0, 6, 12, 0, + 255, 58, 1, 144, 18, 0, 0, 4, 0, + 0, 17, 30, 0, 80, 17, 0, 0, 2, + 15, 0, 16, 31, 0, 80, 17, 0, 0, + 7, 12, 0, 16, 31, 0, 32, 17, 0, + 0, 2, 12, 0, 17, 30, 0, 16, 17, + 0, 0, 5, 15, 0, 16, 31, 0, 240, + 16, 0, 0, 4, 12, 0, 17, 30, 0, + 89, 16, 0, 0, 1, 15, 0, 16, 31, + 0, 29, 16, 0, 0, 3, 12, 0, 17, + 30, 0, 233, 14, 0, 0, 7, 15, 0, + 16, 31, 0, 28, 14, 0, 0, 4, 12, + 0, 16, 31, 0, 32, 13, 0, 0, 5, + 12, 0, 16, 31, 0, 193, 12, 0, 0, + 7, 12, 0, 17, 30, 0, 128, 12, 0, + 0, 1, 15, 0, 17, 30, 0, 240, 11, + 0, 0, 6, 15, 0, 255, 58, 1, 16, + 11, 0, 0, 4, 0, 0, 16, 31, 0, + 180, 10, 0, 0, 3, 12, 0, 17, 30, + 0, 134, 10, 0, 0, 6, 15, 0, 16, + 31, 0, 151, 9, 0, 0, 0, 12, 0, + 17, 30, 0, 237, 8, 0, 0, 5, 15, + 0, 16, 31, 0, 212, 8, 0, 0, 2, + 12, 0, 16, 31, 0, 112, 7, 0, 0, + 5, 12, 0, 17, 30, 0, 16, 7, 0, + 0, 1, 15, 0, 16, 31, 0, 208, 6, + 0, 0, 7, 12, 0, 17, 30, 0, 160, + 6, 0, 0, 4, 15, 0, 16, 31, 0, + 32, 6, 0, 0, 2, 12, 0, 255, 58, + 1, 208, 4, 0, 0, 4, 0, 0, 17, + 30, 0, 202, 3, 0, 0, 4, 15, 0, + 16, 31, 0, 142, 3, 0, 0, 7, 12, + 0, 17, 30, 0, 193, 2, 0, 0, 0, + 15, 0, 16, 31, 0, 38, 2, 0, 0, + 6, 12, 0, 17, 30, 0, 49, 1, 0, + 0, 3, 15, 0 +}; + +const byte ENDRIVER1[10] = { + 16, 31, 0, 4, 1, 0, 0, 1, 12, 0 +}; + +const byte RIVER2OBJECTS[530] = { + 16, 31, 0, 38, 32, 0, 0, 6, 12, + 0, 16, 31, 0, 179, 31, 0, 0, 7, + 12, 0, 17, 30, 0, 19, 31, 0, 0, + 4, 15, 0, 16, 31, 0, 210, 30, 0, + 0, 0, 12, 0, 16, 31, 0, 192, 29, + 0, 0, 2, 12, 0, 17, 30, 0, 48, + 29, 0, 0, 5, 15, 0, 16, 31, 0, + 1, 29, 0, 0, 4, 12, 0, 17, 30, + 0, 192, 28, 0, 0, 1, 15, 0, 16, + 31, 0, 160, 28, 0, 0, 6, 12, 0, + 255, 58, 1, 80, 27, 0, 0, 4, 0, + 0, 16, 31, 0, 64, 26, 0, 0, 3, + 12, 0, 17, 30, 0, 44, 26, 0, 0, + 6, 15, 0, 16, 31, 0, 118, 25, 0, + 0, 2, 12, 0, 17, 30, 0, 81, 24, + 0, 0, 5, 15, 0, 16, 31, 0, 56, + 24, 0, 0, 2, 12, 0, 17, 30, 0, + 102, 23, 0, 0, 1, 15, 0, 16, 31, + 0, 72, 23, 0, 0, 7, 12, 0, 16, + 31, 0, 68, 22, 0, 0, 2, 12, 0, + 17, 30, 0, 18, 22, 0, 0, 4, 15, + 0, 16, 31, 0, 192, 21, 0, 0, 5, + 12, 0, 17, 30, 0, 112, 21, 0, 0, + 6, 15, 0, 255, 58, 1, 208, 19, 0, + 0, 4, 0, 0, 17, 30, 0, 217, 18, + 0, 0, 4, 15, 0, 16, 31, 0, 174, + 18, 0, 0, 2, 12, 0, 17, 30, 0, + 52, 18, 0, 0, 5, 15, 0, 16, 31, + 0, 158, 17, 0, 0, 7, 12, 0, 16, + 31, 0, 143, 17, 0, 0, 1, 12, 0, + 17, 30, 0, 154, 16, 0, 0, 2, 15, + 0, 16, 31, 0, 99, 16, 0, 0, 4, + 12, 0, 255, 58, 1, 208, 14, 0, 0, + 4, 0, 0, 17, 30, 0, 16, 14, 0, + 0, 3, 15, 0, 16, 31, 0, 142, 13, + 0, 0, 5, 12, 0, 16, 31, 0, 94, + 13, 0, 0, 2, 12, 0, 17, 30, 0, + 98, 12, 0, 0, 6, 15, 0, 16, 31, + 0, 144, 11, 0, 0, 4, 12, 0, 17, + 30, 0, 139, 11, 0, 0, 7, 15, 0, + 255, 58, 1, 208, 9, 0, 0, 4, 0, + 0, 17, 30, 0, 111, 9, 0, 0, 1, + 15, 0, 16, 31, 0, 14, 9, 0, 0, + 0, 12, 0, 17, 30, 0, 227, 8, 0, + 0, 2, 15, 0, 16, 31, 0, 222, 8, + 0, 0, 6, 12, 0, 17, 30, 0, 234, + 7, 0, 0, 3, 15, 0, 16, 31, 0, + 208, 7, 0, 0, 0, 12, 0, 16, 31, + 0, 48, 7, 0, 0, 3, 12, 0, 17, + 30, 0, 3, 7, 0, 0, 7, 15, 0, + 16, 31, 0, 98, 6, 0, 0, 5, 12, + 0, 17, 30, 0, 94, 6, 0, 0, 1, + 15, 0, 255, 58, 1, 208, 4, 0, 0, + 4, 0, 0, 17, 30, 0, 202, 3, 0, + 0, 2, 15, 0, 16, 31, 0, 142, 3, + 0, 0, 5, 12, 0, 17, 30, 0, 193, + 2, 0, 0, 0, 15, 0, 16, 31, 0, + 38, 2, 0, 0, 4, 12, 0, 17, 30, + 0, 49, 1, 0, 0, 3, 15, 0 +}; + +const byte ENDRIVER2[10] = { + 16, 31, 0, 4, 1, 0, 0, 6, 12, 0 +}; + +const byte *RIVEROBJECTTBL[6] = { + RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, + ENDRIVER1, RIVER2OBJECTS, ENDRIVER2 +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 434a0f37db..f7e1b0371b 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -83,6 +83,21 @@ extern const int TORCH[12]; extern const int SPEAR[3]; extern const int openObj[10][4]; + +extern const byte MAP0[26]; +extern const byte MAP1[27]; +extern const byte MAP2[32]; + +extern const byte *MAPTBL[3]; + +extern const byte RIVER0OBJECTS[450]; +extern const byte ENDRIVER0[10]; +extern const byte RIVER1OBJECTS[490]; +extern const byte ENDRIVER1[10]; +extern const byte RIVER2OBJECTS[530]; +extern const byte ENDRIVER2[10]; + +extern const byte *RIVEROBJECTTBL[6]; } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index ccace1ea45..6b89a8f348 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -50,8 +50,6 @@ protected: virtual void setupRoom(); - virtual void roomMenu(); - virtual void mainAreaClick(); public: @@ -60,6 +58,8 @@ public: virtual ~AmazonRoom(); virtual void init4Quads(); + + virtual void roomMenu(); }; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index bb8f8a9223..2d462616db 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1590,8 +1590,92 @@ void AmazonScripts::plotInactive() { } +void AmazonScripts::SETRIVERPAN() { + warning("TODO: SETRIVERPAN"); +} + void AmazonScripts::initRiver() { warning("TODO: initRiver()"); + + static const int RIVERVXTBL[3] = {6719, 7039, 8319}; + + _vm->_events->centerMousePos(); + _vm->_events->restrictMouse(); + _vm->_screen->setDisplayScan(); + _vm->_screen->clearScreen(); + _vm->_screen->savePalette(); + _vm->_screen->forceFadeOut(); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(95, 4); + _vm->_buffer2.copyFrom(*_vm->_screen); + + _vm->_screen->restorePalette(); + _vm->_screen->setBufferScan(); + _vm->_destIn = &_vm->_buffer2; + _vm->_room->roomMenu(); + + if (_game->_saveRiver == 1) { + _vm->_screen->_scrollRow = _vm->_rScrollRow; + _vm->_screen->_scrollCol = _vm->_rScrollCol; + _vm->_screen->_scrollX = _vm->_rScrollX; + _vm->_screen->_scrollY = _vm->_rScrollY; + } else { + _vm->_screen->_scrollRow = 0; + _vm->_screen->_scrollCol = 140; + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollY = 0; + } + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->forceFadeIn(); + if (_game->_saveRiver == 1) { + _vm->_oldRects.resize(_vm->_rOldRectCount); + _vm->_newRects.resize(_vm->_rNewRectCount); + // KEYFLG = _vm->_rKeyFlag + } else { + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + // KEYFLG = 0 + } + + _vm->_player->_scrollAmount = 2; + SETRIVERPAN(); + _game->_timers[3]._timer = 1; + _game->_timers[3]._initTm = 1; + ++_game->_timers[3]._flag; + + _game->_canoeFrame = 0; + _game->_mapPtr = (byte *)MAPTBL[_game->_riverFlag] + 1; + if (_game->_saveRiver == 1) { + _game->_mapPtr--; + _game->_mapPtr += _game->_mapOffset; + } else { + _screenVertX = RIVERVXTBL[_game->_riverFlag] - 320; + _game->_canoeLane = 3; + _game->_hitCount = 0; + _game->_hitSafe = 0; + _game->_canoeYPos = 71; + } + + _game->_riverIndex = _game->_riverFlag; + _game->_topList = RIVEROBJECTTBL[_game->_riverIndex]; + UPDATEOBSTACLES(); + SETPHYSX(); + _game->_canoeDir = 0; + _game->_deathFlag = 0; + _game->_deathCount = 0; + + _game->_timers[11]._timer = 1200; + _game->_timers[11]._initTm = 1200; + ++_game->_timers[11]._flag; + _game->_timers[12]._timer = 1500; + _game->_timers[12]._initTm = 1500; + ++_game->_timers[12]._flag; + + _game->_maxHits = 2 - _game->_riverFlag; + _game->_saveRiver = 0; } bool AmazonScripts::JUMPTEST() { diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 5c3fc0fb8c..703e0b8497 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -103,6 +103,7 @@ protected: void SETPHYSX(); void RIVERCOLLIDE(); void SCROLLRIVER1(); + void SETRIVERPAN(); void RIVER(); void plotInactive(); void setInactive(); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index ac07a7579f..fd432573e4 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -273,5 +273,12 @@ bool EventsManager::isKeyMousePressed() { return result; } +void EventsManager::centerMousePos() { + _mousePos = Common::Point(160, 100); +} + +void EventsManager::restrictMouse() { + warning("TODO: restrictMouse"); +} } // End of namespace Access diff --git a/engines/access/events.h b/engines/access/events.h index 4888a27593..d73f76af49 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -126,6 +126,9 @@ public: int checkMouseBox1(Common::Array &rects); bool isKeyMousePressed(); + + void centerMousePos(); + void restrictMouse(); }; } // End of namespace Access diff --git a/engines/access/martian/martian_room.h b/engines/access/martian/martian_room.h index 14744f5311..85529ce8f0 100644 --- a/engines/access/martian/martian_room.h +++ b/engines/access/martian/martian_room.h @@ -46,8 +46,6 @@ protected: virtual void reloadRoom1(); - virtual void roomMenu(); - virtual void mainAreaClick(); public: MartianRoom(AccessEngine *vm); @@ -58,6 +56,7 @@ public: virtual void init4Quads() { } + virtual void roomMenu(); }; } // End of namespace Martian diff --git a/engines/access/room.h b/engines/access/room.h index 6c8b040593..9b3136630e 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -116,8 +116,6 @@ protected: virtual void doCommands(); - virtual void roomMenu() = 0; - virtual void mainAreaClick() = 0; public: Plotter _plotter; @@ -141,6 +139,8 @@ public: virtual void loadRoom(int roomNumber) = 0; + virtual void roomMenu() = 0; + /** * Clear all the data used by the room */ -- cgit v1.2.3 From 1d70d61d2b9935c3d64711757e9da67091ba0bc2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 22 Nov 2014 18:11:56 +0100 Subject: ACCESS: Implement setRiverPan --- engines/access/amazon/amazon_scripts.cpp | 54 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 2d462616db..d3377f97a5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1590,13 +1590,57 @@ void AmazonScripts::plotInactive() { } -void AmazonScripts::SETRIVERPAN() { - warning("TODO: SETRIVERPAN"); +void AmazonScripts::setRiverPan() { + static const int RIVER1OBJ[23][4] = { + {18, -77, 0, 30}, + {18, -325, 0, 20}, + {18, -450, 0, 15}, + {18, -1250, 0, 25}, + {19, -130, 0, 20}, + {19, -410, 0, 15}, + {19, -710, 0, 25}, + {19, -1510, 0, 20}, + {20, -350, 0, 30}, + {20, -695, 0, 25}, + {20, -990, 0, 20}, + {20, -1300, 0, 25}, + {20, -1600, 0, 30}, + {21, -370, 0, 20}, + {21, -650, 0, 30}, + {21, -1215, 0, 40}, + {21, -1815, 0, 35}, + {22, -380, 0, 25}, + {22, -720, 0, 35}, + {22, -1020, 0, 30}, + {22, -1170, 0, 25}, + {22, -1770, 0, 35}, + {23, -500, 63, 20} + }; + + int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + + _xTrack = 9; + _yTrack = _zTrack = 0; + _xCam = 160; + _yCam = 0; + _zCam = 80; + + _game->_timers[24]._timer = 1; + _game->_timers[24]._initTm = 1; + ++_game->_timers[24]._flag; + + _pNumObj = 23; + for (int i = 0; i < _pNumObj; i++) { + _pObject[i] = _vm->_objectsTable[45]; + _pImgNum[i] = RIVER1OBJ[i][0]; + _pObjX[i] = RIVER1OBJ[i][1] + delta; + _pObjY[i] = RIVER1OBJ[i][2]; + _pObjZ[i] = RIVER1OBJ[i][3]; + _pObjXl[i] = _pObjYl[i] = 0; + } } void AmazonScripts::initRiver() { - warning("TODO: initRiver()"); - static const int RIVERVXTBL[3] = {6719, 7039, 8319}; _vm->_events->centerMousePos(); @@ -1641,7 +1685,7 @@ void AmazonScripts::initRiver() { } _vm->_player->_scrollAmount = 2; - SETRIVERPAN(); + setRiverPan(); _game->_timers[3]._timer = 1; _game->_timers[3]._initTm = 1; ++_game->_timers[3]._flag; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 703e0b8497..08ad23d0f6 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -103,7 +103,7 @@ protected: void SETPHYSX(); void RIVERCOLLIDE(); void SCROLLRIVER1(); - void SETRIVERPAN(); + void setRiverPan(); void RIVER(); void plotInactive(); void setInactive(); -- cgit v1.2.3 From 1d60368724198d9c5fd201ab628ef46d285bb73b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Nov 2014 19:24:33 -0500 Subject: ACCESS: Tweaks to mWhileDoOpen and fixes to pan method --- engines/access/amazon/amazon_resources.cpp | 3 ++- engines/access/amazon/amazon_resources.h | 3 ++- engines/access/amazon/amazon_scripts.cpp | 30 ++++++++++++++++++------------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 4df2c0c42e..ead6410bec 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1524,7 +1524,7 @@ const int TORCH[12] = { const int SPEAR[3] = {30, -13, 1}; -const int openObj[10][4] = { +const int OPENING_OBJS[10][4] = { {8, -80, 120, 30}, {13, 229, 0, 50}, {12, 78, 0, 50}, @@ -1746,4 +1746,5 @@ const byte *RIVEROBJECTTBL[6] = { }; } // End of namespace Amazon + } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index f7e1b0371b..b29bdab2c3 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -82,7 +82,7 @@ extern const int TORCH[12]; extern const int SPEAR[3]; -extern const int openObj[10][4]; +extern const int OPENING_OBJS[10][4]; extern const byte MAP0[26]; extern const byte MAP1[27]; @@ -98,6 +98,7 @@ extern const byte RIVER2OBJECTS[530]; extern const byte ENDRIVER2[10]; extern const byte *RIVEROBJECTTBL[6]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d3377f97a5..d4018c2def 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -425,9 +425,12 @@ void AmazonScripts::pan() { for (int i = 0; i < _pNumObj; i++) { _pObjZ[i] += _zTrack; _pObjXl[i] += (_pObjZ[i] * tx) & 0xff; - _pObjX[i] += (_pObjZ[i] * tx) >> 8; + _pObjX[i] += (_pObjZ[i] * tx) >> 8 + (_pObjXl[i] >> 8); + _pObjXl[i] &= 0xff; + _pObjYl[i] += (_pObjZ[i] * ty) & 0xff; - _pObjY[i] += (_pObjZ[i] * ty) >> 8; + _pObjY[i] += (_pObjZ[i] * ty) >> 8 + (_pObjYl[i] >> 8); + _pObjYl[i] &= 0xff; } } @@ -435,7 +438,7 @@ void AmazonScripts::pan() { ImageEntry ie; ie._flags= 8; ie._position = Common::Point(_pObjX[i], _pObjY[i]); - ie._offsetY = 0xFF; + ie._offsetY = 255; ie._spritesPtr = _pObject[i]; ie._frameNumber = _pImgNum[i]; @@ -666,16 +669,16 @@ void AmazonScripts::mWhileDoOpen() { screen.forceFadeOut(); _game->_skipStart = false; if (_vm->_conversation != 2) { + // Cutscene at start of chapter 1 screen.setPanel(3); _game->startChapter(1); _game->establishCenter(0, 1); } Resource *data = _vm->_files->loadFile(1, 0); - SpriteResource *spr = new SpriteResource(_vm, data); + _vm->_objectsTable[1] = new SpriteResource(_vm, data); delete data; - _vm->_objectsTable[1] = spr; _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(1, 2); _vm->_buffer2.copyFrom(*_vm->_screen); @@ -698,10 +701,10 @@ void AmazonScripts::mWhileDoOpen() { for (int i = 0; i < _pNumObj; i++) { _pObject[i] = _vm->_objectsTable[1]; - _pImgNum[i] = openObj[i][0]; - _pObjX[i] = openObj[i][1]; - _pObjY[i] = openObj[i][2]; - _pObjZ[i] = openObj[i][3]; + _pImgNum[i] = OPENING_OBJS[i][0]; + _pObjX[i] = OPENING_OBJS[i][1]; + _pObjY[i] = OPENING_OBJS[i][2]; + _pObjZ[i] = OPENING_OBJS[i][3]; _pObjXl[i] = _pObjYl[i] = 0; } @@ -727,11 +730,14 @@ void AmazonScripts::mWhileDoOpen() { startFl = true; screen.forceFadeIn(); } - events.pollEvents(); - warning("TODO: check on KEYBUFCNT"); - if (events._leftButton || events._rightButton) { + + events.pollEvents(); + if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { _game->_skipStart = true; _vm->_sound->newMusic(10, 1); + + events.debounceLeft(); + events.zeroKeys(); break; } -- cgit v1.2.3 From 30f602b6cb265000d4ac95e645598d324e3d5d49 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Nov 2014 22:17:39 -0500 Subject: ACCESS: Further fixes for panning --- engines/access/access.cpp | 10 +++++----- engines/access/access.h | 2 +- engines/access/amazon/amazon_scripts.cpp | 11 +++++++---- engines/access/asurface.h | 2 ++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index b309e92b29..e87b647b59 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -72,7 +72,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleT1 = 0; _scaleMaxY = 0; _scaleI = 0; - _scaleFlag = false; + _imgUnscaled = false; _canSaveLoad = false; _eseg = nullptr; @@ -351,13 +351,13 @@ void AccessEngine::plotList1() { for (uint idx = 0; idx < _images.size(); ++idx) { ImageEntry &ie = _images[idx]; - _scaleFlag = (ie._flags & 8) != 0; + _imgUnscaled = (ie._flags & IMGFLAG_UNSCALED) != 0; Common::Point pt = ie._position - _screen->_bufferStart; SpriteResource *sprites = ie._spritesPtr; SpriteFrame *frame = sprites->getFrame(ie._frameNumber); Common::Rect bounds(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h); - if (!_scaleFlag) { + if (!_imgUnscaled) { bounds.setWidth(_screen->_scaleTable1[frame->w]); bounds.setHeight(_screen->_scaleTable1[frame->h]); } @@ -376,7 +376,7 @@ void AccessEngine::plotList1() { _newRects.push_back(bounds); - if (!_scaleFlag) { + if (!_imgUnscaled) { _buffer2._rightSkip /= _scale; bounds.setWidth(bounds.width() / _scale); @@ -386,7 +386,7 @@ void AccessEngine::plotList1() { _buffer2.sPlotF(frame, destBounds); } } else { - if (ie._flags & 2) { + if (ie._flags & IMGFLAG_BACKWARDS) { _buffer2.plotB(frame, Common::Point(destBounds.left, destBounds.top)); } else { _buffer2.plotF(frame, Common::Point(destBounds.left, destBounds.top)); diff --git a/engines/access/access.h b/engines/access/access.h index 36951c7504..805abcce02 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -189,7 +189,7 @@ public: int _scaleT1; int _scaleMaxY; int _scaleI; - bool _scaleFlag; + bool _imgUnscaled; bool _canSaveLoad; Resource *_eseg; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d4018c2def..4d354017c6 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -425,11 +425,11 @@ void AmazonScripts::pan() { for (int i = 0; i < _pNumObj; i++) { _pObjZ[i] += _zTrack; _pObjXl[i] += (_pObjZ[i] * tx) & 0xff; - _pObjX[i] += (_pObjZ[i] * tx) >> 8 + (_pObjXl[i] >> 8); + _pObjX[i] += ((_pObjZ[i] * tx) >> 8) + (_pObjXl[i] >> 8); _pObjXl[i] &= 0xff; _pObjYl[i] += (_pObjZ[i] * ty) & 0xff; - _pObjY[i] += (_pObjZ[i] * ty) >> 8 + (_pObjYl[i] >> 8); + _pObjY[i] += ((_pObjZ[i] * ty) >> 8) + (_pObjYl[i] >> 8); _pObjYl[i] &= 0xff; } } @@ -697,8 +697,9 @@ void AmazonScripts::mWhileDoOpen() { _zCam = 270; _vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1; ++_vm->_timers[24]._flag; - _pNumObj = 10; + _vm->_timers.updateTimers(); + _pNumObj = 10; for (int i = 0; i < _pNumObj; i++) { _pObject[i] = _vm->_objectsTable[1]; _pImgNum[i] = OPENING_OBJS[i][0]; @@ -731,7 +732,9 @@ void AmazonScripts::mWhileDoOpen() { screen.forceFadeIn(); } - events.pollEvents(); + events.pollEvents(); + g_system->delayMillis(10); + if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { _game->_skipStart = true; _vm->_sound->newMusic(10, 1); diff --git a/engines/access/asurface.h b/engines/access/asurface.h index d066589f84..1c30db8915 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -131,6 +131,8 @@ public: SpriteFrame *getFrame(int idx) { return _frames[idx]; } }; +enum ImageFlag { IMGFLAG_BACKWARDS = 2, IMGFLAG_UNSCALED = 8 }; + class ImageEntry { public: int _frameNumber; -- cgit v1.2.3 From c1b3db90c49de5c2925cf65dfa49889dd2941164 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 14:56:18 +0100 Subject: ACCESS: Implement riverSound --- engines/access/amazon/amazon_scripts.cpp | 18 +++++++++++++++--- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4d354017c6..61387687b6 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1733,11 +1733,23 @@ void AmazonScripts::initRiver() { bool AmazonScripts::JUMPTEST() { warning("TODO: JUMPTEST();"); + return true; } -void AmazonScripts::RIVERSOUND() { - warning("TODO: RIVERSOUND();"); +void AmazonScripts::riverSound() { + if (_game->_timers[11]._flag == 0) { + ++_game->_timers[11]._flag; + _vm->_sound->playSound(2); + } + + if (_game->_timers[12]._flag == 0) { + ++_game->_timers[12]._flag; + _vm->_sound->playSound(3); + } + + if ((_xCam >= 1300) && (_xCam <= 1320)) + _vm->_sound->playSound(1); } void AmazonScripts::MOVECANOE() { @@ -1786,7 +1798,7 @@ void AmazonScripts::RIVER() { _vm->_images.clear(); _vm->_animation->animate(0); - RIVERSOUND(); + riverSound(); pan(); MOVECANOE(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 08ad23d0f6..7162bab057 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -97,7 +97,7 @@ protected: void loadBackground(int param1, int param2); void initRiver(); bool JUMPTEST(); - void RIVERSOUND(); + void riverSound(); void MOVECANOE(); void UPDATEOBSTACLES(); void SETPHYSX(); -- cgit v1.2.3 From 7fbd145f5db82c002a213f57de8839c4decdc427 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 14:57:37 +0100 Subject: ACCESS: Use a new structure instead of a byte array for River Objects --- engines/access/amazon/amazon_game.cpp | 7 +- engines/access/amazon/amazon_game.h | 4 +- engines/access/amazon/amazon_resources.cpp | 347 ++++++++++++++--------------- engines/access/amazon/amazon_resources.h | 23 +- 4 files changed, 185 insertions(+), 196 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 396ba42148..def64f2f88 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -48,8 +48,8 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _hitSafe = 0; _oldTitleChapter = _chapter = 0; _updateChapter = -1; - _topList = 0; - _botList = 0; + _topList = nullptr; + _botList = nullptr; _riverIndex = 0; _rawInactiveX = 0; _rawInactiveY = 0; @@ -784,7 +784,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_hitSafe); s.syncAsSint16LE(_chapter); s.syncAsSint16LE(dummy); - s.syncAsSint16LE(_botList); + s.syncAsSint16LE(dummy); s.syncAsSint16LE(_riverIndex); s.syncAsSint16LE(_rawInactiveX); s.syncAsSint16LE(_rawInactiveY); @@ -793,6 +793,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_esTabTable[i]); warning("TODO: s.syncAsSint16LE(_topList);"); + warning("TODO: s.syncAsSint16LE(_botList);"); } /*------------------------------------------------------------------------*/ diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 911ec55412..3b8b98101e 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -55,7 +55,6 @@ public: class AmazonEngine : public AccessEngine { private: // Fields that are included in savegames - int _botList; int _esTabTable[100]; // Other fields @@ -105,7 +104,8 @@ public: int _canoeLane; int _canoeYPos; int _hitCount; - const byte *_topList; + const RiverStruct *_topList; + const RiverStruct *_botList; int _riverIndex; int _saveRiver; int _canoeDir; diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index ead6410bec..192af2c9b6 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1557,190 +1557,169 @@ const byte MAP2[32] = { const byte *MAPTBL[3] = {MAP0, MAP1, MAP2}; -const byte RIVER0OBJECTS[450] = { - 16, 31, 0, 0, 25, 0, 0, 4, 12, - 0, 16, 31, 0, 56, 24, 0, 0, 2, - 12, 0, 17, 30, 0, 212, 23, 0, 0, - 3, 15, 0, 16, 31, 0, 82, 23, 0, - 0, 7, 12, 0, 17, 30, 0, 22, 23, - 0, 0, 5, 15, 0, 17, 30, 0, 98, - 22, 0, 0, 3, 15, 0, 16, 31, 0, - 68, 22, 0, 0, 7, 12, 0, 255, 58, - 1, 16, 21, 0, 0, 4, 0, 0, 17, - 30, 0, 35, 20, 0, 0, 1, 15, 0, - 16, 31, 0, 30, 20, 0, 0, 5, 12, - 0, 16, 31, 0, 192, 19, 0, 0, 7, - 12, 0, 17, 30, 0, 36, 19, 0, 0, - 2, 15, 0, 17, 30, 0, 177, 18, 0, - 0, 7, 15, 0, 16, 31, 0, 82, 18, - 0, 0, 4, 12, 0, 16, 31, 0, 52, - 18, 0, 0, 1, 12, 0, 17, 30, 0, - 208, 17, 0, 0, 5, 15, 0, 16, 31, - 0, 113, 17, 0, 0, 2, 12, 0, 255, - 58, 1, 16, 16, 0, 0, 4, 0, 0, - 17, 30, 0, 165, 15, 0, 0, 3, 15, - 0, 16, 31, 0, 25, 15, 0, 0, 6, - 12, 0, 17, 30, 0, 21, 14, 0, 0, - 4, 15, 0, 16, 31, 0, 32, 13, 0, - 0, 1, 12, 0, 17, 30, 0, 33, 12, - 0, 0, 0, 15, 0, 16, 31, 0, 8, - 12, 0, 0, 7, 12, 0, 17, 30, 0, - 198, 11, 0, 0, 4, 15, 0, 16, 31, - 0, 176, 11, 0, 0, 3, 12, 0, 16, - 31, 0, 160, 11, 0, 0, 2, 12, 0, - 17, 30, 0, 64, 11, 0, 0, 7, 15, - 0, 17, 30, 0, 44, 11, 0, 0, 0, - 15, 0, 255, 58, 1, 208, 9, 0, 0, - 4, 0, 0, 17, 30, 0, 222, 8, 0, - 0, 4, 15, 0, 16, 31, 0, 147, 8, - 0, 0, 6, 12, 0, 17, 30, 0, 32, - 7, 0, 0, 1, 15, 0, 16, 31, 0, - 240, 6, 0, 0, 4, 12, 0, 17, 30, - 0, 114, 6, 0, 0, 3, 15, 0, 16, - 31, 0, 80, 6, 0, 0, 7, 12, 0, - 17, 30, 0, 49, 6, 0, 0, 2, 15, - 0, 255, 58, 1, 208, 4, 0, 0, 4, - 0, 0, 17, 30, 0, 166, 4, 0, 0, - 2, 15, 0, 16, 31, 0, 96, 4, 0, - 0, 4, 12, 0, 17, 30, 0, 202, 3, - 0, 0, 7, 15, 0, 16, 31, 0, 142, - 3, 0, 0, 5, 12, 0, 17, 30, 0, - 193, 2, 0, 0, 0, 15, 0, 16, 31, - 0, 38, 2, 0, 0, 4, 12, 0, 17, - 30, 0, 49, 1, 0, 0, 2, 15, 0 -}; - -const byte ENDRIVER0[10] = {16, 31, 0, 4, 1, 0, 0, 7, 12, 0}; - -const byte RIVER1OBJECTS[490] = { - 16, 31, 0, 8, 27, 0, 0, 1, 12, - 0, 16, 31, 0, 84, 26, 0, 0, 4, - 12, 0, 17, 30, 0, 43, 26, 0, 0, - 1, 15, 0, 16, 31, 0, 210, 25, 0, - 0, 2, 12, 0, 17, 30, 0, 95, 25, - 0, 0, 6, 15, 0, 17, 30, 0, 241, - 24, 0, 0, 4, 15, 0, 16, 31, 0, - 206, 24, 0, 0, 1, 12, 0, 17, 30, - 0, 36, 24, 0, 0, 0, 15, 0, 255, - 58, 1, 144, 23, 0, 0, 4, 0, 0, - 16, 31, 0, 168, 22, 0, 0, 3, 12, - 0, 17, 30, 0, 158, 22, 0, 0, 6, - 15, 0, 16, 31, 0, 154, 21, 0, 0, - 4, 12, 0, 16, 31, 0, 124, 21, 0, - 0, 7, 12, 0, 17, 30, 0, 119, 21, - 0, 0, 1, 15, 0, 17, 30, 0, 0, - 21, 0, 0, 0, 15, 0, 16, 31, 0, - 208, 20, 0, 0, 7, 12, 0, 17, 30, - 0, 128, 20, 0, 0, 2, 15, 0, 16, - 31, 0, 128, 20, 0, 0, 6, 12, 0, - 255, 58, 1, 144, 18, 0, 0, 4, 0, - 0, 17, 30, 0, 80, 17, 0, 0, 2, - 15, 0, 16, 31, 0, 80, 17, 0, 0, - 7, 12, 0, 16, 31, 0, 32, 17, 0, - 0, 2, 12, 0, 17, 30, 0, 16, 17, - 0, 0, 5, 15, 0, 16, 31, 0, 240, - 16, 0, 0, 4, 12, 0, 17, 30, 0, - 89, 16, 0, 0, 1, 15, 0, 16, 31, - 0, 29, 16, 0, 0, 3, 12, 0, 17, - 30, 0, 233, 14, 0, 0, 7, 15, 0, - 16, 31, 0, 28, 14, 0, 0, 4, 12, - 0, 16, 31, 0, 32, 13, 0, 0, 5, - 12, 0, 16, 31, 0, 193, 12, 0, 0, - 7, 12, 0, 17, 30, 0, 128, 12, 0, - 0, 1, 15, 0, 17, 30, 0, 240, 11, - 0, 0, 6, 15, 0, 255, 58, 1, 16, - 11, 0, 0, 4, 0, 0, 16, 31, 0, - 180, 10, 0, 0, 3, 12, 0, 17, 30, - 0, 134, 10, 0, 0, 6, 15, 0, 16, - 31, 0, 151, 9, 0, 0, 0, 12, 0, - 17, 30, 0, 237, 8, 0, 0, 5, 15, - 0, 16, 31, 0, 212, 8, 0, 0, 2, - 12, 0, 16, 31, 0, 112, 7, 0, 0, - 5, 12, 0, 17, 30, 0, 16, 7, 0, - 0, 1, 15, 0, 16, 31, 0, 208, 6, - 0, 0, 7, 12, 0, 17, 30, 0, 160, - 6, 0, 0, 4, 15, 0, 16, 31, 0, - 32, 6, 0, 0, 2, 12, 0, 255, 58, - 1, 208, 4, 0, 0, 4, 0, 0, 17, - 30, 0, 202, 3, 0, 0, 4, 15, 0, - 16, 31, 0, 142, 3, 0, 0, 7, 12, - 0, 17, 30, 0, 193, 2, 0, 0, 0, - 15, 0, 16, 31, 0, 38, 2, 0, 0, - 6, 12, 0, 17, 30, 0, 49, 1, 0, - 0, 3, 15, 0 -}; - -const byte ENDRIVER1[10] = { - 16, 31, 0, 4, 1, 0, 0, 1, 12, 0 -}; - -const byte RIVER2OBJECTS[530] = { - 16, 31, 0, 38, 32, 0, 0, 6, 12, - 0, 16, 31, 0, 179, 31, 0, 0, 7, - 12, 0, 17, 30, 0, 19, 31, 0, 0, - 4, 15, 0, 16, 31, 0, 210, 30, 0, - 0, 0, 12, 0, 16, 31, 0, 192, 29, - 0, 0, 2, 12, 0, 17, 30, 0, 48, - 29, 0, 0, 5, 15, 0, 16, 31, 0, - 1, 29, 0, 0, 4, 12, 0, 17, 30, - 0, 192, 28, 0, 0, 1, 15, 0, 16, - 31, 0, 160, 28, 0, 0, 6, 12, 0, - 255, 58, 1, 80, 27, 0, 0, 4, 0, - 0, 16, 31, 0, 64, 26, 0, 0, 3, - 12, 0, 17, 30, 0, 44, 26, 0, 0, - 6, 15, 0, 16, 31, 0, 118, 25, 0, - 0, 2, 12, 0, 17, 30, 0, 81, 24, - 0, 0, 5, 15, 0, 16, 31, 0, 56, - 24, 0, 0, 2, 12, 0, 17, 30, 0, - 102, 23, 0, 0, 1, 15, 0, 16, 31, - 0, 72, 23, 0, 0, 7, 12, 0, 16, - 31, 0, 68, 22, 0, 0, 2, 12, 0, - 17, 30, 0, 18, 22, 0, 0, 4, 15, - 0, 16, 31, 0, 192, 21, 0, 0, 5, - 12, 0, 17, 30, 0, 112, 21, 0, 0, - 6, 15, 0, 255, 58, 1, 208, 19, 0, - 0, 4, 0, 0, 17, 30, 0, 217, 18, - 0, 0, 4, 15, 0, 16, 31, 0, 174, - 18, 0, 0, 2, 12, 0, 17, 30, 0, - 52, 18, 0, 0, 5, 15, 0, 16, 31, - 0, 158, 17, 0, 0, 7, 12, 0, 16, - 31, 0, 143, 17, 0, 0, 1, 12, 0, - 17, 30, 0, 154, 16, 0, 0, 2, 15, - 0, 16, 31, 0, 99, 16, 0, 0, 4, - 12, 0, 255, 58, 1, 208, 14, 0, 0, - 4, 0, 0, 17, 30, 0, 16, 14, 0, - 0, 3, 15, 0, 16, 31, 0, 142, 13, - 0, 0, 5, 12, 0, 16, 31, 0, 94, - 13, 0, 0, 2, 12, 0, 17, 30, 0, - 98, 12, 0, 0, 6, 15, 0, 16, 31, - 0, 144, 11, 0, 0, 4, 12, 0, 17, - 30, 0, 139, 11, 0, 0, 7, 15, 0, - 255, 58, 1, 208, 9, 0, 0, 4, 0, - 0, 17, 30, 0, 111, 9, 0, 0, 1, - 15, 0, 16, 31, 0, 14, 9, 0, 0, - 0, 12, 0, 17, 30, 0, 227, 8, 0, - 0, 2, 15, 0, 16, 31, 0, 222, 8, - 0, 0, 6, 12, 0, 17, 30, 0, 234, - 7, 0, 0, 3, 15, 0, 16, 31, 0, - 208, 7, 0, 0, 0, 12, 0, 16, 31, - 0, 48, 7, 0, 0, 3, 12, 0, 17, - 30, 0, 3, 7, 0, 0, 7, 15, 0, - 16, 31, 0, 98, 6, 0, 0, 5, 12, - 0, 17, 30, 0, 94, 6, 0, 0, 1, - 15, 0, 255, 58, 1, 208, 4, 0, 0, - 4, 0, 0, 17, 30, 0, 202, 3, 0, - 0, 2, 15, 0, 16, 31, 0, 142, 3, - 0, 0, 5, 12, 0, 17, 30, 0, 193, - 2, 0, 0, 0, 15, 0, 16, 31, 0, - 38, 2, 0, 0, 4, 12, 0, 17, 30, - 0, 49, 1, 0, 0, 3, 15, 0 -}; - -const byte ENDRIVER2[10] = { - 16, 31, 0, 4, 1, 0, 0, 6, 12, 0 -}; - -const byte *RIVEROBJECTTBL[6] = { +const RiverStruct RIVER0OBJECTS[45] = { + {16, 31, 6400, 0, 4, 12}, + {16, 31, 6200, 0, 2, 12}, + {17, 30, 6100, 0, 3, 15}, + {16, 31, 5970, 0, 7, 12}, + {17, 30, 5910, 0, 5, 15}, + {17, 30, 5730, 0, 3, 15}, + {16, 31, 5700, 0, 7, 12}, + {-1, 314, 5392, 0, 4, 0}, + {17, 30, 5155, 0, 1, 15}, + {16, 31, 5150, 0, 5, 12}, + {16, 31, 5056, 0, 7, 12}, + {17, 30, 4900, 0, 2, 15}, + {17, 30, 4785, 0, 7, 15}, + {16, 31, 4690, 0, 4, 12}, + {16, 31, 4660, 0, 1, 12}, + {17, 30, 4560, 0, 5, 15}, + {16, 31, 4465, 0, 2, 12}, + {-1, 314, 4112, 0, 4, 0}, + {17, 30, 4005, 0, 3, 15}, + {16, 31, 3865, 0, 6, 12}, + {17, 30, 3605, 0, 4, 15}, + {16, 31, 3360, 0, 1, 12}, + {17, 30, 3105, 0, 0, 15}, + {16, 31, 3080, 0, 7, 12}, + {17, 30, 3014, 0, 4, 15}, + {16, 31, 2992, 0, 3, 12}, + {16, 31, 2976, 0, 2, 12}, + {17, 30, 2880, 0, 7, 15}, + {17, 30, 2860, 0, 0, 15}, + {-1, 314, 2512, 0, 4, 0}, + {17, 30, 2270, 0, 4, 15}, + {16, 31, 2195, 0, 6, 12}, + {17, 30, 1824, 0, 1, 15}, + {16, 31, 1776, 0, 4, 12}, + {17, 30, 1650, 0, 3, 15}, + {16, 31, 1616, 0, 7, 12}, + {17, 30, 1585, 0, 2, 15}, + {-1, 314, 1232, 0, 4, 0}, + {17, 30, 1190, 0, 2, 15}, + {16, 31, 1120, 0, 4, 12}, + {17, 30, 970, 0, 7, 15}, + {16, 31, 910, 0, 5, 12}, + {17, 30, 705, 0, 0, 15}, + {16, 31, 550, 0, 4, 12}, + {17, 30, 305, 0, 2, 15} +}; + +const RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12}; + +const RiverStruct RIVER1OBJECTS[49] = { + {16, 31, 6920, 0, 1, 12}, + {16, 31, 6740, 0, 4, 12}, + {17, 30, 6699, 0, 1, 15}, + {16, 31, 6610, 0, 2, 12}, + {17, 30, 6495, 0, 6, 15}, + {17, 30, 6385, 0, 4, 15}, + {16, 31, 6350, 0, 1, 12}, + {17, 30, 6180, 0, 0, 15}, + {-1, 314, 6032, 0, 4, 0}, + {16, 31, 5800, 0, 3, 12}, + {17, 30, 5790, 0, 6, 15}, + {16, 31, 5530, 0, 4, 12}, + {16, 31, 5500, 0, 7, 12}, + {17, 30, 5495, 0, 1, 15}, + {17, 30, 5376, 0, 0, 15}, + {16, 31, 5328, 0, 7, 12}, + {17, 30, 5248, 0, 2, 15}, + {16, 31, 5248, 0, 6, 12}, + {-1, 314, 4752, 0, 4, 0}, + {17, 30, 4432, 0, 2, 15}, + {16, 31, 4432, 0, 7, 12}, + {16, 31, 4384, 0, 2, 12}, + {17, 30, 4368, 0, 5, 15}, + {16, 31, 4336, 0, 4, 12}, + {17, 30, 4185, 0, 1, 15}, + {16, 31, 4125, 0, 3, 12}, + {17, 30, 3817, 0, 7, 15}, + {16, 31, 3612, 0, 4, 12}, + {16, 31, 3360, 0, 5, 12}, + {16, 31, 3265, 0, 7, 12}, + {17, 30, 3200, 0, 1, 15}, + {17, 30, 3056, 0, 6, 15}, + {-1, 314, 2832, 0, 4, 0}, + {16, 31, 2740, 0, 3, 12}, + {17, 30, 2694, 0, 6, 15}, + {16, 31, 2455, 0, 0, 12}, + {17, 30, 2285, 0, 5, 15}, + {16, 31, 2260, 0, 2, 12}, + {16, 31, 1904, 0, 5, 12}, + {17, 30, 1808, 0, 1, 15}, + {16, 31, 1744, 0, 7, 12}, + {17, 30, 1696, 0, 4, 15}, + {16, 31, 1568, 0, 2, 12}, + {-1, 314, 1232, 0, 4, 0}, + {17, 30, 970, 0, 4, 15}, + {16, 31, 910, 0, 7, 12}, + {17, 30, 705, 0, 0, 15}, + {16, 31, 550, 0, 6, 12}, + {17, 30, 305, 0, 3, 15} +}; + +const RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12}; + +const RiverStruct RIVER2OBJECTS[53] = { + {16, 31, 8230, 0, 6, 12}, + {16, 31, 8115, 0, 7, 12}, + {17, 30, 7955, 0, 4, 15}, + {16, 31, 7890, 0, 0, 12}, + {16, 31, 7616, 0, 2, 12}, + {17, 30, 7472, 0, 5, 15}, + {16, 31, 7425, 0, 4, 12}, + {17, 30, 7360, 0, 1, 15}, + {16, 31, 7328, 0, 6, 12}, + {-1, 314, 6992, 0, 4, 0}, + {16, 31, 6720, 0, 3, 12}, + {17, 30, 6700, 0, 6, 15}, + {16, 31, 6518, 0, 2, 12}, + {17, 30, 6225, 0, 5, 15}, + {16, 31, 6200, 0, 2, 12}, + {17, 30, 5990, 0, 1, 15}, + {16, 31, 5960, 0, 7, 12}, + {16, 31, 5700, 0, 2, 12}, + {17, 30, 5650, 0, 4, 15}, + {16, 31, 5568, 0, 5, 12}, + {17, 30, 5488, 0, 6, 15}, + {-1, 314, 5072, 0, 4, 0}, + {17, 30, 4825, 0, 4, 15}, + {16, 31, 4782, 0, 2, 12}, + {17, 30, 4660, 0, 5, 15}, + {16, 31, 4510, 0, 7, 12}, + {16, 31, 4495, 0, 1, 12}, + {17, 30, 4250, 0, 2, 15}, + {16, 31, 4195, 0, 4, 12}, + {-1, 314, 3792, 0, 4, 0}, + {17, 30, 3600, 0, 3, 15}, + {16, 31, 3470, 0, 5, 12}, + {16, 31, 3422, 0, 2, 12}, + {17, 30, 3170, 0, 6, 15}, + {16, 31, 2960, 0, 4, 12}, + {17, 30, 2955, 0, 7, 15}, + {-1, 314, 2512, 0, 4, 0}, + {17, 30, 2415, 0, 1, 15}, + {16, 31, 2318, 0, 0, 12}, + {17, 30, 2275, 0, 2, 15}, + {16, 31, 2270, 0, 6, 12}, + {17, 30, 2026, 0, 3, 15}, + {16, 31, 2000, 0, 0, 12}, + {16, 31, 1840, 0, 3, 12}, + {17, 30, 1795, 0, 7, 15}, + {16, 31, 1634, 0, 5, 12}, + {17, 30, 1630, 0, 1, 15}, + {-1, 314, 1232, 0, 4, 0}, + {17, 30, 970, 0, 2, 15}, + {16, 31, 910, 0, 5, 12}, + {17, 30, 705, 0, 0, 15}, + {16, 31, 550, 0, 4, 12}, + {17, 30, 305, 0, 3, 15} +}; + +const RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12}; + +const RiverStruct *RIVEROBJECTTBL[6] = { RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, ENDRIVER1, RIVER2OBJECTS, ENDRIVER2 }; diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index b29bdab2c3..ec412766bc 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -29,6 +29,15 @@ namespace Access { namespace Amazon { +struct RiverStruct { + int _id; + int _field1; + int _field3; + int _field5; + int _lane; + int _field8; +}; + extern const char *const FILENAMES[]; extern const byte *CURSORS[10]; @@ -90,14 +99,14 @@ extern const byte MAP2[32]; extern const byte *MAPTBL[3]; -extern const byte RIVER0OBJECTS[450]; -extern const byte ENDRIVER0[10]; -extern const byte RIVER1OBJECTS[490]; -extern const byte ENDRIVER1[10]; -extern const byte RIVER2OBJECTS[530]; -extern const byte ENDRIVER2[10]; +extern const RiverStruct RIVER0OBJECTS[45]; +extern const RiverStruct ENDRIVER0[1]; +extern const RiverStruct RIVER1OBJECTS[49]; +extern const RiverStruct ENDRIVER1[1]; +extern const RiverStruct RIVER2OBJECTS[53]; +extern const RiverStruct ENDRIVER2[1]; -extern const byte *RIVEROBJECTTBL[6]; +extern const RiverStruct *RIVEROBJECTTBL[6]; } // End of namespace Amazon -- cgit v1.2.3 From ff003f3b657a7651cc1f49be84d5190299ec17d5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 11:57:39 -0500 Subject: ACCESS: Fix the jungle walk 2 cutscene --- engines/access/amazon/amazon_scripts.cpp | 96 ++++++++++++++------------------ engines/access/events.cpp | 5 ++ engines/access/events.h | 2 + 3 files changed, 50 insertions(+), 53 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 61387687b6..d0b13d9c58 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -281,33 +281,33 @@ void AmazonScripts::initJWalk2() { void AmazonScripts::jungleMove() { const static int jungleY[3] = {27, 30, 29}; - int cx = 1; - int dx = 0; - if (_vm->_timers[0]._flag == 0) { - _vm->_timers[0]._flag = 1; + int count = 1; + int frameOffset = 0; + + if (!_vm->_timers[0]._flag) { + ++_vm->_timers[0]._flag; _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - for (int i = 0; i <= 3; i++) { + + for (int i = 0; i < 3; ++i) { int newJCnt = (_jCnt[i] + 1) % 8; _jCnt[i] = newJCnt; _jungleX[i] += 5; } - dx = 4; - if (_game->_allenFlag != 1) - cx = 2; - else - cx = 3; + + frameOffset = 4; + count = (_game->_allenFlag != 1) ? 2 : 3; } - for (int i = 0; i <= cx; i++) { + for (int i = 0; i < count; ++i) { ImageEntry ie; ie._flags = 8; ie._spritesPtr = _vm->_objectsTable[24]; - ie._frameNumber = _jCnt[i] + dx; + ie._frameNumber = _jCnt[i] + frameOffset; ie._position = Common::Point(_jungleX[i], jungleY[i]); ie._offsetY = jungleY[i]; _vm->_images.addToList(ie); - dx += 8; + frameOffset += 8; } } @@ -316,33 +316,33 @@ void AmazonScripts::mWhileJWalk2() { initJWalk2(); - while(true) { + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && + (screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { _vm->_images.clear(); _vm->_events->_vbCount = 6; _pImgNum[0] = _game->_plane._xCount; - while ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { - jungleMove(); - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } - if (_game->_plane._xCount == 2) - ++_game->_plane._xCount; - else - --_game->_plane._xCount; - pan(); - scrollJWalk(); + jungleMove(); + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + } - g_system->delayMillis(10); - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + if (_game->_plane._xCount == 2) + ++_game->_plane._xCount; + else + --_game->_plane._xCount; + + pan(); + scrollJWalk(); + + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); } } + _vm->_events->showCursor(); } @@ -522,8 +522,7 @@ void AmazonScripts::mWhileFly() { events.checkForNextFrameCounter(); _vm->_sound->playSound(0); - g_system->delayMillis(10); - events.pollEvents(); + events.pollEventsAndWait(); } } @@ -572,8 +571,7 @@ void AmazonScripts::mWhileFall() { scrollFall(); while (!_vm->shouldQuit() && events._vbCount > 0) { - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); } } @@ -649,10 +647,8 @@ void AmazonScripts::mWhileJWalk() { pan(); scrollJWalk(); - g_system->delayMillis(10); while (!_vm->shouldQuit() && events._vbCount > 0) { - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); } } @@ -732,8 +728,7 @@ void AmazonScripts::mWhileDoOpen() { screen.forceFadeIn(); } - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { _game->_skipStart = true; @@ -748,8 +743,7 @@ void AmazonScripts::mWhileDoOpen() { events._vbCount = 125; while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) { - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); } break; } @@ -872,10 +866,8 @@ void AmazonScripts::mWhileDownRiver() { _vm->_sound->playSound(0); } - g_system->delayMillis(10); while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } } } @@ -1282,12 +1274,11 @@ void AmazonScripts::doCast(int param1) { _vm->_events->_vbCount = 50; while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone()) - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); break; } @@ -1295,7 +1286,7 @@ void AmazonScripts::doCast(int param1) { _vm->_sound->newMusic(58, 1); _vm->_events->showCursor(); - warning("TODO: delete _roomInfo;"); + _vm->freeCells(); _vm->_oldRects.clear(); _vm->_newRects.clear(); @@ -1834,8 +1825,7 @@ void AmazonScripts::RIVER() { SCROLLRIVER1(); while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } } } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index fd432573e4..d911e666ea 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -181,6 +181,11 @@ void EventsManager::pollEvents() { } } +void EventsManager::pollEventsAndWait() { + pollEvents(); + g_system->delayMillis(10); +} + bool EventsManager::checkForNextFrameCounter() { // Check for next game frame uint32 milli = g_system->getMillis(); diff --git a/engines/access/events.h b/engines/access/events.h index d73f76af49..0a2a541de9 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -107,6 +107,8 @@ public: void pollEvents(); + void pollEventsAndWait(); + void zeroKeys(); bool getKey(Common::KeyState &key); -- cgit v1.2.3 From ada5ca20f97a4d0b3b21ed18feac7c8d814d8959 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 14:52:22 -0500 Subject: ACCESS: Reorganise Amazon game-specific variables that are saved --- engines/access/amazon/amazon_game.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 3b8b98101e..26a9454d09 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -54,10 +54,6 @@ public: class AmazonEngine : public AccessEngine { private: - // Fields that are included in savegames - int _esTabTable[100]; - - // Other fields Common::Point _tilePos; byte _tileData[1455]; Common::Array _chapterCells; @@ -101,18 +97,9 @@ public: bool _charSegSwitch; bool _skipStart; - int _canoeLane; - int _canoeYPos; - int _hitCount; const RiverStruct *_topList; const RiverStruct *_botList; - int _riverIndex; - int _saveRiver; int _canoeDir; - int _hitSafe; - int _rawInactiveX; - int _rawInactiveY; - int _inactiveYOff; // Fields that are mapped to flags int &_guardLocation; @@ -130,7 +117,17 @@ public: int &_noSound; // Saved fields + int _canoeLane; + int _canoeYPos; + int _hitCount; + int _saveRiver; + int _hitSafe; int _chapter; + int _riverIndex; + int _rawInactiveX; + int _rawInactiveY; + int _inactiveYOff; + int _esTabTable[100]; // Other game specific fields Guard _guard; -- cgit v1.2.3 From 1cbaab55cd6870c9f75162f1ddb90f0c25959db3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 21:13:25 +0100 Subject: ACCESS: Split cmdDead in order to use it in RIVER --- engines/access/amazon/amazon_scripts.cpp | 4 ++-- engines/access/scripts.cpp | 10 +++++++--- engines/access/scripts.h | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d0b13d9c58..75fbd052b0 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1805,14 +1805,14 @@ void AmazonScripts::RIVER() { _game->_hitSafe -= 2; if (_game->_hitSafe < 0) { - warning("TODO: cmdDead(RIVERDEATH[0]);"); + cmdDead(RIVERDEATH[0]); return; } if (_game->_deathFlag) { _game->_deathCount--; if (_game->_deathCount == 0) { - warning("TODO: cmdDead(RIVERDEATH[_game->_deathType]);"); + cmdDead(RIVERDEATH[_game->_deathType]); return; } } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 9268b829e7..3f94ea2e55 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -775,14 +775,13 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::cmdDead() { - int deathId = _data->readByte(); +void Scripts::cmdDead(int deathId) { _vm->_events->hideCursor(); _vm->_screen->forceFadeOut(); cmdFreeSound(); _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1)); - + _vm->_screen->clearScreen(); _vm->_screen->setPanel(3); @@ -843,6 +842,11 @@ void Scripts::cmdDead() { } } +void Scripts::cmdDead() { + int deathId = _data->readByte(); + cmdDead(deathId); +} + void Scripts::cmdFadeOut() { _vm->_screen->forceFadeOut(); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 2b527a855a..de27ae7205 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -120,6 +120,7 @@ protected: void cmdPlayerOff(); void cmdPlayerOn(); void cmdDead(); + void cmdDead(int deathId); void cmdFadeOut(); void CMDENDVID(); public: -- cgit v1.2.3 From a0beb08984b989d6dcb1c9dcbc8bb083e2534891 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 16:15:07 -0500 Subject: ACCESS: Refactor _inactive from AccessEngine to AmazonEngine --- engines/access/access.cpp | 9 ------ engines/access/access.h | 6 ---- engines/access/amazon/amazon_game.cpp | 11 ++++++- engines/access/amazon/amazon_game.h | 11 +++++++ engines/access/amazon/amazon_room.cpp | 9 +++++- engines/access/amazon/amazon_room.h | 1 + engines/access/amazon/amazon_scripts.cpp | 50 +++++++++++++++++++------------- engines/access/martian/martian_room.cpp | 6 ++-- engines/access/room.cpp | 1 - engines/access/room.h | 2 +- 10 files changed, 64 insertions(+), 42 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index e87b647b59..cb47598066 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -54,9 +54,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; - _inactive._spritesPtr = nullptr; - _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; - _inactive._position = Common::Point(0, 0); _music = nullptr; _title = nullptr; _converseMode = 0; @@ -128,7 +125,6 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete _inactive._spritesPtr; delete _music; delete _title; delete _eseg; @@ -212,11 +208,6 @@ void AccessEngine::freeCells() { } } -void AccessEngine::freeInactiveData() { - delete _inactive._spritesPtr; - _inactive._spritesPtr = nullptr; -} - void AccessEngine::speakText(ASurface *s, const Common::String &msg) { Common::String lines = msg; Common::String line; diff --git a/engines/access/access.h b/engines/access/access.h index 805abcce02..12e0e1bd5e 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -175,7 +175,6 @@ public: int _mouseMode; int _currentManOld; - ImageEntry _inactive; Resource *_music; Resource *_title; int _converseMode; @@ -250,11 +249,6 @@ public: */ void freeCells(); - /** - * Free the inactive data - */ - void freeInactiveData(); - virtual void establish(int esatabIndex, int sub) = 0; void plotList(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index def64f2f88..5c7a3edca2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -72,10 +72,19 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) memset(_tileData, 0, sizeof(_tileData)); _chapterCells.push_back(CellIdent(0, 96, 17)); - + _inactive._spritesPtr = nullptr; + _inactive._altSpritesPtr = nullptr; + _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; + _inactive._position = Common::Point(0, 0); } AmazonEngine::~AmazonEngine() { + delete _inactive._spritesPtr; +} + +void AmazonEngine::freeInactivePlayer() { + delete _inactive._spritesPtr; + _inactive._spritesPtr = nullptr; } void AmazonEngine::playGame() { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 26a9454d09..05caa21018 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -52,6 +52,11 @@ public: Guard(); }; +class InactivePlayer : public ImageEntry { +public: + SpriteResource *_altSpritesPtr; +}; + class AmazonEngine : public AccessEngine { private: Common::Point _tilePos; @@ -94,6 +99,7 @@ protected: */ virtual void synchronize(Common::Serializer &s); public: + InactivePlayer _inactive; bool _charSegSwitch; bool _skipStart; @@ -161,6 +167,11 @@ public: virtual ~AmazonEngine(); + /** + * Free the inactive player data + */ + void freeInactivePlayer(); + void drawHelp(); virtual void establish(int esatabIndex, int sub); diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index db46b4836c..262a6caa87 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); - _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + _game->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); delete spriteData; _vm->_currentCharFlag = false; } @@ -168,9 +168,11 @@ void AmazonRoom::mainAreaClick() { _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) { switch (checkBoxes1(pt)) { case 0: + // Make Jason the active player _game->_jasMayaFlag = 0; return; case 1: + // Make Maya the active player _game->_jasMayaFlag = 1; return; default: @@ -208,6 +210,11 @@ void AmazonRoom::init4Quads() { _vm->_screen->clearScreen(); } +void AmazonRoom::clearRoom() { + Room::clearRoom(); + _game->freeInactivePlayer(); +} + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index 6b89a8f348..bcb0d84e15 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -52,6 +52,7 @@ protected: virtual void mainAreaClick(); + virtual void clearRoom(); public: AmazonRoom(AccessEngine *vm); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 75fbd052b0..8a92dd6994 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1553,41 +1553,51 @@ void AmazonScripts::boatWalls(int param1, int param2) { } void AmazonScripts::plotInactive() { + Player &player = *_vm->_player; + InactivePlayer &inactive = _game->_inactive; + if (_game->_charSegSwitch) { _game->_currentCharFlag = true; - SpriteResource *tmp = _vm->_inactive._spritesPtr; - _vm->_inactive._spritesPtr = _vm->_player->_playerSprites; - _vm->_player->_playerSprites = tmp; + SpriteResource *tmp = inactive._spritesPtr; + inactive._spritesPtr = player._playerSprites; + player._playerSprites = tmp; _game->_charSegSwitch = false; } else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) { - if (_vm->_player->_playerOff) { + if (player._playerOff) { _game->_jasMayaFlag = (_game->_currentCharFlag ? 1 : 0); } else { _game->_currentCharFlag = (_game->_jasMayaFlag == 1); int tmpX = _game->_rawInactiveX; int tmpY = _game->_rawInactiveY; - _game->_rawInactiveX = _vm->_player->_rawPlayer.x; - _game->_rawInactiveY = _vm->_player->_rawPlayer.y; - _vm->_player->_rawPlayer.x = tmpX; - _vm->_player->_rawPlayer.y = tmpY; - _game->_inactiveYOff = _vm->_player->_playerOffset.y; - _vm->_player->calcManScale(); + _game->_rawInactiveX = player._rawPlayer.x; + _game->_rawInactiveY = player._rawPlayer.y; + player._rawPlayer.x = tmpX; + player._rawPlayer.y = tmpY; + _game->_inactiveYOff = player._playerOffset.y; + player.calcManScale(); } } - if (_vm->_player->_roomNumber == 44) { - warning("CHECKME: Only sets useless(?) flags 155 and 160"); + _game->_flags[155] = 0; + if (_game->_rawInactiveX >= 152 && _game->_rawInactiveX <= 167 && + _game->_rawInactiveY >= 158 && _game->_rawInactiveY <= 173) { + _game->_flags[155] = 1; + } else { + _game->_flags[160] = 1; + if (!_game->_jasMayaFlag && _game->_rawInactiveX <= 266 && _game->_rawInactiveX < 290 + && _game->_rawInactiveY >= 70 && _game->_rawInactiveY <= 87) { + _game->_flags[160] = 1; + } } - _vm->_inactive._flags &= 0xFD; - _vm->_inactive._flags &= 0xF7; - _vm->_inactive._position.x = _game->_rawInactiveX; - _vm->_inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff; - _vm->_inactive._offsetY = _game->_inactiveYOff; - _vm->_inactive._frameNumber = 0; - - _vm->_images.addToList(_vm->_inactive); + inactive._flags &= ~IMGFLAG_UNSCALED; + inactive._flags &= ~IMGFLAG_BACKWARDS; + inactive._position.x = _game->_rawInactiveX; + inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff; + inactive._offsetY = _game->_inactiveYOff; + inactive._frameNumber = 0; + _vm->_images.addToList(_game->_inactive); } void AmazonScripts::setRiverPan() { diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 6d4d62f7e9..62c44bc529 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -75,9 +75,9 @@ void MartianRoom::reloadRoom() { void MartianRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { - Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); - _vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); - delete spriteData; + //Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); + //_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + //delete spriteData; _vm->_currentCharFlag = false; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 31d1583c3e..37746d1b7c 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -164,7 +164,6 @@ void Room::clearRoom() { _vm->freeCells(); freePlayField(); freeTileData(); - _vm->freeInactiveData(); _vm->_player->freeSprites(); } diff --git a/engines/access/room.h b/engines/access/room.h index 9b3136630e..a26f2ed04c 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -144,7 +144,7 @@ public: /** * Clear all the data used by the room */ - void clearRoom(); + virtual void clearRoom(); /** * Builds up a game screen -- cgit v1.2.3 From 9e84be664cab90788aa67049732bc6be1e5b6209 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 22:21:48 +0100 Subject: ACCESS: Implement a couple of script functions --- engines/access/access.cpp | 2 ++ engines/access/access.h | 2 ++ engines/access/scripts.cpp | 17 ++++++++++++++--- engines/access/scripts.h | 2 +- engines/access/video.cpp | 4 +++- engines/access/video.h | 1 + 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cb47598066..cdabb323e4 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -107,6 +107,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _txtPages = 0; _sndSubFile = 0; _loadSaveSlot = -1; + _vidX = _vidY = 0; } AccessEngine::~AccessEngine() { @@ -171,6 +172,7 @@ void AccessEngine::initialize() { _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); _buffer2.create(g_system->getWidth(), g_system->getHeight()); + _vidBuf.create(160, 101); // If requested, load a savegame instead of showing the intro if (ConfMan.hasKey("save_slot")) { diff --git a/engines/access/access.h b/engines/access/access.h index 12e0e1bd5e..2cd35fbf1d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -156,6 +156,8 @@ public: ASurface *_current; ASurface _buffer1; ASurface _buffer2; + ASurface _vidBuf; + int _vidX, _vidY; Common::Array _charTable; SpriteResource *_objectsTable[100]; bool _establishTable[100]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 3f94ea2e55..442d91d255 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -123,7 +123,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, - &Scripts::CMDSETBUFVID, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, + &Scripts::cmdSetBufVid, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, @@ -497,8 +497,19 @@ void Scripts::cmdVideoEnded() { } } -void Scripts::CMDSETBUFVID() { error("TODO CMDSETBUFVID"); } -void Scripts::CMDPLAYBUFVID() { error("TODO CMDPLAYBUFVID"); } +void Scripts::cmdSetBufVid() { + _vm->_vidX = _data->readUint16LE(); + _vm->_vidY = _data->readUint16LE(); + int idx = _data->readUint16LE(); + int rate = _data->readUint16LE(); + + _vm->_video->setVideo(&_vm->_vidBuf, Common::Point(0, 0), FileIdent(_vm->_extraCells[idx]._vid._fileNum, _vm->_extraCells[idx]._vid._subfile), rate); +} + +void Scripts::CMDPLAYBUFVID() { + _vm->_video->playVideo(); + _vm->_video->copyVideo(); +} void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index de27ae7205..aa9b266c0c 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -98,7 +98,7 @@ protected: void cmdSetBuffer(); void cmdSetScroll(); void cmdVideoEnded(); - void CMDSETBUFVID(); + void cmdSetBufVid(); void CMDPLAYBUFVID(); void cmdRemoveLast(); void cmdSpecial(); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index b46bdf240f..539ad34b8c 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -140,5 +140,7 @@ void VideoPlayer::playVideo() { } } - +void VideoPlayer::copyVideo() { + warning("TODO: copyVideo"); +} } // End of namespace Access diff --git a/engines/access/video.h b/engines/access/video.h index b49c876a07..f4be76de31 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -69,6 +69,7 @@ public: */ void playVideo(); + void copyVideo(); /** * Frees the data for a previously loaded video */ -- cgit v1.2.3 From 80ec09d0aee51a5430887cc94c70928375d55640 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 22:29:46 +0100 Subject: ACCESS: Rename a function --- engines/access/scripts.cpp | 4 ++-- engines/access/scripts.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 442d91d255..2336e78041 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -123,7 +123,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, - &Scripts::cmdSetBufVid, &Scripts::CMDPLAYBUFVID, &Scripts::cmdRemoveLast, + &Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, @@ -506,7 +506,7 @@ void Scripts::cmdSetBufVid() { _vm->_video->setVideo(&_vm->_vidBuf, Common::Point(0, 0), FileIdent(_vm->_extraCells[idx]._vid._fileNum, _vm->_extraCells[idx]._vid._subfile), rate); } -void Scripts::CMDPLAYBUFVID() { +void Scripts::cmdPlayBufVid() { _vm->_video->playVideo(); _vm->_video->copyVideo(); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index aa9b266c0c..ebee79d458 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -99,7 +99,7 @@ protected: void cmdSetScroll(); void cmdVideoEnded(); void cmdSetBufVid(); - void CMDPLAYBUFVID(); + void cmdPlayBufVid(); void cmdRemoveLast(); void cmdSpecial(); void cmdSetCycle(); -- cgit v1.2.3 From 74a61d1118df5c54b2ad75f6068328d8a6d54bec Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 17:31:43 -0500 Subject: ACCESS: Fix the ability to switch between players --- engines/access/amazon/amazon_game.cpp | 6 +++--- engines/access/amazon/amazon_room.cpp | 2 +- engines/access/amazon/amazon_scripts.cpp | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 5c7a3edca2..657458fa44 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -79,12 +79,12 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) } AmazonEngine::~AmazonEngine() { - delete _inactive._spritesPtr; + delete _inactive._altSpritesPtr; } void AmazonEngine::freeInactivePlayer() { - delete _inactive._spritesPtr; - _inactive._spritesPtr = nullptr; + delete _inactive._altSpritesPtr; + _inactive._altSpritesPtr = nullptr; } void AmazonEngine::playGame() { diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 262a6caa87..3381688356 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom1() { if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); - _game->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); + _game->_inactive._altSpritesPtr = new SpriteResource(_vm, spriteData); delete spriteData; _vm->_currentCharFlag = false; } diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 8a92dd6994..e4c58c9eb5 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1558,9 +1558,7 @@ void AmazonScripts::plotInactive() { if (_game->_charSegSwitch) { _game->_currentCharFlag = true; - SpriteResource *tmp = inactive._spritesPtr; - inactive._spritesPtr = player._playerSprites; - player._playerSprites = tmp; + SWAP(inactive._altSpritesPtr, player._playerSprites); _game->_charSegSwitch = false; } else if (_game->_jasMayaFlag != (_game->_currentCharFlag ? 1 : 0)) { if (player._playerOff) { @@ -1575,6 +1573,9 @@ void AmazonScripts::plotInactive() { player._rawPlayer.y = tmpY; _game->_inactiveYOff = player._playerOffset.y; player.calcManScale(); + + SWAP(inactive._altSpritesPtr, player._playerSprites); + _vm->_room->setWallCodes(); } } @@ -1595,7 +1596,7 @@ void AmazonScripts::plotInactive() { inactive._position.x = _game->_rawInactiveX; inactive._position.y = _game->_rawInactiveY - _game->_inactiveYOff; inactive._offsetY = _game->_inactiveYOff; - inactive._frameNumber = 0; + inactive._spritesPtr = inactive._altSpritesPtr; _vm->_images.addToList(_game->_inactive); } -- cgit v1.2.3 From ddfe7395546e9b932280d7aae9e6455dbb4d9989 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 23:44:12 +0100 Subject: ACCESS: Implement copyVideo --- engines/access/video.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 539ad34b8c..776c58a83b 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -141,6 +141,28 @@ void VideoPlayer::playVideo() { } void VideoPlayer::copyVideo() { - warning("TODO: copyVideo"); + _vm->_player->calcPlayer(); + Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x, + _vm->_vidY - _vm->_screen->_bufferStart.y, + _vm->_vidX - _vm->_screen->_bufferStart.x + _header._width, + _vm->_vidY - _vm->_screen->_bufferStart.y + _header._height); + if (!_vm->_screen->clip(r)) + return; + + _vm->_newRects.push_back(r); + int vh = _header._height; + int vw = _header._width; + int destIdx = _vm->_vidX - _vm->_screen->_bufferStart.x; + int srcIdx = _vm->_screen->_leftSkip; + for (int i = 0; i < _vm->_screen->_topSkip; i++) + destIdx += 160; + + const byte *srcP = (const byte *)_vm->_vidBuf.getPixels() + srcIdx; + byte *destP = (byte *)_vm->_buffer2.getPixels() + destIdx; + for (int i = 0; i < vh; i++) { + Common::copy(srcP, srcP + vw, destP); + srcP += _vm->_vidBuf.pitch; + destP += _vm->_buffer2.pitch; + } } } // End of namespace Access -- cgit v1.2.3 From 08c65399002ffa7c1d5f055c242996ff0f416fad Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 23 Nov 2014 23:51:25 +0100 Subject: ACCESS: Implement cmdEndVideo --- engines/access/scripts.cpp | 7 +++++-- engines/access/scripts.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2336e78041..d4bd5ad644 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -133,7 +133,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut, - &Scripts::CMDENDVID + &Scripts::cmdEndVideo }; (this->*COMMAND_LIST[commandIndex])(); @@ -862,6 +862,9 @@ void Scripts::cmdFadeOut() { _vm->_screen->forceFadeOut(); } -void Scripts::CMDENDVID() { error("TODO CMDENDVID"); } +void Scripts::cmdEndVideo() { + _vm->_video->closeVideo(); + _vm->_video->_videoEnd = true; +} } // End of namespace Access diff --git a/engines/access/scripts.h b/engines/access/scripts.h index ebee79d458..b6a3dc4dd9 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -122,7 +122,7 @@ protected: void cmdDead(); void cmdDead(int deathId); void cmdFadeOut(); - void CMDENDVID(); + void cmdEndVideo(); public: int _sequence; bool _endFlag; -- cgit v1.2.3 From d2d75dd4a7b3b7d2a90186adf82d45c1c18e3c2a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 17:55:55 -0500 Subject: ACCESS: Workaround for original game bug doing inventory check In scene 31, moving the corrugated metal does a check on an invalid item index --- engines/access/inventory.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 34470ace1e..11baa8fc08 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -87,7 +87,10 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { } int &InventoryManager::operator[](int idx) { - return _inv[idx]._value; + // WORKAROUND: At least in Amazon, some game scripts accidentally do reads + // beyond the length of the inventory array + static int invalid = 0; + return (idx >= _inv.size()) ? invalid : _inv[idx]._value; } int InventoryManager::useItem() { -- cgit v1.2.3 From a9131a93c377311addf8f74d0b71fe6c8fac3aa7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 18:37:22 -0500 Subject: ACCESS: Fix freeing alternate player sprites resource --- engines/access/amazon/amazon_room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 3381688356..762daf06d6 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -211,8 +211,8 @@ void AmazonRoom::init4Quads() { } void AmazonRoom::clearRoom() { - Room::clearRoom(); _game->freeInactivePlayer(); + Room::clearRoom(); } } // End of namespace Amazon -- cgit v1.2.3 From cdb2159ba282bd8218db86651199ee8072603525 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 18:37:34 -0500 Subject: ACCESS: Workaround for original Amazon bug trying to draw player in cutscene In scene 33, the game briefly adds the player to the _images list, even though no player sprites have been loaded, since it's a cutscene scene --- engines/access/player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 2abe9ad097..7adfc5ec0f 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -666,7 +666,8 @@ void Player::plotCom1() { } void Player::plotCom2() { - if (!_playerOff) + // WORKAROUND: Amazon has at least one cutscene with the player not properly turned off + if (!_playerOff && _spritesPtr != nullptr) _vm->_images.addToList(*this); } -- cgit v1.2.3 From 36a3c5d2341204cbbba8bd067f90e65820edb72b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Nov 2014 00:54:45 +0100 Subject: ACCESS: Implement riverJumpTest --- engines/access/amazon/amazon_scripts.cpp | 58 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 4 ++- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index e4c58c9eb5..c61229b5d1 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1733,10 +1733,60 @@ void AmazonScripts::initRiver() { _game->_saveRiver = 0; } -bool AmazonScripts::JUMPTEST() { - warning("TODO: JUMPTEST();"); +void AmazonScripts::RESETPOSITIONS() { + warning("TODO: RESETPOSITIONS"); +} + +void AmazonScripts::CHECKRIVERPAN() { + warning("TODO: CHECKRIVERPAN"); +} + +bool AmazonScripts::riverJumpTest() { + if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) { + int val = _game->_mapPtr[0]; + ++_game->_mapPtr; + if (val == 0xFF) + return true; + _game->_oldScrollCol = _vm->_screen->_scrollCol; + + if (val == 0) { + _vm->_screen->_scrollCol = 139; + _vm->_screen->_scrollX = 14; + _vm->_room->buildScreen(); + RESETPOSITIONS(); + return false; + } + } else if (_vm->_screen->_scrollCol == 105) { + int val1 = _game->_mapPtr[1]; + int val2 = _game->_mapPtr[2]; + _game->_mapPtr += 3; + if (_game->_canoeLane < 3) { + if (val1 != 0) { + _game->_deathFlag = true; + _game->_deathCount = 300; + _game->_deathType = val2; + } + } else { + if (val1 != 1) { + _game->_deathFlag = true; + _game->_deathCount = 300; + _game->_deathType = val2; + } + _game->_oldScrollCol = _vm->_screen->_scrollCol; + _vm->_screen->_scrollCol = 44; + _vm->_screen->_scrollX = 14; + _vm->_room->buildScreen(); + RESETPOSITIONS(); + return false; + } + } - return true; + _vm->_screen->_scrollX = 14; + --_vm->_screen->_scrollCol; + _vm->_buffer1.moveBufferRight(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); + CHECKRIVERPAN(); + return false; } void AmazonScripts::riverSound() { @@ -1784,7 +1834,7 @@ void AmazonScripts::RIVER() { int bx = _vm->_player->_scrollAmount - _screenVertX; if (_vm->_screen->_scrollX == 0) { _vm->_sound->midiRepeat(); - if (JUMPTEST()) { + if (riverJumpTest()) { CHICKENOUTFLG = false; return; } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 7162bab057..155afb8ac7 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -96,7 +96,9 @@ protected: void doCast(int param1); void loadBackground(int param1, int param2); void initRiver(); - bool JUMPTEST(); + void RESETPOSITIONS(); + void CHECKRIVERPAN(); + bool riverJumpTest(); void riverSound(); void MOVECANOE(); void UPDATEOBSTACLES(); -- cgit v1.2.3 From 74a15d659989f90140b8ff30ad4af4783802b758 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 18:59:39 -0500 Subject: ACCESS: Fix the mWhileDownRiver cutscene --- engines/access/amazon/amazon_resources.cpp | 17 ++++++++ engines/access/amazon/amazon_resources.h | 2 + engines/access/amazon/amazon_scripts.cpp | 70 +++++++++++------------------- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 192af2c9b6..af631eae7e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1557,6 +1557,23 @@ const byte MAP2[32] = { const byte *MAPTBL[3] = {MAP0, MAP1, MAP2}; +const int DOWNRIVEROBJ[14][4] = { + { 3, 77, 0, 40 }, + { 2, 30, 0, 30 }, + { 2, 290, 0, 50 }, + { 1, 210, 0, 70 }, + { 2, 350, 0, 30 }, + { 1, 370, 0, 20 }, + { 2, 480, 0, 60 }, + { 3, 395, 0, 10 }, + { 1, 550, 0, 30 }, + { 2, 620, 0, 50 }, + { 1, 690, 0, 10 }, + { 2, 715, 0, 40 }, + { 1, 770, 0, 30 }, + { 3, 700, 0, 20 } +}; + const RiverStruct RIVER0OBJECTS[45] = { {16, 31, 6400, 0, 4, 12}, {16, 31, 6200, 0, 2, 12}, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index ec412766bc..02560ccac4 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -99,6 +99,8 @@ extern const byte MAP2[32]; extern const byte *MAPTBL[3]; +extern const int DOWNRIVEROBJ[14][4]; + extern const RiverStruct RIVER0OBJECTS[45]; extern const RiverStruct ENDRIVER0[1]; extern const RiverStruct RIVER1OBJECTS[49]; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index c61229b5d1..4fc0a4ba91 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -782,23 +782,6 @@ void AmazonScripts::scrollRiver() { } void AmazonScripts::mWhileDownRiver() { - static const int RIVEROBJ[14][4] = { - {3, 77, 0, 40}, - {2, 30, 0, 30}, - {2, 290, 0, 50}, - {1, 210, 0, 70}, - {2, 350, 0, 30}, - {1, 370, 0, 20}, - {2, 480, 0, 60}, - {3, 395, 0, 10}, - {1, 550, 0, 30}, - {2, 620, 0, 50}, - {1, 690, 0, 10}, - {2, 715, 0, 40}, - {1, 770, 0, 30}, - {3, 700, 0, 20} - }; - _vm->_events->hideCursor(); _vm->_screen->setDisplayScan(); _vm->_screen->clearScreen(); @@ -813,8 +796,6 @@ void AmazonScripts::mWhileDownRiver() { _vm->_room->buildScreen(); _vm->copyBF2Vid(); - // KEYFLG = 0; - _vm->_player->_scrollAmount = 2; _vm->_destIn = &_vm->_buffer2; _xTrack = -7; @@ -829,10 +810,10 @@ void AmazonScripts::mWhileDownRiver() { _pNumObj = 14; for (int i = 0; i <_pNumObj; i++) { _pObject[i] = _vm->_objectsTable[33]; - _pImgNum[i] = RIVEROBJ[i][0]; - _pObjX[i] = RIVEROBJ[i][1]; - _pObjY[i] = RIVEROBJ[i][2]; - _pObjZ[i] = RIVEROBJ[i][3]; + _pImgNum[i] = DOWNRIVEROBJ[i][0]; + _pObjX[i] = DOWNRIVEROBJ[i][1]; + _pObjY[i] = DOWNRIVEROBJ[i][2]; + _pObjZ[i] = DOWNRIVEROBJ[i][3]; _pObjXl[i] = _pObjYl[i] = 0; } @@ -843,34 +824,35 @@ void AmazonScripts::mWhileDownRiver() { _game->_timers[4]._initTm = 350; ++_game->_timers[4]._flag; - while(true) { + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && + (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) { _vm->_images.clear(); _vm->_events->_vbCount = 6; - while ((_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) && _vm->_events->_vbCount) { - jungleMove(); - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); - } - pan(); - scrollRiver(); + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_screen->_scrollX >= TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } - if (_game->_timers[3]._flag == 0) { - _game->_timers[3]._flag = 1; - _vm->_sound->playSound(1); - } else if (_game->_timers[4]._flag == 0) { - _game->_timers[4]._flag = 1; - _vm->_sound->playSound(0); - } + pan(); + scrollRiver(); - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); - } + if (!_game->_timers[3]._flag) { + ++_game->_timers[3]._flag; + _vm->_sound->playSound(1); + } else if (!_game->_timers[4]._flag) { + ++_game->_timers[4]._flag; + _vm->_sound->playSound(0); + } + + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); } } + _vm->_events->showCursor(); } -- cgit v1.2.3 From cc07c2e5a229381a5efe5d2aa092270b6dd0b75a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Nov 2014 01:35:24 +0100 Subject: ACCESS: Implement two more RIVER related functions --- engines/access/amazon/amazon_game.h | 4 ++-- engines/access/amazon/amazon_resources.cpp | 14 +++++++------- engines/access/amazon/amazon_resources.h | 16 ++++++++-------- engines/access/amazon/amazon_scripts.cpp | 30 ++++++++++++++++++++++-------- engines/access/amazon/amazon_scripts.h | 4 ++-- 5 files changed, 41 insertions(+), 27 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 05caa21018..c646f513b1 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -103,8 +103,8 @@ public: bool _charSegSwitch; bool _skipStart; - const RiverStruct *_topList; - const RiverStruct *_botList; + RiverStruct *_topList; + RiverStruct *_botList; int _canoeDir; // Fields that are mapped to flags diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index af631eae7e..23929ef4ba 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1574,7 +1574,7 @@ const int DOWNRIVEROBJ[14][4] = { { 3, 700, 0, 20 } }; -const RiverStruct RIVER0OBJECTS[45] = { +RiverStruct RIVER0OBJECTS[45] = { {16, 31, 6400, 0, 4, 12}, {16, 31, 6200, 0, 2, 12}, {17, 30, 6100, 0, 3, 15}, @@ -1622,9 +1622,9 @@ const RiverStruct RIVER0OBJECTS[45] = { {17, 30, 305, 0, 2, 15} }; -const RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12}; +RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12}; -const RiverStruct RIVER1OBJECTS[49] = { +RiverStruct RIVER1OBJECTS[49] = { {16, 31, 6920, 0, 1, 12}, {16, 31, 6740, 0, 4, 12}, {17, 30, 6699, 0, 1, 15}, @@ -1676,9 +1676,9 @@ const RiverStruct RIVER1OBJECTS[49] = { {17, 30, 305, 0, 3, 15} }; -const RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12}; +RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12}; -const RiverStruct RIVER2OBJECTS[53] = { +RiverStruct RIVER2OBJECTS[53] = { {16, 31, 8230, 0, 6, 12}, {16, 31, 8115, 0, 7, 12}, {17, 30, 7955, 0, 4, 15}, @@ -1734,9 +1734,9 @@ const RiverStruct RIVER2OBJECTS[53] = { {17, 30, 305, 0, 3, 15} }; -const RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12}; +RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12}; -const RiverStruct *RIVEROBJECTTBL[6] = { +RiverStruct *RIVEROBJECTTBL[6] = { RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, ENDRIVER1, RIVER2OBJECTS, ENDRIVER2 }; diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 02560ccac4..99ce40e965 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -101,14 +101,14 @@ extern const byte *MAPTBL[3]; extern const int DOWNRIVEROBJ[14][4]; -extern const RiverStruct RIVER0OBJECTS[45]; -extern const RiverStruct ENDRIVER0[1]; -extern const RiverStruct RIVER1OBJECTS[49]; -extern const RiverStruct ENDRIVER1[1]; -extern const RiverStruct RIVER2OBJECTS[53]; -extern const RiverStruct ENDRIVER2[1]; - -extern const RiverStruct *RIVEROBJECTTBL[6]; +extern RiverStruct RIVER0OBJECTS[45]; +extern RiverStruct ENDRIVER0[1]; +extern RiverStruct RIVER1OBJECTS[49]; +extern RiverStruct ENDRIVER1[1]; +extern RiverStruct RIVER2OBJECTS[53]; +extern RiverStruct ENDRIVER2[1]; + +extern RiverStruct *RIVEROBJECTTBL[6]; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4fc0a4ba91..3bd1148b64 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1699,7 +1699,7 @@ void AmazonScripts::initRiver() { _game->_riverIndex = _game->_riverFlag; _game->_topList = RIVEROBJECTTBL[_game->_riverIndex]; UPDATEOBSTACLES(); - SETPHYSX(); + riverSetPhysX(); _game->_canoeDir = 0; _game->_deathFlag = 0; _game->_deathCount = 0; @@ -1715,8 +1715,16 @@ void AmazonScripts::initRiver() { _game->_saveRiver = 0; } -void AmazonScripts::RESETPOSITIONS() { - warning("TODO: RESETPOSITIONS"); +void AmazonScripts::resetPositions() { + riverSetPhysX(); + int val = (_vm->_screen->_scrollCol + 1 - _game->_oldScrollCol) * 16; + if (val > 256) { + val &= 0x7F; + val |= 0x80; + } + + for (int i = 0; i < _pNumObj; i++) + _pObjX[i] += val; } void AmazonScripts::CHECKRIVERPAN() { @@ -1735,7 +1743,7 @@ bool AmazonScripts::riverJumpTest() { _vm->_screen->_scrollCol = 139; _vm->_screen->_scrollX = 14; _vm->_room->buildScreen(); - RESETPOSITIONS(); + resetPositions(); return false; } } else if (_vm->_screen->_scrollCol == 105) { @@ -1758,7 +1766,7 @@ bool AmazonScripts::riverJumpTest() { _vm->_screen->_scrollCol = 44; _vm->_screen->_scrollX = 14; _vm->_room->buildScreen(); - RESETPOSITIONS(); + resetPositions(); return false; } } @@ -1794,8 +1802,14 @@ void AmazonScripts::UPDATEOBSTACLES() { warning("TODO: UPDATEOBSTACLES()"); } -void AmazonScripts::SETPHYSX() { - warning("TODO: SETPHYSX()"); +void AmazonScripts::riverSetPhysX() { + int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + RiverStruct *si = _game->_topList; + RiverStruct *di = _game->_botList; + while (si <= di) { + si[0]._field5 = val - (_screenVertX - si[0]._field3); + si = &si[1]; + } } void AmazonScripts::RIVERCOLLIDE() { @@ -1842,7 +1856,7 @@ void AmazonScripts::RIVER() { } UPDATEOBSTACLES(); - SETPHYSX(); + riverSetPhysX(); RIVERCOLLIDE(); if (_game->_hitSafe != 0) _game->_hitSafe -= 2; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 155afb8ac7..2b634ca89a 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -96,13 +96,13 @@ protected: void doCast(int param1); void loadBackground(int param1, int param2); void initRiver(); - void RESETPOSITIONS(); + void resetPositions(); void CHECKRIVERPAN(); bool riverJumpTest(); void riverSound(); void MOVECANOE(); void UPDATEOBSTACLES(); - void SETPHYSX(); + void riverSetPhysX(); void RIVERCOLLIDE(); void SCROLLRIVER1(); void setRiverPan(); -- cgit v1.2.3 From 68dc425cd4ba6907be6b1fa46c2251e5715b8803 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 23 Nov 2014 21:13:55 -0500 Subject: ACCESS: Implemented buildRow for vertical screen scrolling --- engines/access/asurface.cpp | 4 ++-- engines/access/room.cpp | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index dbbf119171..96cb1991be 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -337,12 +337,12 @@ void ASurface::moveBufferRight() { void ASurface::moveBufferUp() { byte *p = (byte *)getPixels(); - Common::copy(p + w, p + (w * h), p); + Common::copy(p + (w * TILE_HEIGHT), p + (w * h), p); } void ASurface::moveBufferDown() { byte *p = (byte *)getPixels(); - Common::copy_backward(p, p + (w * (h - 1)), p + (w * h)); + Common::copy_backward(p, p + (w * (h - TILE_HEIGHT)), p + (w * h)); } } // End of namespace Access diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 37746d1b7c..f32bc95ae0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -339,7 +339,27 @@ void Room::buildColumn(int playX, int screenX) { } void Room::buildRow(int playY, int screenY) { - error("TODO: buildRow"); + if (playY < 0 || playY >= _playFieldHeight) + return; + assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); + + const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol; + + // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns + int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); + + for (int x = 0; x < w; ++x) { + byte *pTile = _tile + (*pSrc << 8); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY); + + for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { + Common::copy(pTile, pTile + TILE_WIDTH, pDest); + pTile += TILE_WIDTH; + pDest += _vm->_buffer1.pitch; + } + + ++pSrc; + } } void Room::loadPlayField(int fileNum, int subfile) { -- cgit v1.2.3 From 0c4fdc6a4896a4690af45aa0aabe77d90fffcaaf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Nov 2014 13:13:53 +0100 Subject: ACCESS: Implement some more RIVER functions --- engines/access/amazon/amazon_scripts.cpp | 30 +++++++++++++++++++++++------- engines/access/amazon/amazon_scripts.h | 5 +++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 3bd1148b64..3f0e53e6df 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1727,8 +1727,15 @@ void AmazonScripts::resetPositions() { _pObjX[i] += val; } -void AmazonScripts::CHECKRIVERPAN() { - warning("TODO: CHECKRIVERPAN"); +void AmazonScripts::checkRiverPan() { + int val = (_vm->_screen->_scrollCol + 20) * 16; + + for (int i = 0; i < _pNumObj; i++) { + if (_pObjX[i] < val) + return; + } + + setRiverPan(); } bool AmazonScripts::riverJumpTest() { @@ -1775,7 +1782,7 @@ bool AmazonScripts::riverJumpTest() { --_vm->_screen->_scrollCol; _vm->_buffer1.moveBufferRight(); _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); - CHECKRIVERPAN(); + checkRiverPan(); return false; } @@ -1816,8 +1823,17 @@ void AmazonScripts::RIVERCOLLIDE() { warning("TODO: RIVERCOLLIDE()"); } -void AmazonScripts::SCROLLRIVER1() { - warning("TODO: SCROLLRIVER1()"); +void AmazonScripts::PLOTRIVER() { + warning("TODO: PLOTRIVER"); +} + +void AmazonScripts::scrollRiver1() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + PLOTRIVER(); + _vm->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); } void AmazonScripts::RIVER() { @@ -1876,10 +1892,10 @@ void AmazonScripts::RIVER() { if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) { _vm->_events->hideCursor(); - SCROLLRIVER1(); + scrollRiver1(); _vm->_events->pollEvents(); } else - SCROLLRIVER1(); + scrollRiver1(); while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { _vm->_events->pollEventsAndWait(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 2b634ca89a..1e3290e8e7 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -97,14 +97,15 @@ protected: void loadBackground(int param1, int param2); void initRiver(); void resetPositions(); - void CHECKRIVERPAN(); + void checkRiverPan(); bool riverJumpTest(); void riverSound(); void MOVECANOE(); void UPDATEOBSTACLES(); void riverSetPhysX(); void RIVERCOLLIDE(); - void SCROLLRIVER1(); + void PLOTRIVER(); + void scrollRiver1(); void setRiverPan(); void RIVER(); void plotInactive(); -- cgit v1.2.3 From 51ccd0c1fbbb2065441e6c7fbbe7f6ec6c3c3e3e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Nov 2014 21:10:29 +0100 Subject: ACCESS: Implement moveCanoe --- engines/access/amazon/amazon_resources.cpp | 7 ++- engines/access/amazon/amazon_resources.h | 3 + engines/access/amazon/amazon_scripts.cpp | 98 +++++++++++++++++++++++++++++- engines/access/amazon/amazon_scripts.h | 2 +- 4 files changed, 103 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 23929ef4ba..08b57957ec 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1209,9 +1209,10 @@ const char *const NO_HELP_MESSAGE = "WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS. YOUR IQ \ HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \ YOU CAN UNDERSTAND."; -const char *const NO_HINTS_MESSAGE = - "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; - +const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; +const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; +const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; +const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT"; const byte DEATH_SCREENS[58] = { 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 99ce40e965..65a38dc660 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -62,6 +62,9 @@ extern const byte FONT6x6_DATA[]; extern const char *const NO_HELP_MESSAGE; extern const char *const NO_HINTS_MESSAGE; +extern const char *const HIT1; +extern const char *const HIT2; +extern const char *const BAR_MESSAGE; extern const byte DEATH_SCREENS[58]; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 3f0e53e6df..5e53e0b946 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -22,6 +22,7 @@ #include "common/scummsys.h" #include "access/access.h" +#include "access/resources.h" #include "access/amazon/amazon_game.h" #include "access/amazon/amazon_resources.h" #include "access/amazon/amazon_scripts.h" @@ -1801,8 +1802,99 @@ void AmazonScripts::riverSound() { _vm->_sound->playSound(1); } -void AmazonScripts::MOVECANOE() { - warning("TODO: MOVECANOE();"); +void AmazonScripts::moveCanoe() { + if (_game->_canoeDir != 0) { + _game->_canoeYPos += _game->_canoeDir; + ++_game->_canoeMoveCount; + if (_game->_canoeMoveCount == 5) { + _game->_canoeLane += _game->_canoeDir; + _game->_canoeDir = 0; + } + return; + } + + _vm->_events->pollEvents(); + if (_vm->_events->_leftButton) { + Common::Point pt = _vm->_events->calcRawMouse(); + if (pt.y < 180) { + if (_vm->_events->_mousePos.x < RMOUSE[8][0]) { + printString(BAR_MESSAGE); + return; + } + _game->_saveRiver = 1; + _vm->_rScrollRow = _vm->_screen->_scrollRow; + _vm->_rScrollCol = _vm->_screen->_scrollCol; + _vm->_rScrollX = _vm->_screen->_scrollX; + _vm->_rScrollY = _vm->_screen->_scrollY; + _vm->_rOldRectCount = _vm->_oldRects.size(); + _vm->_rNewRectCount = _vm->_newRects.size(); + // _vm->_rKeyFlag = KEYFLG; + _vm->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; + _vm->doLoadSave(); + if (_vm->_room->_function == 1) { + _endFlag = true; + _returnCode = 0; + } else { + _game->_saveRiver = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + } + return; + } + + if (pt.y <= _game->_canoeYPos) { + if (_game->_canoeLane == 0) + return; + + _game->_canoeDir = -1; + _game->_canoeMoveCount = 0; + _game->_canoeYPos += _game->_canoeDir; + ++_game->_canoeMoveCount; + if (_game->_canoeMoveCount == 5) { + _game->_canoeLane += _game->_canoeDir; + _game->_canoeDir = 0; + } + } else { + if (_game->_canoeLane == 7) + return; + + _game->_canoeDir = 1; + _game->_canoeMoveCount = 0; + _game->_canoeYPos += _game->_canoeDir; + ++_game->_canoeMoveCount; + if (_game->_canoeMoveCount == 5) { + _game->_canoeLane += _game->_canoeDir; + _game->_canoeDir = 0; + } + } + return; + } + + if (_vm->_player->_move == UP) { + if (_game->_canoeLane == 0) + return; + + _game->_canoeDir = -1; + _game->_canoeMoveCount = 0; + _game->_canoeYPos += _game->_canoeDir; + ++_game->_canoeMoveCount; + if (_game->_canoeMoveCount == 5) { + _game->_canoeLane += _game->_canoeDir; + _game->_canoeDir = 0; + } + } else if (_vm->_player->_move == DOWN) { + if (_game->_canoeLane == 7) + return; + + _game->_canoeDir = 1; + _game->_canoeMoveCount = 0; + _game->_canoeYPos += _game->_canoeDir; + ++_game->_canoeMoveCount; + if (_game->_canoeMoveCount == 5) { + _game->_canoeLane += _game->_canoeDir; + _game->_canoeDir = 0; + } + } } void AmazonScripts::UPDATEOBSTACLES() { @@ -1864,7 +1956,7 @@ void AmazonScripts::RIVER() { riverSound(); pan(); - MOVECANOE(); + moveCanoe(); if (_vm->_room->_function == 1) { CHICKENOUTFLG = false; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 1e3290e8e7..20fca8ea70 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -100,7 +100,7 @@ protected: void checkRiverPan(); bool riverJumpTest(); void riverSound(); - void MOVECANOE(); + void moveCanoe(); void UPDATEOBSTACLES(); void riverSetPhysX(); void RIVERCOLLIDE(); -- cgit v1.2.3 From f1b99b0ede325c1f447ce79e2c00159871ee1462 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 24 Nov 2014 23:29:57 +0100 Subject: ACCESS: Implement plotRiver --- engines/access/amazon/amazon_scripts.cpp | 45 ++++++++++++++++++++++++++------ engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 5e53e0b946..2c16938ea8 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1903,11 +1903,10 @@ void AmazonScripts::UPDATEOBSTACLES() { void AmazonScripts::riverSetPhysX() { int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; - RiverStruct *si = _game->_topList; - RiverStruct *di = _game->_botList; - while (si <= di) { - si[0]._field5 = val - (_screenVertX - si[0]._field3); - si = &si[1]; + RiverStruct *cur = _game->_topList; + while (cur <= _game->_botList) { + cur[0]._field5 = val - (_screenVertX - cur[0]._field3); + ++cur; } } @@ -1915,14 +1914,44 @@ void AmazonScripts::RIVERCOLLIDE() { warning("TODO: RIVERCOLLIDE()"); } -void AmazonScripts::PLOTRIVER() { - warning("TODO: PLOTRIVER"); +void AmazonScripts::plotRiver() { + if (_vm->_timers[3]._flag == 0) { + ++_vm->_timers[3]._flag; + if (_game->_canoeFrame == 12) + _game->_canoeFrame = 0; + else + ++_game->_canoeFrame; + } + + ImageEntry ie; + ie._flags = 8; + ie._spritesPtr = _vm->_objectsTable[45]; + ie._frameNumber = _game->_canoeFrame; + ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; + ie._position.y = _game->_canoeYPos - 41; + ie._offsetY = 41; + _vm->_images.addToList(ie); + + RiverStruct *cur = _game->_topList; + while (cur <= _game->_botList) { + if (cur[0]._id != -1) { + ie._flags = 8; + ie._spritesPtr = _vm->_objectsTable[45]; + ie._frameNumber = 0; + ie._position.x = cur[0]._field5; + int val = (cur[0]._lane * 5) + 56; + ie._position.y = val - cur[0]._field8; + ie._offsetY = cur[0]._field8; + _vm->_images.addToList(ie); + } + ++cur; + } } void AmazonScripts::scrollRiver1() { _vm->copyBF1BF2(); _vm->_newRects.clear(); - PLOTRIVER(); + plotRiver(); _vm->plotList(); _vm->copyRects(); _vm->copyBF2Vid(); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 20fca8ea70..ef7ead60c9 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -104,7 +104,7 @@ protected: void UPDATEOBSTACLES(); void riverSetPhysX(); void RIVERCOLLIDE(); - void PLOTRIVER(); + void plotRiver(); void scrollRiver1(); void setRiverPan(); void RIVER(); -- cgit v1.2.3 From 8eeb5bd8e6a4f1e3ca7ff8f10c7487ebc75b6426 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Nov 2014 19:18:30 -0500 Subject: ACCESS: Refine scene 9 workaround to stop movement problems on ship --- engines/access/amazon/amazon_room.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 762daf06d6..a942ed3ba8 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -182,7 +182,7 @@ void AmazonRoom::mainAreaClick() { // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due // to not being able to click a Y position that's high enough - if (pt.y > 178) + if (_vm->_screen->_scrollRow == 0 && pt.y > 178) pt.y = 200; _vm->_player->_moveTo = pt; -- cgit v1.2.3 From b01f5d61d7ad648c5d41a86682ce28bb8f9ddc88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Nov 2014 19:23:02 -0500 Subject: ACCESS: Fix vertically scrolling up the screen --- engines/access/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 7adfc5ec0f..2492345ec4 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -741,7 +741,7 @@ bool Player::scrollUp() { _vm->_buffer1.moveBufferUp(); _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, - _vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide); + _vm->_screen->_vWindowLinesTall); if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= _vm->_room->_playFieldHeight) -- cgit v1.2.3 From 9fa0fc845e2cc20f400790be57b607b4e656078e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 24 Nov 2014 21:24:20 -0500 Subject: ACCESS: Fix 'bounce' when reaching left end of a horizontal scrolling scene --- engines/access/player.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 2492345ec4..70f688120c 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -814,8 +814,12 @@ bool Player::scrollRight() { if (_vm->_screen->_scrollX < 0) { do { _vm->_screen->_scrollX += TILE_WIDTH; - if (--_vm->_screen->_scrollCol < 0) + if (--_vm->_screen->_scrollCol < 0) { + _scrollEnd = true; + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollCol = 0; return true; + } _vm->_buffer1.moveBufferRight(); _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); -- cgit v1.2.3 From 5674bed27bb43f0313e4d0a67ad94d4e41e8719c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 07:28:35 +0100 Subject: ACCESS: Implement updateObstacles --- engines/access/amazon/amazon_scripts.cpp | 43 +++++++++++++++++++++++++++++--- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 2c16938ea8..b6d4987caa 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1699,7 +1699,7 @@ void AmazonScripts::initRiver() { _game->_riverIndex = _game->_riverFlag; _game->_topList = RIVEROBJECTTBL[_game->_riverIndex]; - UPDATEOBSTACLES(); + updateObstacles(); riverSetPhysX(); _game->_canoeDir = 0; _game->_deathFlag = 0; @@ -1897,8 +1897,43 @@ void AmazonScripts::moveCanoe() { } } -void AmazonScripts::UPDATEOBSTACLES() { - warning("TODO: UPDATEOBSTACLES()"); +void AmazonScripts::updateObstacles() { + RiverStruct *cur = _game->_topList; + while (true) { + int val = cur[0]._field1 + cur[0]._field3 - 1; + if (val < _screenVertX) { + cur = _game->_topList; + cur--; + _game->_botList = cur; + return; + } + + if (cur[0]._field3 < _screenVertX + 319) { + _game->_topList = _game->_botList = cur; + break; + } + + if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) { + cur = _game->_topList; + cur--; + _game->_botList = cur; + return; + } + } + + while (true) { + if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) + return; + ++cur; + int val = cur[0]._field1 + cur[0]._field3 - 1; + if (val < _screenVertX) + return; + + if (cur[0]._field3 >= _screenVertX + 319) + return; + + _game->_botList = cur; + } } void AmazonScripts::riverSetPhysX() { @@ -1992,7 +2027,7 @@ void AmazonScripts::RIVER() { return; } - UPDATEOBSTACLES(); + updateObstacles(); riverSetPhysX(); RIVERCOLLIDE(); if (_game->_hitSafe != 0) diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index ef7ead60c9..0f71e89e48 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -101,7 +101,7 @@ protected: bool riverJumpTest(); void riverSound(); void moveCanoe(); - void UPDATEOBSTACLES(); + void updateObstacles(); void riverSetPhysX(); void RIVERCOLLIDE(); void plotRiver(); -- cgit v1.2.3 From 6e2d63e4cd8240cc1b0dae2096cbef7bde993afe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 07:48:13 +0100 Subject: ACCESS: Implement checkRiverCollide() --- engines/access/amazon/amazon_scripts.cpp | 26 ++++++++++++++++++++++---- engines/access/amazon/amazon_scripts.h | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index b6d4987caa..e83bc9f190 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1945,8 +1945,26 @@ void AmazonScripts::riverSetPhysX() { } } -void AmazonScripts::RIVERCOLLIDE() { - warning("TODO: RIVERCOLLIDE()"); +bool AmazonScripts::checkRiverCollide() { + if (_game->_hitSafe) + return false; + + _game->_canoeVXPos = _screenVertX + 170; + + for (RiverStruct *si = _game->_topList; si <= _game->_botList; ++si) { + if (si[0]._lane < _game->_canoeLane) + continue; + + if ((si[0]._lane == _game->_canoeLane) || (si[0]._lane == _game->_canoeLane + 1)) { + if (si[0]._field1 + si[0]._field3 - 1 >= _game->_canoeVXPos) { + if (_game->_canoeVXPos + 124 >= si[0]._field3) { + _vm->_sound->playSound(4); + return true; + } + } + } + } + return false; } void AmazonScripts::plotRiver() { @@ -2029,11 +2047,11 @@ void AmazonScripts::RIVER() { updateObstacles(); riverSetPhysX(); - RIVERCOLLIDE(); + bool checkCollide = checkRiverCollide(); if (_game->_hitSafe != 0) _game->_hitSafe -= 2; - if (_game->_hitSafe < 0) { + if (checkCollide) { cmdDead(RIVERDEATH[0]); return; } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 0f71e89e48..1da10d8bdd 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -103,7 +103,7 @@ protected: void moveCanoe(); void updateObstacles(); void riverSetPhysX(); - void RIVERCOLLIDE(); + bool checkRiverCollide(); void plotRiver(); void scrollRiver1(); void setRiverPan(); -- cgit v1.2.3 From a8c99d1986a902aaf65c760b365c49cce2174e30 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 11:33:04 +0100 Subject: ACCESS: Some work on drawHelp (WIP) --- engines/access/amazon/amazon_game.cpp | 64 ++++++++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 2 ++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 657458fa44..e864a921f7 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -624,8 +624,70 @@ void AmazonEngine::updateSummary(int chap) { } } +void AmazonEngine::HELPTITLE() { + warning("TODO: HELPTITLE"); +} + +void AmazonEngine::drawHelpText(const Common::String &msg) { + _screen->_maxChars = 39; + _screen->_printOrg = Common::Point(26, 58); + _screen->_printStart = Common::Point(26, 58); + + Common::String lines = msg; + Common::String line; + int width = 0; + bool lastLine = false; + do { + lastLine = _fonts._font2.getLine(lines, _screen->_maxChars * 6, line, width); + + // Set font colors + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 27; + _fonts._font2._fontColors[2] = 28; + _fonts._font2._fontColors[3] = 29; + + _fonts._font2.drawString(_screen, line, _screen->_printOrg); + _screen->_printOrg = Common::Point(_screen->_printStart.x, _screen->_printOrg.y + 8); + } while (!lastLine); + + _events->showCursor(); +} + void AmazonEngine::drawHelp() { - error("TODO: drawHelp"); + _events->hideCursor(); + if (_useItem == 0) { + _buffer2.copyBuffer(_screen); + if (_screen->_vesaMode) { + _screen->setPanel(2); + _screen->saveScreen(); + } + _screen->setPalette(); + _screen->fadeOut(); + _screen->clearBuffer(); + if (_moreHelp == 1) { + // Set cells + Common::Array cells; + cells.push_back(CellIdent(95, 95, 3)); + loadCells(cells); + } + } + + _files->loadScreen(95, 2); + if (_moreHelp == 1) { + ASurface *oldDest = _destIn; + _destIn = _screen; + int oldClip = _screen->_clipHeight; + _screen->_clipHeight = 200; + _screen->plotImage(_objectsTable[95], 0, Common::Point(76, 168)); + _destIn = oldDest; + _screen->_clipHeight = oldClip; + } + + if ((_useItem == 0) && (_screen->_vesaMode == 0)) + _screen->fadeIn(); + + HELPTITLE(); + drawHelpText("TODO: WHICH BUFFER?"); } void AmazonEngine::startChapter(int chapter) { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index c646f513b1..0aea43575f 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -83,6 +83,8 @@ private: */ void setupGame(); + void HELPTITLE(); + void drawHelpText(const Common::String &msg); void doCredit(); void scrollTitle(); void loadEstablish(int estabIndex); -- cgit v1.2.3 From cc8a8bfdddaf66f6c3b8a7ac049a05b6877eb973 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 07:47:19 -0500 Subject: ACCESS: Refactored Amazon specific player loading into new AmazonPlayer class --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_player.cpp | 86 +++++++++++++++++++++ engines/access/amazon/amazon_player.h | 48 ++++++++++++ engines/access/amazon/amazon_resources.cpp | 13 ++++ engines/access/amazon/amazon_resources.h | 13 ++++ engines/access/animation.cpp | 4 +- engines/access/module.mk | 1 + engines/access/player.cpp | 115 +++++++++++------------------ engines/access/player.h | 8 +- engines/access/resources.cpp | 12 --- engines/access/resources.h | 12 --- 11 files changed, 210 insertions(+), 104 deletions(-) create mode 100644 engines/access/amazon/amazon_player.cpp create mode 100644 engines/access/amazon/amazon_player.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cdabb323e4..88c62a74a7 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -165,7 +165,7 @@ void AccessEngine::initialize() { _events = new EventsManager(this); _files = new FileManager(this); _inventory = new InventoryManager(this); - _player = new Player(this); + _player = Player::init(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); _video = new VideoPlayer(this); diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp new file mode 100644 index 0000000000..ede7ab58e2 --- /dev/null +++ b/engines/access/amazon/amazon_player.cpp @@ -0,0 +1,86 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/room.h" +#include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_player.h" +#include "access/amazon/amazon_resources.h" + +namespace Access { + +namespace Amazon { + +AmazonPlayer::AmazonPlayer(AccessEngine *vm) : Player(vm) { + _game = (AmazonEngine *)vm; +} + +void AmazonPlayer::load() { + Player::load(); + + // Special scene setup for the top-down view when on the Slaver ship + if (_vm->_room->_roomFlag == 3) { + _playerOffset.x = _vm->_screen->_scaleTable1[8]; + _playerOffset.y = _vm->_screen->_scaleTable1[11]; + _leftDelta = 0; + _rightDelta = 8; + _upDelta = 2; + _downDelta = -2; + _scrollConst = 2; + + for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { + _walkOffRight[i] = OVEROFFR[i]; + _walkOffLeft[i] = OVEROFFL[i]; + _walkOffUp[i] = OVEROFFU[i]; + _walkOffDown[i] = OVEROFFD[i]; + _walkOffUR[i].x = OVEROFFURX[i]; + _walkOffUR[i].y = OVEROFFURY[i]; + _walkOffDR[i].x = OVEROFFDRX[i]; + _walkOffDR[i].y = OVEROFFDRY[i]; + _walkOffUL[i].x = OVEROFFULX[i]; + _walkOffUL[i].y = OVEROFFULY[i]; + _walkOffDL[i].x = OVEROFFDLX[i]; + _walkOffDL[i].y = OVEROFFDLY[i]; + } + + _vm->_timers[8]._initTm = 7; + _vm->_timers[8]._timer = 7; + ++_vm->_timers[8]._flag; + + _sideWalkMin = 0; + _sideWalkMax = 5; + _upWalkMin = 12; + _upWalkMax = 17; + _downWalkMin = 6; + _downWalkMax = 11; + _diagUpWalkMin = 0; + _diagUpWalkMax = 5; + _diagDownWalkMin = 0; + _diagDownWalkMax = 5; + _game->_guard._position = Common::Point(56, 190); + } +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h new file mode 100644 index 0000000000..200b530aa1 --- /dev/null +++ b/engines/access/amazon/amazon_player.h @@ -0,0 +1,48 @@ +/* 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 ACCESS_AMAZON_PLAYER_H +#define ACCESS_AMAZON_PLAYER_H + +#include "common/scummsys.h" +#include "access/player.h" + +namespace Access { + +namespace Amazon { + +class AmazonEngine; + +class AmazonPlayer: public Player { +private: + AmazonEngine *_game; +public: + AmazonPlayer(AccessEngine *vm); + + virtual void load(); +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_PLAYER_H */ diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 08b57957ec..e03750fd52 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -245,6 +245,19 @@ const int TRAVEL_POS[][2] = { { 0, 0 } }; +const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; +const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; +const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 }; +const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 }; +const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; +const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 }; +const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; +const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; + const byte CREDITS[] = { 0x2, 0xFF, 0xFF, 0x61, 0x0, 0x3, 0x0, 0x30, 0x22, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 65a38dc660..4229522f44 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -44,6 +44,19 @@ extern const byte *CURSORS[10]; extern const int TRAVEL_POS[][2]; +extern const int OVEROFFR[]; +extern const int OVEROFFL[]; +extern const int OVEROFFU[]; +extern const int OVEROFFD[]; +extern const int OVEROFFURX[]; +extern const int OVEROFFURY[]; +extern const int OVEROFFDRX[]; +extern const int OVEROFFDRY[]; +extern const int OVEROFFULX[]; +extern const int OVEROFFULY[]; +extern const int OVEROFFDLX[]; +extern const int OVEROFFDLY[]; + extern const byte *ROOM_TABLE[]; extern const char *ROOM_DESCR[]; extern const int ROOM_NUMB; diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 184b015371..e59874fe7a 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -222,9 +222,9 @@ void Animation::setFrame1(AnimationFrame *frame) { ImageEntry ie; // Set the flags - ie._flags = part->_flags & 0xF7; + ie._flags = part->_flags & ~IMGFLAG_UNSCALED; if (_vm->_animation->_frameScale == -1) - ie._flags |= 8; + ie._flags |= IMGFLAG_UNSCALED; // Set the other fields ie._spritesPtr = _vm->_objectsTable[part->_spritesIndex]; diff --git a/engines/access/module.mk b/engines/access/module.mk index b6e73b66bd..98464014ba 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS := \ sound.o \ video.o \ amazon/amazon_game.o \ + amazon/amazon_player.o \ amazon/amazon_resources.o \ amazon/amazon_room.o \ amazon/amazon_scripts.o \ diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 70f688120c..b5046632c5 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -25,9 +25,19 @@ #include "access/player.h" #include "access/access.h" #include "access/resources.h" +#include "access/amazon/amazon_player.h" namespace Access { +Player *Player::init(AccessEngine *vm) { + switch (vm->getGameID()) { + case GType_Amazon: + return new Amazon::AmazonPlayer(vm); + default: + return new Player(vm); + } +} + Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); @@ -71,81 +81,40 @@ Player::~Player() { } void Player::load() { - if (_vm->_room->_roomFlag == 3) { - _playerOffset.x = _vm->_screen->_scaleTable1[8]; - _playerOffset.y = _vm->_screen->_scaleTable1[11]; - _leftDelta = 0; - _rightDelta = 8; - _upDelta = 2; - _downDelta = -2; - _scrollConst = 2; - - for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { - _walkOffRight[i] = OVEROFFR[i]; - _walkOffLeft[i] = OVEROFFL[i]; - _walkOffUp[i] = OVEROFFU[i]; - _walkOffDown[i] = OVEROFFD[i]; - _walkOffUR[i].x = OVEROFFURX[i]; - _walkOffUR[i].y = OVEROFFURY[i]; - _walkOffDR[i].x = OVEROFFDRX[i]; - _walkOffDR[i].y = OVEROFFDRY[i]; - _walkOffUL[i].x = OVEROFFULX[i]; - _walkOffUL[i].y = OVEROFFULY[i]; - _walkOffDL[i].x = OVEROFFDLX[i]; - _walkOffDL[i].y = OVEROFFDLY[i]; - } - - _vm->_timers[8]._initTm = 7; - _vm->_timers[8]._timer = 7; - ++_vm->_timers[8]._flag; - - _sideWalkMin = 0; - _sideWalkMax = 5; - _upWalkMin = 12; - _upWalkMax = 17; - _downWalkMin = 6; - _downWalkMax = 11; - _diagUpWalkMin = 0; - _diagUpWalkMax = 5; - _diagDownWalkMin = 0; - _diagDownWalkMax = 5; - _guard = Common::Point(56, 190); - } else { - _playerOffset.x = _vm->_screen->_scaleTable1[25]; - _playerOffset.y = _vm->_screen->_scaleTable1[67]; - _leftDelta = -3; - _rightDelta = 33; - _upDelta = 5; - _downDelta = -10; - _scrollConst = 5; - - for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { - _walkOffRight[i] = SIDEOFFR[i]; - _walkOffLeft[i] = SIDEOFFL[i]; - _walkOffUp[i] = SIDEOFFU[i]; - _walkOffDown[i] = SIDEOFFD[i]; - _walkOffUR[i].x = DIAGOFFURX[i]; - _walkOffUR[i].y = DIAGOFFURY[i]; - _walkOffDR[i].x = DIAGOFFDRX[i]; - _walkOffDR[i].y = DIAGOFFDRY[i]; - _walkOffUL[i].x = DIAGOFFULX[i]; - _walkOffUL[i].y = DIAGOFFULY[i]; - _walkOffDL[i].x = DIAGOFFDLX[i]; - _walkOffDL[i].y = DIAGOFFDLY[i]; - } - - _sideWalkMin = 0; - _sideWalkMax = 7; - _upWalkMin = 16; - _upWalkMax = 23; - _downWalkMin = 8; - _downWalkMax = 15; - _diagUpWalkMin = 0; - _diagUpWalkMax = 7; - _diagDownWalkMin = 0; - _diagDownWalkMax = 7; + _playerOffset.x = _vm->_screen->_scaleTable1[25]; + _playerOffset.y = _vm->_screen->_scaleTable1[67]; + _leftDelta = -3; + _rightDelta = 33; + _upDelta = 5; + _downDelta = -10; + _scrollConst = 5; + + for (int i = 0; i < PLAYER_DATA_COUNT; ++i) { + _walkOffRight[i] = SIDEOFFR[i]; + _walkOffLeft[i] = SIDEOFFL[i]; + _walkOffUp[i] = SIDEOFFU[i]; + _walkOffDown[i] = SIDEOFFD[i]; + _walkOffUR[i].x = DIAGOFFURX[i]; + _walkOffUR[i].y = DIAGOFFURY[i]; + _walkOffDR[i].x = DIAGOFFDRX[i]; + _walkOffDR[i].y = DIAGOFFDRY[i]; + _walkOffUL[i].x = DIAGOFFULX[i]; + _walkOffUL[i].y = DIAGOFFULY[i]; + _walkOffDL[i].x = DIAGOFFDLX[i]; + _walkOffDL[i].y = DIAGOFFDLY[i]; } + _sideWalkMin = 0; + _sideWalkMax = 7; + _upWalkMin = 16; + _upWalkMax = 23; + _downWalkMin = 8; + _downWalkMax = 15; + _diagUpWalkMin = 0; + _diagUpWalkMax = 7; + _diagDownWalkMin = 0; + _diagDownWalkMax = 7; + _playerSprites = _playerSprites1; if (_manPal1) { Common::copy(_manPal1 + 0x270, _manPal1 + 0x270 + 0x60, _vm->_screen->_manPal); diff --git a/engines/access/player.h b/engines/access/player.h index ed48af0932..400770c21a 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -38,8 +38,8 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4, class AccessEngine; -class Player: public ImageEntry, Manager { -private: +class Player: public ImageEntry, public Manager { +protected: int _leftDelta, _rightDelta; int _upDelta, _downDelta; int _scrollConst; @@ -48,7 +48,6 @@ private: int _downWalkMin, _downWalkMax; int _diagUpWalkMin, _diagUpWalkMax; int _diagDownWalkMin, _diagDownWalkMax; - Common::Point _guard; SpriteResource *_playerSprites1; byte *_manPal1; int _scrollEnd; @@ -113,8 +112,9 @@ public: public: Player(AccessEngine *vm); ~Player(); + static Player *init(AccessEngine *vm); - void load(); + virtual void load(); void loadSprites(const Common::String &name); diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index e5a27a8ba1..9bef5cf879 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -58,18 +58,6 @@ const int DIAGOFFULX[] = { 4, 5, 4, 3, 3, 2, 2, 2, 0 }; const int DIAGOFFULY[] = { 3, 3, 1, 2, 2, 1, 1, 1, 0 }; const int DIAGOFFDLX[] = { 4, 5, 3, 3, 5, 4, 6, 1, 0 }; const int DIAGOFFDLY[] = { 2, 2, 1, 2, 3, 1, 2, 1, 0 }; -const int OVEROFFR[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; -const int OVEROFFL[] = { 2, 2, 1, 2, 2, 1, 0, 0, 0 }; -const int OVEROFFU[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; -const int OVEROFFD[] = { 1, 1, 1, 1, 1, 1, 0, 0, 0 }; -const int OVEROFFURX[] = { 3, 1, 1, 2, 2, 1, 0, 0, 0 }; -const int OVEROFFURY[] = { 1, 0, 0, 1, 1, 0, 0, 0, 0 }; -const int OVEROFFDRX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; -const int OVEROFFDRY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; -const int OVEROFFULX[] = { 2, 1, 1, 1, 2, 1, 0, 0, 0 }; -const int OVEROFFULY[] = { 1, 0, 0, 2, 1, 0, 0, 0, 0 }; -const int OVEROFFDLX[] = { 1, 2, 1, 1, 2, 1, 0, 0, 0 }; -const int OVEROFFDLY[] = { 0, 1, 0, 0, 1, 1, 0, 0, 0 }; const int RMOUSE[10][2] = { { 0, 35 }, { 0, 0 }, { 36, 70 }, { 71, 106 }, { 107, 141 }, diff --git a/engines/access/resources.h b/engines/access/resources.h index 6fb781e0d1..10f2adb97e 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -41,18 +41,6 @@ extern const int DIAGOFFULX[]; extern const int DIAGOFFULY[]; extern const int DIAGOFFDLX[]; extern const int DIAGOFFDLY[]; -extern const int OVEROFFR[]; -extern const int OVEROFFL[]; -extern const int OVEROFFU[]; -extern const int OVEROFFD[]; -extern const int OVEROFFURX[]; -extern const int OVEROFFURY[]; -extern const int OVEROFFDRX[]; -extern const int OVEROFFDRY[]; -extern const int OVEROFFULX[]; -extern const int OVEROFFULY[]; -extern const int OVEROFFDLX[]; -extern const int OVEROFFDLY[]; extern const int RMOUSE[10][2]; -- cgit v1.2.3 From 7a691f38cf866c43222ce7d555f6bc953de49017 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 08:24:02 -0500 Subject: ACCESS: Fix guard movement logic on slaver boat --- engines/access/amazon/amazon_scripts.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index e83bc9f190..df6bb8f00f 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1085,10 +1085,11 @@ void AmazonScripts::guard() { switch (_game->_guardLocation) { case 1: + // Guard walking down if (curCel <= 8 || curCel > 13) _game->_guard._guardCel = curCel = 8; - _game->_guard._position.y = _vm->_player->_walkOffDown[curCel - 8]; + _game->_guard._position.y += _vm->_player->_walkOffDown[curCel - 8]; guardSee(); if (_game->_guard._position.y >= 272) { _game->_guard._position.y = 272; @@ -1096,10 +1097,11 @@ void AmazonScripts::guard() { } break; case 2: + // Guard walking left if (curCel <= 43 || curCel > 48) _game->_guard._guardCel = curCel = 43; - _game->_guard._position.x = _vm->_player->_walkOffLeft[curCel - 43]; + _game->_guard._position.x -= _vm->_player->_walkOffLeft[curCel - 43]; guardSee(); if (_game->_guard._position.x <= 56) { _game->_guard._position.x = 56; @@ -1107,10 +1109,11 @@ void AmazonScripts::guard() { } break; case 3: + // Guard walking up if (curCel <= 0 || curCel > 5) _game->_guard._guardCel = curCel = 0; - _game->_guard._position.y = _vm->_player->_walkOffUp[curCel]; + _game->_guard._position.y -= _vm->_player->_walkOffUp[curCel]; guardSee(); if (_game->_guard._position.y <= 89) { _game->_guard._position.y = 89; @@ -1120,10 +1123,11 @@ void AmazonScripts::guard() { } break; default: + // Guard walking right if (curCel <= 43 || curCel > 48) _game->_guard._guardCel = curCel = 43; - _game->_guard._position.x = _vm->_player->_walkOffRight[curCel - 43]; + _game->_guard._position.x += _vm->_player->_walkOffRight[curCel - 43]; guardSee(); if (_game->_guard._position.x >= 127) { _game->_guard._position.x = 127; -- cgit v1.2.3 From 2ea4601589196ba91d2e87582cb5f9325e0b1f95 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 14:56:29 +0100 Subject: ACCESS: Implement helpTitle --- engines/access/amazon/amazon_game.cpp | 48 ++++++++++++++++++++++++++++-- engines/access/amazon/amazon_game.h | 4 ++- engines/access/amazon/amazon_resources.cpp | 17 +++++++++++ engines/access/amazon/amazon_resources.h | 3 +- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index e864a921f7..c12af5e339 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -624,8 +624,50 @@ void AmazonEngine::updateSummary(int chap) { } } -void AmazonEngine::HELPTITLE() { - warning("TODO: HELPTITLE"); +void AmazonEngine::CALCIQ() { + warning("TODO: CALCIQ"); +} + +void AmazonEngine::helpTitle() { + int width = _fonts._font2.stringWidth(_bubbleBox->_bubbleTitle); + int posX = 160 - (width / 2); + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 33; + _fonts._font2._fontColors[2] = 34; + _fonts._font2._fontColors[3] = 35; + _fonts._font2.drawString(_screen, _bubbleBox->_bubbleTitle, Common::Point(posX, 24)); + + width = _fonts._font2.stringWidth(HELPLVLTXT[_helpLevel]); + posX = 160 - (width / 2); + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 10; + _fonts._font2._fontColors[2] = 11; + _fonts._font2._fontColors[3] = 12; + _fonts._font2.drawString(_screen, HELPLVLTXT[_helpLevel], Common::Point(posX, 36)); + + Common::String iqText = "IQ: "; + CALCIQ(); + Common::String IQSCORE = Common::String::format("d", _iqValue); + while (IQSCORE.size() != 4) + IQSCORE = " " + IQSCORE; + + iqText += IQSCORE; + int index = _iqValue; + if (index == 170) + index = 169; + + index /= 20; + + iqText += " "; + iqText += IQLABELS[index]; + + width = _fonts._font2.stringWidth(iqText); + posX = 160 - (width / 2); + _fonts._font2._fontColors[0] = 0; + _fonts._font2._fontColors[1] = 10; + _fonts._font2._fontColors[2] = 11; + _fonts._font2._fontColors[3] = 12; + _fonts._font2.drawString(_screen, iqText, Common::Point(posX, 44)); } void AmazonEngine::drawHelpText(const Common::String &msg) { @@ -686,7 +728,7 @@ void AmazonEngine::drawHelp() { if ((_useItem == 0) && (_screen->_vesaMode == 0)) _screen->fadeIn(); - HELPTITLE(); + helpTitle(); drawHelpText("TODO: WHICH BUFFER?"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 0aea43575f..89d15d36e2 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -83,7 +83,8 @@ private: */ void setupGame(); - void HELPTITLE(); + void CALCIQ(); + void helpTitle(); void drawHelpText(const Common::String &msg); void doCredit(); void scrollTitle(); @@ -164,6 +165,7 @@ public: bool _antEatFl; bool _stabFl; Common::Point _pitPos; + int _iqValue; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index e03750fd52..08ecfff467 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1226,6 +1226,23 @@ const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR TH const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT"; +const char *const HELPLVLTXT[3] = { + " LEVEL 1 ", + " LEVEL 2 ", + " LEVEL 3 " +}; + +const char *const IQLABELS[9] = { + "VEGETABLE", + "NEANDERTHAL", + "LOBOTOMIZED", + "DENSE", + "AVERAGE", + "INTELLIGENT", + "MURPHYITE", + "BRILLIANT", + "GENIUS" +}; const byte DEATH_SCREENS[58] = { 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 4229522f44..37b12d26cf 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -78,7 +78,8 @@ extern const char *const NO_HINTS_MESSAGE; extern const char *const HIT1; extern const char *const HIT2; extern const char *const BAR_MESSAGE; - +extern const char *const HELPLVLTXT[3]; +extern const char *const IQLABELS[9]; extern const byte DEATH_SCREENS[58]; extern const char *const DEATH_TEXT[58]; -- cgit v1.2.3 From 79fa346ca04a6a2a0ac7cb725d21ba496944feb1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 25 Nov 2014 17:06:54 +0100 Subject: ACCESS: Implement calcIQ --- engines/access/amazon/amazon_game.cpp | 31 ++++++++++++++++++++++++++++--- engines/access/amazon/amazon_game.h | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index c12af5e339..33e5888cf4 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -624,8 +624,33 @@ void AmazonEngine::updateSummary(int chap) { } } -void AmazonEngine::CALCIQ() { - warning("TODO: CALCIQ"); +void AmazonEngine::calcIQ() { + int tmpIQ = 170; + for (int i = 0; i < 256; i++) { + if (_help1[i] == 1) + tmpIQ -= 3; + } + + for (int i = 0; i < 256; i++) { + if (_help2[i] == 1) + tmpIQ -= 5; + } + + for (int i = 0; i < 256; i++) { + if (_help3[i] == 1) + tmpIQ -= 10; + } + + if (tmpIQ < 0) + tmpIQ = 0; + + _iqValue = tmpIQ; + + if (_iqValue <= 100) + _badEnd = 1; + + if (_iqValue <= 0) + _noHints = 1; } void AmazonEngine::helpTitle() { @@ -646,7 +671,7 @@ void AmazonEngine::helpTitle() { _fonts._font2.drawString(_screen, HELPLVLTXT[_helpLevel], Common::Point(posX, 36)); Common::String iqText = "IQ: "; - CALCIQ(); + calcIQ(); Common::String IQSCORE = Common::String::format("d", _iqValue); while (IQSCORE.size() != 4) IQSCORE = " " + IQSCORE; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 89d15d36e2..6208796b8a 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -83,7 +83,7 @@ private: */ void setupGame(); - void CALCIQ(); + void calcIQ(); void helpTitle(); void drawHelpText(const Common::String &msg); void doCredit(); -- cgit v1.2.3 From 451a29ada517fad99a5de823efca8758416ccd46 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Nov 2014 00:03:40 +0100 Subject: ACCESS: Fix character in first screen when the intro is played --- engines/access/amazon/amazon_game.cpp | 9 +++++++-- engines/access/amazon/amazon_game.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 33e5888cf4..6288ddb64b 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -107,6 +107,8 @@ void AmazonEngine::playGame() { _screen->forceFadeOut(); _events->showCursor(); + initVariables(); + // If there's a pending savegame to load, load it if (_loadSaveSlot != -1) loadGameState(_loadSaveSlot); @@ -430,8 +432,6 @@ void AmazonEngine::doTent() { } void AmazonEngine::setupGame() { - _chapter = 1; - // Setup timers const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; for (int i = 0; i < 32; ++i) { @@ -456,6 +456,11 @@ void AmazonEngine::setupGame() { _fonts._font1.load(FONT6x6_INDEX, FONT6x6_DATA); _fonts._font2.load(FONT2_INDEX, FONT2_DATA); + initVariables(); +} + +void AmazonEngine::initVariables() { + _chapter = 1; // Set player room and position _player->_roomNumber = 4; _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 6208796b8a..e6c817d242 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -83,6 +83,7 @@ private: */ void setupGame(); + void initVariables(); void calcIQ(); void helpTitle(); void drawHelpText(const Common::String &msg); -- cgit v1.2.3 From 0a28a77e1a6339c292826b264047bd439290fe16 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Nov 2014 00:04:16 +0100 Subject: ACCESS: Silent warning --- engines/access/inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 11baa8fc08..629b89f155 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -90,7 +90,7 @@ int &InventoryManager::operator[](int idx) { // WORKAROUND: At least in Amazon, some game scripts accidentally do reads // beyond the length of the inventory array static int invalid = 0; - return (idx >= _inv.size()) ? invalid : _inv[idx]._value; + return (idx >= (int)_inv.size()) ? invalid : _inv[idx]._value; } int InventoryManager::useItem() { -- cgit v1.2.3 From 486b7d7e04f3832bfd2a6ed63ba92295cd509965 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 26 Nov 2014 00:05:03 +0100 Subject: ACCESS: Add detection for Amazon English Demo --- engines/access/detection_tables.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index 95ac8fa47d..ec1507633c 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -41,6 +41,24 @@ static const AccessGameDescription gameDescriptions[] = { 0 }, + // Amazon Guardians of Eden - Demo English + { + { + "amazon", + "Demo", + { + { "c25.ap", 0, "5baba0c052d22157499bfa05cb1ed5b7", 65458 }, + AD_LISTEND + }, + Common::EN_ANY, + Common::kPlatformDOS, + ADGF_DEMO, + GUIO1(GUIO_NONE) + }, + GType_Amazon, + 0 + }, + { // Amazon: Guardians of Eden - CD English { -- cgit v1.2.3 From 9cd2bbf6bd9c7b053aa5748872087a0fafe0fb3d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 20:17:17 -0500 Subject: ACCESS: Move slaver guard functions into the Guard class --- engines/access/amazon/amazon_game.cpp | 279 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_game.h | 17 +- engines/access/amazon/amazon_scripts.cpp | 253 +--------------------------- engines/access/amazon/amazon_scripts.h | 7 - 4 files changed, 290 insertions(+), 266 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 6288ddb64b..550d8b2b46 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -31,7 +31,7 @@ namespace Access { namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : - AccessEngine(syst, gameDesc), +AccessEngine(syst, gameDesc), _guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), @@ -91,6 +91,7 @@ void AmazonEngine::playGame() { // Initialize Amazon game-specific objects _room = new AmazonRoom(this); _scripts = new AmazonScripts(this); + _guard.setVm(this); // Setup the game setupGame(); @@ -941,17 +942,283 @@ void AmazonEngine::synchronize(Common::Serializer &s) { /*------------------------------------------------------------------------*/ +Plane::Plane() { + _pCount = 0; + _planeCount = 0; + _propCount = 0; + _xCount = 0; +} + +/*------------------------------------------------------------------------*/ + Guard::Guard() { + _vm = nullptr; _guardCel = 0; _gCode1 = _gCode2 = 0; _xMid = _yMid = 0; } -Plane::Plane() { - _pCount = 0; - _planeCount = 0; - _propCount = 0; - _xCount = 0; +void Guard::setVerticalCode() { + _gCode1 = 0; + _gCode2 = 0; + if (_topLeft.x < _vm->_screen->_orgX1) + _gCode1 |= 8; + else if (_topLeft.x == _vm->_screen->_orgX1) { + _gCode1 |= 8; + _gCode1 |= 2; + } + else + _gCode1 |= 2; + + if (_bottomRight.x < _vm->_screen->_orgX1) + _gCode2 |= 8; + else if (_bottomRight.x == _vm->_screen->_orgX1) { + _gCode2 |= 8; + _gCode2 |= 2; + } + else + _gCode2 |= 2; + + if (_topLeft.y < _vm->_screen->_orgY1) + _gCode1 |= 4; + else if (_topLeft.y > _vm->_screen->_orgY2) + _gCode1 |= 1; + + if (_bottomRight.y < _vm->_screen->_orgY1) + _gCode2 |= 4; + else if (_bottomRight.y > _vm->_screen->_orgY2) + _gCode2 |= 1; +} + +void Guard::setHorizontalCode() { + _gCode1 = 0; + _gCode2 = 0; + + if (_topLeft.y < _vm->_screen->_orgY1) + _gCode1 |= 4; + else if (_topLeft.x == _vm->_screen->_orgX1) { + _gCode1 |= 4; + _gCode1 |= 1; + } + else + _gCode1 |= 1; + + if (_bottomRight.y < _vm->_screen->_orgY1) + _gCode2 |= 4; + else if (_bottomRight.x == _vm->_screen->_orgX1) { + _gCode2 |= 4; + _gCode2 |= 1; + } + else + _gCode2 |= 1; + + if (_topLeft.x < _vm->_screen->_orgX1) + _gCode1 |= 8; + else if (_topLeft.x > _vm->_screen->_orgX2) + _gCode1 |= 2; + + if (_bottomRight.x < _vm->_screen->_orgX1) + _gCode2 |= 8; + else if (_bottomRight.y > _vm->_screen->_orgX2) + _gCode2 |= 2; +} + +void Guard::chkVLine() { + if (_position.x > _vm->_player->_rawPlayer.x) { + _topLeft = _vm->_player->_rawPlayer; + _bottomRight = _position; + } else { + _topLeft = _position; + _bottomRight = _vm->_player->_rawPlayer; + } + + if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2) + SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); + + for (;;) { + setVerticalCode(); + int code = _gCode1 | _gCode2; + if (code == 10) { + _vm->_guardFind = 0; + return; + } + + int code2 = _gCode1 & _gCode2; + code2 &= 5; + if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0)) + return; + + int midX = (_topLeft.x + _bottomRight.x) / 2; + int midY = (_topLeft.y + _bottomRight.y) / 2; + + if (midX < _vm->_screen->_orgX1) { + if ((midX == _topLeft.x) && (midY == _topLeft.y)) + return; + + _topLeft.x = midX; + _topLeft.y = midY; + } else { + if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) + return; + + _bottomRight.x = midX; + _bottomRight.y = midY; + } + } +} + +void Guard::chkHLine() { + if (_position.y > _vm->_player->_rawPlayer.y) { + _topLeft = _vm->_player->_rawPlayer; + _bottomRight = _position; + } else { + _topLeft = _position; + _bottomRight = _vm->_player->_rawPlayer; + } + + if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2) + SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); + + while (true) { + setHorizontalCode(); + int code = _gCode1 | _gCode2; + if (code == 5) { + _vm->_guardFind = 0; + return; + } + + int code2 = _gCode1 & _gCode2; + code2 &= 10; + if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0)) + return; + + int midX = (_topLeft.x + _bottomRight.x) / 2; + int midY = (_topLeft.y + _bottomRight.y) / 2; + + if (midY < _vm->_screen->_orgY1) { + if ((midX == _topLeft.x) && (midY == _topLeft.y)) + return; + + _topLeft.x = midX; + _topLeft.y = midY; + } else { + if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) + return; + + _bottomRight.x = midX; + _bottomRight.y = midY; + } + } +} + +void Guard::guardSee() { + int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; + _vm->_flags[140] = 0; + if (tmpY > _position.y) + return; + + tmpY += _vm->_screen->_vWindowLinesTall; + tmpY -= 11; + + if (tmpY < _position.y) + return; + + _vm->_guardFind = 1; + _vm->_flags[140] = 1; + + for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { + _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; + _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; + _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; + _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; + if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { + chkVLine(); + if (_vm->_guardFind == 0) + return; + } + else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { + chkHLine(); + if (_vm->_guardFind == 0) + return; + } + } +} + +void Guard::setGuardFrame() { + ImageEntry ie; + ie._flags = 8; + + if (_vm->_guardLocation == 4) + ie._flags |= 2; + ie._spritesPtr = _vm->_objectsTable[37]; + ie._frameNumber = _guardCel; + ie._position = _position; + ie._offsetY = 10; + _vm->_images.addToList(ie); +} + +void Guard::guard() { + if (_vm->_timers[8]._flag != 0) + return; + + ++_vm->_timers[8]._flag; + ++_guardCel; + int curCel = _guardCel; + + switch (_vm->_guardLocation) { + case 1: + // Guard walking down + if (curCel <= 8 || curCel > 13) + _guardCel = curCel = 8; + + _position.y += _vm->_player->_walkOffDown[curCel - 8]; + guardSee(); + if (_position.y >= 272) { + _position.y = 272; + _vm->_guardLocation = 2; + } + break; + case 2: + // Guard walking left + if (curCel <= 43 || curCel > 48) + _guardCel = curCel = 43; + + _position.x -= _vm->_player->_walkOffLeft[curCel - 43]; + guardSee(); + if (_position.x <= 56) { + _position.x = 56; + _vm->_guardLocation = 3; + } + break; + case 3: + // Guard walking up + if (curCel <= 0 || curCel > 5) + _guardCel = curCel = 0; + + _position.y -= _vm->_player->_walkOffUp[curCel]; + guardSee(); + if (_position.y <= 89) { + _position.y = 89; + _vm->_guardLocation = 4; + if (_vm->_flags[121] == 1) + _vm->_guardLocation = 5; + } + break; + default: + // Guard walking right + if (curCel <= 43 || curCel > 48) + _guardCel = curCel = 43; + + _position.x += _vm->_player->_walkOffRight[curCel - 43]; + guardSee(); + if (_position.x >= 127) { + _position.x = 127; + _vm->_guardLocation = 1; + } + break; + } + + setGuardFrame(); } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index e6c817d242..7917586ba2 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -29,6 +29,8 @@ namespace Access { namespace Amazon { + class AmazonEngine; + class Plane { public: int _pCount; @@ -41,15 +43,28 @@ public: }; class Guard { +private: + AmazonEngine *_vm; + + void chkVLine(); + void chkHLine(); + void setVerticalCode(); + void setHorizontalCode(); + void guardSee(); + void setGuardFrame(); public: int _guardCel; Common::Point _position; int _gCode1; int _gCode2; - Common::Rect _bounds; + Common::Point _topLeft; + Common::Point _bottomRight; int _xMid, _yMid; public: Guard(); + void setVm(AmazonEngine *vm) { _vm = vm; } + + void guard(); }; class InactivePlayer : public ImageEntry { diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index df6bb8f00f..f3f120bf72 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -888,257 +888,6 @@ void AmazonScripts::mWhile(int param1) { } } -void AmazonScripts::setVerticalCode(Common::Rect bounds) { - _game->_guard._gCode1 = 0; - _game->_guard._gCode2 = 0; - if (bounds.left < _vm->_screen->_orgX1) - _game->_guard._gCode1 |= 8; - else if (bounds.left == _vm->_screen->_orgX1) { - _game->_guard._gCode1 |= 8; - _game->_guard._gCode1 |= 2; - } else - _game->_guard._gCode1 |= 2; - - if (bounds.right < _vm->_screen->_orgX1) - _game->_guard._gCode2 |= 8; - else if (bounds.right == _vm->_screen->_orgX1) { - _game->_guard._gCode2 |= 8; - _game->_guard._gCode2 |= 2; - } else - _game->_guard._gCode2 |= 2; - - if (bounds.top < _vm->_screen->_orgY1) - _game->_guard._gCode1 |= 4; - else if (bounds.top > _vm->_screen->_orgY2) - _game->_guard._gCode1 |= 1; - - if (bounds.bottom < _vm->_screen->_orgY1) - _game->_guard._gCode2 |= 4; - else if (bounds.bottom > _vm->_screen->_orgY2) - _game->_guard._gCode2 |= 1; -} - -void AmazonScripts::setHorizontalCode(Common::Rect bounds) { - _game->_guard._gCode1 = 0; - _game->_guard._gCode2 = 0; - - if (bounds.top < _vm->_screen->_orgY1) - _game->_guard._gCode1 |= 4; - else if (bounds.left == _vm->_screen->_orgX1) { - _game->_guard._gCode1 |= 4; - _game->_guard._gCode1 |= 1; - } else - _game->_guard._gCode1 |= 1; - - if (bounds.bottom < _vm->_screen->_orgY1) - _game->_guard._gCode2 |= 4; - else if (bounds.right == _vm->_screen->_orgX1) { - _game->_guard._gCode2 |= 4; - _game->_guard._gCode2 |= 1; - } else - _game->_guard._gCode2 |= 1; - - if (bounds.left < _vm->_screen->_orgX1) - _game->_guard._gCode1 |= 8; - else if (bounds.left > _vm->_screen->_orgX2) - _game->_guard._gCode1 |= 2; - - if (bounds.right < _vm->_screen->_orgX1) - _game->_guard._gCode2 |= 8; - else if (bounds.bottom > _vm->_screen->_orgX2) - _game->_guard._gCode2 |= 2; -} - -void AmazonScripts::chkVLine() { - if (_game->_guard._position.x > _vm->_player->_rawPlayer.x) - _game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y); - else - _game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y); - - if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2) - SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); - - while (true) { - setVerticalCode(_game->_guard._bounds); - int code = _game->_guard._gCode1 | _game->_guard._gCode2; - if (code == 10) { - _game->_guardFind = 0; - return; - } - - int code2 = _game->_guard._gCode1 & _game->_guard._gCode2; - code2 &= 5; - if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0)) - return; - - int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2; - int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2; - - if (midX < _vm->_screen->_orgX1) { - if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top)) - return; - - _game->_guard._bounds.left = midX; - _game->_guard._bounds.top = midY; - } else { - if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom)) - return; - - _game->_guard._bounds.right = midX; - _game->_guard._bounds.bottom = midY; - } - } -} - -void AmazonScripts::chkHLine() { - if (_game->_guard._position.y > _vm->_player->_rawPlayer.y) - _game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y); - else - _game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y); - - if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2) - SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); - - while (true) { - setHorizontalCode(_game->_guard._bounds); - int code = _game->_guard._gCode1 | _game->_guard._gCode2; - if (code == 5) { - _game->_guardFind = 0; - return; - } - - int code2 = _game->_guard._gCode1 & _game->_guard._gCode2; - code2 &= 10; - if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0)) - return; - - int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2; - int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2; - - if (midY < _vm->_screen->_orgY1) { - if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top)) - return; - - _game->_guard._bounds.left = midX; - _game->_guard._bounds.top = midY; - } else { - if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom)) - return; - - _game->_guard._bounds.right = midX; - _game->_guard._bounds.bottom = midY; - } - } -} - -void AmazonScripts::guardSee() { - int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; - _game->_flags[140] = 0; - if (tmpY > _game->_guard._position.y) - return; - - tmpY += _vm->_screen->_vWindowLinesTall; - tmpY -= 11; - - if (tmpY < _game->_guard._position.y) - return; - - _game->_guardFind = 1; - _game->_flags[140] = 1; - - for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { - _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; - _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; - _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; - _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; - if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { - chkVLine(); - if (_game->_guardFind == 0) - return; - } else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { - chkHLine(); - if (_game->_guardFind == 0) - return; - } - } -} - -void AmazonScripts::setGuardFrame() { - ImageEntry ie; - ie._flags = 8; - if (_game->_guardLocation == 4) - ie._flags |= 2; - ie._spritesPtr = _vm->_objectsTable[37]; - ie._frameNumber = _game->_guard._guardCel; - ie._position = _game->_guard._position; - ie._offsetY = 10; - _vm->_images.addToList(ie); -} - -void AmazonScripts::guard() { - if (_vm->_timers[8]._flag != 0) - return; - - ++_vm->_timers[8]._flag; - ++_game->_guard._guardCel; - int curCel = _game->_guard._guardCel; - - switch (_game->_guardLocation) { - case 1: - // Guard walking down - if (curCel <= 8 || curCel > 13) - _game->_guard._guardCel = curCel = 8; - - _game->_guard._position.y += _vm->_player->_walkOffDown[curCel - 8]; - guardSee(); - if (_game->_guard._position.y >= 272) { - _game->_guard._position.y = 272; - _game->_guardLocation = 2; - } - break; - case 2: - // Guard walking left - if (curCel <= 43 || curCel > 48) - _game->_guard._guardCel = curCel = 43; - - _game->_guard._position.x -= _vm->_player->_walkOffLeft[curCel - 43]; - guardSee(); - if (_game->_guard._position.x <= 56) { - _game->_guard._position.x = 56; - _game->_guardLocation = 3; - } - break; - case 3: - // Guard walking up - if (curCel <= 0 || curCel > 5) - _game->_guard._guardCel = curCel = 0; - - _game->_guard._position.y -= _vm->_player->_walkOffUp[curCel]; - guardSee(); - if (_game->_guard._position.y <= 89) { - _game->_guard._position.y = 89; - _game->_guardLocation = 4; - if (_game->_flags[121] == 1) - _game->_guardLocation = 5; - } - break; - default: - // Guard walking right - if (curCel <= 43 || curCel > 48) - _game->_guard._guardCel = curCel = 43; - - _game->_guard._position.x += _vm->_player->_walkOffRight[curCel - 43]; - guardSee(); - if (_game->_guard._position.x >= 127) { - _game->_guard._position.x = 127; - _game->_guardLocation = 1; - } - break; - } - - setGuardFrame(); -} - void AmazonScripts::loadBackground(int param1, int param2) { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(param1, param2); @@ -2099,7 +1848,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { mWhile(param1); break; case 9: - guard(); + _game->_guard.guard(); break; case 10: _vm->_sound->newMusic(param1, param2); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 1da10d8bdd..20dfb6345d 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -80,13 +80,6 @@ protected: void scrollRiver(); void mWhileDownRiver(); void mWhile(int param1); - void setVerticalCode(Common::Rect bounds); - void setHorizontalCode(Common::Rect bounds); - void chkVLine(); - void chkHLine(); - void guardSee(); - void setGuardFrame(); - void guard(); void plotTorchSpear(int indx, const int *&buf); void plotPit(int indx, const int *&buf); int antHandleRight(int indx, const int *&buf); -- cgit v1.2.3 From 84d500a35a2fc674adbbbc59311702f195cb4984 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 20:33:40 -0500 Subject: ACCESS: Fix flickering slaver guard --- engines/access/amazon/amazon_game.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 550d8b2b46..1a89ddb80d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -1158,8 +1158,10 @@ void Guard::setGuardFrame() { } void Guard::guard() { - if (_vm->_timers[8]._flag != 0) + if (_vm->_timers[8]._flag) { + setGuardFrame(); return; + } ++_vm->_timers[8]._flag; ++_guardCel; -- cgit v1.2.3 From 0cafe2719d56e1acd1b3972737a9f8e031d51136 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 25 Nov 2014 21:02:51 -0500 Subject: ACCESS: Fix for proper vertical scrolling on the ship --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f32bc95ae0..57a5c4a88e 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -343,14 +343,14 @@ void Room::buildRow(int playY, int screenY) { return; assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); - const byte *pSrc = _playField + screenY *_playFieldWidth + _vm->_screen->_scrollCol; + const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); for (int x = 0; x < w; ++x) { byte *pTile = _tile + (*pSrc << 8); - byte *pDest = (byte *)_vm->_buffer1.getBasePtr(w * TILE_WIDTH, screenY); + byte *pDest = (byte *)_vm->_buffer1.getBasePtr(x * TILE_WIDTH, screenY); for (int tileY = 0; tileY < TILE_HEIGHT; ++tileY) { Common::copy(pTile, pTile + TILE_WIDTH, pDest); -- cgit v1.2.3 From 953321cc26f431f82314866b15fe312094e32ecb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Nov 2014 00:11:57 +0100 Subject: ACCESS: Fix a glitch in the intro, add a workaround for a crash, fix a logic flaw --- engines/access/amazon/amazon_game.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 1a89ddb80d..05ac80e350 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -161,8 +161,8 @@ void AmazonEngine::doCredit() { _buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55)); _buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98)); } else if (_pCount <= 520) { - _buffer2.plotImage(_objectsTable[0], 7, Common::Point(90, 35)); - _buffer2.plotImage(_objectsTable[0], 8, Common::Point(90, 35)); + _buffer2.plotImage(_objectsTable[0], 7, Common::Point(32, 13)); + _buffer2.plotImage(_objectsTable[0], 8, Common::Point(162, 80)); } else if (_pCount <= 580) { _buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15)); _buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81)); @@ -258,6 +258,7 @@ void AmazonEngine::doTitle() { _events->pollEvents(); g_system->delayMillis(10); } + if (_events->_rightButton) { _skipStart = true; _room->clearRoom(); @@ -343,19 +344,19 @@ void AmazonEngine::doTitle() { ++_screen->_scrollRow; _buffer1.moveBufferUp(); - _room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall * _screen->_bufferBytesWide); + // WORKAROUND: the original was using _screen->_vWindowBytesWide * _screen->_vWindowLinesTall + _room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall); if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { _room->clearRoom(); _events->showCursor(); return; } - - scrollTitle(); - while (!shouldQuit() && (_events->_vbCount > 0)) { - _events->pollEvents(); - g_system->delayMillis(10); - } + } + scrollTitle(); + while (!shouldQuit() && (_events->_vbCount > 0)) { + _events->pollEvents(); + g_system->delayMillis(10); } } } -- cgit v1.2.3 From fde1ea9d0e5edc6b3761b893891c5c7431488a91 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Nov 2014 18:33:03 -0500 Subject: ACCESS: Improve usage of ImageEntry _flags IMGFLAG enum --- engines/access/access.cpp | 10 ++++++---- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/amazon/amazon_scripts.cpp | 14 +++++++------- engines/access/asurface.h | 3 ++- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 88c62a74a7..2c973160b0 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -360,12 +360,12 @@ void AccessEngine::plotList1() { Common::Rect destBounds = bounds; if (_buffer2.clip(bounds)) { - ie._flags |= 1; + ie._flags |= IMGFLAG_CROPPED; } else { - ie._flags &= ~1; + ie._flags &= ~IMGFLAG_CROPPED; if (_buffer2._leftSkip != 0 || _buffer2._rightSkip != 0 || _buffer2._topSkip != 0 || _buffer2._bottomSkip != 0) - ie._flags |= 1; + ie._flags |= IMGFLAG_CROPPED; _newRects.push_back(bounds); @@ -373,7 +373,7 @@ void AccessEngine::plotList1() { _buffer2._rightSkip /= _scale; bounds.setWidth(bounds.width() / _scale); - if (ie._flags & 2) { + if (ie._flags & IMGFLAG_BACKWARDS) { _buffer2.sPlotB(frame, destBounds); } else { _buffer2.sPlotF(frame, destBounds); @@ -386,6 +386,8 @@ void AccessEngine::plotList1() { } } } + + ie._flags |= IMGFLAG_DRAWN; } } diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 05ac80e350..c575d8498c 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -1147,10 +1147,10 @@ void Guard::guardSee() { void Guard::setGuardFrame() { ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; if (_vm->_guardLocation == 4) - ie._flags |= 2; + ie._flags |= IMGFLAG_BACKWARDS; ie._spritesPtr = _vm->_objectsTable[37]; ie._frameNumber = _guardCel; ie._position = _position; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f3f120bf72..7ec0f95e08 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -301,7 +301,7 @@ void AmazonScripts::jungleMove() { for (int i = 0; i < count; ++i) { ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[24]; ie._frameNumber = _jCnt[i] + frameOffset; ie._position = Common::Point(_jungleX[i], jungleY[i]); @@ -437,7 +437,7 @@ void AmazonScripts::pan() { for (int i = 0; i < _pNumObj; i++) { ImageEntry ie; - ie._flags= 8; + ie._flags = IMGFLAG_UNSCALED; ie._position = Common::Point(_pObjX[i], _pObjY[i]); ie._offsetY = 255; ie._spritesPtr = _pObject[i]; @@ -1046,7 +1046,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) { int idx = indx; ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[62]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]); @@ -1057,7 +1057,7 @@ void AmazonScripts::plotTorchSpear(int indx, const int *&buf) { void AmazonScripts::plotPit(int indx, const int *&buf) { int idx = indx; ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[62]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y); @@ -1233,7 +1233,7 @@ void AmazonScripts::ANT() { } ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[61]; ie._frameNumber = buf[(idx / 2)]; ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y); @@ -1730,7 +1730,7 @@ void AmazonScripts::plotRiver() { } ImageEntry ie; - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; ie._frameNumber = _game->_canoeFrame; ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; @@ -1741,7 +1741,7 @@ void AmazonScripts::plotRiver() { RiverStruct *cur = _game->_topList; while (cur <= _game->_botList) { if (cur[0]._id != -1) { - ie._flags = 8; + ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; ie._frameNumber = 0; ie._position.x = cur[0]._field5; diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 1c30db8915..273578c830 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -131,7 +131,8 @@ public: SpriteFrame *getFrame(int idx) { return _frames[idx]; } }; -enum ImageFlag { IMGFLAG_BACKWARDS = 2, IMGFLAG_UNSCALED = 8 }; +enum ImageFlag { IMGFLAG_CROPPED = 1, IMGFLAG_BACKWARDS = 2, IMGFLAG_DRAWN = 4, + IMGFLAG_UNSCALED = 8 }; class ImageEntry { public: -- cgit v1.2.3 From d8c97d259bc19f22ecf8b1cc9da03c374a3adbec Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Nov 2014 00:52:14 +0100 Subject: ACCESS: add code to replace the checks on KEYBUFCNT --- engines/access/amazon/amazon_game.cpp | 15 ++++----------- engines/access/amazon/amazon_scripts.cpp | 3 ++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index c575d8498c..6da895a1ce 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -253,8 +253,7 @@ void AmazonEngine::doTitle() { _screen->forceFadeIn(); _sound->newMusic(1, 0); _events->_vbCount = 700; - warning("TODO: check on KEYBUFCNT"); - while (!shouldQuit() && (_events->_vbCount > 0) && (!_events->_leftButton) && (!_events->_rightButton)) { + while (!shouldQuit() && (_events->_vbCount > 0) && !_events->isKeyMousePressed()) { _events->pollEvents(); g_system->delayMillis(10); } @@ -287,15 +286,9 @@ void AmazonEngine::doTitle() { _pCount = 0; while (!shouldQuit()) { - if (_events->_rightButton) { - _skipStart = true; - _room->clearRoom(); - _events->showCursor(); - return; - } - - warning("TODO: check on KEYBUFCNT"); - if (_events->_leftButton) { + if (!_events->isKeyMousePressed()) { + if (_events->_rightButton) + _skipStart = true; _room->clearRoom(); _events->showCursor(); return; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7ec0f95e08..30cd6c866c 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1004,7 +1004,8 @@ void AmazonScripts::doCast(int param1) { _vm->copyBlocks(); _vm->_events->pollEvents(); - warning("TODO: check on KEYBUFCNT"); + if (_vm->_events->isKeyMousePressed()) + break; if (_yCam < -7550) { _vm->_events->_vbCount = 50; -- cgit v1.2.3 From 89b20c618f16f1d3ad8e33819dd9202d234aa258 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Nov 2014 20:39:36 -0500 Subject: ACCESS: Fix to correctly draw partly off-screen sprites --- engines/access/asurface.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 96cb1991be..e954e9efa6 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -224,7 +224,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { int scaleY = SCALE_LIMIT * bounds.height() / this->h; int scaleXCtr = 0, scaleYCtr = 0; - for (int yCtr = 0, y = bounds.top; yCtr < this->h; ++yCtr) { + for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr, ++destY) { // Handle skipping lines if Y scaling scaleYCtr += scaleY; if (scaleYCtr < SCALE_LIMIT) @@ -232,14 +232,14 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleYCtr -= SCALE_LIMIT; // Handle off-screen lines - if (y < 0) + if (destY < 0) continue; - else if (y >= dest->h) + else if (destY >= dest->h) break; // Handle drawing the line byte *pSrc = (byte *)getBasePtr(0, yCtr); - byte *pDest = (byte *)dest->getBasePtr(bounds.left, y); + byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY); scaleXCtr = 0; int x = bounds.left; @@ -259,8 +259,6 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { ++pDest; ++x; } - - ++y; } } -- cgit v1.2.3 From 7434c764c6899e114d07e756356a55595adb8694 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 26 Nov 2014 22:16:14 -0500 Subject: ACCESS: gcc compilation fixes --- engines/access/access.cpp | 1 - engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_resources.cpp | 6 +++--- engines/access/amazon/amazon_scripts.cpp | 6 +++--- engines/access/files.cpp | 6 +++--- engines/access/files.h | 2 +- engines/access/player.h | 2 +- engines/access/scripts.cpp | 2 -- 10 files changed, 14 insertions(+), 17 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2c973160b0..4d326acff6 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -220,7 +220,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { soundsLeft = _countTbl[curPage]; _events->zeroKeys(); - Common::String line; int width = 0; bool lastLine = _fonts._font2.getLine(lines, s->_maxChars * 6, line, width); diff --git a/engines/access/access.h b/engines/access/access.h index 2cd35fbf1d..c0bc467f08 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -117,7 +117,7 @@ protected: * Support method that generates a savegame name * @param slot Slot number */ - Common::String AccessEngine::generateSaveName(int slot); + Common::String generateSaveName(int slot); /** * Play back an entire video diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 6da895a1ce..9b9df8bc25 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -672,7 +672,7 @@ void AmazonEngine::helpTitle() { Common::String iqText = "IQ: "; calcIQ(); - Common::String IQSCORE = Common::String::format("d", _iqValue); + Common::String IQSCORE = Common::String::format("%d", _iqValue); while (IQSCORE.size() != 4) IQSCORE = " " + IQSCORE; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 7917586ba2..2d371ca9fb 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -165,7 +165,7 @@ public: bool _deathFlag; int _deathCount; int _deathType; - byte *_mapPtr; + const byte *_mapPtr; int _canoeVXPos; int _canoeMoveCount; int _canoeFrame; diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 08ecfff467..68e078ef08 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1653,7 +1653,7 @@ RiverStruct RIVER0OBJECTS[45] = { {17, 30, 305, 0, 2, 15} }; -RiverStruct ENDRIVER0[1] = {16, 31, 260, 0, 7, 12}; +RiverStruct ENDRIVER0[1] = { { 16, 31, 260, 0, 7, 12 } }; RiverStruct RIVER1OBJECTS[49] = { {16, 31, 6920, 0, 1, 12}, @@ -1707,7 +1707,7 @@ RiverStruct RIVER1OBJECTS[49] = { {17, 30, 305, 0, 3, 15} }; -RiverStruct ENDRIVER1[1] = {16, 31, 260, 0, 1, 12}; +RiverStruct ENDRIVER1[1] = { { 16, 31, 260, 0, 1, 12 } }; RiverStruct RIVER2OBJECTS[53] = { {16, 31, 8230, 0, 6, 12}, @@ -1765,7 +1765,7 @@ RiverStruct RIVER2OBJECTS[53] = { {17, 30, 305, 0, 3, 15} }; -RiverStruct ENDRIVER2[1] = {16, 31, 260, 0, 6, 12}; +RiverStruct ENDRIVER2[1] = { { 16, 31, 260, 0, 6, 12 } }; RiverStruct *RIVEROBJECTTBL[6] = { RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 30cd6c866c..7b4729b3e0 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1282,7 +1282,7 @@ void AmazonScripts::ANT() { void AmazonScripts::boatWalls(int param1, int param2) { if (param1 == 1) - _vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 87, 42); + _vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 96 + 87, 27 + 42); else { _vm->_room->_plotter._walls[39].bottom = _vm->_room->_plotter._walls[41].bottom = 106; _vm->_room->_plotter._walls[40].left = 94; @@ -1439,7 +1439,7 @@ void AmazonScripts::initRiver() { ++_game->_timers[3]._flag; _game->_canoeFrame = 0; - _game->_mapPtr = (byte *)MAPTBL[_game->_riverFlag] + 1; + _game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1; if (_game->_saveRiver == 1) { _game->_mapPtr--; _game->_mapPtr += _game->_mapOffset; @@ -1771,7 +1771,7 @@ void AmazonScripts::RIVER() { while (true) { _vm->_events->_vbCount = 4; - int bx = _vm->_player->_scrollAmount - _screenVertX; +// int bx = _vm->_player->_scrollAmount - _screenVertX; if (_vm->_screen->_scrollX == 0) { _vm->_sound->midiRepeat(); if (riverJumpTest()) { diff --git a/engines/access/files.cpp b/engines/access/files.cpp index dacceb7a09..df114229da 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -59,10 +59,10 @@ Resource::~Resource() { delete _stream; } -Resource::Resource(byte *data, int size) { - _data = data; +Resource::Resource(byte *p, int size) { + _data = p; _size = size; - _stream = new Common::MemoryReadStream(data, size); + _stream = new Common::MemoryReadStream(p, size); } byte *Resource::data() { diff --git a/engines/access/files.h b/engines/access/files.h index f65f2ba8da..f90071df85 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -62,7 +62,7 @@ public: int _size; Resource(); - Resource::Resource(byte *data, int size); + Resource(byte *data, int size); ~Resource(); byte *data(); }; diff --git a/engines/access/player.h b/engines/access/player.h index 400770c21a..67908a315d 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -111,7 +111,7 @@ public: Common::Point _rawPlayer; public: Player(AccessEngine *vm); - ~Player(); + virtual ~Player(); static Player *init(AccessEngine *vm); virtual void load(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d4bd5ad644..9aba05a2fb 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -610,13 +610,11 @@ void Scripts::cmdTexChoice() { findNull(); - bool choice2Fl = false; tmpStr = ""; while ((v = _data->readByte()) != 0) tmpStr += (char)v; if (tmpStr.size() != 0) { - choice2Fl = true; _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str(); _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); -- cgit v1.2.3 From f75fa68c057dc5e626428415b38f7159d2d23c06 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Nov 2014 14:58:41 +0100 Subject: ACCESS: Add a replacement of configSelect, currently just initializing _hintLevel --- engines/access/amazon/amazon_game.cpp | 6 ++++++ engines/access/amazon/amazon_game.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 9b9df8bc25..912c4ddfd2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -87,6 +87,11 @@ void AmazonEngine::freeInactivePlayer() { _inactive._altSpritesPtr = nullptr; } +void AmazonEngine::configSelect() { + // Initialize fields contained in the config file. + _hintLevel = 3; +} + void AmazonEngine::playGame() { // Initialize Amazon game-specific objects _room = new AmazonRoom(this); @@ -95,6 +100,7 @@ void AmazonEngine::playGame() { // Setup the game setupGame(); + configSelect(); if (_loadSaveSlot == -1) { // Do introduction diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 2d371ca9fb..d67f0c2150 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -98,6 +98,11 @@ private: */ void setupGame(); + /** + * Initialize variables found in the config file + */ + void configSelect(); + void initVariables(); void calcIQ(); void helpTitle(); -- cgit v1.2.3 From 4c71b12e021d69550a7574579327002afda9d0e7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 10:13:38 -0500 Subject: ACCESS: Fix memory leaks --- engines/access/debugger.cpp | 4 ++++ engines/access/debugger.h | 2 +- engines/access/files.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 359b2e73a5..6b49fb0e67 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -78,6 +78,10 @@ Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { } } +Debugger::~Debugger() { + delete[] _sceneDescr; +} + bool Debugger::Cmd_LoadScene(int argc, const char **argv) { switch (argc) { case 1: diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 60bd22358a..839d13106e 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -43,7 +43,7 @@ public: static Debugger *init(AccessEngine *vm); public: Debugger(AccessEngine *vm); - virtual ~Debugger() {} + virtual ~Debugger(); }; namespace Amazon { diff --git a/engines/access/files.cpp b/engines/access/files.cpp index df114229da..cbcfa3f614 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -55,7 +55,7 @@ Resource::Resource() { } Resource::~Resource() { - delete _data; + delete[] _data; delete _stream; } -- cgit v1.2.3 From abb4b9d1e6cd1373a3d71c2fe97f3ca4d6df2454 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 27 Nov 2014 18:16:21 +0100 Subject: ACCESS: Fix regression in bd004bd6f3b960e36756248d8e44bfdf955fdb52 --- engines/access/asurface.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index e954e9efa6..c9c335e894 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -224,7 +224,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { int scaleY = SCALE_LIMIT * bounds.height() / this->h; int scaleXCtr = 0, scaleYCtr = 0; - for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr, ++destY) { + for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) { // Handle skipping lines if Y scaling scaleYCtr += scaleY; if (scaleYCtr < SCALE_LIMIT) @@ -250,7 +250,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { continue; scaleXCtr -= SCALE_LIMIT; - // Only handle on-scren pixels + // Only handle on-screen pixels if (x >= dest->w) break; if (x >= 0 && *pSrc != 0) @@ -259,6 +259,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { ++pDest; ++x; } + ++destY; } } -- cgit v1.2.3 From f0f19dbea07be8593cdc50bcef671bf69a8bd731 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 16:32:25 -0500 Subject: ACCESS: Fix for vertical scrolling after using inventory screen --- engines/access/asurface.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index c9c335e894..624721920a 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -331,17 +331,17 @@ void ASurface::moveBufferLeft() { void ASurface::moveBufferRight() { byte *p = (byte *)getPixels(); - Common::copy_backward(p, p + (w * h) - TILE_WIDTH, p + (w * h)); + Common::copy_backward(p, p + (pitch * h) - TILE_WIDTH, p + (pitch * h)); } void ASurface::moveBufferUp() { byte *p = (byte *)getPixels(); - Common::copy(p + (w * TILE_HEIGHT), p + (w * h), p); + Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p); } void ASurface::moveBufferDown() { byte *p = (byte *)getPixels(); - Common::copy_backward(p, p + (w * (h - TILE_HEIGHT)), p + (w * h)); + Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h)); } } // End of namespace Access -- cgit v1.2.3 From bb93268ee21a216162ef077c64462e0ac360df0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 16:56:03 -0500 Subject: ACCESS: Fix left button flag beig stuck after saving & loading games --- engines/access/access.cpp | 1 + engines/access/events.cpp | 5 +++++ engines/access/events.h | 2 ++ engines/access/room.cpp | 1 + 4 files changed, 9 insertions(+) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 4d326acff6..82c405c48e 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -491,6 +491,7 @@ Common::Error AccessEngine::loadGameState(int slot) { // Set extra post-load state _room->_function = 1; _timers._timersSavedFlag = false; + _events->clearEvents(); return Common::kNoError; } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index d911e666ea..327fb06dd1 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -236,6 +236,11 @@ void EventsManager::debounceLeft() { } } +void EventsManager::clearEvents() { + _leftButton = _rightButton = false; + _keypresses.clear(); +} + void EventsManager::waitKeyMouse() { while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { pollEvents(); diff --git a/engines/access/events.h b/engines/access/events.h index 0a2a541de9..c72f245412 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -117,6 +117,8 @@ public: void debounceLeft(); + void clearEvents(); + void waitKeyMouse(); bool checkForNextFrameCounter(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 57a5c4a88e..9251db4af4 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -494,6 +494,7 @@ void Room::handleCommand(int commandId) { --commandId; if (commandId == 9) { + _vm->_events->debounceLeft(); _vm->_canSaveLoad = true; _vm->openMainMenuDialog(); _vm->_canSaveLoad = false; -- cgit v1.2.3 From f6a1faa5e4ea7b35b3dd9d1bd942858dd31cdbde Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 17:17:35 -0500 Subject: ACCESS: Fix check for scene area that can be clicked in --- engines/access/amazon/amazon_room.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index a942ed3ba8..4df1131643 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -162,10 +162,12 @@ void AmazonRoom::roomMenu() { void AmazonRoom::mainAreaClick() { Common::Point &mousePos = _vm->_events->_mousePos; Common::Point pt = _vm->_events->calcRawMouse(); + Screen &screen = *_vm->_screen; + Player &player = *_vm->_player; if (_selectCommand == -1) { - if (_vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44 || - _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 29) { + if (player._roomNumber == 42 || player._roomNumber == 44 || + player._roomNumber == 31 || player._roomNumber == 29) { switch (checkBoxes1(pt)) { case 0: // Make Jason the active player @@ -182,15 +184,15 @@ void AmazonRoom::mainAreaClick() { // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due // to not being able to click a Y position that's high enough - if (_vm->_screen->_scrollRow == 0 && pt.y > 178) + if (screen._scrollRow == 0 && pt.y > 178) pt.y = 200; - _vm->_player->_moveTo = pt; - _vm->_player->_playerMove = true; - } else if (mousePos.x >= _vm->_screen->_windowXAdd && - mousePos.x <= _vm->_screen->_vWindowBytesWide && - mousePos.y >= _vm->_screen->_windowYAdd && - mousePos.y <= _vm->_screen->_vWindowLinesTall) { + player._moveTo = pt; + player._playerMove = true; + } else if (mousePos.x >= screen._windowXAdd && + mousePos.x <= (screen._windowXAdd + screen._vWindowBytesWide) && + mousePos.y >= screen._windowYAdd && + mousePos.y <= (screen._windowYAdd + screen._vWindowLinesTall)) { if (checkBoxes1(pt) >= 0) { checkBoxes3(); } -- cgit v1.2.3 From 64b45e68aa10954edafe34139386b4cd7042ad74 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 17:33:42 -0500 Subject: ACCESS: Fix loading or exiting game when Maya is active player --- engines/access/player.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index b5046632c5..b945b76600 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -76,7 +76,7 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { } Player::~Player() { - delete _playerSprites1; + delete _playerSprites; delete[] _manPal1; } @@ -132,7 +132,7 @@ void Player::loadSprites(const Common::String &name) { } void Player::freeSprites() { - delete _playerSprites1; + delete _playerSprites; _playerSprites1 = nullptr; _playerSprites = nullptr; } -- cgit v1.2.3 From 3be3cb1ac21dcaf8f79907e9ce463c4828cba65c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 21:35:20 -0500 Subject: ACCESS: Cleanup of room _function and river canoe movement --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_game.cpp | 10 ++- engines/access/amazon/amazon_resources.cpp | 4 +- engines/access/amazon/amazon_resources.h | 4 +- engines/access/amazon/amazon_scripts.cpp | 140 ++++++++++++----------------- engines/access/amazon/amazon_scripts.h | 3 +- engines/access/room.cpp | 8 +- engines/access/room.h | 12 +-- engines/access/scripts.cpp | 2 +- 9 files changed, 80 insertions(+), 105 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 82c405c48e..885b2f998c 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -489,7 +489,7 @@ Common::Error AccessEngine::loadGameState(int slot) { delete saveFile; // Set extra post-load state - _room->_function = 1; + _room->_function = FN_CLEAR1; _timers._timersSavedFlag = false; _events->clearEvents(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 912c4ddfd2..cdc7727244 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -909,7 +909,7 @@ void AmazonEngine::startChapter(int chapter) { } } else if (chapter != 1) { _player->_roomNumber = CHAPTER_JUMP[_chapter - 1]; - _room->_function = 1; + _room->_function = FN_CLEAR1; _converseMode = 0; _scripts->cmdRetPos(); @@ -936,8 +936,12 @@ void AmazonEngine::synchronize(Common::Serializer &s) { for (int i = 0; i < 100; ++i) s.syncAsSint16LE(_esTabTable[i]); - warning("TODO: s.syncAsSint16LE(_topList);"); - warning("TODO: s.syncAsSint16LE(_botList);"); + if (_player->_roomNumber == 45) { + + + warning("TODO: s.syncAsSint16LE(_topList);"); + warning("TODO: s.syncAsSint16LE(_botList);"); + } } /*------------------------------------------------------------------------*/ diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 68e078ef08..6148eeb8f1 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1223,8 +1223,8 @@ const char *const NO_HELP_MESSAGE = HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \ YOU CAN UNDERSTAND."; const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; -const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; -const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; +const char *const RIVER_HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; +const char *const RIVER_HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT"; const char *const HELPLVLTXT[3] = { " LEVEL 1 ", diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 37b12d26cf..cd1fc95f82 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -75,8 +75,8 @@ extern const byte FONT6x6_DATA[]; extern const char *const NO_HELP_MESSAGE; extern const char *const NO_HINTS_MESSAGE; -extern const char *const HIT1; -extern const char *const HIT2; +extern const char *const RIVER_HIT1; +extern const char *const RIVER_HIT2; extern const char *const BAR_MESSAGE; extern const char *const HELPLVLTXT[3]; extern const char *const IQLABELS[9]; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7b4729b3e0..537dd3094d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -40,6 +40,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _xCam = 0; _yCam = 0; _zCam = 0; + _CHICKENOUTFLG = false; _pNumObj = 0; for (int i = 0; i < 32; i++) { @@ -1557,97 +1558,66 @@ void AmazonScripts::riverSound() { } void AmazonScripts::moveCanoe() { - if (_game->_canoeDir != 0) { - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } - return; - } + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Common::Point pt = events.calcRawMouse(); _vm->_events->pollEvents(); - if (_vm->_events->_leftButton) { - Common::Point pt = _vm->_events->calcRawMouse(); - if (pt.y < 180) { - if (_vm->_events->_mousePos.x < RMOUSE[8][0]) { + + if (_game->_canoeDir) { + // Canoe movement in progress + moveCanoe2(); + } else { + if (events._leftButton && pt.y < 180) { + if (RMOUSE[8][0] < pt.x) { printString(BAR_MESSAGE); - return; - } - _game->_saveRiver = 1; - _vm->_rScrollRow = _vm->_screen->_scrollRow; - _vm->_rScrollCol = _vm->_screen->_scrollCol; - _vm->_rScrollX = _vm->_screen->_scrollX; - _vm->_rScrollY = _vm->_screen->_scrollY; - _vm->_rOldRectCount = _vm->_oldRects.size(); - _vm->_rNewRectCount = _vm->_newRects.size(); - // _vm->_rKeyFlag = KEYFLG; - _vm->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; - _vm->doLoadSave(); - if (_vm->_room->_function == 1) { - _endFlag = true; - _returnCode = 0; } else { - _game->_saveRiver = 0; - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); + _game->_saveRiver = 1; + _game->_rScrollRow = screen._scrollRow; + _game->_rScrollCol = screen._scrollCol; + _game->_rScrollX = screen._scrollX; + _game->_rScrollY = screen._scrollY; + _game->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; + + // Show the ScummVM menu + _vm->_room->handleCommand(9); + + if (_vm->_room->_function == FN_CLEAR1) { + _endFlag = true; + _returnCode = 0; + } else { + _game->_saveRiver = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + } } - return; - } - - if (pt.y <= _game->_canoeYPos) { - if (_game->_canoeLane == 0) - return; - - _game->_canoeDir = -1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; + } else if ((events._leftButton && pt.y <= _game->_canoeYPos) || + (!events._leftButton && _vm->_player->_move == UP)) { + // Move canoe up + if (_game->_canoeLane > 0) { + _game->_canoeDir = -1; + _game->_canoeMoveCount = 0; + + moveCanoe2(); } - } else { - if (_game->_canoeLane == 7) - return; + } else if (events._leftButton || _vm->_player->_move == DOWN) { + // Move canoe down + if (_game->_canoeLane < 7) { + _game->_canoeDir = 1; + _game->_canoeMoveCount = 0; - _game->_canoeDir = 1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; + moveCanoe2(); } } - return; - } - - if (_vm->_player->_move == UP) { - if (_game->_canoeLane == 0) - return; + } +} - _game->_canoeDir = -1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } - } else if (_vm->_player->_move == DOWN) { - if (_game->_canoeLane == 7) - return; +void AmazonScripts::moveCanoe2() { + _game->_canoeYPos += _game->_canoeDir; - _game->_canoeDir = 1; - _game->_canoeMoveCount = 0; + if (++_game->_canoeMoveCount == 5) { _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } + _game->_canoeDir = 0; } } @@ -1768,22 +1738,22 @@ void AmazonScripts::RIVER() { static const int RIVERDEATH[5] = {22, 23, 24, 25, 26}; initRiver(); - while (true) { + while (!_vm->shouldQuit()) { _vm->_events->_vbCount = 4; // int bx = _vm->_player->_scrollAmount - _screenVertX; if (_vm->_screen->_scrollX == 0) { _vm->_sound->midiRepeat(); if (riverJumpTest()) { - CHICKENOUTFLG = false; + _CHICKENOUTFLG = false; return; } } else { _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; } - if (CHICKENOUTFLG) { - CHICKENOUTFLG = false; + if (_CHICKENOUTFLG) { + _CHICKENOUTFLG = false; return; } @@ -1794,8 +1764,8 @@ void AmazonScripts::RIVER() { pan(); moveCanoe(); - if (_vm->_room->_function == 1) { - CHICKENOUTFLG = false; + if (_vm->_room->_function == FN_CLEAR1) { + _CHICKENOUTFLG = false; return; } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 20dfb6345d..5fd1bb848a 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -43,7 +43,7 @@ private: int _zCam; int _pNumObj; int _screenVertX; - bool CHICKENOUTFLG; + bool _CHICKENOUTFLG; int _pImgNum[32]; SpriteResource *_pObject[32]; @@ -94,6 +94,7 @@ protected: bool riverJumpTest(); void riverSound(); void moveCanoe(); + void moveCanoe2(); void updateObstacles(); void riverSetPhysX(); bool checkRiverCollide(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9251db4af4..bc76d48d8d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -29,7 +29,7 @@ namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { - _function = 0; + _function = FN_NONE; _roomFlag = 0; _playField = nullptr; _playFieldWidth = _playFieldHeight = 0; @@ -70,7 +70,7 @@ void Room::doRoom() { reloadFlag = false; _vm->_startup = 8; - _function = 0; + _function = FN_NONE; while (!_vm->shouldQuit()) { _vm->_images.clear(); @@ -111,7 +111,7 @@ void Room::doRoom() { if (_vm->_player->_scrollFlag) { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_function == FN_CLEAR1) { @@ -125,7 +125,7 @@ void Room::doRoom() { } else { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_vm->shouldQuit()) diff --git a/engines/access/room.h b/engines/access/room.h index a26f2ed04c..a3ee019d39 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -91,11 +91,6 @@ protected: */ void freeTileData(); - /** - * Switch to a given command mode - */ - void handleCommand(int commandId); - int checkBoxes(); int checkBoxes1(const Common::Point &pt); int checkBoxes2(const Common::Point &pt, int start, int count); @@ -120,7 +115,7 @@ protected: public: Plotter _plotter; Common::Array _jetFrame; - int _function; + Function _function; int _roomFlag; byte *_playField; int _matrixSize; @@ -166,6 +161,11 @@ public: void setWallCodes(); bool codeWalls(); + + /** + * Switch to a given command mode + */ + void handleCommand(int commandId); }; class RoomInfo { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 9aba05a2fb..72650f472c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -531,7 +531,7 @@ void Scripts::cmdSpecial() { if (_specialFunction == 1) { _vm->_screen->restorePalette(); - _vm->_room->_function = 3; + _vm->_room->_function = FN_RELOAD; } } -- cgit v1.2.3 From c6042e2e2593f92ff0dc936fe34e6b933c284589 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 22:27:09 -0500 Subject: ACCESS: Minor cleanups of canoe code --- engines/access/amazon/amazon_scripts.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 537dd3094d..aa904716c2 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1562,16 +1562,18 @@ void AmazonScripts::moveCanoe() { EventsManager &events = *_vm->_events; Common::Point pt = events.calcRawMouse(); - _vm->_events->pollEvents(); + events.pollEvents(); if (_game->_canoeDir) { // Canoe movement in progress moveCanoe2(); } else { - if (events._leftButton && pt.y < 180) { - if (RMOUSE[8][0] < pt.x) { + if (events._leftButton && pt.y >= 140) { + if (pt.x < RMOUSE[8][0]) { + // Disk icon wasn't clicked printString(BAR_MESSAGE); } else { + // Clicked on the Disc icon _game->_saveRiver = 1; _game->_rScrollRow = screen._scrollRow; _game->_rScrollCol = screen._scrollCol; @@ -1738,6 +1740,8 @@ void AmazonScripts::RIVER() { static const int RIVERDEATH[5] = {22, 23, 24, 25, 26}; initRiver(); + _vm->_events->showCursor(); + while (!_vm->shouldQuit()) { _vm->_events->_vbCount = 4; @@ -1787,14 +1791,11 @@ void AmazonScripts::RIVER() { return; } } - - if (_vm->_events->_mousePos.y >= 24 && _vm->_events->_mousePos.y <= 136) { - _vm->_events->hideCursor(); - scrollRiver1(); - _vm->_events->pollEvents(); - } else - scrollRiver1(); + // Scroll the river + scrollRiver1(); + + // Allow time for new scrolled river position to be shown while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { _vm->_events->pollEventsAndWait(); } -- cgit v1.2.3 From b1ea7879f3f6726e4b63aac5f985876fcd1ea9b2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 22:52:13 -0500 Subject: ACCESS: Fix saving/loading using ScummVM GMM in the river scene --- engines/access/amazon/amazon_scripts.cpp | 67 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index aa904716c2..ea7df7bcbd 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1562,7 +1562,12 @@ void AmazonScripts::moveCanoe() { EventsManager &events = *_vm->_events; Common::Point pt = events.calcRawMouse(); + // Do an event polling + _vm->_canSaveLoad = true; events.pollEvents(); + _vm->_canSaveLoad = false; + if (_vm->_room->_function == FN_CLEAR1) + return; if (_game->_canoeDir) { // Canoe movement in progress @@ -1584,10 +1589,7 @@ void AmazonScripts::moveCanoe() { // Show the ScummVM menu _vm->_room->handleCommand(9); - if (_vm->_room->_function == FN_CLEAR1) { - _endFlag = true; - _returnCode = 0; - } else { + if (_vm->_room->_function != FN_CLEAR1) { _game->_saveRiver = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -1768,36 +1770,43 @@ void AmazonScripts::RIVER() { pan(); moveCanoe(); - if (_vm->_room->_function == FN_CLEAR1) { - _CHICKENOUTFLG = false; - return; - } - - updateObstacles(); - riverSetPhysX(); - bool checkCollide = checkRiverCollide(); - if (_game->_hitSafe != 0) - _game->_hitSafe -= 2; - - if (checkCollide) { - cmdDead(RIVERDEATH[0]); - return; - } + if (_vm->_room->_function != FN_CLEAR1) { + updateObstacles(); + riverSetPhysX(); + bool checkCollide = checkRiverCollide(); + if (_game->_hitSafe != 0) + _game->_hitSafe -= 2; - if (_game->_deathFlag) { - _game->_deathCount--; - if (_game->_deathCount == 0) { - cmdDead(RIVERDEATH[_game->_deathType]); + if (checkCollide) { + cmdDead(RIVERDEATH[0]); return; } - } - // Scroll the river - scrollRiver1(); + if (_game->_deathFlag) { + _game->_deathCount--; + if (_game->_deathCount == 0) { + cmdDead(RIVERDEATH[_game->_deathType]); + return; + } + } + + // Scroll the river + scrollRiver1(); - // Allow time for new scrolled river position to be shown - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); + // Allow time for new scrolled river position to be shown + _vm->_canSaveLoad = true; + while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE && + _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); + } + _vm->_canSaveLoad = false; + } + + if (_vm->_room->_function == FN_CLEAR1) { + _endFlag = true; + _returnCode = 0; + _CHICKENOUTFLG = false; + break; } } } -- cgit v1.2.3 From 3f445384415d18bc4e437c33df67be88dfdb4a0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 23:21:19 -0500 Subject: ACCESS: Fix array sizes for panning objects fields --- engines/access/amazon/amazon_scripts.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 5fd1bb848a..bd47e9ce5b 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -44,15 +44,14 @@ private: int _pNumObj; int _screenVertX; bool _CHICKENOUTFLG; - int _pImgNum[32]; SpriteResource *_pObject[32]; - + int _pImgNum[32]; int _pObjX[32]; int _pObjY[32]; int _pObjZ[32]; - int _pObjXl[16]; - int _pObjYl[16]; + int _pObjXl[32]; + int _pObjYl[32]; int _jCnt[3]; int _jungleX[3]; -- cgit v1.2.3 From 27351011799b4c85e0fc7f80acbbbf10dbb78aa9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 28 Nov 2014 13:59:27 +0100 Subject: ACCESS: Finish the implementation of cmdHelp (still a redraw issue) --- engines/access/amazon/amazon_game.cpp | 4 +-- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_resources.cpp | 4 +++ engines/access/amazon/amazon_resources.h | 1 + engines/access/amazon/amazon_scripts.cpp | 47 ++++++++++++++++++++++++++++-- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index cdc7727244..f4cf83e150 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -726,7 +726,7 @@ void AmazonEngine::drawHelpText(const Common::String &msg) { _events->showCursor(); } -void AmazonEngine::drawHelp() { +void AmazonEngine::drawHelp(const Common::String str) { _events->hideCursor(); if (_useItem == 0) { _buffer2.copyBuffer(_screen); @@ -760,7 +760,7 @@ void AmazonEngine::drawHelp() { _screen->fadeIn(); helpTitle(); - drawHelpText("TODO: WHICH BUFFER?"); + drawHelpText(str); } void AmazonEngine::startChapter(int chapter) { diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index d67f0c2150..435e1722b2 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -197,7 +197,7 @@ public: */ void freeInactivePlayer(); - void drawHelp(); + void drawHelp(const Common::String str); virtual void establish(int esatabIndex, int sub); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 6148eeb8f1..05e234aefc 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1772,6 +1772,10 @@ RiverStruct *RIVEROBJECTTBL[6] = { ENDRIVER1, RIVER2OBJECTS, ENDRIVER2 }; +const int HELP1COORDS[2][4] = { + { 76, 129, 168, 183 }, { 187, 240, 168, 183 } +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index cd1fc95f82..6d94e6a359 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -126,6 +126,7 @@ extern RiverStruct RIVER2OBJECTS[53]; extern RiverStruct ENDRIVER2[1]; extern RiverStruct *RIVEROBJECTTBL[6]; +extern const int HELP1COORDS[2][4]; } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index ea7df7bcbd..cde1ff8324 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1887,8 +1887,51 @@ void AmazonScripts::cmdHelp() { if (level < _game->_helpLevel) _game->_moreHelp = 0; - _game->drawHelp(); - error("TODO: more cmdHelp"); + _game->drawHelp(helpMessage); + + while(true) { + while(!_vm->shouldQuit() && !_vm->_events->_leftButton) + _vm->_events->pollEventsAndWait(); + + _vm->_events->debounceLeft(); + + static const Common::Rect butn1 = Common::Rect(HELP1COORDS[0][0], HELP1COORDS[0][2], HELP1COORDS[0][1], HELP1COORDS[0][3]); + static const Common::Rect butn2 = Common::Rect(HELP1COORDS[1][0], HELP1COORDS[1][2], HELP1COORDS[1][1], HELP1COORDS[1][3]); + const Common::Point pt = _vm->_events->_mousePos; + + int choice = -1; + if (butn1.contains(pt)) + choice = 0; + else if (butn2.contains(pt)) + choice = 1; + + if (choice < 0) + continue; + + if (choice == 1) { + _game->_helpLevel = 0; + _game->_moreHelp = 1; + _game->_useItem = 0; + _vm->_events->hideCursor(); + _vm->_screen->restoreScreen(); + _vm->_screen->setPanel(0); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_screen->restorePalette(); + _vm->_screen->setPalette(); + _vm->_events->showCursor(); + free(_vm->_objectsTable[45]); + _vm->_objectsTable[45] = nullptr; + _vm->_timers.restoreTimers(); + break; + } else { + if ((_game->_moreHelp == 0) || (choice != 0)) + continue; + ++_game->_helpLevel; + _game->_useItem = 1; + break; + } + } + findNull(); } void AmazonScripts::cmdCycleBack() { -- cgit v1.2.3 From 62a7619017c676c229ba72b295a4ceae19d3f0c7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 10:19:26 -0500 Subject: ACCESS: Better fix for drawing partially off-screen sprites --- engines/access/asurface.cpp | 49 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 624721920a..4202ed098f 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -232,33 +232,34 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleYCtr -= SCALE_LIMIT; // Handle off-screen lines - if (destY < 0) - continue; - else if (destY >= dest->h) + if (destY >= dest->h) break; - // Handle drawing the line - byte *pSrc = (byte *)getBasePtr(0, yCtr); - byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY); - scaleXCtr = 0; - int x = bounds.left; - - for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) { - // Handle horizontal scaling - scaleXCtr += scaleX; - if (scaleXCtr < SCALE_LIMIT) - continue; - scaleXCtr -= SCALE_LIMIT; - - // Only handle on-screen pixels - if (x >= dest->w) - break; - if (x >= 0 && *pSrc != 0) - *pDest = *pSrc; - - ++pDest; - ++x; + if (destY >= 0) { + // Handle drawing the line + byte *pSrc = (byte *)getBasePtr(0, yCtr); + byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY); + scaleXCtr = 0; + int x = bounds.left; + + for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) { + // Handle horizontal scaling + scaleXCtr += scaleX; + if (scaleXCtr < SCALE_LIMIT) + continue; + scaleXCtr -= SCALE_LIMIT; + + // Only handle on-screen pixels + if (x >= dest->w) + break; + if (x >= 0 && *pSrc != 0) + *pDest = *pSrc; + + ++pDest; + ++x; + } } + ++destY; } } -- cgit v1.2.3 From bfbce8c6a6ac00423b47f3c3ce0f3b9a32e497ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 11:40:33 -0500 Subject: ACCESS: Cleanup of updateObstacles --- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_game.h | 2 +- engines/access/amazon/amazon_scripts.cpp | 65 +++++++++++++++----------------- engines/access/events.cpp | 2 +- 4 files changed, 33 insertions(+), 38 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index f4cf83e150..4237982b4d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -44,7 +44,7 @@ AccessEngine(syst, gameDesc), _canoeLane = 0; _canoeYPos = 0; _hitCount = 0; - _saveRiver = 0; + _saveRiver = false; _hitSafe = 0; _oldTitleChapter = _chapter = 0; _updateChapter = -1; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 435e1722b2..4c4b304514 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -150,7 +150,7 @@ public: int _canoeLane; int _canoeYPos; int _hitCount; - int _saveRiver; + bool _saveRiver; int _hitSafe; int _chapter; int _riverIndex; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index cde1ff8324..7cae5fd0ef 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1408,12 +1408,14 @@ void AmazonScripts::initRiver() { _vm->_destIn = &_vm->_buffer2; _vm->_room->roomMenu(); - if (_game->_saveRiver == 1) { + if (_game->_saveRiver) { + // Restoring a savegame, so set properties from saved fields _vm->_screen->_scrollRow = _vm->_rScrollRow; _vm->_screen->_scrollCol = _vm->_rScrollCol; _vm->_screen->_scrollX = _vm->_rScrollX; _vm->_screen->_scrollY = _vm->_rScrollY; } else { + // Set initial scene state _vm->_screen->_scrollRow = 0; _vm->_screen->_scrollCol = 140; _vm->_screen->_scrollX = 0; @@ -1423,11 +1425,14 @@ void AmazonScripts::initRiver() { _vm->_room->buildScreen(); _vm->copyBF2Vid(); _vm->_screen->forceFadeIn(); - if (_game->_saveRiver == 1) { + + if (_game->_saveRiver) { + // Restore draw rects from savegame _vm->_oldRects.resize(_vm->_rOldRectCount); _vm->_newRects.resize(_vm->_rNewRectCount); // KEYFLG = _vm->_rKeyFlag } else { + // Reset draw rects _vm->_oldRects.clear(); _vm->_newRects.clear(); // KEYFLG = 0 @@ -1441,7 +1446,7 @@ void AmazonScripts::initRiver() { _game->_canoeFrame = 0; _game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1; - if (_game->_saveRiver == 1) { + if (_game->_saveRiver) { _game->_mapPtr--; _game->_mapPtr += _game->_mapOffset; } else { @@ -1468,7 +1473,7 @@ void AmazonScripts::initRiver() { ++_game->_timers[12]._flag; _game->_maxHits = 2 - _game->_riverFlag; - _game->_saveRiver = 0; + _game->_saveRiver = false; } void AmazonScripts::resetPositions() { @@ -1579,7 +1584,7 @@ void AmazonScripts::moveCanoe() { printString(BAR_MESSAGE); } else { // Clicked on the Disc icon - _game->_saveRiver = 1; + _game->_saveRiver = true; _game->_rScrollRow = screen._scrollRow; _game->_rScrollCol = screen._scrollCol; _game->_rScrollX = screen._scrollX; @@ -1590,7 +1595,7 @@ void AmazonScripts::moveCanoe() { _vm->_room->handleCommand(9); if (_vm->_room->_function != FN_CLEAR1) { - _game->_saveRiver = 0; + _game->_saveRiver = false; _vm->_room->buildScreen(); _vm->copyBF2Vid(); } @@ -1626,42 +1631,32 @@ void AmazonScripts::moveCanoe2() { } void AmazonScripts::updateObstacles() { - RiverStruct *cur = _game->_topList; - while (true) { - int val = cur[0]._field1 + cur[0]._field3 - 1; - if (val < _screenVertX) { - cur = _game->_topList; - cur--; - _game->_botList = cur; - return; - } - - if (cur[0]._field3 < _screenVertX + 319) { - _game->_topList = _game->_botList = cur; + RiverStruct *cur; + for (cur = _game->_topList; cur < RIVEROBJECTTBL[_game->_riverIndex + 1]; ++cur) { + int val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX) break; - } - if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) { - cur = _game->_topList; - cur--; + if (cur->_field3 < (_game->_screenVirtX + 319)) { + _game->_topList = cur; _game->_botList = cur; - return; - } - } - while (true) { - if (cur > RIVEROBJECTTBL[_game->_riverIndex + 1]) - return; - ++cur; - int val = cur[0]._field1 + cur[0]._field3 - 1; - if (val < _screenVertX) - return; + while (cur < RIVEROBJECTTBL[_game->_riverIndex + 1]) { + ++cur; + val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX || (cur->_field3 >= (_game->_screenVirtX + 319))) + break; - if (cur[0]._field3 >= _screenVertX + 319) - return; + _game->_botList = cur; + } - _game->_botList = cur; + return; + } } + + cur = _game->_topList; + cur--; + _game->_botList = cur; } void AmazonScripts::riverSetPhysX() { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 327fb06dd1..06552b781b 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -288,7 +288,7 @@ void EventsManager::centerMousePos() { } void EventsManager::restrictMouse() { - warning("TODO: restrictMouse"); + // No implementation in ScummVM } } // End of namespace Access -- cgit v1.2.3 From abecac94d4b944f1c594f6963cb308614086360a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 11:42:25 -0500 Subject: ACCESS: Fix to restrict river canoe to 7 allowable 'lanes' --- engines/access/amazon/amazon_scripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7cae5fd0ef..58491250ad 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -1625,7 +1625,7 @@ void AmazonScripts::moveCanoe2() { _game->_canoeYPos += _game->_canoeDir; if (++_game->_canoeMoveCount == 5) { - _game->_canoeYPos += _game->_canoeDir; + _game->_canoeLane += _game->_canoeDir; _game->_canoeDir = 0; } } -- cgit v1.2.3 From eeb9d63a19ba3a712a8f02ecede554dc992246fe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 14:16:10 -0500 Subject: ACCESS: Don't decrease timers whilst text dialogs are showing --- engines/access/events.cpp | 16 +++++++++------- engines/access/events.h | 4 ++-- engines/access/scripts.cpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 06552b781b..8b109ea470 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -120,9 +120,9 @@ bool EventsManager::isCursorVisible() { return CursorMan.isVisible(); } -void EventsManager::pollEvents() { +void EventsManager::pollEvents(bool skipTimers) { if (checkForNextFrameCounter()) { - nextFrame(); + nextFrame(skipTimers); } _wheelUp = _wheelDown = false; @@ -200,10 +200,12 @@ bool EventsManager::checkForNextFrameCounter() { return false; } -void EventsManager::nextFrame() { - // Update timers - _vm->_animation->updateTimers(); - _vm->_timers.updateTimers(); +void EventsManager::nextFrame(bool skipTimers) { + if (skipTimers) { + // Update timers + _vm->_animation->updateTimers(); + _vm->_timers.updateTimers(); + } // Give time to the debugger _vm->_debugger->onFrame(); @@ -243,7 +245,7 @@ void EventsManager::clearEvents() { void EventsManager::waitKeyMouse() { while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { - pollEvents(); + pollEvents(true); g_system->delayMillis(10); } diff --git a/engines/access/events.h b/engines/access/events.h index c72f245412..95ba926384 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -47,7 +47,7 @@ private: uint32 _frameCounter; uint32 _priorFrameTime; Graphics::Surface _invCursor; - void nextFrame(); + void nextFrame(bool skipTimers); public: CursorType _cursorId; CursorType _normalMouse; @@ -105,7 +105,7 @@ public: */ bool isCursorVisible(); - void pollEvents(); + void pollEvents(bool skipTimers = false); void pollEventsAndWait(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 72650f472c..d611b6fe26 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -213,7 +213,7 @@ void Scripts::printString(const Common::String &msg) { // Wait until the bubble display is expired while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) { - _vm->_events->pollEvents(); + _vm->_events->pollEvents(true); } // Restore the original screen over the text bubble -- cgit v1.2.3 From 740df9b42aac87472353512d2eda796bdd6d3aa3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 14:22:11 -0500 Subject: ACCESS: Further tweaks to timer skipping --- engines/access/events.cpp | 2 +- engines/access/scripts.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 8b109ea470..87e5d10cc3 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -201,7 +201,7 @@ bool EventsManager::checkForNextFrameCounter() { } void EventsManager::nextFrame(bool skipTimers) { - if (skipTimers) { + if (!skipTimers) { // Update timers _vm->_animation->updateTimers(); _vm->_timers.updateTimers(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d611b6fe26..72650f472c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -213,7 +213,7 @@ void Scripts::printString(const Common::String &msg) { // Wait until the bubble display is expired while (!_vm->shouldQuit() && _vm->_timers[PRINT_TIMER]._flag) { - _vm->_events->pollEvents(true); + _vm->_events->pollEvents(); } // Restore the original screen over the text bubble -- cgit v1.2.3 From e3322185686f268c0375bcaef93c5ef35209ebdc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 15:06:49 -0500 Subject: ACCESS: Workaround for Exit/walk icon in massacre site scene --- engines/access/amazon/amazon_room.cpp | 16 ++++++++++++++++ engines/access/amazon/amazon_room.h | 2 ++ engines/access/room.cpp | 33 ++++++++++++++++++++------------- engines/access/room.h | 2 ++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 4df1131643..ca0d7bf341 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -199,6 +199,22 @@ void AmazonRoom::mainAreaClick() { } } +void AmazonRoom::walkCursor() { + // WORKAROUND: For scene 29, which is a normal walkable scene, but yet can be + // 'exitted'. This workaround ensures the scene will only be left if you click + // the Exit icon wgeb the cursor is already a walk cursor + EventsManager &events = *_vm->_events; + + if (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS) { + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); + _selectCommand = -1; + _vm->_boxSelect = true; + } else { + Room::walkCursor(); + } +} + void AmazonRoom::init4Quads() { if (!_vm->_screen->_vesaMode) return; diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index bcb0d84e15..ab9212724f 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -53,6 +53,8 @@ protected: virtual void mainAreaClick(); virtual void clearRoom(); + + virtual void walkCursor(); public: AmazonRoom(AccessEngine *vm); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index bc76d48d8d..b9ce06959a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -540,19 +540,7 @@ void Room::executeCommand(int commandId) { events.setCursor(CURSOR_TALK); break; case 7: - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); - _vm->_scripts->_sequence = 5000; - _vm->_scripts->searchForSequence(); - roomMenu(); - _selectCommand = -1; - - _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { - _conFlag = false; - _vm->_scripts->executeScript(); - } - _vm->_boxSelect = true; + walkCursor(); return; case 8: events._normalMouse = CURSOR_HELP; @@ -580,6 +568,25 @@ void Room::executeCommand(int commandId) { _vm->_boxSelect = true; } +void Room::walkCursor() { + EventsManager &events = *_vm->_events; + + events._normalMouse = CURSOR_CROSSHAIRS; + events.setCursor(CURSOR_CROSSHAIRS); + _vm->_scripts->_sequence = 5000; + _vm->_scripts->searchForSequence(); + roomMenu(); + _selectCommand = -1; + + _conFlag = true; + while (_conFlag && !_vm->shouldQuit()) { + _conFlag = false; + _vm->_scripts->executeScript(); + } + + _vm->_boxSelect = true; +} + void Room::commandOff() { _selectCommand = -1; _vm->_events->setCursor(CURSOR_CROSSHAIRS); diff --git a/engines/access/room.h b/engines/access/room.h index a3ee019d39..4ec80d114c 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -112,6 +112,8 @@ protected: virtual void doCommands(); virtual void mainAreaClick() = 0; + + virtual void walkCursor(); public: Plotter _plotter; Common::Array _jetFrame; -- cgit v1.2.3 From 1716cd9b30e9fdf97fcbcc854c30c0818ae90011 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 21:02:12 -0500 Subject: ACCESS: Major refactoring of Amazon logic into their own classes --- engines/access/access.cpp | 18 - engines/access/access.h | 11 +- engines/access/amazon/amazon_game.cpp | 389 ++---- engines/access/amazon/amazon_game.h | 78 +- engines/access/amazon/amazon_logic.cpp | 1832 ++++++++++++++++++++++++++++ engines/access/amazon/amazon_logic.h | 228 ++++ engines/access/amazon/amazon_player.cpp | 2 +- engines/access/amazon/amazon_resources.cpp | 62 + engines/access/amazon/amazon_resources.h | 6 + engines/access/amazon/amazon_room.cpp | 3 +- engines/access/amazon/amazon_scripts.cpp | 1514 +---------------------- engines/access/amazon/amazon_scripts.h | 59 - engines/access/martian/martian_game.h | 2 + engines/access/module.mk | 1 + engines/access/player.cpp | 2 +- engines/access/scripts.cpp | 69 +- engines/access/scripts.h | 11 +- 17 files changed, 2236 insertions(+), 2051 deletions(-) create mode 100644 engines/access/amazon/amazon_logic.cpp create mode 100644 engines/access/amazon/amazon_logic.h diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 885b2f998c..1ab40a2de7 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -92,15 +92,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _helpTbl[2] = _help3; _travel = 0; _ask = 0; - _rScrollRow = 0; - _rScrollCol = 0; - _rScrollX = 0; - _rScrollY = 0; - _rOldRectCount = 0; - _rNewRectCount = 0; - _rKeyFlag = 0; - _mapOffset = 0; - _screenVirtX = 0; _lastTime = g_system->getMillis(); _curTime = 0; _narateFile = 0; @@ -524,15 +515,6 @@ void AccessEngine::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_travel); s.syncAsUint16LE(_ask); - s.syncAsUint16LE(_rScrollRow); - s.syncAsUint16LE(_rScrollCol); - s.syncAsSint16LE(_rScrollX); - s.syncAsSint16LE(_rScrollY); - s.syncAsUint16LE(_rOldRectCount); - s.syncAsUint16LE(_rNewRectCount); - s.syncAsUint16LE(_rKeyFlag); - s.syncAsUint16LE(_mapOffset); - s.syncAsUint16LE(_screenVirtX); for (int i = 0; i < 100; ++i) s.syncAsByte(_establishTable[i]); diff --git a/engines/access/access.h b/engines/access/access.h index c0bc467f08..0942c9eb8e 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -213,15 +213,6 @@ public: byte *_helpTbl[3]; int _travel; int _ask; - int _rScrollRow; - int _rScrollCol; - int _rScrollX; - int _rScrollY; - int _rOldRectCount; - int _rNewRectCount; - int _rKeyFlag; - int _mapOffset; - int _screenVirtX; bool _clearSummaryFlag; @@ -234,6 +225,8 @@ public: AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AccessEngine(); + virtual void dead(int deathId) = 0; + uint32 getFeatures() const; bool isCD() const; Common::Language getLanguage() const; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 4237982b4d..55876b5692 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -36,38 +36,22 @@ AccessEngine(syst, gameDesc), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), - _noSound(_flags[239]) { + _noSound(_flags[239]), + _ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), + _plane(this), _river(this) { _skipStart = false; _charSegSwitch = false; - _canoeLane = 0; - _canoeYPos = 0; - _hitCount = 0; _saveRiver = false; - _hitSafe = 0; _oldTitleChapter = _chapter = 0; _updateChapter = -1; - _topList = nullptr; - _botList = nullptr; - _riverIndex = 0; _rawInactiveX = 0; _rawInactiveY = 0; _inactiveYOff = 0; _tilePos = Common::Point(0, 0); _hintLevel = 0; - _antDirection = NONE; - _pitDirection = NONE; - _antCel = 0; - _torchCel = 0; - _pitCel = 0; - _stabCel = 0; - _antPos = Common::Point(0, 0); - _antDieFl = _antEatFl = false; - _stabFl = false; - _pitPos = Common::Point(0, 0); - Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); @@ -96,7 +80,6 @@ void AmazonEngine::playGame() { // Initialize Amazon game-specific objects _room = new AmazonRoom(this); _scripts = new AmazonScripts(this); - _guard.setVm(this); // Setup the game setupGame(); @@ -140,7 +123,7 @@ void AmazonEngine::doIntroduction() { return; _screen->setPanel(3); - ((AmazonScripts *)_scripts)->mWhileDoOpen(); + _opening.mWhileDoOpen(); if (shouldQuit() || _skipStart) return; @@ -916,315 +899,89 @@ void AmazonEngine::startChapter(int chapter) { } } -void AmazonEngine::synchronize(Common::Serializer &s) { - AccessEngine::synchronize(s); - - int dummy = 0; - - s.syncAsSint16LE(_canoeLane); - s.syncAsSint16LE(_canoeYPos); - s.syncAsSint16LE(_hitCount); - s.syncAsSint16LE(_saveRiver); - s.syncAsSint16LE(_hitSafe); - s.syncAsSint16LE(_chapter); - s.syncAsSint16LE(dummy); - s.syncAsSint16LE(dummy); - s.syncAsSint16LE(_riverIndex); - s.syncAsSint16LE(_rawInactiveX); - s.syncAsSint16LE(_rawInactiveY); - s.syncAsSint16LE(_inactiveYOff); - for (int i = 0; i < 100; ++i) - s.syncAsSint16LE(_esTabTable[i]); - - if (_player->_roomNumber == 45) { - - - warning("TODO: s.syncAsSint16LE(_topList);"); - warning("TODO: s.syncAsSint16LE(_botList);"); - } -} - -/*------------------------------------------------------------------------*/ - -Plane::Plane() { - _pCount = 0; - _planeCount = 0; - _propCount = 0; - _xCount = 0; -} - -/*------------------------------------------------------------------------*/ - -Guard::Guard() { - _vm = nullptr; - _guardCel = 0; - _gCode1 = _gCode2 = 0; - _xMid = _yMid = 0; -} -void Guard::setVerticalCode() { - _gCode1 = 0; - _gCode2 = 0; - if (_topLeft.x < _vm->_screen->_orgX1) - _gCode1 |= 8; - else if (_topLeft.x == _vm->_screen->_orgX1) { - _gCode1 |= 8; - _gCode1 |= 2; - } - else - _gCode1 |= 2; - - if (_bottomRight.x < _vm->_screen->_orgX1) - _gCode2 |= 8; - else if (_bottomRight.x == _vm->_screen->_orgX1) { - _gCode2 |= 8; - _gCode2 |= 2; - } - else - _gCode2 |= 2; - - if (_topLeft.y < _vm->_screen->_orgY1) - _gCode1 |= 4; - else if (_topLeft.y > _vm->_screen->_orgY2) - _gCode1 |= 1; - - if (_bottomRight.y < _vm->_screen->_orgY1) - _gCode2 |= 4; - else if (_bottomRight.y > _vm->_screen->_orgY2) - _gCode2 |= 1; -} - -void Guard::setHorizontalCode() { - _gCode1 = 0; - _gCode2 = 0; - - if (_topLeft.y < _vm->_screen->_orgY1) - _gCode1 |= 4; - else if (_topLeft.x == _vm->_screen->_orgX1) { - _gCode1 |= 4; - _gCode1 |= 1; - } - else - _gCode1 |= 1; - - if (_bottomRight.y < _vm->_screen->_orgY1) - _gCode2 |= 4; - else if (_bottomRight.x == _vm->_screen->_orgX1) { - _gCode2 |= 4; - _gCode2 |= 1; - } - else - _gCode2 |= 1; - - if (_topLeft.x < _vm->_screen->_orgX1) - _gCode1 |= 8; - else if (_topLeft.x > _vm->_screen->_orgX2) - _gCode1 |= 2; - - if (_bottomRight.x < _vm->_screen->_orgX1) - _gCode2 |= 8; - else if (_bottomRight.y > _vm->_screen->_orgX2) - _gCode2 |= 2; -} +void AmazonEngine::dead(int deathId) { + _events->hideCursor(); + _screen->forceFadeOut(); + _scripts->cmdFreeSound(); -void Guard::chkVLine() { - if (_position.x > _vm->_player->_rawPlayer.x) { - _topLeft = _vm->_player->_rawPlayer; - _bottomRight = _position; - } else { - _topLeft = _position; - _bottomRight = _vm->_player->_rawPlayer; - } + _sound->_soundTable.push_back(SoundEntry(_files->loadFile(98, 44), 1)); - if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2) - SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); + _screen->clearScreen(); + _screen->setPanel(3); - for (;;) { - setVerticalCode(); - int code = _gCode1 | _gCode2; - if (code == 10) { - _vm->_guardFind = 0; - return; + if (deathId != 10) { + _sound->newMusic(62, 0); + _files->_setPaletteFlag = false; + _files->loadScreen(94, 0); + _files->_setPaletteFlag = true; + _buffer2.copyFrom(*_screen); + + for (int i = 0; i < 3; ++i) { + _sound->playSound(0); + _screen->forceFadeIn(); + _sound->playSound(0); + _screen->forceFadeOut(); } + freeCells(); + + // Load the cell list for the death screen + DeathEntry &de = _deaths[deathId]; + Common::Array cells; + cells.push_back(_deaths._cells[de._screenId]); + loadCells(cells); + + _screen->setDisplayScan(); + _files->_setPaletteFlag = false; + _files->loadScreen(&_buffer2, 94, 1); + _screen->setIconPalette(); + + _buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25)); + _buffer2.copyTo(_screen); + _screen->forceFadeIn(); + + _fonts._charSet._hi = 10; + _fonts._charSet._lo = 1; + _fonts._charFor._lo = 55; + _fonts._charFor._hi = 255; + _screen->_maxChars = 46; + _screen->_printOrg = Common::Point(20, 155); + _screen->_printStart = Common::Point(20, 155); + + Common::String &msg = de._msg; + _printEnd = 180; + printText(_screen, msg); + _screen->forceFadeOut(); - int code2 = _gCode1 & _gCode2; - code2 &= 5; - if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0)) - return; - - int midX = (_topLeft.x + _bottomRight.x) / 2; - int midY = (_topLeft.y + _bottomRight.y) / 2; - - if (midX < _vm->_screen->_orgX1) { - if ((midX == _topLeft.x) && (midY == _topLeft.y)) - return; - - _topLeft.x = midX; - _topLeft.y = midY; - } else { - if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) - return; - - _bottomRight.x = midX; - _bottomRight.y = midY; - } - } -} + _sound->newMusic(0, 1); + _events->showCursor(); + _room->clearRoom(); + freeChar(); -void Guard::chkHLine() { - if (_position.y > _vm->_player->_rawPlayer.y) { - _topLeft = _vm->_player->_rawPlayer; - _bottomRight = _position; + warning("TODO: restart game"); + quitGame(); + _events->pollEvents(); } else { - _topLeft = _position; - _bottomRight = _vm->_player->_rawPlayer; - } - - if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2) - SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); - - while (true) { - setHorizontalCode(); - int code = _gCode1 | _gCode2; - if (code == 5) { - _vm->_guardFind = 0; - return; - } - - int code2 = _gCode1 & _gCode2; - code2 &= 10; - if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0)) - return; - - int midX = (_topLeft.x + _bottomRight.x) / 2; - int midY = (_topLeft.y + _bottomRight.y) / 2; - - if (midY < _vm->_screen->_orgY1) { - if ((midX == _topLeft.x) && (midY == _topLeft.y)) - return; - - _topLeft.x = midX; - _topLeft.y = midY; - } else { - if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) - return; - - _bottomRight.x = midX; - _bottomRight.y = midY; - } - } -} - -void Guard::guardSee() { - int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; - _vm->_flags[140] = 0; - if (tmpY > _position.y) - return; - - tmpY += _vm->_screen->_vWindowLinesTall; - tmpY -= 11; - - if (tmpY < _position.y) - return; - - _vm->_guardFind = 1; - _vm->_flags[140] = 1; - - for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { - _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; - _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; - _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; - _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; - if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { - chkVLine(); - if (_vm->_guardFind == 0) - return; - } - else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { - chkHLine(); - if (_vm->_guardFind == 0) - return; - } + quitGame(); + _events->pollEvents(); } } -void Guard::setGuardFrame() { - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - - if (_vm->_guardLocation == 4) - ie._flags |= IMGFLAG_BACKWARDS; - ie._spritesPtr = _vm->_objectsTable[37]; - ie._frameNumber = _guardCel; - ie._position = _position; - ie._offsetY = 10; - _vm->_images.addToList(ie); -} +void AmazonEngine::synchronize(Common::Serializer &s) { + AccessEngine::synchronize(s); -void Guard::guard() { - if (_vm->_timers[8]._flag) { - setGuardFrame(); - return; - } + int dummy = 0; - ++_vm->_timers[8]._flag; - ++_guardCel; - int curCel = _guardCel; - - switch (_vm->_guardLocation) { - case 1: - // Guard walking down - if (curCel <= 8 || curCel > 13) - _guardCel = curCel = 8; - - _position.y += _vm->_player->_walkOffDown[curCel - 8]; - guardSee(); - if (_position.y >= 272) { - _position.y = 272; - _vm->_guardLocation = 2; - } - break; - case 2: - // Guard walking left - if (curCel <= 43 || curCel > 48) - _guardCel = curCel = 43; - - _position.x -= _vm->_player->_walkOffLeft[curCel - 43]; - guardSee(); - if (_position.x <= 56) { - _position.x = 56; - _vm->_guardLocation = 3; - } - break; - case 3: - // Guard walking up - if (curCel <= 0 || curCel > 5) - _guardCel = curCel = 0; - - _position.y -= _vm->_player->_walkOffUp[curCel]; - guardSee(); - if (_position.y <= 89) { - _position.y = 89; - _vm->_guardLocation = 4; - if (_vm->_flags[121] == 1) - _vm->_guardLocation = 5; - } - break; - default: - // Guard walking right - if (curCel <= 43 || curCel > 48) - _guardCel = curCel = 43; - - _position.x += _vm->_player->_walkOffRight[curCel - 43]; - guardSee(); - if (_position.x >= 127) { - _position.x = 127; - _vm->_guardLocation = 1; - } - break; - } + s.syncAsSint16LE(_chapter); + s.syncAsSint16LE(dummy); + s.syncAsSint16LE(dummy); + s.syncAsSint16LE(_rawInactiveX); + s.syncAsSint16LE(_rawInactiveY); + s.syncAsSint16LE(_inactiveYOff); + for (int i = 0; i < 100; ++i) + s.syncAsSint16LE(_esTabTable[i]); - setGuardFrame(); + _river.synchronize(s); } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 4c4b304514..b09c96d263 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -24,53 +24,13 @@ #define ACCESS_AMAZON_GAME_H #include "access/access.h" +#include "access/amazon/amazon_logic.h" namespace Access { namespace Amazon { - class AmazonEngine; - -class Plane { -public: - int _pCount; - Common::Point _position; - int _planeCount; - int _propCount; - int _xCount; -public: - Plane(); -}; - -class Guard { -private: - AmazonEngine *_vm; - - void chkVLine(); - void chkHLine(); - void setVerticalCode(); - void setHorizontalCode(); - void guardSee(); - void setGuardFrame(); -public: - int _guardCel; - Common::Point _position; - int _gCode1; - int _gCode2; - Common::Point _topLeft; - Common::Point _bottomRight; - int _xMid, _yMid; -public: - Guard(); - void setVm(AmazonEngine *vm) { _vm = vm; } - - void guard(); -}; - -class InactivePlayer : public ImageEntry { -public: - SpriteResource *_altSpritesPtr; -}; +class AmazonEngine; class AmazonEngine : public AccessEngine { private: @@ -126,10 +86,7 @@ public: InactivePlayer _inactive; bool _charSegSwitch; bool _skipStart; - - RiverStruct *_topList; - RiverStruct *_botList; - int _canoeDir; + bool _saveRiver; // Fields that are mapped to flags int &_guardLocation; @@ -147,21 +104,20 @@ public: int &_noSound; // Saved fields - int _canoeLane; - int _canoeYPos; - int _hitCount; - bool _saveRiver; - int _hitSafe; int _chapter; - int _riverIndex; int _rawInactiveX; int _rawInactiveY; int _inactiveYOff; int _esTabTable[100]; // Other game specific fields + Ant _ant; + Cast _cast; Guard _guard; + Jungle _jungle; + Opening _opening; Plane _plane; + River _river; int _hintLevel; int _updateChapter; int _oldTitleChapter; @@ -170,28 +126,14 @@ public: bool _deathFlag; int _deathCount; int _deathType; - const byte *_mapPtr; - int _canoeVXPos; - int _canoeMoveCount; - int _canoeFrame; - - Direction _antDirection; - Direction _pitDirection; - int _antCel; - int _torchCel; - int _pitCel; - int _stabCel; - Common::Point _antPos; - bool _antDieFl; - bool _antEatFl; - bool _stabFl; - Common::Point _pitPos; int _iqValue; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); virtual ~AmazonEngine(); + virtual void dead(int deathId); + /** * Free the inactive player data */ diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp new file mode 100644 index 0000000000..cae3373ea8 --- /dev/null +++ b/engines/access/amazon/amazon_logic.cpp @@ -0,0 +1,1832 @@ +/* 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 "common/scummsys.h" +#include "access/access.h" +#include "access/resources.h" +#include "access/screen.h" +#include "access/amazon/amazon_game.h" +#include "access/amazon/amazon_logic.h" + +namespace Access { + +namespace Amazon { + +PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) { + for (int i = 0; i < PAN_SIZE; ++i) { + _pan[i]._pObject = nullptr; + _pan[i]._pImgNum = 0; + _pan[i]._pObjX = _pan[i]._pObjY = _pan[i]._pObjZ = 0; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + _xCount = 0; + _xTrack = _yTrack = _zTrack = 0; + _xCam = _yCam = _zCam = 0; + _pNumObj = 0; + _screenVertX = 0; +} + +void PannedScene::pan() { + _zCam += _zTrack; + _xCam += _xTrack; + int tx = (_xTrack << 8) / _zCam; + _yCam += _yTrack; + int ty = (_yTrack << 8) / _zCam; + + if (_vm->_timers[24]._flag != 1) { + ++_vm->_timers[24]._flag; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObjZ += _zTrack; + _pan[i]._pObjXl += (_pan[i]._pObjZ * tx) & 0xff; + _pan[i]._pObjX += ((_pan[i]._pObjZ * tx) >> 8) + (_pan[i]._pObjXl >> 8); + _pan[i]._pObjXl &= 0xff; + + _pan[i]._pObjYl += (_pan[i]._pObjZ * ty) & 0xff; + _pan[i]._pObjY += ((_pan[i]._pObjZ * ty) >> 8) + (_pan[i]._pObjYl >> 8); + _pan[i]._pObjYl &= 0xff; + } + } + + for (int i = 0; i < _pNumObj; i++) { + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._position = Common::Point(_pan[i]._pObjX, _pan[i]._pObjY); + ie._offsetY = 255; + ie._spritesPtr = _pan[i]._pObject; + ie._frameNumber = _pan[i]._pImgNum; + + _vm->_images.addToList(ie); + } +} + +/*------------------------------------------------------------------------*/ + +Opening::Opening(AmazonEngine *vm) : PannedScene(vm) { +} + +void Opening::mWhileDoOpen() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + screen.setBufferScan(); + events.hideCursor(); + screen.forceFadeOut(); + _vm->_skipStart = false; + if (_vm->_conversation != 2) { + // Cutscene at start of chapter 1 + screen.setPanel(3); + _vm->startChapter(1); + _vm->establishCenter(0, 1); + } + + Resource *data = _vm->_files->loadFile(1, 0); + _vm->_objectsTable[1] = new SpriteResource(_vm, data); + delete data; + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(1, 2); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + // Load animation data + _vm->_animation->freeAnimationData(); + Resource *animResource = _vm->_files->loadFile(1, 1); + _vm->_animation->loadAnimations(animResource); + delete animResource; + + _xTrack = 8; + _yTrack = -3; + _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 270; + _vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + _vm->_timers.updateTimers(); + + _pNumObj = 10; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[1]; + _pan[i]._pImgNum = OPENING_OBJS[i][0]; + _pan[i]._pObjX = OPENING_OBJS[i][1]; + _pan[i]._pObjY = OPENING_OBJS[i][2]; + _pan[i]._pObjZ = OPENING_OBJS[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + Animation *anim = _vm->_animation->setAnimation(0); + _vm->_animation->setAnimTimer(anim); + anim = _vm->_animation->setAnimation(1); + _vm->_animation->setAnimTimer(anim); + _vm->_sound->newMusic(10, 0); + + bool startFl = false; + while (!_vm->shouldQuit()) { + _vm->_images.clear(); + _vm->_animation->animate(0); + _vm->_animation->animate(1); + pan(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_newRects.clear(); + _vm->plotList(); + _vm->copyBlocks(); + if (!startFl) { + startFl = true; + screen.forceFadeIn(); + } + + events.pollEventsAndWait(); + + if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { + _vm->_skipStart = true; + _vm->_sound->newMusic(10, 1); + + events.debounceLeft(); + events.zeroKeys(); + break; + } + + if (_xCam > 680) { + events._vbCount = 125; + + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) { + events.pollEventsAndWait(); + } + break; + } + } + + events.showCursor(); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + _vm->freeCells(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + _vm->_images.clear(); + + if (_vm->_conversation == 2) { + // Cutscene at end of Chapter 6 + Resource *spriteData = _vm->_files->loadFile(28, 37); + _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_animation->freeAnimationData(); + animResource = _vm->_files->loadFile(28, 38); + _vm->_animation->loadAnimations(animResource); + delete animResource; + } +} + +/*------------------------------------------------------------------------*/ + +Plane::Plane(AmazonEngine *vm): PannedScene(vm) { + _pCount = 0; + _planeCount = 0; + _propCount = 0; +} + + +void Plane::doFlyCell() { + SpriteResource *sprites = _vm->_objectsTable[15]; + + if (_pCount <= 40) { + _vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74)); + } else if (_pCount <= 80) { + _vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74)); + } else if (_pCount <= 120) { + _vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76)); + } else if (_pCount <= 160) { + _vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78)); + } else if (_pCount <= 200) { + _vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74)); + } else if (_pCount <= 240) { + _vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76)); + } else if (_pCount <= 280) { + _vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77)); + } else { + _vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77)); + } + + if (_planeCount == 11 || _planeCount == 12) + ++_position.y; + else if (_planeCount >= 28) + --_position.y; + + _vm->_buffer2.plotImage(sprites, 7, _position); + _vm->_buffer2.plotImage(sprites, 8 + _propCount, Common::Point( + _position.x + 99, _position.y + 10)); + _vm->_buffer2.plotImage(sprites, 11 + _propCount, Common::Point( + _position.x + 104, _position.y + 18)); + + if (++_planeCount >= 30) + _planeCount = 0; + if (++_propCount >= 3) + _propCount = 0; + + ++_xCount; + if (_xCount == 1) + ++_position.x; + else + _xCount = 0; +} + +void Plane::doFallCell() { + if (_vm->_scaleI <= 20) + return; + + SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_planeCount / 6); + Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w], + 11 + _vm->_screen->_scaleTable1[frame->h]); + _vm->_buffer2.sPlotF(frame, r); + + _vm->_scaleI -= 3; + _vm->_scale = _vm->_scaleI; + _vm->_screen->setScaleTable(_vm->_scale); + ++_xCount; + if (_xCount == 5) + return; + _xCount = 0; + if (_planeCount == 18) + _planeCount = 0; + else + _planeCount += 6; +} + +void Plane::scrollFly() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + doFlyCell(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void Plane::scrollFall() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + doFallCell(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void Plane::mWhileFly() { + Screen &screen = *_vm->_screen; + Player &player = *_vm->_player; + EventsManager &events = *_vm->_events; + + events.hideCursor(); + screen.clearScreen(); + screen.setBufferScan(); + screen.fadeOut(); + screen._scrollX = 0; + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + screen.fadeIn(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + + // KEYFLG = 0; + + screen._scrollRow = screen._scrollCol = 0; + screen._scrollX = screen._scrollY = 0; + player._rawPlayer = Common::Point(0, 0); + player._scrollAmount = 1; + + _pCount = 0; + _planeCount = 0; + _propCount = 0; + _xCount = 0; + _position = Common::Point(20, 29); + + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && + ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { + events._vbCount = 4; + screen._scrollX += player._scrollAmount; + + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + } + + scrollFly(); + ++_pCount; + + while (!_vm->shouldQuit() && events._vbCount > 0) { + // To be rewritten when NEWTIMER is done + events.checkForNextFrameCounter(); + _vm->_sound->playSound(0); + + events.pollEventsAndWait(); + } + } + + events.showCursor(); +} + +void Plane::mWhileFall() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + + events.hideCursor(); + screen.clearScreen(); + screen.setBufferScan(); + screen.fadeOut(); + screen._scrollX = 0; + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + screen.fadeIn(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + + // KEYFLG = 0; + + screen._scrollRow = screen._scrollCol = 0; + screen._scrollX = screen._scrollY = 0; + _vm->_player->_scrollAmount = 3; + _vm->_scaleI = 255; + + _xCount = 0; + _planeCount = 0; + + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && + (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + events._vbCount = 4; + screen._scrollX += _vm->_player->_scrollAmount; + + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + } + + scrollFall(); + + while (!_vm->shouldQuit() && events._vbCount > 0) { + events.pollEventsAndWait(); + } + } + + events.showCursor(); +} + +/*------------------------------------------------------------------------*/ + +Jungle::Jungle(AmazonEngine *vm) : PannedScene(vm) { + for (int i = 0; i < JUNGLE_SIZE; ++i) { + _jCnt[i] = _jungleX[i] = -1; + } +} + +void Jungle::jungleMove() { + const static int jungleY[3] = { 27, 30, 29 }; + int count = 1; + int frameOffset = 0; + + if (!_vm->_timers[0]._flag) { + ++_vm->_timers[0]._flag; + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + + for (int i = 0; i < 3; ++i) { + int newJCnt = (_jCnt[i] + 1) % 8; + _jCnt[i] = newJCnt; + _jungleX[i] += 5; + } + + frameOffset = 4; + count = (_vm->_allenFlag != 1) ? 2 : 3; + } + + for (int i = 0; i < count; ++i) { + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[24]; + ie._frameNumber = _jCnt[i] + frameOffset; + ie._position = Common::Point(_jungleX[i], jungleY[i]); + ie._offsetY = jungleY[i]; + + _vm->_images.addToList(ie); + frameOffset += 8; + } +} + +void Jungle::initJWalk2() { + const int JUNGLE1OBJ[7][4] = { + { 2, 470, 0, 20 }, + { 0, 290, 0, 50 }, + { 1, 210, 0, 40 }, + { 0, 500, 0, 30 }, + { 1, 550, 0, 20 }, + { 0, 580, 0, 60 }, + { 1, 650, 0, 30 } + }; + _vm->_screen->fadeOut(); + _vm->_events->hideCursor(); + _vm->_screen->clearScreen(); + _vm->_buffer2.clearBuffer(); + _vm->_screen->setBufferScan(); + + _vm->_screen->_scrollX = _vm->_screen->_scrollY; + _vm->_screen->_scrollCol = _vm->_screen->_scrollRow; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->fadeIn(); + // KEYFL = 0; + + _xCount = 2; + _vm->_player->_scrollAmount = 5; + _xTrack = -10; + _yTrack = _zTrack = 0; + _xCam = 480; + _yCam = 0; + _zCam = 80; + + _vm->_timers[24]._timer = 1; + _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + + _pNumObj = 7; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[24]; + _pan[i]._pImgNum = JUNGLE1OBJ[i][0]; + _pan[i]._pObjX = JUNGLE1OBJ[i][1]; + _pan[i]._pObjY = JUNGLE1OBJ[i][2]; + _pan[i]._pObjZ = JUNGLE1OBJ[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + _jCnt[0] = 0; + _jCnt[1] = 3; + _jCnt[2] = 5; + + _jungleX[0] = 50; + _jungleX[1] = 16; + _jungleX[2] = 93; +} + +void Jungle::mWhileJWalk() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Player &player = *_vm->_player; + + static const int JUNGLE_OBJ[7][4] = { + { 2, 77, 0, 40 }, + { 0, 290, 0, 50 }, + { 1, 210, 0, 70 }, + { 0, 50, 0, 30 }, + { 1, 70, 0, 20 }, + { 0, -280, 0, 60 }, + { 1, -150, 0, 30 }, + }; + + screen.fadeOut(); + events.hideCursor(); + screen.clearScreen(); + _vm->_buffer2.clearBuffer(); + screen.setBufferScan(); + screen._scrollX = 0; + + // Build the initial jungle scene and fade it in + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + screen.fadeIn(); + + // Set up the player to walk horizontally + player._xFlag = 1; + player._yFlag = 0; + player._moveTo.x = 160; + player._playerMove = true; + + _xCount = 2; + _xTrack = 10; + _yTrack = _zTrack = 0; + _xCam = 480; + _yCam = 0; + _zCam = 80; + + TimerEntry *te = &_vm->_timers[24]; + te->_initTm = te->_timer = 1; + te->_flag++; + + _pNumObj = 7; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[24]; + _pan[i]._pImgNum = JUNGLE_OBJ[i][0]; + _pan[i]._pObjX = JUNGLE_OBJ[i][1]; + _pan[i]._pObjY = JUNGLE_OBJ[i][2]; + _pan[i]._pObjZ = JUNGLE_OBJ[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) { + _vm->_images.clear(); + events._vbCount = 6; + + _pan[0]._pImgNum = _xCount; + if (_xCount == 2) + ++_xCount; + else + --_xCount; + + player.checkMove(); + player.checkScroll(); + pan(); + scrollJWalk(); + + while (!_vm->shouldQuit() && events._vbCount > 0) { + events.pollEventsAndWait(); + } + } + + _vm->_images.clear(); + events.showCursor(); +} + +void Jungle::mWhileJWalk2() { + Screen &screen = *_vm->_screen; + + initJWalk2(); + + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && + (screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { + _vm->_images.clear(); + _vm->_events->_vbCount = 6; + _pan[0]._pImgNum = _xCount; + + jungleMove(); + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + } + + if (_xCount == 2) + ++_xCount; + else + --_xCount; + + pan(); + scrollJWalk(); + + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); + } + } + + _vm->_events->showCursor(); +} + +void Jungle::scrollJWalk() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + _vm->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +/*------------------------------------------------------------------------*/ + +Guard::Guard(AmazonEngine *vm): PannedScene(vm) { + _vm = nullptr; + _guardCel = 0; + _gCode1 = _gCode2 = 0; + _xMid = _yMid = 0; +} + +void Guard::setVerticalCode() { + _gCode1 = 0; + _gCode2 = 0; + if (_topLeft.x < _vm->_screen->_orgX1) + _gCode1 |= 8; + else if (_topLeft.x == _vm->_screen->_orgX1) { + _gCode1 |= 8; + _gCode1 |= 2; + } + else + _gCode1 |= 2; + + if (_bottomRight.x < _vm->_screen->_orgX1) + _gCode2 |= 8; + else if (_bottomRight.x == _vm->_screen->_orgX1) { + _gCode2 |= 8; + _gCode2 |= 2; + } + else + _gCode2 |= 2; + + if (_topLeft.y < _vm->_screen->_orgY1) + _gCode1 |= 4; + else if (_topLeft.y > _vm->_screen->_orgY2) + _gCode1 |= 1; + + if (_bottomRight.y < _vm->_screen->_orgY1) + _gCode2 |= 4; + else if (_bottomRight.y > _vm->_screen->_orgY2) + _gCode2 |= 1; +} + +void Guard::setHorizontalCode() { + _gCode1 = 0; + _gCode2 = 0; + + if (_topLeft.y < _vm->_screen->_orgY1) + _gCode1 |= 4; + else if (_topLeft.x == _vm->_screen->_orgX1) { + _gCode1 |= 4; + _gCode1 |= 1; + } + else + _gCode1 |= 1; + + if (_bottomRight.y < _vm->_screen->_orgY1) + _gCode2 |= 4; + else if (_bottomRight.x == _vm->_screen->_orgX1) { + _gCode2 |= 4; + _gCode2 |= 1; + } + else + _gCode2 |= 1; + + if (_topLeft.x < _vm->_screen->_orgX1) + _gCode1 |= 8; + else if (_topLeft.x > _vm->_screen->_orgX2) + _gCode1 |= 2; + + if (_bottomRight.x < _vm->_screen->_orgX1) + _gCode2 |= 8; + else if (_bottomRight.y > _vm->_screen->_orgX2) + _gCode2 |= 2; +} + +void Guard::chkVLine() { + if (_position.x > _vm->_player->_rawPlayer.x) { + _topLeft = _vm->_player->_rawPlayer; + _bottomRight = _position; + } + else { + _topLeft = _position; + _bottomRight = _vm->_player->_rawPlayer; + } + + if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2) + SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2); + + for (;;) { + setVerticalCode(); + int code = _gCode1 | _gCode2; + if (code == 10) { + _vm->_guardFind = 0; + return; + } + + int code2 = _gCode1 & _gCode2; + code2 &= 5; + if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0)) + return; + + int midX = (_topLeft.x + _bottomRight.x) / 2; + int midY = (_topLeft.y + _bottomRight.y) / 2; + + if (midX < _vm->_screen->_orgX1) { + if ((midX == _topLeft.x) && (midY == _topLeft.y)) + return; + + _topLeft.x = midX; + _topLeft.y = midY; + } + else { + if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) + return; + + _bottomRight.x = midX; + _bottomRight.y = midY; + } + } +} + +void Guard::chkHLine() { + if (_position.y > _vm->_player->_rawPlayer.y) { + _topLeft = _vm->_player->_rawPlayer; + _bottomRight = _position; + } + else { + _topLeft = _position; + _bottomRight = _vm->_player->_rawPlayer; + } + + if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2) + SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2); + + while (true) { + setHorizontalCode(); + int code = _gCode1 | _gCode2; + if (code == 5) { + _vm->_guardFind = 0; + return; + } + + int code2 = _gCode1 & _gCode2; + code2 &= 10; + if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0)) + return; + + int midX = (_topLeft.x + _bottomRight.x) / 2; + int midY = (_topLeft.y + _bottomRight.y) / 2; + + if (midY < _vm->_screen->_orgY1) { + if ((midX == _topLeft.x) && (midY == _topLeft.y)) + return; + + _topLeft.x = midX; + _topLeft.y = midY; + } + else { + if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) + return; + + _bottomRight.x = midX; + _bottomRight.y = midY; + } + } +} + +void Guard::guardSee() { + int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; + _vm->_flags[140] = 0; + if (tmpY > _position.y) + return; + + tmpY += _vm->_screen->_vWindowLinesTall; + tmpY -= 11; + + if (tmpY < _position.y) + return; + + _vm->_guardFind = 1; + _vm->_flags[140] = 1; + + for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { + _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; + _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; + _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; + _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; + if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { + chkVLine(); + if (_vm->_guardFind == 0) + return; + } + else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { + chkHLine(); + if (_vm->_guardFind == 0) + return; + } + } +} + +void Guard::setGuardFrame() { + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + + if (_vm->_guardLocation == 4) + ie._flags |= IMGFLAG_BACKWARDS; + ie._spritesPtr = _vm->_objectsTable[37]; + ie._frameNumber = _guardCel; + ie._position = _position; + ie._offsetY = 10; + _vm->_images.addToList(ie); +} + +void Guard::doGuard() { + if (_vm->_timers[8]._flag) { + setGuardFrame(); + return; + } + + ++_vm->_timers[8]._flag; + ++_guardCel; + int curCel = _guardCel; + + switch (_vm->_guardLocation) { + case 1: + // Guard walking down + if (curCel <= 8 || curCel > 13) + _guardCel = curCel = 8; + + _position.y += _vm->_player->_walkOffDown[curCel - 8]; + guardSee(); + if (_position.y >= 272) { + _position.y = 272; + _vm->_guardLocation = 2; + } + break; + case 2: + // Guard walking left + if (curCel <= 43 || curCel > 48) + _guardCel = curCel = 43; + + _position.x -= _vm->_player->_walkOffLeft[curCel - 43]; + guardSee(); + if (_position.x <= 56) { + _position.x = 56; + _vm->_guardLocation = 3; + } + break; + case 3: + // Guard walking up + if (curCel <= 0 || curCel > 5) + _guardCel = curCel = 0; + + _position.y -= _vm->_player->_walkOffUp[curCel]; + guardSee(); + if (_position.y <= 89) { + _position.y = 89; + _vm->_guardLocation = 4; + if (_vm->_flags[121] == 1) + _vm->_guardLocation = 5; + } + break; + default: + // Guard walking right + if (curCel <= 43 || curCel > 48) + _guardCel = curCel = 43; + + _position.x += _vm->_player->_walkOffRight[curCel - 43]; + guardSee(); + if (_position.x >= 127) { + _position.x = 127; + _vm->_guardLocation = 1; + } + break; + } + + setGuardFrame(); +} + +void Guard::setPosition(const Common::Point &pt) { + _position = pt; +} + +/*------------------------------------------------------------------------*/ + +Cast::Cast(AmazonEngine *vm) : PannedScene(vm) { +} + +void Cast::doCast(int param1) { + _vm->_screen->setDisplayScan(); + _vm->_events->hideCursor(); + _vm->_screen->forceFadeOut(); + _vm->_screen->_clipHeight = 173; + _vm->_screen->clearScreen(); + _vm->_chapter = 16; + _vm->tileScreen(); + _vm->updateSummary(param1); + _vm->_screen->setPanel(3); + _vm->_chapter = 14; + + Resource *spriteData = _vm->_files->loadFile(91, 0); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + spriteData = _vm->_files->loadFile(91, 1); + _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(58, 1); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + + _xTrack = 0; + _yTrack = -6; + _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 60; + + _vm->_timers[24]._timer = 1; + _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + + _pNumObj = 26; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[0]; + _pan[i]._pImgNum = CAST_END_OBJ[i][0]; + _pan[i]._pObjX = CAST_END_OBJ[i][1]; + _pan[i]._pObjY = CAST_END_OBJ[i][2]; + _pan[i]._pObjZ = CAST_END_OBJ[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + _pNumObj = 4; + for (int i = 0; i < _pNumObj; i++) { + _pan[26 + i]._pObject = _vm->_objectsTable[1]; + _pan[26 + i]._pImgNum = CAST_END_OBJ1[i][0]; + _pan[26 + i]._pObjX = CAST_END_OBJ1[i][1]; + _pan[26 + i]._pObjY = CAST_END_OBJ1[i][2]; + _pan[26 + i]._pObjZ = CAST_END_OBJ1[i][3]; + _pan[26 + i]._pObjXl = _pan[26 + i]._pObjYl = 0; + } + + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + + _vm->_sound->newMusic(58, 0); + _vm->_screen->forceFadeIn(); + + while (!_vm->shouldQuit()) { + _vm->_images.clear(); + pan(); + _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_newRects.clear(); + _vm->plotList(); + _vm->copyBlocks(); + + _vm->_events->pollEvents(); + if (_vm->_events->isKeyMousePressed()) + break; + + if (_yCam < -7550) { + _vm->_events->_vbCount = 50; + + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); + } + + while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone()) + _vm->_events->pollEventsAndWait(); + + break; + } + } + + _vm->_sound->newMusic(58, 1); + _vm->_events->showCursor(); + + _vm->freeCells(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + _vm->_numAnimTimers = 0; + _vm->_images.clear(); + _vm->_screen->forceFadeOut(); + + _vm->quitGame(); + _vm->_events->pollEvents(); +} + +/*------------------------------------------------------------------------*/ + +River::River(AmazonEngine *vm): PannedScene(vm) { + _vm = nullptr; + _CHICKENOUTFLG = false; + _rScrollRow = 0; + _rScrollCol = 0; + _rScrollX = 0; + _rScrollY = 0; + _rOldRectCount = 0; + _rNewRectCount = 0; + _rKeyFlag = 0; + _mapOffset = 0; + _screenVirtX = 0; +} + +void River::setRiverPan() { + int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + + _xTrack = 9; + _yTrack = _zTrack = 0; + _xCam = 160; + _yCam = 0; + _zCam = 80; + + _vm->_timers[24]._timer = 1; + _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + + _pNumObj = 23; + for (int i = 0; i < _pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[45]; + _pan[i]._pImgNum = RIVER1OBJ[i][0]; + _pan[i]._pObjX = RIVER1OBJ[i][1] + delta; + _pan[i]._pObjY = RIVER1OBJ[i][2]; + _pan[i]._pObjZ = RIVER1OBJ[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } +} + +void River::initRiver() { + static const int RIVERVXTBL[3] = { 6719, 7039, 8319 }; + + _vm->_events->centerMousePos(); + _vm->_events->restrictMouse(); + _vm->_screen->setDisplayScan(); + _vm->_screen->clearScreen(); + _vm->_screen->savePalette(); + _vm->_screen->forceFadeOut(); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(95, 4); + _vm->_buffer2.copyFrom(*_vm->_screen); + + _vm->_screen->restorePalette(); + _vm->_screen->setBufferScan(); + _vm->_destIn = &_vm->_buffer2; + _vm->_room->roomMenu(); + + if (_vm->_saveRiver) { + // Restoring a savegame, so set properties from saved fields + _vm->_screen->_scrollRow = _rScrollRow; + _vm->_screen->_scrollCol = _rScrollCol; + _vm->_screen->_scrollX = _rScrollX; + _vm->_screen->_scrollY = _rScrollY; + } else { + // Set initial scene state + _vm->_screen->_scrollRow = 0; + _vm->_screen->_scrollCol = 140; + _vm->_screen->_scrollX = 0; + _vm->_screen->_scrollY = 0; + } + + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->forceFadeIn(); + + if (_vm->_saveRiver) { + // Restore draw rects from savegame + _vm->_oldRects.resize(_rOldRectCount); + _vm->_newRects.resize(_rNewRectCount); + // KEYFLG = _vm->_rKeyFlag + } else { + // Reset draw rects + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + // KEYFLG = 0 + } + + _vm->_player->_scrollAmount = 2; + setRiverPan(); + _vm->_timers[3]._timer = 1; + _vm->_timers[3]._initTm = 1; + ++_vm->_timers[3]._flag; + + _canoeFrame = 0; + _mapPtr = (const byte *)MAPTBL[_vm->_riverFlag] + 1; + if (_vm->_saveRiver) { + _mapPtr--; + _mapPtr += _mapOffset; + } else { + _screenVertX = RIVERVXTBL[_vm->_riverFlag] - 320; + _canoeLane = 3; + _hitCount = 0; + _hitSafe = 0; + _canoeYPos = 71; + } + + _riverIndex = _vm->_riverFlag; + _topList = RIVEROBJECTTBL[_riverIndex]; + updateObstacles(); + riverSetPhysX(); + _canoeDir = 0; + _vm->_deathFlag = 0; + _vm->_deathCount = 0; + + _vm->_timers[11]._timer = 1200; + _vm->_timers[11]._initTm = 1200; + ++_vm->_timers[11]._flag; + _vm->_timers[12]._timer = 1500; + _vm->_timers[12]._initTm = 1500; + ++_vm->_timers[12]._flag; + + _vm->_maxHits = 2 - _vm->_riverFlag; + _vm->_saveRiver = false; +} + +void River::resetPositions() { + riverSetPhysX(); + int val = (_vm->_screen->_scrollCol + 1 - _vm->_oldScrollCol) * 16; + if (val > 256) { + val &= 0x7F; + val |= 0x80; + } + + for (int i = 0; i < _pNumObj; i++) + _pan[i]._pObjX += val; +} + +void River::checkRiverPan() { + int val = (_vm->_screen->_scrollCol + 20) * 16; + + for (int i = 0; i < _pNumObj; i++) { + if (_pan[i]._pObjX < val) + return; + } + + setRiverPan(); +} + +bool River::riverJumpTest() { + if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) { + int val = _mapPtr[0]; + ++_mapPtr; + if (val == 0xFF) + return true; + _vm->_oldScrollCol = _vm->_screen->_scrollCol; + + if (val == 0) { + _vm->_screen->_scrollCol = 139; + _vm->_screen->_scrollX = 14; + _vm->_room->buildScreen(); + resetPositions(); + return false; + } + } else if (_vm->_screen->_scrollCol == 105) { + int val1 = _mapPtr[1]; + int val2 = _mapPtr[2]; + _mapPtr += 3; + if (_canoeLane < 3) { + if (val1 != 0) { + _vm->_deathFlag = true; + _vm->_deathCount = 300; + _vm->_deathType = val2; + } + } else { + if (val1 != 1) { + _vm->_deathFlag = true; + _vm->_deathCount = 300; + _vm->_deathType = val2; + } + _vm->_oldScrollCol = _vm->_screen->_scrollCol; + _vm->_screen->_scrollCol = 44; + _vm->_screen->_scrollX = 14; + _vm->_room->buildScreen(); + resetPositions(); + return false; + } + } + + _vm->_screen->_scrollX = 14; + --_vm->_screen->_scrollCol; + _vm->_buffer1.moveBufferRight(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); + checkRiverPan(); + return false; +} + +void River::riverSound() { + if (_vm->_timers[11]._flag == 0) { + ++_vm->_timers[11]._flag; + _vm->_sound->playSound(2); + } + + if (_vm->_timers[12]._flag == 0) { + ++_vm->_timers[12]._flag; + _vm->_sound->playSound(3); + } + + if ((_xCam >= 1300) && (_xCam <= 1320)) + _vm->_sound->playSound(1); +} + +void River::moveCanoe() { + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Common::Point pt = events.calcRawMouse(); + + // Do an event polling + _vm->_canSaveLoad = true; + events.pollEvents(); + _vm->_canSaveLoad = false; + if (_vm->_room->_function == FN_CLEAR1) + return; + + if (_canoeDir) { + // Canoe movement in progress + moveCanoe2(); + } else { + if (events._leftButton && pt.y >= 140) { + if (pt.x < RMOUSE[8][0]) { + // Disk icon wasn't clicked + _vm->_scripts->printString(BAR_MESSAGE); + } else { + // Clicked on the Disc icon + _vm->_saveRiver = true; + _rScrollRow = screen._scrollRow; + _rScrollCol = screen._scrollCol; + _rScrollX = screen._scrollX; + _rScrollY = screen._scrollY; + _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag]; + + // Show the ScummVM menu + _vm->_room->handleCommand(9); + + if (_vm->_room->_function != FN_CLEAR1) { + _vm->_saveRiver = false; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + } + } + } + else if ((events._leftButton && pt.y <= _canoeYPos) || + (!events._leftButton && _vm->_player->_move == UP)) { + // Move canoe up + if (_canoeLane > 0) { + _canoeDir = -1; + _canoeMoveCount = 0; + + moveCanoe2(); + } + } + else if (events._leftButton || _vm->_player->_move == DOWN) { + // Move canoe down + if (_canoeLane < 7) { + _canoeDir = 1; + _canoeMoveCount = 0; + + moveCanoe2(); + } + } + } +} + +void River::moveCanoe2() { + _canoeYPos += _canoeDir; + + if (++_canoeMoveCount == 5) { + _canoeLane += _canoeDir; + _canoeDir = 0; + } +} + +void River::updateObstacles() { + RiverStruct *cur; + for (cur = _topList; cur < RIVEROBJECTTBL[_riverIndex + 1]; ++cur) { + int val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX) + break; + + if (cur->_field3 < (_screenVirtX + 319)) { + _topList = cur; + _botList = cur; + + while (cur < RIVEROBJECTTBL[_riverIndex + 1]) { + ++cur; + val = cur->_field1 + cur->_field3 - 1; + if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319))) + break; + + _botList = cur; + } + + return; + } + } + + cur = _topList; + cur--; + _botList = cur; +} + +void River::riverSetPhysX() { + int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + RiverStruct *cur = _topList; + while (cur <= _botList) { + cur[0]._field5 = val - (_screenVertX - cur[0]._field3); + ++cur; + } +} + +bool River::checkRiverCollide() { + if (_hitSafe) + return false; + + _canoeVXPos = _screenVertX + 170; + + for (RiverStruct *si = _topList; si <= _botList; ++si) { + if (si[0]._lane < _canoeLane) + continue; + + if ((si[0]._lane == _canoeLane) || (si[0]._lane == _canoeLane + 1)) { + if (si[0]._field1 + si[0]._field3 - 1 >= _canoeVXPos) { + if (_canoeVXPos + 124 >= si[0]._field3) { + _vm->_sound->playSound(4); + return true; + } + } + } + } + return false; +} + +void River::plotRiver() { + if (_vm->_timers[3]._flag == 0) { + ++_vm->_timers[3]._flag; + if (_canoeFrame == 12) + _canoeFrame = 0; + else + ++_canoeFrame; + } + + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[45]; + ie._frameNumber = _canoeFrame; + ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; + ie._position.y = _canoeYPos - 41; + ie._offsetY = 41; + _vm->_images.addToList(ie); + + RiverStruct *cur = _topList; + while (cur <= _botList) { + if (cur[0]._id != -1) { + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[45]; + ie._frameNumber = 0; + ie._position.x = cur[0]._field5; + int val = (cur[0]._lane * 5) + 56; + ie._position.y = val - cur[0]._field8; + ie._offsetY = cur[0]._field8; + _vm->_images.addToList(ie); + } + ++cur; + } +} + +void River::mWhileDownRiver() { + _vm->_events->hideCursor(); + _vm->_screen->setDisplayScan(); + _vm->_screen->clearScreen(); + _vm->_screen->savePalette(); + + _vm->_files->loadScreen(95, 4); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_screen->restorePalette(); + _vm->_screen->setPalette(); + _vm->_screen->setBufferScan(); + _vm->_screen->_scrollX = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + + _vm->_player->_scrollAmount = 2; + _vm->_destIn = &_vm->_buffer2; + _xTrack = -7; + _yTrack = _zTrack = 0; + _xCam = _yCam = 0; + _zCam = 80; + + _vm->_timers[24]._timer = 1; + _vm->_timers[24]._initTm = 1; + ++_vm->_timers[24]._flag; + + _pNumObj = 14; + for (int i = 0; i <_pNumObj; i++) { + _pan[i]._pObject = _vm->_objectsTable[33]; + _pan[i]._pImgNum = DOWNRIVEROBJ[i][0]; + _pan[i]._pObjX = DOWNRIVEROBJ[i][1]; + _pan[i]._pObjY = DOWNRIVEROBJ[i][2]; + _pan[i]._pObjZ = DOWNRIVEROBJ[i][3]; + _pan[i]._pObjXl = _pan[i]._pObjYl = 0; + } + + _vm->_timers[3]._timer = 200; + _vm->_timers[3]._initTm = 200; + ++_vm->_timers[3]._flag; + _vm->_timers[4]._timer = 350; + _vm->_timers[4]._initTm = 350; + ++_vm->_timers[4]._flag; + + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && + (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) { + _vm->_images.clear(); + _vm->_events->_vbCount = 6; + + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_screen->_scrollX >= TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } + + pan(); + scrollRiver(); + + if (!_vm->_timers[3]._flag) { + ++_vm->_timers[3]._flag; + _vm->_sound->playSound(1); + } + else if (!_vm->_timers[4]._flag) { + ++_vm->_timers[4]._flag; + _vm->_sound->playSound(0); + } + + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); + } + } + + _vm->_events->showCursor(); +} + +void River::scrollRiver() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + _vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30)); + _vm->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void River::scrollRiver1() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + plotRiver(); + _vm->plotList(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void River::river() { + static const int RIVERDEATH[5] = { 22, 23, 24, 25, 26 }; + + initRiver(); + _vm->_events->showCursor(); + + while (!_vm->shouldQuit()) { + _vm->_events->_vbCount = 4; + + // int bx = _vm->_player->_scrollAmount - _screenVertX; + if (_vm->_screen->_scrollX == 0) { + _vm->_sound->midiRepeat(); + if (riverJumpTest()) { + _CHICKENOUTFLG = false; + return; + } + } + else { + _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; + } + + if (_CHICKENOUTFLG) { + _CHICKENOUTFLG = false; + return; + } + + _vm->_images.clear(); + _vm->_animation->animate(0); + + riverSound(); + pan(); + moveCanoe(); + + if (_vm->_room->_function != FN_CLEAR1) { + updateObstacles(); + riverSetPhysX(); + bool checkCollide = checkRiverCollide(); + if (_hitSafe != 0) + _hitSafe -= 2; + + if (checkCollide) { + _vm->dead(RIVERDEATH[0]); + return; + } + + if (_vm->_deathFlag) { + _vm->_deathCount--; + if (_vm->_deathCount == 0) { + _vm->dead(RIVERDEATH[_vm->_deathType]); + return; + } + } + + // Scroll the river + scrollRiver1(); + + // Allow time for new scrolled river position to be shown + _vm->_canSaveLoad = true; + while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE && + _vm->_events->_vbCount > 0) { + _vm->_events->pollEventsAndWait(); + } + _vm->_canSaveLoad = false; + } + + if (_vm->_room->_function == FN_CLEAR1) { + _vm->_scripts->_endFlag = true; + _vm->_scripts->_returnCode = 0; + _CHICKENOUTFLG = false; + break; + } + } +} +void River::synchronize(Common::Serializer &s) { + s.syncAsSint16LE(_canoeLane); + s.syncAsSint16LE(_canoeYPos); + s.syncAsSint16LE(_hitCount); + s.syncAsSint16LE(_riverIndex); + s.syncAsSint16LE(_hitSafe); + s.syncAsUint16LE(_rScrollRow); + s.syncAsUint16LE(_rScrollCol); + s.syncAsSint16LE(_rScrollX); + s.syncAsSint16LE(_rScrollY); + s.syncAsUint16LE(_rOldRectCount); + s.syncAsUint16LE(_rNewRectCount); + s.syncAsUint16LE(_rKeyFlag); + s.syncAsUint16LE(_mapOffset); + s.syncAsUint16LE(_screenVirtX); + warning("TODO: s.syncAsSint16LE(_topList);"); + warning("TODO: s.syncAsSint16LE(_botList);"); +} + +/*------------------------------------------------------------------------*/ + +Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) { + _antDirection = NONE; + _pitDirection = NONE; + _antCel = 0; + _torchCel = 0; + _pitCel = 0; + _stabCel = 0; + _antPos = Common::Point(0, 0); + _antDieFl = _antEatFl = false; + _stabFl = false; + _pitPos = Common::Point(0, 0); +} + +void Ant::plotTorchSpear(int indx, const int *&buf) { + int idx = indx; + + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[62]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_pitPos.x + buf[(idx / 2) + 1], _pitPos.y + buf[(idx / 2) + 2]); + ie._offsetY = 255; + _vm->_images.addToList(ie); +} + +void Ant::plotPit(int indx, const int *&buf) { + int idx = indx; + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[62]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_pitPos.x, _pitPos.y); + ie._offsetY = _pitPos.y; + _vm->_images.addToList(ie); + + _vm->_player->_rawPlayer = _pitPos; + if (_vm->_inventory->_inv[76]._value == 1) { + idx = _torchCel; + buf = Amazon::TORCH; + _vm->_timers[14]._flag = 1; + idx += 6; + if (buf[idx / 2] == -1) + idx = 0; + _torchCel = idx; + plotTorchSpear(idx, buf); + } + else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { + idx = 0; + buf = Amazon::SPEAR; + plotTorchSpear(idx, buf); + } +} + +int Ant::antHandleRight(int indx, const int *&buf) { + int retval = indx; + if (_pitDirection == NONE) { + _pitDirection = UP; + _pitPos.y = 127; + } + retval = _pitCel; + buf = Amazon::PITWALK; + if (_pitPos.x < 230) { + if (retval == 0) { + retval = 48; + _pitPos.y = 127; + } + retval -= 6; + _pitPos.x -= buf[(retval / 2) + 1]; + _pitPos.y -= buf[(retval / 2) + 2]; + _pitCel = retval; + } + return retval; +} + +int Ant::antHandleLeft(int indx, const int *&buf) { + int retval = indx; + if (_pitDirection == UP) { + _pitDirection = NONE; + _pitPos.y = 127; + } + retval = _pitCel; + buf = Amazon::PITWALK; + retval += 6; + if (buf[retval / 2] == -1) { + retval = 0; + _pitPos.y = 127; + } + _pitPos.x += buf[(retval / 2) + 1]; + _pitPos.y += buf[(retval / 2) + 2]; + _pitCel = retval; + + return retval; +} + +int Ant::antHandleStab(int indx, const int *&buf) { + int retval = indx; + if (_vm->_inventory->_inv[78]._value != 1) { + if (_stabFl) { + buf = Amazon::PITSTAB; + retval = _stabCel; + if (_vm->_timers[13]._flag == 0) { + _vm->_timers[13]._flag = 1; + retval += 6; + if (Amazon::PITSTAB[retval] == -1) { + _stabFl = false; + _pitCel = 0; + _pitPos.y = 127; + retval = 0; + buf = Amazon::PITWALK; + } + else { + _pitPos.x += buf[(retval / 2) + 1]; + _pitPos.y += buf[(retval / 2) + 2]; + _pitCel = retval; + } + } + } + else { + _stabFl = true; + _pitCel = 0; + retval = 0; + _stabCel = 0; + int dist = _pitPos.x - _antPos.x; + if (_antEatFl && !_antDieFl && (dist <= 80)) { + _antDieFl = true; + _antCel = 0; + _antPos.y = 123; + _vm->_sound->playSound(1); + } + } + } + return retval; +} + +void Ant::doAnt() { + _antDirection = NONE; + if (_vm->_aniFlag != 1) { + _vm->_aniFlag = 1; + _antCel = 0; + _torchCel = 0; + _pitCel = 0; + + _vm->_timers[15]._timer = 16; + _vm->_timers[15]._initTm = 16; + _vm->_timers[15]._flag = 1; + + _vm->_timers[13]._timer = 5; + _vm->_timers[13]._initTm = 5; + _vm->_timers[13]._flag = 1; + + _vm->_timers[14]._timer = 10; + _vm->_timers[14]._initTm = 10; + _vm->_timers[14]._flag = 1; + + _antPos = Common::Point(-40, 123); + _antDieFl = _antEatFl = false; + _stabFl = false; + _pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127); + } + + const int *buf = nullptr; + if (_antDieFl) { + buf = Amazon::ANTDIE; + } + else if (_antEatFl) { + buf = Amazon::ANTEAT; + } + else if (_antPos.x > 120 && _vm->_flags[198] == 1) { + _antEatFl = true; + _vm->_flags[235] = 1; + _antCel = 0; + buf = Amazon::ANTEAT; + } + else { + buf = Amazon::ANTWALK; + if (_vm->_inventory->_inv[76]._value == 1) + _antDirection = UP; + } + + int idx = _antCel; + if (_vm->_timers[15]._flag == 0) { + _vm->_timers[15]._flag = 1; + if (_antDirection == UP) { + if (_antPos.x > 10) { + if (idx == 0) + idx = 36; + else + idx -= 6; + + _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antCel = idx; + } + } + else { + idx += 6; + if (buf[(idx / 2)] != -1) { + _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antCel = idx; + } + else if (!_antDieFl) { + idx = 0; + _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antCel = idx; + } + else { + idx -= 6; + if (_vm->_flags[200] == 0) + _vm->_flags[200] = 1; + } + } + } + + ImageEntry ie; + ie._flags = IMGFLAG_UNSCALED; + ie._spritesPtr = _vm->_objectsTable[61]; + ie._frameNumber = buf[(idx / 2)]; + ie._position = Common::Point(_antPos.x, _antPos.y); + ie._offsetY = _antPos.y - 70; + _vm->_images.addToList(ie); + _antCel = idx; + + if (_vm->_flags[196] != 1) { + idx = _pitCel; + if (_stabFl == 1) { + idx = antHandleStab(idx, buf); + } + else { + buf = Amazon::PITWALK; + if (_vm->_timers[13]._flag == 0) { + _vm->_timers[13]._flag = 1; + _vm->_events->pollEvents(); + if (_vm->_events->_leftButton) { + Common::Point pt = _vm->_events->calcRawMouse(); + if (pt.x < _pitPos.x) + idx = antHandleLeft(idx, buf); + else if (pt.x > _pitPos.x) + idx = antHandleRight(idx, buf); + } + else { + buf = Amazon::PITWALK; + if (_vm->_player->_playerDirection == UP) + idx = antHandleStab(idx, buf); + else if (_vm->_player->_playerDirection == LEFT) + idx = antHandleLeft(idx, buf); + else if (_vm->_player->_playerDirection == RIGHT) + idx = antHandleRight(idx, buf); + } + } + } + plotPit(idx, buf); + } + + if (!_antDieFl) { + int dist = _pitPos.x - _antPos.x; + if ((_antEatFl && (dist <= 45)) || (!_antEatFl && (dist <= 80))) { + _vm->_flags[199] = 1; + _vm->_aniFlag = 0; + } + } +} + +} // End of namespace Amazon + +} // End of namespace Access diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h new file mode 100644 index 0000000000..4d5e274388 --- /dev/null +++ b/engines/access/amazon/amazon_logic.h @@ -0,0 +1,228 @@ +/* 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 ACCESS_AMAZON_LOGIC_H +#define ACCESS_AMAZON_LOGIC_H + +#include "common/scummsys.h" +#include "access/scripts.h" +#include "access/asurface.h" + +namespace Access { + +namespace Amazon { + +class AmazonEngine; + +#define PAN_SIZE 32 + +class AmazonManager { +protected: + AmazonEngine *_vm; +public: + AmazonManager(AmazonEngine *vm) : _vm(vm) {} +}; + +class PannedScene: public AmazonManager { + struct PanEntry { + SpriteResource *_pObject; + int _pImgNum; + int _pObjX; + int _pObjY; + int _pObjZ; + int _pObjXl; + int _pObjYl; + }; +protected: + int _xCount; + int _xTrack; + int _yTrack; + int _zTrack; + int _xCam; + int _yCam; + int _zCam; + int _pNumObj; + int _screenVertX; + + PanEntry _pan[PAN_SIZE]; +public: + PannedScene(AmazonEngine *vm); + + void pan(); +}; + +class Opening: public PannedScene { +public: + Opening(AmazonEngine *vm); + + void mWhileDoOpen(); +}; + +class Plane: public PannedScene { +public: + int _pCount; + Common::Point _position; + int _planeCount; + int _propCount; + + void doFlyCell(); + void doFallCell(); + void scrollFly(); + void scrollFall(); + void mWhileFly(); + void mWhileFall(); +public: + Plane(AmazonEngine *vm); +}; + +#define JUNGLE_SIZE 3 +class Jungle: public PannedScene { +private: + void initJWalk2(); + void jungleMove(); + void scrollJWalk(); + + int _jCnt[JUNGLE_SIZE]; + int _jungleX[JUNGLE_SIZE]; +public: + Jungle(AmazonEngine *vm); + + void mWhileJWalk(); + void mWhileJWalk2(); +}; + +class Guard : public PannedScene { +private: + int _guardCel; + Common::Point _position; + int _gCode1; + int _gCode2; + Common::Point _topLeft; + Common::Point _bottomRight; + int _xMid, _yMid; + + void chkVLine(); + void chkHLine(); + void setVerticalCode(); + void setHorizontalCode(); + void guardSee(); + void setGuardFrame(); +public: + Guard(AmazonEngine *vm); + + void doGuard(); + + void setPosition(const Common::Point &pt); +}; + +class Cast : public PannedScene { +public: + Cast(AmazonEngine *vm); + + void doCast(int param1); +}; + +class River: public PannedScene { +private: + bool _CHICKENOUTFLG; + const byte *_mapPtr; + int _canoeVXPos; + int _canoeMoveCount; + int _canoeFrame; + RiverStruct *_topList; + RiverStruct *_botList; + int _canoeDir; + + // Saved fields + int _canoeLane; + int _canoeYPos; + int _hitCount; + int _riverIndex; + int _hitSafe; + int _rScrollRow; + int _rScrollCol; + int _rScrollX; + int _rScrollY; + int _rOldRectCount; + int _rNewRectCount; + int _rKeyFlag; + int _mapOffset; + int _screenVirtX; + + void initRiver(); + void resetPositions(); + void checkRiverPan(); + bool riverJumpTest(); + void riverSound(); + void moveCanoe(); + void moveCanoe2(); + void updateObstacles(); + void riverSetPhysX(); + bool checkRiverCollide(); + void plotRiver(); + void scrollRiver(); + void scrollRiver1(); + void setRiverPan(); +public: + River(AmazonEngine *vm); + + void river(); + void mWhileDownRiver(); + + void synchronize(Common::Serializer &s); +}; + +class Ant: public AmazonManager { +private: + Direction _antDirection; + Direction _pitDirection; + int _antCel; + int _torchCel; + int _pitCel; + int _stabCel; + Common::Point _antPos; + bool _antDieFl; + bool _antEatFl; + bool _stabFl; + Common::Point _pitPos; + + void plotTorchSpear(int indx, const int *&buf); + void plotPit(int indx, const int *&buf); + int antHandleRight(int indx, const int *&buf); + int antHandleLeft(int indx, const int *&buf); + int antHandleStab(int indx, const int *&buf); +public: + Ant(AmazonEngine *vm); + + void doAnt(); +}; + +class InactivePlayer : public ImageEntry { +public: + SpriteResource *_altSpritesPtr; +}; + +} // End of namespace Amazon + +} // End of namespace Access + +#endif /* ACCESS_AMAZON_LOGIC_H */ diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp index ede7ab58e2..c9b63a9108 100644 --- a/engines/access/amazon/amazon_player.cpp +++ b/engines/access/amazon/amazon_player.cpp @@ -77,7 +77,7 @@ void AmazonPlayer::load() { _diagUpWalkMax = 5; _diagDownWalkMin = 0; _diagDownWalkMax = 5; - _game->_guard._position = Common::Point(56, 190); + _game->_guard.setPosition(Common::Point(56, 190)); } } diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 05e234aefc..0ae7ef0718 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1776,6 +1776,68 @@ const int HELP1COORDS[2][4] = { { 76, 129, 168, 183 }, { 187, 240, 168, 183 } }; +const int RIVER1OBJ[23][4] = { + { 18, -77, 0, 30 }, + { 18, -325, 0, 20 }, + { 18, -450, 0, 15 }, + { 18, -1250, 0, 25 }, + { 19, -130, 0, 20 }, + { 19, -410, 0, 15 }, + { 19, -710, 0, 25 }, + { 19, -1510, 0, 20 }, + { 20, -350, 0, 30 }, + { 20, -695, 0, 25 }, + { 20, -990, 0, 20 }, + { 20, -1300, 0, 25 }, + { 20, -1600, 0, 30 }, + { 21, -370, 0, 20 }, + { 21, -650, 0, 30 }, + { 21, -1215, 0, 40 }, + { 21, -1815, 0, 35 }, + { 22, -380, 0, 25 }, + { 22, -720, 0, 35 }, + { 22, -1020, 0, 30 }, + { 22, -1170, 0, 25 }, + { 22, -1770, 0, 35 }, + { 23, -500, 63, 20 } +}; + +const int CAST_END_OBJ[26][4] = { + { 0, 118, 210, 10 }, + { 1, 38, 250, 10 }, + { 2, 38, 280, 10 }, + { 3, 38, 310, 10 }, + { 4, 38, 340, 10 }, + { 5, 38, 370, 10 }, + { 6, 38, 400, 10 }, + { 7, 38, 430, 10 }, + { 8, 38, 460, 10 }, + { 9, 38, 490, 10 }, + { 10, 38, 520, 10 }, + { 11, 38, 550, 10 }, + { 12, 38, 580, 10 }, + { 13, 38, 610, 10 }, + { 14, 38, 640, 10 }, + { 15, 38, 670, 10 }, + { 16, 38, 700, 10 }, + { 17, 38, 730, 10 }, + { 18, 38, 760, 10 }, + { 19, 38, 790, 10 }, + { 20, 95, 820, 10 }, + { 21, 94, 850, 10 }, + { 22, 96, 880, 10 }, + { 23, 114, 910, 10 }, + { 24, 114, 940, 10 }, + { 25, 110, 970, 10 } +}; + +const int CAST_END_OBJ1[4][4] = { + { 0, 40, 1100, 10 }, + { 2, 11, 1180, 10 }, + { 1, 154, 1180, 10 }, + { 3, 103, 1300, 10 } +}; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 6d94e6a359..61659d30d4 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -128,6 +128,12 @@ extern RiverStruct ENDRIVER2[1]; extern RiverStruct *RIVEROBJECTTBL[6]; extern const int HELP1COORDS[2][4]; +extern const int RIVER1OBJ[23][4]; + +extern const int CAST_END_OBJ[26][4]; + +extern const int CAST_END_OBJ1[4][4]; + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index ca0d7bf341..14514c2c7c 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -205,7 +205,8 @@ void AmazonRoom::walkCursor() { // the Exit icon wgeb the cursor is already a walk cursor EventsManager &events = *_vm->_events; - if (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS) { + if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && + events._normalMouse != CURSOR_CROSSHAIRS)) { events._normalMouse = CURSOR_CROSSHAIRS; events.setCursor(CURSOR_CROSSHAIRS); _selectCommand = -1; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 58491250ad..d6a57d7919 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -33,28 +33,6 @@ namespace Amazon { AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _game = (AmazonEngine *)_vm; - - _xTrack = 0; - _yTrack = 0; - _zTrack = 0; - _xCam = 0; - _yCam = 0; - _zCam = 0; - _CHICKENOUTFLG = false; - - _pNumObj = 0; - for (int i = 0; i < 32; i++) { - _pImgNum[i] = 0; - _pObject[i] = nullptr; - _pObjX[i] = 0; - _pObjY[i] = 0; - _pObjZ[i] = 0; - } - - for (int i = 0; i < 16; i++) { - _pObjXl[i] = 0; - _pObjYl[i] = 0; - } } void AmazonScripts::cLoop() { @@ -227,662 +205,31 @@ void AmazonScripts::mWhile2() { } while (_vm->_flags[52] == 4); } -void AmazonScripts::initJWalk2() { - const int JUNGLE1OBJ[7][4] = { - {2, 470, 0, 20}, - {0, 290, 0, 50}, - {1, 210, 0, 40}, - {0, 500, 0, 30}, - {1, 550, 0, 20}, - {0, 580, 0, 60}, - {1, 650, 0, 30} - }; - _vm->_screen->fadeOut(); - _vm->_events->hideCursor(); - _vm->_screen->clearScreen(); - _vm->_buffer2.clearBuffer(); - _vm->_screen->setBufferScan(); - - _vm->_screen->_scrollX = _vm->_screen->_scrollY; - _vm->_screen->_scrollCol = _vm->_screen->_scrollRow; - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - _vm->_screen->fadeIn(); - // KEYFL = 0; - - _game->_plane._xCount = 2; - _vm->_player->_scrollAmount = 5; - _xTrack = -10; - _yTrack = _zTrack = 0; - _xCam = 480; - _yCam = 0; - _zCam = 80; - - _game->_timers[24]._timer = 1; - _game->_timers[24]._initTm = 1; - ++_game->_timers[24]._flag; - - _pNumObj = 7; - for (int i = 0; i < _pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[24]; - _pImgNum[i] = JUNGLE1OBJ[i][0]; - _pObjX[i] = JUNGLE1OBJ[i][1]; - _pObjY[i] = JUNGLE1OBJ[i][2]; - _pObjZ[i] = JUNGLE1OBJ[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } - - _jCnt[0] = 0; - _jCnt[1] = 3; - _jCnt[2] = 5; - - _jungleX[0] = 50; - _jungleX[1] = 16; - _jungleX[2] = 93; -} - -void AmazonScripts::jungleMove() { - const static int jungleY[3] = {27, 30, 29}; - int count = 1; - int frameOffset = 0; - - if (!_vm->_timers[0]._flag) { - ++_vm->_timers[0]._flag; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - - for (int i = 0; i < 3; ++i) { - int newJCnt = (_jCnt[i] + 1) % 8; - _jCnt[i] = newJCnt; - _jungleX[i] += 5; - } - - frameOffset = 4; - count = (_game->_allenFlag != 1) ? 2 : 3; - } - - for (int i = 0; i < count; ++i) { - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[24]; - ie._frameNumber = _jCnt[i] + frameOffset; - ie._position = Common::Point(_jungleX[i], jungleY[i]); - ie._offsetY = jungleY[i]; - - _vm->_images.addToList(ie); - frameOffset += 8; - } -} - -void AmazonScripts::mWhileJWalk2() { - Screen &screen = *_vm->_screen; - - initJWalk2(); - - while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { - _vm->_images.clear(); - _vm->_events->_vbCount = 6; - _pImgNum[0] = _game->_plane._xCount; - - jungleMove(); - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } - - if (_game->_plane._xCount == 2) - ++_game->_plane._xCount; - else - --_game->_plane._xCount; - - pan(); - scrollJWalk(); - - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); - } - } - - _vm->_events->showCursor(); -} - -void AmazonScripts::doFlyCell() { - Plane &plane = _game->_plane; - SpriteResource *sprites = _vm->_objectsTable[15]; - - if (plane._pCount <= 40) { - _vm->_buffer2.plotImage(sprites, 3, Common::Point(70, 74)); - } else if (plane._pCount <= 80) { - _vm->_buffer2.plotImage(sprites, 6, Common::Point(70, 74)); - } else if (plane._pCount <= 120) { - _vm->_buffer2.plotImage(sprites, 2, Common::Point(50, 76)); - } else if (plane._pCount <= 160) { - _vm->_buffer2.plotImage(sprites, 14, Common::Point(63, 78)); - } else if (plane._pCount <= 200) { - _vm->_buffer2.plotImage(sprites, 5, Common::Point(86, 74)); - } else if (plane._pCount <= 240) { - _vm->_buffer2.plotImage(sprites, 0, Common::Point(103, 76)); - } else if (plane._pCount <= 280) { - _vm->_buffer2.plotImage(sprites, 4, Common::Point(119, 77)); - } else { - _vm->_buffer2.plotImage(sprites, 1, Common::Point(111, 77)); - } - - if (plane._planeCount == 11 || plane._planeCount == 12) - ++plane._position.y; - else if (plane._planeCount >= 28) - --plane._position.y; - - _vm->_buffer2.plotImage(sprites, 7, plane._position); - _vm->_buffer2.plotImage(sprites, 8 + plane._propCount, Common::Point( - plane._position.x + 99, plane._position.y + 10)); - _vm->_buffer2.plotImage(sprites, 11 + plane._propCount, Common::Point( - plane._position.x + 104, plane._position.y + 18)); - - if (++plane._planeCount >= 30) - plane._planeCount = 0; - if (++plane._propCount >= 3) - plane._propCount = 0; - - ++plane._xCount; - if (plane._xCount == 1) - ++plane._position.x; - else - plane._xCount = 0; -} - -void AmazonScripts::doFallCell() { - if (_vm->_scaleI <= 20) - return; - - SpriteFrame *frame = _vm->_objectsTable[20]->getFrame(_game->_plane._planeCount / 6); - Common::Rect r(115, 11, 115 + _vm->_screen->_scaleTable1[frame->w], - 11 + _vm->_screen->_scaleTable1[frame->h]); - _vm->_buffer2.sPlotF(frame, r); - - _vm->_scaleI -= 3; - _vm->_scale = _vm->_scaleI; - _vm->_screen->setScaleTable(_vm->_scale); - ++_game->_plane._xCount; - if (_game->_plane._xCount == 5) - return; - _game->_plane._xCount = 0; - if (_game->_plane._planeCount == 18) - _game->_plane._planeCount = 0; - else - _game->_plane._planeCount += 6; -} - -void AmazonScripts::pan() { - _zCam += _zTrack; - _xCam += _xTrack; - int tx = (_xTrack << 8) / _zCam; - _yCam += _yTrack; - int ty = (_yTrack << 8) / _zCam; - - if (_vm->_timers[24]._flag != 1) { - ++_vm->_timers[24]._flag; - for (int i = 0; i < _pNumObj; i++) { - _pObjZ[i] += _zTrack; - _pObjXl[i] += (_pObjZ[i] * tx) & 0xff; - _pObjX[i] += ((_pObjZ[i] * tx) >> 8) + (_pObjXl[i] >> 8); - _pObjXl[i] &= 0xff; - - _pObjYl[i] += (_pObjZ[i] * ty) & 0xff; - _pObjY[i] += ((_pObjZ[i] * ty) >> 8) + (_pObjYl[i] >> 8); - _pObjYl[i] &= 0xff; - } - } - - for (int i = 0; i < _pNumObj; i++) { - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._position = Common::Point(_pObjX[i], _pObjY[i]); - ie._offsetY = 255; - ie._spritesPtr = _pObject[i]; - ie._frameNumber = _pImgNum[i]; - - _vm->_images.addToList(ie); - } -} - -void AmazonScripts::scrollFly() { - _vm->copyBF1BF2(); - _vm->_newRects.clear(); - doFlyCell(); - _vm->copyRects(); - _vm->copyBF2Vid(); -} - -void AmazonScripts::scrollFall() { - _vm->copyBF1BF2(); - _vm->_newRects.clear(); - doFallCell(); - _vm->copyRects(); - _vm->copyBF2Vid(); -} - -void AmazonScripts::scrollJWalk() { - _vm->copyBF1BF2(); - _vm->_newRects.clear(); - _game->plotList(); - _vm->copyRects(); - _vm->copyBF2Vid(); -} - -void AmazonScripts::mWhileFly() { - Screen &screen = *_vm->_screen; - Player &player = *_vm->_player; - EventsManager &events = *_vm->_events; - Plane &plane = _game->_plane; - - events.hideCursor(); - screen.clearScreen(); - screen.setBufferScan(); - screen.fadeOut(); - screen._scrollX = 0; - - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - screen.fadeIn(); - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - - // KEYFLG = 0; - - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; - player._rawPlayer = Common::Point(0, 0); - player._scrollAmount = 1; - - plane._pCount = 0; - plane._planeCount = 0; - plane._propCount = 0; - plane._xCount = 0; - plane._position = Common::Point(20, 29); - - while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { - events._vbCount = 4; - screen._scrollX += player._scrollAmount; - - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; - - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } - - scrollFly(); - ++plane._pCount; - - while (!_vm->shouldQuit() && events._vbCount > 0) { - // To be rewritten when NEWTIMER is done - events.checkForNextFrameCounter(); - _vm->_sound->playSound(0); - - events.pollEventsAndWait(); - } - } - - events.showCursor(); -} - -void AmazonScripts::mWhileFall() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - - events.hideCursor(); - screen.clearScreen(); - screen.setBufferScan(); - screen.fadeOut(); - screen._scrollX = 0; - - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - screen.fadeIn(); - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - - // KEYFLG = 0; - - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; - _vm->_player->_scrollAmount = 3; - _vm->_scaleI = 255; - - _game->_plane._xCount = 0; - _game->_plane._planeCount = 0; - - while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { - events._vbCount = 4; - screen._scrollX += _vm->_player->_scrollAmount; - - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; - - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } - - scrollFall(); - - while (!_vm->shouldQuit() && events._vbCount > 0) { - events.pollEventsAndWait(); - } - } - - events.showCursor(); -} - -void AmazonScripts::mWhileJWalk() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - Player &player = *_vm->_player; - - static const int JUNGLE_OBJ[7][4] = { - {2, 77, 0, 40}, - {0, 290, 0, 50}, - {1, 210, 0, 70}, - {0, 50, 0, 30}, - {1, 70, 0, 20}, - {0, -280, 0, 60}, - {1, -150, 0, 30}, - }; - - screen.fadeOut(); - events.hideCursor(); - screen.clearScreen(); - _vm->_buffer2.clearBuffer(); - screen.setBufferScan(); - screen._scrollX = 0; - - // Build the initial jungle scene and fade it in - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - screen.fadeIn(); - - // Set up the player to walk horizontally - player._xFlag = 1; - player._yFlag = 0; - player._moveTo.x = 160; - player._playerMove = true; - - _game->_plane._xCount = 2; - _xTrack = 10; - _yTrack = _zTrack = 0; - _xCam = 480; - _yCam = 0; - _zCam = 80; - - TimerEntry *te = &_vm->_timers[24]; - te->_initTm = te->_timer = 1; - te->_flag++; - - _pNumObj = 7; - for (int i = 0; i < _pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[24]; - _pImgNum[i] = JUNGLE_OBJ[i][0]; - _pObjX[i] = JUNGLE_OBJ[i][1]; - _pObjY[i] = JUNGLE_OBJ[i][2]; - _pObjZ[i] = JUNGLE_OBJ[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } - - while (!_vm->shouldQuit() && !events.isKeyMousePressed() && (player._xFlag != 2)) { - _vm->_images.clear(); - events._vbCount = 6; - - _pImgNum[0] = _game->_plane._xCount; - if (_game->_plane._xCount == 2) - ++_game->_plane._xCount; - else - --_game->_plane._xCount; - - player.checkMove(); - player.checkScroll(); - pan(); - scrollJWalk(); - - while (!_vm->shouldQuit() && events._vbCount > 0) { - events.pollEventsAndWait(); - } - } - - _vm->_images.clear(); - events.showCursor(); -} - -void AmazonScripts::mWhileDoOpen() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - - screen.setBufferScan(); - events.hideCursor(); - screen.forceFadeOut(); - _game->_skipStart = false; - if (_vm->_conversation != 2) { - // Cutscene at start of chapter 1 - screen.setPanel(3); - _game->startChapter(1); - _game->establishCenter(0, 1); - } - - Resource *data = _vm->_files->loadFile(1, 0); - _vm->_objectsTable[1] = new SpriteResource(_vm, data); - delete data; - - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(1, 2); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - - // Load animation data - _vm->_animation->freeAnimationData(); - Resource *animResource = _vm->_files->loadFile(1, 1); - _vm->_animation->loadAnimations(animResource); - delete animResource; - - _xTrack = 8; - _yTrack = -3; - _zTrack = 0; - _xCam = _yCam = 0; - _zCam = 270; - _vm->_timers[24]._timer = _vm->_timers[24]._initTm = 1; - ++_vm->_timers[24]._flag; - _vm->_timers.updateTimers(); - - _pNumObj = 10; - for (int i = 0; i < _pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[1]; - _pImgNum[i] = OPENING_OBJS[i][0]; - _pObjX[i] = OPENING_OBJS[i][1]; - _pObjY[i] = OPENING_OBJS[i][2]; - _pObjZ[i] = OPENING_OBJS[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } - - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - Animation *anim = _vm->_animation->setAnimation(0); - _vm->_animation->setAnimTimer(anim); - anim = _vm->_animation->setAnimation(1); - _vm->_animation->setAnimTimer(anim); - _vm->_sound->newMusic(10, 0); - - bool startFl = false; - while (!_vm->shouldQuit()) { - _vm->_images.clear(); - _vm->_animation->animate(0); - _vm->_animation->animate(1); - pan(); - _vm->_buffer2.copyFrom(_vm->_buffer1); - _vm->_newRects.clear(); - _game->plotList(); - _vm->copyBlocks(); - if (!startFl) { - startFl = true; - screen.forceFadeIn(); - } - - events.pollEventsAndWait(); - - if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { - _game->_skipStart = true; - _vm->_sound->newMusic(10, 1); - - events.debounceLeft(); - events.zeroKeys(); - break; - } - - if (_xCam > 680) { - events._vbCount = 125; - - while(!_vm->shouldQuit() && !events.isKeyMousePressed() && events._vbCount > 0) { - events.pollEventsAndWait(); - } - break; - } - } - - events.showCursor(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - - _vm->freeCells(); - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - _vm->_numAnimTimers = 0; - _vm->_images.clear(); - - if (_vm->_conversation == 2) { - // Cutscene at end of Chapter 6 - Resource *spriteData = _vm->_files->loadFile(28, 37); - _vm->_objectsTable[28] = new SpriteResource(_vm, spriteData); - delete spriteData; - - _vm->_animation->freeAnimationData(); - animResource = _vm->_files->loadFile(28, 38); - _vm->_animation->loadAnimations(animResource); - delete animResource; - } -} - -void AmazonScripts::scrollRiver() { - _vm->copyBF1BF2(); - _vm->_newRects.clear(); - _vm->_buffer2.plotImage(_vm->_objectsTable[33], 0, Common::Point(66, 30)); - _vm->plotList(); - _vm->copyRects(); - _vm->copyBF2Vid(); -} - -void AmazonScripts::mWhileDownRiver() { - _vm->_events->hideCursor(); - _vm->_screen->setDisplayScan(); - _vm->_screen->clearScreen(); - _vm->_screen->savePalette(); - - _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_screen->restorePalette(); - _vm->_screen->setPalette(); - _vm->_screen->setBufferScan(); - _vm->_screen->_scrollX = 0; - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - - _vm->_player->_scrollAmount = 2; - _vm->_destIn = &_vm->_buffer2; - _xTrack = -7; - _yTrack = _zTrack = 0; - _xCam = _yCam = 0; - _zCam = 80; - - _game->_timers[24]._timer = 1; - _game->_timers[24]._initTm = 1; - ++_game->_timers[24]._flag; - - _pNumObj = 14; - for (int i = 0; i <_pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[33]; - _pImgNum[i] = DOWNRIVEROBJ[i][0]; - _pObjX[i] = DOWNRIVEROBJ[i][1]; - _pObjY[i] = DOWNRIVEROBJ[i][2]; - _pObjZ[i] = DOWNRIVEROBJ[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } - - _game->_timers[3]._timer = 200; - _game->_timers[3]._initTm = 200; - ++_game->_timers[3]._flag; - _game->_timers[4]._timer = 350; - _game->_timers[4]._initTm = 350; - ++_game->_timers[4]._flag; - - while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) { - _vm->_images.clear(); - _vm->_events->_vbCount = 6; - - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; - _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); - } - - pan(); - scrollRiver(); - - if (!_game->_timers[3]._flag) { - ++_game->_timers[3]._flag; - _vm->_sound->playSound(1); - } else if (!_game->_timers[4]._flag) { - ++_game->_timers[4]._flag; - _vm->_sound->playSound(0); - } - - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); - } - } - - _vm->_events->showCursor(); -} - void AmazonScripts::mWhile(int param1) { switch(param1) { case 1: mWhile1(); break; case 2: - mWhileFly(); + _game->_plane.mWhileFly(); break; case 3: - mWhileFall(); + _game->_plane.mWhileFall(); break; case 4: - mWhileJWalk(); + _game->_jungle.mWhileJWalk(); break; case 5: - mWhileDoOpen(); + _game->_opening.mWhileDoOpen(); break; case 6: - mWhileDownRiver(); + _game->_river.mWhileDownRiver(); break; case 7: mWhile2(); break; case 8: - mWhileJWalk2(); + _game->_jungle.mWhileJWalk2(); break; default: break; @@ -899,143 +246,6 @@ void AmazonScripts::loadBackground(int param1, int param2) { _vm->_screen->forceFadeIn(); } -void AmazonScripts::doCast(int param1) { - static const int END_OBJ[26][4] = { - { 0, 118, 210, 10}, - { 1, 38, 250, 10}, - { 2, 38, 280, 10}, - { 3, 38, 310, 10}, - { 4, 38, 340, 10}, - { 5, 38, 370, 10}, - { 6, 38, 400, 10}, - { 7, 38, 430, 10}, - { 8, 38, 460, 10}, - { 9, 38, 490, 10}, - {10, 38, 520, 10}, - {11, 38, 550, 10}, - {12, 38, 580, 10}, - {13, 38, 610, 10}, - {14, 38, 640, 10}, - {15, 38, 670, 10}, - {16, 38, 700, 10}, - {17, 38, 730, 10}, - {18, 38, 760, 10}, - {19, 38, 790, 10}, - {20, 95, 820, 10}, - {21, 94, 850, 10}, - {22, 96, 880, 10}, - {23, 114, 910, 10}, - {24, 114, 940, 10}, - {25, 110, 970, 10} - }; - - static const int END_OBJ1[4][4] = { - {0, 40, 1100, 10}, - {2, 11, 1180, 10}, - {1, 154, 1180, 10}, - {3, 103, 1300, 10} - }; - - _vm->_screen->setDisplayScan(); - _vm->_events->hideCursor(); - _vm->_screen->forceFadeOut(); - _vm->_screen->_clipHeight = 173; - _vm->_screen->clearScreen(); - _game->_chapter = 16; - _game->tileScreen(); - _game->updateSummary(param1); - _vm->_screen->setPanel(3); - _game->_chapter = 14; - - Resource *spriteData = _vm->_files->loadFile(91, 0); - _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); - delete spriteData; - spriteData = _vm->_files->loadFile(91, 1); - _vm->_objectsTable[1] = new SpriteResource(_vm, spriteData); - delete spriteData; - - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(58, 1); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - - _xTrack = 0; - _yTrack = -6; - _zTrack = 0; - _xCam = _yCam = 0; - _zCam = 60; - - _game->_timers[24]._timer = 1; - _game->_timers[24]._initTm = 1; - ++_game->_timers[24]._flag; - - _pNumObj = 26; - for (int i = 0; i < _pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[0]; - _pImgNum[i] = END_OBJ[i][0]; - _pObjX[i] = END_OBJ[i][1]; - _pObjY[i] = END_OBJ[i][2]; - _pObjZ[i] = END_OBJ[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } - - _pNumObj = 4; - for (int i = 0; i < _pNumObj; i++) { - _pObject[26 + i] = _vm->_objectsTable[1]; - _pImgNum[26 + i] = END_OBJ1[i][0]; - _pObjX[26 + i] = END_OBJ1[i][1]; - _pObjY[26 + i] = END_OBJ1[i][2]; - _pObjZ[26 + i] = END_OBJ1[i][3]; - _pObjXl[26 + i] = _pObjYl[26 + i] = 0; - } - - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - _vm->_numAnimTimers = 0; - - _vm->_sound->newMusic(58, 0); - _vm->_screen->forceFadeIn(); - - while (!_vm->shouldQuit()) { - _vm->_images.clear(); - pan(); - _vm->_buffer2.copyFrom(_vm->_buffer1); - _vm->_newRects.clear(); - _game->plotList(); - _vm->copyBlocks(); - - _vm->_events->pollEvents(); - if (_vm->_events->isKeyMousePressed()) - break; - - if (_yCam < -7550) { - _vm->_events->_vbCount = 50; - - while(!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); - } - - while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone()) - _vm->_events->pollEventsAndWait(); - - break; - } - } - - _vm->_sound->newMusic(58, 1); - _vm->_events->showCursor(); - - _vm->freeCells(); - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - _vm->_numAnimTimers = 0; - _vm->_images.clear(); - _vm->_screen->forceFadeOut(); - - _vm->quitGame(); - _vm->_events->pollEvents(); -} - void AmazonScripts::setInactive() { _game->_rawInactiveX = _vm->_player->_rawPlayer.x; _game->_rawInactiveY = _vm->_player->_rawPlayer.y; @@ -1044,243 +254,6 @@ void AmazonScripts::setInactive() { mWhile(_game->_rawInactiveY); } -void AmazonScripts::plotTorchSpear(int indx, const int *&buf) { - int idx = indx; - - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[62]; - ie._frameNumber = buf[(idx / 2)]; - ie._position = Common::Point(_game->_pitPos.x + buf[(idx / 2) + 1], _game->_pitPos.y + buf[(idx / 2) + 2]); - ie._offsetY = 255; - _vm->_images.addToList(ie); -} - -void AmazonScripts::plotPit(int indx, const int *&buf) { - int idx = indx; - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[62]; - ie._frameNumber = buf[(idx / 2)]; - ie._position = Common::Point(_game->_pitPos.x, _game->_pitPos.y); - ie._offsetY = _game->_pitPos.y; - _vm->_images.addToList(ie); - - _vm->_player->_rawPlayer = _game->_pitPos; - if (_vm->_inventory->_inv[76]._value == 1) { - idx = _game->_torchCel; - buf = Amazon::TORCH; - _vm->_timers[14]._flag = 1; - idx += 6; - if (buf[idx / 2] == -1) - idx = 0; - _game->_torchCel = idx; - plotTorchSpear(idx, buf); - } else if (!_game->_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { - idx = 0; - buf = Amazon::SPEAR; - plotTorchSpear(idx, buf); - } -} - -int AmazonScripts::antHandleRight(int indx, const int *&buf) { - int retval = indx; - if (_game->_pitDirection == NONE) { - _game->_pitDirection = UP; - _game->_pitPos.y = 127; - } - retval = _game->_pitCel; - buf = Amazon::PITWALK; - if (_game->_pitPos.x < 230) { - if (retval == 0) { - retval = 48; - _game->_pitPos.y = 127; - } - retval -= 6; - _game->_pitPos.x -= buf[(retval / 2) + 1]; - _game->_pitPos.y -= buf[(retval / 2) + 2]; - _game->_pitCel = retval; - } - return retval; -} - -int AmazonScripts::antHandleLeft(int indx, const int *&buf) { - int retval = indx; - if (_game->_pitDirection == UP) { - _game->_pitDirection = NONE; - _game->_pitPos.y = 127; - } - retval = _game->_pitCel; - buf = Amazon::PITWALK; - retval += 6; - if (buf[retval / 2] == -1) { - retval = 0; - _game->_pitPos.y = 127; - } - _game->_pitPos.x += buf[(retval / 2) + 1]; - _game->_pitPos.y += buf[(retval / 2) + 2]; - _game->_pitCel = retval; - - return retval; -} - -int AmazonScripts::antHandleStab(int indx, const int *&buf) { - int retval = indx; - if (_vm->_inventory->_inv[78]._value != 1) { - if (_game->_stabFl) { - buf = Amazon::PITSTAB; - retval = _game->_stabCel; - if (_game->_timers[13]._flag == 0) { - _game->_timers[13]._flag = 1; - retval += 6; - if (Amazon::PITSTAB[retval] == -1) { - _game->_stabFl = false; - _game->_pitCel = 0; - _game->_pitPos.y = 127; - retval = 0; - buf = Amazon::PITWALK; - } else { - _game->_pitPos.x += buf[(retval / 2) + 1]; - _game->_pitPos.y += buf[(retval / 2) + 2]; - _game->_pitCel = retval; - } - } - } else { - _game->_stabFl = true; - _game->_pitCel = 0; - retval = 0; - _game->_stabCel = 0; - int dist = _game->_pitPos.x - _game->_antPos.x; - if (_game->_antEatFl && !_game->_antDieFl && (dist <= 80)) { - _game->_antDieFl = true; - _game->_antCel = 0; - _game->_antPos.y = 123; - _vm->_sound->playSound(1); - } - } - } - return retval; -} - -void AmazonScripts::ANT() { - _game->_antDirection = NONE; - if (_game->_aniFlag != 1) { - _game->_aniFlag = 1; - _game->_antCel = 0; - _game->_torchCel = 0; - _game->_pitCel = 0; - - _game->_timers[15]._timer = 16; - _game->_timers[15]._initTm = 16; - _game->_timers[15]._flag = 1; - - _game->_timers[13]._timer = 5; - _game->_timers[13]._initTm = 5; - _game->_timers[13]._flag = 1; - - _game->_timers[14]._timer = 10; - _game->_timers[14]._initTm = 10; - _game->_timers[14]._flag = 1; - - _game->_antPos = Common::Point(-40, 123); - _game->_antDieFl = _game->_antEatFl = false; - _game->_stabFl = false; - _game->_pitPos = Common::Point(_vm->_player->_rawPlayer.x, 127); - } - - const int *buf = nullptr; - if (_game->_antDieFl) { - buf = Amazon::ANTDIE; - } else if (_game->_antEatFl) { - buf = Amazon::ANTEAT; - } else if (_game->_antPos.x > 120 && _vm->_flags[198] == 1) { - _game->_antEatFl = true; - _vm->_flags[235] = 1; - _game->_antCel = 0; - buf = Amazon::ANTEAT; - } else { - buf = Amazon::ANTWALK; - if (_vm->_inventory->_inv[76]._value == 1) - _game->_antDirection = UP; - } - - int idx = _game->_antCel; - if (_game->_timers[15]._flag == 0) { - _game->_timers[15]._flag = 1; - if (_game->_antDirection == UP) { - if (_game->_antPos.x > 10) { - if (idx == 0) - idx = 36; - else - idx -= 6; - - _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); - _game->_antCel = idx; - } - } else { - idx += 6; - if (buf[(idx / 2)] != -1) { - _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); - _game->_antCel = idx; - } else if (!_game->_antDieFl) { - idx = 0; - _game->_antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); - _game->_antCel = idx; - } else { - idx -= 6; - if (_game->_flags[200] == 0) - _game->_flags[200] = 1; - } - } - } - - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[61]; - ie._frameNumber = buf[(idx / 2)]; - ie._position = Common::Point(_game->_antPos.x, _game->_antPos.y); - ie._offsetY = _game->_antPos.y - 70; - _vm->_images.addToList(ie); - _game->_antCel = idx; - - if (_game->_flags[196] != 1) { - idx = _game->_pitCel; - if (_game->_stabFl == 1) { - idx = antHandleStab(idx, buf); - } else { - buf = Amazon::PITWALK; - if (_game->_timers[13]._flag == 0) { - _game->_timers[13]._flag = 1; - _vm->_events->pollEvents(); - if (_vm->_events->_leftButton) { - Common::Point pt = _vm->_events->calcRawMouse(); - if (pt.x < _game->_pitPos.x) - idx = antHandleLeft(idx, buf); - else if (pt.x > _game->_pitPos.x) - idx = antHandleRight(idx, buf); - } else { - buf = Amazon::PITWALK; - if (_vm->_player->_playerDirection == UP) - idx = antHandleStab(idx, buf); - else if (_vm->_player->_playerDirection == LEFT) - idx = antHandleLeft(idx, buf); - else if (_vm->_player->_playerDirection == RIGHT) - idx = antHandleRight(idx, buf); - } - } - } - plotPit(idx, buf); - } - - if (!_game->_antDieFl) { - int dist = _game->_pitPos.x - _game->_antPos.x; - if ((_game->_antEatFl && (dist <= 45)) || (!_game->_antEatFl && (dist <= 80))) { - _game->_flags[199] = 1; - _game->_aniFlag = 0; - } - } -} - void AmazonScripts::boatWalls(int param1, int param2) { if (param1 == 1) _vm->_room->_plotter._walls[42] = Common::Rect(96, 27, 96 + 87, 27 + 42); @@ -1339,473 +312,6 @@ void AmazonScripts::plotInactive() { _vm->_images.addToList(_game->_inactive); } -void AmazonScripts::setRiverPan() { - static const int RIVER1OBJ[23][4] = { - {18, -77, 0, 30}, - {18, -325, 0, 20}, - {18, -450, 0, 15}, - {18, -1250, 0, 25}, - {19, -130, 0, 20}, - {19, -410, 0, 15}, - {19, -710, 0, 25}, - {19, -1510, 0, 20}, - {20, -350, 0, 30}, - {20, -695, 0, 25}, - {20, -990, 0, 20}, - {20, -1300, 0, 25}, - {20, -1600, 0, 30}, - {21, -370, 0, 20}, - {21, -650, 0, 30}, - {21, -1215, 0, 40}, - {21, -1815, 0, 35}, - {22, -380, 0, 25}, - {22, -720, 0, 35}, - {22, -1020, 0, 30}, - {22, -1170, 0, 25}, - {22, -1770, 0, 35}, - {23, -500, 63, 20} - }; - - int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; - - _xTrack = 9; - _yTrack = _zTrack = 0; - _xCam = 160; - _yCam = 0; - _zCam = 80; - - _game->_timers[24]._timer = 1; - _game->_timers[24]._initTm = 1; - ++_game->_timers[24]._flag; - - _pNumObj = 23; - for (int i = 0; i < _pNumObj; i++) { - _pObject[i] = _vm->_objectsTable[45]; - _pImgNum[i] = RIVER1OBJ[i][0]; - _pObjX[i] = RIVER1OBJ[i][1] + delta; - _pObjY[i] = RIVER1OBJ[i][2]; - _pObjZ[i] = RIVER1OBJ[i][3]; - _pObjXl[i] = _pObjYl[i] = 0; - } -} - -void AmazonScripts::initRiver() { - static const int RIVERVXTBL[3] = {6719, 7039, 8319}; - - _vm->_events->centerMousePos(); - _vm->_events->restrictMouse(); - _vm->_screen->setDisplayScan(); - _vm->_screen->clearScreen(); - _vm->_screen->savePalette(); - _vm->_screen->forceFadeOut(); - - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); - - _vm->_screen->restorePalette(); - _vm->_screen->setBufferScan(); - _vm->_destIn = &_vm->_buffer2; - _vm->_room->roomMenu(); - - if (_game->_saveRiver) { - // Restoring a savegame, so set properties from saved fields - _vm->_screen->_scrollRow = _vm->_rScrollRow; - _vm->_screen->_scrollCol = _vm->_rScrollCol; - _vm->_screen->_scrollX = _vm->_rScrollX; - _vm->_screen->_scrollY = _vm->_rScrollY; - } else { - // Set initial scene state - _vm->_screen->_scrollRow = 0; - _vm->_screen->_scrollCol = 140; - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollY = 0; - } - - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - _vm->_screen->forceFadeIn(); - - if (_game->_saveRiver) { - // Restore draw rects from savegame - _vm->_oldRects.resize(_vm->_rOldRectCount); - _vm->_newRects.resize(_vm->_rNewRectCount); - // KEYFLG = _vm->_rKeyFlag - } else { - // Reset draw rects - _vm->_oldRects.clear(); - _vm->_newRects.clear(); - // KEYFLG = 0 - } - - _vm->_player->_scrollAmount = 2; - setRiverPan(); - _game->_timers[3]._timer = 1; - _game->_timers[3]._initTm = 1; - ++_game->_timers[3]._flag; - - _game->_canoeFrame = 0; - _game->_mapPtr = (const byte *)MAPTBL[_game->_riverFlag] + 1; - if (_game->_saveRiver) { - _game->_mapPtr--; - _game->_mapPtr += _game->_mapOffset; - } else { - _screenVertX = RIVERVXTBL[_game->_riverFlag] - 320; - _game->_canoeLane = 3; - _game->_hitCount = 0; - _game->_hitSafe = 0; - _game->_canoeYPos = 71; - } - - _game->_riverIndex = _game->_riverFlag; - _game->_topList = RIVEROBJECTTBL[_game->_riverIndex]; - updateObstacles(); - riverSetPhysX(); - _game->_canoeDir = 0; - _game->_deathFlag = 0; - _game->_deathCount = 0; - - _game->_timers[11]._timer = 1200; - _game->_timers[11]._initTm = 1200; - ++_game->_timers[11]._flag; - _game->_timers[12]._timer = 1500; - _game->_timers[12]._initTm = 1500; - ++_game->_timers[12]._flag; - - _game->_maxHits = 2 - _game->_riverFlag; - _game->_saveRiver = false; -} - -void AmazonScripts::resetPositions() { - riverSetPhysX(); - int val = (_vm->_screen->_scrollCol + 1 - _game->_oldScrollCol) * 16; - if (val > 256) { - val &= 0x7F; - val |= 0x80; - } - - for (int i = 0; i < _pNumObj; i++) - _pObjX[i] += val; -} - -void AmazonScripts::checkRiverPan() { - int val = (_vm->_screen->_scrollCol + 20) * 16; - - for (int i = 0; i < _pNumObj; i++) { - if (_pObjX[i] < val) - return; - } - - setRiverPan(); -} - -bool AmazonScripts::riverJumpTest() { - if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) { - int val = _game->_mapPtr[0]; - ++_game->_mapPtr; - if (val == 0xFF) - return true; - _game->_oldScrollCol = _vm->_screen->_scrollCol; - - if (val == 0) { - _vm->_screen->_scrollCol = 139; - _vm->_screen->_scrollX = 14; - _vm->_room->buildScreen(); - resetPositions(); - return false; - } - } else if (_vm->_screen->_scrollCol == 105) { - int val1 = _game->_mapPtr[1]; - int val2 = _game->_mapPtr[2]; - _game->_mapPtr += 3; - if (_game->_canoeLane < 3) { - if (val1 != 0) { - _game->_deathFlag = true; - _game->_deathCount = 300; - _game->_deathType = val2; - } - } else { - if (val1 != 1) { - _game->_deathFlag = true; - _game->_deathCount = 300; - _game->_deathType = val2; - } - _game->_oldScrollCol = _vm->_screen->_scrollCol; - _vm->_screen->_scrollCol = 44; - _vm->_screen->_scrollX = 14; - _vm->_room->buildScreen(); - resetPositions(); - return false; - } - } - - _vm->_screen->_scrollX = 14; - --_vm->_screen->_scrollCol; - _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); - checkRiverPan(); - return false; -} - -void AmazonScripts::riverSound() { - if (_game->_timers[11]._flag == 0) { - ++_game->_timers[11]._flag; - _vm->_sound->playSound(2); - } - - if (_game->_timers[12]._flag == 0) { - ++_game->_timers[12]._flag; - _vm->_sound->playSound(3); - } - - if ((_xCam >= 1300) && (_xCam <= 1320)) - _vm->_sound->playSound(1); -} - -void AmazonScripts::moveCanoe() { - Screen &screen = *_vm->_screen; - EventsManager &events = *_vm->_events; - Common::Point pt = events.calcRawMouse(); - - // Do an event polling - _vm->_canSaveLoad = true; - events.pollEvents(); - _vm->_canSaveLoad = false; - if (_vm->_room->_function == FN_CLEAR1) - return; - - if (_game->_canoeDir) { - // Canoe movement in progress - moveCanoe2(); - } else { - if (events._leftButton && pt.y >= 140) { - if (pt.x < RMOUSE[8][0]) { - // Disk icon wasn't clicked - printString(BAR_MESSAGE); - } else { - // Clicked on the Disc icon - _game->_saveRiver = true; - _game->_rScrollRow = screen._scrollRow; - _game->_rScrollCol = screen._scrollCol; - _game->_rScrollX = screen._scrollX; - _game->_rScrollY = screen._scrollY; - _game->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; - - // Show the ScummVM menu - _vm->_room->handleCommand(9); - - if (_vm->_room->_function != FN_CLEAR1) { - _game->_saveRiver = false; - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); - } - } - } else if ((events._leftButton && pt.y <= _game->_canoeYPos) || - (!events._leftButton && _vm->_player->_move == UP)) { - // Move canoe up - if (_game->_canoeLane > 0) { - _game->_canoeDir = -1; - _game->_canoeMoveCount = 0; - - moveCanoe2(); - } - } else if (events._leftButton || _vm->_player->_move == DOWN) { - // Move canoe down - if (_game->_canoeLane < 7) { - _game->_canoeDir = 1; - _game->_canoeMoveCount = 0; - - moveCanoe2(); - } - } - } -} - -void AmazonScripts::moveCanoe2() { - _game->_canoeYPos += _game->_canoeDir; - - if (++_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } -} - -void AmazonScripts::updateObstacles() { - RiverStruct *cur; - for (cur = _game->_topList; cur < RIVEROBJECTTBL[_game->_riverIndex + 1]; ++cur) { - int val = cur->_field1 + cur->_field3 - 1; - if (val < _screenVertX) - break; - - if (cur->_field3 < (_game->_screenVirtX + 319)) { - _game->_topList = cur; - _game->_botList = cur; - - while (cur < RIVEROBJECTTBL[_game->_riverIndex + 1]) { - ++cur; - val = cur->_field1 + cur->_field3 - 1; - if (val < _screenVertX || (cur->_field3 >= (_game->_screenVirtX + 319))) - break; - - _game->_botList = cur; - } - - return; - } - } - - cur = _game->_topList; - cur--; - _game->_botList = cur; -} - -void AmazonScripts::riverSetPhysX() { - int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; - RiverStruct *cur = _game->_topList; - while (cur <= _game->_botList) { - cur[0]._field5 = val - (_screenVertX - cur[0]._field3); - ++cur; - } -} - -bool AmazonScripts::checkRiverCollide() { - if (_game->_hitSafe) - return false; - - _game->_canoeVXPos = _screenVertX + 170; - - for (RiverStruct *si = _game->_topList; si <= _game->_botList; ++si) { - if (si[0]._lane < _game->_canoeLane) - continue; - - if ((si[0]._lane == _game->_canoeLane) || (si[0]._lane == _game->_canoeLane + 1)) { - if (si[0]._field1 + si[0]._field3 - 1 >= _game->_canoeVXPos) { - if (_game->_canoeVXPos + 124 >= si[0]._field3) { - _vm->_sound->playSound(4); - return true; - } - } - } - } - return false; -} - -void AmazonScripts::plotRiver() { - if (_vm->_timers[3]._flag == 0) { - ++_vm->_timers[3]._flag; - if (_game->_canoeFrame == 12) - _game->_canoeFrame = 0; - else - ++_game->_canoeFrame; - } - - ImageEntry ie; - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[45]; - ie._frameNumber = _game->_canoeFrame; - ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; - ie._position.y = _game->_canoeYPos - 41; - ie._offsetY = 41; - _vm->_images.addToList(ie); - - RiverStruct *cur = _game->_topList; - while (cur <= _game->_botList) { - if (cur[0]._id != -1) { - ie._flags = IMGFLAG_UNSCALED; - ie._spritesPtr = _vm->_objectsTable[45]; - ie._frameNumber = 0; - ie._position.x = cur[0]._field5; - int val = (cur[0]._lane * 5) + 56; - ie._position.y = val - cur[0]._field8; - ie._offsetY = cur[0]._field8; - _vm->_images.addToList(ie); - } - ++cur; - } -} - -void AmazonScripts::scrollRiver1() { - _vm->copyBF1BF2(); - _vm->_newRects.clear(); - plotRiver(); - _vm->plotList(); - _vm->copyRects(); - _vm->copyBF2Vid(); -} - -void AmazonScripts::RIVER() { - static const int RIVERDEATH[5] = {22, 23, 24, 25, 26}; - - initRiver(); - _vm->_events->showCursor(); - - while (!_vm->shouldQuit()) { - _vm->_events->_vbCount = 4; - -// int bx = _vm->_player->_scrollAmount - _screenVertX; - if (_vm->_screen->_scrollX == 0) { - _vm->_sound->midiRepeat(); - if (riverJumpTest()) { - _CHICKENOUTFLG = false; - return; - } - } else { - _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; - } - - if (_CHICKENOUTFLG) { - _CHICKENOUTFLG = false; - return; - } - - _vm->_images.clear(); - _vm->_animation->animate(0); - - riverSound(); - pan(); - moveCanoe(); - - if (_vm->_room->_function != FN_CLEAR1) { - updateObstacles(); - riverSetPhysX(); - bool checkCollide = checkRiverCollide(); - if (_game->_hitSafe != 0) - _game->_hitSafe -= 2; - - if (checkCollide) { - cmdDead(RIVERDEATH[0]); - return; - } - - if (_game->_deathFlag) { - _game->_deathCount--; - if (_game->_deathCount == 0) { - cmdDead(RIVERDEATH[_game->_deathType]); - return; - } - } - - // Scroll the river - scrollRiver1(); - - // Allow time for new scrolled river position to be shown - _vm->_canSaveLoad = true; - while (!_vm->shouldQuit() && _vm->_room->_function == FN_NONE && - _vm->_events->_vbCount > 0) { - _vm->_events->pollEventsAndWait(); - } - _vm->_canSaveLoad = false; - } - - if (_vm->_room->_function == FN_CLEAR1) { - _endFlag = true; - _returnCode = 0; - _CHICKENOUTFLG = false; - break; - } - } -} - void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { case 1: @@ -1815,7 +321,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { loadBackground(param1, param2); break; case 3: - doCast(param1); + _game->_cast.doCast(param1); break; case 4: setInactive(); @@ -1824,7 +330,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { mWhile(param1); break; case 9: - _game->_guard.guard(); + _game->_guard.doGuard(); break; case 10: _vm->_sound->newMusic(param1, param2); @@ -1833,10 +339,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { plotInactive(); break; case 13: - RIVER(); + _game->_river.river(); break; case 14: - ANT(); + _game->_ant.doAnt(); break; case 15: boatWalls(param1, param2); diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index bd47e9ce5b..968d51e2c4 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -35,72 +35,15 @@ class AmazonEngine; class AmazonScripts: public Scripts { private: AmazonEngine *_game; - int _xTrack; - int _yTrack; - int _zTrack; - int _xCam; - int _yCam; - int _zCam; - int _pNumObj; - int _screenVertX; - bool _CHICKENOUTFLG; - - SpriteResource *_pObject[32]; - int _pImgNum[32]; - int _pObjX[32]; - int _pObjY[32]; - int _pObjZ[32]; - int _pObjXl[32]; - int _pObjYl[32]; - - int _jCnt[3]; - int _jungleX[3]; - - void pan(); - protected: virtual void executeSpecial(int commandIndex, int param1, int param2); virtual void executeCommand(int commandIndex); - void doFlyCell(); - void doFallCell(); - void scrollFly(); - void scrollFall(); - void scrollJWalk(); void cLoop(); void mWhile1(); void mWhile2(); - void mWhileFly(); - void mWhileFall(); - void mWhileJWalk(); - void initJWalk2(); - void jungleMove(); - void mWhileJWalk2(); - void scrollRiver(); - void mWhileDownRiver(); void mWhile(int param1); - void plotTorchSpear(int indx, const int *&buf); - void plotPit(int indx, const int *&buf); - int antHandleRight(int indx, const int *&buf); - int antHandleLeft(int indx, const int *&buf); - int antHandleStab(int indx, const int *&buf); - void ANT(); - void doCast(int param1); void loadBackground(int param1, int param2); - void initRiver(); - void resetPositions(); - void checkRiverPan(); - bool riverJumpTest(); - void riverSound(); - void moveCanoe(); - void moveCanoe2(); - void updateObstacles(); - void riverSetPhysX(); - bool checkRiverCollide(); - void plotRiver(); - void scrollRiver1(); - void setRiverPan(); - void RIVER(); void plotInactive(); void setInactive(); void boatWalls(int param1, int param2); @@ -114,8 +57,6 @@ protected: void CMDRETFLASH(); public: AmazonScripts(AccessEngine *vm); - - void mWhileDoOpen(); }; } // End of namespace Amazon diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h index a99ece67cf..e46b2bb0fd 100644 --- a/engines/access/martian/martian_game.h +++ b/engines/access/martian/martian_game.h @@ -63,6 +63,8 @@ protected: * Play the game */ virtual void playGame(); + + virtual void dead(int deathId) {} public: MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/module.mk b/engines/access/module.mk index 98464014ba..b6961aeca9 100644 --- a/engines/access/module.mk +++ b/engines/access/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS := \ sound.o \ video.o \ amazon/amazon_game.o \ + amazon/amazon_logic.o \ amazon/amazon_player.o \ amazon/amazon_resources.o \ amazon/amazon_room.o \ diff --git a/engines/access/player.cpp b/engines/access/player.cpp index b945b76600..2313ed266e 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -751,7 +751,7 @@ bool Player::scrollDown() { bool Player::scrollLeft() { Screen &screen = *_vm->_screen; _scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold); - if ((_vm->_rScrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { + if ((screen._scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { _scrollEnd = 2; screen._scrollX = 0; _scrollFlag = true; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 72650f472c..add461eb81 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -784,76 +784,9 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::cmdDead(int deathId) { - _vm->_events->hideCursor(); - _vm->_screen->forceFadeOut(); - cmdFreeSound(); - - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_files->loadFile(98, 44), 1)); - - _vm->_screen->clearScreen(); - _vm->_screen->setPanel(3); - - if (deathId != 10) { - _vm->_sound->newMusic(62, 0); - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(94, 0); - _vm->_files->_setPaletteFlag = true; - _vm->_buffer2.copyFrom(*_vm->_screen); - - for (int i = 0; i < 3; ++i) { - _vm->_sound->playSound(0); - _vm->_screen->forceFadeIn(); - _vm->_sound->playSound(0); - _vm->_screen->forceFadeOut(); - } - _vm->freeCells(); - - // Load the cell list for the death screen - DeathEntry &de = _vm->_deaths[deathId]; - Common::Array cells; - cells.push_back(_vm->_deaths._cells[de._screenId]); - _vm->loadCells(cells); - - _vm->_screen->setDisplayScan(); - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(&_vm->_buffer2, 94, 1); - _vm->_screen->setIconPalette(); - - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(105, 25)); - _vm->_buffer2.copyTo(_vm->_screen); - _vm->_screen->forceFadeIn(); - - _vm->_fonts._charSet._hi = 10; - _vm->_fonts._charSet._lo = 1; - _vm->_fonts._charFor._lo = 55; - _vm->_fonts._charFor._hi = 255; - _vm->_screen->_maxChars = 46; - _vm->_screen->_printOrg = Common::Point(20, 155); - _vm->_screen->_printStart = Common::Point(20, 155); - - Common::String &msg = de._msg; - _vm->_printEnd = 180; - _vm->printText(_vm->_screen, msg); - _vm->_screen->forceFadeOut(); - - _vm->_sound->newMusic(0, 1); - _vm->_events->showCursor(); - _vm->_room->clearRoom(); - _vm->freeChar(); - - warning("TODO: restart game"); - _vm->quitGame(); - _vm->_events->pollEvents(); - } else { - _vm->quitGame(); - _vm->_events->pollEvents(); - } -} - void Scripts::cmdDead() { int deathId = _data->readByte(); - cmdDead(deathId); + _vm->dead(deathId); } void Scripts::cmdFadeOut() { diff --git a/engines/access/scripts.h b/engines/access/scripts.h index b6a3dc4dd9..098fd4f322 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -47,11 +47,6 @@ protected: virtual void executeSpecial(int commandIndex, int param1, int param2) = 0; virtual void executeCommand(int commandIndex); - /** - * Print a given message to the screen in a bubble box - */ - void printString(const Common::String &msg); - /** * Read a null terminated string from the script */ @@ -120,7 +115,6 @@ protected: void cmdPlayerOff(); void cmdPlayerOn(); void cmdDead(); - void cmdDead(int deathId); void cmdFadeOut(); void cmdEndVideo(); public: @@ -146,6 +140,11 @@ public: void findNull(); + /** + * Print a given message to the screen in a bubble box + */ + void printString(const Common::String &msg); + // Script commands that need to be public void cmdFreeSound(); void cmdRetPos(); -- cgit v1.2.3 From 01e9214c7d98f1b64597d943b35ac8efb3069c47 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 21:12:59 -0500 Subject: ACCESS: Only save river scene fields when actually in the river scene I'm still not happy everything needed is being synchronised, so this way we can work on it further without upsetting other Amazon saves --- engines/access/amazon/amazon_logic.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index cae3373ea8..547026560c 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1546,22 +1546,24 @@ void River::river() { } } void River::synchronize(Common::Serializer &s) { - s.syncAsSint16LE(_canoeLane); - s.syncAsSint16LE(_canoeYPos); - s.syncAsSint16LE(_hitCount); - s.syncAsSint16LE(_riverIndex); - s.syncAsSint16LE(_hitSafe); - s.syncAsUint16LE(_rScrollRow); - s.syncAsUint16LE(_rScrollCol); - s.syncAsSint16LE(_rScrollX); - s.syncAsSint16LE(_rScrollY); - s.syncAsUint16LE(_rOldRectCount); - s.syncAsUint16LE(_rNewRectCount); - s.syncAsUint16LE(_rKeyFlag); - s.syncAsUint16LE(_mapOffset); - s.syncAsUint16LE(_screenVirtX); - warning("TODO: s.syncAsSint16LE(_topList);"); - warning("TODO: s.syncAsSint16LE(_botList);"); + if (_vm->_player->_roomNumber == 45) { + s.syncAsSint16LE(_canoeLane); + s.syncAsSint16LE(_canoeYPos); + s.syncAsSint16LE(_hitCount); + s.syncAsSint16LE(_riverIndex); + s.syncAsSint16LE(_hitSafe); + s.syncAsUint16LE(_rScrollRow); + s.syncAsUint16LE(_rScrollCol); + s.syncAsSint16LE(_rScrollX); + s.syncAsSint16LE(_rScrollY); + s.syncAsUint16LE(_rOldRectCount); + s.syncAsUint16LE(_rNewRectCount); + s.syncAsUint16LE(_rKeyFlag); + s.syncAsUint16LE(_mapOffset); + s.syncAsUint16LE(_screenVirtX); + warning("TODO: s.syncAsSint16LE(_topList);"); + warning("TODO: s.syncAsSint16LE(_botList);"); + } } /*------------------------------------------------------------------------*/ -- cgit v1.2.3 From 21519194348425f988f9a78c3748bc596bb1ac61 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 21:19:43 -0500 Subject: ACCESS: Remove accidental resetting of _vm pointers --- engines/access/amazon/amazon_logic.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 547026560c..8df28ae85e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -616,7 +616,6 @@ void Jungle::scrollJWalk() { /*------------------------------------------------------------------------*/ Guard::Guard(AmazonEngine *vm): PannedScene(vm) { - _vm = nullptr; _guardCel = 0; _gCode1 = _gCode2 = 0; _xMid = _yMid = 0; @@ -1004,7 +1003,6 @@ void Cast::doCast(int param1) { /*------------------------------------------------------------------------*/ River::River(AmazonEngine *vm): PannedScene(vm) { - _vm = nullptr; _CHICKENOUTFLG = false; _rScrollRow = 0; _rScrollCol = 0; -- cgit v1.2.3 From b478b05df2ac62425fc01ea7ad13899c50404166 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 22:12:45 -0500 Subject: ACCESS: Move _saveRiver from engine to River class --- engines/access/amazon/amazon_game.cpp | 1 - engines/access/amazon/amazon_game.h | 1 - engines/access/amazon/amazon_logic.cpp | 15 +++++++++------ engines/access/amazon/amazon_logic.h | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 55876b5692..b6c538542e 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -43,7 +43,6 @@ AccessEngine(syst, gameDesc), _skipStart = false; _charSegSwitch = false; - _saveRiver = false; _oldTitleChapter = _chapter = 0; _updateChapter = -1; _rawInactiveX = 0; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index b09c96d263..d697b16c93 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -86,7 +86,6 @@ public: InactivePlayer _inactive; bool _charSegSwitch; bool _skipStart; - bool _saveRiver; // Fields that are mapped to flags int &_guardLocation; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 8df28ae85e..3ecb20d974 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1013,6 +1013,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _rKeyFlag = 0; _mapOffset = 0; _screenVirtX = 0; + _saveRiver = false; } void River::setRiverPan() { @@ -1058,7 +1059,7 @@ void River::initRiver() { _vm->_destIn = &_vm->_buffer2; _vm->_room->roomMenu(); - if (_vm->_saveRiver) { + if (_saveRiver) { // Restoring a savegame, so set properties from saved fields _vm->_screen->_scrollRow = _rScrollRow; _vm->_screen->_scrollCol = _rScrollCol; @@ -1076,7 +1077,7 @@ void River::initRiver() { _vm->copyBF2Vid(); _vm->_screen->forceFadeIn(); - if (_vm->_saveRiver) { + if (_saveRiver) { // Restore draw rects from savegame _vm->_oldRects.resize(_rOldRectCount); _vm->_newRects.resize(_rNewRectCount); @@ -1096,7 +1097,7 @@ void River::initRiver() { _canoeFrame = 0; _mapPtr = (const byte *)MAPTBL[_vm->_riverFlag] + 1; - if (_vm->_saveRiver) { + if (_saveRiver) { _mapPtr--; _mapPtr += _mapOffset; } else { @@ -1123,7 +1124,7 @@ void River::initRiver() { ++_vm->_timers[12]._flag; _vm->_maxHits = 2 - _vm->_riverFlag; - _vm->_saveRiver = false; + _saveRiver = false; } void River::resetPositions() { @@ -1234,7 +1235,7 @@ void River::moveCanoe() { _vm->_scripts->printString(BAR_MESSAGE); } else { // Clicked on the Disc icon - _vm->_saveRiver = true; + _saveRiver = true; _rScrollRow = screen._scrollRow; _rScrollCol = screen._scrollCol; _rScrollX = screen._scrollX; @@ -1245,7 +1246,7 @@ void River::moveCanoe() { _vm->_room->handleCommand(9); if (_vm->_room->_function != FN_CLEAR1) { - _vm->_saveRiver = false; + _saveRiver = false; _vm->_room->buildScreen(); _vm->copyBF2Vid(); } @@ -1561,6 +1562,8 @@ void River::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_screenVirtX); warning("TODO: s.syncAsSint16LE(_topList);"); warning("TODO: s.syncAsSint16LE(_botList);"); + + _saveRiver = s.isLoading(); } } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 4d5e274388..46b3c7047c 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -151,6 +151,7 @@ private: RiverStruct *_topList; RiverStruct *_botList; int _canoeDir; + bool _saveRiver; // Saved fields int _canoeLane; -- cgit v1.2.3 From ec44c0504f7dc37f7d38894b5a7f764aa17721cc Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 22:23:27 -0500 Subject: ACCESS: Remove unneeded dummy field syncs from serializer --- engines/access/amazon/amazon_game.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index b6c538542e..fb884897df 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -969,11 +969,7 @@ void AmazonEngine::dead(int deathId) { void AmazonEngine::synchronize(Common::Serializer &s) { AccessEngine::synchronize(s); - int dummy = 0; - s.syncAsSint16LE(_chapter); - s.syncAsSint16LE(dummy); - s.syncAsSint16LE(dummy); s.syncAsSint16LE(_rawInactiveX); s.syncAsSint16LE(_rawInactiveY); s.syncAsSint16LE(_inactiveYOff); -- cgit v1.2.3 From 01124c3378f03f9fa0c7c7618879caff5926f735 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 22:26:07 -0500 Subject: ACCESS: Moved help table data from AccessEngine to AmazonEngine --- engines/access/access.cpp | 11 ----------- engines/access/access.h | 4 ---- engines/access/amazon/amazon_game.cpp | 14 +++++++++++++- engines/access/amazon/amazon_game.h | 4 ++++ engines/access/amazon/amazon_scripts.cpp | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 1ab40a2de7..2d25ae9d00 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -84,12 +84,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _establishMode = 0; _establishGroup = 0; _establishCtrlTblOfs = 0; - Common::fill(&_help1[0], &_help1[366], 0); - Common::fill(&_help2[0], &_help2[366], 0); - Common::fill(&_help1[0], &_help3[366], 0); - _helpTbl[0] = _help1; - _helpTbl[1] = _help2; - _helpTbl[2] = _help3; _travel = 0; _ask = 0; _lastTime = g_system->getMillis(); @@ -507,11 +501,6 @@ void AccessEngine::synchronize(Common::Serializer &s) { for (int i = 0; i < 256; ++i) s.syncAsUint16LE(_flags[i]); - for (int i = 0; i < 366; ++i) { - s.syncAsByte(_help1[i]); - s.syncAsByte(_help2[i]); - s.syncAsByte(_help3[i]); - } s.syncAsUint16LE(_travel); s.syncAsUint16LE(_ask); diff --git a/engines/access/access.h b/engines/access/access.h index 0942c9eb8e..165ae83b28 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -207,10 +207,6 @@ public: uint32 _newTime; uint32 _newDate; int _flags[256]; - byte _help1[366]; - byte _help2[366]; - byte _help3[366]; - byte *_helpTbl[3]; int _travel; int _ask; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index fb884897df..8958239a15 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -53,7 +53,13 @@ AccessEngine(syst, gameDesc), Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); - + Common::fill(&_help1[0], &_help1[366], 0); + Common::fill(&_help2[0], &_help2[366], 0); + Common::fill(&_help1[0], &_help3[366], 0); + _helpTbl[0] = _help1; + _helpTbl[1] = _help2; + _helpTbl[2] = _help3; + _chapterCells.push_back(CellIdent(0, 96, 17)); _inactive._spritesPtr = nullptr; _inactive._altSpritesPtr = nullptr; @@ -973,8 +979,14 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_rawInactiveX); s.syncAsSint16LE(_rawInactiveY); s.syncAsSint16LE(_inactiveYOff); + for (int i = 0; i < 100; ++i) s.syncAsSint16LE(_esTabTable[i]); + for (int i = 0; i < 366; ++i) { + s.syncAsByte(_help1[i]); + s.syncAsByte(_help2[i]); + s.syncAsByte(_help3[i]); + } _river.synchronize(s); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index d697b16c93..016ddf40f0 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -86,6 +86,10 @@ public: InactivePlayer _inactive; bool _charSegSwitch; bool _skipStart; + byte _help1[366]; + byte _help2[366]; + byte _help3[366]; + byte *_helpTbl[3]; // Fields that are mapped to flags int &_guardLocation; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index d6a57d7919..4c3b83869c 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -448,7 +448,7 @@ void AmazonScripts::cmdSetHelp() { int arrayId = (_data->readUint16LE() && 0xFF) - 1; int helpId = _data->readUint16LE() && 0xFF; - byte *help = _vm->_helpTbl[arrayId]; + byte *help = _game->_helpTbl[arrayId]; help[helpId] = 1; if (_vm->_useItem == 0) { -- cgit v1.2.3 From eadaf534865c674bbe11588818539c34da278e0e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 22:28:06 -0500 Subject: ACCESS: Remove unused _travel and _ask fields --- engines/access/access.cpp | 6 ------ engines/access/access.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2d25ae9d00..6161336de7 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -84,8 +84,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _establishMode = 0; _establishGroup = 0; _establishCtrlTblOfs = 0; - _travel = 0; - _ask = 0; _lastTime = g_system->getMillis(); _curTime = 0; _narateFile = 0; @@ -501,10 +499,6 @@ void AccessEngine::synchronize(Common::Serializer &s) { for (int i = 0; i < 256; ++i) s.syncAsUint16LE(_flags[i]); - - s.syncAsUint16LE(_travel); - s.syncAsUint16LE(_ask); - for (int i = 0; i < 100; ++i) s.syncAsByte(_establishTable[i]); diff --git a/engines/access/access.h b/engines/access/access.h index 165ae83b28..47f5b5ec06 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -207,8 +207,6 @@ public: uint32 _newTime; uint32 _newDate; int _flags[256]; - int _travel; - int _ask; bool _clearSummaryFlag; -- cgit v1.2.3 From 16a8d705baab154498cf33905655c4ed4b93b545 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 28 Nov 2014 22:42:27 -0500 Subject: ACCESS: Fix restoring game scene after using help --- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_scripts.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 8958239a15..b05bb7bb82 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -722,7 +722,7 @@ void AmazonEngine::drawHelp(const Common::String str) { _screen->setPanel(2); _screen->saveScreen(); } - _screen->setPalette(); + _screen->savePalette(); _screen->fadeOut(); _screen->clearBuffer(); if (_moreHelp == 1) { diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 4c3b83869c..e2d18141f4 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -390,8 +390,8 @@ void AmazonScripts::cmdHelp() { _game->drawHelp(helpMessage); - while(true) { - while(!_vm->shouldQuit() && !_vm->_events->_leftButton) + while (!_vm->shouldQuit()) { + while (!_vm->shouldQuit() && !_vm->_events->_leftButton) _vm->_events->pollEventsAndWait(); _vm->_events->debounceLeft(); @@ -410,21 +410,24 @@ void AmazonScripts::cmdHelp() { continue; if (choice == 1) { + // Done button selected _game->_helpLevel = 0; _game->_moreHelp = 1; _game->_useItem = 0; _vm->_events->hideCursor(); _vm->_screen->restoreScreen(); _vm->_screen->setPanel(0); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_screen->copyFrom(_vm->_buffer2); _vm->_screen->restorePalette(); _vm->_screen->setPalette(); _vm->_events->showCursor(); - free(_vm->_objectsTable[45]); + + delete _vm->_objectsTable[45]; _vm->_objectsTable[45] = nullptr; _vm->_timers.restoreTimers(); break; } else { + // More button selected if ((_game->_moreHelp == 0) || (choice != 0)) continue; ++_game->_helpLevel; -- cgit v1.2.3 From c42666f3d28519c52ac30695e175b8abb42436c7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 29 Nov 2014 14:46:15 +0100 Subject: ACCESS: Add some code for VGA mode in cmdHelp --- engines/access/amazon/amazon_scripts.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index e2d18141f4..eadcbddd2b 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -415,8 +415,14 @@ void AmazonScripts::cmdHelp() { _game->_moreHelp = 1; _game->_useItem = 0; _vm->_events->hideCursor(); - _vm->_screen->restoreScreen(); - _vm->_screen->setPanel(0); + if (_vm->_screen->_vesaMode) { + _vm->_screen->restoreScreen(); + _vm->_screen->setPanel(0); + } else { + _vm->_screen->fadeOut(); + _vm->_screen->clearBuffer(); + } + _vm->_screen->copyFrom(_vm->_buffer2); _vm->_screen->restorePalette(); _vm->_screen->setPalette(); -- cgit v1.2.3 From a8e111fae4b492c8478dd4eab239a7fa622b8833 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Nov 2014 11:53:50 -0500 Subject: ACCESS: Refactor opening scenes logic into Opening class --- engines/access/access.cpp | 1 - engines/access/access.h | 1 - engines/access/amazon/amazon_game.cpp | 311 +---------------------------- engines/access/amazon/amazon_game.h | 18 -- engines/access/amazon/amazon_logic.cpp | 324 ++++++++++++++++++++++++++++++- engines/access/amazon/amazon_logic.h | 22 ++- engines/access/amazon/amazon_scripts.cpp | 2 +- engines/access/martian/martian_game.cpp | 8 +- engines/access/martian/martian_game.h | 5 - 9 files changed, 343 insertions(+), 349 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6161336de7..bac1308b09 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -50,7 +50,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _destIn = nullptr; _current = nullptr; - _pCount = 0; _mouseMode = 0; _currentMan = 0; _currentManOld = -1; diff --git a/engines/access/access.h b/engines/access/access.h index 47f5b5ec06..af0d42302b 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -173,7 +173,6 @@ public: Common::Array _oldRects; Common::Array _extraCells; ImageEntryList _images; - int _pCount; int _mouseMode; int _currentManOld; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index b05bb7bb82..dfaba977af 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -40,7 +40,6 @@ AccessEngine(syst, gameDesc), _ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), _plane(this), _river(this) { - _skipStart = false; _charSegSwitch = false; _oldTitleChapter = _chapter = 0; @@ -92,7 +91,7 @@ void AmazonEngine::playGame() { if (_loadSaveSlot == -1) { // Do introduction - doIntroduction(); + _opening.doIntroduction(); if (shouldQuit()) return; } @@ -112,314 +111,6 @@ void AmazonEngine::playGame() { _room->doRoom(); } -void AmazonEngine::doIntroduction() { - _screen->setInitialPalettte(); - _events->setCursor(CURSOR_ARROW); - _events->showCursor(); - _screen->setPanel(0); - _screen->setPalette(); - - _events->setCursor(CURSOR_ARROW); - _events->showCursor(); - _screen->setPanel(3); - doTitle(); - - if (shouldQuit() || _skipStart) - return; - - _screen->setPanel(3); - _opening.mWhileDoOpen(); - - if (shouldQuit() || _skipStart) - return; - - doTent(); -} - -void AmazonEngine::doCredit() { - if (_pCount < 15) - return; - - if (_pCount <= 75) - _buffer2.plotImage(_objectsTable[0], 0, Common::Point(90, 35)); - else if (_pCount <= 210) - _buffer2.plotImage(_objectsTable[0], 1, Common::Point(65, 35)); - else if (_pCount <= 272) - _buffer2.plotImage(_objectsTable[0], 2, Common::Point(96, 45)); - else if (_pCount <= 334) - _buffer2.plotImage(_objectsTable[0], 3, Common::Point(68, 54)); - else if (_pCount <= 396) - _buffer2.plotImage(_objectsTable[0], 4, Common::Point(103, 54)); - else if (_pCount <= 458) { - _buffer2.plotImage(_objectsTable[0], 5, Common::Point(8, 5)); - _buffer2.plotImage(_objectsTable[0], 12, Common::Point(88, 55)); - _buffer2.plotImage(_objectsTable[0], 6, Common::Point(194, 98)); - } else if (_pCount <= 520) { - _buffer2.plotImage(_objectsTable[0], 7, Common::Point(32, 13)); - _buffer2.plotImage(_objectsTable[0], 8, Common::Point(162, 80)); - } else if (_pCount <= 580) { - _buffer2.plotImage(_objectsTable[0], 9, Common::Point(18, 15)); - _buffer2.plotImage(_objectsTable[0], 10, Common::Point(164, 81)); - } else - _buffer2.plotImage(_objectsTable[0], 11, Common::Point(106, 55)); -} - -void AmazonEngine::scrollTitle() { - copyBF1BF2(); - _newRects.clear(); - doCredit(); - copyRects(); - copyBF2Vid(); -} - -void AmazonEngine::doTitle() { - _screen->setDisplayScan(); - _destIn = &_buffer2; - - _screen->forceFadeOut(); - _events->hideCursor(); - - _sound->queueSound(0, 98, 30); - _sound->queueSound(1, 98, 8); - - _files->_setPaletteFlag = false; - _files->loadScreen(0, 3); - - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); - _screen->forceFadeIn(); - _sound->playSound(1); - - // HACK: This delay has been added so that the very first screen is visible. - // The original was using disk loading time to display it, and it's too fast - // nowadays to be visible. - _events->_vbCount = 70; - while (!shouldQuit() && _events->_vbCount > 0) { - _events->pollEvents(); - g_system->delayMillis(10); - } - - Resource *spriteData = _files->loadFile(0, 2); - _objectsTable[0] = new SpriteResource(this, spriteData); - delete spriteData; - - _sound->playSound(1); - - _files->_setPaletteFlag = false; - _files->loadScreen(0, 4); - _sound->playSound(1); - - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); - _sound->playSound(1); - - const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (_pCount = 0; _pCount < 3; ++_pCount) { - _buffer2.copyFrom(_buffer1); - int id = COUNTDOWN[_pCount * 2]; - int xp = COUNTDOWN[_pCount * 2 + 1]; - _buffer2.plotImage(_objectsTable[0], id, Common::Point(xp, 71)); - _screen->copyFrom(_buffer2); - - _events->_vbCount = 70; - while (!shouldQuit() && _events->_vbCount > 0) { - _events->pollEvents(); - g_system->delayMillis(10); - } - } - - _sound->playSound(0); - _screen->forceFadeOut(); - _events->_vbCount = 100; - while (!shouldQuit() && _events->_vbCount > 0) { - _events->pollEvents(); - g_system->delayMillis(10); - } - - _sound->freeSounds(); - delete _objectsTable[0]; - _objectsTable[0] = nullptr; - - _files->_setPaletteFlag = false; - _files->loadScreen(0, 5); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); - _screen->forceFadeIn(); - _sound->newMusic(1, 0); - _events->_vbCount = 700; - while (!shouldQuit() && (_events->_vbCount > 0) && !_events->isKeyMousePressed()) { - _events->pollEvents(); - g_system->delayMillis(10); - } - - if (_events->_rightButton) { - _skipStart = true; - _room->clearRoom(); - _events->showCursor(); - return; - } - - _sound->newMusic(1, 1); - _sound->_musicRepeat = false; - _events->zeroKeys(); - _room->loadRoom(0); - _screen->clearScreen(); - _screen->setBufferScan(); - _screen->_scrollRow = _screen->_scrollCol = 0; - _screen->_scrollX = _screen->_scrollY = 0; - _player->_rawPlayer = Common::Point(0, 0); - _screen->forceFadeOut(); - _screen->_scrollX = 0; - _room->buildScreen(); - copyBF2Vid(); - _screen->forceFadeIn(); - _oldRects.clear(); - _newRects.clear(); - // KEYFLG = 0; - _player->_scrollAmount = 1; - _pCount = 0; - - while (!shouldQuit()) { - if (!_events->isKeyMousePressed()) { - if (_events->_rightButton) - _skipStart = true; - _room->clearRoom(); - _events->showCursor(); - return; - } - - _events->_vbCount = 4; - if (_screen->_scrollCol + _screen->_vWindowWidth != _room->_playFieldWidth) { - _screen->_scrollX += _player->_scrollAmount; - - while (_screen->_scrollX >= TILE_WIDTH) { - _screen->_scrollX -= TILE_WIDTH; - ++_screen->_scrollCol; - - _buffer1.moveBufferLeft(); - _room->buildColumn(_screen->_scrollCol + _screen->_vWindowWidth, _screen->_vWindowBytesWide); - } - scrollTitle(); - ++_pCount; - - while (!shouldQuit() && (_events->_vbCount > 0)) { - _events->pollEvents(); - g_system->delayMillis(10); - } - continue; - } - - _events->_vbCount = 120; - while (!shouldQuit() && (_events->_vbCount > 0)) { - _events->pollEvents(); - g_system->delayMillis(10); - } - - while (!shouldQuit()) { - _pCount = 0; - _events->_vbCount = 3; - if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { - _room->clearRoom(); - _events->showCursor(); - return; - } - - _screen->_scrollY = _screen->_scrollY + _player->_scrollAmount; - - while (_screen->_scrollY >= TILE_HEIGHT && !shouldQuit()) { - _screen->_scrollY -= TILE_HEIGHT; - ++_screen->_scrollRow; - _buffer1.moveBufferUp(); - - // WORKAROUND: the original was using _screen->_vWindowBytesWide * _screen->_vWindowLinesTall - _room->buildRow(_screen->_scrollRow + _screen->_vWindowHeight, _screen->_vWindowLinesTall); - - if (_screen->_scrollRow + _screen->_vWindowHeight >= _room->_playFieldHeight) { - _room->clearRoom(); - _events->showCursor(); - return; - } - } - scrollTitle(); - while (!shouldQuit() && (_events->_vbCount > 0)) { - _events->pollEvents(); - g_system->delayMillis(10); - } - } - } -} - -void AmazonEngine::doTent() { - int step = 0; - _screen->setDisplayScan(); - _screen->forceFadeOut(); - _events->hideCursor(); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 39), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 14), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 15), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 16), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 31), 2)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(98, 52), 2)); - _sound->playSound(0); - - _files->_setPaletteFlag = false; - _files->loadScreen(2, 0); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); - _screen->forceFadeIn(); - - _video->setVideo(_screen, Common::Point(126, 73), FileIdent(2, 1), 10); - while (!shouldQuit() && !_video->_videoEnd) { - _video->playVideo(); - if ((_video->_videoFrame == 32) || (_video->_videoFrame == 34)) - _sound->playSound(4); - else if (_video->_videoFrame == 36) { - if (step != 2) { - _sound->playSound(2); - step = 2; - } - } else if (_video->_videoFrame == 18) { - if (step != 1) { - _sound->newMusic(73, 1); - _sound->newMusic(11, 0); - step = 1; - _sound->playSound(1); - } - } - - g_system->delayMillis(10); - _events->pollEvents(); - } - - _sound->playSound(5); - _video->setVideo(_screen, Common::Point(43, 11), FileIdent(2, 2), 10); - while (!shouldQuit() && !_video->_videoEnd) { - _video->playVideo(); - if (_video->_videoFrame == 26) { - _sound->playSound(5); - } else if (_video->_videoFrame == 15) { - if (step !=3) { - _sound->playSound(3); - step = 3; - } - } - - g_system->delayMillis(10); - _events->pollEvents(); - } - - _events->_vbCount = 200; - while (!shouldQuit() && _events->_vbCount > 0) { - _events->pollEvents(); - g_system->delayMillis(10); - } - _events->showCursor(); - _sound->newMusic(11, 1); - _sound->_soundTable.clear(); - - establishCenter(0, 4); -} - void AmazonEngine::setupGame() { // Setup timers const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 016ddf40f0..ca8287b87e 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -38,21 +38,6 @@ private: byte _tileData[1455]; Common::Array _chapterCells; - /** - * Do the game introduction - */ - void doIntroduction(); - - /** - * Do title sequence - */ - void doTitle(); - - /** - * Do tent scene of introduction - */ - void doTent(); - /** * Setup variables for the game */ @@ -67,8 +52,6 @@ private: void calcIQ(); void helpTitle(); void drawHelpText(const Common::String &msg); - void doCredit(); - void scrollTitle(); void loadEstablish(int estabIndex); void doEstablish(int screenId, int estabIndex); @@ -85,7 +68,6 @@ protected: public: InactivePlayer _inactive; bool _charSegSwitch; - bool _skipStart; byte _help1[366]; byte _help2[366]; byte _help3[366]; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 3ecb20d974..8db7e9f785 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -81,17 +81,18 @@ void PannedScene::pan() { /*------------------------------------------------------------------------*/ -Opening::Opening(AmazonEngine *vm) : PannedScene(vm) { +CampScene::CampScene(AmazonEngine *vm) : PannedScene(vm) { + _skipStart = false; } -void Opening::mWhileDoOpen() { +void CampScene::mWhileDoOpen() { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; screen.setBufferScan(); events.hideCursor(); screen.forceFadeOut(); - _vm->_skipStart = false; + _skipStart = false; if (_vm->_conversation != 2) { // Cutscene at start of chapter 1 screen.setPanel(3); @@ -159,7 +160,7 @@ void Opening::mWhileDoOpen() { events.pollEventsAndWait(); if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { - _vm->_skipStart = true; + _skipStart = true; _vm->_sound->newMusic(10, 1); events.debounceLeft(); @@ -202,6 +203,319 @@ void Opening::mWhileDoOpen() { /*------------------------------------------------------------------------*/ +Opening::Opening(AmazonEngine *vm) : CampScene(vm) { + _pCount = 0; +} + +void Opening::doIntroduction() { + _vm->_screen->setInitialPalettte(); + _vm->_events->setCursor(CURSOR_ARROW); + _vm->_events->showCursor(); + _vm->_screen->setPanel(0); + _vm->_screen->setPalette(); + + _vm->_events->setCursor(CURSOR_ARROW); + _vm->_events->showCursor(); + _vm->_screen->setPanel(3); + doTitle(); + + if (_vm->shouldQuit() || _skipStart) + return; + + _vm->_screen->setPanel(3); + mWhileDoOpen(); + + if (_vm->shouldQuit() || _skipStart) + return; + + doTent(); +} + +void Opening::doCredit() { + if (_pCount < 15) + return; + + if (_pCount <= 75) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(90, 35)); + else if (_pCount <= 210) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35)); + else if (_pCount <= 272) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); + else if (_pCount <= 334) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); + else if (_pCount <= 396) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); + else if (_pCount <= 458) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98)); + } else if (_pCount <= 520) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80)); + } else if (_pCount <= 580) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55)); +} + +void Opening::scrollTitle() { + _vm->copyBF1BF2(); + _vm->_newRects.clear(); + doCredit(); + _vm->copyRects(); + _vm->copyBF2Vid(); +} + +void Opening::doTitle() { + _vm->_screen->setDisplayScan(); + + _vm->_screen->forceFadeOut(); + _vm->_events->hideCursor(); + + _vm->_sound->queueSound(0, 98, 30); + _vm->_sound->queueSound(1, 98, 8); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 3); + + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->forceFadeIn(); + _vm->_sound->playSound(1); + + // HACK: This delay has been added so that the very first screen is visible. + // The original was using disk loading time to display it, and it's too fast + // nowadays to be visible. + _vm->_events->_vbCount = 70; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + Resource *spriteData = _vm->_files->loadFile(0, 2); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; + + _vm->_sound->playSound(1); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 4); + _vm->_sound->playSound(1); + + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_sound->playSound(1); + + const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; + for (_pCount = 0; _pCount < 3; ++_pCount) { + _vm->_buffer2.copyFrom(_vm->_buffer1); + int id = COUNTDOWN[_pCount * 2]; + int xp = COUNTDOWN[_pCount * 2 + 1]; + _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); + _vm->_screen->copyFrom(_vm->_buffer2); + + _vm->_events->_vbCount = 70; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + } + + _vm->_sound->playSound(0); + _vm->_screen->forceFadeOut(); + _vm->_events->_vbCount = 100; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + _vm->_sound->freeSounds(); + delete _vm->_objectsTable[0]; + _vm->_objectsTable[0] = nullptr; + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 5); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->forceFadeIn(); + _vm->_sound->newMusic(1, 0); + _vm->_events->_vbCount = 700; + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + if (_vm->_events->_rightButton) { + _skipStart = true; + _vm->_room->clearRoom(); + _vm->_events->showCursor(); + return; + } + + _vm->_sound->newMusic(1, 1); + _vm->_sound->_musicRepeat = false; + _vm->_events->zeroKeys(); + _vm->_room->loadRoom(0); + _vm->_screen->clearScreen(); + _vm->_screen->setBufferScan(); + _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; + _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; + _vm->_player->_rawPlayer = Common::Point(0, 0); + _vm->_screen->forceFadeOut(); + _vm->_screen->_scrollX = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + _vm->_screen->forceFadeIn(); + _vm->_oldRects.clear(); + _vm->_newRects.clear(); + // KEYFLG = 0; + _vm->_player->_scrollAmount = 1; + _pCount = 0; + + while (!_vm->shouldQuit()) { + if (!_vm->_events->isKeyMousePressed()) { + if (_vm->_events->_rightButton) + _skipStart = true; + _vm->_room->clearRoom(); + _vm->_events->showCursor(); + return; + } + + _vm->_events->_vbCount = 4; + if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) { + _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + + while (_vm->_screen->_scrollX >= TILE_WIDTH) { + _vm->_screen->_scrollX -= TILE_WIDTH; + ++_vm->_screen->_scrollCol; + + _vm->_buffer1.moveBufferLeft(); + _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + } + scrollTitle(); + ++_pCount; + + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + continue; + } + + _vm->_events->_vbCount = 120; + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + + while (!_vm->shouldQuit()) { + _pCount = 0; + _vm->_events->_vbCount = 3; + if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) { + _vm->_room->clearRoom(); + _vm->_events->showCursor(); + return; + } + + _vm->_screen->_scrollY = _vm->_screen->_scrollY + _vm->_player->_scrollAmount; + + while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_screen->_scrollY -= TILE_HEIGHT; + ++_vm->_screen->_scrollRow; + _vm->_buffer1.moveBufferUp(); + + // WORKAROUND: the original was using _vm->_screen->_vWindowBytesWide * _vm->_screen->_vWindowLinesTall + _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall); + + if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) { + _vm->_room->clearRoom(); + _vm->_events->showCursor(); + return; + } + } + scrollTitle(); + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + } + } +} + +void Opening::doTent() { + int step = 0; + _vm->_screen->setDisplayScan(); + _vm->_screen->forceFadeOut(); + _vm->_events->hideCursor(); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 39), 1)); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 14), 1)); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 15), 1)); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 16), 1)); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 31), 2)); + _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 52), 2)); + _vm->_sound->playSound(0); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(2, 0); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->forceFadeIn(); + + _vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10); + while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { + _vm->_video->playVideo(); + if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34)) + _vm->_sound->playSound(4); + else if (_vm->_video->_videoFrame == 36) { + if (step != 2) { + _vm->_sound->playSound(2); + step = 2; + } + } else if (_vm->_video->_videoFrame == 18) { + if (step != 1) { + _vm->_sound->newMusic(73, 1); + _vm->_sound->newMusic(11, 0); + step = 1; + _vm->_sound->playSound(1); + } + } + + g_system->delayMillis(10); + _vm->_events->pollEvents(); + } + + _vm->_sound->playSound(5); + _vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10); + while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { + _vm->_video->playVideo(); + if (_vm->_video->_videoFrame == 26) { + _vm->_sound->playSound(5); + } else if (_vm->_video->_videoFrame == 15) { + if (step !=3) { + _vm->_sound->playSound(3); + step = 3; + } + } + + g_system->delayMillis(10); + _vm->_events->pollEvents(); + } + + _vm->_events->_vbCount = 200; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { + _vm->_events->pollEvents(); + g_system->delayMillis(10); + } + _vm->_events->showCursor(); + _vm->_sound->newMusic(11, 1); + _vm->_sound->_soundTable.clear(); + + _vm->establishCenter(0, 4); +} + +/*------------------------------------------------------------------------*/ + Plane::Plane(AmazonEngine *vm): PannedScene(vm) { _pCount = 0; _planeCount = 0; @@ -400,7 +714,7 @@ void Plane::mWhileFall() { /*------------------------------------------------------------------------*/ -Jungle::Jungle(AmazonEngine *vm) : PannedScene(vm) { +Jungle::Jungle(AmazonEngine *vm) : CampScene(vm) { for (int i = 0; i < JUNGLE_SIZE; ++i) { _jCnt[i] = _jungleX[i] = -1; } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 46b3c7047c..c2752af77b 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -70,13 +70,29 @@ public: void pan(); }; -class Opening: public PannedScene { +class CampScene : public PannedScene { +protected: + bool _skipStart; public: - Opening(AmazonEngine *vm); + CampScene(AmazonEngine *vm); void mWhileDoOpen(); }; +class Opening: public CampScene { +private: + int _pCount; + + void doTitle(); + void doCredit(); + void scrollTitle(); + void doTent(); +public: + Opening(AmazonEngine *vm); + + void doIntroduction(); +}; + class Plane: public PannedScene { public: int _pCount; @@ -95,7 +111,7 @@ public: }; #define JUNGLE_SIZE 3 -class Jungle: public PannedScene { +class Jungle: public CampScene { private: void initJWalk2(); void jungleMove(); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index eadcbddd2b..f38c80c915 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -220,7 +220,7 @@ void AmazonScripts::mWhile(int param1) { _game->_jungle.mWhileJWalk(); break; case 5: - _game->_opening.mWhileDoOpen(); + _game->_jungle.mWhileDoOpen(); break; case 6: _game->_river.mWhileDownRiver(); diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 81a8ffdf4d..e534b6cc03 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -79,7 +79,7 @@ void MartianEngine::doIntroduction() { return; if (!_skipStart) { - doTent(); + //doTent(); if (shouldQuit()) return; } @@ -89,6 +89,7 @@ void MartianEngine::doIntroduction() { } void MartianEngine::doTitle() { + /* _screen->setDisplayScan(); _destIn = &_buffer2; @@ -129,16 +130,13 @@ void MartianEngine::doTitle() { // TODO: More to do delete _objectsTable[0]; + */ } void MartianEngine::doOpening() { warning("TODO doOpening"); } -void MartianEngine::doTent() { - warning("TODO doTent"); -} - void MartianEngine::setupGame() { // Setup timers diff --git a/engines/access/martian/martian_game.h b/engines/access/martian/martian_game.h index e46b2bb0fd..a83b67a288 100644 --- a/engines/access/martian/martian_game.h +++ b/engines/access/martian/martian_game.h @@ -48,11 +48,6 @@ private: */ void doOpening(); - /** - * Do tent scene of introduction - */ - void doTent(); - /** * Setup variables for the game */ -- cgit v1.2.3 From d37593d5c1008995b292a62f473a2a8dfa322cc1 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 29 Nov 2014 12:19:41 -0500 Subject: ACCESS: Replaced delayMilli calls to use pollEventsAndWait --- engines/access/amazon/amazon_logic.cpp | 61 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 8db7e9f785..c62ca5786e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -284,14 +284,14 @@ void Opening::doTitle() { _vm->_screen->forceFadeIn(); _vm->_sound->playSound(1); - // HACK: This delay has been added so that the very first screen is visible. - // The original was using disk loading time to display it, and it's too fast + // WORKAROUND: This delay has been added to replace original game delay that + // came from loading resources, since nowadays it would be too fast to be visible // nowadays to be visible. _vm->_events->_vbCount = 70; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); + if (_vm->shouldQuit()) + return; Resource *spriteData = _vm->_files->loadFile(0, 2); _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); @@ -308,7 +308,7 @@ void Opening::doTitle() { _vm->_sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (_pCount = 0; _pCount < 3; ++_pCount) { + for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { _vm->_buffer2.copyFrom(_vm->_buffer1); int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; @@ -316,19 +316,19 @@ void Opening::doTitle() { _vm->_screen->copyFrom(_vm->_buffer2); _vm->_events->_vbCount = 70; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); } + if (_vm->shouldQuit()) + return; _vm->_sound->playSound(0); _vm->_screen->forceFadeOut(); _vm->_events->_vbCount = 100; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); + if (_vm->shouldQuit()) + return; _vm->_sound->freeSounds(); delete _vm->_objectsTable[0]; @@ -342,8 +342,7 @@ void Opening::doTitle() { _vm->_sound->newMusic(1, 0); _vm->_events->_vbCount = 700; while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } if (_vm->_events->_rightButton) { @@ -397,17 +396,14 @@ void Opening::doTitle() { ++_pCount; while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } continue; } _vm->_events->_vbCount = 120; - while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) + _vm->_events->pollEventsAndWait(); while (!_vm->shouldQuit()) { _pCount = 0; @@ -435,10 +431,8 @@ void Opening::doTitle() { } } scrollTitle(); - while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0)) + _vm->_events->pollEventsAndWait(); } } } @@ -481,8 +475,7 @@ void Opening::doTent() { } } - g_system->delayMillis(10); - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); } _vm->_sound->playSound(5); @@ -498,15 +491,13 @@ void Opening::doTent() { } } - g_system->delayMillis(10); - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); } _vm->_events->_vbCount = 200; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) { - _vm->_events->pollEvents(); - g_system->delayMillis(10); - } + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); + _vm->_events->showCursor(); _vm->_sound->newMusic(11, 1); _vm->_sound->_soundTable.clear(); -- cgit v1.2.3 From 63bcd2ebcbe8063e5009fb27ed2d1aaa08bf28a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 29 Nov 2014 23:43:43 +0100 Subject: ACCESS: Remove second character sprite in Dead command --- engines/access/amazon/amazon_game.cpp | 3 +++ engines/access/player.cpp | 7 +++++++ engines/access/player.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index dfaba977af..b665c49806 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -654,6 +654,9 @@ void AmazonEngine::dead(int deathId) { _room->clearRoom(); freeChar(); + _currentManOld = 1; + _player->removeSprite1(); + warning("TODO: restart game"); quitGame(); _events->pollEvents(); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 2313ed266e..cb7459e8cc 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -137,6 +137,13 @@ void Player::freeSprites() { _playerSprites = nullptr; } +void Player::removeSprite1() { + if (_playerSprites1) { + delete _playerSprites1; + _playerSprites1 = nullptr; + } +} + void Player::calcManScale() { if (!_vm->_manScaleOff) { _vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * diff --git a/engines/access/player.h b/engines/access/player.h index 67908a315d..631452f12d 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -120,6 +120,8 @@ public: void freeSprites(); + void removeSprite1(); + void calcManScale(); void walk(); -- cgit v1.2.3 From a3801df5187cb2500e72b74d37c6bccdbff1f8c5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 30 Nov 2014 13:23:16 +0100 Subject: ACCESS: First implementation of Sound playback for both CD and Floppy version. Courtesy of m_kiewitz --- engines/access/sound.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 6d42cd552e..fdc606b43e 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -21,7 +21,10 @@ */ #include "common/algorithm.h" +#include "audio/mixer.h" #include "audio/audiostream.h" +#include "audio/decoders/raw.h" +#include "audio/decoders/wave.h" #include "access/access.h" #include "access/sound.h" @@ -49,11 +52,14 @@ void SoundManager::clearSounds() { } void SoundManager::queueSound(int idx, int fileNum, int subfile) { + Resource *soundResource; + if (idx >= (int)_soundTable.size()) _soundTable.resize(idx + 1); delete _soundTable[idx]._res; - _soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile); + soundResource = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._res = soundResource; _soundTable[idx]._priority = 1; } @@ -67,6 +73,54 @@ void SoundManager::playSound(int soundIndex) { } void SoundManager::playSound(Resource *res, int priority) { + byte *resourceData = res->data(); + Audio::SoundHandle audioHandle; + Audio::RewindableAudioStream *audioStream = 0; + + assert(res->_size >= 32); + + if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) { + // CD version uses WAVE-files + Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO); + audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); + + } else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) { + // sound files have a fixed header of 32 bytes in total + // header content: + // "STEVE" - fixed header + // byte - sample rate + // 01h mapped internally to 3Ch ?? + // 02h mapped internally to 78h seems to be 11025Hz + // 03h mapped internally to B5h + // 04h mapped internally to F1h + // byte - unknown + // word - actual sample size (should be resource-size - 32) + byte internalSampleRate = resourceData[5]; + int sampleSize = READ_LE_UINT16(resourceData + 7); + + assert( (sampleSize + 32) == res->_size); + + int sampleRate = 0; + switch (internalSampleRate) { + case 1: sampleRate = 16666; break; // 3Ch -> C4h time constant + case 2: sampleRate = 8334; break; // 78h -> 88h time constant + case 3: sampleRate = 5525; break; // B5h -> 4Bh time constant + case 4: sampleRate = 4150; break; // F1h -> 0Fh time constant + default: + error("Unexpected internal Sample Rate %d", internalSampleRate); + return; + } + + audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); + + } else + error("Unknown format"); + + audioHandle = Audio::SoundHandle(); + _mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle, + audioStream, -1, _mixer->kMaxChannelVolume, 0, + DisposeAfterUse::NO); + /* Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); -- cgit v1.2.3 From 11e920f427312c496b080c280dca7a9eb8b75676 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 07:49:26 +0100 Subject: ACCESS: Split SoundManager and MusicManager --- engines/access/access.cpp | 2 ++ engines/access/access.h | 1 + engines/access/amazon/amazon_game.cpp | 16 +++++----- engines/access/amazon/amazon_logic.cpp | 24 +++++++-------- engines/access/amazon/amazon_scripts.cpp | 2 +- engines/access/room.cpp | 18 +++++------ engines/access/scripts.cpp | 2 +- engines/access/sound.cpp | 51 ++++++++++++++++++++------------ engines/access/sound.h | 25 ++++++++++++---- 9 files changed, 85 insertions(+), 56 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index bac1308b09..b0b28f64f6 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -100,6 +100,7 @@ AccessEngine::~AccessEngine() { delete _events; delete _files; delete _inventory; + delete _midi; delete _player; delete _room; delete _screen; @@ -150,6 +151,7 @@ void AccessEngine::initialize() { _player = Player::init(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); + _midi = new MusicManager(this, _mixer); _video = new VideoPlayer(this); _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); diff --git a/engines/access/access.h b/engines/access/access.h index af0d42302b..da10d6326c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -150,6 +150,7 @@ public: Screen *_screen; Scripts *_scripts; SoundManager *_sound; + MusicManager *_midi; VideoPlayer *_video; ASurface *_destIn; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index b665c49806..ba8b156e65 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -450,7 +450,7 @@ void AmazonEngine::startChapter(int chapter) { _room->clearRoom(); freeChar(); - _sound->newMusic(32, 0); + _midi->newMusic(32, 0); playVideo(0, Common::Point()); if (shouldQuit()) return; @@ -508,8 +508,8 @@ void AmazonEngine::startChapter(int chapter) { if (chapter == 14) _screen->plotImage(_objectsTable[_chapter], 1, Common::Point(169, 76)); - _sound->newMusic(chapImg[4], 1); - _sound->newMusic(33, 0); + _midi->newMusic(chapImg[4], 1); + _midi->newMusic(33, 0); _screen->forceFadeIn(); _timers[20]._timer = 950; @@ -534,8 +534,8 @@ void AmazonEngine::startChapter(int chapter) { _buffer2.copyFrom(*_screen); _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7)); - _sound->newMusic(7, 1); - _sound->newMusic(34, 0); + _midi->newMusic(7, 1); + _midi->newMusic(34, 0); _screen->forceFadeIn(); _buffer2.copyFrom(*_screen); @@ -567,7 +567,7 @@ void AmazonEngine::startChapter(int chapter) { _screen->clearBuffer(); freeCells(); - _sound->newMusic(_chapter * 2, 1); + _midi->newMusic(_chapter * 2, 1); if (chapter != 1 && chapter != 14) { _room->init4Quads(); @@ -607,7 +607,7 @@ void AmazonEngine::dead(int deathId) { _screen->setPanel(3); if (deathId != 10) { - _sound->newMusic(62, 0); + _midi->newMusic(62, 0); _files->_setPaletteFlag = false; _files->loadScreen(94, 0); _files->_setPaletteFlag = true; @@ -649,7 +649,7 @@ void AmazonEngine::dead(int deathId) { printText(_screen, msg); _screen->forceFadeOut(); - _sound->newMusic(0, 1); + _midi->newMusic(0, 1); _events->showCursor(); _room->clearRoom(); freeChar(); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c62ca5786e..c330429ee6 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -140,7 +140,7 @@ void CampScene::mWhileDoOpen() { _vm->_animation->setAnimTimer(anim); anim = _vm->_animation->setAnimation(1); _vm->_animation->setAnimTimer(anim); - _vm->_sound->newMusic(10, 0); + _vm->_midi->newMusic(10, 0); bool startFl = false; while (!_vm->shouldQuit()) { @@ -161,7 +161,7 @@ void CampScene::mWhileDoOpen() { if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { _skipStart = true; - _vm->_sound->newMusic(10, 1); + _vm->_midi->newMusic(10, 1); events.debounceLeft(); events.zeroKeys(); @@ -339,7 +339,7 @@ void Opening::doTitle() { _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); - _vm->_sound->newMusic(1, 0); + _vm->_midi->newMusic(1, 0); _vm->_events->_vbCount = 700; while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { _vm->_events->pollEventsAndWait(); @@ -352,8 +352,8 @@ void Opening::doTitle() { return; } - _vm->_sound->newMusic(1, 1); - _vm->_sound->_musicRepeat = false; + _vm->_midi->newMusic(1, 1); + _vm->_midi->_musicRepeat = false; _vm->_events->zeroKeys(); _vm->_room->loadRoom(0); _vm->_screen->clearScreen(); @@ -468,8 +468,8 @@ void Opening::doTent() { } } else if (_vm->_video->_videoFrame == 18) { if (step != 1) { - _vm->_sound->newMusic(73, 1); - _vm->_sound->newMusic(11, 0); + _vm->_midi->newMusic(73, 1); + _vm->_midi->newMusic(11, 0); step = 1; _vm->_sound->playSound(1); } @@ -499,7 +499,7 @@ void Opening::doTent() { _vm->_events->pollEventsAndWait(); _vm->_events->showCursor(); - _vm->_sound->newMusic(11, 1); + _vm->_midi->newMusic(11, 1); _vm->_sound->_soundTable.clear(); _vm->establishCenter(0, 4); @@ -1262,7 +1262,7 @@ void Cast::doCast(int param1) { _vm->_newRects.clear(); _vm->_numAnimTimers = 0; - _vm->_sound->newMusic(58, 0); + _vm->_midi->newMusic(58, 0); _vm->_screen->forceFadeIn(); while (!_vm->shouldQuit()) { @@ -1284,14 +1284,14 @@ void Cast::doCast(int param1) { _vm->_events->pollEventsAndWait(); } - while (!_vm->shouldQuit() && !_vm->_sound->checkMidiDone()) + while (!_vm->shouldQuit() && !_vm->_midi->checkMidiDone()) _vm->_events->pollEventsAndWait(); break; } } - _vm->_sound->newMusic(58, 1); + _vm->_midi->newMusic(58, 1); _vm->_events->showCursor(); _vm->freeCells(); @@ -1787,7 +1787,7 @@ void River::river() { // int bx = _vm->_player->_scrollAmount - _screenVertX; if (_vm->_screen->_scrollX == 0) { - _vm->_sound->midiRepeat(); + _vm->_midi->midiRepeat(); if (riverJumpTest()) { _CHICKENOUTFLG = false; return; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index f38c80c915..da43f1bc82 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -333,7 +333,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { _game->_guard.doGuard(); break; case 10: - _vm->_sound->newMusic(param1, param2); + _vm->_midi->newMusic(param1, param2); break; case 11: plotInactive(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9ce06959a..7ef3d6937d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -86,7 +86,7 @@ void Room::doRoom() { g_system->delayMillis(5); _vm->_player->walk(); - _vm->_sound->midiRepeat(); + _vm->_midi->midiRepeat(); _vm->_player->checkScroll(); doCommands(); @@ -150,10 +150,10 @@ void Room::doRoom() { } void Room::clearRoom() { - if (_vm->_sound->_music) { - _vm->_sound->stopSong(); - delete _vm->_sound->_music; - _vm->_sound->_music = nullptr; + if (_vm->_midi->_music) { + _vm->_midi->stopSong(); + delete _vm->_midi->_music; + _vm->_midi->_music = nullptr; } _vm->_sound->freeSounds(); @@ -181,11 +181,11 @@ void Room::loadRoomData(const byte *roomData) { } } - _vm->_sound->freeMusic(); + _vm->_midi->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_sound->_music = _vm->_files->loadFile(roomInfo._musicFile); - _vm->_sound->midiPlay(); - _vm->_sound->_musicRepeat = true; + _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile); + _vm->_midi->midiPlay(); + _vm->_midi->_musicRepeat = true; } _vm->_scaleH1 = roomInfo._scaleH1; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index add461eb81..2c32f59ced 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -679,7 +679,7 @@ void Scripts::cmdWait() { while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() && !_vm->_events->_leftButton && !_vm->_events->_rightButton && _vm->_timers[3]._flag) { - _vm->_sound->midiRepeat(); + _vm->_midi->midiRepeat(); charLoop(); _vm->_events->pollEvents(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index fdc606b43e..7d1885955a 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -32,17 +32,12 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { - _music = nullptr; - _tempMusic = nullptr; - _musicRepeat = false; _playingSound = false; _isVoice = false; } SoundManager::~SoundManager() { clearSounds(); - delete _music; - delete _tempMusic; } void SoundManager::clearSounds() { @@ -138,33 +133,51 @@ void SoundManager::loadSounds(Common::Array &sounds) { } } -void SoundManager::midiPlay() { - // TODO +void SoundManager::stopSound() { + // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG + warning("TODO: stopSound"); +} + +void SoundManager::freeSounds() { + stopSound(); + clearSounds(); +} + +/******************************************************************************************/ + +MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { + _music = nullptr; + _tempMusic = nullptr; + _musicRepeat = false; +} + +MusicManager::~MusicManager() { + delete _music; + delete _tempMusic; } -bool SoundManager::checkMidiDone() { +void MusicManager::midiPlay() { // TODO - return true; } -void SoundManager::midiRepeat() { +bool MusicManager::checkMidiDone() { // TODO + return true; } -void SoundManager::stopSong() { +void MusicManager::midiRepeat() { // TODO } -void SoundManager::stopSound() { - // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG +void MusicManager::stopSong() { + // TODO } -void SoundManager::freeSounds() { - stopSound(); - clearSounds(); +Resource *MusicManager::loadMusic(int fileNum, int subfile) { + return _vm->_files->loadFile(fileNum, subfile); } -void SoundManager::newMusic(int musicId, int mode) { +void MusicManager::newMusic(int musicId, int mode) { if (mode == 1) { stopSong(); freeMusic(); @@ -177,11 +190,11 @@ void SoundManager::newMusic(int musicId, int mode) { _musicRepeat = (mode == 2); _tempMusic = _music; stopSong(); - _music = loadSound(97, musicId); + _music = loadMusic(97, musicId); } } -void SoundManager::freeMusic() { +void MusicManager::freeMusic() { delete _music; _music = nullptr; } diff --git a/engines/access/sound.h b/engines/access/sound.h index 46e3b23bb1..b14ce7c685 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -54,9 +54,6 @@ private: public: Common::Array _soundTable; - Resource *_music; - Resource *_tempMusic; - bool _musicRepeat; bool _playingSound; bool _isVoice; public: @@ -70,6 +67,25 @@ public: Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); + void freeSounds(); +}; + +class MusicManager { +private: + AccessEngine *_vm; + Audio::Mixer *_mixer; + + Resource *loadMusic(int fileNum, int subfile); + +public: + Resource *_music; + Resource *_tempMusic; + bool _musicRepeat; + bool _playingSound; +public: + MusicManager(AccessEngine *vm, Audio::Mixer *mixer); + ~MusicManager(); + void midiPlay(); bool checkMidiDone(); @@ -78,13 +94,10 @@ public: void stopSong(); - void freeSounds(); - void newMusic(int musicId, int mode); void freeMusic(); }; - } // End of namespace Access #endif /* ACCESS_SOUND_H*/ -- cgit v1.2.3 From 0277d1654d23fa92d09bfb6486d0b7a9514e6403 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 07:52:08 +0100 Subject: ACCESS: Remove two unused variables --- engines/access/access.cpp | 4 ---- engines/access/access.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index b0b28f64f6..6111ec7906 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -53,8 +53,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _mouseMode = 0; _currentMan = 0; _currentManOld = -1; - _music = nullptr; - _title = nullptr; _converseMode = 0; _startAboutBox = 0; _startTravelBox = 0; @@ -109,8 +107,6 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete _music; - delete _title; delete _eseg; } diff --git a/engines/access/access.h b/engines/access/access.h index da10d6326c..2fdf619a35 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -177,8 +177,6 @@ public: int _mouseMode; int _currentManOld; - Resource *_music; - Resource *_title; int _converseMode; int _startAboutBox; int _startTravelBox; -- cgit v1.2.3 From 9604da9da3fad69daca3604de618f5c91c293850 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 07:59:42 +0100 Subject: ACCESS: Rename _Eseg --- engines/access/access.cpp | 4 ++-- engines/access/access.h | 2 +- engines/access/amazon/amazon_game.cpp | 28 ++++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6111ec7906..41706fc4fd 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -68,7 +68,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleI = 0; _imgUnscaled = false; _canSaveLoad = false; - _eseg = nullptr; + _establish = nullptr; _conversation = 0; _currentMan = 0; @@ -107,7 +107,7 @@ AccessEngine::~AccessEngine() { delete _video; freeCells(); - delete _eseg; + delete _establish; } void AccessEngine::setVGA() { diff --git a/engines/access/access.h b/engines/access/access.h index 2fdf619a35..eacdae9709 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -191,7 +191,7 @@ public: bool _imgUnscaled; bool _canSaveLoad; - Resource *_eseg; + Resource *_establish; int _et; int _printEnd; int _txtPages; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index ba8b156e65..5b27eb24a2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -165,26 +165,26 @@ void AmazonEngine::loadEstablish(int estabIndex) { int oldGroup = _establishGroup; _establishGroup = 0; - _eseg = _files->loadFile(_estTable[oldGroup]); - _establishCtrlTblOfs = READ_LE_UINT16(_eseg->data()); + _establish = _files->loadFile(_estTable[oldGroup]); + _establishCtrlTblOfs = READ_LE_UINT16(_establish->data()); int ofs = _establishCtrlTblOfs + (estabIndex * 2); - int idx = READ_LE_UINT16(_eseg->data() + ofs); - _narateFile = READ_LE_UINT16(_eseg->data() + idx); - _txtPages = READ_LE_UINT16(_eseg->data() + idx + 2); + int idx = READ_LE_UINT16(_establish->data() + ofs); + _narateFile = READ_LE_UINT16(_establish->data() + idx); + _txtPages = READ_LE_UINT16(_establish->data() + idx + 2); if (!_txtPages) return; - _sndSubFile = READ_LE_UINT16(_eseg->data() + idx + 4); + _sndSubFile = READ_LE_UINT16(_establish->data() + idx + 4); for (int i = 0; i < _txtPages; ++i) - _countTbl[i] = READ_LE_UINT16(_eseg->data() + idx + 6 + (2 * i)); + _countTbl[i] = READ_LE_UINT16(_establish->data() + idx + 6 + (2 * i)); } else { _establishGroup = 0; _narateFile = 0; _txtPages = 0; _sndSubFile = 0; - _eseg = _files->loadFile("ETEXT.DAT"); + _establish = _files->loadFile("ETEXT.DAT"); } } @@ -212,10 +212,10 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(estabIndex); _et = estabIndex; - uint16 msgOffset = READ_LE_UINT16(_eseg->data() + (estabIndex * 2) + 2); + uint16 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2); _printEnd = 155; - Common::String msg((const char *)_eseg->data() + msgOffset); + Common::String msg((const char *)_establish->data() + msgOffset); if (_txtPages == 0) { printText(_screen, msg); @@ -226,8 +226,8 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->forceFadeOut(); _screen->clearScreen(); - delete _eseg; - _eseg = nullptr; + delete _establish; + _establish = nullptr; if (_establishMode == 0) _room->init4Quads(); @@ -550,10 +550,10 @@ void AmazonEngine::startChapter(int chapter) { _establishGroup = 1; loadEstablish(0x40 + _chapter); - uint16 msgOffset = READ_LE_UINT16(_eseg->data() + ((0x40 + _chapter) * 2) + 2); + uint16 msgOffset = READ_LE_UINT16(_establish->data() + ((0x40 + _chapter) * 2) + 2); _printEnd = 170; - Common::String msg((const char *)_eseg->data() + msgOffset); + Common::String msg((const char *)_establish->data() + msgOffset); if (_txtPages == 0) { printText(_screen, msg); -- cgit v1.2.3 From 6e8f29c15b433e517b06c17fc63d082e7c5069d9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 08:22:40 +0100 Subject: ACCESS: Implement stopSound --- engines/access/sound.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 7d1885955a..a24dd1a24b 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -134,8 +134,7 @@ void SoundManager::loadSounds(Common::Array &sounds) { } void SoundManager::stopSound() { - // TODO: REALSTOPSND or BLASTSTOPSND or STOP_SOUNDG - warning("TODO: stopSound"); + _mixer->stopHandle(Audio::SoundHandle()); } void SoundManager::freeSounds() { -- cgit v1.2.3 From f364782d05cf0772bf2eaa71ea418650e0d9bf27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 08:46:32 +0100 Subject: ACCESS: Some rework in MusicManager --- engines/access/room.cpp | 5 ++--- engines/access/sound.cpp | 10 +++++++--- engines/access/sound.h | 10 +++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 7ef3d6937d..8ef61a9d68 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -152,8 +152,7 @@ void Room::doRoom() { void Room::clearRoom() { if (_vm->_midi->_music) { _vm->_midi->stopSong(); - delete _vm->_midi->_music; - _vm->_midi->_music = nullptr; + _vm->_midi->freeMusic(); } _vm->_sound->freeSounds(); @@ -183,7 +182,7 @@ void Room::loadRoomData(const byte *roomData) { _vm->_midi->freeMusic(); if (roomInfo._musicFile._fileNum != -1) { - _vm->_midi->_music = _vm->_files->loadFile(roomInfo._musicFile); + _vm->_midi->loadMusic(roomInfo._musicFile); _vm->_midi->midiPlay(); _vm->_midi->_musicRepeat = true; } diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index a24dd1a24b..316ac54d42 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -172,8 +172,12 @@ void MusicManager::stopSong() { // TODO } -Resource *MusicManager::loadMusic(int fileNum, int subfile) { - return _vm->_files->loadFile(fileNum, subfile); +void MusicManager::loadMusic(int fileNum, int subfile) { + _music = _vm->_files->loadFile(fileNum, subfile); +} + +void MusicManager::loadMusic(FileIdent file) { + _music = _vm->_files->loadFile(file); } void MusicManager::newMusic(int musicId, int mode) { @@ -189,7 +193,7 @@ void MusicManager::newMusic(int musicId, int mode) { _musicRepeat = (mode == 2); _tempMusic = _music; stopSong(); - _music = loadMusic(97, musicId); + loadMusic(97, musicId); } } diff --git a/engines/access/sound.h b/engines/access/sound.h index b14ce7c685..827a00f8b5 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -75,13 +75,14 @@ private: AccessEngine *_vm; Audio::Mixer *_mixer; - Resource *loadMusic(int fileNum, int subfile); + Resource *_tempMusic; public: - Resource *_music; - Resource *_tempMusic; bool _musicRepeat; bool _playingSound; + + Resource *_music; + public: MusicManager(AccessEngine *vm, Audio::Mixer *mixer); ~MusicManager(); @@ -97,6 +98,9 @@ public: void newMusic(int musicId, int mode); void freeMusic(); + + void loadMusic(int fileNum, int subfile); + void loadMusic(FileIdent file); }; } // End of namespace Access -- cgit v1.2.3 From 11870c414460d8c9ea70651a979b1842e58569e5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 14:07:09 +0100 Subject: ACCESS: Implement music player (WIP) --- engines/access/amazon/amazon_logic.cpp | 2 +- engines/access/room.cpp | 2 +- engines/access/sound.cpp | 84 ++++++++++++++++++++++++++++++---- engines/access/sound.h | 12 +++-- 4 files changed, 84 insertions(+), 16 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c330429ee6..de497c2a35 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -353,7 +353,7 @@ void Opening::doTitle() { } _vm->_midi->newMusic(1, 1); - _vm->_midi->_musicRepeat = false; + _vm->_midi->setLoop(false); _vm->_events->zeroKeys(); _vm->_room->loadRoom(0); _vm->_screen->clearScreen(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 8ef61a9d68..a5873b2c38 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -184,7 +184,7 @@ void Room::loadRoomData(const byte *roomData) { if (roomInfo._musicFile._fileNum != -1) { _vm->_midi->loadMusic(roomInfo._musicFile); _vm->_midi->midiPlay(); - _vm->_midi->_musicRepeat = true; + _vm->_midi->setLoop(true); } _vm->_scaleH1 = roomInfo._scaleH1; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 316ac54d42..2d38a2c6bc 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -147,7 +147,20 @@ void SoundManager::freeSounds() { MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _music = nullptr; _tempMusic = nullptr; - _musicRepeat = false; + _isLooping = false; + + MidiPlayer::createDriver(); + MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM); + + int retValue = _driver->open(); + if (retValue == 0) { + if (_nativeMT32) + _driver->sendMT32Reset(); + else + _driver->sendGMReset(); + + _driver->setTimerCallback(this, &timerCallback); + } } MusicManager::~MusicManager() { @@ -155,46 +168,92 @@ MusicManager::~MusicManager() { delete _tempMusic; } +void MusicManager::send(uint32 b) { + if ((b & 0xF0) == 0xC0 && !_nativeMT32) { + b = (b & 0xFFFF00FF) | MidiDriver::_mt32ToGm[(b >> 8) & 0xFF] << 8; + } + + Audio::MidiPlayer::send(b); +} + void MusicManager::midiPlay() { - // TODO + warning("MusicManager::midiPlay"); + if (_music->_size < 4) { + error("midiPlay() wrong music resource size"); + } + + if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M')) + error("midiPlay() Unexpected signature"); + + stop(); + + _parser = MidiParser::createParser_XMIDI(); + + if (!_parser->loadMusic(_music->data(), _music->_size)) + error("midiPlay() wrong music resource"); + + _parser->setTrack(0); + _parser->setMidiDriver(this); + _parser->setTimerRate(_driver->getBaseTempo()); + _parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); + _parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1); + + // Handle music looping + _parser->property(MidiParser::mpAutoLoop, _isLooping); + // _isLooping = loop; + + setVolume(127); + _isPlaying = true; } bool MusicManager::checkMidiDone() { - // TODO - return true; + warning("MusicManager::checkMidiDone"); + return (!_isPlaying); } void MusicManager::midiRepeat() { - // TODO + warning("MusicManager::midiRepeat"); + if (!_parser) + return; + + _isLooping = true; + _parser->property(MidiParser::mpAutoLoop, _isLooping); + if (!_isPlaying) + _parser->setTrack(0); } void MusicManager::stopSong() { - // TODO + warning("MusicManager::stopSong"); + stop(); } void MusicManager::loadMusic(int fileNum, int subfile) { + warning("MusicManager::loadMusic %d %d", fileNum, subfile); _music = _vm->_files->loadFile(fileNum, subfile); } void MusicManager::loadMusic(FileIdent file) { + warning("MusicManager::loadMusic %d %d", file._fileNum, file._subfile); _music = _vm->_files->loadFile(file); } void MusicManager::newMusic(int musicId, int mode) { + warning("MusicManager::newMusic %d %d", musicId, mode); if (mode == 1) { stopSong(); freeMusic(); _music = _tempMusic; _tempMusic = nullptr; - _musicRepeat = true; - if (_music) - midiPlay(); + _isLooping = true; } else { - _musicRepeat = (mode == 2); + _isLooping = (mode == 2); _tempMusic = _music; stopSong(); loadMusic(97, musicId); } + + if (_music) + midiPlay(); } void MusicManager::freeMusic() { @@ -202,4 +261,9 @@ void MusicManager::freeMusic() { _music = nullptr; } +void MusicManager::setLoop(bool loop) { + _isLooping = loop; + if (_parser) + _parser->property(MidiParser::mpAutoLoop, _isLooping); +} } // End of namespace Access diff --git a/engines/access/sound.h b/engines/access/sound.h index 827a00f8b5..5089bd093b 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -26,6 +26,8 @@ #include "common/scummsys.h" #include "audio/mixer.h" #include "access/files.h" +#include "audio/midiplayer.h" +#include "audio/midiparser.h" #define MAX_SOUNDS 20 @@ -70,17 +72,17 @@ public: void freeSounds(); }; -class MusicManager { +class MusicManager : public Audio::MidiPlayer { private: AccessEngine *_vm; Audio::Mixer *_mixer; Resource *_tempMusic; -public: - bool _musicRepeat; - bool _playingSound; + // MidiDriver_BASE interface implementation + virtual void send(uint32 b); +public: Resource *_music; public: @@ -101,6 +103,8 @@ public: void loadMusic(int fileNum, int subfile); void loadMusic(FileIdent file); + + void setLoop(bool loop); }; } // End of namespace Access -- cgit v1.2.3 From 0028556d6c1706f647f0df3fddd04adb87bd6630 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 15:01:47 +0100 Subject: ACCESS: improve the sound during the title countdown --- engines/access/amazon/amazon_logic.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index de497c2a35..5db3efbecb 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -316,8 +316,12 @@ void Opening::doTitle() { _vm->_screen->copyFrom(_vm->_buffer2); _vm->_events->_vbCount = 70; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) { + _vm->_sound->playSound(1); _vm->_events->pollEventsAndWait(); + if (_vm->_events->_rightButton) + _skipStart = true; + } } if (_vm->shouldQuit()) return; -- cgit v1.2.3 From 0eeb5b5bf3e6dfe5537647068f697eedda87c468 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 1 Dec 2014 15:18:21 +0100 Subject: ACCESS: Fix the horizontal scrolling in intro, add some calls to clearEvents --- engines/access/amazon/amazon_logic.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 5db3efbecb..1649cddc51 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -372,12 +372,12 @@ void Opening::doTitle() { _vm->_screen->forceFadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); - // KEYFLG = 0; + _vm->_events->clearEvents(); _vm->_player->_scrollAmount = 1; _pCount = 0; while (!_vm->shouldQuit()) { - if (!_vm->_events->isKeyMousePressed()) { + if (_vm->_events->isKeyMousePressed()) { if (_vm->_events->_rightButton) _skipStart = true; _vm->_room->clearRoom(); @@ -616,8 +616,7 @@ void Plane::mWhileFly() { screen.fadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); - - // KEYFLG = 0; + _vm->_events->clearEvents(); screen._scrollRow = screen._scrollCol = 0; screen._scrollX = screen._scrollY = 0; @@ -673,8 +672,7 @@ void Plane::mWhileFall() { screen.fadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); - - // KEYFLG = 0; + _vm->_events->clearEvents(); screen._scrollRow = screen._scrollCol = 0; screen._scrollX = screen._scrollY = 0; @@ -768,7 +766,7 @@ void Jungle::initJWalk2() { _vm->_room->buildScreen(); _vm->copyBF2Vid(); _vm->_screen->fadeIn(); - // KEYFL = 0; + _vm->_events->clearEvents(); _xCount = 2; _vm->_player->_scrollAmount = 5; @@ -1395,7 +1393,8 @@ void River::initRiver() { // Reset draw rects _vm->_oldRects.clear(); _vm->_newRects.clear(); - // KEYFLG = 0 + _vm->_events->clearEvents(); + } _vm->_player->_scrollAmount = 2; -- cgit v1.2.3 From 954a0d0f9f8ebf3fc49df583d9eda59de8f62ed8 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Dec 2014 16:28:30 +0100 Subject: ACCESS: Remove useless (and commented) code --- engines/access/sound.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2d38a2c6bc..bf11d6a624 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -200,7 +200,6 @@ void MusicManager::midiPlay() { // Handle music looping _parser->property(MidiParser::mpAutoLoop, _isLooping); - // _isLooping = loop; setVolume(127); _isPlaying = true; -- cgit v1.2.3 From 66f9d71f1dc27ab0e4d3499703e39ebf35e87a27 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Dec 2014 16:29:42 +0100 Subject: ACCESS: Add some code for the intro (WIP) --- engines/access/access.h | 1 + engines/access/amazon/amazon_logic.cpp | 148 ++++++------ engines/access/amazon/amazon_resources.cpp | 375 +++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 2 + engines/access/amazon/amazon_room.cpp | 5 +- engines/access/detection.cpp | 4 + engines/access/files.cpp | 5 +- 7 files changed, 465 insertions(+), 75 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index eacdae9709..2fe4b726a2 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -221,6 +221,7 @@ public: uint32 getFeatures() const; bool isCD() const; + bool isDemo() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; uint16 getVersion() const; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 1649cddc51..68a52e77f8 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -273,92 +273,94 @@ void Opening::doTitle() { _vm->_screen->forceFadeOut(); _vm->_events->hideCursor(); - _vm->_sound->queueSound(0, 98, 30); - _vm->_sound->queueSound(1, 98, 8); - - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(0, 3); - - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->forceFadeIn(); - _vm->_sound->playSound(1); + if (!_vm->isDemo()) { + _vm->_sound->queueSound(0, 98, 30); + _vm->_sound->queueSound(1, 98, 8); + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 3); + + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->forceFadeIn(); + _vm->_sound->playSound(1); - // WORKAROUND: This delay has been added to replace original game delay that - // came from loading resources, since nowadays it would be too fast to be visible - // nowadays to be visible. - _vm->_events->_vbCount = 70; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) - _vm->_events->pollEventsAndWait(); - if (_vm->shouldQuit()) - return; + // WORKAROUND: This delay has been added to replace original game delay that + // came from loading resources, since nowadays it would be too fast to be visible + // nowadays to be visible. + _vm->_events->_vbCount = 70; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); + if (_vm->shouldQuit()) + return; - Resource *spriteData = _vm->_files->loadFile(0, 2); - _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); - delete spriteData; + Resource *spriteData = _vm->_files->loadFile(0, 2); + _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); + delete spriteData; - _vm->_sound->playSound(1); + _vm->_sound->playSound(1); - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(0, 4); - _vm->_sound->playSound(1); + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 4); + _vm->_sound->playSound(1); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_sound->playSound(1); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_sound->playSound(1); - const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; - for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { - _vm->_buffer2.copyFrom(_vm->_buffer1); - int id = COUNTDOWN[_pCount * 2]; - int xp = COUNTDOWN[_pCount * 2 + 1]; - _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); - _vm->_screen->copyFrom(_vm->_buffer2); + const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; + for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { + _vm->_buffer2.copyFrom(_vm->_buffer1); + int id = COUNTDOWN[_pCount * 2]; + int xp = COUNTDOWN[_pCount * 2 + 1]; + _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); + _vm->_screen->copyFrom(_vm->_buffer2); - _vm->_events->_vbCount = 70; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) { - _vm->_sound->playSound(1); - _vm->_events->pollEventsAndWait(); - if (_vm->_events->_rightButton) - _skipStart = true; + _vm->_events->_vbCount = 70; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) { + _vm->_sound->playSound(1); + _vm->_events->pollEventsAndWait(); + if (_vm->_events->_rightButton) + _skipStart = true; + } } - } - if (_vm->shouldQuit()) - return; + if (_vm->shouldQuit()) + return; - _vm->_sound->playSound(0); - _vm->_screen->forceFadeOut(); - _vm->_events->_vbCount = 100; - while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) - _vm->_events->pollEventsAndWait(); - if (_vm->shouldQuit()) - return; + _vm->_sound->playSound(0); + _vm->_screen->forceFadeOut(); + _vm->_events->_vbCount = 100; + while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) + _vm->_events->pollEventsAndWait(); + if (_vm->shouldQuit()) + return; - _vm->_sound->freeSounds(); - delete _vm->_objectsTable[0]; - _vm->_objectsTable[0] = nullptr; + _vm->_sound->freeSounds(); + delete _vm->_objectsTable[0]; + _vm->_objectsTable[0] = nullptr; + + _vm->_files->_setPaletteFlag = false; + _vm->_files->loadScreen(0, 5); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_screen->forceFadeIn(); + _vm->_midi->newMusic(1, 0); + _vm->_events->_vbCount = 700; + while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { + _vm->_events->pollEventsAndWait(); + } - _vm->_files->_setPaletteFlag = false; - _vm->_files->loadScreen(0, 5); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->forceFadeIn(); - _vm->_midi->newMusic(1, 0); - _vm->_events->_vbCount = 700; - while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { - _vm->_events->pollEventsAndWait(); - } + if (_vm->_events->_rightButton) { + _skipStart = true; + _vm->_room->clearRoom(); + _vm->_events->showCursor(); + return; + } - if (_vm->_events->_rightButton) { - _skipStart = true; - _vm->_room->clearRoom(); - _vm->_events->showCursor(); - return; + _vm->_midi->newMusic(1, 1); + _vm->_midi->setLoop(false); + _vm->_events->zeroKeys(); } - - _vm->_midi->newMusic(1, 1); - _vm->_midi->setLoop(false); - _vm->_events->zeroKeys(); _vm->_room->loadRoom(0); _vm->_screen->clearScreen(); _vm->_screen->setBufferScan(); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 0ae7ef0718..8e5fccbf25 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -51,6 +51,25 @@ const char *const FILENAMES[] = { "NARATE13.AP", "NARATE14.AP", "S00.AP", "TAG.AP" }; +const char *const FILENAMES_DEMO[] = { + "S00.AP", "S01.AP", "S02.AP", "R03.AP", "S04.AP", "S05.AP", + "S06.AP", "S07.AP", "S08.AP", "S09.AP", "S10.AP", "S11.AP", + "S12.AP", "S13.AP", "S14.AP", "S15.AP", "S16.AP", "S17.AP", + "S18.AP", "S19.AP", "S20.AP", "S21.AP", "S22.AP", "S23.AP", + "S24.AP", "S25.AP", "S26.AP", "S27.AP", "S28.AP", "S29.AP", + "S30.AP", "S31.AP", "S32.AP", "S33.AP", "S34.AP", "R35.AP", + "S36.AP", "S37.AP", "S38.AP", "S39.AP", "S40.AP", "TITLE.AP", + "S42.AP", "S01.AP", "S44.AP", "S45.AP", "S46.AP", "S47.AP", + nullptr, nullptr, "S50.AP", nullptr, nullptr, "S53.AP", + "S54.AP", nullptr, nullptr, "S57.AP", nullptr, nullptr, + nullptr, "S61.AP", nullptr, "C23.AP", "C12.AP", "C00.AP", + "C01.AP", "C06.AP", "C07.AP", "C08.AP", "C05.AP", "C09.AP", + "C12.AP", "C03.AP", "C13.AP", "C15.AP", "C14.AP", "C16.AP", + "C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP", + "C24.AP", "C25.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", + "R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP", + "CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" +}; const byte MOUSE0[] = { 0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, @@ -603,6 +622,362 @@ const char *ROOM_DESCR[] = { nullptr, "Pit with Ants", nullptr, nullptr }; +const byte ROOM_TABLE1_DEMO[] = { + 0x02, 0x61, 0x00, 0x03, 0x00, 0x30, 0x22, 0x30, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE5_DEMO[] = { + 0x00, 0x61, 0x00, 0x0E, 0x00, 0x36, 0x0F, 0x5E, 0x04, 0x00, + 0x00, 0x00, 0x04, 0x04, 0x00, 0x03, 0x00, 0xFF, 0x04, 0x00, + 0x02, 0x00, 0x04, 0x00, 0x01, 0x00, 0x8C, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x0B, 0x00, 0x01, 0x00, 0x62, 0x00, 0x0C, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x0D, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE6_DEMO[] = { + 0x00, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x3E, 0x1A, 0x05, 0x00, + 0x00, 0x00, 0x05, 0x05, 0x00, 0x03, 0x00, 0xFF, 0x05, 0x00, + 0x02, 0x00, 0x05, 0x00, 0x01, 0x00, 0xFF, 0x30, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x12, 0x00, 0x03, 0x00, 0x62, 0x00, 0x13, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x14, 0x00, 0x02, 0x00, 0x62, 0x00, + 0x04, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE7_DEMO[] = { + 0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x20, 0xC4, 0x06, 0x00, + 0x00, 0x00, 0x06, 0x06, 0x00, 0x03, 0x00, 0xFF, 0x06, 0x00, + 0x02, 0x00, 0x06, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x01, 0x00, 0x01, 0x00, 0x62, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x03, 0x00, 0x02, 0x00, 0x62, 0x00, + 0x26, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE9_DEMO[] = { + 0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x20, 0xC4, 0x08, 0x00, + 0x00, 0x00, 0x08, 0x08, 0x00, 0x03, 0x00, 0xFF, 0x08, 0x00, + 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x07, 0x00, 0x01, 0x00, 0x62, 0x00, 0x08, 0x00, + 0x02, 0x00, 0x62, 0x00, 0x09, 0x00, 0x01, 0x00, 0x62, 0x00, + 0x0A, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE10_DEMO[] = { + 0x00, 0x61, 0x00, 0x0E, 0x00, 0x30, 0x18, 0x9B, 0x09, 0x00, + 0x00, 0x00, 0x09, 0x09, 0x00, 0x03, 0x00, 0xFF, 0x09, 0x00, + 0x02, 0x00, 0x09, 0x00, 0x01, 0x00, 0xB4, 0x10, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x62, 0x00, 0x04, 0x00, 0x01, 0x00, 0x62, 0x00, 0x05, 0x00, + 0x02, 0x00, 0x62, 0x00, 0x06, 0x00, 0x02, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE11_DEMO[] = { + 0x01, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x30, 0x14, 0x0A, 0x00, + 0x00, 0x00, 0x0A, 0x0A, 0x00, 0x03, 0x00, 0xFF, 0x0A, 0x00, + 0x02, 0x00, 0x0A, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x15, 0x00, 0x01, 0x00, 0x62, 0x00, 0x16, 0x00, + 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE12_DEMO[] = { + 0x01, 0x61, 0x00, 0x0E, 0x00, 0x40, 0x3A, 0x22, 0x0B, 0x00, + 0x00, 0x00, 0x0B, 0x0B, 0x00, 0x03, 0x00, 0xFF, 0x0B, 0x00, + 0x02, 0x00, 0x0B, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE13_DEMO[] = { + 0x01, 0x61, 0x00, 0x08, 0x00, 0x40, 0x30, 0x14, 0x0C, 0x00, + 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x03, 0x00, 0xFF, 0x0C, 0x00, + 0x02, 0x00, 0x0C, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x18, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x17, 0x00, 0x01, 0x00, 0x62, 0x00, 0x11, 0x00, + 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE14_DEMO[] = { + 0x01, 0x61, 0x00, 0x0D, 0x00, 0x40, 0x36, 0x2C, 0x0D, 0x00, + 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x03, 0x00, 0xFF, 0x0D, 0x00, + 0x02, 0x00, 0x0D, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE15_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3E, 0x33, 0xFF, 0xFF, + 0x00, 0x00, 0xFF, 0x0E, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, + 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF +}; + +const byte ROOM_TABLE16_DEMO[] = { + 0x01, 0x61, 0x00, 0x10, 0x00, 0x28, 0x0C, 0x5E, 0x0F, 0x00, + 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x02, 0x00, 0xFF, 0x0F, 0x00, + 0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE17_DEMO[] = { + 0x02, 0x61, 0x00, 0x10, 0x00, 0x40, 0x20, 0x30, 0x10, 0x00, + 0x00, 0x00, 0x10, 0x10, 0x00, 0x03, 0x00, 0xFF, 0x10, 0x00, + 0x02, 0x00, 0x10, 0x00, 0x01, 0x00, 0x6E, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE18_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x19, 0x2B, 0x11, 0x00, + 0x00, 0x00, 0x11, 0x11, 0x00, 0x03, 0x00, 0xFF, 0x11, 0x00, + 0x02, 0x00, 0x11, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE19_DEMO[] = { + 0x01, 0x61, 0x00, 0x11, 0x00, 0x2D, 0x14, 0x3C, 0x12, 0x00, + 0x00, 0x00, 0x12, 0x12, 0x00, 0x03, 0x00, 0xFF, 0x12, 0x00, + 0x02, 0x00, 0x12, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE20_DEMO[] = { + 0x02, 0x61, 0x00, 0x12, 0x00, 0x2D, 0x28, 0x28, 0x13, 0x00, + 0x00, 0x00, 0x13, 0x13, 0x00, 0x03, 0x00, 0xFF, 0x13, 0x00, + 0x02, 0x00, 0x13, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x29, 0x00, 0x01, 0x00, 0x62, 0x00, 0x24, 0x00, + 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE21_DEMO[] = { + 0x01, 0x61, 0x00, 0x16, 0x00, 0x28, 0x0C, 0x5E, 0x14, 0x00, + 0x00, 0x00, 0x14, 0x14, 0x00, 0x02, 0x00, 0xFF, 0x14, 0x00, + 0x01, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE22_DEMO[] = { + 0x01, 0x61, 0x00, 0x12, 0x00, 0x3C, 0x2A, 0x29, 0x15, 0x00, + 0x00, 0x00, 0x15, 0x15, 0x00, 0x03, 0x00, 0xFF, 0x15, 0x00, + 0x02, 0x00, 0x15, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x23, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE23_DEMO[] = { + 0x01, 0x61, 0x00, 0x13, 0x00, 0x40, 0x2D, 0x64, 0x16, 0x00, + 0x00, 0x00, 0xFF, 0x16, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00, + 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x16, 0x00, 0x02, + 0x00, 0xFF, 0xFF, 0x62, 0x00, 0x2A, 0x00, 0x01, 0x00, 0xFF, + 0xFF +}; + +const byte ROOM_TABLE24_DEMO[] = { + 0x02, 0x61, 0x00, 0x14, 0x00, 0x40, 0x3C, 0x19, 0x17, 0x00, + 0x00, 0x00, 0x17, 0x17, 0x00, 0x03, 0x00, 0xFF, 0x17, 0x00, + 0x02, 0x00, 0x17, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE25_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x3F, 0x5A, 0x18, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x02, 0x00, 0xFF, 0x18, 0x00, + 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xDC, 0xA0, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE26_DEMO[] = { + 0x02, 0x61, 0x00, 0x17, 0x00, 0x3E, 0x32, 0x80, 0x19, 0x00, + 0x00, 0x00, 0x19, 0x19, 0x00, 0x03, 0x00, 0xFF, 0x19, 0x00, + 0x02, 0x00, 0x19, 0x00, 0x01, 0x00, 0x64, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE27_DEMO[] = { + 0x01, 0x61, 0x00, 0x19, 0x00, 0x34, 0x28, 0x28, 0x1A, 0x00, + 0x00, 0x00, 0x1A, 0x1A, 0x00, 0x03, 0x00, 0xFF, 0x1A, 0x00, + 0x02, 0x00, 0x1A, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x28, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x2B, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE28_DEMO[] = { + 0x02, 0x61, 0x00, 0x18, 0x00, 0x40, 0x3A, 0x6C, 0x1B, 0x00, + 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x03, 0x00, 0xFF, 0x1B, 0x00, + 0x02, 0x00, 0x1B, 0x00, 0x01, 0x00, 0xC8, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE30_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x18, 0x73, 0x1D, 0x00, + 0x00, 0x00, 0x1D, 0x1D, 0x00, 0x03, 0x00, 0xFF, 0x1D, 0x00, + 0x02, 0x00, 0x1D, 0x00, 0x01, 0x00, 0x80, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE31_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x1C, 0x27, 0x1E, 0x00, + 0x00, 0x00, 0x1E, 0x1E, 0x00, 0x03, 0x00, 0xFF, 0x1E, 0x00, + 0x02, 0x00, 0x1E, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE32_DEMO[] = { + 0x02, 0x61, 0x00, 0x1B, 0x00, 0x40, 0x10, 0x78, 0x1F, 0x00, + 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x03, 0x00, 0xFF, 0x1F, 0x00, + 0x02, 0x00, 0x1F, 0x00, 0x01, 0x00, 0xFE, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE33_DEMO[] = { + 0x01, 0x61, 0x00, 0x1E, 0x00, 0x40, 0x3B, 0x4B, 0x20, 0x00, + 0x00, 0x00, 0x20, 0x20, 0x00, 0x03, 0x00, 0xFF, 0x20, 0x00, + 0x02, 0x00, 0x20, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE34_DEMO[] = { + 0x01, 0x61, 0x00, 0x04, 0x00, 0x30, 0x10, 0x51, 0x21, 0x00, + 0x00, 0x00, 0x21, 0x21, 0x00, 0x02, 0x00, 0xFF, 0x21, 0x00, + 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x2E, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE37_DEMO[] = { + 0x02, 0x61, 0x00, 0x04, 0x00, 0x3E, 0x3A, 0x32, 0x24, 0x00, + 0x00, 0x00, 0x24, 0x24, 0x00, 0x03, 0x00, 0xFF, 0x24, 0x00, + 0x02, 0x00, 0x24, 0x00, 0x01, 0x00, 0xB4, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x2D, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0x62, 0x00, 0x2E, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE38_DEMO[] = { + 0x03, 0x61, 0x00, 0x08, 0x00, 0x3F, 0x3F, 0xFF, 0x25, 0x00, + 0x00, 0x00, 0x25, 0x25, 0x00, 0x03, 0x00, 0xFF, 0x25, 0x00, + 0x02, 0x00, 0x25, 0x00, 0x01, 0x00, 0xFF, 0x40, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x62, 0x00, 0x21, 0x00, 0x01, 0x00, 0x62, 0x00, 0x25, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x1F, 0x00, 0x01, 0x00, 0x62, 0x00, + 0x30, 0x00, 0x01, 0x00, 0x62, 0x00, 0x32, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE39_DEMO[] = { + 0x01, 0x61, 0x00, 0x08, 0x00, 0x40, 0x32, 0x50, 0x26, 0x00, + 0x00, 0x00, 0x26, 0x26, 0x00, 0x03, 0x00, 0xFF, 0x26, 0x00, + 0x02, 0x00, 0x26, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x62, 0x00, 0x22, 0x00, 0x02, 0x00, 0x62, 0x00, 0x31, 0x00, + 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE40_DEMO[] = { + 0x02, 0x61, 0x00, 0x09, 0x00, 0x40, 0x3F, 0x37, 0x27, 0x00, + 0x00, 0x00, 0x27, 0x27, 0x00, 0x03, 0x00, 0xFF, 0x27, 0x00, + 0x02, 0x00, 0x27, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x62, 0x00, 0x1B, 0x00, 0x03, 0x00, 0x62, 0x00, 0x1C, 0x00, + 0x01, 0x00, 0x62, 0x00, 0x1F, 0x00, 0x02, 0x00, 0x62, 0x00, + 0x23, 0x00, 0x01, 0x00, 0x62, 0x00, 0x32, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE43_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1B, 0x6E, 0x2A, 0x00, + 0x00, 0x00, 0x2A, 0x2A, 0x00, 0x03, 0x00, 0xFF, 0x2A, 0x00, + 0x02, 0x00, 0x2A, 0x00, 0x01, 0x00, 0xA5, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE45_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1D, 0xBE, 0x2C, 0x00, + 0x00, 0x00, 0x2C, 0x2C, 0x00, 0x03, 0x00, 0xFF, 0x2C, 0x00, + 0x02, 0x00, 0x2C, 0x00, 0x01, 0x00, 0x50, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE46_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x1D, 0x78, 0x2D, 0x00, + 0x00, 0x00, 0x2D, 0x2D, 0x00, 0x03, 0x00, 0xFF, 0x2D, 0x00, + 0x02, 0x00, 0x2D, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE47_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0x2E, 0x00, + 0x00, 0x00, 0x2E, 0x2E, 0x00, 0x03, 0x00, 0xFF, 0x2E, 0x00, + 0x02, 0x00, 0x2E, 0x00, 0x01, 0x00, 0xF0, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE48_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0x2F, 0x00, + 0x00, 0x00, 0x2F, 0x2F, 0x00, 0x03, 0x00, 0xFF, 0x2F, 0x00, + 0x02, 0x00, 0x2F, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE51_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x32, 0xFF, 0xFF, + 0x00, 0x00, 0xFF, 0x32, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x04, + 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x32, + 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF +}; + +const byte ROOM_TABLE55_DEMO[] = { + 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x1E, 0x6E, 0x36, 0x00, + 0x00, 0x00, 0x36, 0x36, 0x00, 0x03, 0x00, 0xFF, 0x36, 0x00, + 0x02, 0x00, 0x36, 0x00, 0x01, 0x00, 0xFF, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0x36, 0x00, 0x04, 0x00, 0xFF, 0xFF, 0xFF, 0xFF +}; + +const byte ROOM_TABLE58_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x32, 0x14, 0x73, 0x39, 0x00, + 0x00, 0x00, 0x39, 0x39, 0x00, 0x03, 0x00, 0xFF, 0x39, 0x00, + 0x02, 0x00, 0x39, 0x00, 0x01, 0x00, 0xB4, 0x00, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, + 0xFF, 0xFF +}; + +const byte ROOM_TABLE62_DEMO[] = { + 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x3F, 0x19, 0x3D, 0x00, + 0x00, 0x00, 0x3D, 0x3D, 0x00, 0x03, 0x00, 0x3E, 0x3D, 0x00, + 0x04, 0x00, 0xFF, 0x3D, 0x00, 0x02, 0x00, 0x3D, 0x00, 0x01, + 0x00, 0xBE, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x62, + 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00 +}; + +const byte *ROOM_TABLE_DEMO[] = { + ROOM_TABLE1_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE5_DEMO, + ROOM_TABLE6_DEMO, ROOM_TABLE7_DEMO, nullptr, ROOM_TABLE9_DEMO, ROOM_TABLE10_DEMO, + ROOM_TABLE11_DEMO, ROOM_TABLE12_DEMO, ROOM_TABLE13_DEMO, ROOM_TABLE14_DEMO, ROOM_TABLE15_DEMO, + ROOM_TABLE16_DEMO, ROOM_TABLE17_DEMO, ROOM_TABLE18_DEMO, ROOM_TABLE19_DEMO, ROOM_TABLE20_DEMO, + ROOM_TABLE21_DEMO, ROOM_TABLE22_DEMO, ROOM_TABLE23_DEMO, ROOM_TABLE24_DEMO, ROOM_TABLE25_DEMO, + ROOM_TABLE26_DEMO, ROOM_TABLE27_DEMO, ROOM_TABLE28_DEMO, nullptr, ROOM_TABLE30_DEMO, + ROOM_TABLE31_DEMO, ROOM_TABLE32_DEMO, ROOM_TABLE33_DEMO, ROOM_TABLE34_DEMO, nullptr, + nullptr, ROOM_TABLE37_DEMO, ROOM_TABLE38_DEMO, ROOM_TABLE39_DEMO, ROOM_TABLE40_DEMO, + nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO, + ROOM_TABLE46_DEMO, ROOM_TABLE47_DEMO, ROOM_TABLE48_DEMO, nullptr, nullptr, + ROOM_TABLE51_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE55_DEMO, + nullptr, nullptr, ROOM_TABLE58_DEMO, nullptr, nullptr, + nullptr, ROOM_TABLE62_DEMO, nullptr, nullptr +}; + const int ROOM_NUMB = 63; const byte ELAINE[] = { diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 61659d30d4..e75b78a9e3 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -39,6 +39,7 @@ struct RiverStruct { }; extern const char *const FILENAMES[]; +extern const char *const FILENAMES_DEMO[]; extern const byte *CURSORS[10]; @@ -59,6 +60,7 @@ extern const int OVEROFFDLY[]; extern const byte *ROOM_TABLE[]; extern const char *ROOM_DESCR[]; +extern const byte *ROOM_TABLE_DEMO[]; extern const int ROOM_NUMB; extern const byte *CHARTBL[]; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 14514c2c7c..24aedf5722 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -41,7 +41,10 @@ AmazonRoom::~AmazonRoom() { } void AmazonRoom::loadRoom(int roomNumber) { - loadRoomData(ROOM_TABLE[roomNumber]); + if (_vm->isDemo()) + loadRoomData(ROOM_TABLE_DEMO[roomNumber]); + else + loadRoomData(ROOM_TABLE[roomNumber]); } void AmazonRoom::reloadRoom() { diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index 59c4bc4738..914f98e232 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -61,6 +61,10 @@ bool AccessEngine::isCD() const { return (bool)(_gameDescription->desc.flags & ADGF_CD); } +bool AccessEngine::isDemo() const { + return (bool)(_gameDescription->desc.flags & ADGF_DEMO); +} + Common::Language AccessEngine::getLanguage() const { return _gameDescription->desc.language; } diff --git a/engines/access/files.cpp b/engines/access/files.cpp index cbcfa3f614..6671a484de 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -82,7 +82,10 @@ byte *Resource::data() { FileManager::FileManager(AccessEngine *vm): _vm(vm) { switch (vm->getGameID()) { case GType_Amazon: - _filenames = &Amazon::FILENAMES[0]; + if (_vm->isDemo()) + _filenames = &Amazon::FILENAMES_DEMO[0]; + else + _filenames = &Amazon::FILENAMES[0]; break; case GType_MartianMemorandum: _filenames = &Martian::FILENAMES[0]; -- cgit v1.2.3 From f9685533292b0301ed9770439e55f39fbc934a7f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Dec 2014 23:50:40 +0100 Subject: ACCESS: Fix RoomInfo for the demo version, fix a typo in a comment --- engines/access/files.cpp | 2 +- engines/access/room.cpp | 7 ++++--- engines/access/room.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 6671a484de..9fff6c4102 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -211,7 +211,7 @@ void FileManager::setAppended(Resource *res, int fileNum) { if (!res->_file.open(_filenames[fileNum])) error("Could not open file %s", _filenames[fileNum]); - // If a different file has been opened then previously, load it's index + // If a different file has been opened then previously, load its index if (_fileNumber != fileNum) { _fileNumber = fileNum; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a5873b2c38..97341b04b9 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -167,7 +167,7 @@ void Room::clearRoom() { } void Room::loadRoomData(const byte *roomData) { - RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD()); + RoomInfo roomInfo(roomData, _vm->getGameID(), _vm->isCD(), _vm->isDemo()); _roomFlag = roomInfo._roomFlag; @@ -777,7 +777,7 @@ bool Room::checkCode(int v1, int v2) { /*------------------------------------------------------------------------*/ -RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { +RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo) { Common::MemoryReadStream stream(data, 999); _roomFlag = stream.readByte(); @@ -787,7 +787,8 @@ RoomInfo::RoomInfo(const byte *data, int gameType, bool isCD) { _estIndex = stream.readSint16LE(); else { _estIndex = -1; - stream.readSint16LE(); + if (!isDemo) + stream.readSint16LE(); } } else _estIndex = -1; diff --git a/engines/access/room.h b/engines/access/room.h index 4ec80d114c..db794dbc96 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -194,7 +194,7 @@ public: Common::Array _extraCells; Common::Array _sounds; public: - RoomInfo(const byte *data, int gameType, bool isCD); + RoomInfo(const byte *data, int gameType, bool isCD, bool isDemo); }; } // End of namespace Access -- cgit v1.2.3 From 8267b5d2abe9bd5f620502bd436acb74453daa06 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 2 Dec 2014 23:59:36 +0100 Subject: ACCESS: Skip the unknown midi file format used by the demo --- engines/access/sound.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index bf11d6a624..7dab0a75f7 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -182,27 +182,29 @@ void MusicManager::midiPlay() { error("midiPlay() wrong music resource size"); } - if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M')) - error("midiPlay() Unexpected signature"); - stop(); - _parser = MidiParser::createParser_XMIDI(); + if (READ_BE_UINT32(_music->data()) != MKTAG('F', 'O', 'R', 'M')) { + warning("midiPlay() Unexpected signature"); + _isPlaying = false; + } else { + _parser = MidiParser::createParser_XMIDI(); - if (!_parser->loadMusic(_music->data(), _music->_size)) - error("midiPlay() wrong music resource"); + if (!_parser->loadMusic(_music->data(), _music->_size)) + error("midiPlay() wrong music resource"); - _parser->setTrack(0); - _parser->setMidiDriver(this); - _parser->setTimerRate(_driver->getBaseTempo()); - _parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); - _parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1); + _parser->setTrack(0); + _parser->setMidiDriver(this); + _parser->setTimerRate(_driver->getBaseTempo()); + _parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); + _parser->property(MidiParser::mpSendSustainOffOnNotesOff, 1); - // Handle music looping - _parser->property(MidiParser::mpAutoLoop, _isLooping); + // Handle music looping + _parser->property(MidiParser::mpAutoLoop, _isLooping); - setVolume(127); - _isPlaying = true; + setVolume(127); + _isPlaying = true; + } } bool MusicManager::checkMidiDone() { -- cgit v1.2.3 From 860f7c717cc9ed2f89b87bd75783f3d74c19c572 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Dec 2014 00:33:08 +0100 Subject: ACCESS: Implement the demo logic in doTitle --- engines/access/amazon/amazon_logic.cpp | 80 ++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 68a52e77f8..b92197129a 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -236,27 +236,69 @@ void Opening::doCredit() { return; if (_pCount <= 75) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(90, 35)); - else if (_pCount <= 210) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35)); - else if (_pCount <= 272) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); - else if (_pCount <= 334) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); - else if (_pCount <= 396) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); - else if (_pCount <= 458) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35)); + else if (_pCount <= 210) { + if (_vm->isDemo()) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35)); + else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35)); + } else if (_pCount <= 272) { + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); + } else if (_pCount <= 334) { + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); + } else if (_pCount <= 396) { + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); + } else if (_pCount <= 458) { + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55)); + } else { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98)); + } } else if (_pCount <= 520) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80)); + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110)); + } else { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80)); + } } else if (_pCount <= 580) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81)); - } else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55)); + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105)); + } else { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81)); + } + } else { + if (_vm->isDemo()) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55)); + } } void Opening::scrollTitle() { -- cgit v1.2.3 From 2413fd0798b3eb0bd89b51a03dea432b40311bfd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Dec 2014 00:57:52 +0100 Subject: ACCESS: Skip the end of the full intro in the demo --- engines/access/amazon/amazon_logic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index b92197129a..4fcca20594 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -219,7 +219,7 @@ void Opening::doIntroduction() { _vm->_screen->setPanel(3); doTitle(); - if (_vm->shouldQuit() || _skipStart) + if (_vm->shouldQuit() || _skipStart || _vm->isDemo()) return; _vm->_screen->setPanel(3); -- cgit v1.2.3 From c6322702e692948933056b889820c84b8af842c5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Dec 2014 20:30:21 +0100 Subject: ACCESS: Fix doEstablish for the floppy and for the demo versions --- engines/access/amazon/amazon_game.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 5b27eb24a2..29197fe93c 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -142,7 +142,10 @@ void AmazonEngine::setupGame() { void AmazonEngine::initVariables() { _chapter = 1; // Set player room and position - _player->_roomNumber = 4; + if (isDemo()) + _player->_roomNumber = 33; + else + _player->_roomNumber = 4; _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; } @@ -212,7 +215,11 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(estabIndex); _et = estabIndex; - uint16 msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2); + uint16 msgOffset; + if (!isCD()) + msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2)); + else + msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2) + 2); _printEnd = 155; Common::String msg((const char *)_establish->data() + msgOffset); -- cgit v1.2.3 From cbd772ea5fa0c6911ba56d3aad78c078f1d9a2ac Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 3 Dec 2014 23:52:06 +0100 Subject: ACCESS: Avoid the call to loadScreen in mWhileDownRiver --- engines/access/amazon/amazon_logic.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 4fcca20594..65519f3b17 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1731,15 +1731,17 @@ void River::plotRiver() { void River::mWhileDownRiver() { _vm->_events->hideCursor(); + _vm->_screen->setDisplayScan(); _vm->_screen->clearScreen(); _vm->_screen->savePalette(); - - _vm->_files->loadScreen(95, 4); + if (!_vm->isDemo()) + _vm->_files->loadScreen(95, 4); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_screen->restorePalette(); _vm->_screen->setPalette(); _vm->_screen->setBufferScan(); + _vm->_screen->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); -- cgit v1.2.3 From 771bcc8efd12d40c9ad13c270fe93567e093f329 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 01:01:20 +0100 Subject: ACCESS: Add warnings about opcodes changed in the demo version --- engines/access/amazon/amazon_scripts.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index da43f1bc82..80aded7983 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -321,14 +321,29 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { loadBackground(param1, param2); break; case 3: - _game->_cast.doCast(param1); + if (_vm->isDemo()) + warning("TODO: DEMO - LOADCELLSET"); + else + _game->_cast.doCast(param1); break; case 4: - setInactive(); + if (_vm->isDemo()) + warning("TODO: DEMO - LOADNSOUND"); + else + setInactive(); + break; + case 5: + warning("TODO: DEMO - UNLOADCELLSET"); break; case 6: mWhile(param1); break; + case 7: + warning("TODO: DEMO - ADDMONEY"); + break; + case 8: + warning("TODO: DEMO - CHKMONEY"); + break; case 9: _game->_guard.doGuard(); break; -- cgit v1.2.3 From 580fec468f61d8883ad0a78b27cc6555532b5803 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 01:21:23 +0100 Subject: ACCESS: Implement loadNSound, add a warning about another special opcode used by the demo --- engines/access/amazon/amazon_scripts.cpp | 10 +++++++++- engines/access/amazon/amazon_scripts.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 80aded7983..43532aa93c 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -246,6 +246,11 @@ void AmazonScripts::loadBackground(int param1, int param2) { _vm->_screen->forceFadeIn(); } +void AmazonScripts::loadNSound(int param1, int param2) { + Resource *sound = _vm->_files->loadFile(param1, param2); + _vm->_sound->_soundTable.push_back(SoundEntry(sound, 1)); +} + void AmazonScripts::setInactive() { _game->_rawInactiveX = _vm->_player->_rawPlayer.x; _game->_rawInactiveY = _vm->_player->_rawPlayer.y; @@ -314,6 +319,9 @@ void AmazonScripts::plotInactive() { void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { switch (commandIndex) { + case 0: + warning("TODO: DEMO - RESETAN"); + break; case 1: _vm->establish(param1, param2); break; @@ -328,7 +336,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { break; case 4: if (_vm->isDemo()) - warning("TODO: DEMO - LOADNSOUND"); + loadNSound(param1, param2); else setInactive(); break; diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 968d51e2c4..573ffb89bf 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -45,6 +45,7 @@ protected: void mWhile(int param1); void loadBackground(int param1, int param2); void plotInactive(); + void loadNSound(int param1, int param2); void setInactive(); void boatWalls(int param1, int param2); -- cgit v1.2.3 From e35e6df93a72f1a29b731281bef123d675bcfd01 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 01:25:16 +0100 Subject: ACCESS: Rename cmdObject --- engines/access/scripts.cpp | 4 ++-- engines/access/scripts.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2c32f59ced..57af1a869c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -109,7 +109,7 @@ typedef void(Scripts::*ScriptMethodPtr)(); void Scripts::executeCommand(int commandIndex) { static const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::CMDOBJECT, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, + &Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, @@ -139,7 +139,7 @@ void Scripts::executeCommand(int commandIndex) { (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::CMDOBJECT() { +void Scripts::cmdObject() { _vm->_bubbleBox->load(_data); } diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 098fd4f322..cc9eca3d04 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -52,7 +52,7 @@ protected: */ Common::String readString(); - void CMDOBJECT(); + void cmdObject(); void cmdEndObject(); void cmdJumpLook(); void cmdJumpHelp(); -- cgit v1.2.3 From 7571fdd4b19f5f1bf3008d764c85c254ed86f635 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 02:01:51 +0100 Subject: ACCESS: Add some more Demo opcodes --- engines/access/amazon/amazon_scripts.cpp | 8 ++- engines/access/scripts.cpp | 100 ++++++++++++++++++++++++++++--- engines/access/scripts.h | 13 ++++ 3 files changed, 111 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 43532aa93c..5cf22106b7 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -472,8 +472,12 @@ void AmazonScripts::cmdCycleBack() { _vm->_screen->cyclePaletteBackwards(); } void AmazonScripts::cmdChapter() { - int chapter = _data->readByte(); - _game->startChapter(chapter); + if (_vm->isDemo()) { + cmdSetHelp(); + } else { + int chapter = _data->readByte(); + _game->startChapter(chapter); + } } void AmazonScripts::cmdSetHelp() { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 57af1a869c..053e824956 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -114,24 +114,24 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, - &Scripts::cmdSetInventory, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, + &Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetTimer, + &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout, &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, - &Scripts::cmdSetTravel, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, + &Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, - &Scripts::cmdSetScroll, &Scripts::cmdVideoEnded, &Scripts::cmdVideoEnded, + &Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded, &Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, - &Scripts::cmdSpecial, &Scripts::cmdSpecial, &Scripts::cmdSpecial, + &Scripts::cmdDoTravel, &Scripts::cmdCheckAbout, &Scripts::cmdSpecial, &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, &Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, - &Scripts::CMDPUSHLOCATION, &Scripts::CMDPUSHLOCATION, &Scripts::cmdPlayerOff, + &Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, + &Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut, &Scripts::cmdEndVideo }; @@ -263,6 +263,15 @@ void Scripts::cmdGoto() { searchForSequence(); } +void Scripts::cmdAddScore() { + if (_vm->isCD()) { + cmdSetInventory(); + return; + } + + _data->skip(1); +} + void Scripts::cmdSetInventory() { int itemId = _data->readByte(); int itemVal = _data->readByte(); @@ -400,6 +409,15 @@ void Scripts::cmdDispInv() { _vm->_inventory->newDisplayInv(); } +void Scripts::cmdSetAbout() { + if (_vm->isCD()) { + cmdSetTimer(); + return; + } + + error("TODO: DEMO - cmdSetAbout"); +} + void Scripts::cmdSetTimer() { int idx = _data->readUint16LE(); int val = _data->readUint16LE(); @@ -439,6 +457,14 @@ void Scripts::cmdCheckTimer() { } void Scripts::cmdSetTravel() { + if (_vm->isCD()) { + cmdJumpGoto(); + return; + } + error("TODO: DEMO - cmdSetTravel"); +} + +void Scripts::cmdJumpGoto() { if (_vm->_room->_selectCommand == 5) cmdGoto(); else @@ -486,6 +512,14 @@ void Scripts::cmdSetScroll() { _vm->_screen->_scrollY = 0; } +void Scripts::cmdSaveRect() { + if (_vm->isCD()) { + cmdVideoEnded(); + return; + } + error("TODO: DEMO - cmdSaveRect"); +} + void Scripts::cmdVideoEnded() { _vm->_events->pollEvents(); @@ -515,6 +549,22 @@ void Scripts::cmdRemoveLast() { --_vm->_numAnimTimers; } +void Scripts::cmdDoTravel() { + if (_vm->isCD()) { + cmdSpecial(); + return; + } + error("TODO: DEMO - cmdDoTravel"); +} + +void Scripts::cmdCheckAbout() { + if (_vm->isCD()) { + cmdSpecial(); + return; + } + error("TODO: DEMO - cmdCheckAbout"); +} + void Scripts::cmdSpecial() { _specialFunction = _data->readUint16LE(); int p1 = _data->readUint16LE(); @@ -774,7 +824,41 @@ void Scripts::cmdPlayVideoSound() { g_system->delayMillis(10); } -void Scripts::CMDPUSHLOCATION() { error("TODO CMDPUSHLOCATION"); } +void Scripts::cmdPrintWatch() { + if (_vm->isCD()) { + CMDPUSHLOCATION(); + return; + } + error("TODO: DEMO - cmdPrintWatch"); +} + +void Scripts::cmdDispAbout() { + if (_vm->isCD()) { + CMDPUSHLOCATION(); + return; + } + error("TODO: DEMO - cmdDispAbout"); +} + +void Scripts::CMDPUSHLOCATION() { + error("TODO CMDPUSHLOCATION"); +} + +void Scripts::cmdCheckTravel() { + if (_vm->isCD()) { + CMDPUSHLOCATION(); + return; + } + error("TODO: DEMO - cmdCheckTravel"); +} + +void Scripts::cmdBlock() { + if (_vm->isCD()) { + CMDPUSHLOCATION(); + return; + } + error("TODO: DEMO - cmdBlock"); +} void Scripts::cmdPlayerOff() { _vm->_player->_playerOff = true; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index cc9eca3d04..320da73bbb 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -71,6 +71,7 @@ protected: */ void cmdGoto(); + void cmdAddScore(); void cmdSetInventory(); void cmdCheckInventory(); void cmdSetTex(); @@ -83,8 +84,10 @@ protected: void cmdCheckLoc(); void cmdSetAnim(); void cmdDispInv(); + void cmdSetAbout(); void cmdSetTimer(); void cmdCheckTimer(); + void cmdJumpGoto(); void cmdSetTravel(); void cmdSetVideo(); void cmdPlayVideo(); @@ -92,10 +95,13 @@ protected: void cmdSetDisplay(); void cmdSetBuffer(); void cmdSetScroll(); + void cmdSaveRect(); void cmdVideoEnded(); void cmdSetBufVid(); void cmdPlayBufVid(); void cmdRemoveLast(); + void cmdDoTravel(); + void cmdCheckAbout(); void cmdSpecial(); void cmdSetCycle(); void cmdCycle(); @@ -111,12 +117,19 @@ protected: void cmdLoadSound(); void cmdSetVideoSound(); void cmdPlayVideoSound(); + void cmdPrintWatch(); + void cmdDispAbout(); void CMDPUSHLOCATION(); + void cmdCheckTravel(); + void cmdBlock(); void cmdPlayerOff(); void cmdPlayerOn(); void cmdDead(); void cmdFadeOut(); void cmdEndVideo(); + void cmdHelp(); + void cmdCycleBack(); + void cmdSetHelp(); public: int _sequence; bool _endFlag; -- cgit v1.2.3 From 889a564e73e824f736706345c19497007a321df7 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 22:25:37 -0500 Subject: ACCESS: Fix definition of river data structures --- engines/access/amazon/amazon_logic.cpp | 6 +++--- engines/access/amazon/amazon_resources.cpp | 28 +++++++++++++--------------- engines/access/amazon/amazon_resources.h | 14 ++++++-------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 65519f3b17..039cc01342 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1461,7 +1461,7 @@ void River::initRiver() { } _riverIndex = _vm->_riverFlag; - _topList = RIVEROBJECTTBL[_riverIndex]; + _topList = RIVER_OBJECTS[_riverIndex][RIVER_START]; updateObstacles(); riverSetPhysX(); _canoeDir = 0; @@ -1637,7 +1637,7 @@ void River::moveCanoe2() { void River::updateObstacles() { RiverStruct *cur; - for (cur = _topList; cur < RIVEROBJECTTBL[_riverIndex + 1]; ++cur) { + for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) { int val = cur->_field1 + cur->_field3 - 1; if (val < _screenVertX) break; @@ -1646,7 +1646,7 @@ void River::updateObstacles() { _topList = cur; _botList = cur; - while (cur < RIVEROBJECTTBL[_riverIndex + 1]) { + while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) { ++cur; val = cur->_field1 + cur->_field3 - 1; if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319))) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 8e5fccbf25..1b83e6bf70 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1980,7 +1980,7 @@ const int DOWNRIVEROBJ[14][4] = { { 3, 700, 0, 20 } }; -RiverStruct RIVER0OBJECTS[45] = { +RiverStruct RIVER0OBJECTS[46] = { {16, 31, 6400, 0, 4, 12}, {16, 31, 6200, 0, 2, 12}, {17, 30, 6100, 0, 3, 15}, @@ -2025,12 +2025,11 @@ RiverStruct RIVER0OBJECTS[45] = { {16, 31, 910, 0, 5, 12}, {17, 30, 705, 0, 0, 15}, {16, 31, 550, 0, 4, 12}, - {17, 30, 305, 0, 2, 15} + {17, 30, 305, 0, 2, 15}, + {16, 31, 260, 0, 7, 12} }; -RiverStruct ENDRIVER0[1] = { { 16, 31, 260, 0, 7, 12 } }; - -RiverStruct RIVER1OBJECTS[49] = { +RiverStruct RIVER1OBJECTS[50] = { {16, 31, 6920, 0, 1, 12}, {16, 31, 6740, 0, 4, 12}, {17, 30, 6699, 0, 1, 15}, @@ -2079,12 +2078,11 @@ RiverStruct RIVER1OBJECTS[49] = { {16, 31, 910, 0, 7, 12}, {17, 30, 705, 0, 0, 15}, {16, 31, 550, 0, 6, 12}, - {17, 30, 305, 0, 3, 15} + {17, 30, 305, 0, 3, 15}, + { 16, 31, 260, 0, 1, 12 } }; -RiverStruct ENDRIVER1[1] = { { 16, 31, 260, 0, 1, 12 } }; - -RiverStruct RIVER2OBJECTS[53] = { +RiverStruct RIVER2OBJECTS[54] = { {16, 31, 8230, 0, 6, 12}, {16, 31, 8115, 0, 7, 12}, {17, 30, 7955, 0, 4, 15}, @@ -2137,14 +2135,14 @@ RiverStruct RIVER2OBJECTS[53] = { {16, 31, 910, 0, 5, 12}, {17, 30, 705, 0, 0, 15}, {16, 31, 550, 0, 4, 12}, - {17, 30, 305, 0, 3, 15} + {17, 30, 305, 0, 3, 15}, + {16, 31, 260, 0, 6, 12} }; -RiverStruct ENDRIVER2[1] = { { 16, 31, 260, 0, 6, 12 } }; - -RiverStruct *RIVEROBJECTTBL[6] = { - RIVER0OBJECTS, ENDRIVER0, RIVER1OBJECTS, - ENDRIVER1, RIVER2OBJECTS, ENDRIVER2 +RiverStruct *RIVER_OBJECTS[3][2] = { + { RIVER0OBJECTS, RIVER0OBJECTS + 46 - 1}, + { RIVER1OBJECTS, RIVER0OBJECTS + 50 - 1 }, + { RIVER2OBJECTS, RIVER0OBJECTS + 54 - 1 } }; const int HELP1COORDS[2][4] = { diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index e75b78a9e3..be1dc7d05b 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -120,14 +120,12 @@ extern const byte *MAPTBL[3]; extern const int DOWNRIVEROBJ[14][4]; -extern RiverStruct RIVER0OBJECTS[45]; -extern RiverStruct ENDRIVER0[1]; -extern RiverStruct RIVER1OBJECTS[49]; -extern RiverStruct ENDRIVER1[1]; -extern RiverStruct RIVER2OBJECTS[53]; -extern RiverStruct ENDRIVER2[1]; - -extern RiverStruct *RIVEROBJECTTBL[6]; +extern RiverStruct RIVER0OBJECTS[46]; +extern RiverStruct RIVER1OBJECTS[50]; +extern RiverStruct RIVER2OBJECTS[54]; +extern RiverStruct *RIVER_OBJECTS[3][2]; +enum { RIVER_START = 0, RIVER_END = 1 }; + extern const int HELP1COORDS[2][4]; extern const int RIVER1OBJ[23][4]; -- cgit v1.2.3 From 4c2ab8b2979dcbc7ccaee4d42e79aed554d1eb46 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 22:53:45 -0500 Subject: ACCESS: Remove misnamed duplicate _screenVirtX field --- engines/access/amazon/amazon_logic.cpp | 16 ++++++++-------- engines/access/amazon/amazon_logic.h | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 039cc01342..1a9765e835 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -43,7 +43,6 @@ PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) { _xTrack = _yTrack = _zTrack = 0; _xCam = _yCam = _zCam = 0; _pNumObj = 0; - _screenVertX = 0; } void PannedScene::pan() { @@ -1363,7 +1362,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _rNewRectCount = 0; _rKeyFlag = 0; _mapOffset = 0; - _screenVirtX = 0; + _screenVertX = 0; _saveRiver = false; } @@ -1642,14 +1641,14 @@ void River::updateObstacles() { if (val < _screenVertX) break; - if (cur->_field3 < (_screenVirtX + 319)) { + if (cur->_field3 < (_screenVertX + 319)) { _topList = cur; _botList = cur; while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) { ++cur; val = cur->_field1 + cur->_field3 - 1; - if (val < _screenVertX || (cur->_field3 >= (_screenVirtX + 319))) + if (val < _screenVertX || (cur->_field3 >= (_screenVertX + 319))) break; _botList = cur; @@ -1834,15 +1833,16 @@ void River::river() { while (!_vm->shouldQuit()) { _vm->_events->_vbCount = 4; - // int bx = _vm->_player->_scrollAmount - _screenVertX; + // Move the river position + _screenVertX -= _vm->_player->_scrollAmount; + if (_vm->_screen->_scrollX == 0) { _vm->_midi->midiRepeat(); if (riverJumpTest()) { _CHICKENOUTFLG = false; return; } - } - else { + } else { _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; } @@ -1913,7 +1913,7 @@ void River::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_rNewRectCount); s.syncAsUint16LE(_rKeyFlag); s.syncAsUint16LE(_mapOffset); - s.syncAsUint16LE(_screenVirtX); + s.syncAsUint16LE(_screenVertX); warning("TODO: s.syncAsSint16LE(_topList);"); warning("TODO: s.syncAsSint16LE(_botList);"); diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index c2752af77b..f6f07b46e2 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -61,7 +61,6 @@ protected: int _yCam; int _zCam; int _pNumObj; - int _screenVertX; PanEntry _pan[PAN_SIZE]; public: @@ -183,7 +182,7 @@ private: int _rNewRectCount; int _rKeyFlag; int _mapOffset; - int _screenVirtX; + int _screenVertX; void initRiver(); void resetPositions(); -- cgit v1.2.3 From c1e80440b5969e025109301fad9fa8426558108a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 22:56:58 -0500 Subject: ACCESS: Fix the formatting of a bunch of else statements --- engines/access/amazon/amazon_logic.cpp | 36 ++++++++++++---------------------- engines/access/player.cpp | 3 +-- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 1a9765e835..94a61ade61 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1040,8 +1040,7 @@ void Guard::chkVLine() { if (_position.x > _vm->_player->_rawPlayer.x) { _topLeft = _vm->_player->_rawPlayer; _bottomRight = _position; - } - else { + } else { _topLeft = _position; _bottomRight = _vm->_player->_rawPlayer; } @@ -1071,8 +1070,7 @@ void Guard::chkVLine() { _topLeft.x = midX; _topLeft.y = midY; - } - else { + } else { if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) return; @@ -1086,8 +1084,7 @@ void Guard::chkHLine() { if (_position.y > _vm->_player->_rawPlayer.y) { _topLeft = _vm->_player->_rawPlayer; _bottomRight = _position; - } - else { + } else { _topLeft = _position; _bottomRight = _vm->_player->_rawPlayer; } @@ -1117,8 +1114,7 @@ void Guard::chkHLine() { _topLeft.x = midX; _topLeft.y = midY; - } - else { + } else { if ((midX == _bottomRight.x) && (midY == _bottomRight.y)) return; @@ -2032,15 +2028,13 @@ int Ant::antHandleStab(int indx, const int *&buf) { _pitPos.y = 127; retval = 0; buf = Amazon::PITWALK; - } - else { + } else { _pitPos.x += buf[(retval / 2) + 1]; _pitPos.y += buf[(retval / 2) + 2]; _pitCel = retval; } } - } - else { + } else { _stabFl = true; _pitCel = 0; retval = 0; @@ -2095,8 +2089,7 @@ void Ant::doAnt() { _vm->_flags[235] = 1; _antCel = 0; buf = Amazon::ANTEAT; - } - else { + } else { buf = Amazon::ANTWALK; if (_vm->_inventory->_inv[76]._value == 1) _antDirection = UP; @@ -2115,19 +2108,16 @@ void Ant::doAnt() { _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; } - } - else { + } else { idx += 6; if (buf[(idx / 2)] != -1) { _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; - } - else if (!_antDieFl) { + } else if (!_antDieFl) { idx = 0; _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; - } - else { + } else { idx -= 6; if (_vm->_flags[200] == 0) _vm->_flags[200] = 1; @@ -2148,8 +2138,7 @@ void Ant::doAnt() { idx = _pitCel; if (_stabFl == 1) { idx = antHandleStab(idx, buf); - } - else { + } else { buf = Amazon::PITWALK; if (_vm->_timers[13]._flag == 0) { _vm->_timers[13]._flag = 1; @@ -2160,8 +2149,7 @@ void Ant::doAnt() { idx = antHandleLeft(idx, buf); else if (pt.x > _pitPos.x) idx = antHandleRight(idx, buf); - } - else { + } else { buf = Amazon::PITWALK; if (_vm->_player->_playerDirection == UP) idx = antHandleStab(idx, buf); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index cb7459e8cc..97d7d4845d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -528,8 +528,7 @@ void Player::walkDownRight() { _rawTempL = (byte)tempL; _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] + (tempL >= 0x100 ? 1 : 0); - } - else { + } else { _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[_scrollConst]; } -- cgit v1.2.3 From 93b1516f9f7398de188808884f2696751056237a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 23:04:28 -0500 Subject: ACCESS: Fix display of rocks in the river arcade scene --- engines/access/amazon/amazon_logic.cpp | 28 ++++++++++++++-------------- engines/access/amazon/amazon_resources.h | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 94a61ade61..7029a7c917 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1633,18 +1633,18 @@ void River::moveCanoe2() { void River::updateObstacles() { RiverStruct *cur; for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) { - int val = cur->_field1 + cur->_field3 - 1; + int val = cur->_field1 + cur->_riverX - 1; if (val < _screenVertX) break; - if (cur->_field3 < (_screenVertX + 319)) { + if (cur->_riverX < (_screenVertX + 319)) { _topList = cur; _botList = cur; while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) { ++cur; - val = cur->_field1 + cur->_field3 - 1; - if (val < _screenVertX || (cur->_field3 >= (_screenVertX + 319))) + val = cur->_field1 + cur->_riverX - 1; + if (val < _screenVertX || (cur->_riverX >= (_screenVertX + 319))) break; _botList = cur; @@ -1663,7 +1663,7 @@ void River::riverSetPhysX() { int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; RiverStruct *cur = _topList; while (cur <= _botList) { - cur[0]._field5 = val - (_screenVertX - cur[0]._field3); + cur[0]._xp = val - (_screenVertX - cur[0]._riverX); ++cur; } } @@ -1675,12 +1675,12 @@ bool River::checkRiverCollide() { _canoeVXPos = _screenVertX + 170; for (RiverStruct *si = _topList; si <= _botList; ++si) { - if (si[0]._lane < _canoeLane) + if (si->_lane < _canoeLane) continue; - if ((si[0]._lane == _canoeLane) || (si[0]._lane == _canoeLane + 1)) { - if (si[0]._field1 + si[0]._field3 - 1 >= _canoeVXPos) { - if (_canoeVXPos + 124 >= si[0]._field3) { + if ((si->_lane == _canoeLane) || (si->_lane == _canoeLane + 1)) { + if (si->_field1 + si->_riverX - 1 >= _canoeVXPos) { + if (_canoeVXPos + 124 >= si->_riverX) { _vm->_sound->playSound(4); return true; } @@ -1710,14 +1710,14 @@ void River::plotRiver() { RiverStruct *cur = _topList; while (cur <= _botList) { - if (cur[0]._id != -1) { + if (cur->_id != -1) { ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; - ie._frameNumber = 0; - ie._position.x = cur[0]._field5; + ie._frameNumber = cur->_id; + ie._position.x = cur->_xp; int val = (cur[0]._lane * 5) + 56; - ie._position.y = val - cur[0]._field8; - ie._offsetY = cur[0]._field8; + ie._position.y = val - cur->_offsetY; + ie._offsetY = cur->_offsetY; _vm->_images.addToList(ie); } ++cur; diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index be1dc7d05b..b6b0dbbdce 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -32,10 +32,10 @@ namespace Amazon { struct RiverStruct { int _id; int _field1; - int _field3; - int _field5; + int _riverX; + int _xp; int _lane; - int _field8; + int _offsetY; }; extern const char *const FILENAMES[]; -- cgit v1.2.3 From f2cd2ee5b3b9cef53441375cb35bd2fd67a80f48 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 23:13:15 -0500 Subject: ACCESS: Move river death flags from engine to River class --- engines/access/amazon/amazon_game.h | 3 --- engines/access/amazon/amazon_logic.cpp | 25 +++++++++++++------------ engines/access/amazon/amazon_logic.h | 3 +++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index ca8287b87e..43fce80191 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -108,9 +108,6 @@ public: int _oldTitleChapter; int _maxHits; int _oldScrollCol; - bool _deathFlag; - int _deathCount; - int _deathType; int _iqValue; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 7029a7c917..9ccf5eb62c 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1360,6 +1360,8 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _mapOffset = 0; _screenVertX = 0; _saveRiver = false; + _deathFlag = false; + _deathCount = 0; } void River::setRiverPan() { @@ -1460,8 +1462,8 @@ void River::initRiver() { updateObstacles(); riverSetPhysX(); _canoeDir = 0; - _vm->_deathFlag = 0; - _vm->_deathCount = 0; + _deathFlag = false; + _deathCount = 0; _vm->_timers[11]._timer = 1200; _vm->_timers[11]._initTm = 1200; @@ -1518,15 +1520,15 @@ bool River::riverJumpTest() { _mapPtr += 3; if (_canoeLane < 3) { if (val1 != 0) { - _vm->_deathFlag = true; - _vm->_deathCount = 300; - _vm->_deathType = val2; + _deathFlag = true; + _deathCount = 300; + _deathType = val2; } } else { if (val1 != 1) { - _vm->_deathFlag = true; - _vm->_deathCount = 300; - _vm->_deathType = val2; + _deathFlag = true; + _deathCount = 300; + _deathType = val2; } _vm->_oldScrollCol = _vm->_screen->_scrollCol; _vm->_screen->_scrollCol = 44; @@ -1866,10 +1868,9 @@ void River::river() { return; } - if (_vm->_deathFlag) { - _vm->_deathCount--; - if (_vm->_deathCount == 0) { - _vm->dead(RIVERDEATH[_vm->_deathType]); + if (_deathFlag) { + if (--_deathCount == 0) { + _vm->dead(RIVERDEATH[_deathType]); return; } } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index f6f07b46e2..14f51990cc 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -167,6 +167,9 @@ private: RiverStruct *_botList; int _canoeDir; bool _saveRiver; + bool _deathFlag; + int _deathCount; + int _deathType; // Saved fields int _canoeLane; -- cgit v1.2.3 From 06f99158f063e72a492a661fc94529ec3b0d242a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 3 Dec 2014 23:22:03 -0500 Subject: ACCESS: Debounce any mouse press when showing death screen --- engines/access/amazon/amazon_game.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 29197fe93c..248f5e2f49 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -607,6 +607,8 @@ void AmazonEngine::dead(int deathId) { _events->hideCursor(); _screen->forceFadeOut(); _scripts->cmdFreeSound(); + _events->debounceLeft(); + _events->zeroKeys(); _sound->_soundTable.push_back(SoundEntry(_files->loadFile(98, 44), 1)); -- cgit v1.2.3 From 3c97961fd2c300a4b4541517a4884498f5d52366 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 13:43:12 +0100 Subject: ACCESS: Fix the display in the floppy and demo version by removing the inventory pre-rendering --- engines/access/inventory.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 629b89f155..1bf3bdc8a0 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -102,10 +102,14 @@ void InventoryManager::setUseItem(int itemId) { } void InventoryManager::refreshInventory() { - if (_vm->_screen->_vesaMode) { - _invRefreshFlag = true; - newDisplayInv(); - } + + // The original version was using pre-rendering for the inventory to spare some time. + // This is not needed on modern hardware, and it breaks a couple of things. + // Therefore it was removed in order to keep the same logic than for the CD version + // if (_vm->_screen->_vesaMode) { + // _invRefreshFlag = true; + // newDisplayInv(); + // } } int InventoryManager::newDisplayInv() { -- cgit v1.2.3 From 84ba0df9b2ce15d6c1d32a6c61794a1accb3fc99 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 4 Dec 2014 14:17:30 +0100 Subject: ACCESS: Janitorial --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_game.cpp | 26 +++---- engines/access/amazon/amazon_logic.cpp | 10 +-- engines/access/amazon/amazon_resources.cpp | 40 +++++------ engines/access/amazon/amazon_room.cpp | 8 +-- engines/access/amazon/amazon_scripts.cpp | 10 +-- engines/access/animation.cpp | 6 +- engines/access/asurface.cpp | 6 +- engines/access/bubble_box.cpp | 10 +-- engines/access/bubble_box.h | 2 +- engines/access/data.h | 2 +- engines/access/events.h | 4 +- engines/access/files.cpp | 4 +- engines/access/font.cpp | 6 +- engines/access/inventory.cpp | 17 +++-- engines/access/martian/martian_resources.cpp | 12 ++-- engines/access/martian/martian_room.cpp | 4 +- engines/access/player.cpp | 18 ++--- engines/access/resources.cpp | 4 +- engines/access/room.cpp | 14 ++-- engines/access/scripts.cpp | 104 +++++++++++++-------------- engines/access/sound.cpp | 12 ++-- engines/access/video.cpp | 10 +-- 23 files changed, 165 insertions(+), 166 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 41706fc4fd..2153f594b1 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -396,7 +396,7 @@ void AccessEngine::copyBF1BF2() { void AccessEngine::copyBF2Vid() { const byte *srcP = (const byte *)_buffer2.getPixels(); - byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd, + byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd, _screen->_windowYAdd + _screen->_screenYOff); for (int yp = 0; yp < _screen->_vWindowLinesTall; ++yp) { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 248f5e2f49..deb45ff4b1 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -32,12 +32,12 @@ namespace Amazon { AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc), - _guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), + _guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), - _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), - _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), + _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), + _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), _noSound(_flags[239]), - _ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), + _ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), _plane(this), _river(this) { _charSegSwitch = false; @@ -263,7 +263,7 @@ void AmazonEngine::tileScreen() { int x = res->_stream->readSint16LE(); int y = res->_stream->readSint16LE(); int size = ((x + 2) * y) + 10; - + for (int i = 0; i < size; ++i) _tileData[i] = res->_stream->readByte(); @@ -292,7 +292,7 @@ void AmazonEngine::updateSummary(int chap) { _updateChapter = chapter; Common::Array summaryCells; loadCells(summaryCells); - + for (int i = celSubFile; i < 16; ++i) { if (i > 7) warning("TODO: DRAWOBJECT"); @@ -374,7 +374,7 @@ void AmazonEngine::helpTitle() { index = 169; index /= 20; - + iqText += " "; iqText += IQLABELS[index]; @@ -439,7 +439,7 @@ void AmazonEngine::drawHelp(const Common::String str) { _screen->_clipHeight = 200; _screen->plotImage(_objectsTable[95], 0, Common::Point(76, 168)); _destIn = oldDest; - _screen->_clipHeight = oldClip; + _screen->_clipHeight = oldClip; } if ((_useItem == 0) && (_screen->_vesaMode == 0)) @@ -456,7 +456,7 @@ void AmazonEngine::startChapter(int chapter) { if (chapter != 1) { _room->clearRoom(); freeChar(); - + _midi->newMusic(32, 0); playVideo(0, Common::Point()); if (shouldQuit()) @@ -495,7 +495,7 @@ void AmazonEngine::startChapter(int chapter) { _screen->clearScreen(); _screen->setPanel(3); - + // Set up cells for the chapter display Common::Array chapterCells; chapterCells.push_back(CellIdent(0, 96, 17)); @@ -508,7 +508,7 @@ void AmazonEngine::startChapter(int chapter) { _buffer2.copyFrom(*_screen); const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0]; - _screen->plotImage(_objectsTable[0], _chapter - 1, + _screen->plotImage(_objectsTable[0], _chapter - 1, Common::Point(chapImg[1], chapImg[2])); _screen->plotImage(_objectsTable[_chapter], 0, Common::Point(chapImg[3], chapImg[4])); @@ -535,7 +535,7 @@ void AmazonEngine::startChapter(int chapter) { _screen->forceFadeOut(); _events->debounceLeft(); _events->zeroKeys(); - + _screen->clearBuffer(); _files->loadScreen(96, 16); _buffer2.copyFrom(*_screen); @@ -573,7 +573,7 @@ void AmazonEngine::startChapter(int chapter) { _screen->forceFadeOut(); _screen->clearBuffer(); freeCells(); - + _midi->newMusic(_chapter * 2, 1); if (chapter != 1 && chapter != 14) { diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 9ccf5eb62c..428b85f969 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -245,19 +245,19 @@ void Opening::doCredit() { if (_vm->isDemo()) { _vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20)); _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35)); - } else + } else _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); } else if (_pCount <= 334) { if (_vm->isDemo()) { _vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70)); _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85)); - } else + } else _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); } else if (_pCount <= 396) { if (_vm->isDemo()) { _vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15)); _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30)); - } else + } else _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); } else if (_pCount <= 458) { if (_vm->isDemo()) { @@ -320,7 +320,7 @@ void Opening::doTitle() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 3); - + _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); @@ -523,7 +523,7 @@ void Opening::doTent() { } _vm->_events->pollEventsAndWait(); - } + } _vm->_sound->playSound(5); _vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 1b83e6bf70..bd4e4f838d 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -68,10 +68,10 @@ const char *const FILENAMES_DEMO[] = { "C17.AP", "C19.AP", "C20.AP", "C21.AP", "C22.AP", "C23.AP", "C24.AP", "C25.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP", - "CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" + "CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" }; const byte MOUSE0[] = { - 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, @@ -971,7 +971,7 @@ const byte *ROOM_TABLE_DEMO[] = { ROOM_TABLE26_DEMO, ROOM_TABLE27_DEMO, ROOM_TABLE28_DEMO, nullptr, ROOM_TABLE30_DEMO, ROOM_TABLE31_DEMO, ROOM_TABLE32_DEMO, ROOM_TABLE33_DEMO, ROOM_TABLE34_DEMO, nullptr, nullptr, ROOM_TABLE37_DEMO, ROOM_TABLE38_DEMO, ROOM_TABLE39_DEMO, ROOM_TABLE40_DEMO, - nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO, + nullptr, nullptr, ROOM_TABLE43_DEMO, nullptr, ROOM_TABLE45_DEMO, ROOM_TABLE46_DEMO, ROOM_TABLE47_DEMO, ROOM_TABLE48_DEMO, nullptr, nullptr, ROOM_TABLE51_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE55_DEMO, nullptr, nullptr, ROOM_TABLE58_DEMO, nullptr, nullptr, @@ -1124,14 +1124,14 @@ const byte BEXPLODE[] = { const byte THORNICK[] = { 0x2, 0x7, 0x0, 0x7, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, - 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0, - 0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3, + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x0, 0x0, 0x0, 0x7, 0x0, 0x2, 0x0, + 0x7, 0x0, 0x5, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x6, 0x0, 0x7, 0x0, 0x3, 0x0, 0x7, 0x0, 0x7, 0x0, 0x7, 0x0, 0x4, 0x0, 0x7, 0x0, 0x8, 0x0, 0xFF, 0xFF }; const byte MAYA[] = { - 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, - 0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, + 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x48, 0x48, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x48, 0x0, 0x0, 0x0, 0x48, 0x0, 0x2, 0x0, 0x48, 0x0, 0x13, 0x0, 0x48, 0x0, 0x3, 0x0, 0x48, 0x0, 0x14, 0x0, 0x48, 0x0, 0x4, 0x0, 0x48, 0x0, 0x15, 0x0, 0x48, 0x0, 0x5, 0x0, 0x48, 0x0, 0x16, 0x0, 0x48, 0x0, 0x6, 0x0, 0x48, @@ -1258,14 +1258,14 @@ const byte JWATER[] = { const byte SHOOT[] = { 0x2, 0xFF, 0xFF, 0x52, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x38, 0x52, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, - 0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52, + 0x0, 0x52, 0x0, 0x0, 0x0, 0x52, 0x0, 0x3, 0x0, 0x52, 0x0, 0x5, 0x0, 0x52, 0x0, 0x4, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF }; const byte ADIE[] = { 0x2, 0xFF, 0xFF, 0x53, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x2, 0x0, 0x53, 0x0, 0x0, 0x0, 0x53, - 0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4, + 0x0, 0x2, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x3, 0x0, 0x62, 0x0, 0x4, 0x0, 0x53, 0x0, 0x4, 0x0, 0x62, 0x0, 0x4, 0x0, 0xFF, 0xFF }; @@ -1278,20 +1278,20 @@ const byte DYNAMITE[] = { const byte MAYASHOT[] = { 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x36, 0x55, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, - 0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, + 0x3, 0x0, 0x55, 0x0, 0x0, 0x0, 0x55, 0x0, 0x2, 0x0, 0x62, 0x0, 0x1F, 0x0, 0xFF, 0xFF }; const byte OFFKEV[] = { - 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, - 0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, + 0x0, 0x0, 0x0, 0x4D, 0x29, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x29, 0x0, 0x0, 0x0, 0x29, 0x0, 0x2, 0x0, 0x29, 0x0, 0x3, 0x0, 0xFF, 0xFF }; const byte VALLEY[] = { 0x2, 0x3A, 0x0, 0x3A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 0x0, 0x3A, 0x3A, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0xFF, 0x3, 0x0, - 0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0, + 0x3A, 0x0, 0x0, 0x0, 0x3A, 0x0, 0x3, 0x0, 0x3A, 0x0, 0x5, 0x0, 0x3A, 0x0, 0x4, 0x0, 0x62, 0x0, 0x27, 0x0, 0xFF, 0xFF }; @@ -1352,14 +1352,14 @@ const byte ROBOT[] = { }; const byte ANTKILL[] = { - 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, - 0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59, + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, + 0x0, 0x0, 0x3C, 0x59, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x59, 0x0, 0x0, 0x0, 0x59, 0x0, 0x2, 0x0, 0x62, 0x0, 0x0E, 0x0, 0xFF, 0xFF }; const byte LOCOHOT[] = { - 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, - 0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A, + 0x3, 0xFF, 0xFF, 0xFF, 0xFF, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, + 0x0, 0x0, 0x19, 0x5A, 0x0, 0x1, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x5A, 0x0, 0x0, 0x0, 0x5A, 0x0, 0x2, 0x0, 0x62, 0x0, 0x3C, 0x0, 0xFF, 0xFF }; @@ -1593,7 +1593,7 @@ const byte FONT6x6_DATA[] = { 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x4d, 0x4f, 0x56, 0x49, }; -const char *const NO_HELP_MESSAGE = +const char *const NO_HELP_MESSAGE = "WE ARE UNABLE TO PROVIDE YOU WITH ANY MORE HINTS. YOUR IQ \ HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \ YOU CAN UNDERSTAND."; @@ -1707,7 +1707,7 @@ const char *const DEATH_TEXT[58] = { "MAYA FALLS OFF THE END OF THE BROKEN BRIDGE.", "YOUR WEIGHT IS JUST ENOUGH TO CAUSE THE REMAINING SUPPORT CABLE TO SNAP AND YOU " "FALL TO THE BOTTOM OF THE GORGE.", - + "EVEN WITH REPAIRS THE BRIDGE IS NOT STRONG ENOUGH TO HOLD TWO PEOPLE.", "SANCHEZ AND HIS MEN FIND YOU AND HOLD FIRING SQUAD PRACTICE.", "THE TWO GUARDS ARE DISTURBED IN THEIR LOVE NEST AND COME LOOKING FOR ANYONE ACTING SUSPICIOUS. " @@ -1886,7 +1886,7 @@ const int ANTEAT[33] = { 9, 0, -6, 8, 0, 11, 7, 0, 6, - -1, -1, -1 + -1, -1, -1 }; const int ANTDIE[21] = { diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 24aedf5722..d6ab2bd758 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -54,7 +54,7 @@ void AmazonRoom::reloadRoom() { _vm->_currentMan = _roomFlag; _vm->_currentManOld = _roomFlag; _vm->_manScaleOff = 0; - + switch (_vm->_currentMan) { case 0: _vm->_player->loadSprites("MAN.LZ"); @@ -78,7 +78,7 @@ void AmazonRoom::reloadRoom() { } void AmazonRoom::reloadRoom1() { - if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 + if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); _game->_inactive._altSpritesPtr = new SpriteResource(_vm, spriteData); @@ -183,7 +183,7 @@ void AmazonRoom::mainAreaClick() { default: break; } - } + } // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due // to not being able to click a Y position that's high enough @@ -208,7 +208,7 @@ void AmazonRoom::walkCursor() { // the Exit icon wgeb the cursor is already a walk cursor EventsManager &events = *_vm->_events; - if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && + if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS)) { events._normalMouse = CURSOR_CROSSHAIRS; events.setCursor(CURSOR_CROSSHAIRS); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 5cf22106b7..fb1ccbe05e 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -57,7 +57,7 @@ void AmazonScripts::mWhile1() { _vm->_screen->setIconPalette(); _vm->_screen->forceFadeIn(); - + Resource *spriteData = _vm->_files->loadFile(14, 6); _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); delete spriteData; @@ -340,7 +340,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { else setInactive(); break; - case 5: + case 5: warning("TODO: DEMO - UNLOADCELLSET"); break; case 6: @@ -450,7 +450,7 @@ void AmazonScripts::cmdHelp() { _vm->_screen->restorePalette(); _vm->_screen->setPalette(); _vm->_events->showCursor(); - + delete _vm->_objectsTable[45]; _vm->_objectsTable[45] = nullptr; _vm->_timers.restoreTimers(); @@ -507,8 +507,8 @@ void AmazonScripts::cmdMainPanel() { } } -void AmazonScripts::CMDRETFLASH() { - error("TODO CMDRETFLASH"); +void AmazonScripts::CMDRETFLASH() { + error("TODO CMDRETFLASH"); } } // End of namespace Amazon diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index e59874fe7a..b13fcfdc1e 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -87,7 +87,7 @@ typedef void(Animation::*AnimationMethodPtr)(); void Animation::animate() { static const AnimationMethodPtr METHODS[8] = - { &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, + { &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, &Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 }; (this->*METHODS[_type])(); @@ -310,10 +310,10 @@ Animation *AnimationManager::setAnimation(int animId) { anim->_countdownTicks = anim->_initialTicks; anim->_frameNumber = 0; - anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : + anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : anim->_loopCount; anim->_field10 = 0; - + return anim; } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 4202ed098f..cd872e04b2 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -55,11 +55,11 @@ SpriteFrame::SpriteFrame(AccessEngine *vm, Common::SeekableReadStream *stream, i int xSize = stream->readUint16LE(); int ySize = stream->readUint16LE(); create(xSize, ySize); - + // Empty surface byte *data = (byte *)getPixels(); Common::fill(data, data + w * h, 0); - + // Decode the data for (int y = 0; y < h; ++y) { int offset = stream->readByte(); @@ -225,7 +225,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { int scaleXCtr = 0, scaleYCtr = 0; for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) { - // Handle skipping lines if Y scaling + // Handle skipping lines if Y scaling scaleYCtr += scaleY; if (scaleYCtr < SCALE_LIMIT) continue; diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index ff6c4de53d..e9e2a182c0 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -159,10 +159,10 @@ void BubbleBox::printBubble(const Common::String &msg) { int xp = _vm->_screen->_printOrg.x; if (_type == TYPE_4) xp = (_bounds.width() - width) / 2 + _bounds.left - 4; - + // Draw the text font2.drawString(_vm->_screen, line, Common::Point(xp, _vm->_screen->_printOrg.y)); - + // Move print position _vm->_screen->_printOrg.y += 6; _vm->_screen->_printOrg.x = _vm->_screen->_printStart.x; @@ -237,10 +237,10 @@ void BubbleBox::doBox(int item, int box) { yp += (_type == TYPE_4) ? 4 : 8; for (int x = 0; x < xSize; ++x, xp += 20) { - screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x, + screen.plotImage(icons, (_type == TYPE_4 ? 62 : 34) + x, Common::Point(xp, yp)); } - + yp = screen._orgY2 - (_type == TYPE_4 ? 18 : 12); screen.plotImage(icons, (_type == TYPE_4) ? 73 : 23, Common::Point(xp, yp)); @@ -274,7 +274,7 @@ void BubbleBox::doBox(int item, int box) { _charCol = charCol; _rowOff = rowOff; _vm->_screen->restoreScreen(); - + // Free icons data delete icons; } diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 7b25a58183..128bd618ff 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -71,7 +71,7 @@ public: void calcBubble(const Common::String &msg); /** - * Prints a text bubble and it's contents + * Prints a text bubble and it's contents */ void printBubble(const Common::String &msg); diff --git a/engines/access/data.h b/engines/access/data.h index 08fbb40d68..6b44eddd75 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -77,7 +77,7 @@ public: void updateTimers(); /** - * Synchronize savegame data + * Synchronize savegame data */ void synchronize(Common::Serializer &s); }; diff --git a/engines/access/events.h b/engines/access/events.h index 95ba926384..965e8e7fd6 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -29,9 +29,9 @@ namespace Access { -enum CursorType { +enum CursorType { CURSOR_NONE = -1, - CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, + CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK, CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP, CURSOR_INVENTORY = 99 }; diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 9fff6c4102..b846cbd32c 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -187,7 +187,7 @@ void FileManager::handleFile(Resource *res) { bool isCompressed = !strncmp(header, "DBE", 3); - // If the data is compressed, uncompress it and replace the stream + // If the data is compressed, uncompress it and replace the stream // in the resource with the decompressed one if (isCompressed) { // Read in the entire compressed data @@ -214,7 +214,7 @@ void FileManager::setAppended(Resource *res, int fileNum) { // If a different file has been opened then previously, load its index if (_fileNumber != fileNum) { _fileNumber = fileNum; - + // Read in the file index int count = res->_file.readUint16LE(); assert(count <= 100); diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 5686cdf3b0..51fb9dc1c8 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -50,7 +50,7 @@ void Font::load(const int *fontIndex, const byte *fontData) { int bitsLeft = 0; byte srcByte = 0; byte pixel; - + byte *pDest = (byte *)_chars[i].getBasePtr(0, y); for (int x = 0; x < _chars[i].w; ++x, ++pDest) { // Get the pixel @@ -115,8 +115,8 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w s = ""; return true; } - - // Work backwards to find space at the start of the current word + + // Work backwards to find space at the start of the current word // as a point to split the line on while (src >= s.c_str() && *src != ' ') { width -= charWidth(*src); diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 1bf3bdc8a0..d9e1b496a4 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -93,16 +93,15 @@ int &InventoryManager::operator[](int idx) { return (idx >= (int)_inv.size()) ? invalid : _inv[idx]._value; } -int InventoryManager::useItem() { +int InventoryManager::useItem() { return _vm->_useItem; } -void InventoryManager::setUseItem(int itemId) { - _vm->_useItem = itemId; +void InventoryManager::setUseItem(int itemId) { + _vm->_useItem = itemId; } void InventoryManager::refreshInventory() { - // The original version was using pre-rendering for the inventory to spare some time. // This is not needed on modern hardware, and it breaks a couple of things. // Therefore it was removed in order to keep the same logic than for the CD version @@ -120,7 +119,7 @@ int InventoryManager::newDisplayInv() { _invModeFlag = true; _vm->_timers.saveTimers(); - + if (!room._tile && !_invRefreshFlag) { saveScreens(); } @@ -361,7 +360,7 @@ void InventoryManager::saveScreens() { _vm->_buffer1.copyTo(&_savedBuffer1); _vm->_screen->copyTo(&_savedScreen); _vm->_newRects.push_back(Common::Rect(0, 0, _savedScreen.w, _savedScreen.h)); - + } void InventoryManager::restoreScreens() { @@ -425,7 +424,7 @@ void InventoryManager::combineItems() { Common::Point newPt; newPt.x = MAX(events._mousePos.x - tempMouse.x + tempBox.x, 0); newPt.y = MAX(events._mousePos.y - tempMouse.y + tempBox.y, 0); - + screen.plotImage(sprites, invItem, newPt); lastBox = newPt; } @@ -435,7 +434,7 @@ void InventoryManager::combineItems() { && _items[destBox] != -1) { int itemA = invItem; int itemB = _items[destBox]; - + // Check whether the items can be combined int combinedItem = _inv[itemA].checkItem(itemB); if (combinedItem != -1) { @@ -454,7 +453,7 @@ void InventoryManager::combineItems() { Common::Rect destRect(_invCoords[destBox].left, _invCoords[destBox].top, _invCoords[destBox].left + 46, _invCoords[destBox].top + 35); _vm->_buffer2.copyBlock(&_vm->_buffer1, destRect); - screen._screenYOff = 0; + screen._screenYOff = 0; zoomIcon(itemB, -1, destBox, true); // Exand up the new combined item from nothing to full size diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp index ae63f66c7c..046e06c6e3 100644 --- a/engines/access/martian/martian_resources.cpp +++ b/engines/access/martian/martian_resources.cpp @@ -32,11 +32,11 @@ const char *const FILENAMES[] = { "R08.AP", "R09.AP", "R10.AP", "R11.AP", "R12.AP", "R13.AP", "R14.AP", "R15.AP", "R16.AP", "R17.AP", "R18.AP", "R19.AP", "R20.AP", "R21.AP", "R22.AP", "R23.AP", "R24.AP", "R25.AP", "R26.AP", "R27.AP", "R28.AP", "R29.AP", "R30.AP", "R31.AP", - "R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", + "R32.AP", "R33.AP", "R34.AP", "R35.AP", "R36.AP", "R37.AP", "R38.AP", "R39.AP", "R40.AP","TITLE.AP","R42.AP","S01.AP", "R44.AP", "R45.AP","SOUND.AP","MUSIC.AP", "DEAD.AP","EST.AP", "W02.AP", "C02.AP", "C05.AP", "C04.AP", "C10.AP", "C03.AP", - "C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", - "C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", + "C07.AP", "LOVE.AP","CAFE.AP","C08.AP", "C18.AP", "C19.AP", "C21.AP", "C23.AP", + "C12.AP", "C16.AP","CAFE1.AP","C05A.AP","C06.AP","C11.AP", "C13.AP", "C20.AP", "C16A.AP","C09.AP", "R45.AP", "R46.AP", "R47.AP", "R48.AP", "R49.AP" }; @@ -653,9 +653,9 @@ const byte CHAR_TABLE27[] = { const byte *CHAR_TABLE[] = { CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5, CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10, - CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, - CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20, - CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25, + CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, + CHAR_TABLE16, nullptr, CHAR_TABLE18, CHAR_TABLE19, CHAR_TABLE20, + CHAR_TABLE21, nullptr, CHAR_TABLE23, CHAR_TABLE24, CHAR_TABLE25, CHAR_TABLE26, CHAR_TABLE27 }; diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 62c44bc529..2bd98186f0 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -49,7 +49,7 @@ void MartianRoom::reloadRoom() { _vm->_currentMan = _roomFlag; _vm->_currentManOld = _roomFlag; _vm->_manScaleOff = 0; - + switch (_vm->_currentMan) { case 0: _vm->_player->loadSprites("MAN.LZ"); @@ -73,7 +73,7 @@ void MartianRoom::reloadRoom() { } void MartianRoom::reloadRoom1() { - if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 + if (_vm->_player->_roomNumber == 29 || _vm->_player->_roomNumber == 31 || _vm->_player->_roomNumber == 42 || _vm->_player->_roomNumber == 44) { //Resource *spriteData = _vm->_files->loadFile("MAYA.LZ"); //_vm->_inactive._spritesPtr = new SpriteResource(_vm, spriteData); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 97d7d4845d..5668e9c6b9 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -146,7 +146,7 @@ void Player::removeSprite1() { void Player::calcManScale() { if (!_vm->_manScaleOff) { - _vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * + _vm->_scale = ((((_rawPlayer.y - _vm->_scaleMaxY + _vm->_scaleN1) * _vm->_scaleT1 + (_vm->_scaleH2 << 8)) & 0xff00) / _vm->_scaleH1 * _vm->_scaleI) >> 8; _vm->_screen->setScaleTable(_vm->_scale); @@ -159,7 +159,7 @@ void Player::calcManScale() { void Player::walk() { _collideFlag = false; _playerDirection = NONE; - + if (_playerOff) return; else if (_vm->_timers[0]._flag) { @@ -223,7 +223,7 @@ void Player::walkUp() { int walkOff = _walkOffUp[_frame - _upWalkMin]; int tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOff]; _rawYTempL = (byte)tempL; - int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] - + int yTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff] - (tempL < 0 ? 1 : 0); _rawYTemp = yTemp; _rawXTemp = _rawPlayer.x; @@ -233,7 +233,7 @@ void Player::walkUp() { } else { _rawPlayer.y = _rawYTemp; _rawPlayerLow.y = _rawYTempL; - + calcManScale(); // This code looks totally useless as 'si' is unconditionally set in plotCom @@ -297,7 +297,7 @@ void Player::walkLeft() { (tempL < 0 ? 1 : 0); } else { _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; - } + } _rawYTemp = _rawPlayer.y; if (_vm->_room->codeWalls()) { @@ -378,7 +378,7 @@ void Player::walkUpLeft() { } else { _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst]; } - + walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y; tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; _rawYTempL = (byte)tempL; @@ -446,7 +446,7 @@ void Player::walkDownLeft() { ++_frame; calcManScale(); - + // This code looks totally useless as 'si' is unconditionally set in plotCom1 //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) // warning("TODO: walkDownLeft - si = 0?"); @@ -668,7 +668,7 @@ void Player::checkScroll() { if (!scrollRight()) { if (_playerDirection == DOWNLEFT) goto scrollUp; - + return; } } else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT || @@ -678,7 +678,7 @@ void Player::checkScroll() { if (!scrollLeft()) { if (_playerDirection == DOWNRIGHT) goto scrollUp; - + return; } } diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 9bef5cf879..41f611d136 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -26,7 +26,7 @@ namespace Access { const byte INITIAL_PALETTE[18 * 3] = { - 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xe0, @@ -73,7 +73,7 @@ const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT."; const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS"; const char *TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE."; const char *const GENERAL_MESSAGES[] = { - LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, + LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE }; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 97341b04b9..b3c3317307 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -266,7 +266,7 @@ void Room::setupRoom() { screen._scrollCol -= sx + 1; } } - + if (screen._vWindowHeight == _playFieldHeight) { screen._scrollY = 0; screen._scrollRow = 0; @@ -317,7 +317,7 @@ void Room::buildColumn(int playX, int screenX) { if (playX < 0 || playX >= _playFieldWidth) return; - const byte *pSrc = _playField + _vm->_screen->_scrollRow * + const byte *pSrc = _playField + _vm->_screen->_scrollRow * _playFieldWidth + playX; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns @@ -406,7 +406,7 @@ Plotter::Plotter() { void Plotter::load(Common::SeekableReadStream *stream, int wallCount, int blockCount) { // Load the wall count _walls.resize(wallCount); - + for (int i = 0; i < wallCount; ++i) _walls[i].left = stream->readSint16LE(); for (int i = 0; i < wallCount; ++i) @@ -474,7 +474,7 @@ void Room::doCommands() { } } -void Room::cycleCommand(int incr) { +void Room::cycleCommand(int incr) { int command = _selectCommand + incr; if (command < -1) command = 6; @@ -560,7 +560,7 @@ void Room::executeCommand(int commandId) { delete iconData; // Draw the button as selected - _vm->_screen->plotImage(spr, _selectCommand + 2, + _vm->_screen->plotImage(spr, _selectCommand + 2, Common::Point(RMOUSE[_selectCommand][0], 176)); _vm->_screen->restoreScreen(); @@ -569,7 +569,7 @@ void Room::executeCommand(int commandId) { void Room::walkCursor() { EventsManager &events = *_vm->_events; - + events._normalMouse = CURSOR_CROSSHAIRS; events.setCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; @@ -698,7 +698,7 @@ bool Room::codeWalls() { if ((player._rawYTemp >= screen._orgY1) && (player._rawYTemp <= screen._orgY2)) { jf._wallCode |= (calcLR(player._rawYTemp) - player._rawXTemp) < 0 ? 2 : 1; - jf._wallCode1 |= (calcLR(player._rawYTemp) - + jf._wallCode1 |= (calcLR(player._rawYTemp) - (player._rawXTemp + player._playerOffset.x)) < 0 ? 2 : 1; } } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 053e824956..ec41f37d8c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -109,29 +109,29 @@ typedef void(Scripts::*ScriptMethodPtr)(); void Scripts::executeCommand(int commandIndex) { static const ScriptMethodPtr COMMAND_LIST[] = { - &Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, + &Scripts::cmdObject, &Scripts::cmdEndObject, &Scripts::cmdJumpLook, &Scripts::cmdJumpHelp, &Scripts::cmdJumpGet, &Scripts::cmdJumpMove, - &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, + &Scripts::cmdJumpUse, &Scripts::cmdJumpTalk, &Scripts::cmdNull, &Scripts::cmdPrint, &Scripts::cmdRetPos, &Scripts::cmdAnim, - &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, - &Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, - &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, - &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, - &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, - &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout, + &Scripts::cmdSetFlag, &Scripts::cmdCheckFlag, &Scripts::cmdGoto, + &Scripts::cmdAddScore, &Scripts::cmdSetInventory, &Scripts::cmdCheckInventory, + &Scripts::cmdSetTex, &Scripts::cmdNewRoom, &Scripts::cmdConverse, + &Scripts::cmdCheckFrame, &Scripts::cmdCheckAnim, &Scripts::cmdSnd, + &Scripts::cmdRetNeg, &Scripts::cmdRetPos, &Scripts::cmdCheckLoc, + &Scripts::cmdSetAnim, &Scripts::cmdDispInv, &Scripts::cmdSetAbout, &Scripts::cmdSetTimer, &Scripts::cmdCheckTimer, &Scripts::cmdSetTravel, - &Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, - &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, - &Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded, - &Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, + &Scripts::cmdJumpGoto, &Scripts::cmdSetVideo, &Scripts::cmdPlayVideo, + &Scripts::cmdPlotImage, &Scripts::cmdSetDisplay, &Scripts::cmdSetBuffer, + &Scripts::cmdSetScroll, &Scripts::cmdSaveRect, &Scripts::cmdVideoEnded, + &Scripts::cmdSetBufVid, &Scripts::cmdPlayBufVid, &Scripts::cmdRemoveLast, &Scripts::cmdDoTravel, &Scripts::cmdCheckAbout, &Scripts::cmdSpecial, - &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, - &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, - &Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, - &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, + &Scripts::cmdSetCycle, &Scripts::cmdCycle, &Scripts::cmdCharSpeak, + &Scripts::cmdTexSpeak, &Scripts::cmdTexChoice, &Scripts::cmdWait, + &Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, + &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, - &Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, - &Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, + &Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, + &Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut, &Scripts::cmdEndVideo }; @@ -139,11 +139,11 @@ void Scripts::executeCommand(int commandIndex) { (this->*COMMAND_LIST[commandIndex])(); } -void Scripts::cmdObject() { +void Scripts::cmdObject() { _vm->_bubbleBox->load(_data); } -void Scripts::cmdEndObject() { +void Scripts::cmdEndObject() { printString(GENERAL_MESSAGES[_vm->_room->_selectCommand]); } @@ -154,35 +154,35 @@ void Scripts::cmdJumpLook() { _data->skip(2); } -void Scripts::cmdJumpHelp() { +void Scripts::cmdJumpHelp() { if (_vm->_room->_selectCommand == 8) cmdGoto(); else _data->skip(2); } -void Scripts::cmdJumpGet() { +void Scripts::cmdJumpGet() { if (_vm->_room->_selectCommand == 3) cmdGoto(); else _data->skip(2); } -void Scripts::cmdJumpMove() { +void Scripts::cmdJumpMove() { if (_vm->_room->_selectCommand == 2) cmdGoto(); else _data->skip(2); } -void Scripts::cmdJumpUse() { +void Scripts::cmdJumpUse() { if (_vm->_room->_selectCommand == 4) cmdGoto(); else _data->skip(2); } -void Scripts::cmdJumpTalk() { +void Scripts::cmdJumpTalk() { if (_vm->_room->_selectCommand == 6) cmdGoto(); else @@ -234,12 +234,12 @@ void Scripts::cmdRetPos() { _returnCode = 0; } -void Scripts::cmdAnim() { +void Scripts::cmdAnim() { int animId = _data->readByte(); _vm->_animation->animate(animId); } -void Scripts::cmdSetFlag() { +void Scripts::cmdSetFlag() { int flagNum = _data->readByte(); byte flagVal = _data->readByte(); assert(flagNum < 256); @@ -247,7 +247,7 @@ void Scripts::cmdSetFlag() { _vm->_flags[flagNum] = flagVal; } -void Scripts::cmdCheckFlag() { +void Scripts::cmdCheckFlag() { int flagNum = _data->readUint16LE(); int flagVal = _data->readUint16LE(); assert(flagNum < 256); @@ -258,7 +258,7 @@ void Scripts::cmdCheckFlag() { _data->skip(2); } -void Scripts::cmdGoto() { +void Scripts::cmdGoto() { _sequence = _data->readUint16LE(); searchForSequence(); } @@ -272,7 +272,7 @@ void Scripts::cmdAddScore() { _data->skip(1); } -void Scripts::cmdSetInventory() { +void Scripts::cmdSetInventory() { int itemId = _data->readByte(); int itemVal = _data->readByte(); @@ -282,7 +282,7 @@ void Scripts::cmdSetInventory() { _vm->_inventory->_invChangeFlag = true; } -void Scripts::cmdCheckInventory() { +void Scripts::cmdCheckInventory() { int itemId = _data->readUint16LE(); int itemVal = _data->readUint16LE(); @@ -323,7 +323,7 @@ void Scripts::cmdSetTex() { #define CURRENT_ROOM 0xFF -void Scripts::cmdNewRoom() { +void Scripts::cmdNewRoom() { int roomNumber = _data->readByte(); if (roomNumber != CURRENT_ROOM) _vm->_player->_roomNumber = roomNumber; @@ -334,7 +334,7 @@ void Scripts::cmdNewRoom() { cmdRetPos(); } -void Scripts::cmdConverse() { +void Scripts::cmdConverse() { _vm->_conversation = _data->readUint16LE(); _vm->_room->clearRoom(); _vm->freeChar(); @@ -397,7 +397,7 @@ void Scripts::cmdCheckLoc() { _data->skip(2); } -void Scripts::cmdSetAnim() { +void Scripts::cmdSetAnim() { int animId = _data->readByte(); Animation *anim = _vm->_animation->setAnimation(animId); @@ -471,7 +471,7 @@ void Scripts::cmdJumpGoto() { _data->skip(2); } -void Scripts::cmdSetVideo() { +void Scripts::cmdSetVideo() { Common::Point pt; pt.x = _data->readSint16LE(); pt.y = _data->readSint16LE(); @@ -481,7 +481,7 @@ void Scripts::cmdSetVideo() { _vm->_video->setVideo(_vm->_screen, pt, _vm->_extraCells[cellIndex]._vid, rate); } -void Scripts::cmdPlayVideo() { +void Scripts::cmdPlayVideo() { _vm->_video->playVideo(); } @@ -520,7 +520,7 @@ void Scripts::cmdSaveRect() { error("TODO: DEMO - cmdSaveRect"); } -void Scripts::cmdVideoEnded() { +void Scripts::cmdVideoEnded() { _vm->_events->pollEvents(); if (_vm->_video->_videoEnd) { @@ -565,7 +565,7 @@ void Scripts::cmdCheckAbout() { error("TODO: DEMO - cmdCheckAbout"); } -void Scripts::cmdSpecial() { +void Scripts::cmdSpecial() { _specialFunction = _data->readUint16LE(); int p1 = _data->readUint16LE(); int p2 = _data->readUint16LE(); @@ -585,7 +585,7 @@ void Scripts::cmdSpecial() { } } -void Scripts::cmdSetCycle() { +void Scripts::cmdSetCycle() { int startCycle = _data->readUint16LE(); int endCycle = _data->readUint16LE(); int timer = _data->readUint16LE(); @@ -628,7 +628,7 @@ void Scripts::cmdTexSpeak() { #define BTN_COUNT 6 void Scripts::cmdTexChoice() { static const int BTN_RANGES[BTN_COUNT][2] = { - { 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, + { 0, 76 }, { 77, 154 }, { 155, 232 }, { 233, 276 }, { 0, 0 }, { 277, 319 } }; @@ -714,12 +714,12 @@ void Scripts::cmdTexChoice() { } } } while ((choice == -1) || ((choice == 2) && choice3Fl)); - + _choice = choice + 1; _vm->_bubbleBox->clearBubbles(); } -void Scripts::cmdWait() { +void Scripts::cmdWait() { int time = _data->readSint16LE(); _vm->_timers[3]._timer = time; _vm->_timers[3]._initTm = time; @@ -750,7 +750,7 @@ void Scripts::cmdSetConPos() { _texsOrg = Common::Point(x, y); } -void Scripts::cmdCheckVFrame() { +void Scripts::cmdCheckVFrame() { if (_vm->_video->_videoFrame == _data->readSint16LE()) cmdGoto(); else @@ -759,7 +759,7 @@ void Scripts::cmdCheckVFrame() { void Scripts::cmdJumpChoice() { int val = (_data->readUint16LE() & 0xFF); - + if (val == _choice) { _sequence = _data->readUint16LE(); searchForSequence(); @@ -783,7 +783,7 @@ void Scripts::cmdLoadSound() { _vm->_sound->_soundTable.push_back(SoundEntry(sound, 1)); } -void Scripts::cmdFreeSound() { +void Scripts::cmdFreeSound() { SoundManager &sound = *_vm->_sound; if (sound._soundTable.size() > 0 && sound._soundTable[0]._res) { @@ -812,7 +812,7 @@ void Scripts::cmdSetVideoSound() { _vm->_video->_soundFlag = false; } -void Scripts::cmdPlayVideoSound() { +void Scripts::cmdPlayVideoSound() { _vm->_video->playVideo(); if (_vm->_video->_soundFrame == _vm->_video->_videoFrame && !_vm->_video->_soundFlag) { @@ -829,7 +829,7 @@ void Scripts::cmdPrintWatch() { CMDPUSHLOCATION(); return; } - error("TODO: DEMO - cmdPrintWatch"); + error("TODO: DEMO - cmdPrintWatch"); } void Scripts::cmdDispAbout() { @@ -837,11 +837,11 @@ void Scripts::cmdDispAbout() { CMDPUSHLOCATION(); return; } - error("TODO: DEMO - cmdDispAbout"); + error("TODO: DEMO - cmdDispAbout"); } void Scripts::CMDPUSHLOCATION() { - error("TODO CMDPUSHLOCATION"); + error("TODO CMDPUSHLOCATION"); } void Scripts::cmdCheckTravel() { @@ -849,7 +849,7 @@ void Scripts::cmdCheckTravel() { CMDPUSHLOCATION(); return; } - error("TODO: DEMO - cmdCheckTravel"); + error("TODO: DEMO - cmdCheckTravel"); } void Scripts::cmdBlock() { @@ -857,7 +857,7 @@ void Scripts::cmdBlock() { CMDPUSHLOCATION(); return; } - error("TODO: DEMO - cmdBlock"); + error("TODO: DEMO - cmdBlock"); } void Scripts::cmdPlayerOff() { @@ -868,7 +868,7 @@ void Scripts::cmdPlayerOn() { _vm->_player->_playerOff = false; } -void Scripts::cmdDead() { +void Scripts::cmdDead() { int deathId = _data->readByte(); _vm->dead(deathId); } diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 7dab0a75f7..95576d212b 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -30,7 +30,7 @@ namespace Access { -SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : +SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _playingSound = false; _isVoice = false; @@ -71,7 +71,7 @@ void SoundManager::playSound(Resource *res, int priority) { byte *resourceData = res->data(); Audio::SoundHandle audioHandle; Audio::RewindableAudioStream *audioStream = 0; - + assert(res->_size >= 32); if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) { @@ -92,7 +92,7 @@ void SoundManager::playSound(Resource *res, int priority) { // word - actual sample size (should be resource-size - 32) byte internalSampleRate = resourceData[5]; int sampleSize = READ_LE_UINT16(resourceData + 7); - + assert( (sampleSize + 32) == res->_size); int sampleRate = 0; @@ -105,12 +105,12 @@ void SoundManager::playSound(Resource *res, int priority) { error("Unexpected internal Sample Rate %d", internalSampleRate); return; } - + audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); } else error("Unknown format"); - + audioHandle = Audio::SoundHandle(); _mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle, audioStream, -1, _mixer->kMaxChannelVolume, 0, @@ -119,7 +119,7 @@ void SoundManager::playSound(Resource *res, int priority) { /* Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, + _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false); */ } diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 776c58a83b..abe833ce42 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -54,7 +54,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const _header._height = _videoData->_stream->readUint16LE(); _videoData->_stream->skip(1); _header._flags = (VideoFlags)_videoData->_stream->readByte(); - + _startCoord = (byte *)vidSurface->getBasePtr(pt.x, pt.y); _frameCount = _header._frameCount - 2; _xCount = _header._width; @@ -72,7 +72,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const if (vidSurface == _vm->_screen) _vm->_newRects.push_back(Common::Rect(pt.x, pt.y, pt.x + _xCount, pt.y + _scanCount)); - + getFrame(); } @@ -115,7 +115,7 @@ void VideoPlayer::playVideo() { pDest += count; } else { // Read count number of pixels - + // Load across lines if necessary while (count >= (pLine + _xCount - pDest)) { int lineCount = (pLine + _xCount - pDest); @@ -143,12 +143,12 @@ void VideoPlayer::playVideo() { void VideoPlayer::copyVideo() { _vm->_player->calcPlayer(); Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x, - _vm->_vidY - _vm->_screen->_bufferStart.y, + _vm->_vidY - _vm->_screen->_bufferStart.y, _vm->_vidX - _vm->_screen->_bufferStart.x + _header._width, _vm->_vidY - _vm->_screen->_bufferStart.y + _header._height); if (!_vm->_screen->clip(r)) return; - + _vm->_newRects.push_back(r); int vh = _header._height; int vw = _header._width; -- cgit v1.2.3 From 1f42800e0cd2b4ab08bba78edbe69f657dc89367 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 4 Dec 2014 22:40:09 -0500 Subject: ACCESS: Further cleanup of river obstacles checks --- engines/access/amazon/amazon_game.cpp | 3 +++ engines/access/amazon/amazon_logic.cpp | 21 +++++++++++---------- engines/access/amazon/amazon_resources.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index deb45ff4b1..79fca87b3f 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -627,6 +627,9 @@ void AmazonEngine::dead(int deathId) { _screen->forceFadeIn(); _sound->playSound(0); _screen->forceFadeOut(); + + if (shouldQuit()) + return; } freeCells(); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 428b85f969..a7ee432183 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1635,8 +1635,9 @@ void River::moveCanoe2() { void River::updateObstacles() { RiverStruct *cur; for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) { - int val = cur->_field1 + cur->_riverX - 1; + int val = cur->_riverX + cur->_width - 1; if (val < _screenVertX) + // Obstacle is not yet on-scren break; if (cur->_riverX < (_screenVertX + 319)) { @@ -1645,7 +1646,7 @@ void River::updateObstacles() { while (cur < RIVER_OBJECTS[_riverIndex][RIVER_END]) { ++cur; - val = cur->_field1 + cur->_riverX - 1; + val = cur->_riverX + cur->_width - 1; if (val < _screenVertX || (cur->_riverX >= (_screenVertX + 319))) break; @@ -1676,19 +1677,19 @@ bool River::checkRiverCollide() { _canoeVXPos = _screenVertX + 170; - for (RiverStruct *si = _topList; si <= _botList; ++si) { - if (si->_lane < _canoeLane) + for (RiverStruct *cur = _topList; cur <= _botList; ++cur) { + if (cur->_lane < _canoeLane) continue; - if ((si->_lane == _canoeLane) || (si->_lane == _canoeLane + 1)) { - if (si->_field1 + si->_riverX - 1 >= _canoeVXPos) { - if (_canoeVXPos + 124 >= si->_riverX) { - _vm->_sound->playSound(4); - return true; - } + if ((cur->_lane == _canoeLane) || (cur->_lane == _canoeLane + 1)) { + if ((cur->_riverX + cur->_width - 1) >= _canoeVXPos && + cur->_riverX < (_canoeVXPos + 124)) { + _vm->_sound->playSound(4); + return true; } } } + return false; } diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index b6b0dbbdce..777c579073 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -31,7 +31,7 @@ namespace Amazon { struct RiverStruct { int _id; - int _field1; + int _width; int _riverX; int _xp; int _lane; -- cgit v1.2.3 From c41d7bab2b3bdfd04a1872d2261866660c8b0bf3 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Dec 2014 08:28:35 +0100 Subject: ACCESS: Add some data for the character info used by the demo --- engines/access/amazon/amazon_resources.cpp | 32 ++++++++++++++++++++++++++++++ engines/access/amazon/amazon_resources.h | 1 + engines/access/char.cpp | 9 +++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index bd4e4f838d..509c8bcac4 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1383,6 +1383,31 @@ const byte LETTER[] = { 0x0, 0x0, 0x0, 0x30, 0x0, 0x5, 0x0, 0xFF, 0xFF }; +const byte OVERBOARD_DEMO[] = { + 0x02, 0xFF, 0xFF, 0x22, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x00, 0x02, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x22, 0x00, 0x00, 0x00, 0x22, + 0x00, 0x03, 0x00, 0x22, 0x00, 0x06, 0x00, 0x22, 0x00, 0x04, + 0x00, 0x22, 0x00, 0x07, 0x00, 0x22, 0x00, 0x05, 0x00, 0x62, + 0x00, 0x1D, 0x00, 0x60, 0x00, 0x00, 0x00, 0x22, 0x00, 0x06, + 0x00, 0x60, 0x00, 0x01, 0x00, 0x22, 0x00, 0x07, 0x00, 0xFF, + 0xFF +}; + +const byte SHORE1[] = { + 0x02, 0xFF, 0xFF, 0x55, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x03, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x55, 0x00, 0x02, 0x00, 0x62, 0x00, + 0x2E, 0x00, 0x55, 0x00, 0x02, 0x00, 0x62, 0x00, 0x2F, 0x00, + 0xFF, 0xFF +}; + +const byte CHAP8[] = { + 0x02, 0xFF, 0xFF, 0x60, 0x00, 0x03, 0x00, 0xFF, 0xFF, 0xFF, + 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0x60, 0x00, 0x02, 0x00, 0xFF, 0xFF +}; + const byte *CHARTBL[] = { ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT, BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, @@ -1392,6 +1417,13 @@ const byte *CHARTBL[] = { CRACK, LETTER }; +const byte *CHARTBL_DEMO[] = { + ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD_DEMO, PILOT2, TIKAGENT, + BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, + ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS, + JWATER, SHOOT, ADIE, DYNAMITE, SHORE1, CHAP8 +}; + const char *const INVENTORY_NAMES[] = { "RAT", "ALCOHOL", "SAFE COMBINATION", "BEAKER", "MICROFILM", "VAULT KEY", "BOLT CUTTERS", "BLOWGUN", "LOVE POTION", "MONEY", diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 777c579073..6e35ca0361 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -64,6 +64,7 @@ extern const byte *ROOM_TABLE_DEMO[]; extern const int ROOM_NUMB; extern const byte *CHARTBL[]; +extern const byte *CHARTBL_DEMO[]; extern const char *const INVENTORY_NAMES[]; diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 8ce43a5730..d5eec3eb7f 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -71,8 +71,13 @@ CharManager::CharManager(AccessEngine *vm) : Manager(vm) { switch (vm->getGameID()) { case GType_Amazon: // Setup character list - for (int i = 0; i < 37; ++i) - _charTable.push_back(CharEntry(Amazon::CHARTBL[i])); + if (_vm->isDemo()) { + for (int i = 0; i < 27; ++i) + _charTable.push_back(CharEntry(Amazon::CHARTBL_DEMO[i])); + } else { + for (int i = 0; i < 37; ++i) + _charTable.push_back(CharEntry(Amazon::CHARTBL[i])); + } break; default: error("Unknown game"); -- cgit v1.2.3 From 59099a72057ff2e242679955a80e29d425219c8a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Dec 2014 10:27:44 +0100 Subject: ACCESS: Fix cmdDead for the demo --- engines/access/amazon/amazon_game.cpp | 111 +++++++++++++++++++---------- engines/access/amazon/amazon_resources.cpp | 44 ++++++++++++ engines/access/amazon/amazon_resources.h | 2 + 3 files changed, 120 insertions(+), 37 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 79fca87b3f..3252754239 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -124,9 +124,16 @@ void AmazonEngine::setupGame() { // Load death list _deaths.resize(58); - for (int i = 0; i < 58; ++i) { - _deaths[i]._screenId = DEATH_SCREENS[i]; - _deaths[i]._msg = DEATH_TEXT[i]; + if (isDemo()) { + for (int i = 0; i < 34; ++i) { + _deaths[i]._screenId = DEATH_SCREENS_DEMO[i]; + _deaths[i]._msg = DEATH_TEXT_DEMO[i]; + } + } else { + for (int i = 0; i < 58; ++i) { + _deaths[i]._screenId = DEATH_SCREENS[i]; + _deaths[i]._msg = DEATH_TEXT[i]; + } } _deaths._cells.resize(12); for (int i = 0; i < 12; ++i) @@ -616,7 +623,8 @@ void AmazonEngine::dead(int deathId) { _screen->setPanel(3); if (deathId != 10) { - _midi->newMusic(62, 0); + if (!isDemo()) + _midi->newMusic(62, 0); _files->_setPaletteFlag = false; _files->loadScreen(94, 0); _files->_setPaletteFlag = true; @@ -631,43 +639,72 @@ void AmazonEngine::dead(int deathId) { if (shouldQuit()) return; } - freeCells(); - // Load the cell list for the death screen - DeathEntry &de = _deaths[deathId]; - Common::Array cells; - cells.push_back(_deaths._cells[de._screenId]); - loadCells(cells); + if (!isDemo()) { + freeCells(); - _screen->setDisplayScan(); - _files->_setPaletteFlag = false; - _files->loadScreen(&_buffer2, 94, 1); - _screen->setIconPalette(); - - _buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25)); - _buffer2.copyTo(_screen); - _screen->forceFadeIn(); - - _fonts._charSet._hi = 10; - _fonts._charSet._lo = 1; - _fonts._charFor._lo = 55; - _fonts._charFor._hi = 255; - _screen->_maxChars = 46; - _screen->_printOrg = Common::Point(20, 155); - _screen->_printStart = Common::Point(20, 155); - - Common::String &msg = de._msg; - _printEnd = 180; - printText(_screen, msg); - _screen->forceFadeOut(); + // Load the cell list for the death screen + DeathEntry &de = _deaths[deathId]; + Common::Array cells; + cells.push_back(_deaths._cells[de._screenId]); + loadCells(cells); - _midi->newMusic(0, 1); - _events->showCursor(); - _room->clearRoom(); - freeChar(); + _screen->setDisplayScan(); + _files->_setPaletteFlag = false; + _files->loadScreen(&_buffer2, 94, 1); + _screen->setIconPalette(); + + _buffer2.plotImage(_objectsTable[0], 0, Common::Point(105, 25)); + _buffer2.copyTo(_screen); + _screen->forceFadeIn(); + + _fonts._charSet._hi = 10; + _fonts._charSet._lo = 1; + _fonts._charFor._lo = 55; + _fonts._charFor._hi = 255; + _screen->_maxChars = 46; + _screen->_printOrg = Common::Point(20, 155); + _screen->_printStart = Common::Point(20, 155); - _currentManOld = 1; - _player->removeSprite1(); + Common::String &msg = de._msg; + _printEnd = 180; + + printText(_screen, msg); + _screen->forceFadeOut(); + + _midi->newMusic(0, 1); + _events->showCursor(); + _room->clearRoom(); + freeChar(); + + _currentManOld = 1; + _player->removeSprite1(); + + } else { + _files->loadScreen(_screen, 94, _deaths[deathId]._screenId); + _screen->forceFadeIn(); + + _fonts._charSet._hi = 10; + _fonts._charSet._lo = 1; + _fonts._charFor._lo = 55; + _fonts._charFor._hi = 255; + _screen->_maxChars = 49; + _screen->_printOrg = Common::Point(15, 165); + _screen->_printStart = Common::Point(15, 165); + + Common::String msg = Common::String(_deaths[deathId]._msg); + _printEnd = 200; + + printText(_screen, msg); + _screen->fadeOut(); + + _events->showCursor(); + _room->clearRoom(); + freeChar(); + + _currentManOld = 1; + _player->removeSprite1(); + } warning("TODO: restart game"); quitGame(); diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 509c8bcac4..ed4a012bd1 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1660,6 +1660,13 @@ const byte DEATH_SCREENS[58] = { 8, 0, 5, 8, 0, 12, 12, 11 }; +const byte DEATH_SCREENS_DEMO[34] = { + 1, 2, 1, 1, 1, 1, 1, 1, 4, 1, + 3, 4, 2, 4, 2, 1, 1, 1, 1, 1, + 1, 4, 2, 4, 2, 4, 2, 4, 4, 4, + 1, 1, 1, 1 +}; + const char *const DEATH_TEXT[58] = { "SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.", "WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.", @@ -1755,6 +1762,43 @@ const char *const DEATH_TEXT[58] = { "TWENTY YEARS LATER YOU ARE RELEASED FROM A SOUTH AMERICAN PRISON." }; +const char *const DEATH_TEXT_DEMO[34] = { + "SAM SALVADOR SPOTS YOU AND LETS YOU HAVE IT.", + "WHILE TAKING A MOONLIGHT SWIM YOU DISCOVER THAT PIRANHA REALLY CAN STRIP FLESH TO THE BONE.", + "THE GUARD FILLS YOU FULL OF HOLES BEFORE TOSSING YOU TO THE PIRANHA.", + "YOU'RE ONLY ABLE TO SWIM HALFWAY ACROSS THE RIVER BEFORE RUNNING OUT OF AIR. YOU MAKE SO MUCH NOISE GASPING FOR BREATH THAT SAM EASILY FINDS YOU AND LEAVES YOU IN THE RIVER PERMANENTLY.", + "SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO. HE TRACKS YOU DOWN AND LETS YOU HAVE IT.", + "THE GUARD COMES AROUND THE CORNER. HE DECIDES THAT THREE LEAD SLUGS WILL TEACH YOU TO BE MORE POLITE.", + "THE CAPTAIN IS WAITING OUTSIDE THE DOOR.", + "THE CAPTAIN',27h,'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.", + "THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP. UNFORTUNATELY, YOU'RE STILL ABOARD.", + "THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.", + "", + "YOU RUN OUT ON DECK, THEN REALIZE THAT MAYA IS STILL TIED UP. AS YOU TURN TO GO BACK THE BOAT BLOWS UP.", + "AFTER YOU FAIL TO PROVE YOUR DIVINITY THE NATIVES EAT YOU FOR LUNCH.", + "THIS IS THE GENERIC DEATH SCENE", + "YOU ONLY MAKE IT HALFWAY ACROSS THE RIVER BEFORE THE PIRANHA STRIKE.", + "WITH NOTHING TO PROTECT HIM FROM THE HAIL OF BULLETS ALLEN IS QUICKLY GUNNED DOWN. JASON AND MAYA SOON FOLLOW...", + "THE COMBINATION OF THE WIND AND GUNFIRE KNOCK THE CORRUGATED IRON OVER, LEAVING YOU WITHOUT PROTECTION.", + "WITHOUT SUFFICIENT AMMUNITION, ALLEN IS UNABLE TO HOLD OFF THE ATTACKERS FOR LONG. THIS RESULTS IN A SERIOUS CASE OF LEAD POISONING.", + "ALLEN IS A MARVELOUS SHOT, BUT HIS AMMUNITION IS NOT UNLIMITED. SOON IT IS ALL OVER.", + "THE PILOT FEELS YOU ARE TOO CLOSE AND PULLS THE TRIGGER.", + "THE PILOT SHOOTS YOU IN THE HEAD, THEN TOSSES YOUR LIFELESS", + "THE PLANE CRASHES INTO THE JUNGLE CANOPY AT 200 MPH.", + "THE CANOE HITS THE ROCKS AND CAPSIZES, AND THE PIRANHA MAKE YOU THEIR LUNCH GUESTS.", + "YOU ACCIDENTALLY DISCOVER THE FOURTH TALLEST WATERFALL IN SOUTH AMERICA.", + "YOU DISCOVER A VERY HUNGRY TRIBE OF CANNIBALS.", + "YOU BECOME LOST IN THE WINDING WATERWAYS AND WANDER UNTIL YOU STARVE TO DEATH.", + "YOU BECOME TRAPPED IN THE RAPIDS AND ARE CRUSHED BETWEEN THE ROCKS.", + "YOU WAIT AROUND FOR SOME TIME, BUT HANS STROHEIM NEVER SPEAKS TO YOU AGAIN. FINALLY YOU RETURN HOME KNOWING YOU HAVE FAILED.", + "DECIDING THAT YOU THREATEN HIM AND HIS WORK, HANS STROHEIM HAS THE NATIVES IN THE VILLAGE KILL YOU.", + "YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN INTO A THOUSAND PIECES.", + "STANDING OUT IN THE OPEN YOU ARE EXPOSED TO THE HAIL OF BULLETS FROM SANCHEZ' MEN.", + "THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.", + "SAM MAY BE UGLY, BUT HE',27h,'S NOT DEAF. HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.", + "WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY" +}; + const int DEATH_CELLS[12][3] = { { 0, 94, 3 }, { 0, 94, 4 }, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 6e35ca0361..92e0cecf68 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -84,8 +84,10 @@ extern const char *const BAR_MESSAGE; extern const char *const HELPLVLTXT[3]; extern const char *const IQLABELS[9]; extern const byte DEATH_SCREENS[58]; +extern const byte DEATH_SCREENS_DEMO[34]; extern const char *const DEATH_TEXT[58]; +extern const char *const DEATH_TEXT_DEMO[34]; extern const int DEATH_CELLS[12][3]; -- cgit v1.2.3 From 84d77b7daf8473cd25196ae9445015ed3656797a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 5 Dec 2014 17:58:41 +0100 Subject: ACCESS: Fix the inventory behavior in the floppy and demo version --- engines/access/inventory.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index d9e1b496a4..78a85c3257 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -168,7 +168,9 @@ int InventoryManager::newDisplayInv() { restoreFields(); screen.restorePalette(); - if (!screen._vesaMode && !_invRefreshFlag) { + // The original was testing the vesa mode too. + // We removed this check as we don't use pre-rendering + if (!_invRefreshFlag) { screen.clearBuffer(); screen.setPalette(); } @@ -179,10 +181,10 @@ int InventoryManager::newDisplayInv() { screen.setBufferScan(); room.buildScreen(); - if (!screen._vesaMode) { - screen.fadeOut(); - _vm->copyBF2Vid(); - } + // The original was doing a check on the vesa mode at this point. + // We don't need it as we don't do inventory pre-rendering + screen.fadeOut(); + _vm->copyBF2Vid(); } events._cursorExitFlag = false; @@ -275,7 +277,9 @@ void InventoryManager::initFields() { _vm->_buffer1.clearBuffer(); _vm->_buffer2.clearBuffer(); - if (!_invRefreshFlag && !screen._vesaMode) + // The original was doing at this point a check on vesa mode + // We don't need it as we don't do inventory pre-rendering + if (!_invRefreshFlag) screen.clearBuffer(); screen.savePalette(); -- cgit v1.2.3 From 67b3304f710a6888943e8b029237b246377d4026 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Dec 2014 15:01:52 -0500 Subject: ACCESS: Clean up keyboard control --- engines/access/access.cpp | 4 ++-- engines/access/amazon/amazon_game.cpp | 6 ++---- engines/access/amazon/amazon_logic.cpp | 5 +---- engines/access/events.cpp | 28 ++++++++++++++++++---------- engines/access/events.h | 6 +++++- engines/access/scripts.cpp | 7 +++---- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 2153f594b1..55fe2514ed 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -229,7 +229,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->debounceLeft(); _sndSubFile += soundsLeft; break; - } else if (_events->_keypresses.size() != 0) { + } else if (_events->isKeyPending()) { _sndSubFile += soundsLeft; break; } else { @@ -272,7 +272,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->debounceLeft(); _sndSubFile += soundsLeft; break; - } else if (_events->_keypresses.size() != 0) { + } else if (_events->isKeyPending()) { _sndSubFile += soundsLeft; break; } else { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 3252754239..902cfcd38a 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -489,8 +489,7 @@ void AmazonEngine::startChapter(int chapter) { _sound->freeSounds(); // Wait loop - while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton - && _events->_keypresses.size() == 0 && _timers[20]._flag) { + while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { _events->pollEvents(); g_system->delayMillis(10); } @@ -531,8 +530,7 @@ void AmazonEngine::startChapter(int chapter) { _timers[20]._flag++; // Wait loop - while (!shouldQuit() && !_events->_leftButton && !_events->_rightButton - && _events->_keypresses.size() == 0 && _timers[20]._flag) { + while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { _events->pollEvents(); g_system->delayMillis(10); } diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index a7ee432183..5def4815e2 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -158,12 +158,9 @@ void CampScene::mWhileDoOpen() { events.pollEventsAndWait(); - if (events._leftButton || events._rightButton || events._keypresses.size() > 0) { + if (_vm->_events->isKeyMousePressed()) { _skipStart = true; _vm->_midi->newMusic(10, 1); - - events.debounceLeft(); - events.zeroKeys(); break; } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 87e5d10cc3..60073e6030 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -45,6 +45,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _mouseCol = _mouseRow = 0; _cursorExitFlag = false; _vbCount = 0; + _keyCode = Common::KEYCODE_INVALID; } EventsManager::~EventsManager() { @@ -141,7 +142,7 @@ void EventsManager::pollEvents(bool skipTimers) { _vm->_debugger->attach(); _vm->_debugger->onFrame(); } else { - _keypresses.push(event.kbd); + keyControl(event.kbd.keycode); } return; case Common::EVENT_KEYUP: @@ -181,6 +182,11 @@ void EventsManager::pollEvents(bool skipTimers) { } } +void EventsManager::keyControl(Common::KeyCode keycode) { + _keyCode = keycode; + // TODO: Keypress handling +} + void EventsManager::pollEventsAndWait() { pollEvents(); g_system->delayMillis(10); @@ -219,18 +225,23 @@ void EventsManager::delay(int time) { } void EventsManager::zeroKeys() { - _keypresses.clear(); + _keyCode = Common::KEYCODE_INVALID; } bool EventsManager::getKey(Common::KeyState &key) { - if (_keypresses.empty()) { + if (_keyCode == Common::KEYCODE_INVALID) { return false; } else { - key = _keypresses.pop(); + key = _keyCode; + _keyCode = Common::KEYCODE_INVALID; return true; } } +bool EventsManager::isKeyPending() const { + return _keyCode != Common::KEYCODE_INVALID; +} + void EventsManager::debounceLeft() { while (_leftButton && !_vm->shouldQuit()) { pollEvents(); @@ -240,17 +251,14 @@ void EventsManager::debounceLeft() { void EventsManager::clearEvents() { _leftButton = _rightButton = false; - _keypresses.clear(); + zeroKeys(); } void EventsManager::waitKeyMouse() { - while (!_vm->shouldQuit() && !_leftButton && _keypresses.size() == 0) { + while (!_vm->shouldQuit() && isKeyMousePressed()) { pollEvents(true); g_system->delayMillis(10); } - - zeroKeys(); - debounceLeft(); } Common::Point EventsManager::calcRawMouse() { @@ -278,7 +286,7 @@ int EventsManager::checkMouseBox1(Common::Array &rects) { } bool EventsManager::isKeyMousePressed() { - bool result = _leftButton || _rightButton || _keypresses.size() > 0; + bool result = _leftButton || _rightButton || isKeyPending(); debounceLeft(); zeroKeys(); diff --git a/engines/access/events.h b/engines/access/events.h index 965e8e7fd6..ffb0dbab3f 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -46,8 +46,11 @@ private: AccessEngine *_vm; uint32 _frameCounter; uint32 _priorFrameTime; + Common::KeyCode _keyCode; + Graphics::Surface _invCursor; void nextFrame(bool skipTimers); + void keyControl(Common::KeyCode keycode); public: CursorType _cursorId; CursorType _normalMouse; @@ -58,7 +61,6 @@ public: int _mouseCol, _mouseRow; bool _cursorExitFlag; int _vbCount; - Common::FixedStack _keypresses; public: /** * Constructor @@ -113,6 +115,8 @@ public: bool getKey(Common::KeyState &key); + bool isKeyPending() const; + void delay(int time); void debounceLeft(); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index ec41f37d8c..728421c6d9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -443,7 +443,7 @@ void Scripts::cmdCheckTimer() { if (_endFlag) return; - if ((idx == 9) && (_vm->_events->_keypresses.size() > 0)) { + if ((idx == 9) && _vm->_events->isKeyPending()) { _vm->_events->zeroKeys(); _vm->_timers[9]._timer = 0; _vm->_timers[9]._flag = 0; @@ -724,10 +724,9 @@ void Scripts::cmdWait() { _vm->_timers[3]._timer = time; _vm->_timers[3]._initTm = time; _vm->_timers[3]._flag++; - _vm->_events->_keypresses.clear(); + _vm->_events->zeroKeys(); - while (!_vm->shouldQuit() && _vm->_events->_keypresses.empty() && - !_vm->_events->_leftButton && !_vm->_events->_rightButton && + while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && _vm->_timers[3]._flag) { _vm->_midi->midiRepeat(); charLoop(); -- cgit v1.2.3 From 7cd7bb9b54266f952c4049875532e587b0278415 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Dec 2014 15:21:35 -0500 Subject: ACCESS: Implement player keyboard movement --- engines/access/events.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++--- engines/access/events.h | 2 +- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 60073e6030..a1be7ffa5b 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -27,6 +27,7 @@ #include "engines/util.h" #include "access/access.h" #include "access/events.h" +#include "access/player.h" #include "access/amazon/amazon_resources.h" #define CURSOR_WIDTH 16 @@ -142,10 +143,11 @@ void EventsManager::pollEvents(bool skipTimers) { _vm->_debugger->attach(); _vm->_debugger->onFrame(); } else { - keyControl(event.kbd.keycode); + keyControl(event.kbd.keycode, true); } return; case Common::EVENT_KEYUP: + keyControl(event.kbd.keycode, false); return; case Common::EVENT_MOUSEMOVE: _mousePos = event.mouse; @@ -182,9 +184,51 @@ void EventsManager::pollEvents(bool skipTimers) { } } -void EventsManager::keyControl(Common::KeyCode keycode) { +void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) { + Player &player = *_vm->_player; + + if (!isKeyDown) { + if (player._move != NONE) { + _keyCode = Common::KEYCODE_INVALID; + player._move = NONE; + } + return; + } + _keyCode = keycode; - // TODO: Keypress handling + + switch (keycode) { + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + player._move = UP; + break; + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + player._move = DOWN; + break; + case Common::KEYCODE_LEFT: + case Common::KEYCODE_KP4: + player._move = LEFT; + break; + case Common::KEYCODE_RIGHT: + case Common::KEYCODE_KP6: + player._move = RIGHT; + break; + case Common::KEYCODE_KP7: + player._move = UPLEFT; + break; + case Common::KEYCODE_KP9: + player._move = UPRIGHT; + break; + case Common::KEYCODE_KP1: + player._move = DOWNLEFT; + break; + case Common::KEYCODE_KP3: + player._move = DOWNRIGHT; + break; + default: + break; + } } void EventsManager::pollEventsAndWait() { diff --git a/engines/access/events.h b/engines/access/events.h index ffb0dbab3f..04edd2bdf3 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -50,7 +50,7 @@ private: Graphics::Surface _invCursor; void nextFrame(bool skipTimers); - void keyControl(Common::KeyCode keycode); + void keyControl(Common::KeyCode keycode, bool isKeyDown); public: CursorType _cursorId; CursorType _normalMouse; -- cgit v1.2.3 From 40b84172969781899347aff208f87da9d243d0ba Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Dec 2014 16:07:14 -0500 Subject: ACCESS: Correct down-right player movement --- engines/access/player.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 5668e9c6b9..35c5dadf02 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -516,14 +516,14 @@ void Player::walkDownRight() { _playerDirection = DOWNRIGHT; int walkOffset, tempL; - bool flag = _scrollEnd == 1; + bool flag = _scrollEnd == 2; if (!flag) { calcPlayer(); - flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] - + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - _vm->_player->_scrollThreshold) > 0; } if (flag) { - walkOffset = _walkOffUR[_frame - _sideWalkMin].x; + walkOffset = _walkOffUR[_frame - _diagDownWalkMin].x; tempL = _rawPlayerLow.x + _vm->_screen->_scaleTable2[walkOffset]; _rawTempL = (byte)tempL; _rawXTemp = _rawPlayer.x + _vm->_screen->_scaleTable1[walkOffset] + @@ -533,7 +533,7 @@ void Player::walkDownRight() { } walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y; - tempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset]; + tempL = _rawPlayerLow.y + _vm->_screen->_scaleTable2[walkOffset]; _rawYTempL = (byte)tempL; _rawYTemp = _rawPlayer.y + _vm->_screen->_scaleTable1[walkOffset] + (tempL >= 0x100 ? 1 : 0); @@ -546,17 +546,17 @@ void Player::walkDownRight() { _rawPlayerLow.x = _rawTempL; _rawPlayerLow.y = _rawYTempL; - ++_frame; calcManScale(); // This code looks totally useless as 'si' is unconditionally set in plotCom1 //if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) // warning("TODO: walkDownRight - si = 0?"); + ++_frame; if (_frame > _diagDownWalkMax) _frame = _diagDownWalkMin; - plotCom1(); + plotCom(0); } } -- cgit v1.2.3 From a1e5e8be9481add1402ea337039b755937ef6441 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Dec 2014 16:43:30 -0500 Subject: ACCESS: Cleaned up event handling for scene establish text display --- engines/access/access.cpp | 10 +++------- engines/access/amazon/amazon_game.cpp | 1 + engines/access/events.cpp | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 55fe2514ed..a09e47c733 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -196,7 +196,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { int curPage = 0; int soundsLeft = 0; - for (;;) { + while (!shouldQuit()) { soundsLeft = _countTbl[curPage]; _events->zeroKeys(); @@ -216,7 +216,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { if (!_sound->_isVoice) { _events->waitKeyMouse(); } else { - for (;;) { + while (!shouldQuit()) { _sound->freeSounds(); Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundTable.push_back(SoundEntry(sound, 1)); @@ -225,11 +225,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->pollEvents(); - if (_events->_leftButton) { - _events->debounceLeft(); - _sndSubFile += soundsLeft; - break; - } else if (_events->isKeyPending()) { + if (_events->isKeyMousePressed()) { _sndSubFile += soundsLeft; break; } else { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 902cfcd38a..979fffe2d3 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -201,6 +201,7 @@ void AmazonEngine::loadEstablish(int estabIndex) { void AmazonEngine::doEstablish(int screenId, int estabIndex) { _establishMode = 1; + _events->clearEvents(); _screen->forceFadeOut(); _screen->clearScreen(); _screen->setPanel(3); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index a1be7ffa5b..5ed5ee2052 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -299,7 +299,7 @@ void EventsManager::clearEvents() { } void EventsManager::waitKeyMouse() { - while (!_vm->shouldQuit() && isKeyMousePressed()) { + while (!_vm->shouldQuit() && !isKeyMousePressed()) { pollEvents(true); g_system->delayMillis(10); } -- cgit v1.2.3 From bf361715e0c83ebb18914e8769a867a2c5c370c2 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 6 Dec 2014 16:54:25 -0500 Subject: ACCESS: Simply river savegame fields --- engines/access/amazon/amazon_logic.cpp | 15 +-------------- engines/access/amazon/amazon_logic.h | 3 --- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 5def4815e2..c9e8886d08 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1351,9 +1351,6 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _rScrollCol = 0; _rScrollX = 0; _rScrollY = 0; - _rOldRectCount = 0; - _rNewRectCount = 0; - _rKeyFlag = 0; _mapOffset = 0; _screenVertX = 0; _saveRiver = false; @@ -1422,12 +1419,7 @@ void River::initRiver() { _vm->copyBF2Vid(); _vm->_screen->forceFadeIn(); - if (_saveRiver) { - // Restore draw rects from savegame - _vm->_oldRects.resize(_rOldRectCount); - _vm->_newRects.resize(_rNewRectCount); - // KEYFLG = _vm->_rKeyFlag - } else { + if (!_saveRiver) { // Reset draw rects _vm->_oldRects.clear(); _vm->_newRects.clear(); @@ -1904,13 +1896,8 @@ void River::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_rScrollCol); s.syncAsSint16LE(_rScrollX); s.syncAsSint16LE(_rScrollY); - s.syncAsUint16LE(_rOldRectCount); - s.syncAsUint16LE(_rNewRectCount); - s.syncAsUint16LE(_rKeyFlag); s.syncAsUint16LE(_mapOffset); s.syncAsUint16LE(_screenVertX); - warning("TODO: s.syncAsSint16LE(_topList);"); - warning("TODO: s.syncAsSint16LE(_botList);"); _saveRiver = s.isLoading(); } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 14f51990cc..1cc65cbf6d 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -181,9 +181,6 @@ private: int _rScrollCol; int _rScrollX; int _rScrollY; - int _rOldRectCount; - int _rNewRectCount; - int _rKeyFlag; int _mapOffset; int _screenVertX; -- cgit v1.2.3 From b864b846356b6b20d6e6def414456b5d44fe88c7 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 7 Dec 2014 19:03:06 +0100 Subject: ACCESS: Fix the end of the demo --- engines/access/amazon/amazon_game.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 979fffe2d3..b425fe9e22 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -621,7 +621,11 @@ void AmazonEngine::dead(int deathId) { _screen->clearScreen(); _screen->setPanel(3); - if (deathId != 10) { + if ((deathId == 10) && !isDemo()) { + quitGame(); + _events->pollEvents(); + return; + } else { if (!isDemo()) _midi->newMusic(62, 0); _files->_setPaletteFlag = false; @@ -629,14 +633,16 @@ void AmazonEngine::dead(int deathId) { _files->_setPaletteFlag = true; _buffer2.copyFrom(*_screen); - for (int i = 0; i < 3; ++i) { - _sound->playSound(0); - _screen->forceFadeIn(); - _sound->playSound(0); - _screen->forceFadeOut(); + if (!isDemo() || deathId != 10) { + for (int i = 0; i < 3; ++i) { + _sound->playSound(0); + _screen->forceFadeIn(); + _sound->playSound(0); + _screen->forceFadeOut(); - if (shouldQuit()) - return; + if (shouldQuit()) + return; + } } if (!isDemo()) { @@ -708,9 +714,6 @@ void AmazonEngine::dead(int deathId) { warning("TODO: restart game"); quitGame(); _events->pollEvents(); - } else { - quitGame(); - _events->pollEvents(); } } -- cgit v1.2.3 From 3cf08939797c1963264cf1ef49ed227fba3daf00 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 7 Dec 2014 19:53:19 +0100 Subject: ACCESS: Add a cheat mode which currently skips the guard in chapter 8 --- engines/access/access.cpp | 1 + engines/access/access.h | 2 +- engines/access/amazon/amazon_logic.cpp | 5 +++++ engines/access/debugger.cpp | 13 +++++++++++++ engines/access/debugger.h | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index a09e47c733..428c4c603a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -88,6 +88,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _sndSubFile = 0; _loadSaveSlot = -1; _vidX = _vidY = 0; + _cheatFl = false; } AccessEngine::~AccessEngine() { diff --git a/engines/access/access.h b/engines/access/access.h index 2fe4b726a2..2fdf26318e 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -207,7 +207,7 @@ public: int _flags[256]; bool _clearSummaryFlag; - + bool _cheatFl; // Fields mapped into the flags array int &_useItem; int &_startup; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c9e8886d08..c1df5353a2 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1168,6 +1168,11 @@ void Guard::setGuardFrame() { } void Guard::doGuard() { + // Skip the code dealing with the guard on the boat (chapter 8) + // if the cheat mode is activated + if (_vm->_cheatFl) + return; + if (_vm->_timers[8]._flag) { setGuardFrame(); return; diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 6b49fb0e67..1f8100452b 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -57,6 +57,7 @@ Debugger *Debugger::init(AccessEngine *vm) { Debugger::Debugger(AccessEngine *vm) : GUI::Debugger(), _vm(vm) { registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); registerCmd("scene", WRAP_METHOD(Debugger, Cmd_LoadScene)); + registerCmd("cheat", WRAP_METHOD(Debugger, Cmd_Cheat)); switch (vm->getGameID()) { case GType_Amazon: @@ -120,6 +121,18 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { } } +bool Debugger::Cmd_Cheat(int argc, const char **argv) { + if (argc != 1) { + debugPrintf("Usage: %s\n", argv[0]); + debugPrintf("Switches on/off the cheat mode\n"); + return true; + } + + _vm->_cheatFl = !_vm->_cheatFl; + debugPrintf("Cheat is now %s\n", _vm->_cheatFl ? "ON" : "OFF"); + return true; +} + /*------------------------------------------------------------------------*/ namespace Amazon { diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 839d13106e..6bd23740cd 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -37,6 +37,7 @@ protected: AccessEngine *_vm; bool Cmd_LoadScene(int argc, const char **argv); + bool Cmd_Cheat(int argc, const char **argv); Common::String *_sceneDescr; int _sceneNumb; public: -- cgit v1.2.3 From 07456932d4be48fcf27a991d9d764a111abc5524 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 7 Dec 2014 22:28:03 +0100 Subject: ACCESS: Add a debug channel for the sound & music handling --- engines/access/access.cpp | 1 + engines/access/access.h | 3 ++- engines/access/sound.cpp | 42 +++++++++++++++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 428c4c603a..b63bb29e0a 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -120,6 +120,7 @@ void AccessEngine::initialize() { DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level"); DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts"); DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling"); + DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling"); if (isCD()) { const Common::FSNode gameDataDir(ConfMan.get("path")); diff --git a/engines/access/access.h b/engines/access/access.h index 2fdf26318e..284ac2690c 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -71,7 +71,8 @@ enum { enum AccessDebugChannels { kDebugPath = 1 << 0, kDebugScripts = 1 << 1, - kDebugGraphics = 1 << 2 + kDebugGraphics = 1 << 2, + kDebugSound = 1 << 3 }; struct AccessGameDescription; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 95576d212b..b5800ba82f 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -30,8 +30,7 @@ namespace Access { -SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : - _vm(vm), _mixer(mixer) { +SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { _playingSound = false; _isVoice = false; } @@ -41,12 +40,16 @@ SoundManager::~SoundManager() { } void SoundManager::clearSounds() { + debugC(1, kDebugSound, "clearSounds()"); + for (uint i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]._res; _soundTable.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { + debugC(1, kDebugSound, "queueSound(%d, %d, %d)", idx, fileNum, subfile); + Resource *soundResource; if (idx >= (int)_soundTable.size()) @@ -59,15 +62,20 @@ void SoundManager::queueSound(int idx, int fileNum, int subfile) { } Resource *SoundManager::loadSound(int fileNum, int subfile) { + debugC(1, kDebugSound, "loadSound(%d, %d)", fileNum, subfile); return _vm->_files->loadFile(fileNum, subfile); } void SoundManager::playSound(int soundIndex) { + debugC(1, kDebugSound, "playSound(%d)", soundIndex); + int priority = _soundTable[soundIndex]._priority; playSound(_soundTable[soundIndex]._res, priority); } void SoundManager::playSound(Resource *res, int priority) { + debugC(1, kDebugSound, "playSound"); + byte *resourceData = res->data(); Audio::SoundHandle audioHandle; Audio::RewindableAudioStream *audioStream = 0; @@ -125,6 +133,8 @@ void SoundManager::playSound(Resource *res, int priority) { } void SoundManager::loadSounds(Common::Array &sounds) { + debugC(1, kDebugSound, "loadSounds"); + clearSounds(); for (uint i = 0; i < sounds.size(); ++i) { @@ -134,10 +144,14 @@ void SoundManager::loadSounds(Common::Array &sounds) { } void SoundManager::stopSound() { + debugC(3, kDebugSound, "stopSound"); + _mixer->stopHandle(Audio::SoundHandle()); } void SoundManager::freeSounds() { + debugC(3, kDebugSound, "freeSounds"); + stopSound(); clearSounds(); } @@ -177,7 +191,8 @@ void MusicManager::send(uint32 b) { } void MusicManager::midiPlay() { - warning("MusicManager::midiPlay"); + debugC(1, kDebugSound, "midiPlay"); + if (_music->_size < 4) { error("midiPlay() wrong music resource size"); } @@ -208,12 +223,13 @@ void MusicManager::midiPlay() { } bool MusicManager::checkMidiDone() { - warning("MusicManager::checkMidiDone"); + debugC(1, kDebugSound, "checkMidiDone"); return (!_isPlaying); } void MusicManager::midiRepeat() { - warning("MusicManager::midiRepeat"); + debugC(1, kDebugSound, "midiRepeat"); + if (!_parser) return; @@ -224,22 +240,26 @@ void MusicManager::midiRepeat() { } void MusicManager::stopSong() { - warning("MusicManager::stopSong"); + debugC(1, kDebugSound, "stopSong"); + stop(); } void MusicManager::loadMusic(int fileNum, int subfile) { - warning("MusicManager::loadMusic %d %d", fileNum, subfile); + debugC(1, kDebugSound, "loadMusic(%d, %d)", fileNum, subfile); + _music = _vm->_files->loadFile(fileNum, subfile); } void MusicManager::loadMusic(FileIdent file) { - warning("MusicManager::loadMusic %d %d", file._fileNum, file._subfile); + debugC(1, kDebugSound, "loadMusic(%d, %d)", file._fileNum, file._subfile); + _music = _vm->_files->loadFile(file); } void MusicManager::newMusic(int musicId, int mode) { - warning("MusicManager::newMusic %d %d", musicId, mode); + debugC(1, kDebugSound, "newMusic(%d, %d)", musicId, mode); + if (mode == 1) { stopSong(); freeMusic(); @@ -258,11 +278,15 @@ void MusicManager::newMusic(int musicId, int mode) { } void MusicManager::freeMusic() { + debugC(3, kDebugSound, "freeMusic"); + delete _music; _music = nullptr; } void MusicManager::setLoop(bool loop) { + debugC(3, kDebugSound, "setLoop"); + _isLooping = loop; if (_parser) _parser->property(MidiParser::mpAutoLoop, _isLooping); -- cgit v1.2.3 From 8e90ef2ec7fd1b3bf7d020988fff1629605b0481 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 7 Dec 2014 17:45:51 -0500 Subject: ACCESS: Minor river code clean up and saving fix --- engines/access/amazon/amazon_game.h | 1 - engines/access/amazon/amazon_logic.cpp | 51 +++++++++++++++++++--------------- engines/access/amazon/amazon_logic.h | 1 + 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 43fce80191..63ee978359 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -107,7 +107,6 @@ public: int _updateChapter; int _oldTitleChapter; int _maxHits; - int _oldScrollCol; int _iqValue; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c1df5353a2..cb655bbf14 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1361,6 +1361,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _saveRiver = false; _deathFlag = false; _deathCount = 0; + _oldScrollCol = 0; } void River::setRiverPan() { @@ -1472,7 +1473,7 @@ void River::initRiver() { void River::resetPositions() { riverSetPhysX(); - int val = (_vm->_screen->_scrollCol + 1 - _vm->_oldScrollCol) * 16; + int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16; if (val > 256) { val &= 0x7F; val |= 0x80; @@ -1483,7 +1484,7 @@ void River::resetPositions() { } void River::checkRiverPan() { - int val = (_vm->_screen->_scrollCol + 20) * 16; + int val = _vm->_screen->_scrollCol * 16 + 320; for (int i = 0; i < _pNumObj; i++) { if (_pan[i]._pObjX < val) @@ -1499,7 +1500,7 @@ bool River::riverJumpTest() { ++_mapPtr; if (val == 0xFF) return true; - _vm->_oldScrollCol = _vm->_screen->_scrollCol; + _oldScrollCol = _vm->_screen->_scrollCol; if (val == 0) { _vm->_screen->_scrollCol = 139; @@ -1524,7 +1525,7 @@ bool River::riverJumpTest() { _deathCount = 300; _deathType = val2; } - _vm->_oldScrollCol = _vm->_screen->_scrollCol; + _oldScrollCol = _vm->_screen->_scrollCol; _vm->_screen->_scrollCol = 44; _vm->_screen->_scrollX = 14; _vm->_room->buildScreen(); @@ -1579,11 +1580,6 @@ void River::moveCanoe() { } else { // Clicked on the Disc icon _saveRiver = true; - _rScrollRow = screen._scrollRow; - _rScrollCol = screen._scrollCol; - _rScrollX = screen._scrollX; - _rScrollY = screen._scrollY; - _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag]; // Show the ScummVM menu _vm->_room->handleCommand(9); @@ -1635,6 +1631,8 @@ void River::updateObstacles() { break; if (cur->_riverX < (_screenVertX + 319)) { + // Object is now on-screen. So set _topList/_botList to the range + // of river obstacles that are currently visible _topList = cur; _botList = cur; @@ -1657,11 +1655,10 @@ void River::updateObstacles() { } void River::riverSetPhysX() { - int val = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; - RiverStruct *cur = _topList; - while (cur <= _botList) { - cur[0]._xp = val - (_screenVertX - cur[0]._riverX); - ++cur; + int xAmt = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + + for (RiverStruct *cur = _topList; cur <= _botList; ++cur) { + cur->_xp = xAmt - (_screenVertX - cur->_riverX); } } @@ -1688,14 +1685,15 @@ bool River::checkRiverCollide() { } void River::plotRiver() { + // Handle cycling through the canoe rowing frames if (_vm->_timers[3]._flag == 0) { ++_vm->_timers[3]._flag; - if (_canoeFrame == 12) + + if (_canoeFrame++ == 12) _canoeFrame = 0; - else - ++_canoeFrame; } + // Draw the canoe ImageEntry ie; ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; @@ -1705,19 +1703,17 @@ void River::plotRiver() { ie._offsetY = 41; _vm->_images.addToList(ie); - RiverStruct *cur = _topList; - while (cur <= _botList) { + // Draw any on-screen obstacles + for (RiverStruct *cur = _topList; cur <= _botList; ++cur) { if (cur->_id != -1) { ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; ie._frameNumber = cur->_id; ie._position.x = cur->_xp; - int val = (cur[0]._lane * 5) + 56; - ie._position.y = val - cur->_offsetY; + ie._position.y = (cur->_lane * 5) + 56 - cur->_offsetY; ie._offsetY = cur->_offsetY; _vm->_images.addToList(ie); } - ++cur; } } @@ -1890,8 +1886,19 @@ void River::river() { } } } + void River::synchronize(Common::Serializer &s) { if (_vm->_player->_roomNumber == 45) { + if (s.isSaving()) { + // Set river properties to be saved out + Screen &screen = *_vm->_screen; + _rScrollRow = screen._scrollRow; + _rScrollCol = screen._scrollCol; + _rScrollX = screen._scrollX; + _rScrollY = screen._scrollY; + _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag]; + } + s.syncAsSint16LE(_canoeLane); s.syncAsSint16LE(_canoeYPos); s.syncAsSint16LE(_hitCount); diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 1cc65cbf6d..d2fb3334fa 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -183,6 +183,7 @@ private: int _rScrollY; int _mapOffset; int _screenVertX; + int _oldScrollCol; void initRiver(); void resetPositions(); -- cgit v1.2.3 From 86bee5b48ecbadf9c8f1b4ae2f48c8bcbdf3fce9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 7 Dec 2014 17:53:05 -0500 Subject: ACCESS: Fix function key mapping for game icons --- engines/access/room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b3c3317307..a781dab24a 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -468,8 +468,8 @@ void Room::doCommands() { mainAreaClick(); } } else if (_vm->_events->getKey(keyState)) { - if (keyState.ascii >= ';' && keyState.ascii <= 'D') { - handleCommand((int)keyState.ascii - ';'); + if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) { + handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1); } } } -- cgit v1.2.3 From 7508e7b5f8c491556b65ff48d54f289cec9532b1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 8 Dec 2014 07:45:11 +0100 Subject: ACCESS: Minor River cleanup --- engines/access/amazon/amazon_game.h | 1 - engines/access/amazon/amazon_logic.cpp | 4 ++-- engines/access/amazon/amazon_logic.h | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 63ee978359..30b9b80778 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -106,7 +106,6 @@ public: int _hintLevel; int _updateChapter; int _oldTitleChapter; - int _maxHits; int _iqValue; public: AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index cb655bbf14..89ea81507b 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1362,6 +1362,7 @@ River::River(AmazonEngine *vm): PannedScene(vm) { _deathFlag = false; _deathCount = 0; _oldScrollCol = 0; + _maxHits = 0; } void River::setRiverPan() { @@ -1467,7 +1468,7 @@ void River::initRiver() { _vm->_timers[12]._initTm = 1500; ++_vm->_timers[12]._flag; - _vm->_maxHits = 2 - _vm->_riverFlag; + _maxHits = 2 - _vm->_riverFlag; _saveRiver = false; } @@ -1558,7 +1559,6 @@ void River::riverSound() { } void River::moveCanoe() { - Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; Common::Point pt = events.calcRawMouse(); diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index d2fb3334fa..2799e4f8dd 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -170,6 +170,7 @@ private: bool _deathFlag; int _deathCount; int _deathType; + int _maxHits; // Saved fields int _canoeLane; -- cgit v1.2.3 From 960a787c033fa7a90d347b9d37c4c0e890444ce2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 8 Dec 2014 07:55:47 +0100 Subject: ACCESS: Reduce the scope of a variable in Inventory --- engines/access/inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 78a85c3257..4038929a67 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -318,13 +318,13 @@ void InventoryManager::putInvIcon(int itemIndex, int itemId) { void InventoryManager::chooseItem() { EventsManager &events = *_vm->_events; _vm->_useItem = -1; - int selIndex; while (!_vm->shouldQuit()) { // Check for events events.pollEvents(); g_system->delayMillis(10); + int selIndex; // Poll events and wait for a click on a known area if (!events._leftButton || ((selIndex = coordIndexOf()) == -1)) continue; -- cgit v1.2.3 From 9ef60f3f3357491e39dfe3c16470fa3711e8a211 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 8 Dec 2014 07:56:13 +0100 Subject: ACCESS: Fix a bug in plotInactive --- engines/access/amazon/amazon_scripts.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index fb1ccbe05e..c5b77950ad 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -300,8 +300,8 @@ void AmazonScripts::plotInactive() { _game->_rawInactiveY >= 158 && _game->_rawInactiveY <= 173) { _game->_flags[155] = 1; } else { - _game->_flags[160] = 1; - if (!_game->_jasMayaFlag && _game->_rawInactiveX <= 266 && _game->_rawInactiveX < 290 + _game->_flags[160] = 0; + if (!_game->_jasMayaFlag && _game->_rawInactiveX >= 266 && _game->_rawInactiveX <= 290 && _game->_rawInactiveY >= 70 && _game->_rawInactiveY <= 87) { _game->_flags[160] = 1; } -- cgit v1.2.3 From 35922c28c8579c9f2fe476a351da74a92b7660d5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Dec 2014 00:35:02 +0100 Subject: ACCESS: Add a hack to fake queueing --- engines/access/amazon/amazon_logic.cpp | 2 +- engines/access/sound.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 89ea81507b..f1bf7dcf3b 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -354,9 +354,9 @@ void Opening::doTitle() { _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); _vm->_screen->copyFrom(_vm->_buffer2); + _vm->_sound->playSound(1); _vm->_events->_vbCount = 70; while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0 && !_skipStart) { - _vm->_sound->playSound(1); _vm->_events->pollEventsAndWait(); if (_vm->_events->_rightButton) _skipStart = true; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index b5800ba82f..4e701618d9 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -82,6 +82,10 @@ void SoundManager::playSound(Resource *res, int priority) { assert(res->_size >= 32); + // HACK: Simulates queueing for the rare sounds played one after the other + while (_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType)) + ; + if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) { // CD version uses WAVE-files Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO); -- cgit v1.2.3 From b20c755f46b34906305c773d1e4e320d0d8affbe Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 8 Dec 2014 21:59:00 -0500 Subject: ACCESS: Fix progressing within the river --- engines/access/amazon/amazon_logic.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index f1bf7dcf3b..952809f11f 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1497,10 +1497,10 @@ void River::checkRiverPan() { bool River::riverJumpTest() { if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) { - int val = _mapPtr[0]; - ++_mapPtr; + int val = *++_mapPtr; if (val == 0xFF) return true; + _oldScrollCol = _vm->_screen->_scrollCol; if (val == 0) { -- cgit v1.2.3 From c69480f6bf6f7afd6f0cffb0a6a76e22ad8e08cf Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 8 Dec 2014 23:13:42 -0500 Subject: ACCESS: Fix event pollig in death flashing loop --- engines/access/amazon/amazon_game.cpp | 1 + engines/access/amazon/amazon_logic.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index b425fe9e22..9880b65b69 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -640,6 +640,7 @@ void AmazonEngine::dead(int deathId) { _sound->playSound(0); _screen->forceFadeOut(); + _events->pollEvents(); if (shouldQuit()) return; } diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 952809f11f..01450077bd 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1475,8 +1475,7 @@ void River::initRiver() { void River::resetPositions() { riverSetPhysX(); int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16; - if (val > 256) { - val &= 0x7F; + if (val < 0) { val |= 0x80; } -- cgit v1.2.3 From 8ee8444779b11528391fb969f186fd8a74f437a6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Dec 2014 07:49:39 +0100 Subject: ACCESS: Skip chapter speech for the non-CD versions --- engines/access/amazon/amazon_game.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 9880b65b69..98eba1f086 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -481,13 +481,14 @@ void AmazonEngine::startChapter(int chapter) { _timers[20]._flag++; _sound->freeSounds(); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); - _sound->playSound(0); - _sound->freeSounds(); + if (isCD()) { + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); + _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); + _sound->playSound(0); + _sound->playSound(1); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); - _sound->playSound(0); - _sound->freeSounds(); + _sound->freeSounds(); + } // Wait loop while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { -- cgit v1.2.3 From 8d97dc9891a3a4a217c72915b8a319f66f84d250 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Dec 2014 07:50:40 +0100 Subject: ACCESS: stops the SFX sounds in the intro at the end of the countdown --- engines/access/amazon/amazon_logic.cpp | 1 + engines/access/sound.h | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 01450077bd..80c98a8ad1 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -365,6 +365,7 @@ void Opening::doTitle() { if (_vm->shouldQuit()) return; + _vm->_sound->stopSound(); _vm->_sound->playSound(0); _vm->_screen->forceFadeOut(); _vm->_events->_vbCount = 100; diff --git a/engines/access/sound.h b/engines/access/sound.h index 5089bd093b..dc8bd90b85 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -52,8 +52,6 @@ private: void clearSounds(); void playSound(Resource *res, int priority); - void stopSound(); - public: Common::Array _soundTable; bool _playingSound; @@ -69,6 +67,7 @@ public: Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); + void stopSound(); void freeSounds(); }; -- cgit v1.2.3 From 98685b935822f3f934d3b69aa079e3e70b71f2e2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Dec 2014 07:59:18 +0100 Subject: ACCESS: Add some more checks for the floppy version --- engines/access/amazon/amazon_game.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 98eba1f086..77ee8fe620 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -232,7 +232,7 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _printEnd = 155; Common::String msg((const char *)_establish->data() + msgOffset); - if (_txtPages == 0) { + if ((_txtPages == 0) || !isCD()) { printText(_screen, msg); } else { speakText(_screen, msg); @@ -569,7 +569,7 @@ void AmazonEngine::startChapter(int chapter) { Common::String msg((const char *)_establish->data() + msgOffset); - if (_txtPages == 0) { + if ((_txtPages == 0) || !isCD()) { printText(_screen, msg); } else { speakText(_screen, msg); -- cgit v1.2.3 From 1870e31e25bd2b502fca538fd6c84e97c839b5a5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 9 Dec 2014 08:02:10 +0100 Subject: ACCESS: Add a comment related to the CD specific files --- engines/access/amazon/amazon_resources.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index ed4a012bd1..cb84841002 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -45,6 +45,7 @@ const char *const FILENAMES[] = { "C24.AP", "C25.AP", "C29.AP", "C30.AP", "C32.AP", "C33.AP", "C34.AP", "CREDITS.AP", "MIDIDRV.AP", "SUMMARY.AP", "DEAD.AP", "EST.AP", "CHAPTER.AP", "MIDI.AP", "SOUND.AP", "INV.AP", + // The following files are only present in the CD version "NARATE01.AP", "NARATE02.AP", "NARATE03.AP", "NARATE04.AP", "NARATE05.AP", "NARATE06.AP", "NARATE07.AP", "NARATE08.AP", "NARATE09.AP", "NARATE10.AP", "NARATE11.AP", "NARATE12.AP", -- cgit v1.2.3 From beba0b40d5730844d6c8ffc813f19cf5d743f2af Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 9 Dec 2014 19:43:38 -0500 Subject: ACCESS: Minor cleanup of _saveRiver flag --- engines/access/amazon/amazon_logic.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 80c98a8ad1..23a8a43932 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1578,14 +1578,10 @@ void River::moveCanoe() { // Disk icon wasn't clicked _vm->_scripts->printString(BAR_MESSAGE); } else { - // Clicked on the Disc icon - _saveRiver = true; - - // Show the ScummVM menu + // Clicked on the Disc icon. Show the ScummVM menu _vm->_room->handleCommand(9); if (_vm->_room->_function != FN_CLEAR1) { - _saveRiver = false; _vm->_room->buildScreen(); _vm->copyBF2Vid(); } -- cgit v1.2.3 From cdc27778c0c07d728876ebe169d658dda666ef1f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 9 Dec 2014 20:11:44 -0500 Subject: ACCESS: Add a button to allow skipping the river scene --- engines/access/amazon/amazon_logic.cpp | 22 +++++++++++++++++----- engines/access/amazon/amazon_logic.h | 2 +- engines/access/amazon/amazon_scripts.cpp | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 23a8a43932..eb889d2000 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1471,6 +1471,12 @@ void River::initRiver() { _maxHits = 2 - _vm->_riverFlag; _saveRiver = false; + + Font &font2 = _vm->_fonts._font2; + font2._fontColors[0] = 0; + font2._fontColors[1] = 33; + font2._fontColors[2] = 34; + font2._fontColors[3] = 35; } void River::resetPositions() { @@ -1561,6 +1567,7 @@ void River::riverSound() { void River::moveCanoe() { EventsManager &events = *_vm->_events; Common::Point pt = events.calcRawMouse(); + Common::Point mousePos = events.getMousePos(); // Do an event polling _vm->_canSaveLoad = true; @@ -1586,8 +1593,10 @@ void River::moveCanoe() { _vm->copyBF2Vid(); } } - } - else if ((events._leftButton && pt.y <= _canoeYPos) || + } else if (events._leftButton && mousePos.x < 35 && mousePos.y < 12) { + // Clicked on the Skip button. So chicken out + _CHICKENOUTFLG = true; + } else if ((events._leftButton && pt.y <= _canoeYPos) || (!events._leftButton && _vm->_player->_move == UP)) { // Move canoe up if (_canoeLane > 0) { @@ -1596,8 +1605,7 @@ void River::moveCanoe() { moveCanoe2(); } - } - else if (events._leftButton || _vm->_player->_move == DOWN) { + } else if (events._leftButton || _vm->_player->_move == DOWN) { // Move canoe down if (_canoeLane < 7) { _canoeDir = 1; @@ -1711,6 +1719,10 @@ void River::plotRiver() { _vm->_images.addToList(ie); } } + + // Draw the text for skipping the river + Font &font2 = _vm->_fonts._font2; + font2.drawString(_vm->_screen, "SKIP", Common::Point(5, 5)); } void River::mWhileDownRiver() { @@ -1809,7 +1821,7 @@ void River::scrollRiver1() { _vm->copyBF2Vid(); } -void River::river() { +void River::doRiver() { static const int RIVERDEATH[5] = { 22, 23, 24, 25, 26 }; initRiver(); diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 2799e4f8dd..2962d77722 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -203,7 +203,7 @@ private: public: River(AmazonEngine *vm); - void river(); + void doRiver(); void mWhileDownRiver(); void synchronize(Common::Serializer &s); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index c5b77950ad..76513db7fb 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -362,7 +362,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { plotInactive(); break; case 13: - _game->_river.river(); + _game->_river.doRiver(); break; case 14: _game->_ant.doAnt(); -- cgit v1.2.3 From 80dfc3537d8495bb1f096c1bd21ab4052ac0cb40 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Dec 2014 08:12:37 +0100 Subject: ACCESS: Fix _help3 initialization --- engines/access/amazon/amazon_game.cpp | 8 ++++---- engines/access/amazon/amazon_game.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 77ee8fe620..20d71021c2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -47,14 +47,13 @@ AccessEngine(syst, gameDesc), _rawInactiveX = 0; _rawInactiveY = 0; _inactiveYOff = 0; - _tilePos = Common::Point(0, 0); _hintLevel = 0; Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); - Common::fill(&_help1[0], &_help3[366], 0); + Common::fill(&_help3[0], &_help3[366], 0); _helpTbl[0] = _help1; _helpTbl[1] = _help2; _helpTbl[2] = _help3; @@ -276,8 +275,9 @@ void AmazonEngine::tileScreen() { _tileData[i] = res->_stream->readByte(); // CHECKME: Depending on the Vesa mode during initialization, 400 or 480 - for (_tilePos.y = 0; _tilePos.y < 480; _tilePos.y += y) { - for (_tilePos.x = 0; _tilePos.x < 640; _tilePos.x += x) + Common::Point tilePos; + for (tilePos.y = 0; tilePos.y < 480; tilePos.y += y) { + for (tilePos.x = 0; tilePos.x < 640; tilePos.x += x) warning("TODO: DRAWOBJECT"); } diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 30b9b80778..e475542772 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -34,7 +34,6 @@ class AmazonEngine; class AmazonEngine : public AccessEngine { private: - Common::Point _tilePos; byte _tileData[1455]; Common::Array _chapterCells; -- cgit v1.2.3 From 538782e14e085fa4cc8e435439f0432b3b1f0b21 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Dec 2014 08:25:35 +0100 Subject: ACCESS: Get rid of the use of 'this' in constructor --- engines/access/amazon/amazon_game.cpp | 40 ++++++++++++++++++++++++++------ engines/access/amazon/amazon_game.h | 15 ++++++------ engines/access/amazon/amazon_player.cpp | 2 +- engines/access/amazon/amazon_scripts.cpp | 20 ++++++++-------- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 20d71021c2..cfcafbba6f 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -36,9 +36,15 @@ AccessEngine(syst, gameDesc), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), - _noSound(_flags[239]), - _ant(this), _cast(this), _guard(this), _jungle(this), _opening(this), - _plane(this), _river(this) { + _noSound(_flags[239]) { + + _ant = nullptr; + _cast = nullptr; + _guard = nullptr; + _jungle = nullptr; + _opening = nullptr; + _plane = nullptr; + _river = nullptr; _charSegSwitch = false; @@ -67,6 +73,14 @@ AccessEngine(syst, gameDesc), AmazonEngine::~AmazonEngine() { delete _inactive._altSpritesPtr; + + delete _ant; + delete _cast; + delete _guard; + delete _jungle; + delete _opening; + delete _plane; + delete _river; } void AmazonEngine::freeInactivePlayer() { @@ -79,18 +93,30 @@ void AmazonEngine::configSelect() { _hintLevel = 3; } -void AmazonEngine::playGame() { - // Initialize Amazon game-specific objects +void AmazonEngine::initObjects() { _room = new AmazonRoom(this); _scripts = new AmazonScripts(this); + _ant = new Ant(this); + _cast = new Cast(this); + _guard = new Guard(this); + _jungle = new Jungle(this); + _opening = new Opening(this); + _plane = new Plane(this); + _river = new River(this); +} + +void AmazonEngine::playGame() { + // Initialize Amazon game-specific objects + initObjects(); + // Setup the game setupGame(); configSelect(); if (_loadSaveSlot == -1) { // Do introduction - _opening.doIntroduction(); + _opening->doIntroduction(); if (shouldQuit()) return; } @@ -735,7 +761,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsByte(_help3[i]); } - _river.synchronize(s); + _river->synchronize(s); } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index e475542772..4ebea0f7eb 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -48,6 +48,7 @@ private: void configSelect(); void initVariables(); + void initObjects(); void calcIQ(); void helpTitle(); void drawHelpText(const Common::String &msg); @@ -95,13 +96,13 @@ public: int _esTabTable[100]; // Other game specific fields - Ant _ant; - Cast _cast; - Guard _guard; - Jungle _jungle; - Opening _opening; - Plane _plane; - River _river; + Ant *_ant; + Cast *_cast; + Guard *_guard; + Jungle *_jungle; + Opening *_opening; + Plane *_plane; + River *_river; int _hintLevel; int _updateChapter; int _oldTitleChapter; diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp index c9b63a9108..2780922935 100644 --- a/engines/access/amazon/amazon_player.cpp +++ b/engines/access/amazon/amazon_player.cpp @@ -77,7 +77,7 @@ void AmazonPlayer::load() { _diagUpWalkMax = 5; _diagDownWalkMin = 0; _diagDownWalkMax = 5; - _game->_guard.setPosition(Common::Point(56, 190)); + _game->_guard->setPosition(Common::Point(56, 190)); } } diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 76513db7fb..52c142a415 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -211,25 +211,25 @@ void AmazonScripts::mWhile(int param1) { mWhile1(); break; case 2: - _game->_plane.mWhileFly(); + _game->_plane->mWhileFly(); break; case 3: - _game->_plane.mWhileFall(); + _game->_plane->mWhileFall(); break; case 4: - _game->_jungle.mWhileJWalk(); + _game->_jungle->mWhileJWalk(); break; case 5: - _game->_jungle.mWhileDoOpen(); + _game->_jungle->mWhileDoOpen(); break; case 6: - _game->_river.mWhileDownRiver(); + _game->_river->mWhileDownRiver(); break; case 7: mWhile2(); break; case 8: - _game->_jungle.mWhileJWalk2(); + _game->_jungle->mWhileJWalk2(); break; default: break; @@ -332,7 +332,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { if (_vm->isDemo()) warning("TODO: DEMO - LOADCELLSET"); else - _game->_cast.doCast(param1); + _game->_cast->doCast(param1); break; case 4: if (_vm->isDemo()) @@ -353,7 +353,7 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { warning("TODO: DEMO - CHKMONEY"); break; case 9: - _game->_guard.doGuard(); + _game->_guard->doGuard(); break; case 10: _vm->_midi->newMusic(param1, param2); @@ -362,10 +362,10 @@ void AmazonScripts::executeSpecial(int commandIndex, int param1, int param2) { plotInactive(); break; case 13: - _game->_river.doRiver(); + _game->_river->doRiver(); break; case 14: - _game->_ant.doAnt(); + _game->_ant->doAnt(); break; case 15: boatWalls(param1, param2); -- cgit v1.2.3 From 8517209bcbef56a1fa68a6e17b04d56c13fa77b2 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 10 Dec 2014 23:25:18 +0100 Subject: ACCESS: Implement restart after death --- engines/access/access.cpp | 4 +++ engines/access/access.h | 2 ++ engines/access/amazon/amazon_game.cpp | 67 ++++++++++++++++++++++------------- engines/access/room.cpp | 8 ++--- engines/access/scripts.cpp | 2 +- 5 files changed, 53 insertions(+), 30 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index b63bb29e0a..4201564e84 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -89,6 +89,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _loadSaveSlot = -1; _vidX = _vidY = 0; _cheatFl = false; + _restartFl = false; } AccessEngine::~AccessEngine() { @@ -570,4 +571,7 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH out->writeUint32LE(_events->getFrameCounter()); } +bool AccessEngine::shouldQuitOrRestart() { + return shouldQuit() || _restartFl; +} } // End of namespace Access diff --git a/engines/access/access.h b/engines/access/access.h index 284ac2690c..5470d2a208 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -209,6 +209,7 @@ public: bool _clearSummaryFlag; bool _cheatFl; + bool _restartFl; // Fields mapped into the flags array int &_useItem; int &_startup; @@ -228,6 +229,7 @@ public: uint16 getVersion() const; uint32 getGameID() const; uint32 getGameFeatures() const; + bool shouldQuitOrRestart(); int getRandomNumber(int maxNumber); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index cfcafbba6f..29466f1dee 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -121,40 +121,36 @@ void AmazonEngine::playGame() { return; } - _screen->clearScreen(); - _screen->setPanel(0); - _screen->forceFadeOut(); - _events->showCursor(); - - initVariables(); - - // If there's a pending savegame to load, load it - if (_loadSaveSlot != -1) - loadGameState(_loadSaveSlot); + do { + _restartFl = false; + _screen->clearScreen(); + _screen->setPanel(0); + _screen->forceFadeOut(); + _events->showCursor(); + + initVariables(); + + // If there's a pending savegame to load, load it + if (_loadSaveSlot != -1) { + loadGameState(_loadSaveSlot); + _loadSaveSlot = -1; + } - // Execute the room - _room->doRoom(); + // Execute the room + _room->doRoom(); + } while (_restartFl); } void AmazonEngine::setupGame() { - // Setup timers - const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; - for (int i = 0; i < 32; ++i) { - TimerEntry te; - te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; - te._flag = 1; - - _timers.push_back(te); - } - // Load death list - _deaths.resize(58); if (isDemo()) { + _deaths.resize(34); for (int i = 0; i < 34; ++i) { _deaths[i]._screenId = DEATH_SCREENS_DEMO[i]; _deaths[i]._msg = DEATH_TEXT_DEMO[i]; } } else { + _deaths.resize(58); for (int i = 0; i < 58; ++i) { _deaths[i]._screenId = DEATH_SCREENS[i]; _deaths[i]._msg = DEATH_TEXT[i]; @@ -178,8 +174,29 @@ void AmazonEngine::initVariables() { _player->_roomNumber = 33; else _player->_roomNumber = 4; + + _converseMode = 0; + _inventory->_startInvItem = 0; + _inventory->_startInvBox = 0; + Common::fill(&_objectsTable[0], &_objectsTable[100], (SpriteResource *)nullptr); + _player->_playerOff = false; + + // Setup timers + const int TIMER_DEFAULTS[] = { 3, 10, 8, 1, 1, 1, 1, 2 }; + for (int i = 0; i < 32; ++i) { + TimerEntry te; + te._initTm = te._timer = (i < 8) ? TIMER_DEFAULTS[i] : 1; + te._flag = 1; + + _timers.push_back(te); + } + _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; + _room->_selectCommand = -1; + _events->_normalMouse = CURSOR_CROSSHAIRS; + _mouseMode = 0; + _numAnimTimers = 0; } void AmazonEngine::establish(int screenId, int esatabIndex) { @@ -739,8 +756,8 @@ void AmazonEngine::dead(int deathId) { _player->removeSprite1(); } - warning("TODO: restart game"); - quitGame(); + // The original was jumping to the restart label in main + _restartFl = true; _events->pollEvents(); } } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a781dab24a..57332f742d 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -90,7 +90,7 @@ void Room::doRoom() { _vm->_player->checkScroll(); doCommands(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; // DOROOMFLASHBACK jump point @@ -128,7 +128,7 @@ void Room::doRoom() { _function = FN_NONE; roomLoop(); - if (_vm->shouldQuit()) + if (_vm->shouldQuitOrRestart()) return; if (_function == FN_CLEAR1) { @@ -578,7 +578,7 @@ void Room::walkCursor() { _selectCommand = -1; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } @@ -622,7 +622,7 @@ void Room::checkBoxes3() { _vm->_boxSelect = start; _conFlag = true; - while (_conFlag && !_vm->shouldQuit()) { + while (_conFlag && !_vm->shouldQuitOrRestart()) { _conFlag = false; _vm->_scripts->executeScript(); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 728421c6d9..6c9f278736 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -100,7 +100,7 @@ int Scripts::executeScript() { assert(_scriptCommand >= 0x80); executeCommand(_scriptCommand - 0x80); - } while (!_endFlag && !_vm->shouldQuit()); + } while (!_endFlag && !_vm->shouldQuitOrRestart()); return _returnCode; } -- cgit v1.2.3 From b1d5359fc6033c25c3360d30de0fe98ce4fce29e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:12:04 -0500 Subject: ACCESS: Minor formatting for debugger error messages --- engines/access/debugger.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 1f8100452b..5eb615f4dc 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -96,11 +96,11 @@ bool Debugger::Cmd_LoadScene(int argc, const char **argv) { case 2: { int newRoom = strToInt(argv[1]); if (newRoom < 0 || newRoom >= _sceneNumb) { - debugPrintf("Invalid Room Number"); + debugPrintf("Invalid Room Number\n"); return true; } if (!_sceneDescr[newRoom].size()) { - debugPrintf("Unused Room Number"); + debugPrintf("Unused Room Number\n"); return true; } -- cgit v1.2.3 From 781c6ff8c44efd4e9411114d2628d547fab8ce33 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:12:39 -0500 Subject: ACCESS: Initial enum cleanup for Ant fields --- engines/access/amazon/amazon_logic.cpp | 30 +++++++++++++++--------------- engines/access/amazon/amazon_logic.h | 6 ++++-- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index eb889d2000..49bc47fc64 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1926,8 +1926,8 @@ void River::synchronize(Common::Serializer &s) { /*------------------------------------------------------------------------*/ Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) { - _antDirection = NONE; - _pitDirection = NONE; + _antDirection = RIGHT; + _pitDirection = RIGHT; _antCel = 0; _torchCel = 0; _pitCel = 0; @@ -1962,6 +1962,7 @@ void Ant::plotPit(int indx, const int *&buf) { _vm->_player->_rawPlayer = _pitPos; if (_vm->_inventory->_inv[76]._value == 1) { + // Player has torch idx = _torchCel; buf = Amazon::TORCH; _vm->_timers[14]._flag = 1; @@ -1970,8 +1971,8 @@ void Ant::plotPit(int indx, const int *&buf) { idx = 0; _torchCel = idx; plotTorchSpear(idx, buf); - } - else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { + } else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { + // Player has spear idx = 0; buf = Amazon::SPEAR; plotTorchSpear(idx, buf); @@ -1980,8 +1981,8 @@ void Ant::plotPit(int indx, const int *&buf) { int Ant::antHandleRight(int indx, const int *&buf) { int retval = indx; - if (_pitDirection == NONE) { - _pitDirection = UP; + if (_pitDirection == RIGHT) { + _pitDirection = LEFT; _pitPos.y = 127; } retval = _pitCel; @@ -2001,8 +2002,8 @@ int Ant::antHandleRight(int indx, const int *&buf) { int Ant::antHandleLeft(int indx, const int *&buf) { int retval = indx; - if (_pitDirection == UP) { - _pitDirection = NONE; + if (_pitDirection == LEFT) { + _pitDirection = RIGHT; _pitPos.y = 127; } retval = _pitCel; @@ -2058,7 +2059,7 @@ int Ant::antHandleStab(int indx, const int *&buf) { } void Ant::doAnt() { - _antDirection = NONE; + _antDirection = RIGHT; if (_vm->_aniFlag != 1) { _vm->_aniFlag = 1; _antCel = 0; @@ -2086,11 +2087,9 @@ void Ant::doAnt() { const int *buf = nullptr; if (_antDieFl) { buf = Amazon::ANTDIE; - } - else if (_antEatFl) { + } else if (_antEatFl) { buf = Amazon::ANTEAT; - } - else if (_antPos.x > 120 && _vm->_flags[198] == 1) { + } else if (_antPos.x > 120 && _vm->_flags[198] == 1) { _antEatFl = true; _vm->_flags[235] = 1; _antCel = 0; @@ -2098,13 +2097,14 @@ void Ant::doAnt() { } else { buf = Amazon::ANTWALK; if (_vm->_inventory->_inv[76]._value == 1) - _antDirection = UP; + // Player has burning torch, which scares the Ant + _antDirection = LEFT; } int idx = _antCel; if (_vm->_timers[15]._flag == 0) { _vm->_timers[15]._flag = 1; - if (_antDirection == UP) { + if (_antDirection == LEFT) { if (_antPos.x > 10) { if (idx == 0) idx = 36; diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 2962d77722..d66a8d818e 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -209,10 +209,12 @@ public: void synchronize(Common::Serializer &s); }; +enum AntDirection { RIGHT = 0, LEFT = 1 }; + class Ant: public AmazonManager { private: - Direction _antDirection; - Direction _pitDirection; + AntDirection _antDirection; + AntDirection _pitDirection; int _antCel; int _torchCel; int _pitCel; -- cgit v1.2.3 From 547f3debb2b44dfb8fb3d659ac09f3bd24a017c4 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:27:06 -0500 Subject: ACCESS: Separate timer updates from frame updates, and overall delay cleanup --- engines/access/access.cpp | 4 +--- engines/access/amazon/amazon_game.cpp | 6 ++---- engines/access/amazon/amazon_logic.cpp | 3 --- engines/access/events.cpp | 34 ++++++++++++++++++++++++---------- engines/access/events.h | 11 +++++++---- engines/access/inventory.cpp | 9 +++------ engines/access/room.cpp | 3 +-- engines/access/screen.cpp | 4 ++-- engines/access/scripts.cpp | 9 +++------ 9 files changed, 43 insertions(+), 40 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 4201564e84..bb5414da31 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -410,9 +410,7 @@ void AccessEngine::playVideo(int videoNum, const Common::Point &pt) { while (!shouldQuit() && !_video->_videoEnd) { _video->playVideo(); - - g_system->delayMillis(10); - _events->pollEvents(); + _events->pollEventsAndWait(); } } diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 29466f1dee..63291bde52 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -535,8 +535,7 @@ void AmazonEngine::startChapter(int chapter) { // Wait loop while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { - _events->pollEvents(); - g_system->delayMillis(10); + _events->pollEventsAndWait(); } } @@ -576,8 +575,7 @@ void AmazonEngine::startChapter(int chapter) { // Wait loop while (!shouldQuit() && !_events->isKeyMousePressed() && _timers[20]._flag) { - _events->pollEvents(); - g_system->delayMillis(10); + _events->pollEventsAndWait(); } if (shouldQuit()) return; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 49bc47fc64..320d87476a 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -687,10 +687,7 @@ void Plane::mWhileFly() { ++_pCount; while (!_vm->shouldQuit() && events._vbCount > 0) { - // To be rewritten when NEWTIMER is done - events.checkForNextFrameCounter(); _vm->_sound->playSound(0); - events.pollEventsAndWait(); } } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 5ed5ee2052..249ba15010 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -47,6 +47,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { _cursorExitFlag = false; _vbCount = 0; _keyCode = Common::KEYCODE_INVALID; + _priorTimerTime = 0; } EventsManager::~EventsManager() { @@ -124,9 +125,12 @@ bool EventsManager::isCursorVisible() { void EventsManager::pollEvents(bool skipTimers) { if (checkForNextFrameCounter()) { - nextFrame(skipTimers); + nextFrame(); } + if (checkForNextTimerUpdate() && !skipTimers) + nextTimer(); + _wheelUp = _wheelDown = false; Common::Event event; @@ -233,7 +237,7 @@ void EventsManager::keyControl(Common::KeyCode keycode, bool isKeyDown) { void EventsManager::pollEventsAndWait() { pollEvents(); - g_system->delayMillis(10); + delay(); } bool EventsManager::checkForNextFrameCounter() { @@ -250,13 +254,19 @@ bool EventsManager::checkForNextFrameCounter() { return false; } -void EventsManager::nextFrame(bool skipTimers) { - if (!skipTimers) { - // Update timers - _vm->_animation->updateTimers(); - _vm->_timers.updateTimers(); +bool EventsManager::checkForNextTimerUpdate() { + // Check for next timer update + uint32 milli = g_system->getMillis(); + if ((milli - _priorTimerTime) >= GAME_TIMER_TIME) { + _priorTimerTime = milli; + + return true; } + return false; +} + +void EventsManager::nextFrame() { // Give time to the debugger _vm->_debugger->onFrame(); @@ -264,6 +274,11 @@ void EventsManager::nextFrame(bool skipTimers) { _vm->_screen->updateScreen(); } +void EventsManager::nextTimer() { + _vm->_animation->updateTimers(); + _vm->_timers.updateTimers(); +} + void EventsManager::delay(int time) { g_system->delayMillis(time); } @@ -288,8 +303,7 @@ bool EventsManager::isKeyPending() const { void EventsManager::debounceLeft() { while (_leftButton && !_vm->shouldQuit()) { - pollEvents(); - g_system->delayMillis(10); + pollEventsAndWait(); } } @@ -301,7 +315,7 @@ void EventsManager::clearEvents() { void EventsManager::waitKeyMouse() { while (!_vm->shouldQuit() && !isKeyMousePressed()) { pollEvents(true); - g_system->delayMillis(10); + delay(); } } diff --git a/engines/access/events.h b/engines/access/events.h index 04edd2bdf3..c43bf472f0 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -38,6 +38,7 @@ enum CursorType { #define GAME_FRAME_RATE 100 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) +#define GAME_TIMER_TIME 15 class AccessEngine; @@ -46,10 +47,14 @@ private: AccessEngine *_vm; uint32 _frameCounter; uint32 _priorFrameTime; + uint32 _priorTimerTime; Common::KeyCode _keyCode; Graphics::Surface _invCursor; - void nextFrame(bool skipTimers); + bool checkForNextFrameCounter(); + bool checkForNextTimerUpdate(); + void nextFrame(); + void nextTimer(); void keyControl(Common::KeyCode keycode, bool isKeyDown); public: CursorType _cursorId; @@ -117,7 +122,7 @@ public: bool isKeyPending() const; - void delay(int time); + void delay(int time = 5); void debounceLeft(); @@ -125,8 +130,6 @@ public: void waitKeyMouse(); - bool checkForNextFrameCounter(); - Common::Point &getMousePos() { return _mousePos; } Common::Point calcRawMouse(); diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 4038929a67..acba60433f 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -321,8 +321,7 @@ void InventoryManager::chooseItem() { while (!_vm->shouldQuit()) { // Check for events - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); int selIndex; // Poll events and wait for a click on a known area @@ -414,8 +413,7 @@ void InventoryManager::combineItems() { // Item drag handling loop if left button is held down while (!_vm->shouldQuit() && events._leftButton) { // Poll for events - events.pollEvents(); - g_system->delayMillis(10); + events.pollEventsAndWait(); // Check positioning if (lastMouse == events._mousePos) @@ -485,8 +483,7 @@ void InventoryManager::zoomIcon(int zoomItem, int backItem, int zoomBox, bool sh _invCoords[zoomBox].left + 46, _invCoords[zoomBox].top + 35); while (!_vm->shouldQuit() && zoomScale != 0 && zoomScale != 256) { - _vm->_events->pollEvents(); - g_system->delayMillis(5); + _vm->_events->pollEventsAndWait(); _vm->_buffer2.copyBlock(&_vm->_buffer1, boxRect); if (backItem != -1) { diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 57332f742d..e18bd4a329 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -81,9 +81,8 @@ void Room::doRoom() { // Poll for events _vm->_canSaveLoad = true; - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); _vm->_canSaveLoad = false; - g_system->delayMillis(5); _vm->_player->walk(); _vm->_midi->midiRepeat(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index f98552470c..318eb66516 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -158,7 +158,7 @@ void Screen::forceFadeOut() { } updatePalette(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } while (repeatFlag && !_vm->shouldQuit()); } @@ -180,7 +180,7 @@ void Screen::forceFadeIn() { } updatePalette(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } while (repeatFlag); } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 6c9f278736..d8f9a51e8f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -521,12 +521,11 @@ void Scripts::cmdSaveRect() { } void Scripts::cmdVideoEnded() { - _vm->_events->pollEvents(); + _vm->_events->pollEventsAndWait(); if (_vm->_video->_videoEnd) { cmdGoto(); } else { - g_system->delayMillis(10); _data->skip(2); } } @@ -731,8 +730,7 @@ void Scripts::cmdWait() { _vm->_midi->midiRepeat(); charLoop(); - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } _vm->_events->debounceLeft(); @@ -819,8 +817,7 @@ void Scripts::cmdPlayVideoSound() { _vm->_video->_soundFlag = true; } - _vm->_events->pollEvents(); - g_system->delayMillis(10); + _vm->_events->pollEventsAndWait(); } void Scripts::cmdPrintWatch() { -- cgit v1.2.3 From c2e5dd8487834b875333652d6b482bd61a50354d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:40:36 -0500 Subject: ACCESS: Fix positioning of Ant in pit scene --- engines/access/amazon/amazon_logic.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 320d87476a..517351f7c3 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -2108,17 +2108,17 @@ void Ant::doAnt() { else idx -= 6; - _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antPos -= Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; } } else { idx += 6; if (buf[(idx / 2)] != -1) { - _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antPos += Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; } else if (!_antDieFl) { idx = 0; - _antPos = Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); + _antPos += Common::Point(buf[(idx / 2) + 1], buf[(idx / 2) + 2]); _antCel = idx; } else { idx -= 6; -- cgit v1.2.3 From 41d0908606469ebbac5d8b3a6442e70a5e778b7f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 10 Dec 2014 21:48:53 -0500 Subject: ACCESS: Fix death cell list data --- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/amazon/amazon_resources.cpp | 3 ++- engines/access/amazon/amazon_resources.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 63291bde52..802cb3887d 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -156,8 +156,8 @@ void AmazonEngine::setupGame() { _deaths[i]._msg = DEATH_TEXT[i]; } } - _deaths._cells.resize(12); - for (int i = 0; i < 12; ++i) + _deaths._cells.resize(13); + for (int i = 0; i < 13; ++i) _deaths._cells[i] = CellIdent(DEATH_CELLS[i][0], DEATH_CELLS[i][1], DEATH_CELLS[i][2]); // Miscellaneous diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index cb84841002..694454cc3e 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1800,7 +1800,8 @@ const char *const DEATH_TEXT_DEMO[34] = { "WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY" }; -const int DEATH_CELLS[12][3] = { +const int DEATH_CELLS[13][3] = { + { 0, 94, 2 }, { 0, 94, 3 }, { 0, 94, 4 }, { 0, 94, 5 }, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 92e0cecf68..36ae2af092 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -89,7 +89,7 @@ extern const byte DEATH_SCREENS_DEMO[34]; extern const char *const DEATH_TEXT[58]; extern const char *const DEATH_TEXT_DEMO[34]; -extern const int DEATH_CELLS[12][3]; +extern const int DEATH_CELLS[13][3]; extern const int CHAPTER_CELLS[17][3]; -- cgit v1.2.3 From a6cc9250d329ab0d56c49dd24018ac1c84a723dc Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 11 Dec 2014 07:58:05 +0100 Subject: ACCESS: Remove a useless variable, some renaming --- engines/access/amazon/amazon_game.cpp | 13 +++++++------ engines/access/amazon/amazon_game.h | 1 - engines/access/amazon/amazon_logic.cpp | 12 ++++++------ engines/access/amazon/amazon_logic.h | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 802cb3887d..ff16bbfa94 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -55,7 +55,6 @@ AccessEngine(syst, gameDesc), _inactiveYOff = 0; _hintLevel = 0; - Common::fill(&_esTabTable[0], &_esTabTable[100], 0); memset(_tileData, 0, sizeof(_tileData)); Common::fill(&_help1[0], &_help1[366], 0); Common::fill(&_help2[0], &_help2[366], 0); @@ -415,11 +414,11 @@ void AmazonEngine::helpTitle() { Common::String iqText = "IQ: "; calcIQ(); - Common::String IQSCORE = Common::String::format("%d", _iqValue); - while (IQSCORE.size() != 4) - IQSCORE = " " + IQSCORE; + Common::String scoreIQ = Common::String::format("%d", _iqValue); + while (scoreIQ.size() < 4) + scoreIQ = " " + scoreIQ; - iqText += IQSCORE; + iqText += scoreIQ; int index = _iqValue; if (index == 170) index = 169; @@ -768,8 +767,10 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_rawInactiveY); s.syncAsSint16LE(_inactiveYOff); + int dummy = 0; for (int i = 0; i < 100; ++i) - s.syncAsSint16LE(_esTabTable[i]); + s.syncAsSint16LE(dummy); + for (int i = 0; i < 366; ++i) { s.syncAsByte(_help1[i]); s.syncAsByte(_help2[i]); diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 4ebea0f7eb..5d87cc434e 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -93,7 +93,6 @@ public: int _rawInactiveX; int _rawInactiveY; int _inactiveYOff; - int _esTabTable[100]; // Other game specific fields Ant *_ant; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 517351f7c3..2aed0bcafb 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1349,7 +1349,7 @@ void Cast::doCast(int param1) { /*------------------------------------------------------------------------*/ River::River(AmazonEngine *vm): PannedScene(vm) { - _CHICKENOUTFLG = false; + _chickenOutFl = false; _rScrollRow = 0; _rScrollCol = 0; _rScrollX = 0; @@ -1592,7 +1592,7 @@ void River::moveCanoe() { } } else if (events._leftButton && mousePos.x < 35 && mousePos.y < 12) { // Clicked on the Skip button. So chicken out - _CHICKENOUTFLG = true; + _chickenOutFl = true; } else if ((events._leftButton && pt.y <= _canoeYPos) || (!events._leftButton && _vm->_player->_move == UP)) { // Move canoe up @@ -1833,15 +1833,15 @@ void River::doRiver() { if (_vm->_screen->_scrollX == 0) { _vm->_midi->midiRepeat(); if (riverJumpTest()) { - _CHICKENOUTFLG = false; + _chickenOutFl = false; return; } } else { _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; } - if (_CHICKENOUTFLG) { - _CHICKENOUTFLG = false; + if (_chickenOutFl) { + _chickenOutFl = false; return; } @@ -1886,7 +1886,7 @@ void River::doRiver() { if (_vm->_room->_function == FN_CLEAR1) { _vm->_scripts->_endFlag = true; _vm->_scripts->_returnCode = 0; - _CHICKENOUTFLG = false; + _chickenOutFl = false; break; } } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index d66a8d818e..8fb6df9354 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -158,7 +158,7 @@ public: class River: public PannedScene { private: - bool _CHICKENOUTFLG; + bool _chickenOutFl; const byte *_mapPtr; int _canoeVXPos; int _canoeMoveCount; -- cgit v1.2.3 From c82fb8c9571073b95da0f45a6b8beb3000fbfbc0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 11 Dec 2014 08:11:28 +0100 Subject: ACCESS: Reduce screen pointer usage in amazon logic --- engines/access/amazon/amazon_logic.cpp | 235 ++++++++++++++++++--------------- 1 file changed, 126 insertions(+), 109 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 2aed0bcafb..c8bf054d3b 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -204,21 +204,23 @@ Opening::Opening(AmazonEngine *vm) : CampScene(vm) { } void Opening::doIntroduction() { - _vm->_screen->setInitialPalettte(); + Screen &screen = *_vm->_screen; + + screen.setInitialPalettte(); _vm->_events->setCursor(CURSOR_ARROW); _vm->_events->showCursor(); - _vm->_screen->setPanel(0); - _vm->_screen->setPalette(); + screen.setPanel(0); + screen.setPalette(); _vm->_events->setCursor(CURSOR_ARROW); _vm->_events->showCursor(); - _vm->_screen->setPanel(3); + screen.setPanel(3); doTitle(); if (_vm->shouldQuit() || _skipStart || _vm->isDemo()) return; - _vm->_screen->setPanel(3); + screen.setPanel(3); mWhileDoOpen(); if (_vm->shouldQuit() || _skipStart) @@ -306,9 +308,11 @@ void Opening::scrollTitle() { } void Opening::doTitle() { - _vm->_screen->setDisplayScan(); + Screen &screen = *_vm->_screen; - _vm->_screen->forceFadeOut(); + screen.setDisplayScan(); + + screen.forceFadeOut(); _vm->_events->hideCursor(); if (!_vm->isDemo()) { @@ -320,7 +324,7 @@ void Opening::doTitle() { _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); _vm->_sound->playSound(1); // WORKAROUND: This delay has been added to replace original game delay that @@ -352,7 +356,7 @@ void Opening::doTitle() { int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); - _vm->_screen->copyFrom(_vm->_buffer2); + screen.copyFrom(_vm->_buffer2); _vm->_sound->playSound(1); _vm->_events->_vbCount = 70; @@ -367,7 +371,7 @@ void Opening::doTitle() { _vm->_sound->stopSound(); _vm->_sound->playSound(0); - _vm->_screen->forceFadeOut(); + screen.forceFadeOut(); _vm->_events->_vbCount = 100; while (!_vm->shouldQuit() && _vm->_events->_vbCount > 0) _vm->_events->pollEventsAndWait(); @@ -382,7 +386,7 @@ void Opening::doTitle() { _vm->_files->loadScreen(0, 5); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); _vm->_midi->newMusic(1, 0); _vm->_events->_vbCount = 700; while (!_vm->shouldQuit() && (_vm->_events->_vbCount > 0) && !_vm->_events->isKeyMousePressed()) { @@ -401,16 +405,16 @@ void Opening::doTitle() { _vm->_events->zeroKeys(); } _vm->_room->loadRoom(0); - _vm->_screen->clearScreen(); - _vm->_screen->setBufferScan(); - _vm->_screen->_scrollRow = _vm->_screen->_scrollCol = 0; - _vm->_screen->_scrollX = _vm->_screen->_scrollY = 0; + screen.clearScreen(); + screen.setBufferScan(); + screen._scrollRow = screen._scrollCol = 0; + screen._scrollX = screen._scrollY = 0; _vm->_player->_rawPlayer = Common::Point(0, 0); - _vm->_screen->forceFadeOut(); - _vm->_screen->_scrollX = 0; + screen.forceFadeOut(); + screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); _vm->_oldRects.clear(); _vm->_newRects.clear(); _vm->_events->clearEvents(); @@ -427,15 +431,15 @@ void Opening::doTitle() { } _vm->_events->_vbCount = 4; - if (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth) { - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + if (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) { + screen._scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollTitle(); ++_pCount; @@ -453,23 +457,23 @@ void Opening::doTitle() { while (!_vm->shouldQuit()) { _pCount = 0; _vm->_events->_vbCount = 3; - if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) { + if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; } - _vm->_screen->_scrollY = _vm->_screen->_scrollY + _vm->_player->_scrollAmount; + screen._scrollY = screen._scrollY + _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { - _vm->_screen->_scrollY -= TILE_HEIGHT; - ++_vm->_screen->_scrollRow; + while (screen._scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + screen._scrollY -= TILE_HEIGHT; + ++screen._scrollRow; _vm->_buffer1.moveBufferUp(); - // WORKAROUND: the original was using _vm->_screen->_vWindowBytesWide * _vm->_screen->_vWindowLinesTall - _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall); + // WORKAROUND: the original was using screen._vWindowBytesWide * screen._vWindowLinesTall + _vm->_room->buildRow(screen._scrollRow + screen._vWindowHeight, screen._vWindowLinesTall); - if (_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight >= _vm->_room->_playFieldHeight) { + if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; @@ -793,17 +797,19 @@ void Jungle::initJWalk2() { { 0, 580, 0, 60 }, { 1, 650, 0, 30 } }; - _vm->_screen->fadeOut(); + + Screen &screen = *_vm->_screen; + screen.fadeOut(); _vm->_events->hideCursor(); - _vm->_screen->clearScreen(); + screen.clearScreen(); _vm->_buffer2.clearBuffer(); - _vm->_screen->setBufferScan(); + screen.setBufferScan(); - _vm->_screen->_scrollX = _vm->_screen->_scrollY; - _vm->_screen->_scrollCol = _vm->_screen->_scrollRow; + screen._scrollX = screen._scrollY; + screen._scrollCol = screen._scrollRow; _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->fadeIn(); + screen.fadeIn(); _vm->_events->clearEvents(); _xCount = 2; @@ -967,67 +973,71 @@ Guard::Guard(AmazonEngine *vm): PannedScene(vm) { } void Guard::setVerticalCode() { + Screen &screen = *_vm->_screen; + _gCode1 = 0; _gCode2 = 0; - if (_topLeft.x < _vm->_screen->_orgX1) + if (_topLeft.x < screen._orgX1) _gCode1 |= 8; - else if (_topLeft.x == _vm->_screen->_orgX1) { + else if (_topLeft.x == screen._orgX1) { _gCode1 |= 8; _gCode1 |= 2; } else _gCode1 |= 2; - if (_bottomRight.x < _vm->_screen->_orgX1) + if (_bottomRight.x < screen._orgX1) _gCode2 |= 8; - else if (_bottomRight.x == _vm->_screen->_orgX1) { + else if (_bottomRight.x == screen._orgX1) { _gCode2 |= 8; _gCode2 |= 2; } else _gCode2 |= 2; - if (_topLeft.y < _vm->_screen->_orgY1) + if (_topLeft.y < screen._orgY1) _gCode1 |= 4; - else if (_topLeft.y > _vm->_screen->_orgY2) + else if (_topLeft.y > screen._orgY2) _gCode1 |= 1; - if (_bottomRight.y < _vm->_screen->_orgY1) + if (_bottomRight.y < screen._orgY1) _gCode2 |= 4; - else if (_bottomRight.y > _vm->_screen->_orgY2) + else if (_bottomRight.y > screen._orgY2) _gCode2 |= 1; } void Guard::setHorizontalCode() { + Screen &screen = *_vm->_screen; + _gCode1 = 0; _gCode2 = 0; - if (_topLeft.y < _vm->_screen->_orgY1) + if (_topLeft.y < screen._orgY1) _gCode1 |= 4; - else if (_topLeft.x == _vm->_screen->_orgX1) { + else if (_topLeft.x == screen._orgX1) { _gCode1 |= 4; _gCode1 |= 1; } else _gCode1 |= 1; - if (_bottomRight.y < _vm->_screen->_orgY1) + if (_bottomRight.y < screen._orgY1) _gCode2 |= 4; - else if (_bottomRight.x == _vm->_screen->_orgX1) { + else if (_bottomRight.x == screen._orgX1) { _gCode2 |= 4; _gCode2 |= 1; } else _gCode2 |= 1; - if (_topLeft.x < _vm->_screen->_orgX1) + if (_topLeft.x < screen._orgX1) _gCode1 |= 8; - else if (_topLeft.x > _vm->_screen->_orgX2) + else if (_topLeft.x > screen._orgX2) _gCode1 |= 2; - if (_bottomRight.x < _vm->_screen->_orgX1) + if (_bottomRight.x < screen._orgX1) _gCode2 |= 8; - else if (_bottomRight.y > _vm->_screen->_orgX2) + else if (_bottomRight.y > screen._orgX2) _gCode2 |= 2; } @@ -1120,12 +1130,13 @@ void Guard::chkHLine() { } void Guard::guardSee() { - int tmpY = (_vm->_screen->_scrollRow << 4) + _vm->_screen->_scrollY; + Screen &screen = *_vm->_screen; + int tmpY = (screen._scrollRow << 4) + screen._scrollY; _vm->_flags[140] = 0; if (tmpY > _position.y) return; - tmpY += _vm->_screen->_vWindowLinesTall; + tmpY += screen._vWindowLinesTall; tmpY -= 11; if (tmpY < _position.y) @@ -1135,16 +1146,16 @@ void Guard::guardSee() { _vm->_flags[140] = 1; for (uint16 idx = 0; idx < _vm->_room->_plotter._walls.size(); idx++) { - _vm->_screen->_orgX1 = _vm->_room->_plotter._walls[idx].left; - _vm->_screen->_orgY1 = _vm->_room->_plotter._walls[idx].top; - _vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right; - _vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom; - if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) { + screen._orgX1 = _vm->_room->_plotter._walls[idx].left; + screen._orgY1 = _vm->_room->_plotter._walls[idx].top; + screen._orgX2 = _vm->_room->_plotter._walls[idx].right; + screen._orgY2 = _vm->_room->_plotter._walls[idx].bottom; + if (screen._orgX1 == screen._orgX2) { chkVLine(); if (_vm->_guardFind == 0) return; } - else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) { + else if (screen._orgY1 == screen._orgY2) { chkHLine(); if (_vm->_guardFind == 0) return; @@ -1246,15 +1257,17 @@ Cast::Cast(AmazonEngine *vm) : PannedScene(vm) { } void Cast::doCast(int param1) { - _vm->_screen->setDisplayScan(); + Screen &screen = *_vm->_screen; + + screen.setDisplayScan(); _vm->_events->hideCursor(); - _vm->_screen->forceFadeOut(); - _vm->_screen->_clipHeight = 173; - _vm->_screen->clearScreen(); + screen.forceFadeOut(); + screen._clipHeight = 173; + screen.clearScreen(); _vm->_chapter = 16; _vm->tileScreen(); _vm->updateSummary(param1); - _vm->_screen->setPanel(3); + screen.setPanel(3); _vm->_chapter = 14; Resource *spriteData = _vm->_files->loadFile(91, 0); @@ -1304,7 +1317,7 @@ void Cast::doCast(int param1) { _vm->_numAnimTimers = 0; _vm->_midi->newMusic(58, 0); - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); while (!_vm->shouldQuit()) { _vm->_images.clear(); @@ -1340,7 +1353,7 @@ void Cast::doCast(int param1) { _vm->_newRects.clear(); _vm->_numAnimTimers = 0; _vm->_images.clear(); - _vm->_screen->forceFadeOut(); + screen.forceFadeOut(); _vm->quitGame(); _vm->_events->pollEvents(); @@ -1389,40 +1402,41 @@ void River::setRiverPan() { void River::initRiver() { static const int RIVERVXTBL[3] = { 6719, 7039, 8319 }; + Screen &screen = *_vm->_screen; _vm->_events->centerMousePos(); _vm->_events->restrictMouse(); - _vm->_screen->setDisplayScan(); - _vm->_screen->clearScreen(); - _vm->_screen->savePalette(); - _vm->_screen->forceFadeOut(); + screen.setDisplayScan(); + screen.clearScreen(); + screen.savePalette(); + screen.forceFadeOut(); _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(95, 4); _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_screen->restorePalette(); - _vm->_screen->setBufferScan(); + screen.restorePalette(); + screen.setBufferScan(); _vm->_destIn = &_vm->_buffer2; _vm->_room->roomMenu(); if (_saveRiver) { // Restoring a savegame, so set properties from saved fields - _vm->_screen->_scrollRow = _rScrollRow; - _vm->_screen->_scrollCol = _rScrollCol; - _vm->_screen->_scrollX = _rScrollX; - _vm->_screen->_scrollY = _rScrollY; + screen._scrollRow = _rScrollRow; + screen._scrollCol = _rScrollCol; + screen._scrollX = _rScrollX; + screen._scrollY = _rScrollY; } else { // Set initial scene state - _vm->_screen->_scrollRow = 0; - _vm->_screen->_scrollCol = 140; - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollY = 0; + screen._scrollRow = 0; + screen._scrollCol = 140; + screen._scrollX = 0; + screen._scrollY = 0; } _vm->_room->buildScreen(); _vm->copyBF2Vid(); - _vm->_screen->forceFadeIn(); + screen.forceFadeIn(); if (!_saveRiver) { // Reset draw rects @@ -1499,21 +1513,23 @@ void River::checkRiverPan() { } bool River::riverJumpTest() { - if (_vm->_screen->_scrollCol == 120 || _vm->_screen->_scrollCol == 60 || _vm->_screen->_scrollCol == 0) { + Screen &screen = *_vm->_screen; + + if (screen._scrollCol == 120 || screen._scrollCol == 60 || screen._scrollCol == 0) { int val = *++_mapPtr; if (val == 0xFF) return true; - _oldScrollCol = _vm->_screen->_scrollCol; + _oldScrollCol = screen._scrollCol; if (val == 0) { - _vm->_screen->_scrollCol = 139; - _vm->_screen->_scrollX = 14; + screen._scrollCol = 139; + screen._scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } - } else if (_vm->_screen->_scrollCol == 105) { + } else if (screen._scrollCol == 105) { int val1 = _mapPtr[1]; int val2 = _mapPtr[2]; _mapPtr += 3; @@ -1529,19 +1545,19 @@ bool River::riverJumpTest() { _deathCount = 300; _deathType = val2; } - _oldScrollCol = _vm->_screen->_scrollCol; - _vm->_screen->_scrollCol = 44; - _vm->_screen->_scrollX = 14; + _oldScrollCol = screen._scrollCol; + screen._scrollCol = 44; + screen._scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } } - _vm->_screen->_scrollX = 14; - --_vm->_screen->_scrollCol; + screen._scrollX = 14; + --screen._scrollCol; _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); + _vm->_room->buildColumn(screen._scrollCol, 0); checkRiverPan(); return false; } @@ -1628,7 +1644,7 @@ void River::updateObstacles() { for (cur = _topList; cur < RIVER_OBJECTS[_riverIndex][RIVER_END]; ++cur) { int val = cur->_riverX + cur->_width - 1; if (val < _screenVertX) - // Obstacle is not yet on-scren + // Obstacle is not yet on-screen break; if (cur->_riverX < (_screenVertX + 319)) { @@ -1723,19 +1739,20 @@ void River::plotRiver() { } void River::mWhileDownRiver() { + Screen &screen = *_vm->_screen; _vm->_events->hideCursor(); - _vm->_screen->setDisplayScan(); - _vm->_screen->clearScreen(); - _vm->_screen->savePalette(); + screen.setDisplayScan(); + screen.clearScreen(); + screen.savePalette(); if (!_vm->isDemo()) _vm->_files->loadScreen(95, 4); _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_screen->restorePalette(); - _vm->_screen->setPalette(); - _vm->_screen->setBufferScan(); + screen.restorePalette(); + screen.setPalette(); + screen.setBufferScan(); - _vm->_screen->_scrollX = 0; + screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -1768,16 +1785,16 @@ void River::mWhileDownRiver() { ++_vm->_timers[4]._flag; while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth != _vm->_room->_playFieldWidth)) { + (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { _vm->_images.clear(); _vm->_events->_vbCount = 6; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; - while (_vm->_screen->_scrollX >= TILE_WIDTH) { - _vm->_screen->_scrollX -= TILE_WIDTH; - ++_vm->_screen->_scrollCol; + screen._scrollX += _vm->_player->_scrollAmount; + while (screen._scrollX >= TILE_WIDTH) { + screen._scrollX -= TILE_WIDTH; + ++screen._scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol + _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide); + _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } pan(); -- cgit v1.2.3 From 5520a763849a4dd7df6cd2eb727ac89294b5790f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Dec 2014 01:07:47 +0100 Subject: ACCESS: Fix speakText behavior --- engines/access/access.cpp | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index bb5414da31..97b08d73c4 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -216,27 +216,25 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { s->_printOrg = Common::Point(s->_printStart.x, s->_printOrg.y + 9); if ((s->_printOrg.y > _printEnd) && (!lastLine)) { - if (!_sound->_isVoice) { - _events->waitKeyMouse(); - } else { - while (!shouldQuit()) { - _sound->freeSounds(); - Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundTable.push_back(SoundEntry(sound, 1)); - _sound->playSound(0); - _scripts->cmdFreeSound(); - - _events->pollEvents(); - - if (_events->isKeyMousePressed()) { - _sndSubFile += soundsLeft; + _events->clearEvents(); + while (!shouldQuit()) { + _sound->freeSounds(); + Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); + _sound->_soundTable.push_back(SoundEntry(sound, 1)); + _sound->playSound(0); + _scripts->cmdFreeSound(); + + _events->pollEvents(); + + if (_events->isKeyMousePressed()) { + _sndSubFile += soundsLeft; + break; + } else { + ++_sndSubFile; + --soundsLeft; + if (soundsLeft == 0) break; - } else { - ++_sndSubFile; - --soundsLeft; - if (soundsLeft == 0) - break; - } + _events->clearEvents(); } } @@ -253,11 +251,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { if (soundsLeft == 0) return; - if (!_sound->_isVoice) { - _events->waitKeyMouse(); - return; - } - for (;;) { _sound->freeSounds(); Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); -- cgit v1.2.3 From b1f63a9985055a7a71ebfdfb14bfe1d59502ad16 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 11 Dec 2014 20:39:06 -0500 Subject: ACCESS: Fix for player movement and stab action in pit scene --- engines/access/amazon/amazon_game.cpp | 1 + engines/access/amazon/amazon_logic.cpp | 61 ++++++++++++++++++++++++---------- engines/access/amazon/amazon_logic.h | 4 ++- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index ff16bbfa94..af9de52cc2 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -778,6 +778,7 @@ void AmazonEngine::synchronize(Common::Serializer &s) { } _river->synchronize(s); + _ant->synchronize(s); } } // End of namespace Amazon diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c8bf054d3b..e8e27fc24e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1940,8 +1940,8 @@ void River::synchronize(Common::Serializer &s) { /*------------------------------------------------------------------------*/ Ant::Ant(AmazonEngine *vm) : AmazonManager(vm) { - _antDirection = RIGHT; - _pitDirection = RIGHT; + _antDirection = ANT_RIGHT; + _pitDirection = ANT_RIGHT; _antCel = 0; _torchCel = 0; _pitCel = 0; @@ -1975,7 +1975,7 @@ void Ant::plotPit(int indx, const int *&buf) { _vm->_images.addToList(ie); _vm->_player->_rawPlayer = _pitPos; - if (_vm->_inventory->_inv[76]._value == 1) { + if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) { // Player has torch idx = _torchCel; buf = Amazon::TORCH; @@ -1985,7 +1985,8 @@ void Ant::plotPit(int indx, const int *&buf) { idx = 0; _torchCel = idx; plotTorchSpear(idx, buf); - } else if (!_stabFl && (_vm->_inventory->_inv[78]._value == 1)) { + } + else if (!_stabFl && (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY)) { // Player has spear idx = 0; buf = Amazon::SPEAR; @@ -1995,8 +1996,8 @@ void Ant::plotPit(int indx, const int *&buf) { int Ant::antHandleRight(int indx, const int *&buf) { int retval = indx; - if (_pitDirection == RIGHT) { - _pitDirection = LEFT; + if (_pitDirection == ANT_RIGHT) { + _pitDirection = ANT_LEFT; _pitPos.y = 127; } retval = _pitCel; @@ -2016,8 +2017,8 @@ int Ant::antHandleRight(int indx, const int *&buf) { int Ant::antHandleLeft(int indx, const int *&buf) { int retval = indx; - if (_pitDirection == LEFT) { - _pitDirection = RIGHT; + if (_pitDirection == ANT_LEFT) { + _pitDirection = ANT_RIGHT; _pitPos.y = 127; } retval = _pitCel; @@ -2036,14 +2037,16 @@ int Ant::antHandleLeft(int indx, const int *&buf) { int Ant::antHandleStab(int indx, const int *&buf) { int retval = indx; - if (_vm->_inventory->_inv[78]._value != 1) { + if (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY) { if (_stabFl) { buf = Amazon::PITSTAB; retval = _stabCel; if (_vm->_timers[13]._flag == 0) { _vm->_timers[13]._flag = 1; retval += 6; - if (Amazon::PITSTAB[retval] == -1) { + _stabCel = retval; + + if (buf[retval] == -1) { _stabFl = false; _pitCel = 0; _pitPos.y = 127; @@ -2069,11 +2072,12 @@ int Ant::antHandleStab(int indx, const int *&buf) { } } } + return retval; } void Ant::doAnt() { - _antDirection = RIGHT; + _antDirection = ANT_RIGHT; if (_vm->_aniFlag != 1) { _vm->_aniFlag = 1; _antCel = 0; @@ -2110,15 +2114,15 @@ void Ant::doAnt() { buf = Amazon::ANTEAT; } else { buf = Amazon::ANTWALK; - if (_vm->_inventory->_inv[76]._value == 1) + if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) // Player has burning torch, which scares the Ant - _antDirection = LEFT; + _antDirection = ANT_LEFT; } int idx = _antCel; if (_vm->_timers[15]._flag == 0) { _vm->_timers[15]._flag = 1; - if (_antDirection == LEFT) { + if (_antDirection == ANT_LEFT) { if (_antPos.x > 10) { if (idx == 0) idx = 36; @@ -2156,7 +2160,7 @@ void Ant::doAnt() { if (_vm->_flags[196] != 1) { idx = _pitCel; - if (_stabFl == 1) { + if (_stabFl) { idx = antHandleStab(idx, buf); } else { buf = Amazon::PITWALK; @@ -2164,18 +2168,20 @@ void Ant::doAnt() { _vm->_timers[13]._flag = 1; _vm->_events->pollEvents(); if (_vm->_events->_leftButton) { + // Handle moving the player whilst the mouse button is held down Common::Point pt = _vm->_events->calcRawMouse(); if (pt.x < _pitPos.x) idx = antHandleLeft(idx, buf); else if (pt.x > _pitPos.x) idx = antHandleRight(idx, buf); } else { + // Handle movement based on keyboard keys buf = Amazon::PITWALK; - if (_vm->_player->_playerDirection == UP) + if (_vm->_player->_move == UP) idx = antHandleStab(idx, buf); - else if (_vm->_player->_playerDirection == LEFT) + else if (_vm->_player->_move == LEFT) idx = antHandleLeft(idx, buf); - else if (_vm->_player->_playerDirection == RIGHT) + else if (_vm->_player->_move == RIGHT) idx = antHandleRight(idx, buf); } } @@ -2192,6 +2198,25 @@ void Ant::doAnt() { } } +void Ant::synchronize(Common::Serializer &s) { + if (_vm->_player->_roomNumber == 61) { + s.syncAsByte(_antDirection); + s.syncAsByte(_pitDirection); + s.syncAsSint16LE(_antCel); + s.syncAsSint16LE(_torchCel); + s.syncAsSint16LE(_pitCel); + s.syncAsSint16LE(_stabCel); + s.syncAsSint16LE(_antPos.x); + s.syncAsSint16LE(_antPos.y); + s.syncAsSint16LE(_pitPos.x); + s.syncAsSint16LE(_pitPos.y); + s.syncAsByte(_antDieFl); + s.syncAsByte(_antEatFl); + s.syncAsByte(_stabFl); + } +} + + } // End of namespace Amazon } // End of namespace Access diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 8fb6df9354..9b429d8108 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -209,7 +209,7 @@ public: void synchronize(Common::Serializer &s); }; -enum AntDirection { RIGHT = 0, LEFT = 1 }; +enum AntDirection { ANT_RIGHT = 0, ANT_LEFT = 1 }; class Ant: public AmazonManager { private: @@ -234,6 +234,8 @@ public: Ant(AmazonEngine *vm); void doAnt(); + + void synchronize(Common::Serializer &s); }; class InactivePlayer : public ImageEntry { -- cgit v1.2.3 From 712a18d0500dd51dc113ebaf5ac420ceaa8e456c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Dec 2014 22:33:46 +0100 Subject: ACCESS: Fix compilation errors reported by Criezy --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_scripts.cpp | 4 ++-- engines/access/sound.cpp | 2 +- engines/access/sound.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 97b08d73c4..d0bd3e6eed 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -150,7 +150,7 @@ void AccessEngine::initialize() { _player = Player::init(this); _screen = new Screen(this); _sound = new SoundManager(this, _mixer); - _midi = new MusicManager(this, _mixer); + _midi = new MusicManager(this); _video = new VideoPlayer(this); _buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight()); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 52c142a415..ce9a3d5c5c 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -481,8 +481,8 @@ void AmazonScripts::cmdChapter() { } void AmazonScripts::cmdSetHelp() { - int arrayId = (_data->readUint16LE() && 0xFF) - 1; - int helpId = _data->readUint16LE() && 0xFF; + int arrayId = (_data->readUint16LE() & 0xFF) - 1; + int helpId = _data->readUint16LE() & 0xFF; byte *help = _game->_helpTbl[arrayId]; help[helpId] = 1; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 4e701618d9..e151458f21 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -162,7 +162,7 @@ void SoundManager::freeSounds() { /******************************************************************************************/ -MusicManager::MusicManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { +MusicManager::MusicManager(AccessEngine *vm) : _vm(vm) { _music = nullptr; _tempMusic = nullptr; _isLooping = false; diff --git a/engines/access/sound.h b/engines/access/sound.h index dc8bd90b85..ed8fe0b060 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -74,7 +74,6 @@ public: class MusicManager : public Audio::MidiPlayer { private: AccessEngine *_vm; - Audio::Mixer *_mixer; Resource *_tempMusic; @@ -85,7 +84,7 @@ public: Resource *_music; public: - MusicManager(AccessEngine *vm, Audio::Mixer *mixer); + MusicManager(AccessEngine *vm); ~MusicManager(); void midiPlay(); -- cgit v1.2.3 From de63e2afbc967016e5cdd1d5aff126a1fca7d4ed Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 12 Dec 2014 23:22:41 +0100 Subject: ACCESS: Properly indent some code in playSound --- engines/access/sound.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index e151458f21..57f95c9516 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -96,8 +96,8 @@ void SoundManager::playSound(Resource *res, int priority) { // header content: // "STEVE" - fixed header // byte - sample rate - // 01h mapped internally to 3Ch ?? - // 02h mapped internally to 78h seems to be 11025Hz + // 01h mapped internally to 3Ch + // 02h mapped internally to 78h // 03h mapped internally to B5h // 04h mapped internally to F1h // byte - unknown @@ -109,10 +109,22 @@ void SoundManager::playSound(Resource *res, int priority) { int sampleRate = 0; switch (internalSampleRate) { - case 1: sampleRate = 16666; break; // 3Ch -> C4h time constant - case 2: sampleRate = 8334; break; // 78h -> 88h time constant - case 3: sampleRate = 5525; break; // B5h -> 4Bh time constant - case 4: sampleRate = 4150; break; // F1h -> 0Fh time constant + case 1: // NEG(3Ch) -> C4h time constant + sampleRate = 16666; + break; + + case 2: // NEG(78h) -> 88h time constant + sampleRate = 8334; + break; + + case 3: // NEG(B5h) -> 4Bh time constant + sampleRate = 5525; + break; + + case 4: // NEG(F1h) -> 0Fh time constant + sampleRate = 4150; + break; + default: error("Unexpected internal Sample Rate %d", internalSampleRate); return; -- cgit v1.2.3 From 330cb5fb07c18ecd61e1cac20ce3e030dfe5687b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 12 Dec 2014 23:24:49 -0500 Subject: ACCESS: Remove old dummy unused fields from savegame --- engines/access/amazon/amazon_game.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index af9de52cc2..793a601d34 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -767,10 +767,6 @@ void AmazonEngine::synchronize(Common::Serializer &s) { s.syncAsSint16LE(_rawInactiveY); s.syncAsSint16LE(_inactiveYOff); - int dummy = 0; - for (int i = 0; i < 100; ++i) - s.syncAsSint16LE(dummy); - for (int i = 0; i < 366; ++i) { s.syncAsByte(_help1[i]); s.syncAsByte(_help2[i]); -- cgit v1.2.3 From 4e20a93931685c5a5e37a869c6ef57ed9f78aa83 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 13 Dec 2014 14:08:34 +0100 Subject: SCI: Fix comment for workaround. The previous explanation just wasn't true. --- engines/sci/engine/savegame.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 9decc4cef6..0b55425406 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -640,9 +640,11 @@ void SoundCommandParser::reconstructPlayList() { initSoundResource(*i); if ((*i)->status == kSoundPlaying) { - // Sync the sound object's selectors related to playing with the stored - // ones in the playlist, as they may have been invalidated when loading. - // Refer to bug #3104624. + // WORKAROUND: PQ3 (German?) scripts can set volume negative in the + // sound object directly without going through DoSound. + // Since we re-read this selector when re-playing the sound after loading, + // this will lead to unexpected behaviour. As a workaround we + // sync the sound object's selectors here. (See bug #5501) writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(loop), (*i)->loop); writeSelectorValue(_segMan, (*i)->soundObj, SELECTOR(priority), (*i)->priority); if (_soundVersion >= SCI_VERSION_1_EARLY) -- cgit v1.2.3 From 98889efae52bba628c83f0d9109962e65c6f5c0a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Dec 2014 21:25:46 -0500 Subject: ACCESS: Beginnings of dirty rect handling for screen --- engines/access/access.cpp | 5 +++++ engines/access/asurface.h | 7 ++++--- engines/access/screen.cpp | 22 ++++++++++++++++++++-- engines/access/screen.h | 5 +++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index d0bd3e6eed..b67aebfcc0 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -396,6 +396,11 @@ void AccessEngine::copyBF2Vid() { srcP += _buffer2.pitch; destP += _screen->pitch; } + + // Add dirty rect for affected area + Common::Rect r(_screen->_vWindowBytesWide, _screen->_vWindowLinesTall); + r.moveTo(_screen->_windowXAdd, _screen->_windowYAdd + _screen->_screenYOff); + _screen->addDirtyRect(r); } void AccessEngine::playVideo(int videoNum, const Common::Point &pt) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 273578c830..0ce08bbb5c 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -38,9 +38,10 @@ class SpriteFrame; class ASurface : public Graphics::Surface { private: Graphics::Surface _savedBlock; - Common::Rect _savedBounds; void flipHorizontal(ASurface &dest); +protected: + Common::Rect _savedBounds; public: static int _leftSkip, _rightSkip; static int _topSkip, _bottomSkip; @@ -92,6 +93,8 @@ public: virtual void copyBlock(ASurface *src, const Common::Rect &bounds); + virtual void restoreBlock(); + void copyTo(ASurface *dest, const Common::Point &destPos); void copyTo(ASurface *dest, const Common::Rect &bounds); @@ -100,8 +103,6 @@ public: void saveBlock(const Common::Rect &bounds); - void restoreBlock(); - void drawRect(); void moveBufferLeft(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 318eb66516..9ccad28931 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -68,6 +68,8 @@ void Screen::clearScreen() { clearBuffer(); if (_vesaMode) _vm->_clearSummaryFlag = true; + + addDirtyRect(Common::Rect(0, 0, this->w, this->h)); } void Screen::setDisplayScan() { @@ -87,9 +89,15 @@ void Screen::setPanel(int num) { } void Screen::updateScreen() { - g_system->copyRectToScreen((byte *)getPixels(), this->pitch, 0, 0, - this->w, this->h); + for (uint i = 0; i < _dirtyRects.size(); ++i) { + const Common::Rect &r = _dirtyRects[i]; + const byte *srcP = (const byte *)getBasePtr(r.left, r.top); + g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top, + r.width(), r.height()); + } + g_system->updateScreen(); + _dirtyRects.clear(); } void Screen::setInitialPalettte() { @@ -239,6 +247,12 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { destBounds.translate(_windowXAdd, _windowYAdd + _screenYOff); copyRectToSurface(*src, destBounds.left, destBounds.top, bounds); + addDirtyRect(destBounds); +} + +void Screen::restoreBlock() { + ASurface::restoreBlock(); + addDirtyRect(_savedBounds); } void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { @@ -276,4 +290,8 @@ void Screen::cyclePaletteBackwards() { } } +void Screen::addDirtyRect(const Common::Rect &r) { + _dirtyRects.push_back(r); +} + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 8875ce12b7..93da5aa8b3 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -63,6 +63,7 @@ private: int _startCycle; int _cycleStart; int _endCycle; + Common::Array _dirtyRects; void updatePalette(); public: @@ -83,6 +84,8 @@ public: bool _screenChangeFlag; public: virtual void copyBlock(ASurface *src, const Common::Rect &bounds); + + virtual void restoreBlock(); public: Screen(AccessEngine *vm); @@ -157,6 +160,8 @@ public: void cyclePaletteForward(); void cyclePaletteBackwards(); + + void addDirtyRect(const Common::Rect &r); }; } // End of namespace Access -- cgit v1.2.3 From 9314daa11cb2eb8d4c4ecbe1c00fc044ba271f3d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Dec 2014 22:06:58 -0500 Subject: ACCESS: Dirty rect handling for bubble boxes --- engines/access/asurface.h | 4 ++-- engines/access/inventory.cpp | 2 +- engines/access/screen.cpp | 8 +++++++- engines/access/screen.h | 2 ++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 0ce08bbb5c..ffa22d58e5 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -95,6 +95,8 @@ public: virtual void restoreBlock(); + virtual void drawRect(); + void copyTo(ASurface *dest, const Common::Point &destPos); void copyTo(ASurface *dest, const Common::Rect &bounds); @@ -103,8 +105,6 @@ public: void saveBlock(const Common::Rect &bounds); - void drawRect(); - void moveBufferLeft(); void moveBufferRight(); diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index acba60433f..20c9976a3b 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -171,7 +171,7 @@ int InventoryManager::newDisplayInv() { // The original was testing the vesa mode too. // We removed this check as we don't use pre-rendering if (!_invRefreshFlag) { - screen.clearBuffer(); + screen.clearScreen(); screen.setPalette(); } diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 9ccad28931..98dbdb4e9c 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -251,8 +251,13 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { } void Screen::restoreBlock() { - ASurface::restoreBlock(); addDirtyRect(_savedBounds); + ASurface::restoreBlock(); +} + +void Screen::drawRect() { + addDirtyRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2)); + ASurface::drawRect(); } void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { @@ -292,6 +297,7 @@ void Screen::cyclePaletteBackwards() { void Screen::addDirtyRect(const Common::Rect &r) { _dirtyRects.push_back(r); + assert(r.isValidRect() && r.width() > 0 && r.height() > 0); } } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 93da5aa8b3..c43a03c9dc 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -86,6 +86,8 @@ public: virtual void copyBlock(ASurface *src, const Common::Rect &bounds); virtual void restoreBlock(); + + virtual void drawRect(); public: Screen(AccessEngine *vm); -- cgit v1.2.3 From 310853a285d5d648f1695cc3a40a165223b2928a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 13 Dec 2014 22:33:23 -0500 Subject: ACCESS: Add dirty rects when plotting images to the screen --- engines/access/amazon/amazon_logic.cpp | 2 +- engines/access/amazon/amazon_scripts.cpp | 6 ++--- engines/access/asurface.cpp | 43 ++++++++++++++++++-------------- engines/access/asurface.h | 12 +++++---- engines/access/screen.cpp | 15 +++++++++++ engines/access/screen.h | 6 +++++ 6 files changed, 56 insertions(+), 28 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index e8e27fc24e..42f9a243ce 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -356,7 +356,7 @@ void Opening::doTitle() { int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); - screen.copyFrom(_vm->_buffer2); + _vm->_buffer2.copyTo(_vm->_screen); _vm->_sound->playSound(1); _vm->_events->_vbCount = 70; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index ce9a3d5c5c..6f9d9c9697 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -71,8 +71,8 @@ void AmazonScripts::mWhile1() { _sequence = 2100; } while (_vm->_flags[52] == 1); - _vm->_screen->copyFrom(_vm->_buffer1); - _vm->_buffer1.copyFrom(_vm->_buffer2); + _vm->_buffer1.copyTo(_vm->_screen); + _vm->_buffer2.copyTo(&_vm->_buffer1); _game->establish(-1, 14); @@ -446,7 +446,7 @@ void AmazonScripts::cmdHelp() { _vm->_screen->clearBuffer(); } - _vm->_screen->copyFrom(_vm->_buffer2); + _vm->_buffer2.copyTo(_vm->_screen); _vm->_screen->restorePalette(); _vm->_screen->setPalette(); _vm->_events->showCursor(); diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index cd872e04b2..9725a5f646 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -203,13 +203,13 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } } -void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { - if (dest->getPixels() == nullptr) - dest->create(w, h); +void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) { + if (getPixels() == nullptr) + create(w, h); - for (int yp = 0; yp < h; ++yp) { - byte *srcP = (byte *)getBasePtr(0, yp); - byte *destP = (byte *)dest->getBasePtr(destPos.x, destPos.y + yp); + for (int yp = 0; yp < src->h; ++yp) { + const byte *srcP = (const byte *)src->getBasePtr(0, yp); + byte *destP = (byte *)getBasePtr(destPos.x, destPos.y + yp); for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) { if (*srcP != 0) @@ -218,13 +218,13 @@ void ASurface::copyTo(ASurface *dest, const Common::Point &destPos) { } } -void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { +void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) { const int SCALE_LIMIT = 0x100; - int scaleX = SCALE_LIMIT * bounds.width() / this->w; - int scaleY = SCALE_LIMIT * bounds.height() / this->h; + int scaleX = SCALE_LIMIT * bounds.width() / src->w; + int scaleY = SCALE_LIMIT * bounds.height() / src->h; int scaleXCtr = 0, scaleYCtr = 0; - for (int yCtr = 0, destY = bounds.top; yCtr < this->h; ++yCtr) { + for (int yCtr = 0, destY = bounds.top; yCtr < src->h; ++yCtr) { // Handle skipping lines if Y scaling scaleYCtr += scaleY; if (scaleYCtr < SCALE_LIMIT) @@ -232,17 +232,17 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleYCtr -= SCALE_LIMIT; // Handle off-screen lines - if (destY >= dest->h) + if (destY >= this->h) break; if (destY >= 0) { // Handle drawing the line - byte *pSrc = (byte *)getBasePtr(0, yCtr); - byte *pDest = (byte *)dest->getBasePtr(bounds.left, destY); + const byte *pSrc = (const byte *)src->getBasePtr(0, yCtr); + byte *pDest = (byte *)getBasePtr(bounds.left, destY); scaleXCtr = 0; int x = bounds.left; - for (int xCtr = 0; xCtr < this->w; ++xCtr, ++pSrc) { + for (int xCtr = 0; xCtr < src->w; ++xCtr, ++pSrc) { // Handle horizontal scaling scaleXCtr += scaleX; if (scaleXCtr < SCALE_LIMIT) @@ -250,7 +250,7 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { scaleXCtr -= SCALE_LIMIT; // Only handle on-screen pixels - if (x >= dest->w) + if (x >= this->w) break; if (x >= 0 && *pSrc != 0) *pDest = *pSrc; @@ -264,8 +264,12 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) { } } -void ASurface::copyTo(ASurface *dest) { - copyTo(dest, Common::Point()); +void ASurface::copyFrom(ASurface &src) { + copyFrom(&src, Common::Point()); +} + +void ASurface::copyBuffer(Graphics::Surface *src) { + Graphics::Surface::copyFrom(*src); } void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { @@ -277,13 +281,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { - frame->copyTo(this, bounds); + copyFrom(frame, bounds); } void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - flippedFrame.copyTo(this, bounds); + + copyFrom(&flippedFrame, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index ffa22d58e5..36fd2518c3 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -65,8 +65,6 @@ public: void clearBuffer(); - void copyBuffer(Graphics::Surface *src) { copyFrom(*src); } - bool clip(Common::Rect &r); void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt); @@ -97,11 +95,15 @@ public: virtual void drawRect(); - void copyTo(ASurface *dest, const Common::Point &destPos); + virtual void copyFrom(ASurface *src, const Common::Point &destPos); + + virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + + virtual void copyFrom(ASurface &src); - void copyTo(ASurface *dest, const Common::Rect &bounds); + void copyTo(ASurface *dest) { dest->copyFrom(*this); } - void copyTo(ASurface *dest); + virtual void copyBuffer(Graphics::Surface *src); void saveBlock(const Common::Rect &bounds); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 98dbdb4e9c..14ead2e266 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -260,6 +260,21 @@ void Screen::drawRect() { ASurface::drawRect(); } +void Screen::copyFrom(ASurface *src, const Common::Point &destPos) { + addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h)); + ASurface::copyFrom(src, destPos); +} + +void Screen::copyFrom(ASurface *src, const Common::Rect &bounds) { + addDirtyRect(bounds); + ASurface::copyFrom(src, bounds); +} + +void Screen::copyBuffer(Graphics::Surface *src) { + addDirtyRect(Common::Rect(0, 0, src->w, src->h)); + ASurface::copyBuffer(src); +} + void Screen::setPaletteCycle(int startCycle, int endCycle, int timer) { _startCycle = _cycleStart = startCycle; _endCycle = endCycle; diff --git a/engines/access/screen.h b/engines/access/screen.h index c43a03c9dc..1d93efbfee 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -88,6 +88,12 @@ public: virtual void restoreBlock(); virtual void drawRect(); + + virtual void copyFrom(ASurface *src, const Common::Point &destPos); + + virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + + virtual void copyBuffer(Graphics::Surface *src); public: Screen(AccessEngine *vm); -- cgit v1.2.3 From 2cdd05306c4c4c405a7405f1d0e5d491ec886c1d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 10:17:47 -0500 Subject: ACCESS: Dirty rect handling for conversation videos --- engines/access/screen.cpp | 3 ++- engines/access/video.cpp | 10 +++++++++- engines/access/video.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 14ead2e266..2276fcc963 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -251,7 +251,8 @@ void Screen::copyBlock(ASurface *src, const Common::Rect &bounds) { } void Screen::restoreBlock() { - addDirtyRect(_savedBounds); + if (!_savedBounds.isEmpty()) + addDirtyRect(_savedBounds); ASurface::restoreBlock(); } diff --git a/engines/access/video.cpp b/engines/access/video.cpp index abe833ce42..eb50083de5 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -60,6 +60,7 @@ void VideoPlayer::setVideo(ASurface *vidSurface, const Common::Point &pt, const _xCount = _header._width; _scanCount = _header._height; _videoFrame = 0; + _videoBounds = Common::Rect(pt.x, pt.y, pt.x + _header._width, pt.y + _header._height); getFrame(); @@ -133,6 +134,10 @@ void VideoPlayer::playVideo() { } } + // If the video is playing on the screen surface, add a dirty rect + if (_vidSurface == _vm->_screen) + _vm->_screen->addDirtyRect(_videoBounds); + getFrame(); if (++_videoFrame == _frameCount) { closeVideo(); @@ -142,14 +147,16 @@ void VideoPlayer::playVideo() { void VideoPlayer::copyVideo() { _vm->_player->calcPlayer(); + + // Figure out the dirty rect area for the video frame Common::Rect r = Common::Rect(_vm->_vidX - _vm->_screen->_bufferStart.x, _vm->_vidY - _vm->_screen->_bufferStart.y, _vm->_vidX - _vm->_screen->_bufferStart.x + _header._width, _vm->_vidY - _vm->_screen->_bufferStart.y + _header._height); if (!_vm->_screen->clip(r)) return; - _vm->_newRects.push_back(r); + int vh = _header._height; int vw = _header._width; int destIdx = _vm->_vidX - _vm->_screen->_bufferStart.x; @@ -165,4 +172,5 @@ void VideoPlayer::copyVideo() { destP += _vm->_buffer2.pitch; } } + } // End of namespace Access diff --git a/engines/access/video.h b/engines/access/video.h index f4be76de31..65d6ad61a7 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -48,6 +48,7 @@ private: int _xCount; int _scanCount; int _frameSize; + Common::Rect _videoBounds; void getFrame(); public: -- cgit v1.2.3 From 93979484f6932759ea5075d68ac75fa479848080 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 11:56:42 -0500 Subject: ACCESS: Fix for background redraws during conversations --- engines/access/asurface.cpp | 14 +++++++------- engines/access/asurface.h | 10 +++++----- engines/access/screen.cpp | 8 ++++---- engines/access/screen.h | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 9725a5f646..ef8e079c42 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -203,7 +203,7 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } } -void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) { +void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) { if (getPixels() == nullptr) create(w, h); @@ -218,7 +218,7 @@ void ASurface::copyFrom(ASurface *src, const Common::Point &destPos) { } } -void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) { +void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) { const int SCALE_LIMIT = 0x100; int scaleX = SCALE_LIMIT * bounds.width() / src->w; int scaleY = SCALE_LIMIT * bounds.height() / src->h; @@ -264,12 +264,12 @@ void ASurface::copyFrom(ASurface *src, const Common::Rect &bounds) { } } -void ASurface::copyFrom(ASurface &src) { - copyFrom(&src, Common::Point()); +void ASurface::transCopyFrom(ASurface &src) { + copyFrom(src); } void ASurface::copyBuffer(Graphics::Surface *src) { - Graphics::Surface::copyFrom(*src); + copyFrom(*src); } void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { @@ -281,14 +281,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { - copyFrom(frame, bounds); + transCopyFrom(frame, bounds); } void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - copyFrom(&flippedFrame, bounds); + transCopyFrom(&flippedFrame, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 36fd2518c3..c04b33c36e 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -95,16 +95,16 @@ public: virtual void drawRect(); - virtual void copyFrom(ASurface *src, const Common::Point &destPos); + virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); - virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); - virtual void copyFrom(ASurface &src); - - void copyTo(ASurface *dest) { dest->copyFrom(*this); } + virtual void transCopyFrom(ASurface &src); virtual void copyBuffer(Graphics::Surface *src); + void copyTo(ASurface *dest) { dest->copyFrom(*this); } + void saveBlock(const Common::Rect &bounds); void moveBufferLeft(); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 2276fcc963..5897fbec2e 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -261,14 +261,14 @@ void Screen::drawRect() { ASurface::drawRect(); } -void Screen::copyFrom(ASurface *src, const Common::Point &destPos) { +void Screen::transCopyFrom(ASurface *src, const Common::Point &destPos) { addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h)); - ASurface::copyFrom(src, destPos); + ASurface::transCopyFrom(src, destPos); } -void Screen::copyFrom(ASurface *src, const Common::Rect &bounds) { +void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) { addDirtyRect(bounds); - ASurface::copyFrom(src, bounds); + ASurface::transCopyFrom(src, bounds); } void Screen::copyBuffer(Graphics::Surface *src) { diff --git a/engines/access/screen.h b/engines/access/screen.h index 1d93efbfee..f790dd7986 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -89,9 +89,9 @@ public: virtual void drawRect(); - virtual void copyFrom(ASurface *src, const Common::Point &destPos); + virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); - virtual void copyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); virtual void copyBuffer(Graphics::Surface *src); public: -- cgit v1.2.3 From 924f2abdf40a97966fff991d7cb0db842212a567 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 14:45:06 -0500 Subject: ACCESS: Dirty rect handling for intro screens --- engines/access/asurface.cpp | 4 ++++ engines/access/asurface.h | 2 ++ engines/access/files.cpp | 3 +++ engines/access/screen.cpp | 5 +++++ engines/access/screen.h | 2 ++ 5 files changed, 16 insertions(+) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index ef8e079c42..e135ae7184 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -268,6 +268,10 @@ void ASurface::transCopyFrom(ASurface &src) { copyFrom(src); } +void ASurface::copyFrom(Graphics::Surface &src) { + Graphics::Surface::copyFrom(src); +} + void ASurface::copyBuffer(Graphics::Surface *src) { copyFrom(*src); } diff --git a/engines/access/asurface.h b/engines/access/asurface.h index c04b33c36e..db17eb2089 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -101,6 +101,8 @@ public: virtual void transCopyFrom(ASurface &src); + virtual void copyFrom(Graphics::Surface &src); + virtual void copyBuffer(Graphics::Surface *src); void copyTo(ASurface *dest) { dest->copyFrom(*this); } diff --git a/engines/access/files.cpp b/engines/access/files.cpp index b846cbd32c..004886a379 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -168,6 +168,9 @@ void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) { res->_stream->read(pDest, dest->w); } } + + if (dest == _vm->_screen) + _vm->_screen->addDirtyRect(Common::Rect(0, 0, dest->w, dest->h)); } void FileManager::loadScreen(int fileNum, int subfile) { diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 5897fbec2e..34755ade47 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -271,6 +271,11 @@ void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) { ASurface::transCopyFrom(src, bounds); } +void Screen::copyFrom(Graphics::Surface &src) { + addDirtyRect(Common::Rect(0, 0, src.w, src.h)); + ASurface::copyFrom(src); +} + void Screen::copyBuffer(Graphics::Surface *src) { addDirtyRect(Common::Rect(0, 0, src->w, src->h)); ASurface::copyBuffer(src); diff --git a/engines/access/screen.h b/engines/access/screen.h index f790dd7986..56ee9bed20 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -93,6 +93,8 @@ public: virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); + virtual void copyFrom(Graphics::Surface &src); + virtual void copyBuffer(Graphics::Surface *src); public: Screen(AccessEngine *vm); -- cgit v1.2.3 From fda4ef620f3eefc76d7362945d514e6c46187073 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 15:22:09 -0500 Subject: ACCESS: Add dirty rect handling for font display --- engines/access/asurface.h | 2 ++ engines/access/font.cpp | 2 ++ engines/access/screen.h | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/access/asurface.h b/engines/access/asurface.h index db17eb2089..139565190b 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -105,6 +105,8 @@ public: virtual void copyBuffer(Graphics::Surface *src); + virtual void addDirtyRect(const Common::Rect &r) {} + void copyTo(ASurface *dest) { dest->copyFrom(*this); } void saveBlock(const Common::Rect &bounds); diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 51fb9dc1c8..1aadfb6be2 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -150,6 +150,8 @@ void Font::drawString(ASurface *s, const Common::String &msg, const Common::Poin int Font::drawChar(ASurface *s, char c, Common::Point &pt) { Graphics::Surface &ch = _chars[c - ' ']; + s->addDirtyRect(Common::Rect(pt.x, pt.y, pt.x + ch.w, pt.y + ch.h)); + // Loop through the lines of the character for (int y = 0; y < ch.h; ++y) { byte *pSrc = (byte *)ch.getBasePtr(0, y); diff --git a/engines/access/screen.h b/engines/access/screen.h index 56ee9bed20..7134afffeb 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -96,6 +96,8 @@ public: virtual void copyFrom(Graphics::Surface &src); virtual void copyBuffer(Graphics::Surface *src); + + virtual void addDirtyRect(const Common::Rect &r); public: Screen(AccessEngine *vm); @@ -170,8 +172,6 @@ public: void cyclePaletteForward(); void cyclePaletteBackwards(); - - void addDirtyRect(const Common::Rect &r); }; } // End of namespace Access -- cgit v1.2.3 From 831a3f7f3591182ab0e7b8812e98c12282923909 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 15:39:37 -0500 Subject: ACCESS: Implement dirty rect merging --- engines/access/screen.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++-- engines/access/screen.h | 6 +++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 34755ade47..3e6bd7e38f 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -89,13 +89,19 @@ void Screen::setPanel(int num) { } void Screen::updateScreen() { - for (uint i = 0; i < _dirtyRects.size(); ++i) { - const Common::Rect &r = _dirtyRects[i]; + // Merge the dirty rects + mergeDirtyRects(); + + // Loop through copying dirty areas to the physical screen + Common::List::iterator i; + for (i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) { + const Common::Rect &r = *i; const byte *srcP = (const byte *)getBasePtr(r.left, r.top); g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top, r.width(), r.height()); } + // Signal the physical screen to update g_system->updateScreen(); _dirtyRects.clear(); } @@ -321,4 +327,43 @@ void Screen::addDirtyRect(const Common::Rect &r) { assert(r.isValidRect() && r.width() > 0 && r.height() > 0); } +void Screen::mergeDirtyRects() { + Common::List::iterator rOuter, rInner; + + // Ensure dirty rect list has at least two entries + rOuter = _dirtyRects.begin(); + for (int i = 0; i < 2; ++i, ++rOuter) { + if (rOuter == _dirtyRects.end()) + return; + } + + // Process the dirty rect list to find any rects to merge + for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) { + rInner = rOuter; + while (++rInner != _dirtyRects.end()) { + + if ((*rOuter).intersects(*rInner)) { + // these two rectangles overlap or + // are next to each other - merge them + + unionRectangle(*rOuter, *rOuter, *rInner); + + // remove the inner rect from the list + _dirtyRects.erase(rInner); + + // move back to beginning of list + rInner = rOuter; + } + } + } +} + +bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2) { + destRect = src1; + destRect.extend(src2); + + return !destRect.isEmpty(); +} + + } // End of namespace Access diff --git a/engines/access/screen.h b/engines/access/screen.h index 7134afffeb..775cb6b0c3 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -63,9 +63,13 @@ private: int _startCycle; int _cycleStart; int _endCycle; - Common::Array _dirtyRects; + Common::List _dirtyRects; void updatePalette(); + + void mergeDirtyRects(); + + bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2); public: int _vesaMode; int _startColor, _numColors; -- cgit v1.2.3 From 27ed5246b8780dc74235478058177abcc1d8e84d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 22:43:01 +0100 Subject: ACCESS: Use the same (weird) key mapping than in the original game --- engines/access/room.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index e18bd4a329..b9d13c94cd 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -467,9 +467,10 @@ void Room::doCommands() { mainAreaClick(); } } else if (_vm->_events->getKey(keyState)) { - if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F9) { + if (keyState.keycode == Common::KEYCODE_F1) handleCommand(keyState.keycode - Common::KEYCODE_F1 + 1); - } + else if (keyState.keycode >= Common::KEYCODE_F2 && keyState.keycode <= Common::KEYCODE_F10) + handleCommand(keyState.keycode - Common::KEYCODE_F1); } } -- cgit v1.2.3 From dcc6ceb117549a68a275b5740edea5e5e02030bd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 23:22:54 +0100 Subject: ACCESS: Fix icon when unselecting a menu button --- engines/access/room.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index b9d13c94cd..a33f773bac 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -588,6 +588,7 @@ void Room::walkCursor() { void Room::commandOff() { _selectCommand = -1; + _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; _vm->_events->setCursor(CURSOR_CROSSHAIRS); roomMenu(); } -- cgit v1.2.3 From 66bf0ec7412949eee758c138be1f81571b1fc56d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 23:51:01 +0100 Subject: ACCESS: Some refactoring concerning the mouse cursor --- engines/access/amazon/amazon_game.cpp | 2 +- engines/access/amazon/amazon_room.cpp | 5 ++--- engines/access/events.cpp | 9 +++++++++ engines/access/events.h | 10 ++++++++++ engines/access/inventory.cpp | 9 +++------ engines/access/martian/martian_room.cpp | 2 +- engines/access/room.cpp | 30 +++++++++++------------------- 7 files changed, 37 insertions(+), 30 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 793a601d34..9a86642579 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -193,7 +193,7 @@ void AmazonEngine::initVariables() { _player->_playerX = _player->_rawPlayer.x = TRAVEL_POS[_player->_roomNumber][0]; _player->_playerY = _player->_rawPlayer.y = TRAVEL_POS[_player->_roomNumber][1]; _room->_selectCommand = -1; - _events->_normalMouse = CURSOR_CROSSHAIRS; + _events->setNormalCursor(CURSOR_CROSSHAIRS); _mouseMode = 0; _numAnimTimers = 0; } diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index d6ab2bd758..10b622c738 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -87,7 +87,7 @@ void AmazonRoom::reloadRoom1() { } _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + _vm->_events->setNormalCursor(CURSOR_CROSSHAIRS); _vm->_mouseMode = 0; _vm->_boxSelect = true; _vm->_player->_playerOff = false; @@ -210,8 +210,7 @@ void AmazonRoom::walkCursor() { if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && events._normalMouse != CURSOR_CROSSHAIRS)) { - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); + events.forceSetCursor(CURSOR_CROSSHAIRS); _selectCommand = -1; _vm->_boxSelect = true; } else { diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 249ba15010..cd1880b338 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -54,6 +54,15 @@ EventsManager::~EventsManager() { _invCursor.free(); } +void EventsManager::forceSetCursor(CursorType cursorId) { + setNormalCursor(cursorId); + setCursor(cursorId); +} + +void EventsManager::setNormalCursor(CursorType cursorId) { + _normalMouse = cursorId; +} + void EventsManager::setCursor(CursorType cursorId) { if (cursorId == _cursorId) return; diff --git a/engines/access/events.h b/engines/access/events.h index c43bf472f0..fd3adf8797 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -82,6 +82,16 @@ public: */ uint32 getFrameCounter() { return _frameCounter; } + /** + * Sets the cursor and reset the normal cursor + */ + void EventsManager::forceSetCursor(CursorType cursorId); + + /** + * Sets the normal cursor + */ + void EventsManager::setNormalCursor(CursorType cursorId); + /** * Sets the cursor */ diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 20c9976a3b..49fa6e7efc 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -198,12 +198,9 @@ int InventoryManager::newDisplayInv() { if (!_invRefreshFlag) { if (_vm->_useItem == -1) { result = 2; - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); - } else { - events.setCursor(CURSOR_INVENTORY); - events._normalMouse = CURSOR_INVENTORY; - } + events.forceSetCursor(CURSOR_CROSSHAIRS); + } else + events.forceSetCursor(CURSOR_INVENTORY); } _invRefreshFlag = false; diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 2bd98186f0..22f456fd4c 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -82,7 +82,7 @@ void MartianRoom::reloadRoom1() { } _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; + _vm->_events->setNormalCursor(CURSOR_CROSSHAIRS); _vm->_mouseMode = 0; _vm->_boxSelect = true; _vm->_player->_playerOff = false; diff --git a/engines/access/room.cpp b/engines/access/room.cpp index a33f773bac..f4826090b1 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -136,11 +136,11 @@ void Room::doRoom() { } else { _vm->plotList(); - if (_vm->_events->_mousePos.y < 177) { + if (_vm->_events->_mousePos.y < 177) _vm->_events->setCursor(_vm->_events->_normalMouse); - } else { + else _vm->_events->setCursor(CURSOR_ARROW); - } + _vm->copyBlocks(); } } @@ -512,16 +512,13 @@ void Room::executeCommand(int commandId) { switch (commandId) { case 0: - events._normalMouse = CURSOR_LOOK; - events.setCursor(CURSOR_LOOK); + events.forceSetCursor(CURSOR_LOOK); break; case 2: - events._normalMouse = CURSOR_USE; - events.setCursor(CURSOR_USE); + events.forceSetCursor(CURSOR_USE); break; case 3: - events._normalMouse = CURSOR_TAKE; - events.setCursor(CURSOR_TAKE); + events.forceSetCursor(CURSOR_TAKE); break; case 4: events.setCursor(CURSOR_ARROW); @@ -531,19 +528,16 @@ void Room::executeCommand(int commandId) { } break; case 5: - events._normalMouse = CURSOR_CLIMB; - events.setCursor(CURSOR_CLIMB); + events.forceSetCursor(CURSOR_CLIMB); break; case 6: - events._normalMouse = CURSOR_TALK; - events.setCursor(CURSOR_TALK); + events.forceSetCursor(CURSOR_TALK); break; case 7: walkCursor(); return; case 8: - events._normalMouse = CURSOR_HELP; - events.setCursor(CURSOR_HELP); + events.forceSetCursor(CURSOR_HELP); break; default: break; @@ -570,8 +564,7 @@ void Room::executeCommand(int commandId) { void Room::walkCursor() { EventsManager &events = *_vm->_events; - events._normalMouse = CURSOR_CROSSHAIRS; - events.setCursor(CURSOR_CROSSHAIRS); + events.forceSetCursor(CURSOR_CROSSHAIRS); _vm->_scripts->_sequence = 5000; _vm->_scripts->searchForSequence(); roomMenu(); @@ -588,8 +581,7 @@ void Room::walkCursor() { void Room::commandOff() { _selectCommand = -1; - _vm->_events->_normalMouse = CURSOR_CROSSHAIRS; - _vm->_events->setCursor(CURSOR_CROSSHAIRS); + _vm->_events->forceSetCursor(CURSOR_CROSSHAIRS); roomMenu(); } -- cgit v1.2.3 From 450deabd4536eb71671286e52e4b01a03a4e581a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 14 Dec 2014 23:55:22 +0100 Subject: ACCESS: Fix a couple of typos in comments --- engines/access/amazon/amazon_room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 10b622c738..d026f7b6a5 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -204,8 +204,8 @@ void AmazonRoom::mainAreaClick() { void AmazonRoom::walkCursor() { // WORKAROUND: For scene 29, which is a normal walkable scene, but yet can be - // 'exitted'. This workaround ensures the scene will only be left if you click - // the Exit icon wgeb the cursor is already a walk cursor + // 'exited'. This workaround ensures the scene will only be left if you click + // the Exit icon when the cursor is already a walk cursor EventsManager &events = *_vm->_events; if (_vm->_events->_middleButton || (_vm->_player->_roomNumber == 29 && -- cgit v1.2.3 From 37aefd08f245c0a5de0c11929e06705271952f65 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 18:27:29 -0500 Subject: ACCESS: Add enum for inventory items referred in hardcoded logic --- engines/access/amazon/amazon_logic.cpp | 9 +++++---- engines/access/amazon/amazon_resources.h | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 42f9a243ce..ecc43f5b1e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -26,6 +26,7 @@ #include "access/screen.h" #include "access/amazon/amazon_game.h" #include "access/amazon/amazon_logic.h" +#include "access/amazon/amazon_resources.h" namespace Access { @@ -1975,7 +1976,7 @@ void Ant::plotPit(int indx, const int *&buf) { _vm->_images.addToList(ie); _vm->_player->_rawPlayer = _pitPos; - if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) { + if (_vm->_inventory->_inv[INV_TORCH]._value == ITEM_IN_INVENTORY) { // Player has torch idx = _torchCel; buf = Amazon::TORCH; @@ -1986,7 +1987,7 @@ void Ant::plotPit(int indx, const int *&buf) { _torchCel = idx; plotTorchSpear(idx, buf); } - else if (!_stabFl && (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY)) { + else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) { // Player has spear idx = 0; buf = Amazon::SPEAR; @@ -2037,7 +2038,7 @@ int Ant::antHandleLeft(int indx, const int *&buf) { int Ant::antHandleStab(int indx, const int *&buf) { int retval = indx; - if (_vm->_inventory->_inv[78]._value == ITEM_IN_INVENTORY) { + if (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY) { if (_stabFl) { buf = Amazon::PITSTAB; retval = _stabCel; @@ -2114,7 +2115,7 @@ void Ant::doAnt() { buf = Amazon::ANTEAT; } else { buf = Amazon::ANTWALK; - if (_vm->_inventory->_inv[76]._value == ITEM_IN_INVENTORY) + if (_vm->_inventory->_inv[INV_TORCH]._value == ITEM_IN_INVENTORY) // Player has burning torch, which scares the Ant _antDirection = ANT_LEFT; } diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 36ae2af092..c4d2cc994d 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -29,6 +29,10 @@ namespace Access { namespace Amazon { +enum InventoryEnum { + INV_BAITED_POLE = 67, INV_TORCH = 76, INV_KNIFE_SPEAR = 78 +}; + struct RiverStruct { int _id; int _width; -- cgit v1.2.3 From e806c6333283ca33a52a2c3ed0f36779c7bc48d6 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 18:37:31 -0500 Subject: ACCESS: Formatting fixes --- engines/access/amazon/amazon_logic.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index ecc43f5b1e..98ab57b32e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -983,8 +983,7 @@ void Guard::setVerticalCode() { else if (_topLeft.x == screen._orgX1) { _gCode1 |= 8; _gCode1 |= 2; - } - else + } else _gCode1 |= 2; if (_bottomRight.x < screen._orgX1) @@ -992,8 +991,7 @@ void Guard::setVerticalCode() { else if (_bottomRight.x == screen._orgX1) { _gCode2 |= 8; _gCode2 |= 2; - } - else + } else _gCode2 |= 2; if (_topLeft.y < screen._orgY1) @@ -1018,8 +1016,7 @@ void Guard::setHorizontalCode() { else if (_topLeft.x == screen._orgX1) { _gCode1 |= 4; _gCode1 |= 1; - } - else + } else _gCode1 |= 1; if (_bottomRight.y < screen._orgY1) @@ -1027,8 +1024,7 @@ void Guard::setHorizontalCode() { else if (_bottomRight.x == screen._orgX1) { _gCode2 |= 4; _gCode2 |= 1; - } - else + } else _gCode2 |= 1; if (_topLeft.x < screen._orgX1) @@ -1155,8 +1151,7 @@ void Guard::guardSee() { chkVLine(); if (_vm->_guardFind == 0) return; - } - else if (screen._orgY1 == screen._orgY2) { + } else if (screen._orgY1 == screen._orgY2) { chkHLine(); if (_vm->_guardFind == 0) return; @@ -1804,8 +1799,7 @@ void River::mWhileDownRiver() { if (!_vm->_timers[3]._flag) { ++_vm->_timers[3]._flag; _vm->_sound->playSound(1); - } - else if (!_vm->_timers[4]._flag) { + } else if (!_vm->_timers[4]._flag) { ++_vm->_timers[4]._flag; _vm->_sound->playSound(0); } @@ -1986,8 +1980,7 @@ void Ant::plotPit(int indx, const int *&buf) { idx = 0; _torchCel = idx; plotTorchSpear(idx, buf); - } - else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) { + } else if (!_stabFl && (_vm->_inventory->_inv[INV_KNIFE_SPEAR]._value == ITEM_IN_INVENTORY)) { // Player has spear idx = 0; buf = Amazon::SPEAR; -- cgit v1.2.3 From 0e4a4a28ad57e7b9698baff4b42b398d345e8a24 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 14 Dec 2014 21:33:14 -0500 Subject: ACCESS: Fix distortion occurring at left edge of jungle scrolling in introduction --- engines/access/amazon/amazon_logic.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 98ab57b32e..eb7d8b567d 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -405,6 +405,8 @@ void Opening::doTitle() { _vm->_midi->setLoop(false); _vm->_events->zeroKeys(); } + + _vm->_buffer1.create(_vm->_screen->w + TILE_WIDTH, _vm->_screen->h); _vm->_room->loadRoom(0); screen.clearScreen(); screen.setBufferScan(); -- cgit v1.2.3 From 8120cbfde316ce344d11bcdfac18222414965d8a Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 15 Dec 2014 19:48:02 +0100 Subject: ACCESS: Remove extra qualification stupidly accepted by MSVC --- engines/access/events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/events.h b/engines/access/events.h index fd3adf8797..3fdcf12136 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -85,12 +85,12 @@ public: /** * Sets the cursor and reset the normal cursor */ - void EventsManager::forceSetCursor(CursorType cursorId); + void forceSetCursor(CursorType cursorId); /** * Sets the normal cursor */ - void EventsManager::setNormalCursor(CursorType cursorId); + void setNormalCursor(CursorType cursorId); /** * Sets the cursor -- cgit v1.2.3 From 409ce79a35131d8538e3100e499366e43ae15d02 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 13 Dec 2014 03:42:07 +0200 Subject: ZVISION: Rename RlfAnimation -> RLFDecoder --- engines/zvision/animation/meta_animation.cpp | 2 +- engines/zvision/animation/meta_animation.h | 4 ++-- engines/zvision/animation/rlf_animation.cpp | 26 +++++++++++++------------- engines/zvision/animation/rlf_animation.h | 10 +++++----- engines/zvision/zvision.h | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp index 857a0dd688..5a8dba6b9d 100644 --- a/engines/zvision/animation/meta_animation.cpp +++ b/engines/zvision/animation/meta_animation.cpp @@ -44,7 +44,7 @@ MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) if (tmpFileName.hasSuffix(".rlf")) { _fileType = RLF; Common::File *_file = engine->getSearchManager()->openFile(tmpFileName); - _animation.rlf = new RlfAnimation(_file, false); + _animation.rlf = new RLFDecoder(_file, false); _frmDelay = _animation.rlf->frameTime(); } else if (tmpFileName.hasSuffix(".avi")) { _fileType = AVI; diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h index 93b69587c4..6d2025b2cf 100644 --- a/engines/zvision/animation/meta_animation.h +++ b/engines/zvision/animation/meta_animation.h @@ -43,7 +43,7 @@ struct Surface; namespace ZVision { class ZVision; -class RlfAnimation; +class RLFDecoder; class MetaAnimation { public: @@ -69,7 +69,7 @@ private: private: union { - RlfAnimation *rlf; + RLFDecoder *rlf; Video::VideoDecoder *avi; } _animation; diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp index d9b8fa3894..eaf08a79f9 100644 --- a/engines/zvision/animation/rlf_animation.cpp +++ b/engines/zvision/animation/rlf_animation.cpp @@ -34,7 +34,7 @@ namespace ZVision { -RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) +RLFDecoder::RLFDecoder(const Common::String &fileName, bool stream) : _stream(stream), _readStream(NULL), _lastFrameRead(0), @@ -72,7 +72,7 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream) } } -RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream) +RLFDecoder::RLFDecoder(Common::SeekableReadStream *rstream, bool stream) : _stream(stream), _readStream(rstream), _lastFrameRead(0), @@ -102,7 +102,7 @@ RlfAnimation::RlfAnimation(Common::SeekableReadStream *rstream, bool stream) } } -RlfAnimation::~RlfAnimation() { +RLFDecoder::~RLFDecoder() { for (uint i = 0; i < _frameCount; ++i) { delete[] _frames[i].encodedData; } @@ -111,7 +111,7 @@ RlfAnimation::~RlfAnimation() { _currentFrameBuffer.free(); } -bool RlfAnimation::readHeader() { +bool RLFDecoder::readHeader() { if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { return false; } @@ -160,8 +160,8 @@ bool RlfAnimation::readHeader() { return true; } -RlfAnimation::Frame RlfAnimation::readNextFrame() { - RlfAnimation::Frame frame; +RLFDecoder::Frame RLFDecoder::readNextFrame() { + RLFDecoder::Frame frame; _readStream->readUint32BE(); // Magic number MARF uint32 size = _readStream->readUint32LE(); // Size @@ -188,7 +188,7 @@ RlfAnimation::Frame RlfAnimation::readNextFrame() { return frame; } -void RlfAnimation::seekToFrame(int frameNumber) { +void RLFDecoder::seekToFrame(int frameNumber) { assert(!_stream); assert(frameNumber < (int)_frameCount || frameNumber >= -1); @@ -228,7 +228,7 @@ void RlfAnimation::seekToFrame(int frameNumber) { _nextFrame = frameNumber; } -const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { +const Graphics::Surface *RLFDecoder::getFrameData(uint frameNumber) { assert(!_stream); assert(frameNumber < _frameCount); @@ -244,7 +244,7 @@ const Graphics::Surface *RlfAnimation::getFrameData(uint frameNumber) { return decodeNextFrame(); } -const Graphics::Surface *RlfAnimation::decodeNextFrame() { +const Graphics::Surface *RLFDecoder::decodeNextFrame() { assert(_nextFrame < (int)_frameCount); if (_stream) { @@ -257,7 +257,7 @@ const Graphics::Surface *RlfAnimation::decodeNextFrame() { return &_currentFrameBuffer; } -void RlfAnimation::applyFrameToCurrent(uint frameNumber) { +void RLFDecoder::applyFrameToCurrent(uint frameNumber) { if (_frames[frameNumber].type == Masked) { decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); } else if (_frames[frameNumber].type == Simple) { @@ -265,7 +265,7 @@ void RlfAnimation::applyFrameToCurrent(uint frameNumber) { } } -void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) { +void RLFDecoder::applyFrameToCurrent(const RLFDecoder::Frame &frame) { if (frame.type == Masked) { decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); } else if (frame.type == Simple) { @@ -273,7 +273,7 @@ void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) { } } -void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { +void RLFDecoder::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; int16 numberOfCopy = 0; @@ -320,7 +320,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3 } } -void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { +void RLFDecoder::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; int16 numberOfCopy = 0; diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h index c8b2930676..62fa6099bf 100644 --- a/engines/zvision/animation/rlf_animation.h +++ b/engines/zvision/animation/rlf_animation.h @@ -33,11 +33,11 @@ class String; namespace ZVision { -class RlfAnimation { +class RLFDecoder { public: - RlfAnimation(const Common::String &fileName, bool stream = true); - RlfAnimation(Common::SeekableReadStream *rstream, bool stream); - ~RlfAnimation(); + RLFDecoder(const Common::String &fileName, bool stream = true); + RLFDecoder(Common::SeekableReadStream *rstream, bool stream); + ~RLFDecoder(); private: enum EncodingType { @@ -143,7 +143,7 @@ private: * * @param frame A Frame object to apply to _currentFrameBuffer */ - void applyFrameToCurrent(const RlfAnimation::Frame &frame); + void applyFrameToCurrent(const RLFDecoder::Frame &frame); /** * Decode frame data that uses masked run length encoding. This is the encoding diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 5850bf66cd..891f9a9a0f 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -50,7 +50,7 @@ class RenderManager; class CursorManager; class StringManager; class SaveManager; -class RlfAnimation; +class RLFDecoder; class MenuHandler; class TextRenderer; class Subtitle; -- cgit v1.2.3 From 3315522ba1607d68c3402f3d1c8b51b7dc38a7dd Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 13 Dec 2014 15:28:22 +0200 Subject: ZVISION: Move the RLF decoder --- engines/zvision/animation/meta_animation.cpp | 2 +- engines/zvision/animation/rlf_animation.cpp | 382 --------------------------- engines/zvision/animation/rlf_animation.h | 172 ------------ engines/zvision/core/events.cpp | 1 - engines/zvision/module.mk | 2 +- engines/zvision/video/rlf_decoder.cpp | 382 +++++++++++++++++++++++++++ engines/zvision/video/rlf_decoder.h | 172 ++++++++++++ 7 files changed, 556 insertions(+), 557 deletions(-) delete mode 100644 engines/zvision/animation/rlf_animation.cpp delete mode 100644 engines/zvision/animation/rlf_animation.h create mode 100644 engines/zvision/video/rlf_decoder.cpp create mode 100644 engines/zvision/video/rlf_decoder.h diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp index 5a8dba6b9d..85b2e0f6b7 100644 --- a/engines/zvision/animation/meta_animation.cpp +++ b/engines/zvision/animation/meta_animation.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/animation/rlf_animation.h" +#include "zvision/video/rlf_decoder.h" #include "zvision/video/zork_avi_decoder.h" #include "video/video_decoder.h" diff --git a/engines/zvision/animation/rlf_animation.cpp b/engines/zvision/animation/rlf_animation.cpp deleted file mode 100644 index eaf08a79f9..0000000000 --- a/engines/zvision/animation/rlf_animation.cpp +++ /dev/null @@ -1,382 +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 "common/scummsys.h" - -#include "zvision/animation/rlf_animation.h" - -#include "common/str.h" -#include "common/file.h" -#include "common/textconsole.h" -#include "common/debug.h" -#include "common/endian.h" - -#include "graphics/colormasks.h" - -namespace ZVision { - -RLFDecoder::RLFDecoder(const Common::String &fileName, bool stream) - : _stream(stream), - _readStream(NULL), - _lastFrameRead(0), - _frameCount(0), - _width(0), - _height(0), - _frameTime(0), - _frames(0), - _nextFrame(0), - _frameBufferByteSize(0) { - - Common::File *_file = new Common::File; - if (!_file->open(fileName)) { - warning("RLF animation file %s could not be opened", fileName.c_str()); - return; - } - - _readStream = _file; - - if (!readHeader()) { - warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str()); - return; - } - - _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); - _frameBufferByteSize = _width * _height * sizeof(uint16); - - if (!stream) { - _frames = new Frame[_frameCount]; - - // Read in each frame - for (uint i = 0; i < _frameCount; ++i) { - _frames[i] = readNextFrame(); - } - } -} - -RLFDecoder::RLFDecoder(Common::SeekableReadStream *rstream, bool stream) - : _stream(stream), - _readStream(rstream), - _lastFrameRead(0), - _frameCount(0), - _width(0), - _height(0), - _frameTime(0), - _frames(0), - _nextFrame(0), - _frameBufferByteSize(0) { - - if (!readHeader()) { - warning("Stream is not a RLF animation. Wrong magic number"); - return; - } - - _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); - _frameBufferByteSize = _width * _height * sizeof(uint16); - - if (!stream) { - _frames = new Frame[_frameCount]; - - // Read in each frame - for (uint i = 0; i < _frameCount; ++i) { - _frames[i] = readNextFrame(); - } - } -} - -RLFDecoder::~RLFDecoder() { - for (uint i = 0; i < _frameCount; ++i) { - delete[] _frames[i].encodedData; - } - delete[] _frames; - delete _readStream; - _currentFrameBuffer.free(); -} - -bool RLFDecoder::readHeader() { - if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { - return false; - } - - // Read the header - _readStream->readUint32LE(); // Size1 - _readStream->readUint32LE(); // Unknown1 - _readStream->readUint32LE(); // Unknown2 - _frameCount = _readStream->readUint32LE(); // Frame count - - // Since we don't need any of the data, we can just seek right to the - // entries we need rather than read in all the individual entries. - _readStream->seek(136, SEEK_CUR); - - //// Read CIN header - //_readStream->readUint32BE(); // Magic number FNIC - //_readStream->readUint32LE(); // Size2 - //_readStream->readUint32LE(); // Unknown3 - //_readStream->readUint32LE(); // Unknown4 - //_readStream->readUint32LE(); // Unknown5 - //_readStream->seek(0x18, SEEK_CUR); // VRLE - //_readStream->readUint32LE(); // LRVD - //_readStream->readUint32LE(); // Unknown6 - //_readStream->seek(0x18, SEEK_CUR); // HRLE - //_readStream->readUint32LE(); // ELHD - //_readStream->readUint32LE(); // Unknown7 - //_readStream->seek(0x18, SEEK_CUR); // HKEY - //_readStream->readUint32LE(); // ELRH - - //// Read MIN info header - //_readStream->readUint32BE(); // Magic number FNIM - //_readStream->readUint32LE(); // Size3 - //_readStream->readUint32LE(); // OEDV - //_readStream->readUint32LE(); // Unknown8 - //_readStream->readUint32LE(); // Unknown9 - //_readStream->readUint32LE(); // Unknown10 - _width = _readStream->readUint32LE(); // Width - _height = _readStream->readUint32LE(); // Height - - // Read time header - _readStream->readUint32BE(); // Magic number EMIT - _readStream->readUint32LE(); // Size4 - _readStream->readUint32LE(); // Unknown11 - _frameTime = _readStream->readUint32LE() / 10; // Frame time in microseconds - - return true; -} - -RLFDecoder::Frame RLFDecoder::readNextFrame() { - RLFDecoder::Frame frame; - - _readStream->readUint32BE(); // Magic number MARF - uint32 size = _readStream->readUint32LE(); // Size - _readStream->readUint32LE(); // Unknown1 - _readStream->readUint32LE(); // Unknown2 - uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH - uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28 - _readStream->readUint32LE(); // Unknown3 - - frame.encodedSize = size - headerSize; - frame.encodedData = new int8[frame.encodedSize]; - _readStream->read(frame.encodedData, frame.encodedSize); - - if (type == MKTAG('E', 'L', 'H', 'D')) { - frame.type = Masked; - } else if (type == MKTAG('E', 'L', 'R', 'H')) { - frame.type = Simple; - _completeFrames.push_back(_lastFrameRead); - } else { - warning("Frame %u doesn't have type that can be decoded", _lastFrameRead); - } - - _lastFrameRead++; - return frame; -} - -void RLFDecoder::seekToFrame(int frameNumber) { - assert(!_stream); - assert(frameNumber < (int)_frameCount || frameNumber >= -1); - - if (_nextFrame == frameNumber) - return; - - if (frameNumber < 0) { - _nextFrame = 0; - return; - } - - int closestFrame = _nextFrame; - int distance = (int)frameNumber - _nextFrame; - - if (distance < 0) { - for (uint i = 0; i < _completeFrames.size(); ++i) { - if ((int)_completeFrames[i] > frameNumber) - break; - closestFrame = _completeFrames[i]; - } - } else { - for (uint i = 0; i < _completeFrames.size(); ++i) { - int newDistance = (int)frameNumber - (int)(_completeFrames[i]); - if (newDistance < 0) - break; - if (newDistance < distance) { - closestFrame = _completeFrames[i]; - distance = newDistance; - } - } - } - - for (int i = closestFrame; i < frameNumber; ++i) { - applyFrameToCurrent(i); - } - - _nextFrame = frameNumber; -} - -const Graphics::Surface *RLFDecoder::getFrameData(uint frameNumber) { - assert(!_stream); - assert(frameNumber < _frameCount); - - // Since this method is so expensive, first check to see if we can use - // decodeNextFrame() it's cheap. - if ((int)frameNumber == _nextFrame - 1) { - return &_currentFrameBuffer; - } else if (_nextFrame == (int)frameNumber) { - return decodeNextFrame(); - } - - seekToFrame(frameNumber); - return decodeNextFrame(); -} - -const Graphics::Surface *RLFDecoder::decodeNextFrame() { - assert(_nextFrame < (int)_frameCount); - - if (_stream) { - applyFrameToCurrent(readNextFrame()); - } else { - applyFrameToCurrent(_nextFrame); - } - - _nextFrame++; - return &_currentFrameBuffer; -} - -void RLFDecoder::applyFrameToCurrent(uint frameNumber) { - if (_frames[frameNumber].type == Masked) { - decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); - } else if (_frames[frameNumber].type == Simple) { - decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); - } -} - -void RLFDecoder::applyFrameToCurrent(const RLFDecoder::Frame &frame) { - if (frame.type == Masked) { - decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); - } else if (frame.type == Simple) { - decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); - } -} - -void RLFDecoder::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { - uint32 sourceOffset = 0; - uint32 destOffset = 0; - int16 numberOfCopy = 0; - - while (sourceOffset < sourceSize) { - int8 numberOfSamples = source[sourceOffset]; - sourceOffset++; - - // If numberOfSamples is negative, the next abs(numberOfSamples) samples should - // be copied directly from source to dest - if (numberOfSamples < 0) { - numberOfCopy = -numberOfSamples; - - while (numberOfCopy > 0) { - if (sourceOffset + 1 >= sourceSize) { - return; - } else if (destOffset + 1 >= destSize) { - debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); - return; - } - - byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::RGBToColor >(r, g, b); - WRITE_UINT16(dest + destOffset, destColor); - - sourceOffset += 2; - destOffset += 2; - numberOfCopy--; - } - - // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2) - // This function assumes the dest buffer has been memset with 0's. - } else { - if (sourceOffset + 1 >= sourceSize) { - return; - } else if (destOffset + 1 >= destSize) { - debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); - return; - } - - destOffset += (numberOfSamples * 2) + 2; - } - } -} - -void RLFDecoder::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { - uint32 sourceOffset = 0; - uint32 destOffset = 0; - int16 numberOfCopy = 0; - - while (sourceOffset < sourceSize) { - int8 numberOfSamples = source[sourceOffset]; - sourceOffset++; - - // If numberOfSamples is negative, the next abs(numberOfSamples) samples should - // be copied directly from source to dest - if (numberOfSamples < 0) { - numberOfCopy = -numberOfSamples; - - while (numberOfCopy > 0) { - if (sourceOffset + 1 >= sourceSize) { - return; - } else if (destOffset + 1 >= destSize) { - debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); - return; - } - - byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::RGBToColor >(r, g, b); - WRITE_UINT16(dest + destOffset, destColor); - - sourceOffset += 2; - destOffset += 2; - numberOfCopy--; - } - - // If numberOfSamples is >= 0, copy one sample from source to the - // next (numberOfSamples + 2) dest spots - } else { - if (sourceOffset + 1 >= sourceSize) { - return; - } - - byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 sampleColor = Graphics::RGBToColor >(r, g, b); - sourceOffset += 2; - - numberOfCopy = numberOfSamples + 2; - while (numberOfCopy > 0) { - if (destOffset + 1 >= destSize) { - debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); - return; - } - - WRITE_UINT16(dest + destOffset, sampleColor); - destOffset += 2; - numberOfCopy--; - } - } - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/animation/rlf_animation.h b/engines/zvision/animation/rlf_animation.h deleted file mode 100644 index 62fa6099bf..0000000000 --- a/engines/zvision/animation/rlf_animation.h +++ /dev/null @@ -1,172 +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 ZVISION_RLF_ANIMATION_H -#define ZVISION_RLF_ANIMATION_H - -#include "common/file.h" - -#include "graphics/surface.h" - -namespace Common { -class String; -} - -namespace ZVision { - -class RLFDecoder { -public: - RLFDecoder(const Common::String &fileName, bool stream = true); - RLFDecoder(Common::SeekableReadStream *rstream, bool stream); - ~RLFDecoder(); - -private: - enum EncodingType { - Masked, - Simple - }; - - struct Frame { - EncodingType type; - int8 *encodedData; - uint32 encodedSize; - }; - -private: - Common::SeekableReadStream *_readStream; - bool _stream; - uint _lastFrameRead; - - uint _frameCount; - uint _width; - uint _height; - uint32 _frameTime; // In milliseconds - Frame *_frames; - Common::Array _completeFrames; - - int _nextFrame; - Graphics::Surface _currentFrameBuffer; - uint32 _frameBufferByteSize; - -public: - uint frameCount() { - return _frameCount; - } - uint width() { - return _width; - } - uint height() { - return _height; - } - uint32 frameTime() { - return _frameTime; - } - - /** - * Seeks to the frameNumber and updates the internal Surface with - * the new frame data. If frameNumber == -1, it only sets _currentFrame, - * the internal Surface is unchanged. This function requires _stream = false - * - * @param frameNumber The frame number to seek to - */ - void seekToFrame(int frameNumber); - - /** - * Returns the pixel data of the frame specified. It will try to use - * decodeNextFrame() if possible. If not, it uses seekToFrame() to - * update the internal Surface and then returns a pointer to it. - * This function requires _stream = false - * - * @param frameNumber The frame number to get data for - * @return A pointer to the pixel data. Do NOT delete this. - */ - const Graphics::Surface *getFrameData(uint frameNumber); - /** - * Returns the pixel data of current frame and go to next. It is up to the user to - * check if the current frame is valid before calling this. - * IE. Use endOfAnimation() - * - * @return A pointer to the pixel data. Do NOT delete this. - */ - const Graphics::Surface *decodeNextFrame(); - /** - * @return Is the currentFrame is the last frame in the animation? - */ - bool endOfAnimation() { - return _nextFrame == (int)_frameCount; - } - -private: - /** - * Reads in the header of the RLF file - * - * @return Will return false if the header magic number is wrong - */ - bool readHeader(); - /** - * Reads the next frame from the RLF file, stores the data in - * a Frame object, then returns the object - * - * @return A Frame object representing the frame data - */ - Frame readNextFrame(); - - /** - * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer. - * This function requires _stream = false so it can look up the Frame object - * referenced by frameNumber. - * - * @param frameNumber The frame number to apply to _currentFrameBuffer - */ - void applyFrameToCurrent(uint frameNumber); - /** - * Applies the data from a Frame object on top of a _currentFrameBuffer. - * - * @param frame A Frame object to apply to _currentFrameBuffer - */ - void applyFrameToCurrent(const RLFDecoder::Frame &frame); - - /** - * Decode frame data that uses masked run length encoding. This is the encoding - * used by P-frames. - * - * @param source The source pixel data - * @param dest The destination buffer - * @param sourceSize The size of the source pixel data - * @param destSize The size of the destination buffer - */ - void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; - /** - * Decode frame data that uses simple run length encoding. This is the encoding - * used by I-frames. - * - * @param source The source pixel data - * @param dest The destination buffer - * @param sourceSize The size of the source pixel data - * @param destSize The size of the destination buffer - */ - void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 52d71c92f6..839f919ad6 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -28,7 +28,6 @@ #include "zvision/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/animation/rlf_animation.h" #include "zvision/core/menu.h" #include "zvision/sound/zork_raw.h" diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 045eb5264a..5c2fd2045b 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -2,7 +2,6 @@ MODULE := engines/zvision MODULE_OBJS := \ animation/meta_animation.o \ - animation/rlf_animation.o \ core/console.o \ core/events.o \ core/menu.o \ @@ -48,6 +47,7 @@ MODULE_OBJS := \ utility/lzss_read_stream.o \ utility/utility.o \ utility/zfs_archive.o \ + video/rlf_decoder.o \ video/video.o \ video/zork_avi_decoder.o \ zvision.o diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp new file mode 100644 index 0000000000..a4f16af9b0 --- /dev/null +++ b/engines/zvision/video/rlf_decoder.cpp @@ -0,0 +1,382 @@ +/* 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 "common/scummsys.h" + +#include "zvision/video/rlf_decoder.h" + +#include "common/str.h" +#include "common/file.h" +#include "common/textconsole.h" +#include "common/debug.h" +#include "common/endian.h" + +#include "graphics/colormasks.h" + +namespace ZVision { + +RLFDecoder::RLFDecoder(const Common::String &fileName, bool stream) + : _stream(stream), + _readStream(NULL), + _lastFrameRead(0), + _frameCount(0), + _width(0), + _height(0), + _frameTime(0), + _frames(0), + _nextFrame(0), + _frameBufferByteSize(0) { + + Common::File *_file = new Common::File; + if (!_file->open(fileName)) { + warning("RLF animation file %s could not be opened", fileName.c_str()); + return; + } + + _readStream = _file; + + if (!readHeader()) { + warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str()); + return; + } + + _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); + _frameBufferByteSize = _width * _height * sizeof(uint16); + + if (!stream) { + _frames = new Frame[_frameCount]; + + // Read in each frame + for (uint i = 0; i < _frameCount; ++i) { + _frames[i] = readNextFrame(); + } + } +} + +RLFDecoder::RLFDecoder(Common::SeekableReadStream *rstream, bool stream) + : _stream(stream), + _readStream(rstream), + _lastFrameRead(0), + _frameCount(0), + _width(0), + _height(0), + _frameTime(0), + _frames(0), + _nextFrame(0), + _frameBufferByteSize(0) { + + if (!readHeader()) { + warning("Stream is not a RLF animation. Wrong magic number"); + return; + } + + _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); + _frameBufferByteSize = _width * _height * sizeof(uint16); + + if (!stream) { + _frames = new Frame[_frameCount]; + + // Read in each frame + for (uint i = 0; i < _frameCount; ++i) { + _frames[i] = readNextFrame(); + } + } +} + +RLFDecoder::~RLFDecoder() { + for (uint i = 0; i < _frameCount; ++i) { + delete[] _frames[i].encodedData; + } + delete[] _frames; + delete _readStream; + _currentFrameBuffer.free(); +} + +bool RLFDecoder::readHeader() { + if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { + return false; + } + + // Read the header + _readStream->readUint32LE(); // Size1 + _readStream->readUint32LE(); // Unknown1 + _readStream->readUint32LE(); // Unknown2 + _frameCount = _readStream->readUint32LE(); // Frame count + + // Since we don't need any of the data, we can just seek right to the + // entries we need rather than read in all the individual entries. + _readStream->seek(136, SEEK_CUR); + + //// Read CIN header + //_readStream->readUint32BE(); // Magic number FNIC + //_readStream->readUint32LE(); // Size2 + //_readStream->readUint32LE(); // Unknown3 + //_readStream->readUint32LE(); // Unknown4 + //_readStream->readUint32LE(); // Unknown5 + //_readStream->seek(0x18, SEEK_CUR); // VRLE + //_readStream->readUint32LE(); // LRVD + //_readStream->readUint32LE(); // Unknown6 + //_readStream->seek(0x18, SEEK_CUR); // HRLE + //_readStream->readUint32LE(); // ELHD + //_readStream->readUint32LE(); // Unknown7 + //_readStream->seek(0x18, SEEK_CUR); // HKEY + //_readStream->readUint32LE(); // ELRH + + //// Read MIN info header + //_readStream->readUint32BE(); // Magic number FNIM + //_readStream->readUint32LE(); // Size3 + //_readStream->readUint32LE(); // OEDV + //_readStream->readUint32LE(); // Unknown8 + //_readStream->readUint32LE(); // Unknown9 + //_readStream->readUint32LE(); // Unknown10 + _width = _readStream->readUint32LE(); // Width + _height = _readStream->readUint32LE(); // Height + + // Read time header + _readStream->readUint32BE(); // Magic number EMIT + _readStream->readUint32LE(); // Size4 + _readStream->readUint32LE(); // Unknown11 + _frameTime = _readStream->readUint32LE() / 10; // Frame time in microseconds + + return true; +} + +RLFDecoder::Frame RLFDecoder::readNextFrame() { + RLFDecoder::Frame frame; + + _readStream->readUint32BE(); // Magic number MARF + uint32 size = _readStream->readUint32LE(); // Size + _readStream->readUint32LE(); // Unknown1 + _readStream->readUint32LE(); // Unknown2 + uint32 type = _readStream->readUint32BE(); // Either ELHD or ELRH + uint32 headerSize = _readStream->readUint32LE(); // Offset from the beginning of this frame to the frame data. Should always be 28 + _readStream->readUint32LE(); // Unknown3 + + frame.encodedSize = size - headerSize; + frame.encodedData = new int8[frame.encodedSize]; + _readStream->read(frame.encodedData, frame.encodedSize); + + if (type == MKTAG('E', 'L', 'H', 'D')) { + frame.type = Masked; + } else if (type == MKTAG('E', 'L', 'R', 'H')) { + frame.type = Simple; + _completeFrames.push_back(_lastFrameRead); + } else { + warning("Frame %u doesn't have type that can be decoded", _lastFrameRead); + } + + _lastFrameRead++; + return frame; +} + +void RLFDecoder::seekToFrame(int frameNumber) { + assert(!_stream); + assert(frameNumber < (int)_frameCount || frameNumber >= -1); + + if (_nextFrame == frameNumber) + return; + + if (frameNumber < 0) { + _nextFrame = 0; + return; + } + + int closestFrame = _nextFrame; + int distance = (int)frameNumber - _nextFrame; + + if (distance < 0) { + for (uint i = 0; i < _completeFrames.size(); ++i) { + if ((int)_completeFrames[i] > frameNumber) + break; + closestFrame = _completeFrames[i]; + } + } else { + for (uint i = 0; i < _completeFrames.size(); ++i) { + int newDistance = (int)frameNumber - (int)(_completeFrames[i]); + if (newDistance < 0) + break; + if (newDistance < distance) { + closestFrame = _completeFrames[i]; + distance = newDistance; + } + } + } + + for (int i = closestFrame; i < frameNumber; ++i) { + applyFrameToCurrent(i); + } + + _nextFrame = frameNumber; +} + +const Graphics::Surface *RLFDecoder::getFrameData(uint frameNumber) { + assert(!_stream); + assert(frameNumber < _frameCount); + + // Since this method is so expensive, first check to see if we can use + // decodeNextFrame() it's cheap. + if ((int)frameNumber == _nextFrame - 1) { + return &_currentFrameBuffer; + } else if (_nextFrame == (int)frameNumber) { + return decodeNextFrame(); + } + + seekToFrame(frameNumber); + return decodeNextFrame(); +} + +const Graphics::Surface *RLFDecoder::decodeNextFrame() { + assert(_nextFrame < (int)_frameCount); + + if (_stream) { + applyFrameToCurrent(readNextFrame()); + } else { + applyFrameToCurrent(_nextFrame); + } + + _nextFrame++; + return &_currentFrameBuffer; +} + +void RLFDecoder::applyFrameToCurrent(uint frameNumber) { + if (_frames[frameNumber].type == Masked) { + decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); + } else if (_frames[frameNumber].type == Simple) { + decodeSimpleRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); + } +} + +void RLFDecoder::applyFrameToCurrent(const RLFDecoder::Frame &frame) { + if (frame.type == Masked) { + decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); + } else if (frame.type == Simple) { + decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); + } +} + +void RLFDecoder::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { + uint32 sourceOffset = 0; + uint32 destOffset = 0; + int16 numberOfCopy = 0; + + while (sourceOffset < sourceSize) { + int8 numberOfSamples = source[sourceOffset]; + sourceOffset++; + + // If numberOfSamples is negative, the next abs(numberOfSamples) samples should + // be copied directly from source to dest + if (numberOfSamples < 0) { + numberOfCopy = -numberOfSamples; + + while (numberOfCopy > 0) { + if (sourceOffset + 1 >= sourceSize) { + return; + } else if (destOffset + 1 >= destSize) { + debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); + return; + } + + byte r, g, b; + Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 destColor = Graphics::RGBToColor >(r, g, b); + WRITE_UINT16(dest + destOffset, destColor); + + sourceOffset += 2; + destOffset += 2; + numberOfCopy--; + } + + // If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2) + // This function assumes the dest buffer has been memset with 0's. + } else { + if (sourceOffset + 1 >= sourceSize) { + return; + } else if (destOffset + 1 >= destSize) { + debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); + return; + } + + destOffset += (numberOfSamples * 2) + 2; + } + } +} + +void RLFDecoder::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { + uint32 sourceOffset = 0; + uint32 destOffset = 0; + int16 numberOfCopy = 0; + + while (sourceOffset < sourceSize) { + int8 numberOfSamples = source[sourceOffset]; + sourceOffset++; + + // If numberOfSamples is negative, the next abs(numberOfSamples) samples should + // be copied directly from source to dest + if (numberOfSamples < 0) { + numberOfCopy = -numberOfSamples; + + while (numberOfCopy > 0) { + if (sourceOffset + 1 >= sourceSize) { + return; + } else if (destOffset + 1 >= destSize) { + debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); + return; + } + + byte r, g, b; + Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 destColor = Graphics::RGBToColor >(r, g, b); + WRITE_UINT16(dest + destOffset, destColor); + + sourceOffset += 2; + destOffset += 2; + numberOfCopy--; + } + + // If numberOfSamples is >= 0, copy one sample from source to the + // next (numberOfSamples + 2) dest spots + } else { + if (sourceOffset + 1 >= sourceSize) { + return; + } + + byte r, g, b; + Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 sampleColor = Graphics::RGBToColor >(r, g, b); + sourceOffset += 2; + + numberOfCopy = numberOfSamples + 2; + while (numberOfCopy > 0) { + if (destOffset + 1 >= destSize) { + debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize); + return; + } + + WRITE_UINT16(dest + destOffset, sampleColor); + destOffset += 2; + numberOfCopy--; + } + } + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h new file mode 100644 index 0000000000..dcfd8606c2 --- /dev/null +++ b/engines/zvision/video/rlf_decoder.h @@ -0,0 +1,172 @@ +/* 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 ZVISION_RLF_DECODER_H +#define ZVISION_RLF_DECODER_H + +#include "common/file.h" + +#include "graphics/surface.h" + +namespace Common { +class String; +} + +namespace ZVision { + +class RLFDecoder { +public: + RLFDecoder(const Common::String &fileName, bool stream = true); + RLFDecoder(Common::SeekableReadStream *rstream, bool stream); + ~RLFDecoder(); + +private: + enum EncodingType { + Masked, + Simple + }; + + struct Frame { + EncodingType type; + int8 *encodedData; + uint32 encodedSize; + }; + +private: + Common::SeekableReadStream *_readStream; + bool _stream; + uint _lastFrameRead; + + uint _frameCount; + uint _width; + uint _height; + uint32 _frameTime; // In milliseconds + Frame *_frames; + Common::Array _completeFrames; + + int _nextFrame; + Graphics::Surface _currentFrameBuffer; + uint32 _frameBufferByteSize; + +public: + uint frameCount() { + return _frameCount; + } + uint width() { + return _width; + } + uint height() { + return _height; + } + uint32 frameTime() { + return _frameTime; + } + + /** + * Seeks to the frameNumber and updates the internal Surface with + * the new frame data. If frameNumber == -1, it only sets _currentFrame, + * the internal Surface is unchanged. This function requires _stream = false + * + * @param frameNumber The frame number to seek to + */ + void seekToFrame(int frameNumber); + + /** + * Returns the pixel data of the frame specified. It will try to use + * decodeNextFrame() if possible. If not, it uses seekToFrame() to + * update the internal Surface and then returns a pointer to it. + * This function requires _stream = false + * + * @param frameNumber The frame number to get data for + * @return A pointer to the pixel data. Do NOT delete this. + */ + const Graphics::Surface *getFrameData(uint frameNumber); + /** + * Returns the pixel data of current frame and go to next. It is up to the user to + * check if the current frame is valid before calling this. + * IE. Use endOfAnimation() + * + * @return A pointer to the pixel data. Do NOT delete this. + */ + const Graphics::Surface *decodeNextFrame(); + /** + * @return Is the currentFrame is the last frame in the animation? + */ + bool endOfAnimation() { + return _nextFrame == (int)_frameCount; + } + +private: + /** + * Reads in the header of the RLF file + * + * @return Will return false if the header magic number is wrong + */ + bool readHeader(); + /** + * Reads the next frame from the RLF file, stores the data in + * a Frame object, then returns the object + * + * @return A Frame object representing the frame data + */ + Frame readNextFrame(); + + /** + * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer. + * This function requires _stream = false so it can look up the Frame object + * referenced by frameNumber. + * + * @param frameNumber The frame number to apply to _currentFrameBuffer + */ + void applyFrameToCurrent(uint frameNumber); + /** + * Applies the data from a Frame object on top of a _currentFrameBuffer. + * + * @param frame A Frame object to apply to _currentFrameBuffer + */ + void applyFrameToCurrent(const RLFDecoder::Frame &frame); + + /** + * Decode frame data that uses masked run length encoding. This is the encoding + * used by P-frames. + * + * @param source The source pixel data + * @param dest The destination buffer + * @param sourceSize The size of the source pixel data + * @param destSize The size of the destination buffer + */ + void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; + /** + * Decode frame data that uses simple run length encoding. This is the encoding + * used by I-frames. + * + * @param source The source pixel data + * @param dest The destination buffer + * @param sourceSize The size of the source pixel data + * @param destSize The size of the destination buffer + */ + void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; +}; + +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 3d1a9e34422f3bb9d86149c18695cc5a9e4ebac8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 15 Dec 2014 03:15:30 +0200 Subject: ZVISION: Simplify the working window code --- engines/zvision/zvision.cpp | 12 +++++++++--- engines/zvision/zvision.h | 13 +++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 8a44ccebea..ec1fb9413b 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -81,9 +81,6 @@ struct zvisionIniSettings { ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), - _workingWindow_ZGI((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - WORKING_WINDOW_WIDTH) / 2) + WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - WORKING_WINDOW_HEIGHT) / 2) + WORKING_WINDOW_HEIGHT), - _workingWindow_ZNM((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2, (WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2, ((WINDOW_WIDTH - ZNM_WORKING_WINDOW_WIDTH) / 2) + ZNM_WORKING_WINDOW_WIDTH, ((WINDOW_HEIGHT - ZNM_WORKING_WINDOW_HEIGHT) / 2) + ZNM_WORKING_WINDOW_HEIGHT), - _workingWindow(gameDesc->gameId == GID_NEMESIS ? _workingWindow_ZNM : _workingWindow_ZGI), _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ _desiredFrameTime(33), /* ~30 fps */ _clock(_system), @@ -101,6 +98,15 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) debug(1, "ZVision::ZVision"); + uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; + uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; + _workingWindow = Common::Rect( + (WINDOW_WIDTH - workingWindowWidth) / 2, + (WINDOW_HEIGHT - workingWindowHeight) / 2, + ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth, + ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight + ); + memset(_cheatBuff, 0, sizeof(_cheatBuff)); } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 891f9a9a0f..f8763f94ee 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -67,7 +67,7 @@ public: * are given in this coordinate space. Also, all images are clipped to the * edges of this Rectangle */ - const Common::Rect &_workingWindow; + Common::Rect _workingWindow; const Graphics::PixelFormat _pixelFormat; private: @@ -75,13 +75,13 @@ private: WINDOW_WIDTH = 640, WINDOW_HEIGHT = 480, - //Zork nemesis working window sizes + // Zork nemesis working window sizes ZNM_WORKING_WINDOW_WIDTH = 512, ZNM_WORKING_WINDOW_HEIGHT = 320, - //ZGI(and default) working window sizes - WORKING_WINDOW_WIDTH = 640, - WORKING_WINDOW_HEIGHT = 344, + // ZGI working window sizes + ZGI_WORKING_WINDOW_WIDTH = 640, + ZGI_WORKING_WINDOW_HEIGHT = 344, ROTATION_SCREEN_EDGE_OFFSET = 60, MAX_ROTATION_SPEED = 400, // Pixels per second @@ -117,9 +117,6 @@ private: // To prevent allocation every time we process events Common::Event _event; - const Common::Rect _workingWindow_ZGI; - const Common::Rect _workingWindow_ZNM; - int _rendDelay; int16 _mouseVelocity; int16 _kbdVelocity; -- cgit v1.2.3 From 67bd78a95f6efab6d0da4b3bef1b0cebc79c537c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 15 Dec 2014 03:40:52 +0200 Subject: ZVISION: Prefix class member variables with an underscore This makes the code adhere to our code formatting conventions --- engines/zvision/core/search_manager.cpp | 48 ++++++++++++++++----------------- engines/zvision/core/search_manager.h | 6 ++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp index 9c5d8fb323..1523319c94 100644 --- a/engines/zvision/core/search_manager.cpp +++ b/engines/zvision/core/search_manager.cpp @@ -36,11 +36,11 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { Common::FSNode fsNode(_root); - listDirRecursive(dirList, fsNode, depth); + listDirRecursive(_dirList, fsNode, depth); - for (Common::List::iterator it = dirList.begin(); it != dirList.end();) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) if (it->size() == _root.size()) - it = dirList.erase(it); + it = _dirList.erase(it); else if (it->size() > _root.size()) { *it = Common::String(it->c_str() + _root.size() + 1); it++; @@ -49,32 +49,32 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { } SearchManager::~SearchManager() { - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { delete *it; it++; } - archList.clear(); + _archList.clear(); } void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { Common::String lowerCaseName = dst; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator it = files.find(lowerCaseName); + SearchManager::MatchList::iterator it = _files.find(lowerCaseName); - if (it != files.end()) { + if (it != _files.end()) { lowerCaseName = src; lowerCaseName.toLowercase(); - files[lowerCaseName] = it->_value; + _files[lowerCaseName] = it->_value; } } void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { bool addArch = true; - Common::List::iterator it = archList.begin(); - while (it != archList.end()) { + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { if (*it == arch) { addArch = false; break; @@ -82,7 +82,7 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { it++; } if (addArch) - archList.push_back(arch); + _archList.push_back(arch); Common::String lowerCaseName = name; lowerCaseName.toLowercase(); @@ -91,10 +91,10 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { nod.name = lowerCaseName; nod.arch = arch; - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit == files.end()) { - files[lowerCaseName] = nod; + if (fit == _files.end()) { + _files[lowerCaseName] = nod; } else { Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); if (stream) { @@ -102,7 +102,7 @@ void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { fit->_value.arch = arch; delete stream; } else { - files[lowerCaseName] = nod; + _files[lowerCaseName] = nod; } } } @@ -111,9 +111,9 @@ Common::File *SearchManager::openFile(const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) { + if (fit != _files.end()) { Common::File *tmp = new Common::File(); tmp->open(fit->_value.name, *fit->_value.arch); return tmp; @@ -125,9 +125,9 @@ bool SearchManager::openFile(Common::File &file, const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) + if (fit != _files.end()) return file.open(fit->_value.name, *fit->_value.arch); return false; } @@ -136,9 +136,9 @@ bool SearchManager::hasFile(const Common::String &name) { Common::String lowerCaseName = name; lowerCaseName.toLowercase(); - SearchManager::MatchList::iterator fit = files.find(lowerCaseName); + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - if (fit != files.end()) + if (fit != _files.end()) return true; return false; } @@ -187,7 +187,7 @@ void SearchManager::loadZix(const Common::String &name) { if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') path.deleteLastChar(); if (path.size()) - for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) if (path.equalsIgnoreCase(*it)) { path = *it; break; @@ -220,7 +220,7 @@ void SearchManager::loadZix(const Common::String &name) { void SearchManager::addDir(const Common::String &name) { Common::String path; - for (Common::List::iterator it = dirList.begin(); it != dirList.end(); ++it) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) if (name.equalsIgnoreCase(*it)) { path = *it; break; diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h index 180102eac6..fdd70fd381 100644 --- a/engines/zvision/core/search_manager.h +++ b/engines/zvision/core/search_manager.h @@ -56,12 +56,12 @@ private: Common::Archive *arch; }; - Common::List dirList; + Common::List _dirList; typedef Common::HashMap MatchList; - Common::List archList; - MatchList files; + Common::List _archList; + MatchList _files; Common::String _root; -- cgit v1.2.3 From 7f61a094781256f7c2734aa08637494c1dfac6bf Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 00:48:16 +0200 Subject: ZVISION: Make the RLF decoder a subclass of the common video decoder This way, the redundant MetaAnimation class can now be removed --- engines/zvision/animation/meta_animation.cpp | 132 ------------ engines/zvision/animation/meta_animation.h | 98 --------- engines/zvision/module.mk | 1 - .../zvision/scripting/controls/fist_control.cpp | 14 +- engines/zvision/scripting/controls/fist_control.h | 8 +- .../zvision/scripting/controls/hotmov_control.cpp | 10 +- .../zvision/scripting/controls/hotmov_control.h | 8 +- .../zvision/scripting/controls/input_control.cpp | 14 +- engines/zvision/scripting/controls/input_control.h | 7 +- .../zvision/scripting/controls/lever_control.cpp | 8 +- engines/zvision/scripting/controls/lever_control.h | 9 +- .../zvision/scripting/controls/safe_control.cpp | 10 +- engines/zvision/scripting/controls/safe_control.h | 9 +- .../zvision/scripting/sidefx/animation_node.cpp | 10 +- engines/zvision/scripting/sidefx/animation_node.h | 11 +- engines/zvision/video/rlf_decoder.cpp | 141 ++++--------- engines/zvision/video/rlf_decoder.h | 224 +++++++++------------ engines/zvision/video/video.cpp | 20 ++ engines/zvision/zvision.h | 1 + 19 files changed, 222 insertions(+), 513 deletions(-) delete mode 100644 engines/zvision/animation/meta_animation.cpp delete mode 100644 engines/zvision/animation/meta_animation.h diff --git a/engines/zvision/animation/meta_animation.cpp b/engines/zvision/animation/meta_animation.cpp deleted file mode 100644 index 85b2e0f6b7..0000000000 --- a/engines/zvision/animation/meta_animation.cpp +++ /dev/null @@ -1,132 +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 "common/scummsys.h" - -#include "zvision/animation/meta_animation.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/video/rlf_decoder.h" -#include "zvision/video/zork_avi_decoder.h" - -#include "video/video_decoder.h" - -#include "graphics/surface.h" - -namespace ZVision { - -MetaAnimation::MetaAnimation(const Common::String &fileName, ZVision *engine) - : _fileType(RLF), - _curFrame(NULL) { - Common::String tmpFileName = fileName; - tmpFileName.toLowercase(); - if (tmpFileName.hasSuffix(".rlf")) { - _fileType = RLF; - Common::File *_file = engine->getSearchManager()->openFile(tmpFileName); - _animation.rlf = new RLFDecoder(_file, false); - _frmDelay = _animation.rlf->frameTime(); - } else if (tmpFileName.hasSuffix(".avi")) { - _fileType = AVI; - Common::File *_file = engine->getSearchManager()->openFile(tmpFileName); - _animation.avi = new ZorkAVIDecoder(); - _animation.avi->loadStream(_file); - _frmDelay = 1000.0 / _animation.avi->getDuration().framerate(); - } else { - warning("Unrecognized animation file type: %s", fileName.c_str()); - } -} - -MetaAnimation::~MetaAnimation() { - if (_fileType == RLF) { - delete _animation.rlf; - } else if (_fileType == AVI) { - delete _animation.avi; - } -} - -uint MetaAnimation::frameCount() { - if (_fileType == RLF) { - return _animation.rlf->frameCount(); - } else - return _animation.avi->getFrameCount(); - -} - -uint MetaAnimation::width() { - if (_fileType == RLF) { - return _animation.rlf->width(); - } else - return _animation.avi->getWidth(); -} -uint MetaAnimation::height() { - if (_fileType == RLF) { - return _animation.rlf->height(); - } else - return _animation.avi->getHeight(); -} -uint32 MetaAnimation::frameTime() { - return _frmDelay; -} - -void MetaAnimation::seekToFrame(int frameNumber) { - if (frameNumber >= (int)frameCount()) - frameNumber = frameCount() - 1; - - if (_fileType == RLF) { - _animation.rlf->seekToFrame(frameNumber); - } else - _animation.avi->seekToFrame(frameNumber); -} - -const Graphics::Surface *MetaAnimation::decodeNextFrame() { - if (_fileType == RLF) - _curFrame = _animation.rlf->decodeNextFrame(); - else - _curFrame = _animation.avi->decodeNextFrame(); - - return _curFrame; -} - -const Graphics::Surface *MetaAnimation::getFrameData(uint frameNumber) { - if (frameNumber >= frameCount()) - frameNumber = frameCount() - 1; - - if (_fileType == RLF) { - _curFrame = _animation.rlf->getFrameData(frameNumber); - return _curFrame; - } else { - _animation.avi->seekToFrame(frameNumber); - _curFrame = _animation.avi->decodeNextFrame(); - return _curFrame; - } -} - -bool MetaAnimation::endOfAnimation() { - if (_fileType == RLF) { - return _animation.rlf->endOfAnimation(); - } else - return _animation.avi->endOfVideo(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/animation/meta_animation.h b/engines/zvision/animation/meta_animation.h deleted file mode 100644 index 6d2025b2cf..0000000000 --- a/engines/zvision/animation/meta_animation.h +++ /dev/null @@ -1,98 +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 ZVISION_METAANIM_NODE_H -#define ZVISION_METAANIM_NODE_H - -#include "zvision/scripting/sidefx.h" -#include "zvision/zvision.h" -#include "common/rect.h" -#include "common/list.h" - -namespace Common { -class String; -} - -namespace Video { -class VideoDecoder; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; -class RLFDecoder; - -class MetaAnimation { -public: - MetaAnimation(const Common::String &fileName, ZVision *engine); - ~MetaAnimation(); - - struct playnode { - Common::Rect pos; - int32 slot; - int32 start; - int32 stop; - int32 loop; - int32 _curFrame; - int32 _delay; - Graphics::Surface *_scaled; - }; - -private: - enum FileType { - RLF = 1, - AVI = 2 - }; - -private: - union { - RLFDecoder *rlf; - Video::VideoDecoder *avi; - } _animation; - - FileType _fileType; - int32 _frmDelay; - - const Graphics::Surface *_curFrame; - -public: - - uint frameCount(); - uint width(); - uint height(); - uint32 frameTime(); - - void seekToFrame(int frameNumber); - - const Graphics::Surface *decodeNextFrame(); - const Graphics::Surface *getFrameData(uint frameNumber); - - bool endOfAnimation(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 5c2fd2045b..6ed3eee718 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -1,7 +1,6 @@ MODULE := engines/zvision MODULE_OBJS := \ - animation/meta_animation.o \ core/console.o \ core/events.o \ core/menu.o \ diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index dd6a7f11a9..c3a69084f2 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -22,20 +22,19 @@ #include "common/scummsys.h" -#include "zvision/scripting/controls/fist_control.h" - #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" +#include "zvision/scripting/controls/fist_control.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" -#include "zvision/animation/meta_animation.h" #include "zvision/utility/utility.h" +#include "zvision/video/rlf_decoder.h" #include "common/stream.h" #include "common/file.h" #include "common/system.h" - #include "graphics/surface.h" +#include "video/video_decoder.h" namespace ZVision { @@ -106,7 +105,8 @@ void FistControl::renderFrame(uint frameNumber) { const Graphics::Surface *frameData; if (_animation) { - frameData = _animation->getFrameData(frameNumber); + _animation->seekToFrame(frameNumber); + frameData = _animation->decodeNextFrame(); if (frameData) _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect); } @@ -121,7 +121,7 @@ bool FistControl::process(uint32 deltaTimeInMillis) { _frameTime -= deltaTimeInMillis; if (_frameTime <= 0) { - _frameTime = _animation->frameTime(); + _frameTime = 1000.0 / _animation->getDuration().framerate(); renderFrame(_frameCur); @@ -194,7 +194,7 @@ void FistControl::readDescFile(const Common::String &fileName) { if (param.matchString("animation_id", true)) { // Not used } else if (param.matchString("animation", true)) { - _animation = new MetaAnimation(values, _engine); + _animation = _engine->loadAnimation(values); } else if (param.matchString("anim_rect", true)) { int left, top, right, bottom; sscanf(values.c_str(), "%d %d %d %d", &left, &top, &right, &bottom); diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index cb765c429a..0a6b977ead 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -28,9 +28,11 @@ #include "common/array.h" #include "common/rect.h" -namespace ZVision { +namespace Video { + class VideoDecoder; +} -class MetaAnimation; +namespace ZVision { class FistControl : public Control { public: @@ -58,7 +60,7 @@ private: Common::Array _entries; - MetaAnimation *_animation; + Video::VideoDecoder *_animation; Common::Rect _anmRect; int32 _soundKey; int32 _frameCur; diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index 68861dc221..dfa0200f47 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -28,14 +28,13 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" -#include "zvision/animation/meta_animation.h" #include "zvision/utility/utility.h" #include "common/stream.h" #include "common/file.h" #include "common/system.h" - #include "graphics/surface.h" +#include "video/video_decoder.h" namespace ZVision { @@ -79,7 +78,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt char filename[64]; sscanf(values.c_str(), "%s", filename); values = Common::String(filename); - _animation = new MetaAnimation(values, _engine); + _animation = _engine->loadAnimation(values); } else if (param.matchString("venus_id", true)) { _venusId = atoi(values.c_str()); } @@ -106,7 +105,8 @@ void HotMovControl::renderFrame(uint frameNumber) { const Graphics::Surface *frameData; if (_animation) { - frameData = _animation->getFrameData(frameNumber); + _animation->seekToFrame(frameNumber); + frameData = _animation->decodeNextFrame(); if (frameData) _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle); } @@ -130,7 +130,7 @@ bool HotMovControl::process(uint32 deltaTimeInMillis) { else _engine->getScriptManager()->setStateValue(_key, 2); - _frameTime = _animation->frameTime(); + _frameTime = 1000.0 / _animation->getDuration().framerate(); } } diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index 86600d65dc..b18d44c7a6 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -28,9 +28,11 @@ #include "common/array.h" #include "common/rect.h" -namespace ZVision { +namespace Video { + class VideoDecoder; +} -class MetaAnimation; +namespace ZVision { class HotMovControl : public Control { public: @@ -44,7 +46,7 @@ private: int32 _lastRenderedFrame; int32 _cycle; int32 _cyclesCount; - MetaAnimation *_animation; + Video::VideoDecoder *_animation; Common::Rect _rectangle; Common::Array _frames; public: diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index c541693ec3..60dcd37453 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -34,6 +34,7 @@ #include "common/str.h" #include "common/stream.h" #include "common/rect.h" +#include "video/video_decoder.h" namespace ZVision { @@ -96,7 +97,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(values.c_str(), "%25s %*u", fileName); - _animation = new MetaAnimation(fileName, _engine); + _animation = _engine->loadAnimation(fileName); _frame = -1; _frameDelay = 0; } else if (param.matchString("focus", true)) { @@ -213,16 +214,17 @@ bool InputControl::process(uint32 deltaTimeInMillis) { bool needDraw = true;// = _textChanged; _frameDelay -= deltaTimeInMillis; if (_frameDelay <= 0) { - _frame = (_frame + 1) % _animation->frameCount(); - _frameDelay = _animation->frameTime(); + _frame = (_frame + 1) % _animation->getFrameCount(); + _frameDelay = 1000.0 / _animation->getDuration().framerate(); needDraw = true; } if (needDraw) { - const Graphics::Surface *srf = _animation->getFrameData(_frame); + _animation->seekToFrame(_frame); + const Graphics::Surface *srf = _animation->decodeNextFrame(); uint32 xx = _textRectangle.left + _txtWidth; - if (xx >= _textRectangle.left + (_textRectangle.width() - _animation->width())) - xx = _textRectangle.left + _textRectangle.width() - _animation->width(); + if (xx >= _textRectangle.left + (_textRectangle.width() - (int16)_animation->getWidth())) + xx = _textRectangle.left + _textRectangle.width() - (int16)_animation->getWidth(); _engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top); } } diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 410caf6d49..99f7f5287d 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -24,12 +24,15 @@ #define ZVISION_INPUT_CONTROL_H #include "zvision/scripting/control.h" -#include "zvision/animation/meta_animation.h" #include "zvision/text/text.h" #include "zvision/text/string_manager.h" #include "common/rect.h" +namespace Video { + class VideoDecoder; +} + namespace ZVision { class InputControl : public Control { @@ -51,7 +54,7 @@ private: bool _readOnly; int16 _txtWidth; - MetaAnimation *_animation; + Video::VideoDecoder *_animation; int32 _frameDelay; int16 _frame; diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 1e4087963e..9566e4e038 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -28,15 +28,14 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" -#include "zvision/animation/meta_animation.h" #include "zvision/utility/utility.h" #include "common/stream.h" #include "common/file.h" #include "common/tokenizer.h" #include "common/system.h" - #include "graphics/surface.h" +#include "video/video_decoder.h" namespace ZVision { @@ -106,7 +105,7 @@ void LeverControl::parseLevFile(const Common::String &fileName) { if (param.matchString("animation_id", true)) { // Not used } else if (param.matchString("filename", true)) { - _animation = new MetaAnimation(values, _engine); + _animation = _engine->loadAnimation(values); } else if (param.matchString("skipcolor", true)) { // Not used } else if (param.matchString("anim_coords", true)) { @@ -374,7 +373,8 @@ void LeverControl::renderFrame(uint frameNumber) { const Graphics::Surface *frameData; - frameData = _animation->getFrameData(frameNumber); + _animation->seekToFrame(frameNumber); + frameData = _animation->decodeNextFrame(); if (frameData) _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _animationCoords); } diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h index 37d4d3bd8d..fdf4a649dc 100644 --- a/engines/zvision/scripting/controls/lever_control.h +++ b/engines/zvision/scripting/controls/lever_control.h @@ -28,10 +28,11 @@ #include "common/list.h" #include "common/rect.h" -namespace ZVision { +namespace Video { + class VideoDecoder; +} -class ZorkAVIDecoder; -class MetaAnimation; +namespace ZVision { class LeverControl : public Control { public: @@ -59,7 +60,7 @@ private: }; private: - MetaAnimation *_animation; + Video::VideoDecoder *_animation; int _cursor; Common::Rect _animationCoords; diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 3ad5d3a8ae..9f4e29acae 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -28,15 +28,14 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/cursors/cursor_manager.h" -#include "zvision/animation/meta_animation.h" #include "zvision/utility/utility.h" #include "common/stream.h" #include "common/file.h" #include "common/tokenizer.h" #include "common/system.h" - #include "graphics/surface.h" +#include "video/video_decoder.h" namespace ZVision { @@ -65,7 +64,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream while (!stream.eos() && !line.contains('}')) { if (param.matchString("animation", true)) { - _animation = new MetaAnimation(values, _engine); + _animation = _engine->loadAnimation(values); } else if (param.matchString("rectangle", true)) { int x; int y; @@ -129,7 +128,8 @@ void SafeControl::renderFrame(uint frameNumber) { int x = _rectangle.left; int y = _rectangle.top; - frameData = _animation->getFrameData(frameNumber); + _animation->seekToFrame(frameNumber); + frameData = _animation->decodeNextFrame(); if (frameData) _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); } @@ -149,7 +149,7 @@ bool SafeControl::process(uint32 deltaTimeInMillis) { _curFrame--; renderFrame(_curFrame); } - _frameTime = _animation->frameTime(); + _frameTime = 1000.0 / _animation->getDuration().framerate(); } } return false; diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h index e32ca97b70..6e1095e304 100644 --- a/engines/zvision/scripting/controls/safe_control.h +++ b/engines/zvision/scripting/controls/safe_control.h @@ -28,10 +28,11 @@ #include "common/list.h" #include "common/rect.h" -namespace ZVision { +namespace Video { + class VideoDecoder; +} -class ZorkAVIDecoder; -class MetaAnimation; +namespace ZVision { class SafeControl : public Control { public: @@ -41,7 +42,7 @@ public: private: int16 _statesCount; int16 _curState; - MetaAnimation *_animation; + Video::VideoDecoder *_animation; Common::Point _center; Common::Rect _rectangle; int16 _innerRaduis; diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 74e4cadbe9..e15f8ec00f 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -27,9 +27,9 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/animation/meta_animation.h" #include "graphics/surface.h" +#include "video/video_decoder.h" namespace ZVision { @@ -39,8 +39,8 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _mask(mask), _animation(NULL) { - _animation = new MetaAnimation(fileName, engine); - _frmDelay = _animation->frameTime(); + _animation = engine->loadAnimation(fileName); + _frmDelay = 1000.0 / _animation->getDuration().framerate(); if (frate > 0) _frmDelay = 1000.0 / frate; @@ -164,8 +164,8 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.start = startFrame; nod.stop = endFrame; - if (nod.stop >= (int)_animation->frameCount()) - nod.stop = _animation->frameCount() - 1; + if (nod.stop >= (int)_animation->getFrameCount()) + nod.stop = _animation->getFrameCount() - 1; nod.slot = slot; nod._curFrame = -1; diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 94428d2542..3adfd91f32 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -27,18 +27,17 @@ #include "common/rect.h" #include "common/list.h" -namespace Common { -class String; -} - namespace Graphics { struct Surface; } +namespace Video { + class VideoDecoder; +} + namespace ZVision { class ZVision; -class MetaAnimation; class AnimationNode : public SideFX { public: @@ -64,7 +63,7 @@ private: int32 _mask; bool _DisposeAfterUse; - MetaAnimation *_animation; + Video::VideoDecoder *_animation; int32 _frmDelay; public: diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index a4f16af9b0..bdb5dc18bc 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -34,75 +34,46 @@ namespace ZVision { -RLFDecoder::RLFDecoder(const Common::String &fileName, bool stream) - : _stream(stream), - _readStream(NULL), - _lastFrameRead(0), - _frameCount(0), - _width(0), - _height(0), - _frameTime(0), - _frames(0), - _nextFrame(0), - _frameBufferByteSize(0) { - - Common::File *_file = new Common::File; - if (!_file->open(fileName)) { - warning("RLF animation file %s could not be opened", fileName.c_str()); - return; - } - - _readStream = _file; - - if (!readHeader()) { - warning("%s is not a RLF animation file. Wrong magic number", fileName.c_str()); - return; - } +RLFDecoder::~RLFDecoder() { + close(); +} - _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); - _frameBufferByteSize = _width * _height * sizeof(uint16); +bool RLFDecoder::loadStream(Common::SeekableReadStream *stream) { + close(); - if (!stream) { - _frames = new Frame[_frameCount]; + addTrack(new RLFVideoTrack(stream)); - // Read in each frame - for (uint i = 0; i < _frameCount; ++i) { - _frames[i] = readNextFrame(); - } - } + return true; } -RLFDecoder::RLFDecoder(Common::SeekableReadStream *rstream, bool stream) - : _stream(stream), - _readStream(rstream), +RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) + : _readStream(stream), _lastFrameRead(0), _frameCount(0), _width(0), _height(0), _frameTime(0), _frames(0), - _nextFrame(0), + _curFrame(0), _frameBufferByteSize(0) { if (!readHeader()) { - warning("Stream is not a RLF animation. Wrong magic number"); + warning("Not a RLF animation file. Wrong magic number"); return; } _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); _frameBufferByteSize = _width * _height * sizeof(uint16); - if (!stream) { - _frames = new Frame[_frameCount]; + _frames = new Frame[_frameCount]; - // Read in each frame - for (uint i = 0; i < _frameCount; ++i) { - _frames[i] = readNextFrame(); - } + // Read in each frame + for (uint i = 0; i < _frameCount; ++i) { + _frames[i] = readNextFrame(); } } -RLFDecoder::~RLFDecoder() { +RLFDecoder::RLFVideoTrack::~RLFVideoTrack() { for (uint i = 0; i < _frameCount; ++i) { delete[] _frames[i].encodedData; } @@ -111,7 +82,7 @@ RLFDecoder::~RLFDecoder() { _currentFrameBuffer.free(); } -bool RLFDecoder::readHeader() { +bool RLFDecoder::RLFVideoTrack::readHeader() { if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { return false; } @@ -160,8 +131,8 @@ bool RLFDecoder::readHeader() { return true; } -RLFDecoder::Frame RLFDecoder::readNextFrame() { - RLFDecoder::Frame frame; +RLFDecoder::RLFVideoTrack::Frame RLFDecoder::RLFVideoTrack::readNextFrame() { + RLFDecoder::RLFVideoTrack::Frame frame; _readStream->readUint32BE(); // Magic number MARF uint32 size = _readStream->readUint32LE(); // Size @@ -188,30 +159,30 @@ RLFDecoder::Frame RLFDecoder::readNextFrame() { return frame; } -void RLFDecoder::seekToFrame(int frameNumber) { - assert(!_stream); - assert(frameNumber < (int)_frameCount || frameNumber >= -1); +bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { + uint frame = getFrameAtTime(time); + assert(frame < (int)_frameCount); - if (_nextFrame == frameNumber) - return; + if ((uint)_curFrame == frame) + return true; - if (frameNumber < 0) { - _nextFrame = 0; - return; + if (frame < 0) { + _curFrame = 0; + return false; } - int closestFrame = _nextFrame; - int distance = (int)frameNumber - _nextFrame; + int closestFrame = _curFrame; + int distance = (int)frame - _curFrame; if (distance < 0) { for (uint i = 0; i < _completeFrames.size(); ++i) { - if ((int)_completeFrames[i] > frameNumber) + if ((int)_completeFrames[i] > frame) break; closestFrame = _completeFrames[i]; } } else { for (uint i = 0; i < _completeFrames.size(); ++i) { - int newDistance = (int)frameNumber - (int)(_completeFrames[i]); + int newDistance = (int)frame - (int)(_completeFrames[i]); if (newDistance < 0) break; if (newDistance < distance) { @@ -221,43 +192,27 @@ void RLFDecoder::seekToFrame(int frameNumber) { } } - for (int i = closestFrame; i < frameNumber; ++i) { + for (uint i = closestFrame; i < frame; ++i) { applyFrameToCurrent(i); } - _nextFrame = frameNumber; -} - -const Graphics::Surface *RLFDecoder::getFrameData(uint frameNumber) { - assert(!_stream); - assert(frameNumber < _frameCount); + _curFrame = frame; - // Since this method is so expensive, first check to see if we can use - // decodeNextFrame() it's cheap. - if ((int)frameNumber == _nextFrame - 1) { - return &_currentFrameBuffer; - } else if (_nextFrame == (int)frameNumber) { - return decodeNextFrame(); - } - - seekToFrame(frameNumber); - return decodeNextFrame(); + return true; } -const Graphics::Surface *RLFDecoder::decodeNextFrame() { - assert(_nextFrame < (int)_frameCount); +const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() { + // When an animation ends, rewind + if (_curFrame == (int)_frameCount) + seek(Audio::Timestamp(0, getFrameRate().toInt())); + + applyFrameToCurrent(_curFrame); - if (_stream) { - applyFrameToCurrent(readNextFrame()); - } else { - applyFrameToCurrent(_nextFrame); - } - - _nextFrame++; + _curFrame++; return &_currentFrameBuffer; } -void RLFDecoder::applyFrameToCurrent(uint frameNumber) { +void RLFDecoder::RLFVideoTrack::applyFrameToCurrent(uint frameNumber) { if (_frames[frameNumber].type == Masked) { decodeMaskedRunLengthEncoding(_frames[frameNumber].encodedData, (int8 *)_currentFrameBuffer.getPixels(), _frames[frameNumber].encodedSize, _frameBufferByteSize); } else if (_frames[frameNumber].type == Simple) { @@ -265,15 +220,7 @@ void RLFDecoder::applyFrameToCurrent(uint frameNumber) { } } -void RLFDecoder::applyFrameToCurrent(const RLFDecoder::Frame &frame) { - if (frame.type == Masked) { - decodeMaskedRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); - } else if (frame.type == Simple) { - decodeSimpleRunLengthEncoding(frame.encodedData, (int8 *)_currentFrameBuffer.getPixels(), frame.encodedSize, _frameBufferByteSize); - } -} - -void RLFDecoder::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { +void RLFDecoder::RLFVideoTrack::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; int16 numberOfCopy = 0; @@ -320,7 +267,7 @@ void RLFDecoder::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 } } -void RLFDecoder::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { +void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const { uint32 sourceOffset = 0; uint32 destOffset = 0; int16 numberOfCopy = 0; diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h index dcfd8606c2..f0f31c2128 100644 --- a/engines/zvision/video/rlf_decoder.h +++ b/engines/zvision/video/rlf_decoder.h @@ -24,147 +24,109 @@ #define ZVISION_RLF_DECODER_H #include "common/file.h" +#include "video/video_decoder.h" #include "graphics/surface.h" -namespace Common { -class String; -} - namespace ZVision { -class RLFDecoder { +class RLFDecoder : public Video::VideoDecoder { public: - RLFDecoder(const Common::String &fileName, bool stream = true); - RLFDecoder(Common::SeekableReadStream *rstream, bool stream); + RLFDecoder() {} ~RLFDecoder(); -private: - enum EncodingType { - Masked, - Simple - }; - - struct Frame { - EncodingType type; - int8 *encodedData; - uint32 encodedSize; - }; - -private: - Common::SeekableReadStream *_readStream; - bool _stream; - uint _lastFrameRead; - - uint _frameCount; - uint _width; - uint _height; - uint32 _frameTime; // In milliseconds - Frame *_frames; - Common::Array _completeFrames; - - int _nextFrame; - Graphics::Surface _currentFrameBuffer; - uint32 _frameBufferByteSize; - -public: - uint frameCount() { - return _frameCount; - } - uint width() { - return _width; - } - uint height() { - return _height; - } - uint32 frameTime() { - return _frameTime; - } - - /** - * Seeks to the frameNumber and updates the internal Surface with - * the new frame data. If frameNumber == -1, it only sets _currentFrame, - * the internal Surface is unchanged. This function requires _stream = false - * - * @param frameNumber The frame number to seek to - */ - void seekToFrame(int frameNumber); - - /** - * Returns the pixel data of the frame specified. It will try to use - * decodeNextFrame() if possible. If not, it uses seekToFrame() to - * update the internal Surface and then returns a pointer to it. - * This function requires _stream = false - * - * @param frameNumber The frame number to get data for - * @return A pointer to the pixel data. Do NOT delete this. - */ - const Graphics::Surface *getFrameData(uint frameNumber); - /** - * Returns the pixel data of current frame and go to next. It is up to the user to - * check if the current frame is valid before calling this. - * IE. Use endOfAnimation() - * - * @return A pointer to the pixel data. Do NOT delete this. - */ - const Graphics::Surface *decodeNextFrame(); - /** - * @return Is the currentFrame is the last frame in the animation? - */ - bool endOfAnimation() { - return _nextFrame == (int)_frameCount; - } + bool loadStream(Common::SeekableReadStream *stream); private: - /** - * Reads in the header of the RLF file - * - * @return Will return false if the header magic number is wrong - */ - bool readHeader(); - /** - * Reads the next frame from the RLF file, stores the data in - * a Frame object, then returns the object - * - * @return A Frame object representing the frame data - */ - Frame readNextFrame(); - - /** - * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer. - * This function requires _stream = false so it can look up the Frame object - * referenced by frameNumber. - * - * @param frameNumber The frame number to apply to _currentFrameBuffer - */ - void applyFrameToCurrent(uint frameNumber); - /** - * Applies the data from a Frame object on top of a _currentFrameBuffer. - * - * @param frame A Frame object to apply to _currentFrameBuffer - */ - void applyFrameToCurrent(const RLFDecoder::Frame &frame); - - /** - * Decode frame data that uses masked run length encoding. This is the encoding - * used by P-frames. - * - * @param source The source pixel data - * @param dest The destination buffer - * @param sourceSize The size of the source pixel data - * @param destSize The size of the destination buffer - */ - void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; - /** - * Decode frame data that uses simple run length encoding. This is the encoding - * used by I-frames. - * - * @param source The source pixel data - * @param dest The destination buffer - * @param sourceSize The size of the source pixel data - * @param destSize The size of the destination buffer - */ - void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; + class RLFVideoTrack : public FixedRateVideoTrack { + public: + RLFVideoTrack(Common::SeekableReadStream *stream); + ~RLFVideoTrack(); + + uint16 getWidth() const { return _width; } + uint16 getHeight() const { return _height; } + Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); /*RGB 565*/ } + int getCurFrame() const { return _curFrame; } + int getFrameCount() const { return _frameCount; } + const Graphics::Surface *decodeNextFrame(); + bool isSeekable() const { return true; } + bool seek(const Audio::Timestamp &time); + + protected: + Common::Rational getFrameRate() const { return Common::Rational(60, _frameTime); } + + private: + enum EncodingType { + Masked, + Simple + }; + + struct Frame { + EncodingType type; + int8 *encodedData; + uint32 encodedSize; + }; + + /** + * Reads in the header of the RLF file + * + * @return Will return false if the header magic number is wrong + */ + bool readHeader(); + + /** + * Reads the next frame from the RLF file, stores the data in + * a Frame object, then returns the object + * + * @return A Frame object representing the frame data + */ + Frame readNextFrame(); + + /** + * Applies the frame corresponding to frameNumber on top of _currentFrameBuffer. + * This function requires _stream = false so it can look up the Frame object + * referenced by frameNumber. + * + * @param frameNumber The frame number to apply to _currentFrameBuffer + */ + void applyFrameToCurrent(uint frameNumber); + + /** + * Decode frame data that uses masked run length encoding. This is the encoding + * used by P-frames. + * + * @param source The source pixel data + * @param dest The destination buffer + * @param sourceSize The size of the source pixel data + * @param destSize The size of the destination buffer + */ + void decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; + /** + * Decode frame data that uses simple run length encoding. This is the encoding + * used by I-frames. + * + * @param source The source pixel data + * @param dest The destination buffer + * @param sourceSize The size of the source pixel data + * @param destSize The size of the destination buffer + */ + void decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const; + + uint _lastFrameRead; + + uint _frameCount; + uint _width; + uint _height; + uint32 _frameTime; // In milliseconds + Frame *_frames; + Common::Array _completeFrames; + + int _curFrame; + Graphics::Surface _currentFrameBuffer; + uint32 _frameBufferByteSize; + + Common::SeekableReadStream *_readStream; + }; // RLFVideoTrack }; } // End of namespace ZVision diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index db6161bf0c..c8f968d975 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -30,9 +30,29 @@ #include "zvision/utility/clock.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/subtitles.h" +#include "zvision/video/rlf_decoder.h" +#include "zvision/video/zork_avi_decoder.h" namespace ZVision { +Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { + Common::String tmpFileName = fileName; + tmpFileName.toLowercase(); + Video::VideoDecoder *animation = NULL; + + if (tmpFileName.hasSuffix(".rlf")) + animation = new RLFDecoder(); + else if (tmpFileName.hasSuffix(".avi")) + animation = new ZorkAVIDecoder(); + else + error("Unknown suffix for animation %s", fileName.c_str()); + + Common::File *_file = getSearchManager()->openFile(tmpFileName); + animation->loadStream(_file); + + return animation; +} + void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, bool skippable, Subtitle *sub) { Common::Rect dst = destRect; // If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index f8763f94ee..82030e6944 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -173,6 +173,7 @@ public: * @param skippable If true, the video can be skipped at any time using [Spacebar] */ void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL); + Video::VideoDecoder *loadAnimation(const Common::String &fileName); void rotateTo(int16 to, int16 time); -- cgit v1.2.3 From 4b2b5e686b6ac2105f11983b2072037358d9ad7f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:00:50 +0200 Subject: ZVISION: Move the mouse cursor handling code into the graphics code --- engines/zvision/core/console.cpp | 2 +- engines/zvision/core/events.cpp | 2 +- engines/zvision/cursors/cursor.cpp | 122 ----------------- engines/zvision/cursors/cursor.h | 79 ----------- engines/zvision/cursors/cursor_manager.cpp | 152 --------------------- engines/zvision/cursors/cursor_manager.h | 134 ------------------ engines/zvision/graphics/cursors/cursor.cpp | 122 +++++++++++++++++ engines/zvision/graphics/cursors/cursor.h | 79 +++++++++++ .../zvision/graphics/cursors/cursor_manager.cpp | 152 +++++++++++++++++++++ engines/zvision/graphics/cursors/cursor_manager.h | 134 ++++++++++++++++++ engines/zvision/module.mk | 4 +- engines/zvision/scripting/actions.cpp | 2 +- .../zvision/scripting/controls/fist_control.cpp | 2 +- .../zvision/scripting/controls/hotmov_control.cpp | 2 +- .../zvision/scripting/controls/input_control.cpp | 2 +- .../zvision/scripting/controls/lever_control.cpp | 2 +- .../zvision/scripting/controls/paint_control.cpp | 2 +- .../scripting/controls/push_toggle_control.cpp | 2 +- .../zvision/scripting/controls/safe_control.cpp | 2 +- .../zvision/scripting/controls/slot_control.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- engines/zvision/zvision.cpp | 2 +- 22 files changed, 502 insertions(+), 502 deletions(-) delete mode 100644 engines/zvision/cursors/cursor.cpp delete mode 100644 engines/zvision/cursors/cursor.h delete mode 100644 engines/zvision/cursors/cursor_manager.cpp delete mode 100644 engines/zvision/cursors/cursor_manager.h create mode 100644 engines/zvision/graphics/cursors/cursor.cpp create mode 100644 engines/zvision/graphics/cursors/cursor.h create mode 100644 engines/zvision/graphics/cursors/cursor_manager.cpp create mode 100644 engines/zvision/graphics/cursors/cursor_manager.h diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 0f6cbfc96f..76481a3549 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -31,7 +31,7 @@ #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" #include "zvision/utility/utility.h" -#include "zvision/cursors/cursor.h" +#include "zvision/graphics/cursors/cursor.h" #include "common/system.h" #include "common/file.h" diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 839f919ad6..c66e61a61a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -25,7 +25,7 @@ #include "zvision/zvision.h" #include "zvision/core/console.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" #include "zvision/core/menu.h" diff --git a/engines/zvision/cursors/cursor.cpp b/engines/zvision/cursors/cursor.cpp deleted file mode 100644 index b07220df92..0000000000 --- a/engines/zvision/cursors/cursor.cpp +++ /dev/null @@ -1,122 +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 "common/scummsys.h" - -#include "zvision/cursors/cursor.h" - -#include "common/str.h" -#include "common/file.h" - -namespace ZVision { - -ZorkCursor::ZorkCursor() - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { -} - -ZorkCursor::ZorkCursor(const Common::String &fileName) - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { - Common::File file; - if (!file.open(fileName)) - return; - - uint32 magic = file.readUint32BE(); - if (magic != MKTAG('Z', 'C', 'R', '1')) { - warning("%s is not a Zork Cursor file", fileName.c_str()); - return; - } - - _hotspotX = file.readUint16LE(); - _hotspotY = file.readUint16LE(); - _width = file.readUint16LE(); - _height = file.readUint16LE(); - - uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); - uint32 bytesRead = file.read(_surface.getPixels(), dataSize); - assert(bytesRead == dataSize); - - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); -} - -ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { - Common::File file; - if (!engine->getSearchManager()->openFile(file, fileName)) - return; - - uint32 magic = file.readUint32BE(); - if (magic != MKTAG('Z', 'C', 'R', '1')) { - warning("%s is not a Zork Cursor file", fileName.c_str()); - return; - } - - _hotspotX = file.readUint16LE(); - _hotspotY = file.readUint16LE(); - _width = file.readUint16LE(); - _height = file.readUint16LE(); - - uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); - uint32 bytesRead = file.read(_surface.getPixels(), dataSize); - assert(bytesRead == dataSize); - - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); -} - -ZorkCursor::ZorkCursor(const ZorkCursor &other) { - _width = other._width; - _height = other._height; - _hotspotX = other._hotspotX; - _hotspotY = other._hotspotY; - - _surface.copyFrom(other._surface); -} - -ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) { - _width = other._width; - _height = other._height; - _hotspotX = other._hotspotX; - _hotspotY = other._hotspotY; - - _surface.free(); - _surface.copyFrom(other._surface); - - return *this; -} - -ZorkCursor::~ZorkCursor() { - _surface.free(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/cursors/cursor.h b/engines/zvision/cursors/cursor.h deleted file mode 100644 index 0c1e99411f..0000000000 --- a/engines/zvision/cursors/cursor.h +++ /dev/null @@ -1,79 +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 ZVISION_CURSOR_H -#define ZVISION_CURSOR_H - -#include "graphics/surface.h" -#include "zvision/zvision.h" - -namespace Common { -class String; -} - -namespace ZVision { - -/** - * Utility class to parse and hold cursor data - * Modeled off Graphics::Cursor - */ -class ZorkCursor { -public: - ZorkCursor(); - ZorkCursor(const Common::String &fileName); - ZorkCursor(ZVision *engine, const Common::String &fileName); - ZorkCursor(const ZorkCursor &other); - ~ZorkCursor(); - -private: - uint16 _width; - uint16 _height; - uint16 _hotspotX; - uint16 _hotspotY; - Graphics::Surface _surface; - -public: - ZorkCursor &operator=(const ZorkCursor &other); - - uint16 getWidth() const { - return _width; - } - uint16 getHeight() const { - return _height; - } - uint16 getHotspotX() const { - return _hotspotX; - } - uint16 getHotspotY() const { - return _hotspotY; - } - byte getKeyColor() const { - return 0; - } - const byte *getSurface() const { - return (const byte *)_surface.getPixels(); - } -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/cursors/cursor_manager.cpp b/engines/zvision/cursors/cursor_manager.cpp deleted file mode 100644 index 33fb55515b..0000000000 --- a/engines/zvision/cursors/cursor_manager.cpp +++ /dev/null @@ -1,152 +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 "common/scummsys.h" - -#include "zvision/cursors/cursor_manager.h" - -#include "zvision/zvision.h" - -#include "common/system.h" - -#include "graphics/pixelformat.h" -#include "graphics/cursorman.h" - -namespace ZVision { - -const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" - }; - -const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", - "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" - }; - -const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft", - "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" - }; - -CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) - : _engine(engine), - _pixelFormat(pixelFormat), - _cursorIsPushed(false), - _item(0), - _lastitem(0) { - for (int i = 0; i < NUM_CURSORS; i++) { - if (_engine->getGameId() == GID_NEMESIS) { - Common::String name; - name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); - _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor - name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); - _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor - } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor - char buffer[25]; - strcpy(buffer, _zgiCursorFileNames[i]); - buffer[3] += 2; - _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor - } - } -} - -void CursorManager::setItemID(int id) { - if (id != _item) { - if (id) { - Common::String file; - if (_engine->getGameId() == GID_NEMESIS) { - file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a'); - _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); - file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b'); - _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); - file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a'); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); - file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b'); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); - } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { - file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id); - _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); - file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id); - _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); - file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id); - _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); - file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id); - _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file); - } else - return; - } - _item = id; - changeCursor(CursorIndex_Idle); - } -} - -void CursorManager::initialize() { - changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]); - showMouse(true); -} - -void CursorManager::changeCursor(const ZorkCursor &cursor) { - CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat); -} - -void CursorManager::cursorDown(bool pushed) { - if (_cursorIsPushed == pushed) - return; - - _cursorIsPushed = pushed; - - changeCursor(_cursors[_currentCursor][_cursorIsPushed]); -} - -void CursorManager::changeCursor(int id) { - int _id = id; - - if (_item && - (_id == CursorIndex_Active || - _id == CursorIndex_Idle || - _id == CursorIndex_HandPu)) { - - if (_id == CursorIndex_Idle) - _id = CursorIndex_ItemIdle; - else - _id = CursorIndex_ItemAct; - } - - if (_currentCursor != _id || - ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) { - _currentCursor = _id; - _lastitem = _item; - changeCursor(_cursors[_currentCursor][_cursorIsPushed]); - } -} - -int CursorManager::getCursorId(const Common::String &name) { - for (int i = 0; i < NUM_CURSORS; i++) - if (name.equals(_cursorNames[i])) - return i; - return CursorIndex_Idle; -} - -void CursorManager::showMouse(bool vis) { - CursorMan.showMouse(vis); -} - -} // End of namespace ZVision diff --git a/engines/zvision/cursors/cursor_manager.h b/engines/zvision/cursors/cursor_manager.h deleted file mode 100644 index 460f6fade6..0000000000 --- a/engines/zvision/cursors/cursor_manager.h +++ /dev/null @@ -1,134 +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 ZVISION_CURSOR_MANAGER_H -#define ZVISION_CURSOR_MANAGER_H - -#include "zvision/cursors/cursor.h" - -#include "common/str.h" - -namespace Graphics { -struct PixelFormat; -} - -namespace ZVision { - -class ZVision; - -/** - * Mostly usable cursors - */ -enum CursorIndex { - CursorIndex_Active = 0, - CursorIndex_DownArr = 3, - CursorIndex_HandPu = 6, - CursorIndex_Idle = 11, - CursorIndex_Left = 12, - CursorIndex_Right = 13, - CursorIndex_UpArr = 17, - CursorIndex_ItemIdle = 18, - CursorIndex_ItemAct = 19 -}; - -/** - * Class to manage cursor changes. The actual changes have to be done - * through CursorMan. Otherwise the cursor will disappear after GMM - * or debug console. - * TODO: Figure out a way to get rid of the extraneous data copying due to having to use CursorMan - */ -class CursorManager { -public: - CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat); - -private: - static const int NUM_CURSORS = 18; - - // 18 default cursors in up/down states, +2 for items idle/act cursors - ZorkCursor _cursors[NUM_CURSORS + 2][2]; - - ZVision *_engine; - const Graphics::PixelFormat *_pixelFormat; - bool _cursorIsPushed; - int _item; - int _lastitem; - int _currentCursor; - - static const char *_cursorNames[]; - static const char *_zgiCursorFileNames[]; - static const char *_zNemCursorFileNames[]; - -public: - /** Creates the idle cursor and shows it */ - void initialize(); - - /** - * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item. - * - * @param id Wanted cursor id. - */ - - void changeCursor(int id); - - /** - * Return founded id for string contains cursor name - * - * @param name Cursor name - * @return Id of cursor or idle cursor id if not found - */ - - int getCursorId(const Common::String &name); - - /** - * Load cursor for item by id, and try to change cursor to item cursor if it's not 0 - * - * @param id Item id or 0 for no item cursor - */ - - void setItemID(int id); - - /** - * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen. - * - * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) - */ - void cursorDown(bool pushed); - - /** - * Show or hide mouse cursor. - * - * @param vis Should the cursor be showed (true) or hide (false) - */ - void showMouse(bool vis); - -private: - /** - * Calls CursorMan.replaceCursor() using the data in cursor - * - * @param cursor The cursor to show - */ - void changeCursor(const ZorkCursor &cursor); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp new file mode 100644 index 0000000000..07323b45c4 --- /dev/null +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -0,0 +1,122 @@ +/* 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 "common/scummsys.h" + +#include "zvision/graphics/cursors/cursor.h" + +#include "common/str.h" +#include "common/file.h" + +namespace ZVision { + +ZorkCursor::ZorkCursor() + : _width(0), + _height(0), + _hotspotX(0), + _hotspotY(0) { +} + +ZorkCursor::ZorkCursor(const Common::String &fileName) + : _width(0), + _height(0), + _hotspotX(0), + _hotspotY(0) { + Common::File file; + if (!file.open(fileName)) + return; + + uint32 magic = file.readUint32BE(); + if (magic != MKTAG('Z', 'C', 'R', '1')) { + warning("%s is not a Zork Cursor file", fileName.c_str()); + return; + } + + _hotspotX = file.readUint16LE(); + _hotspotY = file.readUint16LE(); + _width = file.readUint16LE(); + _height = file.readUint16LE(); + + uint dataSize = _width * _height * sizeof(uint16); + _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + uint32 bytesRead = file.read(_surface.getPixels(), dataSize); + assert(bytesRead == dataSize); + + // Convert to RGB 565 + _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); +} + +ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) + : _width(0), + _height(0), + _hotspotX(0), + _hotspotY(0) { + Common::File file; + if (!engine->getSearchManager()->openFile(file, fileName)) + return; + + uint32 magic = file.readUint32BE(); + if (magic != MKTAG('Z', 'C', 'R', '1')) { + warning("%s is not a Zork Cursor file", fileName.c_str()); + return; + } + + _hotspotX = file.readUint16LE(); + _hotspotY = file.readUint16LE(); + _width = file.readUint16LE(); + _height = file.readUint16LE(); + + uint dataSize = _width * _height * sizeof(uint16); + _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + uint32 bytesRead = file.read(_surface.getPixels(), dataSize); + assert(bytesRead == dataSize); + + // Convert to RGB 565 + _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); +} + +ZorkCursor::ZorkCursor(const ZorkCursor &other) { + _width = other._width; + _height = other._height; + _hotspotX = other._hotspotX; + _hotspotY = other._hotspotY; + + _surface.copyFrom(other._surface); +} + +ZorkCursor &ZorkCursor::operator=(const ZorkCursor &other) { + _width = other._width; + _height = other._height; + _hotspotX = other._hotspotX; + _hotspotY = other._hotspotY; + + _surface.free(); + _surface.copyFrom(other._surface); + + return *this; +} + +ZorkCursor::~ZorkCursor() { + _surface.free(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/cursors/cursor.h b/engines/zvision/graphics/cursors/cursor.h new file mode 100644 index 0000000000..0c1e99411f --- /dev/null +++ b/engines/zvision/graphics/cursors/cursor.h @@ -0,0 +1,79 @@ +/* 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 ZVISION_CURSOR_H +#define ZVISION_CURSOR_H + +#include "graphics/surface.h" +#include "zvision/zvision.h" + +namespace Common { +class String; +} + +namespace ZVision { + +/** + * Utility class to parse and hold cursor data + * Modeled off Graphics::Cursor + */ +class ZorkCursor { +public: + ZorkCursor(); + ZorkCursor(const Common::String &fileName); + ZorkCursor(ZVision *engine, const Common::String &fileName); + ZorkCursor(const ZorkCursor &other); + ~ZorkCursor(); + +private: + uint16 _width; + uint16 _height; + uint16 _hotspotX; + uint16 _hotspotY; + Graphics::Surface _surface; + +public: + ZorkCursor &operator=(const ZorkCursor &other); + + uint16 getWidth() const { + return _width; + } + uint16 getHeight() const { + return _height; + } + uint16 getHotspotX() const { + return _hotspotX; + } + uint16 getHotspotY() const { + return _hotspotY; + } + byte getKeyColor() const { + return 0; + } + const byte *getSurface() const { + return (const byte *)_surface.getPixels(); + } +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp new file mode 100644 index 0000000000..a20deb26b5 --- /dev/null +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -0,0 +1,152 @@ +/* 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 "common/scummsys.h" + +#include "zvision/graphics/cursors/cursor_manager.h" + +#include "zvision/zvision.h" + +#include "common/system.h" + +#include "graphics/pixelformat.h" +#include "graphics/cursorman.h" + +namespace ZVision { + +const char *CursorManager::_cursorNames[NUM_CURSORS] = { "active", "arrow", "backward", "downarrow", "forward", "handpt", "handpu", "hdown", "hleft", + "hright", "hup", "idle", "leftarrow", "rightarrow", "suggest_surround", "suggest_tilt", "turnaround", "zuparrow" + }; + +const char *CursorManager::_zgiCursorFileNames[NUM_CURSORS] = { "g0gbc011.zcr", "g0gac001.zcr", "g0gac021.zcr", "g0gac031.zcr", "g0gac041.zcr", "g0gac051.zcr", "g0gac061.zcr", "g0gac071.zcr", "g0gac081.zcr", + "g0gac091.zcr", "g0gac101.zcr", "g0gac011.zcr", "g0gac111.zcr", "g0gac121.zcr", "g0gac131.zcr", "g0gac141.zcr", "g0gac151.zcr", "g0gac161.zcr" + }; + +const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow", "back", "down", "forw", "handpt", "handpu", "hdown", "hleft", + "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" + }; + +CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) + : _engine(engine), + _pixelFormat(pixelFormat), + _cursorIsPushed(false), + _item(0), + _lastitem(0) { + for (int i = 0; i < NUM_CURSORS; i++) { + if (_engine->getGameId() == GID_NEMESIS) { + Common::String name; + name = Common::String::format("%sa.zcr", _zNemCursorFileNames[i]); + _cursors[i][0] = ZorkCursor(_engine, name); // Up cursor + name = Common::String::format("%sb.zcr", _zNemCursorFileNames[i]); + _cursors[i][1] = ZorkCursor(_engine, name); // Down cursor + } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { + _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor + char buffer[25]; + strcpy(buffer, _zgiCursorFileNames[i]); + buffer[3] += 2; + _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor + } + } +} + +void CursorManager::setItemID(int id) { + if (id != _item) { + if (id) { + Common::String file; + if (_engine->getGameId() == GID_NEMESIS) { + file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'a'); + _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); + file = Common::String::format("%2.2d%s%c.zcr", id, "idle", 'b'); + _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); + file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'a'); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); + file = Common::String::format("%2.2d%s%c.zcr", id, "act", 'b'); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); + } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { + file = Common::String::format("g0b%cc%2.2x1.zcr", 'a' , id); + _cursors[NUM_CURSORS][0] = ZorkCursor(_engine, file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'c' , id); + _cursors[NUM_CURSORS][1] = ZorkCursor(_engine, file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'b' , id); + _cursors[NUM_CURSORS + 1][0] = ZorkCursor(_engine, file); + file = Common::String::format("g0b%cc%2.2x1.zcr", 'd' , id); + _cursors[NUM_CURSORS + 1][1] = ZorkCursor(_engine, file); + } else + return; + } + _item = id; + changeCursor(CursorIndex_Idle); + } +} + +void CursorManager::initialize() { + changeCursor(_cursors[CursorIndex_Idle][_cursorIsPushed]); + showMouse(true); +} + +void CursorManager::changeCursor(const ZorkCursor &cursor) { + CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat); +} + +void CursorManager::cursorDown(bool pushed) { + if (_cursorIsPushed == pushed) + return; + + _cursorIsPushed = pushed; + + changeCursor(_cursors[_currentCursor][_cursorIsPushed]); +} + +void CursorManager::changeCursor(int id) { + int _id = id; + + if (_item && + (_id == CursorIndex_Active || + _id == CursorIndex_Idle || + _id == CursorIndex_HandPu)) { + + if (_id == CursorIndex_Idle) + _id = CursorIndex_ItemIdle; + else + _id = CursorIndex_ItemAct; + } + + if (_currentCursor != _id || + ((_id == CursorIndex_ItemAct || _id == CursorIndex_ItemIdle) && _lastitem != _item)) { + _currentCursor = _id; + _lastitem = _item; + changeCursor(_cursors[_currentCursor][_cursorIsPushed]); + } +} + +int CursorManager::getCursorId(const Common::String &name) { + for (int i = 0; i < NUM_CURSORS; i++) + if (name.equals(_cursorNames[i])) + return i; + return CursorIndex_Idle; +} + +void CursorManager::showMouse(bool vis) { + CursorMan.showMouse(vis); +} + +} // End of namespace ZVision diff --git a/engines/zvision/graphics/cursors/cursor_manager.h b/engines/zvision/graphics/cursors/cursor_manager.h new file mode 100644 index 0000000000..bbfa085c23 --- /dev/null +++ b/engines/zvision/graphics/cursors/cursor_manager.h @@ -0,0 +1,134 @@ +/* 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 ZVISION_CURSOR_MANAGER_H +#define ZVISION_CURSOR_MANAGER_H + +#include "zvision/graphics/cursors/cursor.h" + +#include "common/str.h" + +namespace Graphics { +struct PixelFormat; +} + +namespace ZVision { + +class ZVision; + +/** + * Mostly usable cursors + */ +enum CursorIndex { + CursorIndex_Active = 0, + CursorIndex_DownArr = 3, + CursorIndex_HandPu = 6, + CursorIndex_Idle = 11, + CursorIndex_Left = 12, + CursorIndex_Right = 13, + CursorIndex_UpArr = 17, + CursorIndex_ItemIdle = 18, + CursorIndex_ItemAct = 19 +}; + +/** + * Class to manage cursor changes. The actual changes have to be done + * through CursorMan. Otherwise the cursor will disappear after GMM + * or debug console. + * TODO: Figure out a way to get rid of the extraneous data copying due to having to use CursorMan + */ +class CursorManager { +public: + CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat); + +private: + static const int NUM_CURSORS = 18; + + // 18 default cursors in up/down states, +2 for items idle/act cursors + ZorkCursor _cursors[NUM_CURSORS + 2][2]; + + ZVision *_engine; + const Graphics::PixelFormat *_pixelFormat; + bool _cursorIsPushed; + int _item; + int _lastitem; + int _currentCursor; + + static const char *_cursorNames[]; + static const char *_zgiCursorFileNames[]; + static const char *_zNemCursorFileNames[]; + +public: + /** Creates the idle cursor and shows it */ + void initialize(); + + /** + * Change cursor to specified cursor ID. If item setted to not 0 and cursor id idle/acrive/handpu change cursor to item. + * + * @param id Wanted cursor id. + */ + + void changeCursor(int id); + + /** + * Return founded id for string contains cursor name + * + * @param name Cursor name + * @return Id of cursor or idle cursor id if not found + */ + + int getCursorId(const Common::String &name); + + /** + * Load cursor for item by id, and try to change cursor to item cursor if it's not 0 + * + * @param id Item id or 0 for no item cursor + */ + + void setItemID(int id); + + /** + * Change the cursor to a certain push state. If the cursor is already in the specified push state, nothing will happen. + * + * @param pushed Should the cursor be pushed (true) or not pushed (false) (Another way to say it: down or up) + */ + void cursorDown(bool pushed); + + /** + * Show or hide mouse cursor. + * + * @param vis Should the cursor be showed (true) or hide (false) + */ + void showMouse(bool vis); + +private: + /** + * Calls CursorMan.replaceCursor() using the data in cursor + * + * @param cursor The cursor to show + */ + void changeCursor(const ZorkCursor &cursor); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 6ed3eee718..604b697ec7 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -7,9 +7,9 @@ MODULE_OBJS := \ core/midi.o \ core/save_manager.o \ core/search_manager.o \ - cursors/cursor_manager.o \ - cursors/cursor.o \ detection.o \ + graphics/cursors/cursor_manager.o \ + graphics/cursors/cursor.o \ graphics/effects/fog.o \ graphics/effects/light.o \ graphics/effects/wave.o \ diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index c8c82063f7..d6883ed38f 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -43,7 +43,7 @@ #include "zvision/graphics/effects/light.h" #include "zvision/graphics/effects/wave.h" #include "zvision/core/save_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index c3a69084f2..887ad7950d 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -26,7 +26,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/scripting/controls/fist_control.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/utility/utility.h" #include "zvision/video/rlf_decoder.h" diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index dfa0200f47..b2c9cdd577 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 60dcd37453..1b15eacd78 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -23,7 +23,7 @@ #include "common/scummsys.h" #include "zvision/scripting/controls/input_control.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 9566e4e038..07eec1fb63 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index 9bad6f2c58..0ef7618b5b 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index c5ec070899..fcd8cd0356 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 9f4e29acae..8135eb34cc 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/utility/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 1d83b44392..7f04c2d311 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index c532a2b15d..c735fe6eb0 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" #include "zvision/scripting/actions.h" #include "zvision/utility/utility.h" diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index ec1fb9413b..34fe0794bd 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -26,7 +26,7 @@ #include "zvision/core/console.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/cursors/cursor_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" #include "zvision/text/string_manager.h" #include "zvision/detection.h" -- cgit v1.2.3 From 2463b4580436b41a46500e53b4868789c9c7b21e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:05:01 +0200 Subject: ZVISION: Move the MIDI code together with the rest of the sound code --- engines/zvision/core/midi.cpp | 89 ------------------------- engines/zvision/core/midi.h | 59 ---------------- engines/zvision/module.mk | 2 +- engines/zvision/scripting/sidefx/music_node.cpp | 2 +- engines/zvision/sound/midi.cpp | 89 +++++++++++++++++++++++++ engines/zvision/sound/midi.h | 59 ++++++++++++++++ engines/zvision/zvision.cpp | 2 +- 7 files changed, 151 insertions(+), 151 deletions(-) delete mode 100644 engines/zvision/core/midi.cpp delete mode 100644 engines/zvision/core/midi.h create mode 100644 engines/zvision/sound/midi.cpp create mode 100644 engines/zvision/sound/midi.h diff --git a/engines/zvision/core/midi.cpp b/engines/zvision/core/midi.cpp deleted file mode 100644 index 736be1311d..0000000000 --- a/engines/zvision/core/midi.cpp +++ /dev/null @@ -1,89 +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 "common/scummsys.h" - -#include "zvision/core/midi.h" - -namespace ZVision { - -MidiManager::MidiManager() { - MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); - _driver = MidiDriver::createMidi(dev); - _driver->open(); -} - -MidiManager::~MidiManager() { - stop(); - _driver->close(); - delete _driver; -} - -void MidiManager::stop() { - for (int8 i = 0; i < 16; i++) - if (_playChannels[i].playing) - noteOff(i); -} - -void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) { - assert(channel <= 15); - - _playChannels[channel].playing = true; - _playChannels[channel].note = note; - _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); -} - -void MidiManager::noteOff(int8 channel) { - assert(channel <= 15); - - if (_playChannels[channel].playing) { - _playChannels[channel].playing = false; - _driver->send(channel | (_playChannels[channel].note << 8) | 0x80); - } -} - -int8 MidiManager::getFreeChannel() { - for (int8 i = 0; i < 16; i++) - if (!_playChannels[i].playing) - return i; - return -1; -} - -void MidiManager::setPan(int8 channel, int8 pan) { - assert(channel <= 15); - - _driver->send(channel | (pan << 16) | 0xAB0); -} - -void MidiManager::setVolume(int8 channel, int8 volume) { - assert(channel <= 15); - - _driver->send(channel | (volume << 16) | 0x7B0); -} - -void MidiManager::setProgram(int8 channel, int8 prog) { - assert(channel <= 15); - - _driver->send(channel | (prog << 8) | 0xC0); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/midi.h b/engines/zvision/core/midi.h deleted file mode 100644 index a3bac19636..0000000000 --- a/engines/zvision/core/midi.h +++ /dev/null @@ -1,59 +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 ZVISION_MIDI_H -#define ZVISION_MIDI_H - -#include "audio/mididrv.h" - -namespace ZVision { - -class MidiManager { -public: - MidiManager(); - ~MidiManager(); - - void stop(); - void noteOn(int8 channel, int8 noteNumber, int8 velocity); - void noteOff(int8 channel); - void setPan(int8 channel, int8 pan); - void setVolume(int8 channel, int8 volume); - void setProgram(int8 channel, int8 prog); - - int8 getFreeChannel(); - -protected: - - struct chan { - bool playing; - int8 note; - - chan() : playing(false), note(0) {}; - }; - - MidiDriver *_driver; - chan _playChannels[16]; -}; - -} - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 604b697ec7..c9a1cb7187 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -4,7 +4,6 @@ MODULE_OBJS := \ core/console.o \ core/events.o \ core/menu.o \ - core/midi.o \ core/save_manager.o \ core/search_manager.o \ detection.o \ @@ -39,6 +38,7 @@ MODULE_OBJS := \ scripting/sidefx/syncsound_node.o \ scripting/sidefx/timer_node.o \ scripting/sidefx/ttytext_node.o \ + sound/midi.o \ sound/zork_raw.o \ text/string_manager.o \ text/text.o \ diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index 8316c1a76b..c79dd0296d 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -25,9 +25,9 @@ #include "zvision/scripting/sidefx/music_node.h" #include "zvision/zvision.h" -#include "zvision/core/midi.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" +#include "zvision/sound/midi.h" #include "zvision/sound/zork_raw.h" #include "common/stream.h" diff --git a/engines/zvision/sound/midi.cpp b/engines/zvision/sound/midi.cpp new file mode 100644 index 0000000000..920002c7c3 --- /dev/null +++ b/engines/zvision/sound/midi.cpp @@ -0,0 +1,89 @@ +/* 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 "common/scummsys.h" + +#include "zvision/sound/midi.h" + +namespace ZVision { + +MidiManager::MidiManager() { + MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); + _driver = MidiDriver::createMidi(dev); + _driver->open(); +} + +MidiManager::~MidiManager() { + stop(); + _driver->close(); + delete _driver; +} + +void MidiManager::stop() { + for (int8 i = 0; i < 16; i++) + if (_playChannels[i].playing) + noteOff(i); +} + +void MidiManager::noteOn(int8 channel, int8 note, int8 velocity) { + assert(channel <= 15); + + _playChannels[channel].playing = true; + _playChannels[channel].note = note; + _driver->send(channel | (velocity << 16) | (note << 8) | 0x90); +} + +void MidiManager::noteOff(int8 channel) { + assert(channel <= 15); + + if (_playChannels[channel].playing) { + _playChannels[channel].playing = false; + _driver->send(channel | (_playChannels[channel].note << 8) | 0x80); + } +} + +int8 MidiManager::getFreeChannel() { + for (int8 i = 0; i < 16; i++) + if (!_playChannels[i].playing) + return i; + return -1; +} + +void MidiManager::setPan(int8 channel, int8 pan) { + assert(channel <= 15); + + _driver->send(channel | (pan << 16) | 0xAB0); +} + +void MidiManager::setVolume(int8 channel, int8 volume) { + assert(channel <= 15); + + _driver->send(channel | (volume << 16) | 0x7B0); +} + +void MidiManager::setProgram(int8 channel, int8 prog) { + assert(channel <= 15); + + _driver->send(channel | (prog << 8) | 0xC0); +} + +} // End of namespace ZVision diff --git a/engines/zvision/sound/midi.h b/engines/zvision/sound/midi.h new file mode 100644 index 0000000000..a3bac19636 --- /dev/null +++ b/engines/zvision/sound/midi.h @@ -0,0 +1,59 @@ +/* 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 ZVISION_MIDI_H +#define ZVISION_MIDI_H + +#include "audio/mididrv.h" + +namespace ZVision { + +class MidiManager { +public: + MidiManager(); + ~MidiManager(); + + void stop(); + void noteOn(int8 channel, int8 noteNumber, int8 velocity); + void noteOff(int8 channel); + void setPan(int8 channel, int8 pan); + void setVolume(int8 channel, int8 volume); + void setProgram(int8 channel, int8 prog); + + int8 getFreeChannel(); + +protected: + + struct chan { + bool playing; + int8 note; + + chan() : playing(false), note(0) {}; + }; + + MidiDriver *_driver; + chan _playChannels[16]; +}; + +} + +#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 34fe0794bd..45dc124b58 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -34,7 +34,7 @@ #include "zvision/core/search_manager.h" #include "zvision/text/text.h" #include "zvision/graphics/truetype_font.h" -#include "zvision/core/midi.h" +#include "zvision/sound/midi.h" #include "zvision/utility/zfs_archive.h" #include "common/config-manager.h" -- cgit v1.2.3 From d8a961244d99a87c1a01613a971173cc135c246a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:14:37 +0200 Subject: ZVISION: Move all the file-related classes together --- engines/zvision/core/search_manager.cpp | 273 --------------------------- engines/zvision/core/search_manager.h | 73 ------- engines/zvision/file/lzss_read_stream.cpp | 102 ++++++++++ engines/zvision/file/lzss_read_stream.h | 71 +++++++ engines/zvision/file/search_manager.cpp | 273 +++++++++++++++++++++++++++ engines/zvision/file/search_manager.h | 73 +++++++ engines/zvision/file/zfs_archive.cpp | 154 +++++++++++++++ engines/zvision/file/zfs_archive.h | 125 ++++++++++++ engines/zvision/graphics/render_manager.cpp | 2 +- engines/zvision/graphics/subtitles.cpp | 2 +- engines/zvision/module.mk | 6 +- engines/zvision/text/string_manager.cpp | 2 +- engines/zvision/utility/lzss_read_stream.cpp | 102 ---------- engines/zvision/utility/lzss_read_stream.h | 71 ------- engines/zvision/utility/zfs_archive.cpp | 154 --------------- engines/zvision/utility/zfs_archive.h | 125 ------------ engines/zvision/zvision.cpp | 4 +- engines/zvision/zvision.h | 2 +- 18 files changed, 807 insertions(+), 807 deletions(-) delete mode 100644 engines/zvision/core/search_manager.cpp delete mode 100644 engines/zvision/core/search_manager.h create mode 100644 engines/zvision/file/lzss_read_stream.cpp create mode 100644 engines/zvision/file/lzss_read_stream.h create mode 100644 engines/zvision/file/search_manager.cpp create mode 100644 engines/zvision/file/search_manager.h create mode 100644 engines/zvision/file/zfs_archive.cpp create mode 100644 engines/zvision/file/zfs_archive.h delete mode 100644 engines/zvision/utility/lzss_read_stream.cpp delete mode 100644 engines/zvision/utility/lzss_read_stream.h delete mode 100644 engines/zvision/utility/zfs_archive.cpp delete mode 100644 engines/zvision/utility/zfs_archive.h diff --git a/engines/zvision/core/search_manager.cpp b/engines/zvision/core/search_manager.cpp deleted file mode 100644 index 1523319c94..0000000000 --- a/engines/zvision/core/search_manager.cpp +++ /dev/null @@ -1,273 +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 "common/debug.h" -#include "common/fs.h" -#include "common/stream.h" - -#include "zvision/core/search_manager.h" -#include "zvision/utility/zfs_archive.h" - -namespace ZVision { - -SearchManager::SearchManager(const Common::String &rootPath, int depth) { - _root = rootPath; - if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') - _root.deleteLastChar(); - - Common::FSNode fsNode(_root); - - listDirRecursive(_dirList, fsNode, depth); - - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) - if (it->size() == _root.size()) - it = _dirList.erase(it); - else if (it->size() > _root.size()) { - *it = Common::String(it->c_str() + _root.size() + 1); - it++; - } else - it++; -} - -SearchManager::~SearchManager() { - Common::List::iterator it = _archList.begin(); - while (it != _archList.end()) { - delete *it; - it++; - } - - _archList.clear(); -} - -void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { - Common::String lowerCaseName = dst; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator it = _files.find(lowerCaseName); - - if (it != _files.end()) { - lowerCaseName = src; - lowerCaseName.toLowercase(); - _files[lowerCaseName] = it->_value; - } -} - -void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { - bool addArch = true; - Common::List::iterator it = _archList.begin(); - while (it != _archList.end()) { - if (*it == arch) { - addArch = false; - break; - } - it++; - } - if (addArch) - _archList.push_back(arch); - - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::Node nod; - nod.name = lowerCaseName; - nod.arch = arch; - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit == _files.end()) { - _files[lowerCaseName] = nod; - } else { - Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); - if (stream) { - if (stream->size() < 10) - fit->_value.arch = arch; - delete stream; - } else { - _files[lowerCaseName] = nod; - } - } -} - -Common::File *SearchManager::openFile(const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) { - Common::File *tmp = new Common::File(); - tmp->open(fit->_value.name, *fit->_value.arch); - return tmp; - } - return NULL; -} - -bool SearchManager::openFile(Common::File &file, const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) - return file.open(fit->_value.name, *fit->_value.arch); - return false; -} - -bool SearchManager::hasFile(const Common::String &name) { - Common::String lowerCaseName = name; - lowerCaseName.toLowercase(); - - SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); - - if (fit != _files.end()) - return true; - return false; -} - -void SearchManager::loadZix(const Common::String &name) { - Common::File file; - file.open(name); - - Common::String line; - - while (!file.eos()) { - line = file.readLine(); - if (line.matchString("----------*", true)) - break; - } - - if (file.eos()) - return; - - Common::Array archives; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - if (line.matchString("----------*", true)) - break; - else if (line.matchString("DIR:*", true)) { - Common::String path(line.c_str() + 5); - Common::Archive *arc; - char tempPath[128]; - strcpy(tempPath, path.c_str()); - for (uint i = 0; i < path.size(); i++) - if (tempPath[i] == '\\') - tempPath[i] = '/'; - - path = Common::String(tempPath); - if (path.size() && path[0] == '.') - path.deleteChar(0); - if (path.size() && path[0] == '/') - path.deleteChar(0); - - if (path.matchString("*.zfs", true)) - arc = new ZfsArchive(path); - else { - if (path.size()) { - if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') - path.deleteLastChar(); - if (path.size()) - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) - if (path.equalsIgnoreCase(*it)) { - path = *it; - break; - } - } - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - arc = new Common::FSDirectory(path); - } - archives.push_back(arc); - } - } - - if (file.eos()) - return; - - while (!file.eos()) { - line = file.readLine(); - line.trim(); - uint dr = 0; - char buf[32]; - if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { - if (dr <= archives.size() && dr > 0) { - addFile(Common::String(buf), archives[dr - 1]); - } - } - } -} - -void SearchManager::addDir(const Common::String &name) { - Common::String path; - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) - if (name.equalsIgnoreCase(*it)) { - path = *it; - break; - } - - if (path.size() == 0) - return; - - path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); - - Common::FSDirectory *dir = new Common::FSDirectory(path); - - Common::ArchiveMemberList list; - dir->listMatchingMembers(list, "*.zfs"); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - - ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); - - Common::ArchiveMemberList zfslist; - zfs->listMembers(zfslist); - - for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { - Common::String zfsFileName = (*ziter)->getName(); - addFile(zfsFileName, zfs); - } - } - - list.clear(); - dir->listMembers(list); - - for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::String flname = (*iter)->getName(); - addFile(flname, dir); - } -} - -void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { - Common::FSList fsList; - fsNode.getChildren(fsList); - - _list.push_back(fsNode.getPath()); - - if (depth > 1) - for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) - listDirRecursive(_list, *it, depth - 1); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/search_manager.h b/engines/zvision/core/search_manager.h deleted file mode 100644 index fdd70fd381..0000000000 --- a/engines/zvision/core/search_manager.h +++ /dev/null @@ -1,73 +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 ZVISION_SEARCH_MANAGER_H -#define ZVISION_SEARCH_MANAGER_H - -#include "common/str.h" -#include "common/hash-str.h" -#include "common/hashmap.h" -#include "common/archive.h" -#include "common/file.h" -#include "common/list.h" - -namespace ZVision { - -class SearchManager { -public: - SearchManager(const Common::String &rootPath, int depth); - ~SearchManager(); - - void addFile(const Common::String &name, Common::Archive *arch); - void addDir(const Common::String &name); - void addPatch(const Common::String &src, const Common::String &dst); - - Common::File *openFile(const Common::String &name); - bool openFile(Common::File &file, const Common::String &name); - bool hasFile(const Common::String &name); - - void loadZix(const Common::String &name); - -private: - - void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); - - struct Node { - Common::String name; - Common::Archive *arch; - }; - - Common::List _dirList; - - typedef Common::HashMap MatchList; - - Common::List _archList; - MatchList _files; - - Common::String _root; - -private: -}; - -} - -#endif // ZVISION_SEARCH_MANAGER_H diff --git a/engines/zvision/file/lzss_read_stream.cpp b/engines/zvision/file/lzss_read_stream.cpp new file mode 100644 index 0000000000..6f27eaa765 --- /dev/null +++ b/engines/zvision/file/lzss_read_stream.cpp @@ -0,0 +1,102 @@ +/* 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 "common/scummsys.h" + +#include "zvision/file/lzss_read_stream.h" + +namespace ZVision { + +LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) + : _source(source), + // It's convention to set the starting cursor position to blockSize - 16 + _windowCursor(0x0FEE), + _eosFlag(false) { + // Clear the window to null + memset(_window, 0, BLOCK_SIZE); +} + +uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) { + uint32 destinationCursor = 0; + + while (destinationCursor < numberOfBytes) { + byte flagbyte = _source->readByte(); + if (_source->eos()) + break; + uint mask = 1; + + for (int i = 0; i < 8; ++i) { + if ((flagbyte & mask) == mask) { + byte data = _source->readByte(); + if (_source->eos()) { + return destinationCursor; + } + + _window[_windowCursor] = data; + destination[destinationCursor++] = data; + + // Increment and wrap the window cursor + _windowCursor = (_windowCursor + 1) & 0xFFF; + } else { + byte low = _source->readByte(); + if (_source->eos()) { + return destinationCursor; + } + + byte high = _source->readByte(); + if (_source->eos()) { + return destinationCursor; + } + + uint16 length = (high & 0xF) + 2; + uint16 offset = low | ((high & 0xF0) << 4); + + for (int j = 0; j <= length; ++j) { + byte temp = _window[(offset + j) & 0xFFF]; + _window[_windowCursor] = temp; + destination[destinationCursor++] = temp; + _windowCursor = (_windowCursor + 1) & 0xFFF; + } + } + + mask = mask << 1; + } + } + + return destinationCursor; +} + +bool LzssReadStream::eos() const { + return _eosFlag; +} + +uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) { + uint32 bytesRead = decompressBytes(static_cast(dataPtr), dataSize); + if (bytesRead < dataSize) { + // Flag that we're at EOS + _eosFlag = true; + } + + return dataSize; +} + +} // End of namespace ZVision diff --git a/engines/zvision/file/lzss_read_stream.h b/engines/zvision/file/lzss_read_stream.h new file mode 100644 index 0000000000..1420621f13 --- /dev/null +++ b/engines/zvision/file/lzss_read_stream.h @@ -0,0 +1,71 @@ +/* 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 ZVISION_LZSS_STREAM_H +#define ZVISION_LZSS_STREAM_H + +#include "common/stream.h" +#include "common/array.h" + +namespace Common { +class SeekableReadStream; +} + +namespace ZVision { + +class LzssReadStream : public Common::ReadStream { +public: + /** + * A class that decompresses LZSS data and implements ReadStream for easy access + * to the decompiled data. + * + * @param source The source data + */ + LzssReadStream(Common::SeekableReadStream *source); + +private: + enum { + BLOCK_SIZE = 0x1000 + }; + +private: + Common::SeekableReadStream *_source; + byte _window[BLOCK_SIZE]; + uint _windowCursor; + bool _eosFlag; + +public: + bool eos() const; + uint32 read(void *dataPtr, uint32 dataSize); + +private: + /** + * Decompress the next from the source stream. Or until EOS + * + * @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes + */ + uint32 decompressBytes(byte *destination, uint32 numberOfBytes); +}; + +} + +#endif diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp new file mode 100644 index 0000000000..752b52b01f --- /dev/null +++ b/engines/zvision/file/search_manager.cpp @@ -0,0 +1,273 @@ +/* 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 "common/debug.h" +#include "common/fs.h" +#include "common/stream.h" + +#include "zvision/file/search_manager.h" +#include "zvision/file/zfs_archive.h" + +namespace ZVision { + +SearchManager::SearchManager(const Common::String &rootPath, int depth) { + _root = rootPath; + if (_root[_root.size() - 1] == '\\' || _root[_root.size() - 1] == '/') + _root.deleteLastChar(); + + Common::FSNode fsNode(_root); + + listDirRecursive(_dirList, fsNode, depth); + + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) + if (it->size() == _root.size()) + it = _dirList.erase(it); + else if (it->size() > _root.size()) { + *it = Common::String(it->c_str() + _root.size() + 1); + it++; + } else + it++; +} + +SearchManager::~SearchManager() { + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { + delete *it; + it++; + } + + _archList.clear(); +} + +void SearchManager::addPatch(const Common::String &src, const Common::String &dst) { + Common::String lowerCaseName = dst; + lowerCaseName.toLowercase(); + + SearchManager::MatchList::iterator it = _files.find(lowerCaseName); + + if (it != _files.end()) { + lowerCaseName = src; + lowerCaseName.toLowercase(); + _files[lowerCaseName] = it->_value; + } +} + +void SearchManager::addFile(const Common::String &name, Common::Archive *arch) { + bool addArch = true; + Common::List::iterator it = _archList.begin(); + while (it != _archList.end()) { + if (*it == arch) { + addArch = false; + break; + } + it++; + } + if (addArch) + _archList.push_back(arch); + + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); + + SearchManager::Node nod; + nod.name = lowerCaseName; + nod.arch = arch; + + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); + + if (fit == _files.end()) { + _files[lowerCaseName] = nod; + } else { + Common::SeekableReadStream *stream = fit->_value.arch->createReadStreamForMember(fit->_value.name); + if (stream) { + if (stream->size() < 10) + fit->_value.arch = arch; + delete stream; + } else { + _files[lowerCaseName] = nod; + } + } +} + +Common::File *SearchManager::openFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); + + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); + + if (fit != _files.end()) { + Common::File *tmp = new Common::File(); + tmp->open(fit->_value.name, *fit->_value.arch); + return tmp; + } + return NULL; +} + +bool SearchManager::openFile(Common::File &file, const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); + + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); + + if (fit != _files.end()) + return file.open(fit->_value.name, *fit->_value.arch); + return false; +} + +bool SearchManager::hasFile(const Common::String &name) { + Common::String lowerCaseName = name; + lowerCaseName.toLowercase(); + + SearchManager::MatchList::iterator fit = _files.find(lowerCaseName); + + if (fit != _files.end()) + return true; + return false; +} + +void SearchManager::loadZix(const Common::String &name) { + Common::File file; + file.open(name); + + Common::String line; + + while (!file.eos()) { + line = file.readLine(); + if (line.matchString("----------*", true)) + break; + } + + if (file.eos()) + return; + + Common::Array archives; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + if (line.matchString("----------*", true)) + break; + else if (line.matchString("DIR:*", true)) { + Common::String path(line.c_str() + 5); + Common::Archive *arc; + char tempPath[128]; + strcpy(tempPath, path.c_str()); + for (uint i = 0; i < path.size(); i++) + if (tempPath[i] == '\\') + tempPath[i] = '/'; + + path = Common::String(tempPath); + if (path.size() && path[0] == '.') + path.deleteChar(0); + if (path.size() && path[0] == '/') + path.deleteChar(0); + + if (path.matchString("*.zfs", true)) + arc = new ZfsArchive(path); + else { + if (path.size()) { + if (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/') + path.deleteLastChar(); + if (path.size()) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + arc = new Common::FSDirectory(path); + } + archives.push_back(arc); + } + } + + if (file.eos()) + return; + + while (!file.eos()) { + line = file.readLine(); + line.trim(); + uint dr = 0; + char buf[32]; + if (sscanf(line.c_str(), "%u %s", &dr, buf) == 2) { + if (dr <= archives.size() && dr > 0) { + addFile(Common::String(buf), archives[dr - 1]); + } + } + } +} + +void SearchManager::addDir(const Common::String &name) { + Common::String path; + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end(); ++it) + if (name.equalsIgnoreCase(*it)) { + path = *it; + break; + } + + if (path.size() == 0) + return; + + path = Common::String::format("%s/%s", _root.c_str(), path.c_str()); + + Common::FSDirectory *dir = new Common::FSDirectory(path); + + Common::ArchiveMemberList list; + dir->listMatchingMembers(list, "*.zfs"); + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + + ZfsArchive *zfs = new ZfsArchive(Common::String::format("%s/%s", name.c_str(), flname.c_str())); + + Common::ArchiveMemberList zfslist; + zfs->listMembers(zfslist); + + for (Common::ArchiveMemberList::iterator ziter = zfslist.begin(); ziter != zfslist.end(); ++ziter) { + Common::String zfsFileName = (*ziter)->getName(); + addFile(zfsFileName, zfs); + } + } + + list.clear(); + dir->listMembers(list); + + for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { + Common::String flname = (*iter)->getName(); + addFile(flname, dir); + } +} + +void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { + Common::FSList fsList; + fsNode.getChildren(fsList); + + _list.push_back(fsNode.getPath()); + + if (depth > 1) + for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) + listDirRecursive(_list, *it, depth - 1); +} + +} // End of namespace ZVision diff --git a/engines/zvision/file/search_manager.h b/engines/zvision/file/search_manager.h new file mode 100644 index 0000000000..fdd70fd381 --- /dev/null +++ b/engines/zvision/file/search_manager.h @@ -0,0 +1,73 @@ +/* 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 ZVISION_SEARCH_MANAGER_H +#define ZVISION_SEARCH_MANAGER_H + +#include "common/str.h" +#include "common/hash-str.h" +#include "common/hashmap.h" +#include "common/archive.h" +#include "common/file.h" +#include "common/list.h" + +namespace ZVision { + +class SearchManager { +public: + SearchManager(const Common::String &rootPath, int depth); + ~SearchManager(); + + void addFile(const Common::String &name, Common::Archive *arch); + void addDir(const Common::String &name); + void addPatch(const Common::String &src, const Common::String &dst); + + Common::File *openFile(const Common::String &name); + bool openFile(Common::File &file, const Common::String &name); + bool hasFile(const Common::String &name); + + void loadZix(const Common::String &name); + +private: + + void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); + + struct Node { + Common::String name; + Common::Archive *arch; + }; + + Common::List _dirList; + + typedef Common::HashMap MatchList; + + Common::List _archList; + MatchList _files; + + Common::String _root; + +private: +}; + +} + +#endif // ZVISION_SEARCH_MANAGER_H diff --git a/engines/zvision/file/zfs_archive.cpp b/engines/zvision/file/zfs_archive.cpp new file mode 100644 index 0000000000..9b55a366ed --- /dev/null +++ b/engines/zvision/file/zfs_archive.cpp @@ -0,0 +1,154 @@ +/* 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 "common/scummsys.h" +#include "common/memstream.h" +#include "common/debug.h" +#include "common/file.h" + +#include "zvision/file/zfs_archive.h" + +namespace ZVision { + +ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { + Common::File zfsFile; + + if (!zfsFile.open(_fileName)) { + warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); + return; + } + + readHeaders(&zfsFile); + + debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); +} + +ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) { + readHeaders(stream); + + debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); +} + +ZfsArchive::~ZfsArchive() { + debug(1, "ZfsArchive Destructor Called"); + ZfsEntryHeaderMap::iterator it = _entryHeaders.begin(); + for (; it != _entryHeaders.end(); ++it) { + delete it->_value; + } +} + +void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { + // Don't do a straight struct cast since we can't guarantee endianness + _header.magic = stream->readUint32LE(); + _header.unknown1 = stream->readUint32LE(); + _header.maxNameLength = stream->readUint32LE(); + _header.filesPerBlock = stream->readUint32LE(); + _header.fileCount = stream->readUint32LE(); + _header.xorKey[0] = stream->readByte(); + _header.xorKey[1] = stream->readByte(); + _header.xorKey[2] = stream->readByte(); + _header.xorKey[3] = stream->readByte(); + _header.fileSectionOffset = stream->readUint32LE(); + + uint32 nextOffset; + + do { + // Read the offset to the next block + nextOffset = stream->readUint32LE(); + + // Read in each entry header + for (uint32 i = 0; i < _header.filesPerBlock; ++i) { + ZfsEntryHeader entryHeader; + + entryHeader.name = readEntryName(stream); + entryHeader.offset = stream->readUint32LE(); + entryHeader.id = stream->readUint32LE(); + entryHeader.size = stream->readUint32LE(); + entryHeader.time = stream->readUint32LE(); + entryHeader.unknown = stream->readUint32LE(); + + if (entryHeader.size != 0) + _entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader); + } + + // Seek to the next block of headers + stream->seek(nextOffset); + } while (nextOffset != 0); +} + +Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const { + // Entry Names are at most 16 bytes and are null padded + char buffer[16]; + stream->read(buffer, 16); + + return Common::String(buffer); +} + +bool ZfsArchive::hasFile(const Common::String &name) const { + return _entryHeaders.contains(name); +} + +int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const { + int matches = 0; + + for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) { + list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this))); + matches++; + } + + return matches; +} + +const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const { + if (!_entryHeaders.contains(name)) + return Common::ArchiveMemberPtr(); + + return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); +} + +Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const { + if (!_entryHeaders.contains(name)) { + return 0; + } + + ZfsEntryHeader *entryHeader = _entryHeaders[name]; + + Common::File zfsArchive; + zfsArchive.open(_fileName); + zfsArchive.seek(entryHeader->offset); + + // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory + byte *buffer = (byte *)malloc(entryHeader->size); + zfsArchive.read(buffer, entryHeader->size); + // Decrypt the data in place + if (_header.xorKey != 0) + unXor(buffer, entryHeader->size, _header.xorKey); + + return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); +} + +void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const { + for (uint32 i = 0; i < length; ++i) + buffer[i] ^= xorKey[i % 4]; +} + +} // End of namespace ZVision diff --git a/engines/zvision/file/zfs_archive.h b/engines/zvision/file/zfs_archive.h new file mode 100644 index 0000000000..571591a6d1 --- /dev/null +++ b/engines/zvision/file/zfs_archive.h @@ -0,0 +1,125 @@ +/* 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 ZVISION_ZFS_ARCHIVE_H +#define ZVISION_ZFS_ARCHIVE_H + +#include "common/archive.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace Common { +class String; +} + +namespace ZVision { + +struct ZfsHeader { + uint32 magic; + uint32 unknown1; + uint32 maxNameLength; + uint32 filesPerBlock; + uint32 fileCount; + byte xorKey[4]; + uint32 fileSectionOffset; +}; + +struct ZfsEntryHeader { + Common::String name; + uint32 offset; + uint32 id; + uint32 size; + uint32 time; + uint32 unknown; +}; + +typedef Common::HashMap ZfsEntryHeaderMap; + +class ZfsArchive : public Common::Archive { +public: + ZfsArchive(const Common::String &fileName); + ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream); + ~ZfsArchive(); + + /** + * Check if a member with the given name is present in the Archive. + * Patterns are not allowed, as this is meant to be a quick File::exists() + * replacement. + */ + bool hasFile(const Common::String &fileName) const; + + /** + * Add all members of the Archive to list. + * Must only append to list, and not remove elements from it. + * + * @return The number of names added to list + */ + int listMembers(Common::ArchiveMemberList &list) const; + + /** + * Returns a ArchiveMember representation of the given file. + */ + const Common::ArchiveMemberPtr getMember(const Common::String &name) const; + + /** + * Create a stream bound to a member with the specified name in the + * archive. If no member with this name exists, 0 is returned. + * + * @return The newly created input stream + */ + Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + +private: + const Common::String _fileName; + ZfsHeader _header; + ZfsEntryHeaderMap _entryHeaders; + + /** + * Parses the zfs file into file entry headers that can be used later + * to get the entry data. + * + * @param stream The contents of the zfs file + */ + void readHeaders(Common::SeekableReadStream *stream); + + /** + * Entry names are contained within a 16 byte block. This reads the block + * and converts it the name to a Common::String + * + * @param stream The zfs file stream + * @return The entry file name + */ + Common::String readEntryName(Common::SeekableReadStream *stream) const; + + /** + * ZFS file entries can be encrypted using XOR encoding. This method + * decodes the buffer in place using the supplied xorKey. + * + * @param buffer The data to decode + * @param length Length of buffer + */ + void unXor(byte *buffer, uint32 length, const byte *xorKey) const; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 97d47e3920..e2ad13a330 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -27,7 +27,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/text/text.h" -#include "zvision/utility/lzss_read_stream.h" +#include "zvision/file/lzss_read_stream.h" #include "common/file.h" #include "common/system.h" diff --git a/engines/zvision/graphics/subtitles.cpp b/engines/zvision/graphics/subtitles.cpp index 784721562a..d2c56f0991 100644 --- a/engines/zvision/graphics/subtitles.cpp +++ b/engines/zvision/graphics/subtitles.cpp @@ -22,7 +22,7 @@ #include "zvision/graphics/render_manager.h" #include "zvision/graphics/subtitles.h" -#include "zvision/core/search_manager.h" +#include "zvision/file/search_manager.h" #include "zvision/text/text.h" namespace ZVision { diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index c9a1cb7187..1d89e22584 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -5,8 +5,10 @@ MODULE_OBJS := \ core/events.o \ core/menu.o \ core/save_manager.o \ - core/search_manager.o \ detection.o \ + file/lzss_read_stream.o \ + file/search_manager.o \ + file/zfs_archive.o \ graphics/cursors/cursor_manager.o \ graphics/cursors/cursor.o \ graphics/effects/fog.o \ @@ -43,9 +45,7 @@ MODULE_OBJS := \ text/string_manager.o \ text/text.o \ utility/clock.o \ - utility/lzss_read_stream.o \ utility/utility.o \ - utility/zfs_archive.o \ video/rlf_decoder.o \ video/video.o \ video/zork_avi_decoder.o \ diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index 1a04c67988..d275bc8769 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -28,7 +28,7 @@ #include "graphics/colormasks.h" #include "zvision/zvision.h" -#include "zvision/core/search_manager.h" +#include "zvision/file/search_manager.h" #include "zvision/text/string_manager.h" #include "zvision/graphics/truetype_font.h" diff --git a/engines/zvision/utility/lzss_read_stream.cpp b/engines/zvision/utility/lzss_read_stream.cpp deleted file mode 100644 index bbe6e35f76..0000000000 --- a/engines/zvision/utility/lzss_read_stream.cpp +++ /dev/null @@ -1,102 +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 "common/scummsys.h" - -#include "zvision/utility/lzss_read_stream.h" - -namespace ZVision { - -LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) - : _source(source), - // It's convention to set the starting cursor position to blockSize - 16 - _windowCursor(0x0FEE), - _eosFlag(false) { - // Clear the window to null - memset(_window, 0, BLOCK_SIZE); -} - -uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) { - uint32 destinationCursor = 0; - - while (destinationCursor < numberOfBytes) { - byte flagbyte = _source->readByte(); - if (_source->eos()) - break; - uint mask = 1; - - for (int i = 0; i < 8; ++i) { - if ((flagbyte & mask) == mask) { - byte data = _source->readByte(); - if (_source->eos()) { - return destinationCursor; - } - - _window[_windowCursor] = data; - destination[destinationCursor++] = data; - - // Increment and wrap the window cursor - _windowCursor = (_windowCursor + 1) & 0xFFF; - } else { - byte low = _source->readByte(); - if (_source->eos()) { - return destinationCursor; - } - - byte high = _source->readByte(); - if (_source->eos()) { - return destinationCursor; - } - - uint16 length = (high & 0xF) + 2; - uint16 offset = low | ((high & 0xF0) << 4); - - for (int j = 0; j <= length; ++j) { - byte temp = _window[(offset + j) & 0xFFF]; - _window[_windowCursor] = temp; - destination[destinationCursor++] = temp; - _windowCursor = (_windowCursor + 1) & 0xFFF; - } - } - - mask = mask << 1; - } - } - - return destinationCursor; -} - -bool LzssReadStream::eos() const { - return _eosFlag; -} - -uint32 LzssReadStream::read(void *dataPtr, uint32 dataSize) { - uint32 bytesRead = decompressBytes(static_cast(dataPtr), dataSize); - if (bytesRead < dataSize) { - // Flag that we're at EOS - _eosFlag = true; - } - - return dataSize; -} - -} // End of namespace ZVision diff --git a/engines/zvision/utility/lzss_read_stream.h b/engines/zvision/utility/lzss_read_stream.h deleted file mode 100644 index 1420621f13..0000000000 --- a/engines/zvision/utility/lzss_read_stream.h +++ /dev/null @@ -1,71 +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 ZVISION_LZSS_STREAM_H -#define ZVISION_LZSS_STREAM_H - -#include "common/stream.h" -#include "common/array.h" - -namespace Common { -class SeekableReadStream; -} - -namespace ZVision { - -class LzssReadStream : public Common::ReadStream { -public: - /** - * A class that decompresses LZSS data and implements ReadStream for easy access - * to the decompiled data. - * - * @param source The source data - */ - LzssReadStream(Common::SeekableReadStream *source); - -private: - enum { - BLOCK_SIZE = 0x1000 - }; - -private: - Common::SeekableReadStream *_source; - byte _window[BLOCK_SIZE]; - uint _windowCursor; - bool _eosFlag; - -public: - bool eos() const; - uint32 read(void *dataPtr, uint32 dataSize); - -private: - /** - * Decompress the next from the source stream. Or until EOS - * - * @param numberOfBytes How many bytes to decompress. This is a count of source bytes, not destination bytes - */ - uint32 decompressBytes(byte *destination, uint32 numberOfBytes); -}; - -} - -#endif diff --git a/engines/zvision/utility/zfs_archive.cpp b/engines/zvision/utility/zfs_archive.cpp deleted file mode 100644 index 13b0168e1c..0000000000 --- a/engines/zvision/utility/zfs_archive.cpp +++ /dev/null @@ -1,154 +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 "common/scummsys.h" -#include "common/memstream.h" -#include "common/debug.h" -#include "common/file.h" - -#include "zvision/utility/zfs_archive.h" - -namespace ZVision { - -ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { - Common::File zfsFile; - - if (!zfsFile.open(_fileName)) { - warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); - return; - } - - readHeaders(&zfsFile); - - debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); -} - -ZfsArchive::ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream) : _fileName(fileName) { - readHeaders(stream); - - debug(1, "ZfsArchive::ZfsArchive(%s): Located %d files", _fileName.c_str(), _entryHeaders.size()); -} - -ZfsArchive::~ZfsArchive() { - debug(1, "ZfsArchive Destructor Called"); - ZfsEntryHeaderMap::iterator it = _entryHeaders.begin(); - for (; it != _entryHeaders.end(); ++it) { - delete it->_value; - } -} - -void ZfsArchive::readHeaders(Common::SeekableReadStream *stream) { - // Don't do a straight struct cast since we can't guarantee endianness - _header.magic = stream->readUint32LE(); - _header.unknown1 = stream->readUint32LE(); - _header.maxNameLength = stream->readUint32LE(); - _header.filesPerBlock = stream->readUint32LE(); - _header.fileCount = stream->readUint32LE(); - _header.xorKey[0] = stream->readByte(); - _header.xorKey[1] = stream->readByte(); - _header.xorKey[2] = stream->readByte(); - _header.xorKey[3] = stream->readByte(); - _header.fileSectionOffset = stream->readUint32LE(); - - uint32 nextOffset; - - do { - // Read the offset to the next block - nextOffset = stream->readUint32LE(); - - // Read in each entry header - for (uint32 i = 0; i < _header.filesPerBlock; ++i) { - ZfsEntryHeader entryHeader; - - entryHeader.name = readEntryName(stream); - entryHeader.offset = stream->readUint32LE(); - entryHeader.id = stream->readUint32LE(); - entryHeader.size = stream->readUint32LE(); - entryHeader.time = stream->readUint32LE(); - entryHeader.unknown = stream->readUint32LE(); - - if (entryHeader.size != 0) - _entryHeaders[entryHeader.name] = new ZfsEntryHeader(entryHeader); - } - - // Seek to the next block of headers - stream->seek(nextOffset); - } while (nextOffset != 0); -} - -Common::String ZfsArchive::readEntryName(Common::SeekableReadStream *stream) const { - // Entry Names are at most 16 bytes and are null padded - char buffer[16]; - stream->read(buffer, 16); - - return Common::String(buffer); -} - -bool ZfsArchive::hasFile(const Common::String &name) const { - return _entryHeaders.contains(name); -} - -int ZfsArchive::listMembers(Common::ArchiveMemberList &list) const { - int matches = 0; - - for (ZfsEntryHeaderMap::const_iterator it = _entryHeaders.begin(); it != _entryHeaders.end(); ++it) { - list.push_back(Common::ArchiveMemberList::value_type(new Common::GenericArchiveMember(it->_value->name, this))); - matches++; - } - - return matches; -} - -const Common::ArchiveMemberPtr ZfsArchive::getMember(const Common::String &name) const { - if (!_entryHeaders.contains(name)) - return Common::ArchiveMemberPtr(); - - return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); -} - -Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common::String &name) const { - if (!_entryHeaders.contains(name)) { - return 0; - } - - ZfsEntryHeader *entryHeader = _entryHeaders[name]; - - Common::File zfsArchive; - zfsArchive.open(_fileName); - zfsArchive.seek(entryHeader->offset); - - // This *HAS* to be malloc (not new[]) because MemoryReadStream uses free() to free the memory - byte *buffer = (byte *)malloc(entryHeader->size); - zfsArchive.read(buffer, entryHeader->size); - // Decrypt the data in place - if (_header.xorKey != 0) - unXor(buffer, entryHeader->size, _header.xorKey); - - return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); -} - -void ZfsArchive::unXor(byte *buffer, uint32 length, const byte *xorKey) const { - for (uint32 i = 0; i < length; ++i) - buffer[i] ^= xorKey[i % 4]; -} - -} // End of namespace ZVision diff --git a/engines/zvision/utility/zfs_archive.h b/engines/zvision/utility/zfs_archive.h deleted file mode 100644 index 571591a6d1..0000000000 --- a/engines/zvision/utility/zfs_archive.h +++ /dev/null @@ -1,125 +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 ZVISION_ZFS_ARCHIVE_H -#define ZVISION_ZFS_ARCHIVE_H - -#include "common/archive.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Common { -class String; -} - -namespace ZVision { - -struct ZfsHeader { - uint32 magic; - uint32 unknown1; - uint32 maxNameLength; - uint32 filesPerBlock; - uint32 fileCount; - byte xorKey[4]; - uint32 fileSectionOffset; -}; - -struct ZfsEntryHeader { - Common::String name; - uint32 offset; - uint32 id; - uint32 size; - uint32 time; - uint32 unknown; -}; - -typedef Common::HashMap ZfsEntryHeaderMap; - -class ZfsArchive : public Common::Archive { -public: - ZfsArchive(const Common::String &fileName); - ZfsArchive(const Common::String &fileName, Common::SeekableReadStream *stream); - ~ZfsArchive(); - - /** - * Check if a member with the given name is present in the Archive. - * Patterns are not allowed, as this is meant to be a quick File::exists() - * replacement. - */ - bool hasFile(const Common::String &fileName) const; - - /** - * Add all members of the Archive to list. - * Must only append to list, and not remove elements from it. - * - * @return The number of names added to list - */ - int listMembers(Common::ArchiveMemberList &list) const; - - /** - * Returns a ArchiveMember representation of the given file. - */ - const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - - /** - * Create a stream bound to a member with the specified name in the - * archive. If no member with this name exists, 0 is returned. - * - * @return The newly created input stream - */ - Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - -private: - const Common::String _fileName; - ZfsHeader _header; - ZfsEntryHeaderMap _entryHeaders; - - /** - * Parses the zfs file into file entry headers that can be used later - * to get the entry data. - * - * @param stream The contents of the zfs file - */ - void readHeaders(Common::SeekableReadStream *stream); - - /** - * Entry names are contained within a 16 byte block. This reads the block - * and converts it the name to a Common::String - * - * @param stream The zfs file stream - * @return The entry file name - */ - Common::String readEntryName(Common::SeekableReadStream *stream) const; - - /** - * ZFS file entries can be encrypted using XOR encoding. This method - * decodes the buffer in place using the supplied xorKey. - * - * @param buffer The data to decode - * @param length Length of buffer - */ - void unXor(byte *buffer, uint32 length, const byte *xorKey) const; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 45dc124b58..f9d6bb3e85 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -31,11 +31,11 @@ #include "zvision/text/string_manager.h" #include "zvision/detection.h" #include "zvision/core/menu.h" -#include "zvision/core/search_manager.h" +#include "zvision/file/search_manager.h" #include "zvision/text/text.h" #include "zvision/graphics/truetype_font.h" #include "zvision/sound/midi.h" -#include "zvision/utility/zfs_archive.h" +#include "zvision/file/zfs_archive.h" #include "common/config-manager.h" #include "common/str.h" diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 82030e6944..55dddd4f21 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -26,7 +26,7 @@ #include "zvision/detection.h" #include "zvision/utility/clock.h" -#include "zvision/core/search_manager.h" +#include "zvision/file/search_manager.h" #include "common/random.h" #include "common/events.h" -- cgit v1.2.3 From 7630e3204e3b932d9b43bda7dc4b658405fabf33 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:21:57 +0200 Subject: ZVISION: Move all the remaining utility classes into the core --- engines/zvision/core/clock.cpp | 68 ++++++++++++++++++ engines/zvision/core/clock.h | 84 ++++++++++++++++++++++ engines/zvision/core/console.cpp | 2 +- engines/zvision/core/utility.cpp | 45 ++++++++++++ engines/zvision/core/utility.h | 47 ++++++++++++ engines/zvision/module.mk | 4 +- engines/zvision/scripting/control.cpp | 2 +- .../zvision/scripting/controls/fist_control.cpp | 2 +- .../zvision/scripting/controls/hotmov_control.cpp | 2 +- .../zvision/scripting/controls/input_control.cpp | 2 +- .../zvision/scripting/controls/lever_control.cpp | 2 +- .../zvision/scripting/controls/paint_control.cpp | 2 +- .../scripting/controls/push_toggle_control.cpp | 2 +- .../zvision/scripting/controls/safe_control.cpp | 2 +- .../zvision/scripting/controls/save_control.cpp | 2 +- .../zvision/scripting/controls/slot_control.cpp | 2 +- .../zvision/scripting/controls/titler_control.cpp | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- engines/zvision/sound/zork_raw.cpp | 2 +- engines/zvision/utility/clock.cpp | 68 ------------------ engines/zvision/utility/clock.h | 84 ---------------------- engines/zvision/utility/utility.cpp | 45 ------------ engines/zvision/utility/utility.h | 47 ------------ engines/zvision/video/video.cpp | 2 +- engines/zvision/zvision.h | 2 +- 26 files changed, 263 insertions(+), 263 deletions(-) create mode 100644 engines/zvision/core/clock.cpp create mode 100644 engines/zvision/core/clock.h create mode 100644 engines/zvision/core/utility.cpp create mode 100644 engines/zvision/core/utility.h delete mode 100644 engines/zvision/utility/clock.cpp delete mode 100644 engines/zvision/utility/clock.h delete mode 100644 engines/zvision/utility/utility.cpp delete mode 100644 engines/zvision/utility/utility.h diff --git a/engines/zvision/core/clock.cpp b/engines/zvision/core/clock.cpp new file mode 100644 index 0000000000..1425d550b7 --- /dev/null +++ b/engines/zvision/core/clock.cpp @@ -0,0 +1,68 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/clock.h" + +#include "common/system.h" + +namespace ZVision { + +Clock::Clock(OSystem *system) + : _system(system), + _lastTime(0), + _deltaTime(0), + _pausedTime(0), + _paused(false) { +} + +void Clock::update() { + uint32 currentTime = _system->getMillis(); + + _deltaTime = (currentTime - _lastTime); + if (_paused) { + _deltaTime -= (currentTime - _pausedTime); + } + + if (_deltaTime < 0) { + _deltaTime = 0; + } + + _lastTime = currentTime; +} + +void Clock::start() { + if (_paused) { + _lastTime = _system->getMillis(); + _paused = false; + } +} + +void Clock::stop() { + if (!_paused) { + _pausedTime = _system->getMillis(); + _paused = true; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/clock.h b/engines/zvision/core/clock.h new file mode 100644 index 0000000000..cbf52be560 --- /dev/null +++ b/engines/zvision/core/clock.h @@ -0,0 +1,84 @@ +/* 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 ZVISION_CLOCK_H +#define ZVISION_CLOCK_H + +#include "common/types.h" + +class OSystem; + +namespace ZVision { + +/* Class for handling frame to frame deltaTime while keeping track of time pauses/un-pauses */ +class Clock { +public: + Clock(OSystem *system); + +private: + OSystem *_system; + uint32 _lastTime; + int32 _deltaTime; + uint32 _pausedTime; + bool _paused; + +public: + /** + * Updates _deltaTime with the difference between the current time and + * when the last update() was called. + */ + void update(); + + /** + * Get the delta time since the last frame. (The time between update() calls) + * + * @return Delta time since the last frame (in milliseconds) + */ + uint32 getDeltaTime() const { + return _deltaTime; + } + + /** + * Get the time from the program starting to the last update() call + * + * @return Time from program start to last update() call (in milliseconds) + */ + uint32 getLastMeasuredTime() { + return _lastTime; + } + + /** + * Pause the clock. Any future delta times will take this pause into account. + * Has no effect if the clock is already paused. + */ + void start(); + + /** + * Un-pause the clock. + * Has no effect if the clock is already un-paused. + */ + void stop(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 76481a3549..eb4d281813 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -30,7 +30,7 @@ #include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/graphics/cursors/cursor.h" #include "common/system.h" diff --git a/engines/zvision/core/utility.cpp b/engines/zvision/core/utility.cpp new file mode 100644 index 0000000000..dcbb41171e --- /dev/null +++ b/engines/zvision/core/utility.cpp @@ -0,0 +1,45 @@ +/* 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 "common/scummsys.h" + +#include "zvision/core/utility.h" + +#include "zvision/zvision.h" +#include "zvision/sound/zork_raw.h" + +#include "common/tokenizer.h" +#include "common/file.h" + +namespace ZVision { + +void trimCommentsAndWhiteSpace(Common::String *string) { + for (int i = string->size() - 1; i >= 0; i--) { + if ((*string)[i] == '#') { + string->erase(i); + } + } + + string->trim(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/core/utility.h b/engines/zvision/core/utility.h new file mode 100644 index 0000000000..0ca26b968d --- /dev/null +++ b/engines/zvision/core/utility.h @@ -0,0 +1,47 @@ +/* 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 ZVISION_UTILITY_H +#define ZVISION_UTILITY_H + +#include "common/array.h" + +namespace Common { +class String; +} + +namespace ZVision { + +class ZVision; + +/** + * Removes any line comments using '#' as a sequence start. + * Then removes any trailing and leading 'whitespace' using String::trim() + * Note: String::trim uses isspace() to determine what is whitespace and what is not. + * + * @param string The string to modify. It is modified in place + */ +void trimCommentsAndWhiteSpace(Common::String *string); + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 1d89e22584..18923eeb8f 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -2,9 +2,11 @@ MODULE := engines/zvision MODULE_OBJS := \ core/console.o \ + core/clock.o \ core/events.o \ core/menu.o \ core/save_manager.o \ + core/utility.o \ detection.o \ file/lzss_read_stream.o \ file/search_manager.o \ @@ -44,8 +46,6 @@ MODULE_OBJS := \ sound/zork_raw.o \ text/string_manager.o \ text/text.o \ - utility/clock.o \ - utility/utility.o \ video/rlf_decoder.o \ video/video.o \ video/zork_avi_decoder.o \ diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index 5469106928..86f6a30c8f 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 887ad7950d..40d016f360 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -27,7 +27,7 @@ #include "zvision/scripting/controls/fist_control.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/video/rlf_decoder.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index b2c9cdd577..4a6d2705b4 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 1b15eacd78..e17a5f6dd8 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -29,7 +29,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/text/string_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/str.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 07eec1fb63..632554e7f2 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index 0ef7618b5b..24306bf4db 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" namespace ZVision { diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index fcd8cd0356..28c791168a 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 8135eb34cc..cb754ecbe2 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index d773b5fc6f..7de138d8e3 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -24,7 +24,7 @@ #include "zvision/scripting/controls/input_control.h" #include "zvision/scripting/controls/save_control.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 7f04c2d311..63578d54ea 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -28,7 +28,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index f0126bebc2..af26aed952 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -28,7 +28,7 @@ #include "zvision/text/text.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index f97eed6b75..631cb6128e 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -25,7 +25,7 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/scripting/puzzle.h" #include "zvision/scripting/actions.h" #include "zvision/scripting/controls/push_toggle_control.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index c735fe6eb0..605d27216e 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -29,7 +29,7 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" #include "zvision/scripting/actions.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" #include "zvision/scripting/sidefx/timer_node.h" #include "common/algorithm.h" diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index c26c33a392..d8fabc419b 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -34,7 +34,7 @@ #include "zvision/sound/zork_raw.h" #include "zvision/zvision.h" #include "zvision/detection.h" -#include "zvision/utility/utility.h" +#include "zvision/core/utility.h" namespace ZVision { diff --git a/engines/zvision/utility/clock.cpp b/engines/zvision/utility/clock.cpp deleted file mode 100644 index 0e800a2031..0000000000 --- a/engines/zvision/utility/clock.cpp +++ /dev/null @@ -1,68 +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 "common/scummsys.h" - -#include "zvision/utility/clock.h" - -#include "common/system.h" - -namespace ZVision { - -Clock::Clock(OSystem *system) - : _system(system), - _lastTime(0), - _deltaTime(0), - _pausedTime(0), - _paused(false) { -} - -void Clock::update() { - uint32 currentTime = _system->getMillis(); - - _deltaTime = (currentTime - _lastTime); - if (_paused) { - _deltaTime -= (currentTime - _pausedTime); - } - - if (_deltaTime < 0) { - _deltaTime = 0; - } - - _lastTime = currentTime; -} - -void Clock::start() { - if (_paused) { - _lastTime = _system->getMillis(); - _paused = false; - } -} - -void Clock::stop() { - if (!_paused) { - _pausedTime = _system->getMillis(); - _paused = true; - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/utility/clock.h b/engines/zvision/utility/clock.h deleted file mode 100644 index cbf52be560..0000000000 --- a/engines/zvision/utility/clock.h +++ /dev/null @@ -1,84 +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 ZVISION_CLOCK_H -#define ZVISION_CLOCK_H - -#include "common/types.h" - -class OSystem; - -namespace ZVision { - -/* Class for handling frame to frame deltaTime while keeping track of time pauses/un-pauses */ -class Clock { -public: - Clock(OSystem *system); - -private: - OSystem *_system; - uint32 _lastTime; - int32 _deltaTime; - uint32 _pausedTime; - bool _paused; - -public: - /** - * Updates _deltaTime with the difference between the current time and - * when the last update() was called. - */ - void update(); - - /** - * Get the delta time since the last frame. (The time between update() calls) - * - * @return Delta time since the last frame (in milliseconds) - */ - uint32 getDeltaTime() const { - return _deltaTime; - } - - /** - * Get the time from the program starting to the last update() call - * - * @return Time from program start to last update() call (in milliseconds) - */ - uint32 getLastMeasuredTime() { - return _lastTime; - } - - /** - * Pause the clock. Any future delta times will take this pause into account. - * Has no effect if the clock is already paused. - */ - void start(); - - /** - * Un-pause the clock. - * Has no effect if the clock is already un-paused. - */ - void stop(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp deleted file mode 100644 index e09545a90d..0000000000 --- a/engines/zvision/utility/utility.cpp +++ /dev/null @@ -1,45 +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 "common/scummsys.h" - -#include "zvision/utility/utility.h" - -#include "zvision/zvision.h" -#include "zvision/sound/zork_raw.h" - -#include "common/tokenizer.h" -#include "common/file.h" - -namespace ZVision { - -void trimCommentsAndWhiteSpace(Common::String *string) { - for (int i = string->size() - 1; i >= 0; i--) { - if ((*string)[i] == '#') { - string->erase(i); - } - } - - string->trim(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/utility/utility.h b/engines/zvision/utility/utility.h deleted file mode 100644 index 0ca26b968d..0000000000 --- a/engines/zvision/utility/utility.h +++ /dev/null @@ -1,47 +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 ZVISION_UTILITY_H -#define ZVISION_UTILITY_H - -#include "common/array.h" - -namespace Common { -class String; -} - -namespace ZVision { - -class ZVision; - -/** - * Removes any line comments using '#' as a sequence start. - * Then removes any trailing and leading 'whitespace' using String::trim() - * Note: String::trim uses isspace() to determine what is whitespace and what is not. - * - * @param string The string to modify. It is modified in place - */ -void trimCommentsAndWhiteSpace(Common::String *string); - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index c8f968d975..189fb22194 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -27,7 +27,7 @@ #include "graphics/surface.h" #include "zvision/zvision.h" -#include "zvision/utility/clock.h" +#include "zvision/core/clock.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/subtitles.h" #include "zvision/video/rlf_decoder.h" diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 55dddd4f21..78c1c824a1 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -25,7 +25,7 @@ #define ZVISION_ZVISION_H #include "zvision/detection.h" -#include "zvision/utility/clock.h" +#include "zvision/core/clock.h" #include "zvision/file/search_manager.h" #include "common/random.h" -- cgit v1.2.3 From 77705752efa00ab7f6c65ff8d99e4d9c3fdc4929 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 01:58:05 +0200 Subject: ZVISION: Move trimCommentsAndWhiteSpace() into the script manager This allows us to remove the last remnants of utility.* --- engines/zvision/core/console.cpp | 1 - engines/zvision/core/utility.cpp | 45 --------------------- engines/zvision/core/utility.h | 47 ---------------------- engines/zvision/module.mk | 1 - engines/zvision/scripting/control.cpp | 9 ++--- .../zvision/scripting/controls/fist_control.cpp | 5 +-- .../zvision/scripting/controls/hotmov_control.cpp | 5 +-- .../zvision/scripting/controls/input_control.cpp | 5 +-- .../zvision/scripting/controls/lever_control.cpp | 5 +-- .../zvision/scripting/controls/paint_control.cpp | 5 +-- .../scripting/controls/push_toggle_control.cpp | 5 +-- .../zvision/scripting/controls/safe_control.cpp | 5 +-- .../zvision/scripting/controls/save_control.cpp | 5 +-- .../zvision/scripting/controls/slot_control.cpp | 5 +-- .../zvision/scripting/controls/titler_control.cpp | 5 +-- engines/zvision/scripting/scr_file_handling.cpp | 1 - engines/zvision/scripting/script_manager.cpp | 11 ++++- engines/zvision/scripting/script_manager.h | 9 +++++ engines/zvision/sound/zork_raw.cpp | 1 - 19 files changed, 43 insertions(+), 132 deletions(-) delete mode 100644 engines/zvision/core/utility.cpp delete mode 100644 engines/zvision/core/utility.h diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index eb4d281813..4dd10d6f40 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -30,7 +30,6 @@ #include "zvision/text/string_manager.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/sound/zork_raw.h" -#include "zvision/core/utility.h" #include "zvision/graphics/cursors/cursor.h" #include "common/system.h" diff --git a/engines/zvision/core/utility.cpp b/engines/zvision/core/utility.cpp deleted file mode 100644 index dcbb41171e..0000000000 --- a/engines/zvision/core/utility.cpp +++ /dev/null @@ -1,45 +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 "common/scummsys.h" - -#include "zvision/core/utility.h" - -#include "zvision/zvision.h" -#include "zvision/sound/zork_raw.h" - -#include "common/tokenizer.h" -#include "common/file.h" - -namespace ZVision { - -void trimCommentsAndWhiteSpace(Common::String *string) { - for (int i = string->size() - 1; i >= 0; i--) { - if ((*string)[i] == '#') { - string->erase(i); - } - } - - string->trim(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/utility.h b/engines/zvision/core/utility.h deleted file mode 100644 index 0ca26b968d..0000000000 --- a/engines/zvision/core/utility.h +++ /dev/null @@ -1,47 +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 ZVISION_UTILITY_H -#define ZVISION_UTILITY_H - -#include "common/array.h" - -namespace Common { -class String; -} - -namespace ZVision { - -class ZVision; - -/** - * Removes any line comments using '#' as a sequence start. - * Then removes any trailing and leading 'whitespace' using String::trim() - * Note: String::trim uses isspace() to determine what is whitespace and what is not. - * - * @param string The string to modify. It is modified in place - */ -void trimCommentsAndWhiteSpace(Common::String *string); - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 18923eeb8f..00652f0824 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -6,7 +6,6 @@ MODULE_OBJS := \ core/events.o \ core/menu.o \ core/save_manager.o \ - core/utility.o \ detection.o \ file/lzss_read_stream.o \ file/search_manager.o \ diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index 86f6a30c8f..127f35ef12 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -27,7 +27,6 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" @@ -43,7 +42,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream & // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); while (!stream.eos() && !line.contains('}')) { if (line.matchString("angle*", true)) { @@ -67,7 +66,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream & } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); } renderTable->generateRenderTable(); @@ -79,7 +78,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); while (!stream.eos() && !line.contains('}')) { if (line.matchString("angle*", true)) { @@ -99,7 +98,7 @@ void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stre } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); } renderTable->generateRenderTable(); diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 40d016f360..34a64b4298 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -27,7 +27,6 @@ #include "zvision/scripting/controls/fist_control.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/utility.h" #include "zvision/video/rlf_decoder.h" #include "common/stream.h" @@ -63,7 +62,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -82,7 +81,7 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } } diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index 4a6d2705b4..e77272ec73 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -28,7 +28,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" @@ -53,7 +52,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -84,7 +83,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } } diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index e17a5f6dd8..6959f9eca9 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -29,7 +29,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/text/string_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/core/utility.h" #include "common/str.h" #include "common/stream.h" @@ -50,7 +49,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _animation(NULL) { // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -108,7 +107,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } } diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 632554e7f2..71dd52f40f 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -28,7 +28,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" @@ -53,7 +52,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; @@ -73,7 +72,7 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index 24306bf4db..f06dee25ad 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -28,7 +28,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/core/utility.h" namespace ZVision { @@ -44,7 +43,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -93,7 +92,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 28c791168a..3811498cd5 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -27,7 +27,6 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" @@ -42,7 +41,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -78,7 +77,7 @@ PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::Seekab } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index cb754ecbe2..71be692431 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -28,7 +28,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" #include "common/file.h" @@ -57,7 +56,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -102,7 +101,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } renderFrame(_curState); diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index 7de138d8e3..e27faa50b6 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -24,7 +24,6 @@ #include "zvision/scripting/controls/input_control.h" #include "zvision/scripting/controls/save_control.h" -#include "zvision/core/utility.h" #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" @@ -42,7 +41,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream _saveControl(false) { // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -66,7 +65,7 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 63578d54ea..292a2b4bc9 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -28,7 +28,6 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" @@ -42,7 +41,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -98,7 +97,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index af26aed952..10ba0af655 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -28,7 +28,6 @@ #include "zvision/text/text.h" #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" -#include "zvision/core/utility.h" #include "common/stream.h" @@ -42,7 +41,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt // Loop until we find the closing brace Common::String line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); Common::String param; Common::String values; getParams(line, param, values); @@ -62,7 +61,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt } line = stream.readLine(); - trimCommentsAndWhiteSpace(&line); + _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 631cb6128e..56d0c3bd7f 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -25,7 +25,6 @@ #include "zvision/zvision.h" #include "zvision/scripting/script_manager.h" -#include "zvision/core/utility.h" #include "zvision/scripting/puzzle.h" #include "zvision/scripting/actions.h" #include "zvision/scripting/controls/push_toggle_control.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 605d27216e..65077dfd12 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -29,7 +29,6 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/core/save_manager.h" #include "zvision/scripting/actions.h" -#include "zvision/core/utility.h" #include "zvision/scripting/sidefx/timer_node.h" #include "common/algorithm.h" @@ -812,6 +811,16 @@ void ScriptManager::flushEvent(Common::EventType type) { } } +void ScriptManager::trimCommentsAndWhiteSpace(Common::String *string) const { + for (int i = string->size() - 1; i >= 0; i--) { + if ((*string)[i] == '#') { + string->erase(i); + } + } + + string->trim(); +} + ValueSlot::ValueSlot(ScriptManager *scriptManager, const char *slotValue): _scriptManager(scriptManager) { value = 0; diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 89b961634b..1e308faf0d 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -247,6 +247,15 @@ public: Location getLastLocation(); Location getLastMenuLocation(); + /** + * Removes any line comments using '#' as a sequence start. + * Then removes any trailing and leading 'whitespace' using String::trim() + * Note: String::trim uses isspace() to determine what is whitespace and what is not. + * + * @param string The string to modify. It is modified in place + */ + void trimCommentsAndWhiteSpace(Common::String *string) const; + private: void referenceTableAddPuzzle(uint32 key, PuzzleRef ref); void addPuzzlesToReferenceTable(ScriptScope &scope); diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index d8fabc419b..78c851e132 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -34,7 +34,6 @@ #include "zvision/sound/zork_raw.h" #include "zvision/zvision.h" #include "zvision/detection.h" -#include "zvision/core/utility.h" namespace ZVision { -- cgit v1.2.3 From 8efcc3cf26b80ca0451da4c30113b3610f685467 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 03:46:31 +0200 Subject: ZVISION: Bugfix for addDir() - fixes the Nemesis subtitle patch --- engines/zvision/file/search_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 752b52b01f..1a6a96ec6d 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -38,7 +38,10 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { listDirRecursive(_dirList, fsNode, depth); - for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) + for (Common::List::iterator it = _dirList.begin(); it != _dirList.end();) { + if ((*it).hasSuffix("\\") || (*it).hasSuffix("/")) + (*it).deleteLastChar(); + if (it->size() == _root.size()) it = _dirList.erase(it); else if (it->size() > _root.size()) { @@ -46,6 +49,7 @@ SearchManager::SearchManager(const Common::String &rootPath, int depth) { it++; } else it++; + } } SearchManager::~SearchManager() { -- cgit v1.2.3 From 1241efcbcae7ea053067b2a80dcd93e88b4d0cea Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 03:47:28 +0200 Subject: ZVISION: Allow 2x scaling up in videos again This fixes the alchemists and cup sequence in Nemesis --- engines/zvision/scripting/sidefx/animation_node.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index e15f8ec00f..3a21227d1a 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -120,8 +120,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { // We only scale down the animation to fit its frame, not up, otherwise we // end up with distorted animations - e.g. the armor visor in location cz1e // in Nemesis (one of the armors inside Irondune), or the planet in location - // aa10 in Nemesis (Juperon, outside the asylum). - if (frame->w > dstw || frame->h > dsth) { + // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only + // when a simple 2x filter is requested (e.g. the alchemists and cup sequence + // in Nemesis) + if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) { if (nod->_scaled) if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { delete nod->_scaled; -- cgit v1.2.3 From 003269dc36288a99d15c65f44d2181ad08dc6181 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 16 Dec 2014 11:08:40 +0200 Subject: ZVISION: Fix the display of state variables, such as the high score Common::String::format() was used incorrectly. Also, state variables were handled incorrectly in the TTY text parser --- engines/zvision/scripting/sidefx/ttytext_node.cpp | 2 +- engines/zvision/text/text.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp index 1fb7c10792..9a7fa01649 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.cpp +++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp @@ -96,7 +96,7 @@ bool ttyTextNode::process(uint32 deltaTimeInMillis) { if (ret & TXT_RET_HASSTBOX) { Common::String buf; - buf.format("%d", _style.statebox); + buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style.statebox)); for (uint8 j = 0; j < buf.size(); j++) outchar(buf[j]); diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 0ccca214d7..406c36e5b0 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -396,7 +396,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac if (ret & TXT_RET_HASSTBOX) { Common::String buf3; - buf3.format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); + buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); buf += buf3; textPosition += buf3.size(); } -- cgit v1.2.3 From 64435ef25fb52a9113b6c73619c80bc072372950 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 16 Dec 2014 19:40:27 +0100 Subject: ACCESS: Fix cmdFreeSound, which fixes the sound played during the death animation --- engines/access/scripts.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d8f9a51e8f..b1cc2897ce 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -792,9 +792,11 @@ void Scripts::cmdFreeSound() { _vm->_events->pollEvents(); } while (!_vm->shouldQuit() && sound._playingSound); - // Free the sound - delete sound._soundTable[0]._res; - sound._soundTable.remove_at(0); + // Free the sounds + while (sound._soundTable.size() > 0) { + delete sound._soundTable[0]._res; + sound._soundTable.remove_at(0); + } } } -- cgit v1.2.3 From c3312749ff20c76a527edcc0a30291cf6033c694 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Tue, 16 Dec 2014 22:41:27 +0100 Subject: ACCESS: Fix crash when getting randomly shot in the cabin --- engines/access/amazon/amazon_resources.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 694454cc3e..989dcf15f0 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1771,7 +1771,7 @@ const char *const DEATH_TEXT_DEMO[34] = { "SAM SALVADOR NOTICES SOMEONE HAS BEEN PLAYING WITH THE CARGO. HE TRACKS YOU DOWN AND LETS YOU HAVE IT.", "THE GUARD COMES AROUND THE CORNER. HE DECIDES THAT THREE LEAD SLUGS WILL TEACH YOU TO BE MORE POLITE.", "THE CAPTAIN IS WAITING OUTSIDE THE DOOR.", - "THE CAPTAIN',27h,'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.", + "THE CAPTAIN'S RANDOM SHOOTING FINALLY FINDS ITS TARGET.", "THE CRATE OUTSIDE THE WINDOW EXPLODES, DESTROYING THE SHIP. UNFORTUNATELY, YOU'RE STILL ABOARD.", "THE DOOR WAS NOT BARRED AND THE CAPTAIN WALKS RIGHT IN AND PARTS YOUR HAIR.", "", @@ -1796,7 +1796,7 @@ const char *const DEATH_TEXT_DEMO[34] = { "YOU DO NOT GET FAR ENOUGH AWAY BEFORE THE DYNAMITE EXPLODES AND YOU ARE BLOWN INTO A THOUSAND PIECES.", "STANDING OUT IN THE OPEN YOU ARE EXPOSED TO THE HAIL OF BULLETS FROM SANCHEZ' MEN.", "THE AMAZON SENTINELS SPOT YOU AND FILL YOU FULL OF ARROWS.", - "SAM MAY BE UGLY, BUT HE',27h,'S NOT DEAF. HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.", + "SAM MAY BE UGLY, BUT HE'S NOT DEAF. HE HEARS ALL THE NOISE YOU ARE MAKING AND CANCELS YOUR BOARDING PASS.", "WITH THE BAR OFF THE DOOR THE CAPTAIN WALTZES IN AND BLOWS YOU AWAY" }; -- cgit v1.2.3 From e0cb8f52f73ba927d5bf24c9b44f6d28743509df Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 17 Dec 2014 00:13:54 +0100 Subject: SCI: fix kq6 azure&ariel scenes in dual mode #6750 script patch fixes bug #6750 in dual mode (audio+text) --- engines/sci/engine/script_patches.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index 3d76848a76..03cd1d06e9 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -1214,6 +1214,26 @@ static const uint16 kq6CDPatchAudioTextSupportGirlInTheTower[] = { PATCH_END }; +// Fixes dual mode for scenes with Azure and Ariel (room 370) +// Effectively same patch as the one for fixing "Girl In The Tower" +// Applies to at least: PC-CD +// Patched methods: rm370::init, caughtAtGateCD::changeState, caughtAtGateTXT::changeState, toLabyrinth::changeState +// Fixes bug: #6750 +static const uint16 kq6CDSignatureAudioTextSupportAzureAriel[] = { + SIG_MAGICDWORD, + 0x89, 0x5a, // lsg global[5a] + 0x35, 0x02, // ldi 02 + 0x1a, // eq? + 0x31, // bnt [jump-for-text-code] + SIG_END +}; + +static const uint16 kq6CDPatchAudioTextSupportAzureAriel[] = { + PATCH_ADDTOOFFSET(+4), + 0x12, // and + PATCH_END +}; + // Additional patch specifically for King's Quest 6 // Adds another button state for the text/audio button. We currently use the "speech" view for "dual" mode. // View 947, loop 9, cel 0+1 -> "text" @@ -1306,6 +1326,7 @@ static const SciScriptPatcherEntry kq6Signatures[] = { { false, 1009, "CD: audio + text support KQ6 Guards", 2, kq6CDSignatureAudioTextSupportGuards, kq6CDPatchAudioTextSupportGuards }, { false, 1027, "CD: audio + text support KQ6 Stepmother", 1, kq6CDSignatureAudioTextSupportStepmother, kq6CDPatchAudioTextSupportJumpAlways }, { false, 740, "CD: audio + text support KQ6 Girl In The Tower", 1, kq6CDSignatureAudioTextSupportGirlInTheTower, kq6CDPatchAudioTextSupportGirlInTheTower }, + { false, 370, "CD: audio + text support KQ6 Azure & Ariel", 6, kq6CDSignatureAudioTextSupportAzureAriel, kq6CDPatchAudioTextSupportAzureAriel }, { false, 903, "CD: audio + text support KQ6 menu", 1, kq6CDSignatureAudioTextMenuSupport, kq6CDPatchAudioTextMenuSupport }, SCI_SIGNATUREENTRY_TERMINATOR }; -- cgit v1.2.3 From 7ae4fca38e792e8d27664d58562eafe6bd049a4d Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 16 Dec 2014 22:21:49 -0500 Subject: ACCESS: Fix foreground parallex in opening scene --- engines/access/amazon/amazon_logic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index eb7d8b567d..5ac7341018 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -89,7 +89,7 @@ void CampScene::mWhileDoOpen() { Screen &screen = *_vm->_screen; EventsManager &events = *_vm->_events; - screen.setBufferScan(); + screen.setDisplayScan(); events.hideCursor(); screen.forceFadeOut(); _skipStart = false; -- cgit v1.2.3 From 3a1203ff734f7923042ed0b5ab96a460e72369ec Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 07:47:55 +0100 Subject: ACCESS: Use a while statement as suggested by _sev in the merge request Also fix a formatting issue pointed out by _sev --- engines/access/access.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index b67aebfcc0..c0f8905681 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -248,10 +248,7 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { break; } - if (soundsLeft == 0) - return; - - for (;;) { + while (soundsLeft) { _sound->freeSounds(); Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundTable.push_back(SoundEntry(res, 1)); @@ -270,8 +267,6 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { } else { ++_sndSubFile; --soundsLeft; - if (soundsLeft == 0) - break; } } } @@ -519,7 +514,8 @@ bool AccessEngine::readSavegameHeader(Common::InSaveFile *in, AccessSavegameHead // Read in the string header._saveName.clear(); char ch; - while ((ch = (char)in->readByte()) != '\0') header._saveName += ch; + while ((ch = (char)in->readByte()) != '\0') + header._saveName += ch; // Get the thumbnail header._thumbnail = Graphics::loadThumbnail(*in); -- cgit v1.2.3 From 56d28bc4c8bececc6bba2788e727718c5741d0ec Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 07:58:24 +0100 Subject: ACCESS: Split doCredit in two, putting demo code in a separate function --- engines/access/amazon/amazon_logic.cpp | 112 ++++++++++++++++----------------- engines/access/amazon/amazon_logic.h | 1 + 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 5ac7341018..0200f7a61b 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -236,74 +236,74 @@ void Opening::doCredit() { if (_pCount <= 75) _vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35)); - else if (_pCount <= 210) { - if (_vm->isDemo()) - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35)); - else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35)); - } else if (_pCount <= 272) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35)); - } else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); + else if (_pCount <= 210) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 1, Common::Point(65, 35)); + else if (_pCount <= 272) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(96, 45)); + else if (_pCount <= 334) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); + else if (_pCount <= 396) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); + else if (_pCount <= 458) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98)); + } else if (_pCount <= 520) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80)); + } else if (_pCount <= 580) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81)); + } else + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55)); +} + +void Opening::doCreditDemo() { + if (_pCount < 15) + return; + + if (_pCount <= 75) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], _vm->isDemo()? 24 : 0, Common::Point(90, 35)); + else if (_pCount <= 210) + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 25, Common::Point(82, 35)); + else if (_pCount <= 272) { + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 23, Common::Point(77, 20)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(50, 35)); } else if (_pCount <= 334) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85)); - } else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(68, 54)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 16, Common::Point(200, 70)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(170, 85)); } else if (_pCount <= 396) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30)); - } else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(103, 54)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 15, Common::Point(65, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 2, Common::Point(30, 30)); } else if (_pCount <= 458) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55)); - } else { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(8, 5)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(88, 55)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(194, 98)); - } + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 19, Common::Point(123, 40)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(115, 55)); } else if (_pCount <= 520) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110)); - } else { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(32, 13)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 8, Common::Point(162, 80)); - } + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 18, Common::Point(50, 15)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(40, 30)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 0, Common::Point(40, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 20, Common::Point(198, 95)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 3, Common::Point(160, 110)); } else if (_pCount <= 580) { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105)); - } else { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 9, Common::Point(18, 15)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 10, Common::Point(164, 81)); - } + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 21, Common::Point(40, 10)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 6, Common::Point(20, 25)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 22, Common::Point(145, 50)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 7, Common::Point(125, 65)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 12, Common::Point(207, 90)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 5, Common::Point(200, 105)); } else { - if (_vm->isDemo()) { - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30)); - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45)); - } else - _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(106, 55)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 11, Common::Point(125, 30)); + _vm->_buffer2.plotImage(_vm->_objectsTable[0], 4, Common::Point(115, 45)); } } void Opening::scrollTitle() { _vm->copyBF1BF2(); _vm->_newRects.clear(); - doCredit(); + if (_vm->isDemo()) + doCreditDemo(); + else + doCredit(); _vm->copyRects(); _vm->copyBF2Vid(); } diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 9b429d8108..c8e77455b0 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -84,6 +84,7 @@ private: void doTitle(); void doCredit(); + void doCreditDemo(); void scrollTitle(); void doTent(); public: -- cgit v1.2.3 From 1496ad9717f499a73ce96cf318c6bf8070f02915 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 08:29:24 +0100 Subject: ACCESS: Split mouse data per line --- engines/access/amazon/amazon_resources.cpp | 317 ++++++++++++++++++++--------- 1 file changed, 217 insertions(+), 100 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 989dcf15f0..55302c0708 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -71,126 +71,243 @@ const char *const FILENAMES_DEMO[] = { "R49.AP", "R49.AP", "R49.AP", "R49.AP", "DEAD.AP", "EST.AP", "CHAPTER.AP", "MUSIC.AP", "SOUND.AP", "INV.AP" }; + const byte MOUSE0[] = { + // hotspot x and y, uint16 LE 0, 0, 0, 0, - 0, 2, 6, 1, 0, 3, 6, 6, 1, 0, 3, 6, 6, 1, - 0, 4, 6, 6, 6, 1, 0, 4, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, - 1, 0, 5, 6, 6, 6, 6, 1, 0, 6, 6, 6, 6, 6, 6, 1, 0, 6, - 6, 6, 6, 6, 6, 1, 0, 7, 6, 6, 6, 6, 6, 6, 1, 0, 6, 6, - 6, 6, 6, 6, 1, 0, 5, 6, 6, 6, 6, 1, 2, 3, 6, 6, 1, 3, - 3, 6, 6, 1, 3, 3, 6, 6, 1, 4, 2, 6, 1 + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0, 2, 6, 1, + 0, 3, 6, 6, 1, + 0, 3, 6, 6, 1, + 0, 4, 6, 6, 6, 1, + 0, 4, 6, 6, 6, 1, + 0, 5, 6, 6, 6, 6, 1, + 0, 5, 6, 6, 6, 6, 1, + 0, 6, 6, 6, 6, 6, 6, 1, + 0, 6, 6, 6, 6, 6, 6, 1, + 0, 7, 6, 6, 6, 6, 6, 6, 1, + 0, 6, 6, 6, 6, 6, 6, 1, + 0, 5, 6, 6, 6, 6, 1, + 2, 3, 6, 6, 1, + 3, 3, 6, 6, 1, + 3, 3, 6, 6, 1, + 4, 2, 6, 1 }; + const byte MOUSE1[] = { - 0x07, 0x00, 0x07, 0x00, 0x06, 0x01, 0x05, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x03, 0x07, - 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, - 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, - 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x0D, 0x05, 0x00, - 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, 0x01, 0x0B, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xFF, 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, - 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, - 0x06, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + // hotspot x and y, uint16 LE + 0x07, 0x00, 0x07, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x06, 0x01, 0x05, + 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, + 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, + 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x00, 0x0D, 0x05, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x05, 0x00, 0x00, 0x05, + 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x01, 0x0B, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x02, 0x09, 0xFF, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xFF, + 0x03, 0x07, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, + 0x04, 0x05, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, + 0x06, 0x01, 0x05, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; + const byte MOUSE2[] = { - 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, - 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x02, 0x0C, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, - 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x07, 0x02, 0x04, 0x05, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + // hotspot x and y, uint16 LE + 0x08, 0x00, 0x08, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x00, 0x00, + 0x00, 0x00, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x02, 0x0C, 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x07, 0x02, 0x04, 0x05, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; + const byte MOUSE3[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, 0x00, - 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x00, 0x0C, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, - 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x05, 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, - 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x0C, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x01, 0x0B, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + // hotspot x and y, uint16 LE + 0x00, 0x00, 0x00, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x00, 0x0B, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x05, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x00, 0x0C, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, + 0x01, 0x0B, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; const byte CURSEYE[] = { - 0x01, 0x00, 0x08, 0x00, 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x03, 0x09, 0x0E, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, - 0x34, 0x01, 0x01, 0x0D, 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, - 0x04, 0x01, 0x0D, 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, - 0x07, 0x06, 0x01, 0x0E, 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, - 0x06, 0x0F, 0x0E, 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x01, 0x01, - 0x07, 0x00, 0x03, 0x07, 0x01, 0x07, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00 + // hotspot x and y, uint16 LE + 0x01, 0x00, 0x08, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x04, 0x06, 0x0E, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x03, 0x09, 0x0E, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0D, 0x0D, + 0x02, 0x0B, 0x0E, 0x01, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x01, 0x01, 0x0D, + 0x01, 0x0D, 0x0E, 0x01, 0x04, 0x34, 0x01, 0x01, 0x01, 0x07, 0x33, 0x04, 0x04, 0x01, 0x0D, + 0x00, 0x0F, 0x0E, 0x0E, 0x01, 0x07, 0x33, 0x33, 0x01, 0x01, 0x33, 0x34, 0x07, 0x07, 0x06, 0x01, 0x0E, + 0x01, 0x0D, 0x0F, 0x0F, 0x06, 0x07, 0x34, 0x33, 0x33, 0x34, 0x07, 0x07, 0x06, 0x0F, 0x0E, + 0x03, 0x09, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, + 0x01, 0x01, 0x07, + 0x00, 0x03, 0x07, 0x01, 0x07, + 0x01, 0x01, 0x07, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; + const byte CURSHAND[] = { - 0x02, 0x00, 0x03, 0x00, 0x07, 0x02, 0x17, 0x0E, 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, - 0x0E, 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, 0x01, - 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, 0x02, - 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, 0x04, 0x0B, - 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x04, 0x0B, 0x17, 0x0E, 0x12, - 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, - 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, - 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, - 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, - 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, - 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, - 0x0F, 0x0E, 0x0D, 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x08, - 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, - 0x0D + // hotspot x and y, uint16 LE + 0x02, 0x00, 0x03, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x07, 0x02, 0x17, 0x0E, + 0x05, 0x07, 0x0E, 0x12, 0x17, 0x0E, 0x13, 0x17, 0x0E, + 0x02, 0x0C, 0x07, 0x00, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x00, 0x17, + 0x01, 0x0E, 0x07, 0x01, 0x07, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x11, 0x0F, 0x0E, 0x12, 0x17, 0x0E, + 0x02, 0x0D, 0x07, 0x00, 0x17, 0x0F, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0E, + 0x04, 0x0B, 0x0F, 0x0E, 0x11, 0x17, 0x0E, 0x12, 0x0F, 0x0F, 0x11, 0x17, 0x0E, + 0x04, 0x0B, 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x12, 0x17, 0x0E, 0x11, 0x0F, 0x0E, + 0x00, 0x0F, 0x0E, 0x0D, 0x12, 0x00, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x12, 0x0F, 0x0E, 0x12, 0x17, 0x0F, + 0x00, 0x0F, 0x0F, 0x17, 0x0D, 0x11, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, + 0x01, 0x0E, 0x0F, 0x17, 0x0F, 0x0E, 0x0F, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, + 0x02, 0x0D, 0x0F, 0x17, 0x0F, 0x0E, 0x0D, 0x0D, 0x0F, 0x0F, 0x0E, 0x0F, 0x0E, 0x0E, 0x12, + 0x03, 0x0C, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, + 0x04, 0x0A, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0E, 0x0F, 0x0F, 0x0E, 0x0D, + 0x05, 0x09, 0x0F, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, + 0x06, 0x08, 0x17, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0D, 0x12, + 0x06, 0x07, 0x17, 0x0F, 0x0F, 0x0F, 0x3D, 0x0E, 0x0D }; + const byte CURSGET[] = { - 0x07, 0x00, 0x0E, 0x00, 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x1C, 0x07, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0C, 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x03, 0x0C, 0x07, - 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x02, 0x0D, 0x1C, 0x0F, 0x0E, - 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0F, 0x1C, 0x0E, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0D, - 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, 0x00, 0x0E, 0x1C, 0x0E, - 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, 0x00, 0x0D, 0x1C, 0x0D, - 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, 0x01, 0x0B, 0x0E, 0x0F, 0x0E, - 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, - 0x0E, 0x0F, 0x0C, 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, 0x07, 0x01, 0x07 + // hotspot x and y, uint16 LE + 0x07, 0x00, 0x0E, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x0A, 0x05, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, + 0x08, 0x08, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x06, 0x0A, 0x1C, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x05, 0x0A, 0x07, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x03, 0x0C, 0x07, 0x1C, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x02, 0x0D, 0x1C, 0x0F, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x01, 0x0E, 0x07, 0x0F, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x00, 0x0F, 0x1C, 0x0F, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0C, + 0x00, 0x0F, 0x1C, 0x0E, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x0C, 0x0E, 0x0F, 0x0F, 0x0F, 0x0C, + 0x00, 0x0E, 0x1C, 0x0D, 0x0F, 0x0E, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x0F, 0x0F, 0x0C, + 0x00, 0x0E, 0x1C, 0x0E, 0x0F, 0x0D, 0x0F, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0F, 0x0C, + 0x00, 0x0D, 0x1C, 0x0D, 0x0F, 0x0D, 0x0F, 0x0C, 0x00, 0x00, 0x00, 0x0E, 0x1C, 0x0F, 0x0C, + 0x01, 0x0B, 0x0E, 0x0F, 0x0E, 0x0F, 0x0C, 0x00, 0x00, 0x0E, 0x07, 0x0F, 0x0C, + 0x02, 0x09, 0x0E, 0x0D, 0x0F, 0x0C, 0x00, 0x07, 0x0E, 0x0F, 0x0C, + 0x03, 0x06, 0x0E, 0x0F, 0x0E, 0x07, 0x01, 0x07, + 0x07, 0x01, 0x07 }; + const byte CURSCLIMB[] = { - 0x03, 0x00, 0x0E, 0x00, 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01, - 0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, 0x07, 0x02, 0x0F, 0x0D, 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, - 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, - 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, - 0x12, 0x11, 0x11, 0x0E, 0x0D, 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, - 0x00, 0x0E, 0x0D, 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D, - 0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, 0x03, - 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20, - 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, 0x03, 0x09, 0x07, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x22, 0x04, 0x20, 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x20, 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 + // hotspot x and y, uint16 LE + 0x03, 0x00, 0x0E, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x06, 0x04, 0x01, 0x01, 0x01, 0x01, + 0x06, 0x04, 0x0F, 0x0E, 0x01, 0x01, + 0x06, 0x04, 0x0F, 0x0E, 0x0D, 0x01, + 0x07, 0x02, 0x0F, 0x0D, + 0x00, 0x0C, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x13, 0x12, 0x12, 0x12, 0x12, 0x11, 0x11, + 0x00, 0x0D, 0x0D, 0x0E, 0x00, 0x00, 0x13, 0x14, 0x13, 0x12, 0x12, 0x12, 0x11, 0x11, 0x0E, + 0x01, 0x0C, 0x0D, 0x0D, 0x0D, 0x0E, 0x11, 0x13, 0x13, 0x12, 0x11, 0x11, 0x0E, 0x0D, + 0x02, 0x0C, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x13, 0x12, 0x11, 0x00, 0x00, 0x0E, 0x0D, + 0x03, 0x0B, 0x04, 0x04, 0x04, 0x22, 0x21, 0x21, 0x20, 0x00, 0x00, 0x00, 0x0D, + 0x02, 0x0D, 0x22, 0x04, 0x20, 0x22, 0x04, 0x21, 0x04, 0x20, 0x00, 0x00, 0x00, 0x0E, 0x0E, + 0x03, 0x07, 0x22, 0x21, 0x20, 0x20, 0x22, 0x04, 0x20, + 0x04, 0x06, 0x01, 0x01, 0x00, 0x04, 0x22, 0x20, + 0x02, 0x09, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0x20, + 0x03, 0x09, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x22, 0x04, 0x20, + 0x02, 0x0B, 0x07, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x20, + 0x03, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01 }; + const byte CURSTALK[] = { - 0x02, 0x00, 0x0B, 0x00, 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x0C, - 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x0E, 0x06, 0x06, - 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, 0x00, 0x0F, 0x06, 0x08, - 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x00, 0x0F, 0x06, - 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, 0x00, 0x0F, - 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x01, - 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x02, - 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x04, 0x09, 0x06, - 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, 0x02, 0x08, - 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06, - 0x02, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + // hotspot x and y, uint16 LE + 0x02, 0x00, 0x0B, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x03, 0x08, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x01, 0x0C, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, + 0x00, 0x0E, 0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x07, 0x06, 0x07, 0x06, + 0x00, 0x0F, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, + 0x00, 0x0F, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x08, 0x06, 0x06, + 0x00, 0x0F, 0x06, 0x06, 0x08, 0x06, 0x08, 0x08, 0x08, 0x06, 0x08, 0x06, 0x06, 0x08, 0x06, 0x08, 0x06, + 0x01, 0x0E, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, 0x08, 0x08, 0x06, 0x08, 0x06, 0x08, 0x06, + 0x02, 0x0C, 0x06, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, 0x06, 0x07, 0x06, 0x07, 0x06, + 0x04, 0x09, 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x06, 0x06, + 0x07, 0x04, 0x06, 0x07, 0x07, 0x06, + 0x02, 0x08, 0x07, 0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x01, 0x06, 0x07, 0x01, 0x07, 0x06, 0x06, 0x06, + 0x02, 0x01, 0x07, + 0x00, 0x00, + 0x00, 0x00, + 0x00, 0x00 }; const byte CURSHELP[] = { - 0x02, 0x00, 0x0B, 0x00, 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x02, 0x0A, 0x24, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, - 0x20, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, - 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, - 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, - 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x20, 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x07, 0x24, - 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, 0x02, 0x07, 0x07, - 0x00, 0x24, 0x20, 0x20, 0x20, 0x20, 0x01, 0x03, 0x07, 0x01, 0x07, 0x02, 0x07, 0x07, 0x00, 0x00, - 0x24, 0x24, 0x24, 0x24, 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x04, 0x06, 0x24, 0x22, - 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 + // hotspot x and y, uint16 LE + 0x02, 0x00, 0x0B, 0x00, + // byte 1: number of skipped pixels + // byte 2: number of plotted pixels + // then, pixels + 0x04, 0x06, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x02, 0x0A, 0x24, 0x24, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, + 0x01, 0x0C, 0x24, 0x22, 0x22, 0x22, 0x20, 0x20, 0x20, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, + 0x00, 0x0E, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x20, + 0x01, 0x0D, 0x24, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x07, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x05, 0x07, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x20, + 0x04, 0x05, 0x24, 0x22, 0x22, 0x22, 0x20, + 0x02, 0x07, 0x07, 0x00, 0x24, 0x20, 0x20, 0x20, 0x20, + 0x01, 0x03, 0x07, 0x01, 0x07, + 0x02, 0x07, 0x07, 0x00, 0x00, 0x24, 0x24, 0x24, 0x24, + 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, + 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 }; const byte *CURSORS[10] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP -- cgit v1.2.3 From 82dfe2a5bcac49e2abbec98f09693810839e422e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 18:25:24 +0100 Subject: ACCESS: Use writeString in writeSavegameHeader --- engines/access/access.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index c0f8905681..cc443131b7 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -8,12 +8,12 @@ * 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. @@ -540,7 +540,7 @@ void AccessEngine::writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameH out->writeByte(ACCESS_SAVEGAME_VERSION); // Write savegame name - out->write(header._saveName.c_str(), header._saveName.size()); + out->writeString(header._saveName); out->writeByte('\0'); // Write a thumbnail of the screen -- cgit v1.2.3 From c8d6370edfef51fc0b5d3382cb5141613046d400 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 18:27:01 +0100 Subject: ACCESS: Fix broken file header --- engines/access/amazon/amazon_resources.cpp | 12 ++++++------ engines/access/files.cpp | 12 ++++++------ engines/access/resources.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 55302c0708..e61c704b1d 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1,22 +1,22 @@ /* ScummVM - Graphic Adventure Engine * - * ScummVM is the legal property of its developers, 0xwhose names + * 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, 0xor (at your option) any later version. - + * 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, 0xwrite to the Free Software - * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 004886a379..1e81b7c428 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -1,22 +1,22 @@ /* ScummVM - Graphic Adventure Engine * - * ScummVM is the legal property of its developers, 0xwhose names + * 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, 0xor (at your option) any later version. - + * 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, 0xwrite to the Free Software - * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 41f611d136..6282d93889 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -1,22 +1,22 @@ /* ScummVM - Graphic Adventure Engine * - * ScummVM is the legal property of its developers, 0xwhose names + * 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, 0xor (at your option) any later version. - + * 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, 0xwrite to the Free Software - * Foundation, 0xInc., 0x51 Franklin Street, 0xFifth Floor, 0xBoston, 0xMA 02110-1301, 0xUSA. + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ -- cgit v1.2.3 From 492d974550924522774181cbcfa559c4b7e7b3a1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 18:27:47 +0100 Subject: ACCESS: Some more polishing in the file headers --- engines/access/access.h | 4 ++-- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/amazon/amazon_game.h | 4 ++-- engines/access/amazon/amazon_logic.cpp | 4 ++-- engines/access/amazon/amazon_logic.h | 4 ++-- engines/access/amazon/amazon_player.cpp | 4 ++-- engines/access/amazon/amazon_player.h | 4 ++-- engines/access/amazon/amazon_resources.h | 4 ++-- engines/access/amazon/amazon_room.cpp | 4 ++-- engines/access/amazon/amazon_room.h | 4 ++-- engines/access/amazon/amazon_scripts.cpp | 4 ++-- engines/access/amazon/amazon_scripts.h | 4 ++-- engines/access/animation.cpp | 4 ++-- engines/access/animation.h | 4 ++-- engines/access/asurface.cpp | 4 ++-- engines/access/asurface.h | 4 ++-- engines/access/bubble_box.cpp | 4 ++-- engines/access/bubble_box.h | 4 ++-- engines/access/char.cpp | 4 ++-- engines/access/char.h | 4 ++-- engines/access/data.cpp | 4 ++-- engines/access/data.h | 4 ++-- engines/access/debugger.cpp | 6 +++--- engines/access/debugger.h | 6 +++--- engines/access/decompress.cpp | 4 ++-- engines/access/decompress.h | 4 ++-- engines/access/detection.cpp | 5 ++--- engines/access/detection_tables.h | 4 ++-- engines/access/events.cpp | 4 ++-- engines/access/events.h | 4 ++-- engines/access/files.h | 4 ++-- engines/access/font.cpp | 4 ++-- engines/access/font.h | 4 ++-- engines/access/inventory.cpp | 4 ++-- engines/access/inventory.h | 4 ++-- engines/access/player.cpp | 4 ++-- engines/access/player.h | 4 ++-- engines/access/resources.h | 4 ++-- engines/access/room.cpp | 4 ++-- engines/access/room.h | 4 ++-- engines/access/screen.cpp | 4 ++-- engines/access/screen.h | 4 ++-- engines/access/scripts.cpp | 4 ++-- engines/access/scripts.h | 4 ++-- engines/access/sound.cpp | 4 ++-- engines/access/sound.h | 4 ++-- engines/access/video.cpp | 4 ++-- engines/access/video.h | 4 ++-- 48 files changed, 98 insertions(+), 99 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 5470d2a208..2672f3b57d 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 9a86642579..6ee4242797 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_game.h b/engines/access/amazon/amazon_game.h index 5d87cc434e..8f6dffe28c 100644 --- a/engines/access/amazon/amazon_game.h +++ b/engines/access/amazon/amazon_game.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 0200f7a61b..2e936177d1 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index c8e77455b0..5c781727c0 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_player.cpp b/engines/access/amazon/amazon_player.cpp index 2780922935..b1ed501fce 100644 --- a/engines/access/amazon/amazon_player.cpp +++ b/engines/access/amazon/amazon_player.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h index 200b530aa1..2d3797234d 100644 --- a/engines/access/amazon/amazon_player.h +++ b/engines/access/amazon/amazon_player.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index c4d2cc994d..e7afa2a977 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index d026f7b6a5..82e6db61dc 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_room.h b/engines/access/amazon/amazon_room.h index ab9212724f..6396f80199 100644 --- a/engines/access/amazon/amazon_room.h +++ b/engines/access/amazon/amazon_room.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 6f9d9c9697..633188e4dd 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 573ffb89bf..bdbabfc84d 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index b13fcfdc1e..f030e32eea 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/animation.h b/engines/access/animation.h index 8a39333764..97d45c7b8f 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index e135ae7184..45ce44dfc8 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 139565190b..833927e4ba 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index e9e2a182c0..572567c3a3 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 128bd618ff..8a4d67ecc2 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/char.cpp b/engines/access/char.cpp index d5eec3eb7f..5bc6707509 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/char.h b/engines/access/char.h index 4bd38d7c6d..882e7077a3 100644 --- a/engines/access/char.h +++ b/engines/access/char.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/data.cpp b/engines/access/data.cpp index cbc52c0a26..cf40e81ccb 100644 --- a/engines/access/data.cpp +++ b/engines/access/data.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/data.h b/engines/access/data.h index 6b44eddd75..19413ecd7e 100644 --- a/engines/access/data.h +++ b/engines/access/data.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index 5eb615f4dc..fb5c4d5b22 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -8,12 +8,12 @@ * 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 + * 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. diff --git a/engines/access/debugger.h b/engines/access/debugger.h index 6bd23740cd..f4d8df7634 100644 --- a/engines/access/debugger.h +++ b/engines/access/debugger.h @@ -8,12 +8,12 @@ * 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 + * 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. diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp index 45ae07d712..62bff87860 100644 --- a/engines/access/decompress.cpp +++ b/engines/access/decompress.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/decompress.h b/engines/access/decompress.h index 400aee476c..eea450086b 100644 --- a/engines/access/decompress.h +++ b/engines/access/decompress.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index 914f98e232..abd560404b 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -8,17 +8,16 @@ * 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 "access/access.h" diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index ec1507633c..ed3989ac48 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/events.cpp b/engines/access/events.cpp index cd1880b338..f504c869ed 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/events.h b/engines/access/events.h index 3fdcf12136..b8c5f0ee5e 100644 --- a/engines/access/events.h +++ b/engines/access/events.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/files.h b/engines/access/files.h index f90071df85..8b1aef0363 100644 --- a/engines/access/files.h +++ b/engines/access/files.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 1aadfb6be2..3ff1b7e679 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/font.h b/engines/access/font.h index d8517e3720..6a812051ca 100644 --- a/engines/access/font.h +++ b/engines/access/font.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 49fa6e7efc..d09b784adf 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/inventory.h b/engines/access/inventory.h index 820b15b40f..6a9390eda9 100644 --- a/engines/access/inventory.h +++ b/engines/access/inventory.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 35c5dadf02..f56bd69533 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/player.h b/engines/access/player.h index 631452f12d..ab4222eece 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/resources.h b/engines/access/resources.h index 10f2adb97e..8d59b1b1f1 100644 --- a/engines/access/resources.h +++ b/engines/access/resources.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f4826090b1..fc9cb6a4a0 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/room.h b/engines/access/room.h index db794dbc96..1ba4af10e2 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 3e6bd7e38f..d0974bde26 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/screen.h b/engines/access/screen.h index 775cb6b0c3..1cec75d5e7 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index b1cc2897ce..8b664520d4 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/scripts.h b/engines/access/scripts.h index 320da73bbb..fbc3e743a5 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 57f95c9516..a7d96dac9a 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/sound.h b/engines/access/sound.h index ed8fe0b060..d0f4584fac 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/video.cpp b/engines/access/video.cpp index eb50083de5..b7d5652e5b 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -8,12 +8,12 @@ * 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. diff --git a/engines/access/video.h b/engines/access/video.h index 65d6ad61a7..6331ea4405 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -8,12 +8,12 @@ * 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. -- cgit v1.2.3 From 7d73acbccc9fd2178c711c973b62e216ffdcfd4b Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 18:36:49 +0100 Subject: ACCESS: Remove useless defines --- engines/access/access.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/engines/access/access.h b/engines/access/access.h index 2672f3b57d..c98462003e 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -58,10 +58,6 @@ */ namespace Access { -#define DEBUG_BASIC 1 -#define DEBUG_INTERMEDIATE 2 -#define DEBUG_DETAILED 3 - enum { GType_Amazon = 1, GType_MartianMemorandum = 2, -- cgit v1.2.3 From 9daf9a30c07ede6d5c931af06976d6582fa38ba1 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 19:13:23 +0100 Subject: ACCESS: Modify the indentation of constructor when it's multiline --- engines/access/access.cpp | 6 +++--- engines/access/amazon/amazon_game.cpp | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index cc443131b7..dd6d0ea129 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -31,9 +31,9 @@ namespace Access { -AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) : - _gameDescription(gameDesc), Engine(syst), _randomSource("Access"), - _useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) { +AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) + : _gameDescription(gameDesc), Engine(syst), _randomSource("Access"), + _useItem(_flags[99]), _startup(_flags[170]), _manScaleOff(_flags[172]) { _animation = nullptr; _bubbleBox = nullptr; _char = nullptr; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 6ee4242797..4c57b585b9 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -30,14 +30,12 @@ namespace Access { namespace Amazon { -AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) : -AccessEngine(syst, gameDesc), - _guardLocation(_flags[122]), _guardFind(_flags[128]), _helpLevel(_flags[167]), - _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), _flashbackFlag(_flags[171]), - _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), _badEnd(_flags[218]), - _noHints(_flags[219]), _aniFlag(_flags[229]), _allenFlag(_flags[237]), - _noSound(_flags[239]) { - +AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) + : AccessEngine(syst, gameDesc), _guardLocation(_flags[122]), _guardFind(_flags[128]), + _helpLevel(_flags[167]), _jasMayaFlag(_flags[168]), _moreHelp(_flags[169]), + _flashbackFlag(_flags[171]), _riverFlag(_flags[185]), _aniOutFlag(_flags[195]), + _badEnd(_flags[218]), _noHints(_flags[219]), _aniFlag(_flags[229]), + _allenFlag(_flags[237]), _noSound(_flags[239]) { _ant = nullptr; _cast = nullptr; _guard = nullptr; -- cgit v1.2.3 From 67a40fd9b0be371fcc80f01d5cda73e7272027d0 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 19:14:14 +0100 Subject: ACCESS: Add missing space before semicolumn in constructors --- engines/access/amazon/amazon_logic.cpp | 8 ++++---- engines/access/amazon/amazon_room.cpp | 2 +- engines/access/animation.cpp | 3 +-- engines/access/debugger.cpp | 2 +- engines/access/events.cpp | 2 +- engines/access/files.cpp | 2 +- engines/access/martian/martian_game.cpp | 3 +-- engines/access/martian/martian_room.cpp | 2 +- engines/access/player.cpp | 2 +- 9 files changed, 12 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 2e936177d1..90bc29c329 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -32,7 +32,7 @@ namespace Access { namespace Amazon { -PannedScene::PannedScene(AmazonEngine *vm): AmazonManager(vm) { +PannedScene::PannedScene(AmazonEngine *vm) : AmazonManager(vm) { for (int i = 0; i < PAN_SIZE; ++i) { _pan[i]._pObject = nullptr; _pan[i]._pImgNum = 0; @@ -559,7 +559,7 @@ void Opening::doTent() { /*------------------------------------------------------------------------*/ -Plane::Plane(AmazonEngine *vm): PannedScene(vm) { +Plane::Plane(AmazonEngine *vm) : PannedScene(vm) { _pCount = 0; _planeCount = 0; _propCount = 0; @@ -969,7 +969,7 @@ void Jungle::scrollJWalk() { /*------------------------------------------------------------------------*/ -Guard::Guard(AmazonEngine *vm): PannedScene(vm) { +Guard::Guard(AmazonEngine *vm) : PannedScene(vm) { _guardCel = 0; _gCode1 = _gCode2 = 0; _xMid = _yMid = 0; @@ -1359,7 +1359,7 @@ void Cast::doCast(int param1) { /*------------------------------------------------------------------------*/ -River::River(AmazonEngine *vm): PannedScene(vm) { +River::River(AmazonEngine *vm) : PannedScene(vm) { _chickenOutFl = false; _rScrollRow = 0; _rScrollCol = 0; diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 82e6db61dc..8174969a3d 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -31,7 +31,7 @@ namespace Access { namespace Amazon { -AmazonRoom::AmazonRoom(AccessEngine *vm): Room(vm) { +AmazonRoom::AmazonRoom(AccessEngine *vm) : Room(vm) { _game = (AmazonEngine *)vm; _antOutFlag = false; _icon = nullptr; diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index f030e32eea..126f904a7f 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -49,8 +49,7 @@ AnimationResource::~AnimationResource() { /*------------------------------------------------------------------------*/ -Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : - Manager(vm) { +Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Manager(vm) { uint32 startOfs = stream->pos(); _type = stream->readByte(); diff --git a/engines/access/debugger.cpp b/engines/access/debugger.cpp index fb5c4d5b22..6cb2bb606c 100644 --- a/engines/access/debugger.cpp +++ b/engines/access/debugger.cpp @@ -137,7 +137,7 @@ bool Debugger::Cmd_Cheat(int argc, const char **argv) { namespace Amazon { -AmazonDebugger::AmazonDebugger(AccessEngine *vm): Debugger(vm) { +AmazonDebugger::AmazonDebugger(AccessEngine *vm) : Debugger(vm) { registerCmd("chapter", WRAP_METHOD(AmazonDebugger, Cmd_StartChapter)); } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index f504c869ed..c314fe9444 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -35,7 +35,7 @@ namespace Access { -EventsManager::EventsManager(AccessEngine *vm): _vm(vm) { +EventsManager::EventsManager(AccessEngine *vm) : _vm(vm) { _cursorId = CURSOR_NONE; _normalMouse = CURSOR_CROSSHAIRS; _frameCounter = 10; diff --git a/engines/access/files.cpp b/engines/access/files.cpp index 1e81b7c428..42a7914638 100644 --- a/engines/access/files.cpp +++ b/engines/access/files.cpp @@ -79,7 +79,7 @@ byte *Resource::data() { /*------------------------------------------------------------------------*/ -FileManager::FileManager(AccessEngine *vm): _vm(vm) { +FileManager::FileManager(AccessEngine *vm) : _vm(vm) { switch (vm->getGameID()) { case GType_Amazon: if (_vm->isDemo()) diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index e534b6cc03..6392206209 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -31,8 +31,7 @@ namespace Access { namespace Martian { -MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) : - AccessEngine(syst, gameDesc) { +MartianEngine::MartianEngine(OSystem *syst, const AccessGameDescription *gameDesc) : AccessEngine(syst, gameDesc) { } MartianEngine::~MartianEngine() { diff --git a/engines/access/martian/martian_room.cpp b/engines/access/martian/martian_room.cpp index 22f456fd4c..e9d1b9d8cf 100644 --- a/engines/access/martian/martian_room.cpp +++ b/engines/access/martian/martian_room.cpp @@ -31,7 +31,7 @@ namespace Access { namespace Martian { -MartianRoom::MartianRoom(AccessEngine *vm): Room(vm) { +MartianRoom::MartianRoom(AccessEngine *vm) : Room(vm) { _game = (MartianEngine *)vm; } diff --git a/engines/access/player.cpp b/engines/access/player.cpp index f56bd69533..828be0135d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -38,7 +38,7 @@ Player *Player::init(AccessEngine *vm) { } } -Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() { +Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() { Common::fill(&_walkOffRight[0], &_walkOffRight[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffLeft[0], &_walkOffLeft[PLAYER_DATA_COUNT], 0); Common::fill(&_walkOffUp[0], &_walkOffUp[PLAYER_DATA_COUNT], 0); -- cgit v1.2.3 From df7fa78a860a06d110bad38e559e85257a08c87e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 21:10:50 +0100 Subject: ACCESS: Fix three out of bounds --- engines/access/amazon/amazon_game.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 4c57b585b9..66ccf3dcef 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -54,9 +54,9 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _hintLevel = 0; memset(_tileData, 0, sizeof(_tileData)); - Common::fill(&_help1[0], &_help1[366], 0); - Common::fill(&_help2[0], &_help2[366], 0); - Common::fill(&_help3[0], &_help3[366], 0); + Common::fill(&_help1[0], &_help1[365], 0); + Common::fill(&_help2[0], &_help2[365], 0); + Common::fill(&_help3[0], &_help3[365], 0); _helpTbl[0] = _help1; _helpTbl[1] = _help2; _helpTbl[2] = _help3; -- cgit v1.2.3 From ce1f04b1d5c27ca63c1e01b67ae5bfbe5faa0ee9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 21:19:33 +0100 Subject: ACCESS: Get rid of hardcoded size when using Common::Fill --- engines/access/amazon/amazon_game.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 66ccf3dcef..933a98aded 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -53,10 +53,10 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _inactiveYOff = 0; _hintLevel = 0; - memset(_tileData, 0, sizeof(_tileData)); - Common::fill(&_help1[0], &_help1[365], 0); - Common::fill(&_help2[0], &_help2[365], 0); - Common::fill(&_help3[0], &_help3[365], 0); + Common::fill(&_tileData[0], &_tileData[0] + sizeof(_tileData), 0); + Common::fill(&_help1[0], &_help1[0] + sizeof(_help1), 0); + Common::fill(&_help2[0], &_help2[0] + sizeof(_help2), 0); + Common::fill(&_help3[0], &_help3[0] + sizeof(_help3), 0); _helpTbl[0] = _help1; _helpTbl[1] = _help2; _helpTbl[2] = _help3; -- cgit v1.2.3 From fe627c5ce19482bdb111df7d5018dfcc94030115 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 21:31:26 +0100 Subject: ACCESS: Fix spacing around semicolumn in class definitions --- engines/access/amazon/amazon_logic.h | 12 ++++++------ engines/access/amazon/amazon_player.h | 2 +- engines/access/amazon/amazon_scripts.h | 2 +- engines/access/animation.h | 2 +- engines/access/bubble_box.h | 2 +- engines/access/char.h | 2 +- engines/access/martian/martian_scripts.h | 2 +- engines/access/player.h | 2 +- engines/access/room.h | 2 +- engines/access/screen.h | 2 +- engines/access/scripts.h | 2 +- engines/access/video.h | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index 5c781727c0..a1fb4eef77 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -42,7 +42,7 @@ public: AmazonManager(AmazonEngine *vm) : _vm(vm) {} }; -class PannedScene: public AmazonManager { +class PannedScene : public AmazonManager { struct PanEntry { SpriteResource *_pObject; int _pImgNum; @@ -78,7 +78,7 @@ public: void mWhileDoOpen(); }; -class Opening: public CampScene { +class Opening : public CampScene { private: int _pCount; @@ -93,7 +93,7 @@ public: void doIntroduction(); }; -class Plane: public PannedScene { +class Plane : public PannedScene { public: int _pCount; Common::Point _position; @@ -111,7 +111,7 @@ public: }; #define JUNGLE_SIZE 3 -class Jungle: public CampScene { +class Jungle : public CampScene { private: void initJWalk2(); void jungleMove(); @@ -157,7 +157,7 @@ public: void doCast(int param1); }; -class River: public PannedScene { +class River : public PannedScene { private: bool _chickenOutFl; const byte *_mapPtr; @@ -212,7 +212,7 @@ public: enum AntDirection { ANT_RIGHT = 0, ANT_LEFT = 1 }; -class Ant: public AmazonManager { +class Ant : public AmazonManager { private: AntDirection _antDirection; AntDirection _pitDirection; diff --git a/engines/access/amazon/amazon_player.h b/engines/access/amazon/amazon_player.h index 2d3797234d..236b8bd1bd 100644 --- a/engines/access/amazon/amazon_player.h +++ b/engines/access/amazon/amazon_player.h @@ -32,7 +32,7 @@ namespace Amazon { class AmazonEngine; -class AmazonPlayer: public Player { +class AmazonPlayer : public Player { private: AmazonEngine *_game; public: diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index bdbabfc84d..e10eefb4f5 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -32,7 +32,7 @@ namespace Amazon { class AmazonEngine; -class AmazonScripts: public Scripts { +class AmazonScripts : public Scripts { private: AmazonEngine *_game; protected: diff --git a/engines/access/animation.h b/engines/access/animation.h index 97d45c7b8f..722f5430ab 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -82,7 +82,7 @@ public: Animation *getAnimation(int idx) { return _animations[idx]; } }; -class Animation: public Manager { +class Animation : public Manager { private: Common::Array _frames; diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 8a4d67ecc2..2c05d096c3 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -38,7 +38,7 @@ class AccessEngine; enum BoxType { TYPE_2 = 2, TYPE_4 = 4 }; -class BubbleBox: public Manager { +class BubbleBox : public Manager { private: int _startItem, _startBox; int _charCol, _rowOff; diff --git a/engines/access/char.h b/engines/access/char.h index 882e7077a3..e89cdae49f 100644 --- a/engines/access/char.h +++ b/engines/access/char.h @@ -46,7 +46,7 @@ public: CharEntry(); }; -class CharManager: public Manager { +class CharManager : public Manager { private: void charMenu(); public: diff --git a/engines/access/martian/martian_scripts.h b/engines/access/martian/martian_scripts.h index 9f90643e22..fc7495fc47 100644 --- a/engines/access/martian/martian_scripts.h +++ b/engines/access/martian/martian_scripts.h @@ -32,7 +32,7 @@ namespace Martian { class MartianEngine; -class MartianScripts: public Scripts { +class MartianScripts : public Scripts { private: MartianEngine *_game; protected: diff --git a/engines/access/player.h b/engines/access/player.h index ab4222eece..7c8e9a2e86 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -38,7 +38,7 @@ enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4, class AccessEngine; -class Player: public ImageEntry, public Manager { +class Player : public ImageEntry, public Manager { protected: int _leftDelta, _rightDelta; int _upDelta, _downDelta; diff --git a/engines/access/room.h b/engines/access/room.h index 1ba4af10e2..44279fa6b1 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -60,7 +60,7 @@ public: enum Function { FN_NONE = 0, FN_CLEAR1 = 1, FN_CLEAR2 = 2, FN_RELOAD = 3, FN_BREAK = 4 }; -class Room: public Manager { +class Room : public Manager { private: void roomLoop(); diff --git a/engines/access/screen.h b/engines/access/screen.h index 1cec75d5e7..bf4cceaf11 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -47,7 +47,7 @@ struct ScreenSave { int _screenYOff; }; -class Screen: public ASurface { +class Screen : public ASurface { private: AccessEngine *_vm; byte _tempPalette[PALETTE_SIZE]; diff --git a/engines/access/scripts.h b/engines/access/scripts.h index fbc3e743a5..e12f2826de 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -35,7 +35,7 @@ class Scripts; #define SCRIPT_START_BYTE 0xE0 #define ROOM_SCRIPT 2000 -class Scripts: public Manager { +class Scripts : public Manager { private: Resource *_resource; int _specialFunction; diff --git a/engines/access/video.h b/engines/access/video.h index 6331ea4405..17825db367 100644 --- a/engines/access/video.h +++ b/engines/access/video.h @@ -33,7 +33,7 @@ namespace Access { enum VideoFlags { VIDEOFLAG_NONE = 0, VIDEOFLAG_BG = 1 }; -class VideoPlayer: public Manager { +class VideoPlayer : public Manager { struct VideoHeader { int _frameCount; int _width, _height; -- cgit v1.2.3 From e141da25e80fcf9c124661883a1818e13168bd93 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 21:39:26 +0100 Subject: ACCESS: Use a uint instead of a int in a loop based on size() --- engines/access/animation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 126f904a7f..a1b7952dd4 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -78,7 +78,7 @@ Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Man } Animation::~Animation() { - for (int i = 0; i < (int)_frames.size(); ++i) + for (uint i = 0; i < _frames.size(); ++i) delete _frames[i]; } -- cgit v1.2.3 From bb01fa31f80e45f0537b3ea02083eed113c41f9c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 22:31:29 +0100 Subject: ACCESS: Constify some resources --- engines/access/amazon/amazon_resources.cpp | 14 +++++++------- engines/access/amazon/amazon_resources.h | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index e61c704b1d..2010c7d842 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -309,7 +309,7 @@ const byte CURSHELP[] = { 0x04, 0x06, 0x24, 0x22, 0x22, 0x22, 0x22, 0x20, 0x05, 0x04, 0x20, 0x20, 0x20, 0x20 }; -const byte *CURSORS[10] = { +const byte *const CURSORS[10] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3, CURSEYE, CURSHAND, CURSGET, CURSCLIMB, CURSTALK, CURSHELP }; @@ -713,7 +713,7 @@ const byte PIT[] = { 0x62, 0x0, 0x4D, 0x0, 0x2, 0x0, 0xFF, 0xFF, 0x0 }; -const byte *ROOM_TABLE[] = { +const byte *const ROOM_TABLE[] = { CREDITS, nullptr, nullptr, nullptr, ALLISTER, HALL, JASONLAB, nullptr, ALLENLAB, OUTVAULT, VAULT, LIBRARY, JASAPT, RANSACKED, MEAN1, FLYSOUTH, CUZCO, INAIR, GREENMONKEY, INPLANE, PILFALL, COCKPIT, CRASH, SINKING, @@ -724,7 +724,7 @@ const byte *ROOM_TABLE[] = { CAVE, nullptr, nullptr, nullptr, PIT, nullptr, nullptr }; -const char *ROOM_DESCR[] = { +const char *const ROOM_DESCR[] = { "Credits", nullptr, nullptr, nullptr, "Outside of Allister Center", "Hall", "Jason's Lab", nullptr, "Allen's Lab", "Outside of the Vault", "Inside the Vault", "Reader", "Jason's Apartment", "Jason's ransacked apartment", "Cutscene 1", @@ -1080,7 +1080,7 @@ const byte ROOM_TABLE62_DEMO[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00 }; -const byte *ROOM_TABLE_DEMO[] = { +const byte *const ROOM_TABLE_DEMO[] = { ROOM_TABLE1_DEMO, nullptr, nullptr, nullptr, ROOM_TABLE5_DEMO, ROOM_TABLE6_DEMO, ROOM_TABLE7_DEMO, nullptr, ROOM_TABLE9_DEMO, ROOM_TABLE10_DEMO, ROOM_TABLE11_DEMO, ROOM_TABLE12_DEMO, ROOM_TABLE13_DEMO, ROOM_TABLE14_DEMO, ROOM_TABLE15_DEMO, @@ -1526,7 +1526,7 @@ const byte CHAP8[] = { 0x60, 0x00, 0x02, 0x00, 0xFF, 0xFF }; -const byte *CHARTBL[] = { +const byte *const CHARTBL[] = { ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD, PILOT2, TIKAGENT, BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS, @@ -1535,7 +1535,7 @@ const byte *CHARTBL[] = { CRACK, LETTER }; -const byte *CHARTBL_DEMO[] = { +const byte *const CHARTBL_DEMO[] = { ELAINE, LIB, FLASHBACK, ALLENDIE, OVERBOARD_DEMO, PILOT2, TIKAGENT, BARTENDER, PILOT1, COOK, BEXPLODE, THORNICK, MAYA, CAPTAIN, ALLEN, ARCH, GUARD1, MCANOE, CAMPFIRE, COLONEL, SOLDIERS, @@ -2156,7 +2156,7 @@ const byte MAP2[32] = { 0, 1, 0, 1, 0, 0, 0, 0xFF }; -const byte *MAPTBL[3] = {MAP0, MAP1, MAP2}; +const byte *const MAPTBL[3] = {MAP0, MAP1, MAP2}; const int DOWNRIVEROBJ[14][4] = { { 3, 77, 0, 40 }, diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index e7afa2a977..a952860bc2 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -45,7 +45,7 @@ struct RiverStruct { extern const char *const FILENAMES[]; extern const char *const FILENAMES_DEMO[]; -extern const byte *CURSORS[10]; +extern const byte *const CURSORS[10]; extern const int TRAVEL_POS[][2]; @@ -62,13 +62,13 @@ extern const int OVEROFFULY[]; extern const int OVEROFFDLX[]; extern const int OVEROFFDLY[]; -extern const byte *ROOM_TABLE[]; -extern const char *ROOM_DESCR[]; -extern const byte *ROOM_TABLE_DEMO[]; +extern const byte *const ROOM_TABLE[]; +extern const char *const ROOM_DESCR[]; +extern const byte *const ROOM_TABLE_DEMO[]; extern const int ROOM_NUMB; -extern const byte *CHARTBL[]; -extern const byte *CHARTBL_DEMO[]; +extern const byte *const CHARTBL[]; +extern const byte *const CHARTBL_DEMO[]; extern const char *const INVENTORY_NAMES[]; @@ -123,7 +123,7 @@ extern const byte MAP0[26]; extern const byte MAP1[27]; extern const byte MAP2[32]; -extern const byte *MAPTBL[3]; +extern const byte *const MAPTBL[3]; extern const int DOWNRIVEROBJ[14][4]; -- cgit v1.2.3 From c57f1919603c6a7223cb02c637f3682dfb96975f Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 22:38:01 +0100 Subject: ACCESS: Constify some resources in MM too --- engines/access/martian/martian_resources.cpp | 8 ++++---- engines/access/martian/martian_resources.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/access/martian/martian_resources.cpp b/engines/access/martian/martian_resources.cpp index 046e06c6e3..d2b5dfd5d0 100644 --- a/engines/access/martian/martian_resources.cpp +++ b/engines/access/martian/martian_resources.cpp @@ -83,7 +83,7 @@ const byte MOUSE3[] = { 6, 6, 5, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0 }; -const byte *CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 }; +const byte *const CURSORS[4] = { MOUSE0, MOUSE1, MOUSE2, MOUSE3 }; const int TRAVEL_POS[][2] = { { -1, 0 }, @@ -411,7 +411,7 @@ const byte ROOM_TABLE47[] = { 0xff, 0xff, 0x2b, 0x00, 0x04, 0x00, 0xff, 0xff, 0x2e, 0x00, 0x04, 0x00, 0x01, 0x00, 0xff, 0xff, 0x00, }; -const byte *ROOM_TABLE[] = { +const byte *const ROOM_TABLE[] = { nullptr, ROOM_TABLE1, ROOM_TABLE2, ROOM_TABLE3, ROOM_TABLE4, ROOM_TABLE5, ROOM_TABLE6, ROOM_TABLE7, ROOM_TABLE8, ROOM_TABLE9, nullptr, ROOM_TABLE11, nullptr, ROOM_TABLE13, ROOM_TABLE14, ROOM_TABLE15, ROOM_TABLE16, ROOM_TABLE17, ROOM_TABLE18, nullptr, nullptr, @@ -421,7 +421,7 @@ const byte *ROOM_TABLE[] = { nullptr, nullptr, nullptr, nullptr, nullptr, ROOM_TABLE47 }; -const char *ROOM_DESCR[] = { +const char *const ROOM_DESCR[] = { nullptr, "TBD ROOM_TABLE1", "TBD ROOM_TABLE2", "TBD ROOM_TABLE3", "TBD ROOM_TABLE4", "TBD ROOM_TABLE5", "TBD ROOM_TABLE6", "TBD ROOM_TABLE7", "TBD ROOM_TABLE8", "TBD ROOM_TABLE9", nullptr, "TBD ROOM_TABLE11", nullptr, "TBD ROOM_TABLE13", "TBD ROOM_TABLE14", @@ -650,7 +650,7 @@ const byte CHAR_TABLE27[] = { 0x00, 0x49, 0x00, 0x10, 0x00, 0x49, 0x00, 0x09, 0x00, 0x49, 0x00, 0x11, 0x00, 0xff, 0xff, }; -const byte *CHAR_TABLE[] = { +const byte *const CHAR_TABLE[] = { CHAR_TABLE0, nullptr, CHAR_TABLE2, CHAR_TABLE3, CHAR_TABLE4, CHAR_TABLE5, CHAR_TABLE6, CHAR_TABLE7, CHAR_TABLE8, CHAR_TABLE9, CHAR_TABLE10, CHAR_TABLE11, CHAR_TABLE12, CHAR_TABLE13, nullptr, CHAR_TABLE15, diff --git a/engines/access/martian/martian_resources.h b/engines/access/martian/martian_resources.h index b9584ba2dd..a52967d42a 100644 --- a/engines/access/martian/martian_resources.h +++ b/engines/access/martian/martian_resources.h @@ -31,17 +31,17 @@ namespace Martian { extern const char *const FILENAMES[]; -extern const byte *CURSORS[4]; +extern const byte *const CURSORS[4]; extern const int TRAVEL_POS[][2]; extern const char *const INVENTORY_NAMES[]; -extern const byte *ROOM_TABLE[]; -extern const char *ROOM_DESCR[]; +extern const byte *const ROOM_TABLE[]; +extern const char *const ROOM_DESCR[]; extern const int ROOM_NUMB; -extern const byte *CHAR_TABLE[]; +extern const byte *const CHAR_TABLE[]; extern const int COMBO_TABLE[54][4]; -- cgit v1.2.3 From 223038924b226b67e93081a5b1c7ed18310c9834 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 22:49:01 +0100 Subject: ACCESS: Get rid of a goto --- engines/access/player.cpp | 29 ++++++++++++++++------------- engines/access/player.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 828be0135d..83f075e3d8 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -657,6 +657,19 @@ void Player::plotCom3() { plotCom2(); } +void Player::checkScrollUp() { + if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT || + _playerDirection == DOWN) && (_vm->_screen->_clipHeight - + _playerY - _scrollThreshold) <= 0) { + // Scroll up + if (scrollUp()) { + _scrollEnd = 4; + _vm->_screen->_scrollY &= TILE_HEIGHT; + _scrollFlag = true; + } + } +} + void Player::checkScroll() { _scrollFlag = false; if (_playerDirection == NONE) @@ -667,7 +680,7 @@ void Player::checkScroll() { // Scroll right if (!scrollRight()) { if (_playerDirection == DOWNLEFT) - goto scrollUp; + checkScrollUp(); return; } @@ -677,7 +690,7 @@ void Player::checkScroll() { // Scroll left if (!scrollLeft()) { if (_playerDirection == DOWNRIGHT) - goto scrollUp; + checkScrollUp(); return; } @@ -687,17 +700,7 @@ void Player::checkScroll() { _playerDirection == UP) && _playerY <= _scrollThreshold) { scrollDown(); } else { -scrollUp: - if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT || - _playerDirection == DOWN) && (_vm->_screen->_clipHeight - - _playerY - _scrollThreshold) <= 0) { - // Scroll up - if (scrollUp()) { - _scrollEnd = 4; - _vm->_screen->_scrollY &= TILE_HEIGHT; - _scrollFlag = true; - } - } + checkScrollUp(); } } diff --git a/engines/access/player.h b/engines/access/player.h index 7c8e9a2e86..e3cf5c5433 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -66,6 +66,7 @@ protected: void walkDownLeft(); void walkUpRight(); void walkDownRight(); + void checkScrollUp(); bool scrollUp(); bool scrollDown(); bool scrollLeft(); -- cgit v1.2.3 From 240b9dcaeba7f28800df1cd6929ceed4bb3cff33 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 22:54:29 +0100 Subject: ACCESS: Format Direction enum as suggested by LordHoto --- engines/access/player.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/engines/access/player.h b/engines/access/player.h index e3cf5c5433..26caec681f 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -33,8 +33,17 @@ namespace Access { #define PLAYER_DATA_COUNT 8 -enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4, - UPRIGHT = 5, DOWNRIGHT = 6, UPLEFT = 7, DOWNLEFT = 8 }; +enum Direction { + NONE = 0, + UP = 1, + DOWN = 2, + LEFT = 3, + RIGHT = 4, + UPRIGHT = 5, + DOWNRIGHT = 6, + UPLEFT = 7, + DOWNLEFT = 8 +}; class AccessEngine; -- cgit v1.2.3 From 207c4012ad33f7f11b5375c1478ed2f5e13679b9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:05:22 +0100 Subject: ACCESS: replace an assert by an error as suggested by LordHoto --- engines/access/scripts.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 8b664520d4..79d74694a1 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -98,7 +98,9 @@ int Scripts::executeScript() { while ((_scriptCommand = _data->readByte()) == SCRIPT_START_BYTE) _data->skip(2); - assert(_scriptCommand >= 0x80); + if (_scriptCommand < 0x80) + error("Unexpected opcode value %d", _scriptCommand); + executeCommand(_scriptCommand - 0x80); } while (!_endFlag && !_vm->shouldQuitOrRestart()); -- cgit v1.2.3 From 79b51f20e48f9f93a519f548ba42afdcb8a03899 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:08:54 +0100 Subject: ACCESS: Use clear to empty Common::String variables --- engines/access/font.cpp | 2 +- engines/access/scripts.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/access/font.cpp b/engines/access/font.cpp index 3ff1b7e679..da8f0b6ec5 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -112,7 +112,7 @@ bool Font::getLine(Common::String &s, int maxWidth, Common::String &line, int &w // If this was the last character of the string, let it go if (*src == '\0') { line = Common::String(s.c_str(), src); - s = ""; + s.clear(); return true; } diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 79d74694a1..59d89af2f2 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -661,7 +661,7 @@ void Scripts::cmdTexChoice() { findNull(); - tmpStr = ""; + tmpStr.clear(); while ((v = _data->readByte()) != 0) tmpStr += (char)v; @@ -676,7 +676,7 @@ void Scripts::cmdTexChoice() { findNull(); bool choice3Fl = false; - tmpStr = ""; + tmpStr.clear(); while ((v = _data->readByte()) != 0) tmpStr += (char)v; -- cgit v1.2.3 From cd4183a4638e964cc7b4c6b5c7e31c1bec9ffb99 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:15:13 +0100 Subject: ACCESS: Fix indentation of METHODS in animate() --- engines/access/animation.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index a1b7952dd4..045382aa0a 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -85,9 +85,10 @@ Animation::~Animation() { typedef void(Animation::*AnimationMethodPtr)(); void Animation::animate() { - static const AnimationMethodPtr METHODS[8] = - { &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, - &Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 }; + static const AnimationMethodPtr METHODS[8] = { + &Animation::anim0, &Animation::anim1, &Animation::anim2, &Animation::anim3, + &Animation::anim4, &Animation::animNone, &Animation::animNone, &Animation::anim7 + }; (this->*METHODS[_type])(); } -- cgit v1.2.3 From a9903237034859883618de2b86a08fe5ec572881 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:21:13 +0100 Subject: ACCESS: Format the definition of ImagerFlag and fix a comment --- engines/access/animation.cpp | 2 +- engines/access/asurface.h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 045382aa0a..548e7db02d 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -191,7 +191,7 @@ void Animation::anim4() { } void Animation::animNone() { - // No implementation + // Empty implementation } void Animation::anim7() { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 833927e4ba..6ffbf0e25e 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -138,8 +138,12 @@ public: SpriteFrame *getFrame(int idx) { return _frames[idx]; } }; -enum ImageFlag { IMGFLAG_CROPPED = 1, IMGFLAG_BACKWARDS = 2, IMGFLAG_DRAWN = 4, - IMGFLAG_UNSCALED = 8 }; +enum ImageFlag { + IMGFLAG_CROPPED = 1, + IMGFLAG_BACKWARDS = 2, + IMGFLAG_DRAWN = 4, + IMGFLAG_UNSCALED = 8 +}; class ImageEntry { public: -- cgit v1.2.3 From beba3cd3f21f60ba560a7af3485389c0f3dcc065 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:22:50 +0100 Subject: ACCESS: Fix indentation issue pointed out by _sev --- engines/access/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index abd560404b..1903bf213f 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -77,7 +77,7 @@ Common::Platform AccessEngine::getPlatform() const { static const PlainGameDescriptor AccessGames[] = { {"Access", "Access"}, {"amazon", "Amazon: Guardians of Eden"}, - { "martian", "Martian Memorandum"}, + {"martian", "Martian Memorandum"}, {0, 0} }; -- cgit v1.2.3 From c11b6e3eb36f736de2a726fabfbfe7ee21466d34 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:27:55 +0100 Subject: ACCESS: Add original engine dates --- engines/access/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/detection.cpp b/engines/access/detection.cpp index 1903bf213f..441740c1b2 100644 --- a/engines/access/detection.cpp +++ b/engines/access/detection.cpp @@ -94,7 +94,7 @@ public: } virtual const char *getOriginalCopyright() const { - return "Access (c)"; + return "Access Engine (c) 1989-1994 Access Software"; } virtual bool hasFeature(MetaEngineFeature f) const; -- cgit v1.2.3 From 8fe8cf8e437df59874b0337946708cff6bb56c6d Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:35:12 +0100 Subject: ACCESS: Use AD_ENTRY1s in detection tables --- engines/access/detection_tables.h | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/engines/access/detection_tables.h b/engines/access/detection_tables.h index ed3989ac48..88a64470c5 100644 --- a/engines/access/detection_tables.h +++ b/engines/access/detection_tables.h @@ -24,14 +24,13 @@ namespace Access { static const AccessGameDescription gameDescriptions[] = { { - // Amazon Guadians of Eden - Floppy English + // Amazon Guardians of Eden - Floppy English + // 3.5" and 5.25" floppies provided by Strangerke had the same md5 + // Except the sound file. The executable is also identical { "amazon", 0, - { - { "c00.ap", 0, "dcabf69d5a0d911168cb73511ebaead0", 331481 }, - AD_LISTEND - }, + AD_ENTRY1s("c00.ap", "dcabf69d5a0d911168cb73511ebaead0", 331481), Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, @@ -44,12 +43,9 @@ static const AccessGameDescription gameDescriptions[] = { // Amazon Guardians of Eden - Demo English { { - "amazon", - "Demo", - { - { "c25.ap", 0, "5baba0c052d22157499bfa05cb1ed5b7", 65458 }, - AD_LISTEND - }, + "amazon", + "Demo", + AD_ENTRY1s("c25.ap", "5baba0c052d22157499bfa05cb1ed5b7", 65458), Common::EN_ANY, Common::kPlatformDOS, ADGF_DEMO, @@ -64,10 +60,7 @@ static const AccessGameDescription gameDescriptions[] = { { "amazon", "CD", - { - { "checksum.crc", 0, "bef85478132fec74cb5d9067f3a37d24", 8 }, - AD_LISTEND - }, + AD_ENTRY1s("checksum.crc", "bef85478132fec74cb5d9067f3a37d24", 8), Common::EN_ANY, Common::kPlatformDOS, ADGF_CD, @@ -82,10 +75,7 @@ static const AccessGameDescription gameDescriptions[] = { { "martian", nullptr, - { - { "r00.ap", 0, "af98db5ee7f9ef86c6b1f43187a3691b", 31 }, - AD_LISTEND - }, + AD_ENTRY1s("r00.ap", "af98db5ee7f9ef86c6b1f43187a3691b", 31), Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, -- cgit v1.2.3 From 20bcc7f7aac3f19e002f25dec14e4def7b9c1ca5 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Wed, 17 Dec 2014 23:45:41 +0100 Subject: ACCESS: Rename CMDPUSHLOCATION --- engines/access/scripts.cpp | 14 +++++++------- engines/access/scripts.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 59d89af2f2..ac10fe38d9 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -132,7 +132,7 @@ void Scripts::executeCommand(int commandIndex) { &Scripts::cmdSetConPos, &Scripts::cmdCheckVFrame, &Scripts::cmdJumpChoice, &Scripts::cmdReturnChoice, &Scripts::cmdClearBlock, &Scripts::cmdLoadSound, &Scripts::cmdFreeSound, &Scripts::cmdSetVideoSound, &Scripts::cmdPlayVideoSound, - &Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::CMDPUSHLOCATION, + &Scripts::cmdPrintWatch, &Scripts::cmdDispAbout, &Scripts::cmdPushLocation, &Scripts::cmdCheckTravel, &Scripts::cmdBlock, &Scripts::cmdPlayerOff, &Scripts::cmdPlayerOn, &Scripts::cmdDead, &Scripts::cmdFadeOut, &Scripts::cmdEndVideo @@ -826,7 +826,7 @@ void Scripts::cmdPlayVideoSound() { void Scripts::cmdPrintWatch() { if (_vm->isCD()) { - CMDPUSHLOCATION(); + cmdPushLocation(); return; } error("TODO: DEMO - cmdPrintWatch"); @@ -834,19 +834,19 @@ void Scripts::cmdPrintWatch() { void Scripts::cmdDispAbout() { if (_vm->isCD()) { - CMDPUSHLOCATION(); + cmdPushLocation(); return; } error("TODO: DEMO - cmdDispAbout"); } -void Scripts::CMDPUSHLOCATION() { - error("TODO CMDPUSHLOCATION"); +void Scripts::cmdPushLocation() { + error("TODO cmdPushLocation"); } void Scripts::cmdCheckTravel() { if (_vm->isCD()) { - CMDPUSHLOCATION(); + cmdPushLocation(); return; } error("TODO: DEMO - cmdCheckTravel"); @@ -854,7 +854,7 @@ void Scripts::cmdCheckTravel() { void Scripts::cmdBlock() { if (_vm->isCD()) { - CMDPUSHLOCATION(); + cmdPushLocation(); return; } error("TODO: DEMO - cmdBlock"); diff --git a/engines/access/scripts.h b/engines/access/scripts.h index e12f2826de..cfadf6d901 100644 --- a/engines/access/scripts.h +++ b/engines/access/scripts.h @@ -119,7 +119,7 @@ protected: void cmdPlayVideoSound(); void cmdPrintWatch(); void cmdDispAbout(); - void CMDPUSHLOCATION(); + void cmdPushLocation(); void cmdCheckTravel(); void cmdBlock(); void cmdPlayerOff(); -- cgit v1.2.3 From 7895c5408c37c54dcb5c30ddf7ae09f91052d768 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 18 Dec 2014 07:14:21 +0100 Subject: ACCESS: Constify general messages --- engines/access/resources.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/access/resources.cpp b/engines/access/resources.cpp index 6282d93889..4157cdfc0d 100644 --- a/engines/access/resources.cpp +++ b/engines/access/resources.cpp @@ -64,14 +64,14 @@ const int RMOUSE[10][2] = { { 142, 177 }, { 178, 212 }, { 213, 248 }, { 249, 283 }, { 284, 318 } }; -const char *LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST."; -const char *GET_MESSAGE = "YOU CAN'T TAKE THAT."; -const char *OPEN_MESSAGE = "THAT DOESN'T OPEN."; -const char *MOVE_MESSAGE = "THAT WON'T MOVE."; -const char *USE_MESSAGE = "THAT DOESN'T SEEM TO WORK."; -const char *GO_MESSAGE = "YOU CAN'T CLIMB THAT."; -const char *HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS"; -const char *TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE."; +const char *const LOOK_MESSAGE = "LOOKING THERE REVEALS NOTHING OF INTEREST."; +const char *const GET_MESSAGE = "YOU CAN'T TAKE THAT."; +const char *const OPEN_MESSAGE = "THAT DOESN'T OPEN."; +const char *const MOVE_MESSAGE = "THAT WON'T MOVE."; +const char *const USE_MESSAGE = "THAT DOESN'T SEEM TO WORK."; +const char *const GO_MESSAGE = "YOU CAN'T CLIMB THAT."; +const char *const HELP_MESSAGE = "THIS OBJECT REQUIRES NO HINTS"; +const char *const TALK_MESSAGE = "THERE SEEMS TO BE NO RESPONSE."; const char *const GENERAL_MESSAGES[] = { LOOK_MESSAGE, OPEN_MESSAGE, MOVE_MESSAGE, GET_MESSAGE, USE_MESSAGE, GO_MESSAGE, TALK_MESSAGE, HELP_MESSAGE, HELP_MESSAGE, USE_MESSAGE -- cgit v1.2.3 From 3fca9d42f3ff6d19eba40d09754cc794f8e17585 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Thu, 18 Dec 2014 07:23:18 +0100 Subject: ACCESS: Use Common::String to display bubble box text --- engines/access/bubble_box.cpp | 10 +++++----- engines/access/bubble_box.h | 2 +- engines/access/scripts.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index 572567c3a3..e37a8142e8 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -29,7 +29,7 @@ namespace Access { BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) { _type = TYPE_2; _bounds = Common::Rect(64, 32, 64 + 130, 32 + 122); - _bubblePtr = nullptr; + _bubbleDisplStr = ""; _fieldD = 0; _fieldE = 0; _fieldF = 0; @@ -43,7 +43,7 @@ void BubbleBox::load(Common::SeekableReadStream *stream) { while ((v = stream->readByte()) != 0) _bubbleTitle += (char)v; - _bubblePtr = _bubbleTitle.c_str(); + _bubbleDisplStr = _bubbleTitle; } void BubbleBox::clearBubbles() { @@ -90,7 +90,7 @@ void BubbleBox::calcBubble(const Common::String &msg) { if (_type == TYPE_4) { _vm->_fonts._printMaxX = 110; } else { - _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubblePtr); + _vm->_fonts._printMaxX = _vm->_fonts._font2.stringWidth(_bubbleDisplStr); } // Start of with a rect with the given starting x and y @@ -257,13 +257,13 @@ void BubbleBox::doBox(int item, int box) { } // Handle drawing title - int titleWidth = _vm->_fonts._font2.stringWidth(_bubblePtr); + int titleWidth = _vm->_fonts._font2.stringWidth(_bubbleDisplStr); Font &font2 = _vm->_fonts._font2; font2._fontColors[0] = 0; font2._fontColors[1] = 3; font2._fontColors[2] = 2; font2._fontColors[3] = 1; - font2.drawString(_vm->_screen, _bubblePtr, Common::Point( + font2.drawString(_vm->_screen, _bubbleDisplStr, Common::Point( _bounds.left + (_bounds.width() / 2) - (titleWidth / 2), _bounds.top + 1)); // Restore positional state diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 2c05d096c3..0130344c7e 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -48,7 +48,7 @@ public: Common::Rect _bounds; Common::StringArray _nameIndex; Common::String _bubbleTitle; - const char *_bubblePtr; + Common::String _bubbleDisplStr; int _fieldD; int _fieldE; int _fieldF; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index ac10fe38d9..99f52c0ff8 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -621,7 +621,7 @@ void Scripts::cmdTexSpeak() { while ((v = _data->readByte()) != 0) tmpStr += (char)v; - _vm->_bubbleBox->_bubblePtr = Common::String("JASON").c_str(); + _vm->_bubbleBox->_bubbleDisplStr = Common::String("JASON"); _vm->_bubbleBox->placeBubble1(tmpStr); findNull(); } @@ -645,7 +645,7 @@ void Scripts::cmdTexChoice() { _vm->_screen->_printStart = _texsOrg; _vm->_bubbleBox->clearBubbles(); - _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 1").c_str(); + _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 1"); byte v; Common::String tmpStr = ""; @@ -666,7 +666,7 @@ void Scripts::cmdTexChoice() { tmpStr += (char)v; if (tmpStr.size() != 0) { - _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 2").c_str(); + _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 2"); _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); responseCoords.push_back(_vm->_bubbleBox->_bounds); @@ -681,7 +681,7 @@ void Scripts::cmdTexChoice() { tmpStr += (char)v; if (tmpStr.size() != 0) { - _vm->_bubbleBox->_bubblePtr = Common::String("RESPONSE 3").c_str(); + _vm->_bubbleBox->_bubbleDisplStr = Common::String("RESPONSE 3"); _vm->_bubbleBox->calcBubble(tmpStr); _vm->_bubbleBox->printBubble(tmpStr); responseCoords.push_back(_vm->_bubbleBox->_bounds); @@ -698,7 +698,7 @@ void Scripts::cmdTexChoice() { charLoop(); - _vm->_bubbleBox->_bubblePtr = _vm->_bubbleBox->_bubbleTitle.c_str(); + _vm->_bubbleBox->_bubbleDisplStr = _vm->_bubbleBox->_bubbleTitle; if (_vm->_events->_leftButton) { if (_vm->_events->_mouseRow >= 22) { _vm->_events->debounceLeft(); -- cgit v1.2.3 From 864cab5e477dc5792339e05c1687b78b92318d89 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 19 Dec 2014 01:35:33 +0100 Subject: ACCESS: Fix issue related to demo-only (and unused afawk) opcodes --- engines/access/scripts.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 99f52c0ff8..d1dd5e7a7a 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -266,7 +266,7 @@ void Scripts::cmdGoto() { } void Scripts::cmdAddScore() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdSetInventory(); return; } @@ -412,7 +412,7 @@ void Scripts::cmdDispInv() { } void Scripts::cmdSetAbout() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdSetTimer(); return; } @@ -459,7 +459,7 @@ void Scripts::cmdCheckTimer() { } void Scripts::cmdSetTravel() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdJumpGoto(); return; } @@ -515,7 +515,7 @@ void Scripts::cmdSetScroll() { } void Scripts::cmdSaveRect() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdVideoEnded(); return; } @@ -551,7 +551,7 @@ void Scripts::cmdRemoveLast() { } void Scripts::cmdDoTravel() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdSpecial(); return; } @@ -559,7 +559,7 @@ void Scripts::cmdDoTravel() { } void Scripts::cmdCheckAbout() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdSpecial(); return; } @@ -825,7 +825,7 @@ void Scripts::cmdPlayVideoSound() { } void Scripts::cmdPrintWatch() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdPushLocation(); return; } @@ -833,7 +833,7 @@ void Scripts::cmdPrintWatch() { } void Scripts::cmdDispAbout() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdPushLocation(); return; } @@ -845,7 +845,7 @@ void Scripts::cmdPushLocation() { } void Scripts::cmdCheckTravel() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdPushLocation(); return; } @@ -853,7 +853,7 @@ void Scripts::cmdCheckTravel() { } void Scripts::cmdBlock() { - if (_vm->isCD()) { + if (!_vm->isDemo()) { cmdPushLocation(); return; } -- cgit v1.2.3 From 95aa9a13a6ca634af664a3ac4753faf8b8271fd9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 18 Dec 2014 21:45:55 -0500 Subject: ACCESS: Refactor most of ASurface statics to instance variables --- engines/access/access.cpp | 9 +- engines/access/access.h | 2 + engines/access/amazon/amazon_logic.cpp | 161 ++++++++++++++++----------------- engines/access/amazon/amazon_room.cpp | 6 +- engines/access/asurface.cpp | 21 +---- engines/access/asurface.h | 22 ++--- engines/access/events.cpp | 6 +- engines/access/inventory.cpp | 18 ++-- engines/access/player.cpp | 74 +++++++-------- engines/access/room.cpp | 36 ++++---- engines/access/screen.cpp | 21 ++--- engines/access/screen.h | 1 - engines/access/scripts.cpp | 8 +- 13 files changed, 184 insertions(+), 201 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index dd6d0ea129..6ad1b22408 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -66,6 +66,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleT1 = 0; _scaleMaxY = 0; _scaleI = 0; + _scrollCol = _scrollRow = 0; + _scrollX = _scrollY = 0; _imgUnscaled = false; _canSaveLoad = false; _establish = nullptr; @@ -139,7 +141,6 @@ void AccessEngine::initialize() { } // Create sub-objects of the engine - ASurface::init(); _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); _char = new CharManager(this); @@ -376,9 +377,9 @@ void AccessEngine::copyRects() { void AccessEngine::copyBF1BF2() { _buffer2.copyRectToSurface(_buffer1, 0, 0, - Common::Rect(_buffer1._scrollX, _buffer1._scrollY, - _buffer1._scrollX + _screen->_vWindowBytesWide, - _buffer1._scrollY + _screen->_vWindowLinesTall)); + Common::Rect(_scrollX, _scrollY, + _scrollX + _screen->_vWindowBytesWide, + _scrollY + _screen->_vWindowLinesTall)); } void AccessEngine::copyBF2Vid() { diff --git a/engines/access/access.h b/engines/access/access.h index c98462003e..a082b969c4 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -185,6 +185,8 @@ public: int _scaleT1; int _scaleMaxY; int _scaleI; + int _scrollX, _scrollY; + int _scrollCol, _scrollRow; bool _imgUnscaled; bool _canSaveLoad; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 90bc29c329..436a875688 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -410,11 +410,10 @@ void Opening::doTitle() { _vm->_room->loadRoom(0); screen.clearScreen(); screen.setBufferScan(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_player->_rawPlayer = Common::Point(0, 0); screen.forceFadeOut(); - screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); screen.forceFadeIn(); @@ -434,15 +433,15 @@ void Opening::doTitle() { } _vm->_events->_vbCount = 4; - if (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) { - screen._scrollX += _vm->_player->_scrollAmount; + if (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) { + _vm->_scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollTitle(); ++_pCount; @@ -460,23 +459,23 @@ void Opening::doTitle() { while (!_vm->shouldQuit()) { _pCount = 0; _vm->_events->_vbCount = 3; - if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { + if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; } - screen._scrollY = screen._scrollY + _vm->_player->_scrollAmount; + _vm->_scrollY = _vm->_scrollY + _vm->_player->_scrollAmount; - while (screen._scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { - screen._scrollY -= TILE_HEIGHT; - ++screen._scrollRow; + while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_scrollY -= TILE_HEIGHT; + ++_vm->_scrollRow; _vm->_buffer1.moveBufferUp(); // WORKAROUND: the original was using screen._vWindowBytesWide * screen._vWindowLinesTall - _vm->_room->buildRow(screen._scrollRow + screen._vWindowHeight, screen._vWindowLinesTall); + _vm->_room->buildRow(_vm->_scrollRow + screen._vWindowHeight, screen._vWindowLinesTall); - if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { + if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; @@ -657,7 +656,7 @@ void Plane::mWhileFly() { screen.clearScreen(); screen.setBufferScan(); screen.fadeOut(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -666,8 +665,8 @@ void Plane::mWhileFly() { _vm->_newRects.clear(); _vm->_events->clearEvents(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; player._rawPlayer = Common::Point(0, 0); player._scrollAmount = 1; @@ -678,16 +677,16 @@ void Plane::mWhileFly() { _position = Common::Point(20, 29); while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { + ((_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { events._vbCount = 4; - screen._scrollX += player._scrollAmount; + _vm->_scrollX += player._scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFly(); @@ -710,7 +709,7 @@ void Plane::mWhileFall() { screen.clearScreen(); screen.setBufferScan(); screen.fadeOut(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -719,8 +718,8 @@ void Plane::mWhileFall() { _vm->_newRects.clear(); _vm->_events->clearEvents(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_player->_scrollAmount = 3; _vm->_scaleI = 255; @@ -728,16 +727,16 @@ void Plane::mWhileFall() { _planeCount = 0; while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { events._vbCount = 4; - screen._scrollX += _vm->_player->_scrollAmount; + _vm->_scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFall(); @@ -765,7 +764,7 @@ void Jungle::jungleMove() { if (!_vm->_timers[0]._flag) { ++_vm->_timers[0]._flag; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + _vm->_scrollX += _vm->_player->_scrollAmount; for (int i = 0; i < 3; ++i) { int newJCnt = (_jCnt[i] + 1) % 8; @@ -808,8 +807,8 @@ void Jungle::initJWalk2() { _vm->_buffer2.clearBuffer(); screen.setBufferScan(); - screen._scrollX = screen._scrollY; - screen._scrollCol = screen._scrollRow; + _vm->_scrollX = _vm->_scrollY; + _vm->_scrollCol = _vm->_scrollRow; _vm->_room->buildScreen(); _vm->copyBF2Vid(); screen.fadeIn(); @@ -866,7 +865,7 @@ void Jungle::mWhileJWalk() { screen.clearScreen(); _vm->_buffer2.clearBuffer(); screen.setBufferScan(); - screen._scrollX = 0; + _vm->_scrollX = 0; // Build the initial jungle scene and fade it in _vm->_room->buildScreen(); @@ -930,17 +929,17 @@ void Jungle::mWhileJWalk2() { initJWalk2(); while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { + (_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { _vm->_images.clear(); _vm->_events->_vbCount = 6; _pan[0]._pImgNum = _xCount; jungleMove(); - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } if (_xCount == 2) @@ -1130,7 +1129,7 @@ void Guard::chkHLine() { void Guard::guardSee() { Screen &screen = *_vm->_screen; - int tmpY = (screen._scrollRow << 4) + screen._scrollY; + int tmpY = (_vm->_scrollRow << 4) + _vm->_scrollY; _vm->_flags[140] = 0; if (tmpY > _position.y) return; @@ -1375,7 +1374,7 @@ River::River(AmazonEngine *vm) : PannedScene(vm) { } void River::setRiverPan() { - int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + int delta = (_vm->_scrollCol * 16) + _vm->_scrollX; _xTrack = 9; _yTrack = _zTrack = 0; @@ -1420,16 +1419,16 @@ void River::initRiver() { if (_saveRiver) { // Restoring a savegame, so set properties from saved fields - screen._scrollRow = _rScrollRow; - screen._scrollCol = _rScrollCol; - screen._scrollX = _rScrollX; - screen._scrollY = _rScrollY; + _vm->_scrollRow = _rScrollRow; + _vm->_scrollCol = _rScrollCol; + _vm->_scrollX = _rScrollX; + _vm->_scrollY = _rScrollY; } else { // Set initial scene state - screen._scrollRow = 0; - screen._scrollCol = 140; - screen._scrollX = 0; - screen._scrollY = 0; + _vm->_scrollRow = 0; + _vm->_scrollCol = 140; + _vm->_scrollX = 0; + _vm->_scrollY = 0; } _vm->_room->buildScreen(); @@ -1490,7 +1489,7 @@ void River::initRiver() { void River::resetPositions() { riverSetPhysX(); - int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16; + int val = (_vm->_scrollCol + 1 - _oldScrollCol) * 16; if (val < 0) { val |= 0x80; } @@ -1500,7 +1499,7 @@ void River::resetPositions() { } void River::checkRiverPan() { - int val = _vm->_screen->_scrollCol * 16 + 320; + int val = _vm->_scrollCol * 16 + 320; for (int i = 0; i < _pNumObj; i++) { if (_pan[i]._pObjX < val) @@ -1513,21 +1512,21 @@ void River::checkRiverPan() { bool River::riverJumpTest() { Screen &screen = *_vm->_screen; - if (screen._scrollCol == 120 || screen._scrollCol == 60 || screen._scrollCol == 0) { + if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) { int val = *++_mapPtr; if (val == 0xFF) return true; - _oldScrollCol = screen._scrollCol; + _oldScrollCol = _vm->_scrollCol; if (val == 0) { - screen._scrollCol = 139; - screen._scrollX = 14; + _vm->_scrollCol = 139; + _vm->_scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } - } else if (screen._scrollCol == 105) { + } else if (_vm->_scrollCol == 105) { int val1 = _mapPtr[1]; int val2 = _mapPtr[2]; _mapPtr += 3; @@ -1543,19 +1542,19 @@ bool River::riverJumpTest() { _deathCount = 300; _deathType = val2; } - _oldScrollCol = screen._scrollCol; - screen._scrollCol = 44; - screen._scrollX = 14; + _oldScrollCol = _vm->_scrollCol; + _vm->_scrollCol = 44; + _vm->_scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } } - screen._scrollX = 14; - --screen._scrollCol; + _vm->_scrollX = 14; + --_vm->_scrollCol; _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(screen._scrollCol, 0); + _vm->_room->buildColumn(_vm->_scrollCol, 0); checkRiverPan(); return false; } @@ -1670,7 +1669,7 @@ void River::updateObstacles() { } void River::riverSetPhysX() { - int xAmt = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + int xAmt = (_vm->_scrollCol * 16) + _vm->_scrollX; for (RiverStruct *cur = _topList; cur <= _botList; ++cur) { cur->_xp = xAmt - (_screenVertX - cur->_riverX); @@ -1713,7 +1712,7 @@ void River::plotRiver() { ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; ie._frameNumber = _canoeFrame; - ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; + ie._position.x = (_vm->_scrollCol * 16) + _vm->_scrollX + 160; ie._position.y = _canoeYPos - 41; ie._offsetY = 41; _vm->_images.addToList(ie); @@ -1750,7 +1749,7 @@ void River::mWhileDownRiver() { screen.setPalette(); screen.setBufferScan(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -1783,16 +1782,16 @@ void River::mWhileDownRiver() { ++_vm->_timers[4]._flag; while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { _vm->_images.clear(); _vm->_events->_vbCount = 6; - screen._scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + _vm->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } pan(); @@ -1844,14 +1843,14 @@ void River::doRiver() { // Move the river position _screenVertX -= _vm->_player->_scrollAmount; - if (_vm->_screen->_scrollX == 0) { + if (_vm->_scrollX == 0) { _vm->_midi->midiRepeat(); if (riverJumpTest()) { _chickenOutFl = false; return; } } else { - _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; + _vm->_scrollX -= _vm->_player->_scrollAmount; } if (_chickenOutFl) { @@ -1911,10 +1910,10 @@ void River::synchronize(Common::Serializer &s) { if (s.isSaving()) { // Set river properties to be saved out Screen &screen = *_vm->_screen; - _rScrollRow = screen._scrollRow; - _rScrollCol = screen._scrollCol; - _rScrollX = screen._scrollX; - _rScrollY = screen._scrollY; + _rScrollRow = _vm->_scrollRow; + _rScrollCol = _vm->_scrollCol; + _rScrollX = _vm->_scrollX; + _rScrollY = _vm->_scrollY; _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag]; } diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 8174969a3d..29742f66bd 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -134,8 +134,8 @@ void AmazonRoom::setupRoom() { // WORKAROUND: The original engine doesn't handle vertical scrolling rooms Screen &screen = *_vm->_screen; if (screen._vWindowHeight == (_playFieldHeight - 1)) { - screen._scrollRow = 1; - screen._scrollY = 0; + _vm->_scrollRow = 1; + _vm->_scrollY = 0; } } @@ -187,7 +187,7 @@ void AmazonRoom::mainAreaClick() { // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due // to not being able to click a Y position that's high enough - if (screen._scrollRow == 0 && pt.y > 178) + if (_vm->_scrollRow == 0 && pt.y > 178) pt.y = 200; player._moveTo = pt; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 45ce44dfc8..27e73a0640 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -99,31 +99,14 @@ void ImageEntryList::addToList(ImageEntry &ie) { /*------------------------------------------------------------------------*/ -int ASurface::_leftSkip; -int ASurface::_rightSkip; -int ASurface::_topSkip; -int ASurface::_bottomSkip; int ASurface::_clipWidth; int ASurface::_clipHeight; -int ASurface::_lastBoundsX; -int ASurface::_lastBoundsY; -int ASurface::_lastBoundsW; -int ASurface::_lastBoundsH; -int ASurface::_scrollX; -int ASurface::_scrollY; -int ASurface::_orgX1; -int ASurface::_orgY1; -int ASurface::_orgX2; -int ASurface::_orgY2; -int ASurface::_lColor; - -void ASurface::init() { + +ASurface::ASurface() { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; - _clipWidth = _clipHeight = 0; _lastBoundsX = _lastBoundsY = 0; _lastBoundsW = _lastBoundsH = 0; - _scrollX = _scrollY = 0; _orgX1 = _orgY1 = 0; _orgX2 = _orgY2 = 0; _lColor = 0; diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 6ffbf0e25e..763e3e629e 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -43,22 +43,22 @@ private: protected: Common::Rect _savedBounds; public: - static int _leftSkip, _rightSkip; - static int _topSkip, _bottomSkip; - static int _clipWidth, _clipHeight; - static int _lastBoundsX, _lastBoundsY; - static int _lastBoundsW, _lastBoundsH; - static int _scrollX, _scrollY; - static int _orgX1, _orgY1; - static int _orgX2, _orgY2; - static int _lColor; + int _leftSkip, _rightSkip; + int _topSkip, _bottomSkip; + int _lastBoundsX, _lastBoundsY; + int _lastBoundsW, _lastBoundsH; + int _orgX1, _orgY1; + int _orgX2, _orgY2; + int _lColor; Common::Point _printOrg; Common::Point _printStart; int _maxChars; - - static void init(); public: + static int _clipWidth, _clipHeight; +public: + ASurface(); + virtual ~ASurface(); void create(uint16 width, uint16 height); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index c314fe9444..0867b09765 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -329,12 +329,12 @@ void EventsManager::waitKeyMouse() { } Common::Point EventsManager::calcRawMouse() { - Screen &screen = *_vm->_screen; Common::Point pt; + Screen &screen = *_vm->_screen; pt.x = _mousePos.x - screen._windowXAdd + - (screen._scrollCol * TILE_WIDTH) + screen._scrollX; + (_vm->_scrollCol * TILE_WIDTH) + _vm->_scrollX; pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd + - (screen._scrollRow * TILE_HEIGHT) + screen._scrollY; + (_vm->_scrollRow * TILE_HEIGHT) + _vm->_scrollY; return pt; } diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index d09b784adf..8db62a45fc 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -221,13 +221,13 @@ void InventoryManager::savedFields() { _fields._windowXAdd = screen._windowXAdd; _fields._windowYAdd = screen._windowYAdd; _fields._screenYOff = screen._screenYOff; - _fields._scrollX = screen._scrollX; - _fields._scrollY = screen._scrollY; + _fields._scrollX = _vm->_scrollX; + _fields._scrollY = _vm->_scrollY; _fields._clipWidth = screen._clipWidth; _fields._clipHeight = screen._clipHeight; _fields._bufferStart = screen._bufferStart; - _fields._scrollCol = screen._scrollCol; - _fields._scrollRow = screen._scrollRow; + _fields._scrollCol = _vm->_scrollCol; + _fields._scrollRow = _vm->_scrollRow; } void InventoryManager::restoreFields() { @@ -243,13 +243,13 @@ void InventoryManager::restoreFields() { screen._windowXAdd = _fields._windowXAdd; screen._windowYAdd = _fields._windowYAdd; screen._screenYOff = _fields._screenYOff; - screen._scrollX = _fields._scrollX; - screen._scrollY = _fields._scrollY; + _vm->_scrollX = _fields._scrollX; + _vm->_scrollY = _fields._scrollY; screen._clipWidth = _fields._clipWidth; screen._clipHeight = _fields._clipHeight; screen._bufferStart = _fields._bufferStart; - screen._scrollCol = _fields._scrollCol; - screen._scrollRow = _fields._scrollRow; + _vm->_scrollCol = _fields._scrollCol; + _vm->_scrollRow = _fields._scrollRow; } void InventoryManager::initFields() { @@ -268,9 +268,9 @@ void InventoryManager::initFields() { screen._windowXAdd = 0; screen._windowYAdd = 0; screen._screenYOff = 0; - screen._scrollX = screen._scrollY = 0; screen._bufferStart.x = 0; screen._bufferStart.y = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_buffer1.clearBuffer(); _vm->_buffer2.clearBuffer(); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 83f075e3d8..d547aedc1d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -209,8 +209,8 @@ void Player::walk() { void Player::calcPlayer() { Screen &scr = *_vm->_screen; - scr._bufferStart.x = (scr._scrollCol << 4) + scr._scrollX; - scr._bufferStart.y = (scr._scrollRow << 4) + scr._scrollY; + scr._bufferStart.x = (_vm->_scrollCol << 4) + _vm->_scrollX; + scr._bufferStart.y = (_vm->_scrollRow << 4) + _vm->_scrollY; _playerX = _rawPlayer.x - scr._bufferStart.x; _playerY = _rawPlayer.y - scr._bufferStart.y; } @@ -519,7 +519,7 @@ void Player::walkDownRight() { bool flag = _scrollEnd == 2; if (!flag) { calcPlayer(); - flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - _vm->_player->_scrollThreshold) > 0; } if (flag) { @@ -664,7 +664,7 @@ void Player::checkScrollUp() { // Scroll up if (scrollUp()) { _scrollEnd = 4; - _vm->_screen->_scrollY &= TILE_HEIGHT; + _vm->_scrollY &= TILE_HEIGHT; _scrollFlag = true; } } @@ -706,26 +706,26 @@ void Player::checkScroll() { bool Player::scrollUp() { _scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold); - if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >= _vm->_room->_playFieldHeight) return true; _scrollFlag = true; - _vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount; + _vm->_scrollY = _vm->_scrollY + _scrollAmount; - while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { - _vm->_screen->_scrollY -= TILE_HEIGHT; - ++_vm->_screen->_scrollRow; + while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_scrollY -= TILE_HEIGHT; + ++_vm->_scrollRow; _vm->_buffer1.moveBufferUp(); - _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, + _vm->_room->buildRow(_vm->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall); - if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >= _vm->_room->_playFieldHeight) return true; - if (_vm->_screen->_scrollY <= TILE_HEIGHT) + if (_vm->_scrollY <= TILE_HEIGHT) return false; } @@ -735,50 +735,50 @@ bool Player::scrollUp() { bool Player::scrollDown() { _scrollAmount = -(_playerY - _scrollThreshold); _scrollFlag = true; - _vm->_screen->_scrollY -= _scrollAmount; - if (_vm->_screen->_scrollY >= 0) + _vm->_scrollY -= _scrollAmount; + if (_vm->_scrollY >= 0) return true; do { - _vm->_screen->_scrollY += TILE_HEIGHT; - if (--_vm->_screen->_scrollRow < 0) + _vm->_scrollY += TILE_HEIGHT; + if (--_vm->_scrollRow < 0) break; _vm->_buffer1.moveBufferDown(); - _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); + _vm->_room->buildRow(_vm->_scrollRow, 0); - if (_vm->_screen->_scrollY >= 0) + if (_vm->_scrollY >= 0) return false; } while (!_vm->shouldQuit()); _scrollEnd = 3; - _vm->_screen->_scrollY = 0; - _vm->_screen->_scrollRow = 0; + _vm->_scrollY = 0; + _vm->_scrollRow = 0; return true; } bool Player::scrollLeft() { Screen &screen = *_vm->_screen; - _scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold); - if ((screen._scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { + _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); + if ((_vm->_scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { _scrollEnd = 2; - screen._scrollX = 0; + _vm->_scrollX = 0; _scrollFlag = true; return true; } else { _scrollFlag = true; - screen._scrollX = screen._scrollX + _scrollAmount; + _vm->_scrollX = _vm->_scrollX + _scrollAmount; do { - if (screen._scrollX < TILE_WIDTH) + if (_vm->_scrollX < TILE_WIDTH) return true; - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } while (!_vm->shouldQuit() && (screen._scrollX >= TILE_WIDTH)); + } while (!_vm->shouldQuit() && (_vm->_scrollX >= TILE_WIDTH)); return (_playerDirection == UPRIGHT); } @@ -787,21 +787,21 @@ bool Player::scrollLeft() { bool Player::scrollRight() { _scrollAmount = -(_playerX - _scrollThreshold); _scrollFlag = true; - _vm->_screen->_scrollX -= _scrollAmount; + _vm->_scrollX -= _scrollAmount; - if (_vm->_screen->_scrollX < 0) { + if (_vm->_scrollX < 0) { do { - _vm->_screen->_scrollX += TILE_WIDTH; - if (--_vm->_screen->_scrollCol < 0) { + _vm->_scrollX += TILE_WIDTH; + if (--_vm->_scrollCol < 0) { _scrollEnd = true; - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollCol = 0; + _vm->_scrollX = 0; + _vm->_scrollCol = 0; return true; } _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); - } while (!_vm->shouldQuit() && (_vm->_screen->_scrollX < 0)); + _vm->_room->buildColumn(_vm->_scrollCol, 0); + } while (!_vm->shouldQuit() && (_vm->_scrollX < 0)); return false; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index fc9cb6a4a0..f7c2eabd0f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -253,33 +253,33 @@ void Room::setupRoom() { screen.setIconPalette(); if (screen._vWindowWidth == _playFieldWidth) { - screen._scrollX = 0; - screen._scrollCol = 0; + _vm->_scrollX = 0; + _vm->_scrollCol = 0; } else { int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; - screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; - screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); + _vm->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + _vm->_scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); - int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth; + int sx = _vm->_scrollCol + screen._vWindowWidth - _playFieldWidth; if (sx >= 0) { - screen._scrollCol -= sx + 1; + _vm->_scrollCol -= sx + 1; } } if (screen._vWindowHeight == _playFieldHeight) { - screen._scrollY = 0; - screen._scrollRow = 0; + _vm->_scrollY = 0; + _vm->_scrollRow = 0; } else { - screen._scrollY = _vm->_player->_rawPlayer.y - + _vm->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y / 16) * 16; int yc = MAX((_vm->_player->_rawPlayer.y >> 4) - (screen._vWindowHeight / 2), 0); - screen._scrollRow = yc; + _vm->_scrollRow = yc; yc = yc + screen._vWindowHeight - _playFieldHeight; if (yc >= 0) { - screen._scrollRow = _playFieldHeight - screen._vWindowHeight; - screen._scrollY = 0; + _vm->_scrollRow = _playFieldHeight - screen._vWindowHeight; + _vm->_scrollY = 0; } } } @@ -293,7 +293,7 @@ void Room::setWallCodes() { } void Room::buildScreen() { - int scrollCol = _vm->_screen->_scrollCol; + int scrollCol = _vm->_scrollCol; int offset = 0; // Clear current background buffer @@ -304,11 +304,11 @@ void Room::buildScreen() { // Loop through drawing each column of tiles forming the background for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) { - buildColumn(_vm->_screen->_scrollCol, offset); - ++_vm->_screen->_scrollCol; + buildColumn(_vm->_scrollCol, offset); + ++_vm->_scrollCol; } - _vm->_screen->_scrollCol = scrollCol; + _vm->_scrollCol = scrollCol; _vm->copyBF1BF2(); } @@ -316,7 +316,7 @@ void Room::buildColumn(int playX, int screenX) { if (playX < 0 || playX >= _playFieldWidth) return; - const byte *pSrc = _playField + _vm->_screen->_scrollRow * + const byte *pSrc = _playField + _vm->_scrollRow * _playFieldWidth + playX; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns @@ -341,7 +341,7 @@ void Room::buildRow(int playY, int screenY) { return; assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); - const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol; + const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_scrollCol; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index d0974bde26..35069ba683 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -50,7 +50,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _currentPanel = 0; _hideFlag = true; _startColor = _numColors = 0; - _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; _screenChangeFlag = false; @@ -76,8 +75,8 @@ void Screen::setDisplayScan() { _clipWidth = this->w - 1; _clipHeight = this->h - 1; _windowXAdd = _windowYAdd = 0; - _scrollX = _scrollY = 0; - _scrollCol = _scrollRow = 0; + _vm->_scrollX = _vm->_scrollY = 0; + _vm->_scrollCol = _vm->_scrollRow = 0; _bufferStart.x = _bufferStart.y = 0; _screenYOff = 0; } @@ -225,10 +224,10 @@ void Screen::saveScreen() { _screenSave._clipHeight = _clipHeight; _screenSave._windowXAdd = _windowXAdd; _screenSave._windowYAdd = _windowYAdd; - _screenSave._scroll.x = _scrollX; - _screenSave._scroll.y = _scrollY; - _screenSave._scrollCol = _scrollCol; - _screenSave._scrollRow = _scrollRow; + _screenSave._scroll.x = _vm->_scrollX; + _screenSave._scroll.y = _vm->_scrollY; + _screenSave._scrollCol = _vm->_scrollCol; + _screenSave._scrollRow = _vm->_scrollRow; _screenSave._bufferStart.x = _bufferStart.x; _screenSave._bufferStart.y = _bufferStart.y; _screenSave._screenYOff = _screenYOff; @@ -239,10 +238,10 @@ void Screen::restoreScreen() { _clipHeight = _screenSave._clipHeight; _windowXAdd = _screenSave._windowXAdd; _windowYAdd = _screenSave._windowYAdd; - _scrollX = _screenSave._scroll.x; - _scrollY = _screenSave._scroll.y; - _scrollCol = _screenSave._scrollCol; - _scrollRow = _screenSave._scrollRow; + _vm->_scrollX = _screenSave._scroll.x; + _vm->_scrollY = _screenSave._scroll.y; + _vm->_scrollCol = _screenSave._scrollCol; + _vm->_scrollRow = _screenSave._scrollRow; _bufferStart.x = _screenSave._bufferStart.x; _bufferStart.y = _screenSave._bufferStart.y; _screenYOff = _screenSave._screenYOff; diff --git a/engines/access/screen.h b/engines/access/screen.h index bf4cceaf11..0fa111c21c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -74,7 +74,6 @@ public: int _vesaMode; int _startColor, _numColors; Common::Point _bufferStart; - int _scrollCol, _scrollRow; int _windowXAdd, _windowYAdd; int _screenYOff; byte _manPal[0x60]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d1dd5e7a7a..2e22d9a2ce 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -508,10 +508,10 @@ void Scripts::cmdSetBuffer() { } void Scripts::cmdSetScroll() { - _vm->_screen->_scrollCol = _data->readUint16LE(); - _vm->_screen->_scrollRow = _data->readUint16LE(); - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollY = 0; + _vm->_scrollCol = _data->readUint16LE(); + _vm->_scrollRow = _data->readUint16LE(); + _vm->_scrollX = 0; + _vm->_scrollY = 0; } void Scripts::cmdSaveRect() { -- cgit v1.2.3 From 93bbe3a45e4d9a6542b93ec9747bc0c6031054ae Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 18 Dec 2014 21:52:59 -0500 Subject: ACCESS: Manually implement ASurface::copyFrom for performance The original called Surface::copyFrom, which keeps recreating the dest surface with each copy. This version simply copies the image --- engines/access/asurface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 27e73a0640..38af7add00 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -252,7 +252,11 @@ void ASurface::transCopyFrom(ASurface &src) { } void ASurface::copyFrom(Graphics::Surface &src) { - Graphics::Surface::copyFrom(src); + for (int y = 0; y < src.h; ++y) { + const byte *srcP = (const byte *)src.getBasePtr(0, y); + byte *destP = (byte *)getBasePtr(0, y); + Common::copy(srcP, srcP + src.w, destP); + } } void ASurface::copyBuffer(Graphics::Surface *src) { -- cgit v1.2.3 From f4fe0b008fa564a59dddfc59af9385fd3cd958d0 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 10:46:43 +0600 Subject: ZVISION: Delete unused code --- engines/zvision/graphics/truetype_font.cpp | 76 ----------- engines/zvision/graphics/truetype_font.h | 39 ------ engines/zvision/text/string_manager.cpp | 202 +---------------------------- engines/zvision/text/string_manager.h | 25 ---- engines/zvision/text/text.h | 4 - 5 files changed, 2 insertions(+), 344 deletions(-) diff --git a/engines/zvision/graphics/truetype_font.cpp b/engines/zvision/graphics/truetype_font.cpp index 1a0e92087c..2dbd7ca358 100644 --- a/engines/zvision/graphics/truetype_font.cpp +++ b/engines/zvision/graphics/truetype_font.cpp @@ -36,82 +36,6 @@ namespace ZVision { -TruetypeFont::TruetypeFont(ZVision *engine, int32 fontHeight) - : _engine(engine), - _fontHeight(fontHeight), - _font(0), - _lineHeight(0), - _maxCharWidth(0), - _maxCharHeight(0) { -} - -TruetypeFont::~TruetypeFont(void) { - delete _font; -} - -bool TruetypeFont::loadFile(const Common::String &filename) { - Common::File file; - - bool fileOpened = false; - if (!Common::File::exists(filename)) { - debug("TTF font file %s was not found. Reverting to arial.ttf", filename.c_str()); - fileOpened = file.open("arial.ttf"); - } else { - fileOpened = file.open(filename); - } - - if (!fileOpened) { - debug("TTF file could not be opened"); - return false; - } - - _font = Graphics::loadTTFFont(file, _fontHeight); - _lineHeight = _font->getFontHeight(); - - return true; -} - -Graphics::Surface *TruetypeFont::drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap) { - if (text.equals("")) { - return nullptr; - } - - Graphics::Surface *surface = new Graphics::Surface(); - - if (!wrap) { - int width = MIN(_font->getStringWidth(text), maxWidth); - surface->create(width, _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); - // TODO: Add better alpha support by getting the pixels from the backbuffer. - // However doing that requires some kind of caching system so future text doesn't try to use this text as it's alpha background. - surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); - - _font->drawString(surface, text, 0, 0, maxWidth, textColor, align); - return surface; - } - - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - - while (maxHeight > 0 && (int)lines.size() * _lineHeight > maxHeight) { - lines.pop_back(); - } - if (lines.size() == 0) { - delete surface; - return nullptr; - } - - surface->create(maxWidth, lines.size() * _lineHeight, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); - surface->fillRect(Common::Rect(0, 0, surface->w, surface->h), 0); - - int heightOffset = 0; - for (Common::Array::iterator it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, 0 + heightOffset, maxWidth, textColor, align); - heightOffset += _lineHeight; - } - - return surface; -} - StyledTTFont::StyledTTFont(ZVision *engine) { _engine = engine; _style = 0; diff --git a/engines/zvision/graphics/truetype_font.h b/engines/zvision/graphics/truetype_font.h index 30ef1c73a3..b5fac4af8a 100644 --- a/engines/zvision/graphics/truetype_font.h +++ b/engines/zvision/graphics/truetype_font.h @@ -36,45 +36,6 @@ namespace ZVision { class ZVision; -class TruetypeFont { -public: - TruetypeFont(ZVision *engine, int32 fontHeight); - ~TruetypeFont(); - -private: - ZVision *_engine; - Graphics::Font *_font; - int _lineHeight; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - int32 _fontHeight; - -public: - /** - * Loads a .ttf file into memory. This must be called - * before any calls to drawTextToSurface - * - * @param filename The file name of the .ttf file to load - */ - bool loadFile(const Common::String &filename); - /** - * Renders the supplied text to a Surface using 0x0 as the - * background color. - * - * @param text The to render - * @param textColor The color to render the text with - * @param maxWidth The max width the text should take up. - * @param maxHeight The max height the text should take up. - * @param align The alignment of the text within the bounds of maxWidth - * @param wrap If true, any words extending past maxWidth will wrap to a new line. If false, ellipses will be rendered to show that the text didn't fit - * @return A Surface containing the rendered text - */ - Graphics::Surface *drawTextToSurface(const Common::String &text, uint16 textColor, int maxWidth, int maxHeight, Graphics::TextAlign align, bool wrap); -}; - // Styled TTF class StyledTTFont { public: diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index d275bc8769..ec10b6220c 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -30,7 +30,7 @@ #include "zvision/zvision.h" #include "zvision/file/search_manager.h" #include "zvision/text/string_manager.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/text.h" namespace ZVision { @@ -39,9 +39,7 @@ StringManager::StringManager(ZVision *engine) } StringManager::~StringManager() { - for (Common::HashMap::iterator iter = _fonts.begin(); iter != _fonts.end(); ++iter) { - delete iter->_value; - } + } void StringManager::initialize(ZVisionGameId gameId) { @@ -69,202 +67,6 @@ void StringManager::loadStrFile(const Common::String &fileName) { } } -void StringManager::parseStrFile(const Common::String &fileName) { - Common::File file; - if (!file.open(fileName)) { - warning("%s does not exist. String parsing failed", fileName.c_str()); - return; - } - - uint lineNumber = 0; - while (!file.eos()) { - _lastStyle.align = Graphics::kTextAlignLeft; - _lastStyle.color = 0; - _lastStyle.font = nullptr; - - Common::String asciiLine = readWideLine(file); - if (asciiLine.empty()) { - continue; - } - - char tagString[150]; - uint tagStringCursor = 0; - char textString[150]; - uint textStringCursor = 0; - bool inTag = false; - - for (uint i = 0; i < asciiLine.size(); ++i) { - switch (asciiLine[i]) { - case '<': - inTag = true; - if (!_inGameText[lineNumber].fragments.empty()) { - _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); - textStringCursor = 0; - } - break; - case '>': - inTag = false; - parseTag(Common::String(tagString, tagStringCursor), lineNumber); - tagStringCursor = 0; - break; - default: - if (inTag) { - tagString[tagStringCursor] = asciiLine[i]; - tagStringCursor++; - } else { - textString[textStringCursor] = asciiLine[i]; - textStringCursor++; - } - break; - } - } - - if (textStringCursor > 0) { - _inGameText[lineNumber].fragments.back().text = Common::String(textString, textStringCursor); - } - - lineNumber++; - assert(lineNumber <= NUM_TEXT_LINES); - } -} - -void StringManager::parseTag(const Common::String &tagString, uint lineNumber) { - Common::StringTokenizer tokenizer(tagString); - - Common::String token = tokenizer.nextToken(); - - Common::String fontName; - bool bold = false; - Graphics::TextAlign align = _lastStyle.align; - int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12; - int red = 0; - int green = 0; - int blue = 0; - - while (!token.empty()) { - if (token.matchString("font", true)) { - fontName = tokenizer.nextToken(); - } else if (token.matchString("bold", true)) { - token = tokenizer.nextToken(); - if (token.matchString("on", false)) { - bold = true; - } - } else if (token.matchString("justify", true)) { - token = tokenizer.nextToken(); - if (token.matchString("center", false)) { - align = Graphics::kTextAlignCenter; - } else if (token.matchString("right", false)) { - align = Graphics::kTextAlignRight; - } - } else if (token.matchString("point", true)) { - point = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("red", true)) { - red = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("green", true)) { - green = atoi(tokenizer.nextToken().c_str()); - } else if (token.matchString("blue", true)) { - blue = atoi(tokenizer.nextToken().c_str()); - } - - token = tokenizer.nextToken(); - } - - TextFragment fragment; - - if (fontName.empty()) { - fragment.style.font = _lastStyle.font; - } else { - Common::String newFontName; - if (fontName.matchString("*times new roman*", true)) { - if (bold) { - newFontName = "timesbd.ttf"; - } else { - newFontName = "times.ttf"; - } - } else if (fontName.matchString("*courier new*", true)) { - if (bold) { - newFontName = "courbd.ttf"; - } else { - newFontName = "cour.ttf"; - } - } else if (fontName.matchString("*century schoolbook*", true)) { - if (bold) { - newFontName = "censcbkbd.ttf"; - } else { - newFontName = "censcbk.ttf"; - } - } else if (fontName.matchString("*garamond*", true)) { - if (bold) { - newFontName = "garabd.ttf"; - } else { - newFontName = "gara.ttf"; - } - } else { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - if (bold) { - newFontName = "zorknorm.ttf"; - } else { - newFontName = "arial.ttf"; - } - } - - Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point); - if (_fonts.contains(fontKey)) { - fragment.style.font = _fonts[fontKey]; - } else { - fragment.style.font = new TruetypeFont(_engine, point); - fragment.style.font->loadFile(newFontName); - _fonts[fontKey] = fragment.style.font; - } - } - - fragment.style.align = align; - fragment.style.color = Graphics::ARGBToColor >(0, red, green, blue); - _inGameText[lineNumber].fragments.push_back(fragment); - - _lastStyle = fragment.style; -} - -Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { - Common::String asciiString; - - // Don't spam the user with warnings about UTF-16 support. - // Just do one warning per String - bool charOverflowWarning = false; - - uint16 value = stream.readUint16LE(); - while (!stream.eos()) { - // Check for CRLF - if (value == 0x0A0D) { - // Read in the extra NULL char - stream.readByte(); // \0 - // End of the line. Break - break; - } - - // Crush each octet pair to a single octet with a simple cast - if (value > 255) { - charOverflowWarning = true; - value = '?'; - } - char charValue = (char)value; - - asciiString += charValue; - - value = stream.readUint16LE(); - } - - if (charOverflowWarning) { - warning("UTF-16 is not supported. Characters greater than 255 are replaced with '?'"); - } - - return asciiString; -} - -StringManager::TextStyle StringManager::getTextStyle(uint stringNumber) { - return _inGameText[stringNumber].fragments.front().style; -} - const Common::String StringManager::getTextLine(uint stringNumber) { return _lines[stringNumber]; } diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index 8d6fbe67a6..b77ad65040 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -40,17 +40,6 @@ public: ~StringManager(); public: - struct TextStyle { - TruetypeFont *font; - uint16 color; // In RBG 565 - Graphics::TextAlign align; - }; - - struct TextFragment { - TextStyle style; - Common::String text; - }; - enum { ZVISION_STR_SAVEEXIST = 23, ZVISION_STR_SAVED = 4, @@ -59,10 +48,6 @@ public: }; private: - struct InGameText { - Common::List fragments; - }; - enum { NUM_TEXT_LINES = 56 // Max number of lines in a .str file. We hardcode this number because we know ZNem uses 42 strings and ZGI uses 56 }; @@ -71,22 +56,12 @@ private: ZVision *_engine; Common::String _lines[NUM_TEXT_LINES]; - InGameText _inGameText[NUM_TEXT_LINES]; - Common::HashMap _fonts; - - TextStyle _lastStyle; - public: void initialize(ZVisionGameId gameId); - StringManager::TextStyle getTextStyle(uint stringNumber); const Common::String getTextLine(uint stringNumber); private: void loadStrFile(const Common::String &fileName); - void parseStrFile(const Common::String &fileName); - void parseTag(const Common::String &tagString, uint lineNumber); - - static Common::String readWideLine(Common::SeekableReadStream &stream); }; } // End of namespace ZVision diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index 01c3fd760c..ecec3ccde6 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -28,10 +28,6 @@ #include "zvision/graphics/truetype_font.h" #include "zvision/zvision.h" -namespace Graphics { -class FontManager; -} - namespace ZVision { class ZVision; -- cgit v1.2.3 From 30212e4579e9f811f46cfadc5899c4d21cd513ed Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:30:03 +0600 Subject: ZVISION: Fix array compared against 0 (CID 1109648) --- engines/zvision/file/zfs_archive.cpp | 2 +- engines/zvision/file/zfs_archive.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/file/zfs_archive.cpp b/engines/zvision/file/zfs_archive.cpp index 9b55a366ed..0c076a798b 100644 --- a/engines/zvision/file/zfs_archive.cpp +++ b/engines/zvision/file/zfs_archive.cpp @@ -140,7 +140,7 @@ Common::SeekableReadStream *ZfsArchive::createReadStreamForMember(const Common:: byte *buffer = (byte *)malloc(entryHeader->size); zfsArchive.read(buffer, entryHeader->size); // Decrypt the data in place - if (_header.xorKey != 0) + if (_header.xorKey[0] + _header.xorKey[1] + _header.xorKey[2] + _header.xorKey[3] != 0) unXor(buffer, entryHeader->size, _header.xorKey); return new Common::MemoryReadStream(buffer, entryHeader->size, DisposeAfterUse::YES); diff --git a/engines/zvision/file/zfs_archive.h b/engines/zvision/file/zfs_archive.h index 571591a6d1..fe0221416d 100644 --- a/engines/zvision/file/zfs_archive.h +++ b/engines/zvision/file/zfs_archive.h @@ -39,7 +39,7 @@ struct ZfsHeader { uint32 maxNameLength; uint32 filesPerBlock; uint32 fileCount; - byte xorKey[4]; + uint8 xorKey[4]; uint32 fileSectionOffset; }; -- cgit v1.2.3 From d96834020c9f3dac02d6a4feb8bac673ca223f94 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:31:43 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1109669) --- engines/zvision/scripting/controls/input_control.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 6959f9eca9..e75cc15743 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -46,7 +46,9 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _enterPressed(false), _readOnly(false), _txtWidth(0), - _animation(NULL) { + _animation(NULL), + _frameDelay(0), + _frame(-1) { // Loop until we find the closing brace Common::String line = stream.readLine(); _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); -- cgit v1.2.3 From 76335d4a81679d7334918e4009a083883befebb8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:32:43 +0600 Subject: ZVISION: Fix uninitialized pointer field (CID 1109672) --- engines/zvision/zvision.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index f9d6bb3e85..4e5307c182 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -90,6 +90,12 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _stringManager(nullptr), _cursorManager(nullptr), _midiManager(nullptr), + _rnd(nullptr), + _console(nullptr), + _menu(nullptr), + _searchManager(nullptr), + _textRenderer(nullptr), + _halveDelay(false), _audioId(0), _rendDelay(2), _kbdVelocity(0), -- cgit v1.2.3 From b10f66438f4a11feece7a6f2eb0cd753169701c4 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:33:51 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1109675) --- engines/zvision/graphics/render_table.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index 54faecfa8b..c30e0bd472 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -34,6 +34,9 @@ RenderTable::RenderTable(uint numColumns, uint numRows) assert(numRows != 0 && numColumns != 0); _internalBuffer = new Common::Point[numRows * numColumns]; + + memset(&_panoramaOptions, 0, sizeof(_panoramaOptions)); + memset(&_tiltOptions, 0, sizeof(_tiltOptions)); } RenderTable::~RenderTable() { -- cgit v1.2.3 From c50024fd86e6bb0b21f70eb4e018f823913f36fd Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:37:33 +0600 Subject: ZVISION: Fix uninitialized pointer field (CID 1109699) --- engines/zvision/scripting/controls/lever_control.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 71dd52f40f..8faa18357c 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -48,7 +48,10 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre _mouseIsCaptured(false), _isReturning(false), _accumulatedTime(0), - _returnRoutesCurrentFrame(0) { + _returnRoutesCurrentFrame(0), + _animation(NULL), + _cursor(CursorIndex_Active), + _mirrored(false) { // Loop until we find the closing brace Common::String line = stream.readLine(); -- cgit v1.2.3 From 74ea583a4ef446a92cbba4506f7c04513d1ca997 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:38:28 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1109700) --- engines/zvision/file/zfs_archive.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/file/zfs_archive.cpp b/engines/zvision/file/zfs_archive.cpp index 0c076a798b..3a385cd8fd 100644 --- a/engines/zvision/file/zfs_archive.cpp +++ b/engines/zvision/file/zfs_archive.cpp @@ -31,6 +31,7 @@ namespace ZVision { ZfsArchive::ZfsArchive(const Common::String &fileName) : _fileName(fileName) { Common::File zfsFile; + memset(&_header, 0, sizeof(_header)); if (!zfsFile.open(_fileName)) { warning("ZFSArchive::ZFSArchive(): Could not find the archive file"); -- cgit v1.2.3 From 5a087927805529293fb340b0b7c0d2e789278ae9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:39:51 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1125218) --- engines/zvision/scripting/sidefx/timer_node.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp index abf2c90b04..170f6e7472 100644 --- a/engines/zvision/scripting/sidefx/timer_node.cpp +++ b/engines/zvision/scripting/sidefx/timer_node.cpp @@ -33,6 +33,8 @@ namespace ZVision { TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) : SideFX(engine, key, SIDEFX_TIMER) { + _timeLeft = 0; + if (_engine->getGameId() == GID_NEMESIS) _timeLeft = timeInSeconds * 1000; else if (_engine->getGameId() == GID_GRANDINQUISITOR) -- cgit v1.2.3 From cd2fc20768a8ed8dc34a316ec91e0643b8c2bddf Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:40:45 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257061) --- engines/zvision/core/menu.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index c7898a4fbd..e584e8712f 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -58,6 +58,8 @@ MenuZGI::MenuZGI(ZVision *engine) : scrollPos[1] = 0.0; scrollPos[2] = 0.0; mouseOnItem = -1; + redraw = false; + clean = false; char buf[24]; for (int i = 1; i < 4; i++) { -- cgit v1.2.3 From deea4ef62c1eda0a3cba45b2f9e23be6338f52ca Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:41:39 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257055) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index d6883ed38f..10122f556d 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -781,6 +781,9 @@ bool ActionRotateTo::execute() { ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _x = 0; + _y = 0; + char fileName[25]; int color; -- cgit v1.2.3 From 8c896f5da4eaa4cd95f9ff4c60efa43542cfe557 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:42:19 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257056) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 10122f556d..1d9b4d7be1 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -71,6 +71,8 @@ bool ActionAdd::execute() { ActionAssign::ActionAssign(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + char buf[64]; memset(buf, 0, 64); sscanf(line.c_str(), "%u, %s", &_key, buf); -- cgit v1.2.3 From f9946b726fe7ea5251fe44a77f8dab296052b744 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:43:46 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257057) --- engines/zvision/scripting/actions.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 1d9b4d7be1..31bd681b3b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -654,11 +654,15 @@ bool ActionQuit::execute() { ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _delay = 0; + _type = 0; + _unk1 = 0; + _unk2 = 0; char art[64]; char custom[64]; - int32 x1, x2, y1, y2; + int32 x1 = 0, x2 = 0, y1 = 0, y2 = 0; sscanf(line.c_str(), "%s %d %d %d %d %hu %hu %hu %hu %s", art, &x1, &y1, &x2, &y2, &_delay, &_type, &_unk1, &_unk2, custom); _art = Common::String(art); -- cgit v1.2.3 From cd2612a54ed2b5ab9e35140b5f115e39cfe0a1d7 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:44:41 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257058) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 31bd681b3b..62412e68f8 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -240,6 +240,9 @@ bool ActionDisableVenus::execute() { ActionDisplayMessage::ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _control = 0; + _msgid = 0; + sscanf(line.c_str(), "%hd %hd", &_control, &_msgid); } -- cgit v1.2.3 From e28f8a5d8f3de8e6c21be6a494ab91aaf1602216 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:45:54 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257059) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 62412e68f8..2f7103bf18 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -857,6 +857,8 @@ bool ActionSetScreen::execute() { ActionSetVenus::ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + sscanf(line.c_str(), "%d", &_key); } -- cgit v1.2.3 From fe56e7d02b935e7f7ae3d3f95fcc5bda88a2c50d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 15:47:09 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257060) --- engines/zvision/scripting/sidefx/music_node.h | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index c89345f0d0..b4609583f4 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -115,7 +115,6 @@ public: private: int8 _chan; int8 _noteNumber; - int8 _velocity; int8 _pan; int8 _volume; int8 _prog; -- cgit v1.2.3 From 56f7be8ab62315a3439d3f4aad9b85a294eac2c9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:01:30 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257054) --- engines/zvision/core/menu.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp index e584e8712f..31e0d71370 100644 --- a/engines/zvision/core/menu.cpp +++ b/engines/zvision/core/menu.cpp @@ -559,6 +559,8 @@ MenuNemesis::MenuNemesis(ZVision *engine) : scrolled = false; scrollPos = 0.0; mouseOnItem = -1; + redraw = false; + delay = 0; char buf[24]; for (int i = 0; i < 4; i++) -- cgit v1.2.3 From f8c1b1eb28e3976fda19547230c7a8b70f31244d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:22:57 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257062) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 2f7103bf18..a9b19eaf2b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -95,6 +95,9 @@ bool ActionAssign::execute() { ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + _attenuation = 0; + sscanf(line.c_str(), "%u, %d", &_key, &_attenuation); } -- cgit v1.2.3 From 36af1ff5b1a813f773952fabf1906fe1fb07b846 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:27:27 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257063) --- engines/zvision/scripting/actions.h | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index f9e4ee8167..ef82ef0c88 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -454,7 +454,6 @@ public: ~ActionTimer(); bool execute(); private: - uint32 _key; ValueSlot *_time; }; -- cgit v1.2.3 From 044f2521542617d55c9cd1802f2cab7f9bccb618 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:29:51 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257064) --- engines/zvision/scripting/actions.cpp | 6 ++++-- engines/zvision/scripting/actions.h | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index a9b19eaf2b..8ae1cd733b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -431,10 +431,12 @@ bool ActionMenuBarEnable::execute() { ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &line, bool global) : ResultAction(engine, slotkey), _volume(255), + _note(0), + _prog(0), _universe(global) { - uint type; + uint type = 0; char fileNameBuffer[25]; - uint loop; + uint loop = 0; uint volume = 255; sscanf(line.c_str(), "%u %25s %u %u", &type, fileNameBuffer, &loop, &volume); diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index ef82ef0c88..d859b1d7f1 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -239,7 +239,6 @@ public: bool execute(); private: - uint32 _key; Common::String _fileName; bool _loop; byte _volume; -- cgit v1.2.3 From efb93552233f13128a43854a9d2ed97653a04075 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:31:33 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257065) --- engines/zvision/scripting/actions.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 8ae1cd733b..f2cfbc0684 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -132,6 +132,14 @@ bool ActionChangeLocation::execute() { ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _keyOne = 0; + _keyTwo = 0; + _oneStartVolume = 0; + _twoStartVolume = 0; + _oneEndVolume = 0; + _twoEndVolume = 0; + _timeInMillis = 0; + sscanf(line.c_str(), "%u %u %d %d %d %d %d", &_keyOne, &_keyTwo, &_oneStartVolume, &_twoStartVolume, &_oneEndVolume, &_twoEndVolume, &_timeInMillis); -- cgit v1.2.3 From b96c58188110d7f45e4733a0a010c82f6ec62a25 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:32:27 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257066) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index f2cfbc0684..5b27f52aa5 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -57,6 +57,9 @@ namespace ZVision { ActionAdd::ActionAdd(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + _value = 0; + sscanf(line.c_str(), "%u,%d", &_key, &_value); } -- cgit v1.2.3 From 3b83e82e6f755dd45da8f063f3af831872d6ffdc Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:33:26 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257067) --- engines/zvision/scripting/actions.cpp | 10 ++++++++++ engines/zvision/scripting/actions.h | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 5b27f52aa5..a030f6ce07 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -602,6 +602,16 @@ bool ActionUnloadAnimation::execute() { ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _x = 0; + _y = 0; + _x2 = 0; + _y2 = 0; + _start = 0; + _end = 0; + _loopCount = 0; + _mask = 0; + _framerate = 0; + char fileName[25]; // The two %*u are always 0 and dont seem to have a use diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index d859b1d7f1..ee761c4b30 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -266,7 +266,6 @@ public: bool execute(); private: - uint32 _key; Common::String _fileName; uint32 _x; uint32 _y; -- cgit v1.2.3 From dae76a76c788950a05b827cb58cf3bd3f4bb8c32 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:34:11 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257068) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index a030f6ce07..31ba2cc5c1 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -239,6 +239,8 @@ bool ActionDisableControl::execute() { ActionDisableVenus::ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + sscanf(line.c_str(), "%d", &_key); } -- cgit v1.2.3 From 9c2782a6800ada4330d2ae4f4087c7b13fbf851b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:35:15 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257069) --- engines/zvision/scripting/actions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 31ba2cc5c1..5689f3e2aa 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -119,6 +119,12 @@ bool ActionAttenuate::execute() { ActionChangeLocation::ActionChangeLocation(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _world = 'g'; + _room = 'a'; + _node = 'r'; + _view = 'y'; + _offset = 0; + sscanf(line.c_str(), "%c, %c, %c%c, %u", &_world, &_room, &_node, &_view, &_offset); } -- cgit v1.2.3 From ea2ad625ff780750213821d25aedfe4e46027755 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:36:54 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257070) --- engines/zvision/scripting/actions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 5689f3e2aa..b569b1315a 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -973,8 +973,10 @@ bool ActionStreamVideo::execute() { ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _syncto = 0; + char fileName[25]; - int notUsed; + int notUsed = 0; sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬Used, fileName); -- cgit v1.2.3 From 8278ed6022f4b172c6173866224071f381a12bd5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:38:34 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257071) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index b569b1315a..a14fa37e4b 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -319,6 +319,8 @@ bool ActionDistort::execute() { ActionEnableControl::ActionEnableControl(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + sscanf(line.c_str(), "%u", &_key); } -- cgit v1.2.3 From 704a4b3400e07ce5d86e7db7e63c3cc89da383e9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:39:21 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257072) --- engines/zvision/scripting/actions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index a14fa37e4b..a5cc37a2f7 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -217,6 +217,7 @@ bool ActionCursor::execute() { ActionDelayRender::ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _framesToDelay = 0; sscanf(line.c_str(), "%u", &_framesToDelay); } -- cgit v1.2.3 From edf35284977d0b666eb796d028ea54278c9736c9 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:41:00 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257073) --- engines/zvision/graphics/cursors/cursor_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index a20deb26b5..ae13c9f4fc 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -50,7 +50,8 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel _pixelFormat(pixelFormat), _cursorIsPushed(false), _item(0), - _lastitem(0) { + _lastitem(0), + _currentCursor(CursorIndex_Idle) { for (int i = 0; i < NUM_CURSORS; i++) { if (_engine->getGameId() == GID_NEMESIS) { Common::String name; -- cgit v1.2.3 From 897ecc190fc7233fa45082e24b97ff37bab1bc0c Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:41:51 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257074) --- engines/zvision/scripting/actions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index a5cc37a2f7..7e3a0667aa 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -594,6 +594,7 @@ bool ActionPreloadAnimation::execute() { ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; sscanf(line.c_str(), "%u", &_key); } -- cgit v1.2.3 From 7055ee77552f9126be095aac83ecfcef425f4dd3 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:44:18 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257075) --- engines/zvision/scripting/actions.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 7e3a0667aa..68e9b04dd5 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -298,6 +298,13 @@ bool ActionDissolve::execute() { ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _distSlot = 0; + _speed = 0; + _startAngle = 60.0; + _endAngle = 60.0; + _startLineScale = 1.0; + _endLineScale = 1.0; + sscanf(line.c_str(), "%hd %hd %f %f %f %f", &_distSlot, &_speed, &_startAngle, &_endAngle, &_startLineScale, &_endLineScale); } -- cgit v1.2.3 From fb0872e40be6cc9c04efdb61dea91e914b02b529 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:48:36 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257076) --- engines/zvision/scripting/controls/slot_control.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 292a2b4bc9..5228ba517b 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -34,7 +34,9 @@ namespace ZVision { SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) - : Control(engine, key, CONTROL_SLOT) { + : Control(engine, key, CONTROL_SLOT), + _cursor(CursorIndex_Active), + _distanceId('0') { _renderedItem = 0; _bkg = NULL; -- cgit v1.2.3 From ea3ddd148f88d3aca21a0626ba4700873324897d Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:49:36 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257077) --- engines/zvision/scripting/sidefx/music_node.h | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index b4609583f4..c8077c7a6a 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -77,7 +77,6 @@ public: void setFade(int32 time, uint8 target); private: - int32 _timeLeft; bool _pantrack; int32 _pantrackPosition; int32 _attenuate; -- cgit v1.2.3 From 1078d0c19311b82db00d4524f5f29e7f2ca52795 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:51:01 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257079) --- engines/zvision/scripting/actions.cpp | 3 +++ engines/zvision/scripting/actions.h | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 68e9b04dd5..6e6674d755 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -565,6 +565,9 @@ bool ActionPreferences::execute() { ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _mask = 0; + _framerate = 0; + char fileName[25]; // The two %*u are always 0 and dont seem to have a use diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index ee761c4b30..18757e0dea 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -302,7 +302,6 @@ public: bool execute(); private: - uint32 _key; Common::String _fileName; int32 _mask; int32 _framerate; -- cgit v1.2.3 From abf37ebbf3e678181731a8eb77d69bdf6c51685a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:51:43 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257080) --- engines/zvision/scripting/controls/push_toggle_control.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/scripting/controls/push_toggle_control.cpp b/engines/zvision/scripting/controls/push_toggle_control.cpp index 3811498cd5..f51a28d644 100644 --- a/engines/zvision/scripting/controls/push_toggle_control.cpp +++ b/engines/zvision/scripting/controls/push_toggle_control.cpp @@ -35,6 +35,7 @@ namespace ZVision { PushToggleControl::PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream) : Control(engine, key, CONTROL_PUSHTGL), _countTo(2), + _cursor(CursorIndex_Active), _event(Common::EVENT_LBUTTONUP) { _hotspots.clear(); -- cgit v1.2.3 From ed66fbefdf0bb6428ea82c64e9dece0559132f4a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 16:52:26 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257081) --- engines/zvision/scripting/actions.h | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 18757e0dea..523890e9ac 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -354,7 +354,6 @@ public: bool execute(); private: - uint32 _key; ValueSlot *_max; }; -- cgit v1.2.3 From 5db4e02f9a5bc756807102e76374c493b80cc028 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:02:22 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257082) --- engines/zvision/scripting/actions.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 6e6674d755..b08a7f3c85 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -938,8 +938,14 @@ bool ActionStop::execute() { ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _x1 = 0; + _x2 = 0; + _y1 = 0; + _y2 = 0; + _flags = 0; + char fileName[25]; - uint skipline; //skipline - render video with skip every second line, not skippable. + uint skipline = 0; //skipline - render video with skip every second line, not skippable. sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); -- cgit v1.2.3 From d6e3cea087bd10619f9bad305a03f1517d714687 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:03:07 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257083) --- engines/zvision/scripting/actions.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index b08a7f3c85..dbbb605e43 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -1050,9 +1050,11 @@ bool ActionTimer::execute() { ActionTtyText::ActionTtyText(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _delay = 0; + char filename[64]; - int32 x1, y1, x2, y2; - sscanf(line.c_str(), "%d %d %d %d %s %u", &x1, &y1, &x2, &y2, filename, &_delay); + int32 x1 = 0, y1 = 0, x2 = 0, y2 = 0; + sscanf(line.c_str(), "%d %d %d %d %64s %u", &x1, &y1, &x2, &y2, filename, &_delay); _r = Common::Rect(x1, y1, x2, y2); _filename = Common::String(filename); } -- cgit v1.2.3 From 7e3c270e49c36cb7290955ded4dc4588f763797a Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:03:39 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257084) --- engines/zvision/scripting/actions.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index dbbb605e43..63033886c6 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -675,6 +675,15 @@ bool ActionPlayAnimation::execute() { ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _controlKey = 0; + _x1 = 0; + _y1 = 0; + _x2 = 0; + _y2 = 0; + _startFrame = 0; + _endFrame = 0; + _loopCount = 0; + sscanf(line.c_str(), "%u %u %u %u %u %u %u %u", &_controlKey, &_x1, &_y1, &_x2, &_y2, &_startFrame, &_endFrame, &_loopCount); -- cgit v1.2.3 From 7a0b5982b133c8ef5ed87cd1418ea28cf7da96fb Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:04:04 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257085) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 63033886c6..60d05fb063 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -832,6 +832,9 @@ bool ActionRestoreGame::execute() { ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _time = 0; + _toPos = 0; + sscanf(line.c_str(), "%d, %d", &_toPos, &_time); } -- cgit v1.2.3 From 7609b6d866576de9a70aadfb17895cfd30393eb8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:04:26 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257086) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 60d05fb063..5274637ca0 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -232,6 +232,8 @@ bool ActionDelayRender::execute() { ActionDisableControl::ActionDisableControl(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _key = 0; + sscanf(line.c_str(), "%u", &_key); } -- cgit v1.2.3 From 2cb541c6511d39e7814f38c1b6e1cc64b7589671 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:05:03 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257087) --- engines/zvision/scripting/actions.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 5274637ca0..fd843276c0 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -359,6 +359,9 @@ bool ActionFlushMouseEvents::execute() { ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _type = -1; + _key = 0; + char buf[25]; sscanf(line.c_str(), "%25s %d", buf, &_key); -- cgit v1.2.3 From c8f8da030845c01453652364a48ae0449d62b890 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:05:31 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257088) --- engines/zvision/scripting/actions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index fd843276c0..0422a2c028 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -450,6 +450,8 @@ bool ActionKill::execute() { ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { + _menus = 0xFFFF; + sscanf(line.c_str(), "%hu", &_menus); } -- cgit v1.2.3 From e934ffdd5e7719f80703d6874bbdb8618f1606ea Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:06:47 +0600 Subject: ZVISION: Fix uninitialized scalar field (CID 1257089) --- engines/zvision/scripting/puzzle.h | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/puzzle.h b/engines/zvision/scripting/puzzle.h index 4123880835..7d64357b0a 100644 --- a/engines/zvision/scripting/puzzle.h +++ b/engines/zvision/scripting/puzzle.h @@ -31,7 +31,7 @@ namespace ZVision { struct Puzzle { - Puzzle() : key(0) {} + Puzzle() : key(0), addedBySetState(false) {} ~Puzzle() { for (Common::List::iterator iter = resultActions.begin(); iter != resultActions.end(); ++iter) { diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 56d0c3bd7f..c117da5ec2 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -96,7 +96,7 @@ void ScriptManager::parsePuzzle(Puzzle *puzzle, Common::SeekableReadStream &stre trimCommentsAndWhiteSpace(&line); } - puzzle->addedBySetState = 0; + puzzle->addedBySetState = false; } bool ScriptManager::parseCriteria(Common::SeekableReadStream &stream, Common::List > &criteriaList) const { diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 65077dfd12..4c1e69072d 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -97,7 +97,7 @@ bool ScriptManager::execScope(ScriptScope &scope) { scope.scopeQueue->clear(); for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) - (*PuzzleIter)->addedBySetState = 0; + (*PuzzleIter)->addedBySetState = false; if (scope.procCount < 2 || getStateValue(StateKey_ExecScopeStyle)) { for (PuzzleList::iterator PuzzleIter = scope.puzzles.begin(); PuzzleIter != scope.puzzles.end(); ++PuzzleIter) -- cgit v1.2.3 From 617623e9bff85f2fc0dd75509dfb93e95e366c8e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:07:28 +0600 Subject: ZVISION: Fix unchecked return value (CID 1257090) --- engines/zvision/sound/midi.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/sound/midi.cpp b/engines/zvision/sound/midi.cpp index 920002c7c3..3dd66ff2d4 100644 --- a/engines/zvision/sound/midi.cpp +++ b/engines/zvision/sound/midi.cpp @@ -21,6 +21,7 @@ */ #include "common/scummsys.h" +#include "common/textconsole.h" #include "zvision/sound/midi.h" @@ -29,7 +30,8 @@ namespace ZVision { MidiManager::MidiManager() { MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB); _driver = MidiDriver::createMidi(dev); - _driver->open(); + if (_driver->open()) + warning("Can't open MIDI, no MIDI output!"); } MidiManager::~MidiManager() { -- cgit v1.2.3 From 169bed1e5e8364875f68a66e7576c6947a11903b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:11:26 +0600 Subject: ZVISION: Fix dereference after null check (CID 1257091) --- engines/zvision/sound/zork_raw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 78c851e132..393f2eb6a9 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -73,6 +73,9 @@ RawChunkStream::RawChunk RawChunkStream::readNextChunk(Common::SeekableReadStrea tmp.size = 0; tmp.data = NULL; + if (!stream) + return tmp; + if (stream && (stream->size() == 0 || stream->eos())) return tmp; -- cgit v1.2.3 From ee7ba1bbaf4a17104f8a61be0218f9793b0b9cf6 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:14:13 +0600 Subject: ZVISION: Fix zork raw soundParams handling --- engines/zvision/sound/zork_raw.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 393f2eb6a9..8688039325 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -264,30 +264,33 @@ Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, fileName.toLowercase(); - SoundParams soundParams = {}; + const SoundParams *soundParams = NULL; if (engine->getGameId() == GID_NEMESIS) { for (int i = 0; i < 32; ++i) { if (RawZorkStream::_zNemSoundParamLookupTable[i].identifier == (fileName[6])) - soundParams = RawZorkStream::_zNemSoundParamLookupTable[i]; + soundParams = &RawZorkStream::_zNemSoundParamLookupTable[i]; } } else if (engine->getGameId() == GID_GRANDINQUISITOR) { for (int i = 0; i < 24; ++i) { if (RawZorkStream::_zgiSoundParamLookupTable[i].identifier == (fileName[7])) - soundParams = RawZorkStream::_zgiSoundParamLookupTable[i]; + soundParams = &RawZorkStream::_zgiSoundParamLookupTable[i]; } } - if (soundParams.packed) { - return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams.rate, soundParams.stereo, DisposeAfterUse::YES); + if (soundParams == NULL) + return NULL; + + if (soundParams->packed) { + return makeRawZorkStream(wrapBufferedSeekableReadStream(file, 2048, DisposeAfterUse::YES), soundParams->rate, soundParams->stereo, DisposeAfterUse::YES); } else { byte flags = 0; - if (soundParams.bits16) + if (soundParams->bits16) flags |= Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN; - if (soundParams.stereo) + if (soundParams->stereo) flags |= Audio::FLAG_STEREO; - return Audio::makeRawStream(file, soundParams.rate, flags, DisposeAfterUse::YES); + return Audio::makeRawStream(file, soundParams->rate, flags, DisposeAfterUse::YES); } } -- cgit v1.2.3 From 6c5c1828e1e7ed28865093de12156f6b99fdd40f Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:15:21 +0600 Subject: ZVISION: Fix unchecked return value (CID 1257092) --- engines/zvision/file/search_manager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 1a6a96ec6d..30c269c290 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -265,13 +265,14 @@ void SearchManager::addDir(const Common::String &name) { void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { Common::FSList fsList; - fsNode.getChildren(fsList); + if ( fsNode.getChildren(fsList) ) { - _list.push_back(fsNode.getPath()); + _list.push_back(fsNode.getPath()); - if (depth > 1) - for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) - listDirRecursive(_list, *it, depth - 1); + if (depth > 1) + for (Common::FSList::const_iterator it = fsList.begin(); it != fsList.end(); ++it) + listDirRecursive(_list, *it, depth - 1); + } } } // End of namespace ZVision -- cgit v1.2.3 From 6d1fcdbdbdf72d69eda6f458ff859bed7257410b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:15:48 +0600 Subject: ZVISION: Fix copy into fixed size buffer (CID 1257093) --- engines/zvision/graphics/cursors/cursor_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index ae13c9f4fc..92fd461c72 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -62,7 +62,8 @@ CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixel } else if (_engine->getGameId() == GID_GRANDINQUISITOR) { _cursors[i][0] = ZorkCursor(_engine, _zgiCursorFileNames[i]); // Up cursor char buffer[25]; - strcpy(buffer, _zgiCursorFileNames[i]); + memset(buffer, 0, 25); + strncpy(buffer, _zgiCursorFileNames[i], 24); buffer[3] += 2; _cursors[i][1] = ZorkCursor(_engine, buffer); // Down cursor } -- cgit v1.2.3 From 3806aa44186e4ce383697f6cb2fed8a23042020b Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:17:33 +0600 Subject: ZVISION: Fix explicit null dereferenced (CID 1257094) --- engines/zvision/scripting/sidefx/music_node.cpp | 45 +++++++++++++++---------- engines/zvision/scripting/sidefx/music_node.h | 1 + 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index c79dd0296d..56598189f6 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -47,6 +47,8 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool _pantrack = false; _pantrackPosition = 0; _sub = NULL; + _stereo = false; + _loaded = false; Audio::RewindableAudioStream *audioStream = NULL; @@ -59,30 +61,35 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool audioStream = makeRawZorkStream(filename, _engine); } - _stereo = audioStream->isStereo(); + if (audioStream) { + _stereo = audioStream->isStereo(); - if (_loop) { - Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); - } else { - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); - } + if (_loop) { + Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); + } else { + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); + } - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); + + // Change filename.raw into filename.sub + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); - // Change filename.raw into filename.sub - Common::String subname = filename; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); - if (_engine->getSearchManager()->hasFile(subname)) - _sub = new Subtitle(_engine, subname); + _loaded = true; + } } MusicNode::~MusicNode() { - _engine->_mixer->stopHandle(_handle); + if (!_loaded) + _engine->_mixer->stopHandle(_handle); if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); if (_sub) @@ -110,7 +117,7 @@ void MusicNode::setFade(int32 time, uint8 target) { } bool MusicNode::process(uint32 deltaTimeInMillis) { - if (! _engine->_mixer->isSoundHandleActive(_handle)) + if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle)) return stop(); else { uint8 _newvol = _volume; @@ -137,6 +144,8 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { } void MusicNode::setVolume(uint8 newVolume) { + if (!_loaded) + return; if (_pantrack) { int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); curX -= _pantrackPosition; diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index c8077c7a6a..09bdc3707e 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -88,6 +88,7 @@ private: bool _stereo; Audio::SoundHandle _handle; Subtitle *_sub; + bool _loaded; }; class MusicMidiNode : public MusicNodeBASE { -- cgit v1.2.3 From fafbd425dc9f85e524a8222facdb0067632add84 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:18:11 +0600 Subject: ZVISION: Fix copy into fixed size buffer (CID 1257095) --- engines/zvision/scripting/controls/slot_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/slot_control.cpp b/engines/zvision/scripting/controls/slot_control.cpp index 5228ba517b..42b54a9ab5 100644 --- a/engines/zvision/scripting/controls/slot_control.cpp +++ b/engines/zvision/scripting/controls/slot_control.cpp @@ -76,7 +76,7 @@ SlotControl::SlotControl(ZVision *engine, uint32 key, Common::SeekableReadStream } else if (param.matchString("eligible_objects", true)) { char buf[256]; memset(buf, 0, 256); - strcpy(buf, values.c_str()); + strncpy(buf, values.c_str(), 255); char *curpos = buf; char *strend = buf + strlen(buf); -- cgit v1.2.3 From 79f75059de9ef2530f8d1c043d97dafe8b8ffec8 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:18:46 +0600 Subject: ZVISION: Fix copy into fixed size buffer (CID 1257096) --- engines/zvision/scripting/controls/paint_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index f06dee25ad..df06bb814e 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -69,7 +69,7 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre } else if (param.matchString("eligible_objects", true)) { char buf[256]; memset(buf, 0, 256); - strcpy(buf, values.c_str()); + strncpy(buf, values.c_str(), 255); char *curpos = buf; char *strend = buf + strlen(buf); -- cgit v1.2.3 From 5fb33ee5e7c99f76ba9560b56177041d19fb602e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Fri, 19 Dec 2014 17:19:12 +0600 Subject: ZVISION: Fix unchecked return value (CID 1257098) --- engines/zvision/scripting/controls/save_control.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index e27faa50b6..b35611feca 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -77,10 +77,11 @@ SaveControl::SaveControl(ZVision *engine, uint32 key, Common::SeekableReadStream Common::SeekableReadStream *save = _engine->getSaveManager()->getSlotFile(iter->saveId); if (save) { SaveGameHeader header; - _engine->getSaveManager()->readSaveGameHeader(save, header); + if (_engine->getSaveManager()->readSaveGameHeader(save, header)) { + inp->setText(header.saveName); + iter->exist = true; + } delete save; - inp->setText(header.saveName); - iter->exist = true; } } } -- cgit v1.2.3 From 2170c9bc39fa0b0e9598515211bcef602ddaca48 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 19 Dec 2014 13:38:22 +0200 Subject: ZVISION: the type in ActionInventory is used as a signed byte now --- engines/zvision/scripting/actions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 523890e9ac..292e25e19c 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -210,7 +210,7 @@ public: ActionInventory(ZVision *engine, int32 slotkey, const Common::String &line); bool execute(); private: - uint8 _type; + int8 _type; int32 _key; }; -- cgit v1.2.3 From acb172251aa7401f43308ebcac9f30bef3aa40f5 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 11:14:10 -0600 Subject: ZVISION: Large scale variable, function, and class renaming to improve code clarity --- engines/zvision/core/events.cpp | 8 +- engines/zvision/graphics/render_manager.cpp | 348 +++++++++++++++------------- engines/zvision/graphics/render_manager.h | 102 ++++---- engines/zvision/zvision.cpp | 48 ++-- engines/zvision/zvision.h | 6 +- 5 files changed, 266 insertions(+), 246 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index c66e61a61a..fe357c263b 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -194,7 +194,7 @@ void ZVision::processEvents() { case Common::KEYCODE_LEFT: case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) - _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? + _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; @@ -202,7 +202,7 @@ void ZVision::processEvents() { case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) - _kbdVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? + _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; @@ -226,12 +226,12 @@ void ZVision::processEvents() { case Common::KEYCODE_LEFT: case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) - _kbdVelocity = 0; + _keyboardVelocity = 0; break; case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) - _kbdVelocity = 0; + _keyboardVelocity = 0; break; default: break; diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index e2ad13a330..b9305f5dcc 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -42,68 +42,73 @@ namespace ZVision { RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) : _engine(engine), _system(engine->_system), - _wrkWidth(workingWindow.width()), - _wrkHeight(workingWindow.height()), - _screenCenterX(_wrkWidth / 2), - _screenCenterY(_wrkHeight / 2), + _workingWidth(workingWindow.width()), + _workingHeight(workingWindow.height()), + _screenCenterX(_workingWidth / 2), + _screenCenterY(_workingHeight / 2), _workingWindow(workingWindow), _pixelFormat(pixelFormat), - _bkgWidth(0), - _bkgHeight(0), - _bkgOff(0), - _renderTable(_wrkWidth, _wrkHeight) { + _backgroundWidth(0), + _backgroundHeight(0), + _backgroundOffset(0), + _renderTable(_workingWidth, _workingHeight) { - _wrkWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); - _effectWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); - _outWnd.create(_wrkWidth, _wrkHeight, _pixelFormat); - _menuWnd.create(windowWidth, workingWindow.top, _pixelFormat); - _subWnd.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); + _backgroundSurface.create(_workingWidth, _workingHeight, _pixelFormat); + _effectSurface.create(_workingWidth, _workingHeight, _pixelFormat); + _warpedSceneSurface.create(_workingWidth, _workingHeight, _pixelFormat); + _menuSurface.create(windowWidth, workingWindow.top, _pixelFormat); + _subtitleSurface.create(windowWidth, windowHeight - workingWindow.bottom, _pixelFormat); - _menuWndRect = Common::Rect(0, 0, windowWidth, workingWindow.top); - _subWndRect = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight); + _menuArea = Common::Rect(0, 0, windowWidth, workingWindow.top); + _subtitleArea = Common::Rect(0, workingWindow.bottom, windowWidth, windowHeight); _subid = 0; } RenderManager::~RenderManager() { - _curBkg.free(); - _wrkWnd.free(); - _effectWnd.free(); - _outWnd.free(); - _menuWnd.free(); - _subWnd.free(); + _currentBackgroundImage.free(); + _backgroundSurface.free(); + _effectSurface.free(); + _warpedSceneSurface.free(); + _menuSurface.free(); + _subtitleSurface.free(); } -void RenderManager::renderBackbufferToScreen() { - Graphics::Surface *out = &_outWnd; - Graphics::Surface *in = &_wrkWnd; +void RenderManager::renderSceneToScreen() { + Graphics::Surface *out = &_warpedSceneSurface; + Graphics::Surface *in = &_backgroundSurface; Common::Rect outWndDirtyRect; + // If we have graphical effects, we apply them using a temporary buffer if (!_effects.empty()) { bool copied = false; - Common::Rect windRect(_wrkWidth, _wrkHeight); - for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { + Common::Rect windowRect(_workingWidth, _workingHeight); + + for (EffectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { Common::Rect rect = (*it)->getRegion(); - Common::Rect scrPlace = rect; - if ((*it)->isPort()) - scrPlace = bkgRectToScreen(scrPlace); - if (windRect.intersects(scrPlace)) { + Common::Rect screenSpaceLocation = rect; + + if ((*it)->isPort()) { + screenSpaceLocation = transformBackgroundSpaceRectToScreenSpace(screenSpaceLocation); + } + + if (windowRect.intersects(screenSpaceLocation)) { if (!copied) { copied = true; - _effectWnd.copyFrom(_wrkWnd); - in = &_effectWnd; + _effectSurface.copyFrom(_backgroundSurface); + in = &_effectSurface; } const Graphics::Surface *post; if ((*it)->isPort()) - post = (*it)->draw(_curBkg.getSubArea(rect)); + post = (*it)->draw(_currentBackgroundImage.getSubArea(rect)); else - post = (*it)->draw(_effectWnd.getSubArea(rect)); - blitSurfaceToSurface(*post, _effectWnd, scrPlace.left, scrPlace.top); - scrPlace.clip(windRect); - if (_wrkWndDirtyRect .isEmpty()) { - _wrkWndDirtyRect = scrPlace; + post = (*it)->draw(_effectSurface.getSubArea(rect)); + blitSurfaceToSurface(*post, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top); + screenSpaceLocation.clip(windowRect); + if (_backgroundSurfaceDirtyRect .isEmpty()) { + _backgroundSurfaceDirtyRect = screenSpaceLocation; } else { - _wrkWndDirtyRect.extend(scrPlace); + _backgroundSurfaceDirtyRect.extend(screenSpaceLocation); } } } @@ -111,14 +116,14 @@ void RenderManager::renderBackbufferToScreen() { RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA || state == RenderTable::TILT) { - if (!_wrkWndDirtyRect.isEmpty()) { - _renderTable.mutateImage(&_outWnd, in); - out = &_outWnd; - outWndDirtyRect = Common::Rect(_wrkWidth, _wrkHeight); + if (!_backgroundSurfaceDirtyRect.isEmpty()) { + _renderTable.mutateImage(&_warpedSceneSurface, in); + out = &_warpedSceneSurface; + outWndDirtyRect = Common::Rect(_workingWidth, _workingHeight); } } else { out = in; - outWndDirtyRect = _wrkWndDirtyRect; + outWndDirtyRect = _backgroundSurfaceDirtyRect; } if (!outWndDirtyRect.isEmpty()) { @@ -354,20 +359,20 @@ const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point & } if (state == RenderTable::PANORAMA) { - newPoint += (Common::Point(_bkgOff - _screenCenterX, 0)); + newPoint += (Common::Point(_backgroundOffset - _screenCenterX, 0)); } else if (state == RenderTable::TILT) { - newPoint += (Common::Point(0, _bkgOff - _screenCenterY)); + newPoint += (Common::Point(0, _backgroundOffset - _screenCenterY)); } - if (_bkgWidth) - newPoint.x %= _bkgWidth; - if (_bkgHeight) - newPoint.y %= _bkgHeight; + if (_backgroundWidth) + newPoint.x %= _backgroundWidth; + if (_backgroundHeight) + newPoint.y %= _backgroundHeight; if (newPoint.x < 0) - newPoint.x += _bkgWidth; + newPoint.x += _backgroundWidth; if (newPoint.y < 0) - newPoint.y += _bkgHeight; + newPoint.y += _backgroundHeight; return newPoint; } else { @@ -380,18 +385,18 @@ RenderTable *RenderManager::getRenderTable() { } void RenderManager::setBackgroundImage(const Common::String &fileName) { - readImageToSurface(fileName, _curBkg); - _bkgWidth = _curBkg.w; - _bkgHeight = _curBkg.h; - _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); + readImageToSurface(fileName, _currentBackgroundImage); + _backgroundWidth = _currentBackgroundImage.w; + _backgroundHeight = _currentBackgroundImage.h; + _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight); } void RenderManager::setBackgroundPosition(int offset) { RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::TILT || state == RenderTable::PANORAMA) - if (_bkgOff != offset) - _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); - _bkgOff = offset; + if (_backgroundOffset != offset) + _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight); + _backgroundOffset = offset; _engine->getScriptManager()->setStateValue(StateKey_ViewPos, offset); } @@ -400,9 +405,9 @@ uint32 RenderManager::getCurrentBackgroundOffset() { RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA) { - return _bkgOff; + return _backgroundOffset; } else if (state == RenderTable::TILT) { - return _bkgOff; + return _backgroundOffset; } else { return 0; } @@ -588,24 +593,24 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics: void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) { Common::Rect empt; - blitSurfaceToSurface(src, empt, _curBkg, x, y); + blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); - if (_bkgDirtyRect.isEmpty()) - _bkgDirtyRect = dirty; + if (_backgroundDirtyRect.isEmpty()) + _backgroundDirtyRect = dirty; else - _bkgDirtyRect.extend(dirty); + _backgroundDirtyRect.extend(dirty); } void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) { Common::Rect empt; - blitSurfaceToSurface(src, empt, _curBkg, x, y, colorkey); + blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); - if (_bkgDirtyRect.isEmpty()) - _bkgDirtyRect = dirty; + if (_backgroundDirtyRect.isEmpty()) + _backgroundDirtyRect = dirty; else - _bkgDirtyRect.extend(dirty); + _backgroundDirtyRect.extend(dirty); } void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect) { @@ -636,37 +641,37 @@ void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const C void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) { Common::Rect empt; - blitSurfaceToSurface(src, empt, _menuWnd, x, y); + blitSurfaceToSurface(src, empt, _menuSurface, x, y); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); - if (_menuWndDirtyRect.isEmpty()) - _menuWndDirtyRect = dirty; + if (_menuSurfaceDirtyRect.isEmpty()) + _menuSurfaceDirtyRect = dirty; else - _menuWndDirtyRect.extend(dirty); + _menuSurfaceDirtyRect.extend(dirty); } void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) { Common::Rect empt; - blitSurfaceToSurface(src, empt, _menuWnd, x, y, colorkey); + blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); - if (_menuWndDirtyRect.isEmpty()) - _menuWndDirtyRect = dirty; + if (_menuSurfaceDirtyRect.isEmpty()) + _menuSurfaceDirtyRect = dirty; else - _menuWndDirtyRect.extend(dirty); + _menuSurfaceDirtyRect.extend(dirty); } Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) { Common::Rect dst = rect; - dst.clip(_bkgWidth, _bkgHeight); + dst.clip(_backgroundWidth, _backgroundHeight); if (dst.isEmpty() || !dst.isValidRect()) return NULL; Graphics::Surface *srf = new Graphics::Surface; - srf->create(dst.width(), dst.height(), _curBkg.format); + srf->create(dst.width(), dst.height(), _currentBackgroundImage.format); - srf->copyRectToSurface(_curBkg, 0, 0, Common::Rect(dst)); + srf->copyRectToSurface(_currentBackgroundImage, 0, 0, Common::Rect(dst)); return srf; } @@ -693,101 +698,110 @@ Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) { return loadImage(str, transposed); } -void RenderManager::prepareBkg() { - _bkgDirtyRect.clip(_bkgWidth, _bkgHeight); +void RenderManager::prepareBackground() { + _backgroundDirtyRect.clip(_backgroundWidth, _backgroundHeight); RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA) { - Common::Rect viewPort(_wrkWidth, _wrkHeight); - viewPort.translate(-(_screenCenterX - _bkgOff), 0); - Common::Rect drawRect = _bkgDirtyRect; + // Calculate the visible portion of the background + Common::Rect viewPort(_workingWidth, _workingHeight); + viewPort.translate(-(_screenCenterX - _backgroundOffset), 0); + Common::Rect drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); - if (!drawRect.isEmpty()) - blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - _bkgOff + drawRect.left, drawRect.top); + // Render the visible portion + if (!drawRect.isEmpty()) { + blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - _backgroundOffset + drawRect.left, drawRect.top); + } - _wrkWndDirtyRect = _bkgDirtyRect; - _wrkWndDirtyRect.translate(_screenCenterX - _bkgOff, 0); + // Mark the dirty portion of the surface + _backgroundSurfaceDirtyRect = _backgroundDirtyRect; + _backgroundSurfaceDirtyRect.translate(_screenCenterX - _backgroundOffset, 0); - if (_bkgOff < _screenCenterX) { - viewPort.moveTo(-(_screenCenterX - (_bkgOff + _bkgWidth)), 0); - drawRect = _bkgDirtyRect; + // Panorama mode allows the user to spin in circles. Therefore, we need to render + // the portion of the image that wrapped to the other side of the screen + if (_backgroundOffset < _screenCenterX) { + viewPort.moveTo(-(_screenCenterX - (_backgroundOffset + _backgroundWidth)), 0); + drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); if (!drawRect.isEmpty()) - blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX - (_bkgOff + _bkgWidth) + drawRect.left, drawRect.top); + blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - (_backgroundOffset + _backgroundWidth) + drawRect.left, drawRect.top); - Common::Rect tmp = _bkgDirtyRect; - tmp.translate(_screenCenterX - (_bkgOff + _bkgWidth), 0); + Common::Rect tmp = _backgroundDirtyRect; + tmp.translate(_screenCenterX - (_backgroundOffset + _backgroundWidth), 0); if (!tmp.isEmpty()) - _wrkWndDirtyRect.extend(tmp); + _backgroundSurfaceDirtyRect.extend(tmp); - } else if (_bkgWidth - _bkgOff < _screenCenterX) { - viewPort.moveTo(-(_screenCenterX + _bkgWidth - _bkgOff), 0); - drawRect = _bkgDirtyRect; + } else if (_backgroundWidth - _backgroundOffset < _screenCenterX) { + viewPort.moveTo(-(_screenCenterX + _backgroundWidth - _backgroundOffset), 0); + drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); if (!drawRect.isEmpty()) - blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, _screenCenterX + _bkgWidth - _bkgOff + drawRect.left, drawRect.top); + blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX + _backgroundWidth - _backgroundOffset + drawRect.left, drawRect.top); - Common::Rect tmp = _bkgDirtyRect; - tmp.translate(_screenCenterX + _bkgWidth - _bkgOff, 0); + Common::Rect tmp = _backgroundDirtyRect; + tmp.translate(_screenCenterX + _backgroundWidth - _backgroundOffset, 0); if (!tmp.isEmpty()) - _wrkWndDirtyRect.extend(tmp); + _backgroundSurfaceDirtyRect.extend(tmp); } } else if (state == RenderTable::TILT) { - Common::Rect viewPort(_wrkWidth, _wrkHeight); - viewPort.translate(0, -(_screenCenterY - _bkgOff)); - Common::Rect drawRect = _bkgDirtyRect; + // Tilt doesn't allow wrapping, so we just do a simple clip + Common::Rect viewPort(_workingWidth, _workingHeight); + viewPort.translate(0, -(_screenCenterY - _backgroundOffset)); + Common::Rect drawRect = _backgroundDirtyRect; drawRect.clip(viewPort); if (!drawRect.isEmpty()) - blitSurfaceToSurface(_curBkg, drawRect, _wrkWnd, drawRect.left, _screenCenterY - _bkgOff + drawRect.top); + blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, drawRect.left, _screenCenterY - _backgroundOffset + drawRect.top); - _wrkWndDirtyRect = _bkgDirtyRect; - _wrkWndDirtyRect.translate(0, _screenCenterY - _bkgOff); + // Mark the dirty portion of the surface + _backgroundSurfaceDirtyRect = _backgroundDirtyRect; + _backgroundSurfaceDirtyRect.translate(0, _screenCenterY - _backgroundOffset); } else { - if (!_bkgDirtyRect.isEmpty()) - blitSurfaceToSurface(_curBkg, _bkgDirtyRect, _wrkWnd, _bkgDirtyRect.left, _bkgDirtyRect.top); - _wrkWndDirtyRect = _bkgDirtyRect; + if (!_backgroundDirtyRect.isEmpty()) + blitSurfaceToSurface(_currentBackgroundImage, _backgroundDirtyRect, _backgroundSurface, _backgroundDirtyRect.left, _backgroundDirtyRect.top); + _backgroundSurfaceDirtyRect = _backgroundDirtyRect; } - _bkgDirtyRect = Common::Rect(); + // Clear the dirty rect since everything is clean now + _backgroundDirtyRect = Common::Rect(); - _wrkWndDirtyRect.clip(_wrkWidth, _wrkHeight); + _backgroundSurfaceDirtyRect.clip(_workingWidth, _workingHeight); } void RenderManager::clearMenuSurface() { - _menuWndDirtyRect = Common::Rect(0, 0, _menuWnd.w, _menuWnd.h); - _menuWnd.fillRect(_menuWndDirtyRect, 0); + _menuSurfaceDirtyRect = Common::Rect(0, 0, _menuSurface.w, _menuSurface.h); + _menuSurface.fillRect(_menuSurfaceDirtyRect, 0); } void RenderManager::clearMenuSurface(const Common::Rect &r) { - if (_menuWndDirtyRect.isEmpty()) - _menuWndDirtyRect = r; + if (_menuSurfaceDirtyRect.isEmpty()) + _menuSurfaceDirtyRect = r; else - _menuWndDirtyRect.extend(r); - _menuWnd.fillRect(r, 0); + _menuSurfaceDirtyRect.extend(r); + _menuSurface.fillRect(r, 0); } void RenderManager::renderMenuToScreen() { - if (!_menuWndDirtyRect.isEmpty()) { - _menuWndDirtyRect.clip(Common::Rect(_menuWnd.w, _menuWnd.h)); - if (!_menuWndDirtyRect.isEmpty()) - _system->copyRectToScreen(_menuWnd.getBasePtr(_menuWndDirtyRect.left, _menuWndDirtyRect.top), _menuWnd.pitch, - _menuWndDirtyRect.left + _menuWndRect.left, - _menuWndDirtyRect.top + _menuWndRect.top, - _menuWndDirtyRect.width(), - _menuWndDirtyRect.height()); - _menuWndDirtyRect = Common::Rect(); + if (!_menuSurfaceDirtyRect.isEmpty()) { + _menuSurfaceDirtyRect.clip(Common::Rect(_menuSurface.w, _menuSurface.h)); + if (!_menuSurfaceDirtyRect.isEmpty()) + _system->copyRectToScreen(_menuSurface.getBasePtr(_menuSurfaceDirtyRect.left, _menuSurfaceDirtyRect.top), _menuSurface.pitch, + _menuSurfaceDirtyRect.left + _menuArea.left, + _menuSurfaceDirtyRect.top + _menuArea.top, + _menuSurfaceDirtyRect.width(), + _menuSurfaceDirtyRect.height()); + _menuSurfaceDirtyRect = Common::Rect(); } } uint16 RenderManager::createSubArea(const Common::Rect &area) { _subid++; - oneSub sub; + OneSubtitle sub; sub.redraw = false; sub.timer = -1; sub.todelete = false; @@ -801,11 +815,11 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { uint16 RenderManager::createSubArea() { _subid++; - oneSub sub; + OneSubtitle sub; sub.redraw = false; sub.timer = -1; sub.todelete = false; - sub.r = Common::Rect(_subWndRect.left, _subWndRect.top, _subWndRect.right, _subWndRect.bottom); + sub.r = Common::Rect(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom); sub.r.translate(-_workingWindow.left, -_workingWindow.top); _subsList[_subid] = sub; @@ -825,7 +839,7 @@ void RenderManager::deleteSubArea(uint16 id, int16 delay) { void RenderManager::updateSubArea(uint16 id, const Common::String &txt) { if (_subsList.contains(id)) { - oneSub *sub = &_subsList[id]; + OneSubtitle *sub = &_subsList[id]; sub->txt = txt; sub->redraw = true; } @@ -833,7 +847,7 @@ void RenderManager::updateSubArea(uint16 id, const Common::String &txt) { void RenderManager::processSubs(uint16 deltatime) { bool redraw = false; - for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { + for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { if (it->_value.timer != -1) { it->_value.timer -= deltatime; if (it->_value.timer <= 0) @@ -848,31 +862,31 @@ void RenderManager::processSubs(uint16 deltatime) { } if (redraw) { - _subWnd.fillRect(Common::Rect(_subWnd.w, _subWnd.h), 0); + _subtitleSurface.fillRect(Common::Rect(_subtitleSurface.w, _subtitleSurface.h), 0); - for (subMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { - oneSub *sub = &it->_value; + for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { + OneSubtitle *sub = &it->_value; if (sub->txt.size()) { Graphics::Surface *rndr = new Graphics::Surface(); rndr->create(sub->r.width(), sub->r.height(), _pixelFormat); _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); - blitSurfaceToSurface(*rndr, _subWnd, sub->r.left - _subWndRect.left + _workingWindow.left, sub->r.top - _subWndRect.top + _workingWindow.top); + blitSurfaceToSurface(*rndr, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); rndr->free(); delete rndr; } sub->redraw = false; } - _system->copyRectToScreen(_subWnd.getPixels(), _subWnd.pitch, - _subWndRect.left, - _subWndRect.top, - _subWnd.w, - _subWnd.h); + _system->copyRectToScreen(_subtitleSurface.getPixels(), _subtitleSurface.pitch, + _subtitleArea.left, + _subtitleArea.top, + _subtitleSurface.w, + _subtitleSurface.h); } } Common::Point RenderManager::getBkgSize() { - return Common::Point(_bkgWidth, _bkgHeight); + return Common::Point(_backgroundWidth, _backgroundHeight); } void RenderManager::addEffect(Effect *_effect) { @@ -880,7 +894,7 @@ void RenderManager::addEffect(Effect *_effect) { } void RenderManager::deleteEffect(uint32 ID) { - for (effectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { + for (EffectsList::iterator it = _effects.begin(); it != _effects.end(); it++) { if ((*it)->getKey() == ID) { delete *it; it = _effects.erase(it); @@ -888,54 +902,54 @@ void RenderManager::deleteEffect(uint32 ID) { } } -Common::Rect RenderManager::bkgRectToScreen(const Common::Rect &src) { +Common::Rect RenderManager::transformBackgroundSpaceRectToScreenSpace(const Common::Rect &src) { Common::Rect tmp = src; RenderTable::RenderState state = _renderTable.getRenderState(); if (state == RenderTable::PANORAMA) { - if (_bkgOff < _screenCenterX) { - Common::Rect rScreen(_screenCenterX + _bkgOff, _wrkHeight); - Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight); - lScreen.translate(_bkgWidth - lScreen.width(), 0); + if (_backgroundOffset < _screenCenterX) { + Common::Rect rScreen(_screenCenterX + _backgroundOffset, _workingHeight); + Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight); + lScreen.translate(_backgroundWidth - lScreen.width(), 0); lScreen.clip(src); rScreen.clip(src); if (rScreen.width() < lScreen.width()) { - tmp.translate(_screenCenterX - _bkgOff - _bkgWidth, 0); + tmp.translate(_screenCenterX - _backgroundOffset - _backgroundWidth, 0); } else { - tmp.translate(_screenCenterX - _bkgOff, 0); + tmp.translate(_screenCenterX - _backgroundOffset, 0); } - } else if (_bkgWidth - _bkgOff < _screenCenterX) { - Common::Rect rScreen(_screenCenterX - (_bkgWidth - _bkgOff), _wrkHeight); - Common::Rect lScreen(_wrkWidth - rScreen.width(), _wrkHeight); - lScreen.translate(_bkgWidth - lScreen.width(), 0); + } else if (_backgroundWidth - _backgroundOffset < _screenCenterX) { + Common::Rect rScreen(_screenCenterX - (_backgroundWidth - _backgroundOffset), _workingHeight); + Common::Rect lScreen(_workingWidth - rScreen.width(), _workingHeight); + lScreen.translate(_backgroundWidth - lScreen.width(), 0); lScreen.clip(src); rScreen.clip(src); if (lScreen.width() < rScreen.width()) { - tmp.translate(_screenCenterX + (_bkgWidth - _bkgOff), 0); + tmp.translate(_screenCenterX + (_backgroundWidth - _backgroundOffset), 0); } else { - tmp.translate(_screenCenterX - _bkgOff, 0); + tmp.translate(_screenCenterX - _backgroundOffset, 0); } } else { - tmp.translate(_screenCenterX - _bkgOff, 0); + tmp.translate(_screenCenterX - _backgroundOffset, 0); } } else if (state == RenderTable::TILT) { - tmp.translate(0, (_screenCenterY - _bkgOff)); + tmp.translate(0, (_screenCenterY - _backgroundOffset)); } return tmp; } EffectMap *RenderManager::makeEffectMap(const Common::Point &xy, int16 depth, const Common::Rect &rect, int8 *_minComp, int8 *_maxComp) { - Common::Rect bkgRect(_bkgWidth, _bkgHeight); + Common::Rect bkgRect(_backgroundWidth, _backgroundHeight); if (!bkgRect.contains(xy)) return NULL; if (!bkgRect.intersects(rect)) return NULL; - uint16 color = *(uint16 *)_curBkg.getBasePtr(xy.x, xy.y); + uint16 color = *(uint16 *)_currentBackgroundImage.getBasePtr(xy.x, xy.y); uint8 stC1, stC2, stC3; - _curBkg.format.colorToRGB(color, stC1, stC2, stC3); + _currentBackgroundImage.format.colorToRGB(color, stC1, stC2, stC3); EffectMap *newMap = new EffectMap; EffectMapUnit unit; @@ -953,11 +967,11 @@ EffectMap *RenderManager::makeEffectMap(const Common::Point &xy, int16 depth, co uint8 depth8 = depth << 3; for (int16 j = 0; j < h; j++) { - uint16 *pix = (uint16 *)_curBkg.getBasePtr(rect.left, rect.top + j); + uint16 *pix = (uint16 *)_currentBackgroundImage.getBasePtr(rect.left, rect.top + j); for (int16 i = 0; i < w; i++) { uint16 curClr = pix[i]; uint8 cC1, cC2, cC3; - _curBkg.format.colorToRGB(curClr, cC1, cC2, cC3); + _currentBackgroundImage.format.colorToRGB(curClr, cC1, cC2, cC3); bool use = false; @@ -1055,11 +1069,11 @@ EffectMap *RenderManager::makeEffectMap(const Graphics::Surface &surf, uint16 tr } void RenderManager::markDirty() { - _bkgDirtyRect = Common::Rect(_bkgWidth, _bkgHeight); + _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight); } void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) { - _curBkg.fillRect(Common::Rect(_curBkg.w, _curBkg.h), _curBkg.format.RGBToColor(r, g, b)); + _currentBackgroundImage.fillRect(Common::Rect(_currentBackgroundImage.w, _currentBackgroundImage.h), _currentBackgroundImage.format.RGBToColor(r, g, b)); markDirty(); } diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 879a8643ce..29bbd8f411 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -52,7 +52,7 @@ public: ~RenderManager(); private: - struct oneSub { + struct OneSubtitle { Common::Rect r; Common::String txt; int16 timer; @@ -60,87 +60,91 @@ private: bool redraw; }; - typedef Common::HashMap subMap; - typedef Common::List effectsList; + typedef Common::HashMap SubtitleMap; + typedef Common::List EffectsList; private: ZVision *_engine; OSystem *_system; const Graphics::PixelFormat _pixelFormat; - // A buffer for blitting background image to working window - Graphics::Surface _wrkWnd; + /** + * A Rectangle centered inside the actual window. All in-game coordinates + * are given in this coordinate space. Also, all images are clipped to the + * edges of this Rectangle + */ + const Common::Rect _workingWindow; - Common::Rect _wrkWndDirtyRect; + // Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() + const int _workingWidth; + // Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() + const int _workingHeight; + // Center of the screen in the x direction + const int _screenCenterX; + // Center of the screen in the y direction + const int _screenCenterY; + + /** A buffer for background image that's being used to create the background */ + Graphics::Surface _currentBackgroundImage; + Common::Rect _backgroundDirtyRect; - // A buffer for mutate image by tilt or panorama renderers - Graphics::Surface _outWnd; + /** + * The x1 or y1 offset of the subRectangle of the background that is currently displayed on the screen + * It will be x1 if PANORAMA, or y1 if TILT + */ + int16 _backgroundOffset; + /** The width of the current background image */ + uint16 _backgroundWidth; + /** The height of the current background image */ + uint16 _backgroundHeight; - Common::Rect _bkgDirtyRect; + // A buffer that holds the portion of the background that is used to render the final image + // If it's a normal scene, the pixels will be blitted directly to the screen + // If it's a panorma / tilt scene, the pixels will be first warped to _warpedSceneSurface + Graphics::Surface _backgroundSurface; + Common::Rect _backgroundSurfaceDirtyRect; // A buffer for subtitles - Graphics::Surface _subWnd; + Graphics::Surface _subtitleSurface; + Common::Rect _subtitleSurfaceDirtyRect; - Common::Rect _subWndDirtyRect; + // Rectangle for subtitles area + Common::Rect _subtitleArea; // A buffer for menu drawing - Graphics::Surface _menuWnd; + Graphics::Surface _menuSurface; + Common::Rect _menuSurfaceDirtyRect; - Common::Rect _menuWndDirtyRect; + // Rectangle for menu area + Common::Rect _menuArea; // A buffer used for apply graphics effects - Graphics::Surface _effectWnd; + Graphics::Surface _effectSurface; - /** Width of the working window. Saved to prevent extraneous calls to _workingWindow.width() */ - const int _wrkWidth; - /** Height of the working window. Saved to prevent extraneous calls to _workingWindow.height() */ - const int _wrkHeight; - /** Center of the screen in the x direction */ - const int _screenCenterX; - /** Center of the screen in the y direction */ - const int _screenCenterY; - - /** - * A Rectangle centered inside the actual window. All in-game coordinates - * are given in this coordinate space. Also, all images are clipped to the - * edges of this Rectangle - */ - const Common::Rect _workingWindow; - - // Recatangle for subtitles area - Common::Rect _subWndRect; + // A buffer to store the result of the panorama / tilt warps + Graphics::Surface _warpedSceneSurface; - // Recatangle for menu area - Common::Rect _menuWndRect; /** Used to warp the background image */ RenderTable _renderTable; - // A buffer for background image - Graphics::Surface _curBkg; - /** The (x1,y1) coordinates of the subRectangle of the background that is currently displayed on the screen */ - int16 _bkgOff; - /** The width of the current background image */ - uint16 _bkgWidth; - /** The height of the current background image */ - uint16 _bkgHeight; - // Internal subtitles counter uint16 _subid; // Subtitle list - subMap _subsList; + SubtitleMap _subsList; // Visual effects list - effectsList _effects; + EffectsList _effects; + public: void initialize(); /** - * Renders the current state of the backbuffer to the screen + * Renders the scene to the screen */ - void renderBackbufferToScreen(); + void renderSceneToScreen(); /** * Blits the image or a portion of the image to the background. @@ -274,7 +278,7 @@ public: void renderMenuToScreen(); // Copy needed portion of background surface to workingWindow surface - void prepareBkg(); + void prepareBackground(); /** * Reads an image file pixel data into a Surface buffer. In the process @@ -319,7 +323,7 @@ public: EffectMap *makeEffectMap(const Graphics::Surface &surf, uint16 transp); // Return background rectangle in screen coordinates - Common::Rect bkgRectToScreen(const Common::Rect &src); + Common::Rect transformBackgroundSpaceRectToScreenSpace(const Common::Rect &src); // Mark whole background surface as dirty void markDirty(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 4e5307c182..c32cceb26e 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -97,8 +97,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _textRenderer(nullptr), _halveDelay(false), _audioId(0), - _rendDelay(2), - _kbdVelocity(0), + _frameRenderDelay(2), + _keyboardVelocity(0), _mouseVelocity(0), _videoIsPlaying(false) { @@ -113,7 +113,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight ); - memset(_cheatBuff, 0, sizeof(_cheatBuff)); + memset(_cheatBuffer, 0, sizeof(_cheatBuffer)); } ZVision::~ZVision() { @@ -233,29 +233,31 @@ Common::Error ZVision::run() { processEvents(); updateRotation(); - // Call _renderManager->update() first so the background renders - // before anything that puzzles/controls will render _scriptManager->update(deltaTime); _menu->process(deltaTime); // Render the backBuffer to the screen - _renderManager->prepareBkg(); + _renderManager->prepareBackground(); _renderManager->renderMenuToScreen(); _renderManager->processSubs(deltaTime); - _renderManager->renderBackbufferToScreen(); + _renderManager->renderSceneToScreen(); // Update the screen - if (_rendDelay <= 0) + if (_frameRenderDelay <= 0) { _system->updateScreen(); - else - _rendDelay--; + } else { + _frameRenderDelay--; + } // Calculate the frame delay based off a desired frame time int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); // Ensure non-negative delay = delay < 0 ? 0 : delay; - if (_halveDelay) + + if (_halveDelay) { delay >>= 1; + } + _system->delayMillis(delay); } @@ -266,7 +268,7 @@ bool ZVision::askQuestion(const Common::String &str) { uint16 msgid = _renderManager->createSubArea(); _renderManager->updateSubArea(msgid, str); _renderManager->processSubs(0); - _renderManager->renderBackbufferToScreen(); + _renderManager->renderSceneToScreen(); _clock.stop(); int result = 0; @@ -302,7 +304,7 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { uint16 msgid = _renderManager->createSubArea(); _renderManager->updateSubArea(msgid, str); _renderManager->processSubs(0); - _renderManager->renderBackbufferToScreen(); + _renderManager->renderSceneToScreen(); _clock.stop(); uint32 stopTime = _system->getMillis() + milsecs; @@ -329,7 +331,7 @@ void ZVision::timedMessage(const Common::String &str, uint16 milsecs) { uint16 msgid = _renderManager->createSubArea(); _renderManager->updateSubArea(msgid, str); _renderManager->processSubs(0); - _renderManager->renderBackbufferToScreen(); + _renderManager->renderSceneToScreen(); _renderManager->deleteSubArea(msgid, milsecs); } @@ -352,15 +354,15 @@ Common::String ZVision::generateAutoSaveFileName() { } void ZVision::setRenderDelay(uint delay) { - _rendDelay = delay; + _frameRenderDelay = delay; } bool ZVision::canRender() { - return _rendDelay <= 0; + return _frameRenderDelay <= 0; } void ZVision::updateRotation() { - int16 _velocity = _mouseVelocity + _kbdVelocity; + int16 _velocity = _mouseVelocity + _keyboardVelocity; if (_halveDelay) _velocity /= 2; @@ -480,8 +482,8 @@ void ZVision::rotateTo(int16 _toPos, int16 _time) { _renderManager->setBackgroundPosition(curX); - _renderManager->prepareBkg(); - _renderManager->renderBackbufferToScreen(); + _renderManager->prepareBackground(); + _renderManager->renderSceneToScreen(); _system->updateScreen(); @@ -512,9 +514,9 @@ bool ZVision::ifQuit() { void ZVision::pushKeyToCheatBuf(uint8 key) { for (int i = 0; i < KEYBUF_SIZE - 1; i++) - _cheatBuff[i] = _cheatBuff[i + 1]; + _cheatBuffer[i] = _cheatBuffer[i + 1]; - _cheatBuff[KEYBUF_SIZE - 1] = key; + _cheatBuffer[KEYBUF_SIZE - 1] = key; } bool ZVision::checkCode(const char *code) { @@ -524,7 +526,7 @@ bool ZVision::checkCode(const char *code) { return false; for (int i = 0; i < codeLen; i++) - if (code[i] != _cheatBuff[KEYBUF_SIZE - codeLen + i] && code[i] != '?') + if (code[i] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?') return false; return true; @@ -534,7 +536,7 @@ uint8 ZVision::getBufferedKey(uint8 pos) { if (pos >= KEYBUF_SIZE) return 0; else - return _cheatBuff[KEYBUF_SIZE - pos - 1]; + return _cheatBuffer[KEYBUF_SIZE - pos - 1]; } void ZVision::showDebugMsg(const Common::String &msg, int16 delay) { diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 78c1c824a1..7ea10ed64d 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -117,13 +117,13 @@ private: // To prevent allocation every time we process events Common::Event _event; - int _rendDelay; + int _frameRenderDelay; int16 _mouseVelocity; - int16 _kbdVelocity; + int16 _keyboardVelocity; bool _halveDelay; bool _videoIsPlaying; - uint8 _cheatBuff[KEYBUF_SIZE]; + uint8 _cheatBuffer[KEYBUF_SIZE]; public: uint32 getFeatures() const; Common::Language getLanguage() const; -- cgit v1.2.3 From 808a2045b4a3b210f1f2512617fe1be41c5dc460 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 11:20:01 -0600 Subject: ZVISION: Fix code mis-alignment created from variable rename --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index fe357c263b..6cf0ae5d0d 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -195,16 +195,16 @@ void ZVision::processEvents() { case Common::KEYCODE_RIGHT: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA) _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ? - -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : - _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; case Common::KEYCODE_UP: case Common::KEYCODE_DOWN: if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT) _keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ? - -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : - _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; + -_scriptManager->getStateValue(StateKey_KbdRotateSpeed) : + _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; default: -- cgit v1.2.3 From ff35d7118c0a61a472b74d87337ee62eac993ce1 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Wed, 17 Sep 2014 15:49:44 -0500 Subject: SWORD25: Create a set of functions for manually serializing a double Since we can't assume IEEE. --- engines/sword25/util/double_serializer.cpp | 138 +++++++++++++++++++++++++++++ engines/sword25/util/double_serializer.h | 95 ++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 engines/sword25/util/double_serializer.cpp create mode 100644 engines/sword25/util/double_serializer.h diff --git a/engines/sword25/util/double_serializer.cpp b/engines/sword25/util/double_serializer.cpp new file mode 100644 index 0000000000..d7ba4f3052 --- /dev/null +++ b/engines/sword25/util/double_serializer.cpp @@ -0,0 +1,138 @@ +/* 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 "sword25/util/double_serializer.h" + +#include "common/scummsys.h" + + +namespace Util { + +SerializedDouble encodeDouble(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the the first part of the significand into the integer range + double shiftedsignificandPart = ldexp(abs(significand), 32); + uint32 significandOne = uint32(floor(shiftedsignificandPart)); + + // Shift the remainder of the significand into the integer range + shiftedsignificandPart -= significandOne; + uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 31)); + + SerializedDouble returnValue; + returnValue.significandOne = significandOne; // SignificandOne + returnValue.signAndSignificandTwo = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign + significandTwo; // SignificandTwo + returnValue.exponent = (int16)exponent; + return returnValue; +} + +double decodeDouble(SerializedDouble value) { + // Expand the exponent and the parts of the significand + int exponent = (int)value.exponent; + double expandedsignificandOne = (double)value.significandOne; + double expandedsignificandTwo = (double)(value.signAndSignificandTwo & 0x7FFFFFFF); + + // Deflate the significand + double shiftedsignificand = ldexp(expandedsignificandTwo, -21); + double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue; +} + +uint64 encodeDouble_64(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the significand into the integer range + double shiftedsignificand = ldexp(abs(significand), 53); + + // Combine everything using the IEEE standard + uint64 uintsignificand = (uint64)shiftedsignificand; + return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign + ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023 + (uintsignificand & 0x000FFFFFFFFFFFFF); // significand with MSB inferred +} + +double decodeDouble_64(uint64 value) { + // Expand the exponent and significand + int exponent = (int)((value >> 52) & 0x7FF) - 1023; + double expandedsignificand = (double)(0x10000000000000 /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFF)); + + // Deflate the significand + int temp; + double significand = frexp(expandedsignificand, &temp); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value & 0x8000000000000000) == 0x8000000000000000) ? -returnValue : returnValue; +} + +CompactSerializedDouble encodeDouble_Compact(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the the first part of the significand into the integer range + double shiftedsignificandPart = ldexp(abs(significand), 32); + uint32 significandOne = uint32(floor(shiftedsignificandPart)); + + // Shift the remainder of the significand into the integer range + shiftedsignificandPart -= significandOne; + uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 21)); + + CompactSerializedDouble returnValue; + returnValue.signAndSignificandOne = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign + (significandOne & 0x7FFFFFFF); // significandOne with MSB inferred + // Exponent stored as an offset to 1023 + returnValue.exponentAndSignificandTwo = ((uint32)(exponent + 1023) << 21) | significandTwo; + + return returnValue; +} + +double decodeDouble_Compact(CompactSerializedDouble value) { + // Expand the exponent and the parts of the significand + int exponent = (int)(value.exponentAndSignificandTwo >> 21) - 1023; + double expandedsignificandOne = (double)(0x80000000 /* Inferred MSB */ | (value.signAndSignificandOne & 0x7FFFFFFF)); + double expandedsignificandTwo = (double)(value.exponentAndSignificandTwo & 0x1FFFFF); + + // Deflate the significand + double shiftedsignificand = ldexp(expandedsignificandTwo, -21); + double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue; +} + +} // End of namespace Sword25 diff --git a/engines/sword25/util/double_serializer.h b/engines/sword25/util/double_serializer.h new file mode 100644 index 0000000000..e90338c369 --- /dev/null +++ b/engines/sword25/util/double_serializer.h @@ -0,0 +1,95 @@ +/* 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 DOUBLE_SERIALIZATION_H +#define DOUBLE_SERIALIZATION_H + +#include "common/types.h" + + +namespace Util { + +struct SerializedDouble { + uint32 significandOne; + uint32 signAndSignificandTwo; + int16 exponent; +}; + +struct CompactSerializedDouble { + uint32 signAndSignificandOne; + uint32 exponentAndSignificandTwo; +}; + +/** + * Encodes a double as two uint32 and a one int16 + * + * Supports denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +SerializedDouble encodeDouble(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble(SerializedDouble value); + +/** + * Encodes a double as a uint64 + * + * Does NOT support denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +uint64 encodeDouble_64(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble_64(uint64 value); + +/** + * Encodes a double as two uint32 + * + * Does NOT support denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +CompactSerializedDouble encodeDouble_Compact(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble_Compact(CompactSerializedDouble value); + +} // End of namespace Sword25 + +#endif -- cgit v1.2.3 From efcd6196eeaa2bff468bbed8d07040e60ca3c136 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Wed, 17 Sep 2014 15:52:26 -0500 Subject: SWORD25: Create a function for serializing lua objects This function is very similar to the Pluto function. However, this code is much cleaner and is endian-safe --- engines/sword25/util/lua_serialization.h | 42 ++ engines/sword25/util/lua_serializer.cpp | 852 +++++++++++++++++++++++++++++++ 2 files changed, 894 insertions(+) create mode 100644 engines/sword25/util/lua_serialization.h create mode 100644 engines/sword25/util/lua_serializer.cpp diff --git a/engines/sword25/util/lua_serialization.h b/engines/sword25/util/lua_serialization.h new file mode 100644 index 0000000000..0f0c3bd0b2 --- /dev/null +++ b/engines/sword25/util/lua_serialization.h @@ -0,0 +1,42 @@ +/* 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 LUA_SERIALIZATION_H +#define LUA_SERIALIZATION_H + +#include "sword25/util/lua/lua.h" + + +namespace Common { +class WriteStream; +} + + +namespace Lua { + +#define PERMANENT_TYPE 101 + +void serializeLua(lua_State *luaState, Common::WriteStream *writeStream); + +} // End of namespace Lua + +#endif diff --git a/engines/sword25/util/lua_serializer.cpp b/engines/sword25/util/lua_serializer.cpp new file mode 100644 index 0000000000..b2bbca6be9 --- /dev/null +++ b/engines/sword25/util/lua_serializer.cpp @@ -0,0 +1,852 @@ +/* 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 "sword25/util/lua_serialization.h" + +#include "sword25/util/double_serializer.h" + +#include "common/stream.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" + + +namespace Lua { + +#define NUMTYPES 9 + +static const char* typenames[] = { + "nil", + "boolean", + "lightuserdata", + "number", + "string", + "table", + "function", + "userdata", + "thread" +}; + +#define PERMANENT_TYPE 101 + +/* A simple reimplementation of the unfortunately static function luaA_index. + * Does not support the global table, registry, or upvalues. */ +static StkId getobject(lua_State *luaState, int stackpos) { + if(stackpos > 0) { + lua_assert(luaState->base+stackpos-1 < luaState->top); + return luaState->base+stackpos-1; + } else { + lua_assert(L->top-stackpos >= L->base); + return luaState->top+stackpos; + } +} + + +struct SerializationInfo { + lua_State *luaState; + Common::WriteStream *writeStream; + uint counter; +}; + +static void serializeObject(SerializationInfo *info); + +static void serializeBoolean(SerializationInfo *info); +static void serializeLightUserData(SerializationInfo *info); +static void serializeNumber(SerializationInfo *info); +static void serializeString(SerializationInfo *info); +static void serializeTable(SerializationInfo *info); +static void serializeFunction(SerializationInfo *info); +static void serializeThread(SerializationInfo *info); +static void serializeProto(SerializationInfo *info); +static void serializeUpValue(SerializationInfo *info); +static void serializeUserData(SerializationInfo *info); + + +void serializeLua(lua_State *luaState, Common::WriteStream *writeStream) { + SerializationInfo info; + info.luaState = luaState; + info.writeStream = writeStream; + info.counter = 0u; + + // The process starts with the lua stack as follows: + // >>>>> permTbl rootObj + // That's the table of permanents and the root object to be serialized + + // Make sure there is enough room on the stack + lua_checkstack(luaState, 4); + assert(lua_gettop(luaState) == 2); + // And that the root isn't nil + assert(!lua_isnil(luaState, 2)); + + // Create a table to hold indexes of everything that's serialized + // This allows us to only serialize an object once + // Every other time, just reference the index + lua_newtable(luaState); + // >>>>> permTbl rootObj indexTbl + + // Now we're going to make the table weakly keyed. This prevents the + // GC from visiting it and trying to mark things it doesn't want to + // mark in tables, e.g. upvalues. All objects in the table are + // a priori reachable, so it doesn't matter that we do this. + + // Create the metatable + lua_newtable(luaState); + // >>>>> permTbl rootObj indexTbl metaTbl + + lua_pushstring(luaState, "__mode"); + // >>>>> permTbl rootObj indexTbl metaTbl "__mode" + + lua_pushstring(luaState, "k"); + // >>>>> permTbl rootObj indexTbl metaTbl "__mode" "k" + + lua_settable(luaState, 4); + // >>>>> permTbl rootObj indexTbl metaTbl + + lua_setmetatable(luaState, 3); + // >>>>> permTbl rootObj indexTbl + + // Swap the indexTable and the rootObj + lua_insert(luaState, 2); + // >>>>> permTbl indexTbl rootObj + + // Serialize the root recursively + serializeObject(&info); + + // Return the stack back to the original state + lua_remove(luaState, 2); + // >>>>> permTbl rootObj +} + +static void serializeObject(SerializationInfo *info) { + // The stack can potentially have many things on it + // The object we want to serialize is the item on the top of the stack + // >>>>> permTbl indexTbl rootObj ...... obj + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // If the object has already been written, don't write it again + // Instead write the index of the object from the indexTbl + + // Check the indexTbl + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + lua_rawget(info->luaState, 2); + // >>>>> permTbl indexTbl rootObj ...... obj ?index? + + // If the index isn't nil, the object has already been written + if (!lua_isnil(info->luaState, -1)) { + // Write out a flag that indicates that it's an index + info->writeStream->writeByte(0); + + // Retrieve the index from the stack + uint *index = (uint *)lua_touserdata(info->luaState, -1); + + // Write out the index + info->writeStream->writeUint32LE(*index); + + // Pop the index off the stack + lua_pop(info->luaState, 1); + + return; + } + + // Pop the nil off the stack + lua_pop(info->luaState, 1); + + // Write out a flag that indicates that this is a real object + info->writeStream->writeByte(1); + + // If the object itself is nil, then write out a zero as a placeholder + if (lua_isnil(info->luaState, -1)) { + info->writeStream->writeByte(0); + + return; + } + + // Add the object to the indexTbl + + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + uint *ref = (uint *)lua_newuserdata(info->luaState, sizeof(uint)); + *ref = ++(info->counter); + // >>>>> permTbl indexTbl rootObj ...... obj obj index + + lua_rawset(info->luaState, 2); + // >>>>> permTbl indexTbl rootObj ...... obj + + + // Write out the index + info->writeStream->writeUint32LE(info->counter); + + + // Objects that are in the permanents table are serialized in a special way + + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + lua_gettable(info->luaState, 1); + // >>>>> permTbl indexTbl rootObj ...... obj obj ?permKey? + + if (!lua_isnil(info->luaState, -1)) { + // Write out the type + info->writeStream->writeSint32LE(PERMANENT_TYPE); + + // Serialize the key + serializeObject(info); + + // Pop the key off the stack + lua_pop(info->luaState, 1); + + return; + } + + // Pop the nil off the stack + lua_pop(info->luaState, 1); + + // Query the type of the object + int objType = lua_type(info->luaState, -1); + + // Write it out + info->writeStream->writeSint32LE(objType); + + // Serialize the object by its type + + switch (objType) { + case LUA_TBOOLEAN: + serializeBoolean(info); + break; + case LUA_TLIGHTUSERDATA: + // You can't serialize a pointer + // It would be meaningless on the next run + assert(0); + break; + case LUA_TNUMBER: + serializeNumber(info); + break; + case LUA_TSTRING: + serializeString(info); + break; + case LUA_TTABLE: + serializeTable(info); + break; + case LUA_TFUNCTION: + serializeFunction(info); + break; + case LUA_TTHREAD: + serializeThread(info); + break; + case LUA_TPROTO: + serializeProto(info); + break; + case LUA_TUPVAL: + serializeUpValue(info); + break; + case LUA_TUSERDATA: + serializeUserData(info); + break; + default: + assert(0); + } +} + +static void serializeBoolean(SerializationInfo *info) { + int value = lua_toboolean(info->luaState, -1); + + info->writeStream->writeSint32LE(value); +} + +static void serializeNumber(SerializationInfo *info) { + lua_Number value = lua_tonumber(info->luaState, -1); + +#if 1 + Util::SerializedDouble serializedValue(Util::encodeDouble(value)); + + info->writeStream->writeUint32LE(serializedValue.significandOne); + info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); + info->writeStream->writeSint16LE(serializedValue.exponent); +#else + // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. + // Also, I don't know if we can assume all compilers use IEEE double + // Therefore, I have chosen to store the double as a string. + Common::String buffer = Common::String::format("%f", value); + + info->writeStream->write(buffer.c_str(), buffer.size()); +#endif + +} + +static void serializeString(SerializationInfo *info) { + // Hard cast to a uint32 to force size_t to an explicit size + // *Theoretically* this could truncate, but if we have a 4gb string, we have bigger problems + uint32 length = static_cast(lua_strlen(info->luaState, -1)); + info->writeStream->writeUint32LE(length); + + const char* str = lua_tostring(info->luaState, -1); + info->writeStream->write(str, length); +} + +/* Choose whether to do a regular or special persistence based on an object's + * metatable. "default" is whether the object, if it doesn't have a __persist + * entry, is literally persistable or not. + * Pushes the unpersist closure and returns true if special persistence is + * used. */ +static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 4); + + // Check whether we should persist literally, or via the __persist metafunction + if (!lua_getmetatable(info->luaState, -1)) { + if (defaction) { + // Write out a flag declaring that the metatable doesn't exist + info->writeStream->writeSint32LE(0); + + return false; + } else { + lua_pushstring(info->luaState, "Type not literally persistable by default"); + lua_error(info->luaState); + } + } + + // >>>>> permTbl indexTbl ...... obj metaTbl + lua_pushstring(info->luaState, "__persist"); + // >>>>> permTbl indexTbl rootObj ...... obj metaTbl "__persist" + + lua_rawget(info->luaState, -2); + // >>>>> permTbl indexTbl ...... obj metaTbl ?__persist? + + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... obj metaTbl nil + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + if (defaction) { + // Write out a flag declaring there is no persistence metafunction + info->writeStream->writeSint32LE(0); + + return 0; + } else { + lua_pushstring(info->luaState, "Type not literally persistable by default"); + lua_error(info->luaState); + + return 0; /* not reached */ + } + + } else if (lua_isboolean(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... obj metaTbl bool + if (lua_toboolean(info->luaState, -1)) { + // Write out a flag declaring such + info->writeStream->writeSint32LE(0); + + // >>>>> permTbl indexTbl ...... obj metaTbl true */ + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + return false; + } else { + lua_pushstring(info->luaState, "Metatable forbade persistence"); + lua_error(info->luaState); + + return false; /* not reached */ + } + } else if (!lua_isfunction(info->luaState, -1)) { + lua_pushstring(info->luaState, "__persist not nil, boolean, or function"); + lua_error(info->luaState); + } + + // >>>>> permTbl indexTbl ...... obj metaTbl __persist + lua_pushvalue(info->luaState, -3); + // >>>>> permTbl indexTbl ...... obj metaTbl __persist obj + + // >>>>> permTbl indexTbl ...... obj metaTbl ?func? + + if (!lua_isfunction(info->luaState, -1)) { + lua_pushstring(info->luaState, "__persist function did not return a function"); + lua_error(info->luaState); + } + + // >>>>> permTbl indexTbl ...... obj metaTbl func + + // Write out a flag that the function exists + info->writeStream->writeSint32LE(1); + + // Serialize the function + serializeObject(info); + + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + return true; +} + +static void serializeTable(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... tbl + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 3); + + // Test if the object needs special serialization + if (serializeSpecialObject(info, 1)) { + return; + } + + // >>>>> permTbl indexTbl ...... tbl + + // First, serialize the metatable (if any) + if (!lua_getmetatable(info->luaState, -1)) { + lua_pushnil(info->luaState); + } + + // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + + + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... tbl nil + + // Now, persist all k/v pairs + while (lua_next(info->luaState, -2)) { + // >>>>> permTbl indexTbl ...... tbl k v */ + + lua_pushvalue(info->luaState, -2); + // >>>>> permTbl indexTbl ...... tbl k v k */ + + // Serialize the key + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl k v */ + + // Serialize the value + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl k */ + } + + // >>>>> permTbl indexTbl ...... tbl + + // Terminate the list with a nil + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... tbl + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl +} + +static void pushObject(lua_State *luaState, TValue *obj) { + setobj2s(luaState, luaState->top, obj); + + api_check(luaState, luaState->top < luaState->ci->top); + luaState->top++; +} + +static void pushProto(lua_State *luaState, Proto *proto) { + TValue obj; + setptvalue(luaState, &obj, proto); + + pushObject(luaState, &obj); +} + +static void pushUpVal(lua_State *luaState, UpVal *upval) { + TValue obj; + + obj.value.gc = cast(GCObject *, upval); + obj.tt = LUA_TUPVAL; + checkliveness(G(L), obj); + + pushObject(luaState, &obj); +} + +static void pushString(lua_State *luaState, TString *str) { + TValue o; + setsvalue(luaState, &o, str); + + pushObject(luaState, &o); +} + +static void serializeFunction(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... func + Closure *cl = clvalue(getobject(info->luaState, -1)); + lua_checkstack(info->luaState, 2); + + if (cl->c.isC) { + /* It's a C function. For now, we aren't going to allow + * persistence of C closures, even if the "C proto" is + * already in the permanents table. */ + lua_pushstring(info->luaState, "Attempt to persist a C function"); + lua_error(info->luaState); + } else { + // It's a Lua closure + + // We don't really _NEED_ the number of upvals, but it'll simplify things a bit + info->writeStream->writeByte(cl->l.p->nups); + + // Serialize the prototype + pushProto(info->luaState, cl->l.p); + // >>>>> permTbl indexTbl ...... func proto */ + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + // Serialize upvalue values (not the upvalue objects themselves) + for (byte i=0; il.p->nups; i++) { + // >>>>> permTbl indexTbl ...... func + pushUpVal(info->luaState, cl->l.upvals[i]); + // >>>>> permTbl indexTbl ...... func upval + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // >>>>> permTbl indexTbl ...... func + + // Serialize function environment + lua_getfenv(info->luaState, -1); + // >>>>> permTbl indexTbl ...... func fenv + + if (lua_equal(info->luaState, -1, LUA_GLOBALSINDEX)) { + // Function has the default fenv + + // >>>>> permTbl indexTbl ...... func _G + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... func nil + } + + // >>>>> permTbl indexTbl ...... func fenv/nil + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } +} + +/* Appends one stack to another stack, but the stack is reversed in the process */ +static size_t appendStackToStack_rev(lua_State *from, lua_State *to) { + for (StkId id = from->top - 1; id >= from->stack; --id) { + setobj2s(to, to->top, id); + to->top++; + } + + return from->top - from->stack; +} + +static void serializeThread(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... thread + lua_State *threadState = lua_tothread(info->luaState, -1); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, threadState->top - threadState->stack + 1); + + if (info->luaState == threadState) { + lua_pushstring(info->luaState, "Can't persist currently running thread"); + lua_error(info->luaState); + return; /* not reached */ + } + + // Persist the stack + + // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems + uint stackSize = static_cast(appendStackToStack_rev(threadState, info->luaState)); + info->writeStream->writeUint32LE(stackSize); + + // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ + for (; stackSize > 0; --stackSize) { + serializeObject(info); + + lua_pop(info->luaState, 1); + } + + // >>>>> permTbl indexTbl ...... thread + + // Now, serialize the CallInfo stack + + // Again, we *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems + uint32 numFrames = static_cast((threadState->ci - threadState->base_ci) + 1); + info->writeStream->writeUint32LE(numFrames); + + for (uint32 i = 0; i < numFrames; i++) { + CallInfo *ci = threadState->base_ci + i; + + // Same argument as above about truncation + uint32 stackBase = static_cast(ci->base - threadState->stack); + uint32 stackFunc = static_cast(ci->func - threadState->stack); + uint32 stackTop = static_cast(ci->top - threadState->stack); + + info->writeStream->writeUint32LE(stackBase); + info->writeStream->writeUint32LE(stackFunc); + info->writeStream->writeUint32LE(stackTop); + + info->writeStream->writeSint32LE(ci->nresults); + + uint32 savedpc = (ci != threadState->base_ci) ? static_cast(ci->savedpc - ci_func(ci)->l.p->code) : 0u; + info->writeStream->writeUint32LE(savedpc); + } + + + // Serialize the state's other parameters, with the exception of upval stuff + + assert(threadState->nCcalls <= 1); + info->writeStream->writeByte(threadState->status); + + // Same argument as above about truncation + uint32 stackBase = static_cast(threadState->base - threadState->stack); + uint32 stackFunc = static_cast(threadState->top - threadState->stack); + info->writeStream->writeUint32LE(stackBase); + info->writeStream->writeUint32LE(stackFunc); + + // Same argument as above about truncation + uint32 stackOffset = static_cast(threadState->errfunc); + info->writeStream->writeUint32LE(stackOffset); + + // Finally, record upvalues which need to be reopened + // See the comment above serializeUpVal() for why we do this + + UpVal *upVal; + + // >>>>> permTbl indexTbl ...... thread + for (GCObject *gcObject = threadState->openupval; gcObject != NULL; gcObject = upVal->next) { + upVal = gco2uv(gcObject); + + /* Make sure upvalue is really open */ + assert(upVal->v != &upVal->u.value); + + pushUpVal(info->luaState, upVal); + // >>>>> permTbl indexTbl ...... thread upVal + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + + // Same argument as above about truncation + uint32 stackpos = static_cast(upVal->v - threadState->stack); + info->writeStream->writeUint32LE(stackpos); + } + + // >>>>> permTbl indexTbl ...... thread + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... thread nil + + // Use nil as a terminator + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread +} + +static void serializeProto(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... proto + Proto *proto = gco2p(getobject(info->luaState, -1)->value.gc); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // Serialize constant refs */ + info->writeStream->writeSint32LE(proto->sizek); + + for (int i = 0; i < proto->sizek; ++i) { + pushObject(info->luaState, &proto->k[i]); + // >>>>> permTbl indexTbl ...... proto const + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + // >>>>> permTbl indexTbl ...... proto + + // Serialize inner Proto refs + info->writeStream->writeSint32LE(proto->sizep); + + for (int i = 0; i < proto->sizep; ++i) + { + pushProto(info->luaState, proto->p[i]); + // >>>>> permTbl indexTbl ...... proto subProto */ + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + // >>>>> permTbl indexTbl ...... proto + + // Serialize the code + info->writeStream->writeSint32LE(proto->sizecode); + + uint32 len = static_cast(sizeof(Instruction) * proto->sizecode); + info->writeStream->write(proto->code, len); + + + // Serialize upvalue names + info->writeStream->writeSint32LE(proto->sizeupvalues); + + for (int i = 0; i < proto->sizeupvalues; ++i) + { + pushString(info->luaState, proto->upvalues[i]); + // >>>>> permTbl indexTbl ...... proto str + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + + // Serialize local variable infos + info->writeStream->writeSint32LE(proto->sizelocvars); + + for (int i = 0; i < proto->sizelocvars; ++i) { + pushString(info->luaState, proto->locvars[i].varname); + // >>>>> permTbl indexTbl ...... proto str + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + info->writeStream->writeSint32LE(proto->locvars[i].startpc); + info->writeStream->writeSint32LE(proto->locvars[i].endpc); + } + + + // Serialize source string + pushString(info->luaState, proto->source); + // >>>>> permTbl indexTbl ...... proto sourceStr + + serializeObject(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + // Serialize line numbers + info->writeStream->writeSint32LE(proto->sizelineinfo); + + if (proto->sizelineinfo) { + uint32 len = static_cast(sizeof(int) * proto->sizelineinfo); + info->writeStream->write(proto->lineinfo, len); + } + + // Serialize linedefined and lastlinedefined + info->writeStream->writeSint32LE(proto->linedefined); + info->writeStream->writeSint32LE(proto->lastlinedefined); + + + // Serialize misc values + info->writeStream->writeByte(proto->nups); + info->writeStream->writeByte(proto->numparams); + info->writeStream->writeByte(proto->is_vararg); + info->writeStream->writeByte(proto->maxstacksize); +} + +/* Upvalues are tricky. Here's why. + * + * A particular upvalue may be either "open", in which case its member v + * points into a thread's stack, or "closed" in which case it points to the + * upvalue itself. An upvalue is closed under any of the following conditions: + * -- The function that initially declared the variable "local" returns + * -- The thread in which the closure was created is garbage collected + * + * To make things wackier, just because a thread is reachable by Lua doesn't + * mean it's in our root set. We need to be able to treat an open upvalue + * from an unreachable thread as a closed upvalue. + * + * The solution: + * (a) For the purposes of serializing, don't indicate whether an upvalue is + * closed or not. + * (b) When unserializing, pretend that all upvalues are closed. + * (c) When serializing, persist all open upvalues referenced by a thread + * that is persisted, and tag each one with the corresponding stack position + * (d) When unserializing, "reopen" each of these upvalues as the thread is + * unserialized + */ +static void serializeUpValue(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... upval + assert(ttype(getobject(info->luaState, -1)) == LUA_TUPVAL); + UpVal *upValue = gco2uv(getobject(info->luaState, -1)->value.gc); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + // We can't permit the upValue to linger around on the stack, as Lua + // will bail if its GC finds it. + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... + + pushObject(info->luaState, upValue->v); + // >>>>> permTbl indexTbl ...... obj + + serializeObject(info); + // >>>>> permTbl indexTbl ...... obj +} + +static void serializeUserData(SerializationInfo *info) { + // >>>>> permTbl rootObj ...... udata + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // Test if the object needs special serialization + if (serializeSpecialObject(info, 0)) { + return; + } + + // Use literal persistence + + // Hard cast to a uint32 length + // This could lead to truncation, but if we have a 4gb block of data, we have bigger problems + uint32 length = static_cast(uvalue(getobject(info->luaState, -1))->len); + info->writeStream->writeUint32LE(length); + + info->writeStream->write(lua_touserdata(info->luaState, -1), length); + + // Serialize the metatable (if any) + if (!lua_getmetatable(info->luaState, -1)) { + lua_pushnil(info->luaState); + } + + // >>>>> permTbl rootObj ...... udata metaTbl/nil + serializeObject(info); + + lua_pop(info->luaState, 1); + /* perms reftbl ... udata */ +} + + +} // End of namespace Lua -- cgit v1.2.3 From a4685796ce2e876ec4025a1a084f8c3f4500af4e Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 11:49:42 -0600 Subject: TEST: Add unit tests for uint64 reading --- test/common/endian.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/common/endian.h b/test/common/endian.h index cba7618c43..f083d1248c 100644 --- a/test/common/endian.h +++ b/test/common/endian.h @@ -10,6 +10,18 @@ class EndianTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(MKTAG('A','B','C','D'), tag); } + void test_READ_BE_UINT64() { + const char data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; + uint64 value = READ_BE_UINT64(data); + TS_ASSERT_EQUALS(value, 0x123456789ABCDEFFULL); + } + + void test_READ_LE_UINT64() { + const char data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; + uint64 value = READ_LE_UINT64(data); + TS_ASSERT_EQUALS(value, 0xFFEDCBA978563412ULL); + } + void test_READ_BE_UINT32() { const char data[4] = { 0x12, 0x34, 0x56, 0x78 }; uint32 value = READ_BE_UINT32(data); -- cgit v1.2.3 From dedfd7aa84360b5950b653109b3679c7f469aebc Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 13:38:26 -0600 Subject: SWORD25: Move common functions to their own set of files so they can be shared --- engines/sword25/util/lua_serialization_util.cpp | 77 +++++++++++++++++++++ engines/sword25/util/lua_serialization_util.h | 43 ++++++++++++ engines/sword25/util/lua_serializer.cpp | 91 +++++-------------------- 3 files changed, 138 insertions(+), 73 deletions(-) create mode 100644 engines/sword25/util/lua_serialization_util.cpp create mode 100644 engines/sword25/util/lua_serialization_util.h diff --git a/engines/sword25/util/lua_serialization_util.cpp b/engines/sword25/util/lua_serialization_util.cpp new file mode 100644 index 0000000000..80009aff60 --- /dev/null +++ b/engines/sword25/util/lua_serialization_util.cpp @@ -0,0 +1,77 @@ +/* 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 distri8buted 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 "sword25/util/lua_serialization_util.h" + +#include "common/scummsys.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" +#include "lua/lgc.h" + + +namespace Lua { + +void pushObject(lua_State *luaState, TValue *obj) { + setobj2s(luaState, luaState->top, obj); + + api_check(luaState, luaState->top < luaState->ci->top); + luaState->top++; +} + +void pushProto(lua_State *luaState, Proto *proto) { + TValue obj; + setptvalue(luaState, &obj, proto); + + pushObject(luaState, &obj); +} + +void pushUpValue(lua_State *luaState, UpVal *upval) { + TValue obj; + + obj.value.gc = cast(GCObject *, upval); + obj.tt = LUA_TUPVAL; + checkliveness(G(L), obj); + + pushObject(luaState, &obj); +} + +void pushString(lua_State *luaState, TString *str) { + TValue o; + setsvalue(luaState, &o, str); + + pushObject(luaState, &o); +} + +/* A simple reimplementation of the unfortunately static function luaA_index. + * Does not support the global table, registry, or upvalues. */ +StkId getObject(lua_State *luaState, int stackpos) { + if(stackpos > 0) { + lua_assert(luaState->base+stackpos-1 < luaState->top); + return luaState->base+stackpos-1; + } else { + lua_assert(L->top-stackpos >= L->base); + return luaState->top+stackpos; + } +} + +} // End of namespace Lua diff --git a/engines/sword25/util/lua_serialization_util.h b/engines/sword25/util/lua_serialization_util.h new file mode 100644 index 0000000000..6c55d0dd53 --- /dev/null +++ b/engines/sword25/util/lua_serialization_util.h @@ -0,0 +1,43 @@ +/* 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 distri8buted 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 LUA_SERIALIZATION_UTIL_H +#define LUA_SERIALIZATION_UTIL_H + + +struct lua_State; + +#include "lua/lobject.h" + +typedef TValue *StkId; + +namespace Lua { + +void pushObject(lua_State *luaState, TValue *obj); +void pushProto(lua_State *luaState, Proto *proto); +void pushUpValue(lua_State *luaState, UpVal *upval); +void pushString(lua_State *luaState, TString *str); +StkId getObject(lua_State *luaState, int stackpos); + +} // End of namespace Lua + +#endif diff --git a/engines/sword25/util/lua_serializer.cpp b/engines/sword25/util/lua_serializer.cpp index b2bbca6be9..8c61383fba 100644 --- a/engines/sword25/util/lua_serializer.cpp +++ b/engines/sword25/util/lua_serializer.cpp @@ -23,44 +23,19 @@ #include "sword25/util/lua_serialization.h" #include "sword25/util/double_serializer.h" +#include "sword25/util/lua_serialization_util.h" #include "common/stream.h" #include "lua/lobject.h" #include "lua/lstate.h" +#include "lua/lgc.h" namespace Lua { -#define NUMTYPES 9 - -static const char* typenames[] = { - "nil", - "boolean", - "lightuserdata", - "number", - "string", - "table", - "function", - "userdata", - "thread" -}; - #define PERMANENT_TYPE 101 -/* A simple reimplementation of the unfortunately static function luaA_index. - * Does not support the global table, registry, or upvalues. */ -static StkId getobject(lua_State *luaState, int stackpos) { - if(stackpos > 0) { - lua_assert(luaState->base+stackpos-1 < luaState->top); - return luaState->base+stackpos-1; - } else { - lua_assert(L->top-stackpos >= L->base); - return luaState->top+stackpos; - } -} - - struct SerializationInfo { lua_State *luaState; Common::WriteStream *writeStream; @@ -70,7 +45,6 @@ struct SerializationInfo { static void serializeObject(SerializationInfo *info); static void serializeBoolean(SerializationInfo *info); -static void serializeLightUserData(SerializationInfo *info); static void serializeNumber(SerializationInfo *info); static void serializeString(SerializationInfo *info); static void serializeTable(SerializationInfo *info); @@ -319,13 +293,15 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { // Check whether we should persist literally, or via the __persist metafunction if (!lua_getmetatable(info->luaState, -1)) { if (defaction) { - // Write out a flag declaring that the metatable doesn't exist + // Write out a flag declaring that the object isn't special and should be persisted normally info->writeStream->writeSint32LE(0); return false; } else { lua_pushstring(info->luaState, "Type not literally persistable by default"); lua_error(info->luaState); + + return false; // Not reached } } @@ -342,21 +318,21 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { // >>>>> permTbl indexTbl ...... obj if (defaction) { - // Write out a flag declaring there is no persistence metafunction + // Write out a flag declaring that the object isn't special and should be persisted normally info->writeStream->writeSint32LE(0); - return 0; + return false; } else { lua_pushstring(info->luaState, "Type not literally persistable by default"); lua_error(info->luaState); - return 0; /* not reached */ + return false; // Return false } } else if (lua_isboolean(info->luaState, -1)) { // >>>>> permTbl indexTbl ...... obj metaTbl bool if (lua_toboolean(info->luaState, -1)) { - // Write out a flag declaring such + // Write out a flag declaring that the object isn't special and should be persisted normally info->writeStream->writeSint32LE(0); // >>>>> permTbl indexTbl ...... obj metaTbl true */ @@ -368,7 +344,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { lua_pushstring(info->luaState, "Metatable forbade persistence"); lua_error(info->luaState); - return false; /* not reached */ + return false; // Not reached } } else if (!lua_isfunction(info->luaState, -1)) { lua_pushstring(info->luaState, "__persist not nil, boolean, or function"); @@ -460,40 +436,9 @@ static void serializeTable(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... tbl } -static void pushObject(lua_State *luaState, TValue *obj) { - setobj2s(luaState, luaState->top, obj); - - api_check(luaState, luaState->top < luaState->ci->top); - luaState->top++; -} - -static void pushProto(lua_State *luaState, Proto *proto) { - TValue obj; - setptvalue(luaState, &obj, proto); - - pushObject(luaState, &obj); -} - -static void pushUpVal(lua_State *luaState, UpVal *upval) { - TValue obj; - - obj.value.gc = cast(GCObject *, upval); - obj.tt = LUA_TUPVAL; - checkliveness(G(L), obj); - - pushObject(luaState, &obj); -} - -static void pushString(lua_State *luaState, TString *str) { - TValue o; - setsvalue(luaState, &o, str); - - pushObject(luaState, &o); -} - static void serializeFunction(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... func - Closure *cl = clvalue(getobject(info->luaState, -1)); + Closure *cl = clvalue(getObject(info->luaState, -1)); lua_checkstack(info->luaState, 2); if (cl->c.isC) { @@ -520,7 +465,7 @@ static void serializeFunction(SerializationInfo *info) { // Serialize upvalue values (not the upvalue objects themselves) for (byte i=0; il.p->nups; i++) { // >>>>> permTbl indexTbl ...... func - pushUpVal(info->luaState, cl->l.upvals[i]); + pushUpValue(info->luaState, cl->l.upvals[i]); // >>>>> permTbl indexTbl ...... func upval serializeObject(info); @@ -580,7 +525,7 @@ static void serializeThread(SerializationInfo *info) { // Persist the stack // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems - uint stackSize = static_cast(appendStackToStack_rev(threadState, info->luaState)); + uint32 stackSize = static_cast(appendStackToStack_rev(threadState, info->luaState)); info->writeStream->writeUint32LE(stackSize); // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ @@ -644,7 +589,7 @@ static void serializeThread(SerializationInfo *info) { /* Make sure upvalue is really open */ assert(upVal->v != &upVal->u.value); - pushUpVal(info->luaState, upVal); + pushUpValue(info->luaState, upVal); // >>>>> permTbl indexTbl ...... thread upVal serializeObject(info); @@ -670,7 +615,7 @@ static void serializeThread(SerializationInfo *info) { static void serializeProto(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... proto - Proto *proto = gco2p(getobject(info->luaState, -1)->value.gc); + Proto *proto = gco2p(getObject(info->luaState, -1)->value.gc); // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); @@ -797,8 +742,8 @@ static void serializeProto(SerializationInfo *info) { */ static void serializeUpValue(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... upval - assert(ttype(getobject(info->luaState, -1)) == LUA_TUPVAL); - UpVal *upValue = gco2uv(getobject(info->luaState, -1)->value.gc); + assert(ttype(getObject(info->luaState, -1)) == LUA_TUPVAL); + UpVal *upValue = gco2uv(getObject(info->luaState, -1)->value.gc); // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); @@ -831,7 +776,7 @@ static void serializeUserData(SerializationInfo *info) { // Hard cast to a uint32 length // This could lead to truncation, but if we have a 4gb block of data, we have bigger problems - uint32 length = static_cast(uvalue(getobject(info->luaState, -1))->len); + uint32 length = static_cast(uvalue(getObject(info->luaState, -1))->len); info->writeStream->writeUint32LE(length); info->writeStream->write(lua_touserdata(info->luaState, -1), length); -- cgit v1.2.3 From de20880d9d3dbe9ebbc26848d7a672c104495aeb Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 13:41:58 -0600 Subject: SWORD25: Re-write the pluto unserializing function(s) --- engines/sword25/util/lua_serialization.h | 2 + engines/sword25/util/lua_unserializer.cpp | 1007 +++++++++++++++++++++++++++++ 2 files changed, 1009 insertions(+) create mode 100644 engines/sword25/util/lua_unserializer.cpp diff --git a/engines/sword25/util/lua_serialization.h b/engines/sword25/util/lua_serialization.h index 0f0c3bd0b2..549ea7968d 100644 --- a/engines/sword25/util/lua_serialization.h +++ b/engines/sword25/util/lua_serialization.h @@ -28,6 +28,7 @@ namespace Common { class WriteStream; +class ReadStream; } @@ -36,6 +37,7 @@ namespace Lua { #define PERMANENT_TYPE 101 void serializeLua(lua_State *luaState, Common::WriteStream *writeStream); +void unserializeLua(lua_State *luaState, Common::ReadStream *readStream); } // End of namespace Lua diff --git a/engines/sword25/util/lua_unserializer.cpp b/engines/sword25/util/lua_unserializer.cpp new file mode 100644 index 0000000000..c561a3d99f --- /dev/null +++ b/engines/sword25/util/lua_unserializer.cpp @@ -0,0 +1,1007 @@ +/* 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 "sword25/util/lua_serialization.h" + +#include "sword25/util/double_serializer.h" +#include "sword25/util/lua_serialization_util.h" + +#include "common/stream.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" +#include "lua/lgc.h" +#include "lua/lopcodes.h" + + +namespace Lua { + +struct UnSerializationInfo { + lua_State *luaState; + Common::ReadStream *readStream; +}; + +static void unserializeObject(UnSerializationInfo *info); + +static void unserializeBoolean(UnSerializationInfo *info); +static void unserializeNumber(UnSerializationInfo *info); +static void unserializeString(UnSerializationInfo *info); +static void unserializeTable(UnSerializationInfo *info, int index); +static void unserializeFunction(UnSerializationInfo *info, int index); +static void unserializeThread(UnSerializationInfo *info, int index); +static void unserializeProto(UnSerializationInfo *info, int index); +static void unserializeUpValue(UnSerializationInfo *info, int index); +static void unserializeUserData(UnSerializationInfo *info, int index); +static void unserializePermanent(UnSerializationInfo *info, int index); + + +void unserializeLua(lua_State *luaState, Common::ReadStream *readStream) { + UnSerializationInfo info; + info.luaState = luaState; + info.readStream = readStream; + + // The process starts with the lua stack as follows: + // >>>>> permTbl + // That's the table of permanents + + // Make sure there is enough room on the stack + lua_checkstack(luaState, 3); + + // Create a table to hold indexes of everything thats already been read + lua_newtable(luaState); + // >>>>> permTbl indexTbl + + // Prevent garbage collection while we unserialize + lua_gc(luaState, LUA_GCSTOP, 0); + + // Unserialize the root object + unserializeObject(&info); + // >>>>> permTbl indexTbl rootObj + + // Re-start garbage collection + lua_gc(luaState, LUA_GCRESTART, 0); + + // Remove the indexTbl + lua_replace(luaState, 2); + // >>>>> permTbl rootObj +} + +/* The object is left on the stack. This is primarily used by unpersist, but + * may be used by GCed objects that may incur cycles in order to preregister + * the object. */ +static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... obj + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + lua_pushlightuserdata(info->luaState, (void *)index); + // >>>>> permTbl indexTbl ...... obj index + + lua_pushvalue(info->luaState, -2); + // >>>>> permTbl indexTbl ...... obj index obj + + // Push the k/v pair into the indexTbl + lua_settable(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj +} + +static void unserializeObject(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + byte isARealValue = info->readStream->readByte(); + if(isARealValue) { + int index = info->readStream->readSint32LE(); + int type = info->readStream->readSint32LE(); + + switch(type) { + case LUA_TBOOLEAN: + unserializeBoolean(info); + break; + case LUA_TLIGHTUSERDATA: + // You can't serialize a pointer + // It would be meaningless on the next run + assert(0); + break; + case LUA_TNUMBER: + unserializeNumber(info); + break; + case LUA_TSTRING: + unserializeString(info); + break; + case LUA_TTABLE: + unserializeTable(info, index); + break; + case LUA_TFUNCTION: + unserializeFunction(info, index); + break; + case LUA_TTHREAD: + unserializeThread(info, index); + break; + case LUA_TPROTO: + unserializeProto(info, index); + break; + case LUA_TUPVAL: + unserializeUpValue(info, index); + break; + case LUA_TUSERDATA: + unserializeUserData(info, index); + break; + case PERMANENT_TYPE: + unserializePermanent(info, index); + break; + default: + assert(0); + } + + + // >>>>> permTbl indexTbl ...... obj + assert(lua_type(info->luaState, -1) == type || + type == PERMANENT_TYPE || + // Remember, upvalues get a special dispensation, as described in boxUpValue + (lua_type(info->luaState, -1) == LUA_TFUNCTION && type == LUA_TUPVAL)); + + registerObjectInIndexTable(info, index); + // >>>>> permTbl indexTbl ...... obj + } else { + int index = info->readStream->readSint32LE(); + + if(index == 0) { + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... nil + } else { + // Fetch the object from the indexTbl + + lua_pushlightuserdata(info->luaState, (void *)index); + // >>>>> permTbl indexTbl ...... index + + lua_gettable(info->luaState, 2); + // >>>>> permTbl indexTbl ...... ?obj? + + assert(!lua_isnil(info->luaState, -1)); + } + // >>>>> permTbl indexTbl ...... obj/nil + } + + // >>>>> permTbl indexTbl ...... obj/nil +} + +static void unserializeBoolean(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + int value = info->readStream->readSint32LE(); + + lua_pushboolean(info->luaState, value); + // >>>>> permTbl indexTbl ...... bool +} + +static void unserializeNumber(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + // Read the serialized double + Util::SerializedDouble serializedValue; + serializedValue.significandOne = info->readStream->readUint32LE(); + serializedValue.signAndSignificandTwo = info->readStream->readUint32LE(); + serializedValue.exponent = info->readStream->readSint16LE(); + + lua_Number value = Util::decodeDouble(serializedValue); + + lua_pushnumber(info->luaState, value); + // >>>>> permTbl indexTbl ...... num +} + +static void unserializeString(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + uint32 length = info->readStream->readUint32LE(); + char *string = new char[length]; + + info->readStream->read(string, length); + lua_pushlstring(info->luaState, string, length); + + // >>>>> permTbl indexTbl ...... string + + delete[] string; +} + +static void unserializeSpecialTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + unserializeObject(info); + + // >>>>> permTbl indexTbl ...... spfunc + lua_call(info->luaState, 0, 1); + // >>>>> permTbl indexTbl ...... tbl +} + +static void unserializeLiteralTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 3); + + // Preregister table for handling of cycles + lua_newtable(info->luaState); + + // >>>>> permTbl indexTbl ...... tbl + registerObjectInIndexTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + + // Unserialize metatable + unserializeObject(info); + // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? + + if (lua_istable(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... tbl metaTbl + lua_setmetatable(info->luaState, -2); + // >>>>> permTbl indexTbl ...... tbl + } else { + // >>>>> permTbl indexTbl ...... tbl nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + } + // >>>>> permTbl indexTbl ...... tbl + + + while (1) { + // >>>>> permTbl indexTbl ...... tbl + unserializeObject(info); + // >>>>> permTbl indexTbl ...... tbl key/nil + + // The table serialization is nil terminated + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... tbl nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + + break; + } + + // >>>>> permTbl indexTbl ...... tbl key + unserializeObject(info); + // >>>>> permTbl indexTbl ...... tbl value + + lua_rawset(info->luaState, -3); + // >>>>> permTbl indexTbl ...... tbl + } +} + +void unserializeTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + int isSpecial = info->readStream->readSint32LE(); + + if (isSpecial) { + unserializeSpecialTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + } else { + unserializeLiteralTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + } +} + + + +void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) { + global_State *globalState = G(luaState); + + block = (*globalState->frealloc)(globalState->ud, block, osize, nsize); + globalState->totalbytes = (globalState->totalbytes - osize) + nsize; + + return block; +} + +#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize) +#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e)) +#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T)))) +#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T))) +#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T)) + +void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { + global_State *globalState = G(luaState); + + obj->gch.next = globalState->rootgc; + globalState->rootgc = obj; + obj->gch.marked = luaC_white(globalState); + obj->gch.tt = type; +} + +#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) + +Closure *newLClosure(lua_State *luaState, byte numUpValues, Table *env) { + Closure *newClosure = (Closure *)lua_malloc(luaState, sizeLclosure(numUpValues)); + + lua_linkObjToGC(luaState, obj2gco(newClosure), LUA_TFUNCTION); + + newClosure->l.isC = 0; + newClosure->l.env = env; + newClosure->l.nupvalues = numUpValues; + + while (numUpValues--) { + newClosure->l.upvals[numUpValues] = NULL; + } + + return newClosure; +} + +static void pushClosure(lua_State *luaState, Closure *closure) { + TValue obj; + setclvalue(luaState, &obj, closure); + pushObject(luaState, &obj); +} + +Proto *createProto(lua_State *luaState) { + Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO); + + newProto->k = NULL; + newProto->sizek = 0; + newProto->p = NULL; + newProto->sizep = 0; + newProto->code = NULL; + newProto->sizecode = 0; + newProto->sizelineinfo = 0; + newProto->sizeupvalues = 0; + newProto->nups = 0; + newProto->upvalues = NULL; + newProto->numparams = 0; + newProto->is_vararg = 0; + newProto->maxstacksize = 0; + newProto->lineinfo = NULL; + newProto->sizelocvars = 0; + newProto->locvars = NULL; + newProto->linedefined = 0; + newProto->lastlinedefined = 0; + newProto->source = NULL; + + return newProto; +} + +TString *createString(lua_State *luaState, const char *str, size_t len) { + TString *res; + lua_pushlstring(luaState, str, len); + + res = rawtsvalue(luaState->top - 1); + lua_pop(luaState, 1); + + return res; +} + +static Proto *makeFakeProto(lua_State *L, lu_byte nups) { + Proto *p = createProto(L); + + p->sizelineinfo = 1; + p->lineinfo = lua_newVector(L, 1, int); + p->lineinfo[0] = 1; + p->sizecode = 1; + p->code = lua_newVector(L, 1, Instruction); + p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); + p->source = createString(L, "", 0); + p->maxstacksize = 2; + p->nups = nups; + p->sizek = 0; + p->sizep = 0; + + return p; +} + +static UpVal *createUpValue(lua_State *luaState, int stackpos) { + UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal)); + lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL); + upValue->tt = LUA_TUPVAL; + upValue->v = &upValue->u.value; + upValue->u.l.prev = NULL; + upValue->u.l.next = NULL; + + const TValue *o2 = (TValue *)getObject(luaState, stackpos); + upValue->v->value = o2->value; upValue->v->tt = o2->tt; + checkliveness(G(L), upValue->v); + + return upValue; +} + +static void unboxUpValue(lua_State *luaState) { + // >>>>> ...... func + LClosure *lcl; + UpVal *uv; + + lcl = (LClosure *)clvalue(getObject(luaState, -1)); + uv = lcl->upvals[0]; + + lua_pop(luaState, 1); + // >>>>> ...... + + pushUpValue(luaState, uv); + // >>>>> ...... upValue +} + +void unserializeFunction(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + byte numUpValues = info->readStream->readByte(); + + LClosure *lclosure = (LClosure *)newLClosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt)); + pushClosure(info->luaState, (Closure *)lclosure); + // >>>>> permTbl indexTbl ...... func + + // Put *some* proto in the closure, before the GC can find it + lclosure->p = makeFakeProto(info->luaState, numUpValues); + + //Also, we need to temporarily fill the upvalues + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... func nil + + for(byte i = 0; i < numUpValues; ++i) { + lclosure->upvals[i] = createUpValue(info->luaState, -1); + } + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + // I can't see offhand how a function would ever get to be self- + // referential, but just in case let's register it early + registerObjectInIndexTable(info, index); + + // Now that it's safe, we can get the real proto + unserializeObject(info); + // >>>>> permTbl indexTbl ...... func proto + + lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + for(byte i = 0; i < numUpValues; ++i) { + // >>>>> permTbl indexTbl ...... func + unserializeObject(info); + // >>>>> permTbl indexTbl ...... func func2 + + unboxUpValue(info->luaState); + // >>>>> permTbl indexTbl ...... func upValue + lclosure->upvals[i] = gco2uv(getObject(info->luaState, -1)->value.gc); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // Finally, the fenv + unserializeObject(info); + + // >>>>> permTbl indexTbl ...... func ?fenv/nil? + if(!lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... func fenv + lua_setfenv(info->luaState, -2); + // >>>>> permTbl indexTbl ...... func + } else { + // >>>>> permTbl indexTbl ...... func nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // >>>>> permTbl indexTbl ...... func +} + +static void correctStack(lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + +void lua_reallocstack(lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + + lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack + newsize; + correctStack(L, oldstack); +} + +void lua_growstack(lua_State *L, int n) { + // Double size is enough? + if (n <= L->stacksize) { + lua_reallocstack(L, 2 * L->stacksize); + } else { + lua_reallocstack(L, L->stacksize + n); + } +} + +void lua_reallocCallInfo(lua_State *lauState, int newsize) { + CallInfo *oldci = lauState->base_ci; + lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo); + + lauState->size_ci = newsize; + lauState->ci = (lauState->ci - oldci) + lauState->base_ci; + lauState->end_ci = lauState->base_ci + lauState->size_ci - 1; +} + +void unboxUpVal(lua_State *luaState) { + // >>>>> ... func + LClosure *lcl; + UpVal *uv; + + lcl = (LClosure *)(&getObject(luaState, -1)->value.gc->cl); + uv = lcl->upvals[0]; + lua_pop(luaState, 1); + // >>>>> ... + pushUpValue(luaState, uv); + // >>>>> ... upVal +} + +/* Does basically the opposite of luaC_link(). + * Right now this function is rather inefficient; it requires traversing the + * entire root GC set in order to find one object. If the GC list were doubly + * linked this would be much easier, but there's no reason for Lua to have + * that. */ +static void GCUnlink(lua_State *luaState, GCObject *gco) { + GCObject *prevslot; + if(G(luaState)->rootgc == gco) { + G(luaState)->rootgc = G(luaState)->rootgc->gch.next; + return; + } + + prevslot = G(luaState)->rootgc; + while(prevslot->gch.next != gco) { + prevslot = prevslot->gch.next; + } + + prevslot->gch.next = prevslot->gch.next->gch.next; +} + +void unserializeThread(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + lua_State *L2; + uint32 stacklimit = 0; + + L2 = lua_newthread(info->luaState); + lua_checkstack(info->luaState, 3); + + // L1: permTbl indexTbl ...... thread + // L2: (empty) + registerObjectInIndexTable(info, index); + + // First, deserialize the object stack + uint32 stackSize = info->readStream->readUint32LE(); + lua_growstack(info->luaState, (int)stackSize); + + // Make sure that the first stack element (a nil, representing + // the imaginary top-level C function) is written to the very, + // very bottom of the stack + L2->top--; + for(uint32 i = 0; i < stackSize; ++i) { + unserializeObject(info); + // L1: permTbl indexTbl ...... thread obj* + } + + lua_xmove(info->luaState, L2, stackSize); + // L1: permTbl indexTbl ...... thread + // L2: obj* + + // Hereafter, stacks refer to L1 + + + // Now, deserialize the CallInfo stack + + uint32 numFrames = info->readStream->readUint32LE(); + + lua_reallocCallInfo(L2, numFrames*2); + for(uint32 i = 0; i < numFrames; ++i) { + CallInfo *ci = L2->base_ci + i; + uint32 stackbase = info->readStream->readUint32LE(); + uint32 stackfunc = info->readStream->readUint32LE(); + uint32 stacktop = info->readStream->readUint32LE(); + + ci->nresults = info->readStream->readSint32LE(); + + uint32 savedpc = info->readStream->readUint32LE(); + + if (stacklimit < stacktop) { + stacklimit = stacktop; + } + + ci->base = L2->stack + stackbase; + ci->func = L2->stack + stackfunc; + ci->top = L2->stack + stacktop; + ci->savedpc = (ci != L2->base_ci) ? ci_func(ci)->l.p->code + savedpc : 0; + ci->tailcalls = 0; + + // Update the pointer each time, to keep the GC happy + L2->ci = ci; + } + + // >>>>> permTbl indexTbl ...... thread + // Deserialize the state's other parameters, with the exception of upval stuff + + L2->savedpc = L2->ci->savedpc; + L2->status = info->readStream->readByte(); + uint32 stackbase = info->readStream->readUint32LE(); + uint32 stacktop = info->readStream->readUint32LE(); + + + L2->errfunc = info->readStream->readUint32LE(); + + L2->base = L2->stack + stackbase; + L2->top = L2->stack + stacktop; + + // Finally, "reopen" upvalues. See serializeUpVal() for why we do this + UpVal* uv; + GCObject **nextslot = &L2->openupval; + global_State *g = G(L2); + + while (true) { + unserializeObject(info); + // >>>>> permTbl indexTbl ...... thread upVal/nil + + // The list is terminated by a nil + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... thread nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + break; + } + + // >>>>> permTbl indexTbl ...... thread boxedUpVal + unboxUpVal(info->luaState); + // >>>>> permTbl indexTbl ...... thread boxedUpVal + + uv = &(getObject(info->luaState, -1)->value.gc->uv); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + + uint32 stackpos = info->readStream->readUint32LE(); + uv->v = L2->stack + stackpos; + + GCUnlink(info->luaState, (GCObject *)uv); + + uv->marked = luaC_white(g); + *nextslot = (GCObject *)uv; + nextslot = &uv->next; + uv->u.l.prev = &G(L2)->uvhead; + uv->u.l.next = G(L2)->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + G(L2)->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + } + *nextslot = NULL; + + // The stack must be valid at least to the highest value among the CallInfos + // 'top' and the values up to there must be filled with 'nil' + lua_checkstack(L2, (int)stacklimit); + for (StkId o = L2->top; o <= L2->top + stacklimit; ++o) { + setnilvalue(o); + } +} + +TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) { + lua_pushlstring(luaState, str, len); + TString *luaStr = &(luaState->top - 1)->value.gc->ts; + + lua_pop(luaState, 1); + + return luaStr; +} + +void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) { + global_State *g = G(luaState); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + +Proto *lua_newproto(lua_State *luaState) { + Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_link(luaState, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + +void unserializeProto(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // We have to be careful. The GC expects a lot out of protos. In particular, we need + // to give the function a valid string for its source, and valid code, even before we + // actually read in the real code. + TString *source = lua_newlstr(info->luaState, "", 0); + Proto *p = lua_newproto(info->luaState); + p->source = source; + p->sizecode=1; + p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction)); + p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); + p->maxstacksize = 2; + p->sizek = 0; + p->sizep = 0; + + lua_checkstack(info->luaState, 2); + + pushProto(info->luaState, p); + // >>>>> permTbl indexTbl ...... proto + + // We don't need to register early, since protos can never ever be + // involved in cyclic references + + // Read in constant references + int sizek = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); + for(int i = 0; i < sizek; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserializeObject(info); + // >>>>> permTbl indexTbl ...... proto k + + setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); + p->sizek++; + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + // >>>>> permTbl indexTbl ...... proto + + // Read in sub-proto references + + int sizep = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); + for(int i = 0; i < sizep; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserializeObject(info); + // >>>>> permTbl indexTbl ...... proto subproto + + p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc; + p->sizep++; + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + // >>>>> permTbl indexTbl ...... proto + + + // Read in code + p->sizecode = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->code, 1, p->sizecode, Instruction); + info->readStream->read(p->code, sizeof(Instruction) * p->sizecode); + + + /* Read in upvalue names */ + p->sizeupvalues = info->readStream->readSint32LE(); + if (p->sizeupvalues) { + lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); + for(int i = 0; i < p->sizeupvalues; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserializeObject(info); + // >>>>> permTbl indexTbl ...... proto str + + p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + } + // >>>>> permTbl indexTbl ...... proto + + // Read in local variable infos + p->sizelocvars = info->readStream->readSint32LE(); + if (p->sizelocvars) { + lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); + for(int i = 0; i < p->sizelocvars; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserializeObject(info); + // >>>>> permTbl indexTbl ...... proto str + + p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + p->locvars[i].startpc = info->readStream->readSint32LE(); + p->locvars[i].endpc = info->readStream->readSint32LE(); + } + } + // >>>>> permTbl indexTbl ...... proto + + // Read in source string + unserializeObject(info); + // >>>>> permTbl indexTbl ...... proto sourceStr + + p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + // Read in line numbers + p->sizelineinfo = info->readStream->readSint32LE(); + if (p->sizelineinfo) { + lua_reallocvector(info->luaState, p->lineinfo, 0, p->sizelineinfo, int); + info->readStream->read(p->lineinfo, sizeof(int) * p->sizelineinfo); + } + + + /* Read in linedefined and lastlinedefined */ + p->linedefined = info->readStream->readSint32LE(); + p->lastlinedefined = info->readStream->readSint32LE(); + + // Read in misc values + p->nups = info->readStream->readByte(); + p->numparams = info->readStream->readByte(); + p->is_vararg = info->readStream->readByte(); + p->maxstacksize = info->readStream->readByte(); +} + +Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) { + Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements)); + lua_link(luaState, obj2gco(c), LUA_TFUNCTION); + c->l.isC = 0; + c->l.env = elementTable; + c->l.nupvalues = cast_byte(numElements); + + while (numElements--) { + c->l.upvals[numElements] = NULL; + } + + return c; +} + +static UpVal *makeUpVal(lua_State *luaState, int stackPos) { + UpVal *uv = lua_new(luaState, UpVal); + lua_link(luaState, (GCObject *)uv, LUA_TUPVAL); + uv->tt = LUA_TUPVAL; + uv->v = &uv->u.value; + uv->u.l.prev = NULL; + uv->u.l.next = NULL; + + setobj(luaState, uv->v, getObject(luaState, stackPos)); + + return uv; +} + +/** + * The GC is not fond of finding upvalues in tables. We get around this + * during persistence using a weakly keyed table, so that the GC doesn't + * bother to mark them. This won't work in unpersisting, however, since + * if we make the values weak they'll be collected (since nothing else + * references them). Our solution, during unpersisting, is to represent + * upvalues as dummy functions, each with one upvalue. + */ +static void boxupval_start(lua_State *luaState) { + LClosure *closure; + closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt)); + pushClosure(luaState, (Closure *)closure); + // >>>>> ...... func + closure->p = makeFakeProto(luaState, 1); + + // Temporarily initialize the upvalue to nil + lua_pushnil(luaState); + closure->upvals[0] = makeUpVal(luaState, -1); + lua_pop(luaState, 1); +} + +static void boxupval_finish(lua_State *luaState) { + // >>>>> ...... func obj + LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2)); + + lcl->upvals[0]->u.value = *getObject(luaState, -1); + lua_pop(luaState, 1); + // >>>>> ...... func +} + +void unserializeUpValue(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + lua_checkstack(upi->L, 2); + + boxupval_start(upi->L); + // >>>>> permTbl indexTbl ...... func + registerObjectInIndexTable(info, index); + + unserializeObject(info); + // >>>>> permTbl indexTbl ...... func obj + + boxupval_finish(upi->L); + // >>>>> permTbl indexTbl ...... func +} + +void unserializeUserData(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + int isspecial = info->readStream->readSint32LE(); + if(isspecial) { + unserializeObject(info); + // >>>>> permTbl indexTbl ...... specialFunc + + lua_call(info->luaState, 0, 1); + // >>>>> permTbl indexTbl ...... udata + } else { + uint32 length = info->readStream->readUint32LE(); + lua_newuserdata(info->luaState, length); + // >>>>> permTbl indexTbl ...... udata + registerObjectInIndexTable(info, index); + + info->readStream->read(lua_touserdata(upi->L, -1), length); + + unserializeObject(info); + // >>>>> permTbl indexTbl ...... udata metaTable/nil + + lua_setmetatable(upi->L, -2); + // >>>>> permTbl indexTbl ...... udata + } + // >>>>> permTbl indexTbl ...... udata +} + +void unserializePermanent(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + unserializeObject(info); + // >>>>> permTbl indexTbl ...... permKey + + lua_gettable(info->luaState, 1); + // >>>>> permTbl indexTbl ...... perm +} + +} // End of namespace Lua -- cgit v1.2.3 From 2c7a87a4e3181f228c43b92ffb15ae47401f64a7 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Fri, 19 Dec 2014 14:51:00 -0600 Subject: SWORD25: Fix code formatting ... with AStyle --- engines/sword25/util/lua_serialization_util.cpp | 10 +- engines/sword25/util/lua_serializer.cpp | 62 ++++++------ engines/sword25/util/lua_unserializer.cpp | 127 ++++++++++++------------ 3 files changed, 100 insertions(+), 99 deletions(-) diff --git a/engines/sword25/util/lua_serialization_util.cpp b/engines/sword25/util/lua_serialization_util.cpp index 80009aff60..80c5f86b20 100644 --- a/engines/sword25/util/lua_serialization_util.cpp +++ b/engines/sword25/util/lua_serialization_util.cpp @@ -65,12 +65,12 @@ void pushString(lua_State *luaState, TString *str) { /* A simple reimplementation of the unfortunately static function luaA_index. * Does not support the global table, registry, or upvalues. */ StkId getObject(lua_State *luaState, int stackpos) { - if(stackpos > 0) { - lua_assert(luaState->base+stackpos-1 < luaState->top); - return luaState->base+stackpos-1; + if (stackpos > 0) { + lua_assert(luaState->base + stackpos - 1 < luaState->top); + return luaState->base + stackpos - 1; } else { - lua_assert(L->top-stackpos >= L->base); - return luaState->top+stackpos; + lua_assert(L->top - stackpos >= L->base); + return luaState->top + stackpos; } } diff --git a/engines/sword25/util/lua_serializer.cpp b/engines/sword25/util/lua_serializer.cpp index 8c61383fba..c6c5f99342 100644 --- a/engines/sword25/util/lua_serializer.cpp +++ b/engines/sword25/util/lua_serializer.cpp @@ -81,7 +81,7 @@ void serializeLua(lua_State *luaState, Common::WriteStream *writeStream) { // GC from visiting it and trying to mark things it doesn't want to // mark in tables, e.g. upvalues. All objects in the table are // a priori reachable, so it doesn't matter that we do this. - + // Create the metatable lua_newtable(luaState); // >>>>> permTbl rootObj indexTbl metaTbl @@ -253,22 +253,22 @@ static void serializeBoolean(SerializationInfo *info) { static void serializeNumber(SerializationInfo *info) { lua_Number value = lua_tonumber(info->luaState, -1); - -#if 1 - Util::SerializedDouble serializedValue(Util::encodeDouble(value)); - - info->writeStream->writeUint32LE(serializedValue.significandOne); - info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); - info->writeStream->writeSint16LE(serializedValue.exponent); -#else - // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. - // Also, I don't know if we can assume all compilers use IEEE double - // Therefore, I have chosen to store the double as a string. - Common::String buffer = Common::String::format("%f", value); - - info->writeStream->write(buffer.c_str(), buffer.size()); -#endif - + + #if 1 + Util::SerializedDouble serializedValue(Util::encodeDouble(value)); + + info->writeStream->writeUint32LE(serializedValue.significandOne); + info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); + info->writeStream->writeSint16LE(serializedValue.exponent); + #else + // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. + // Also, I don't know if we can assume all compilers use IEEE double + // Therefore, I have chosen to store the double as a string. + Common::String buffer = Common::String::format("%f", value); + + info->writeStream->write(buffer.c_str(), buffer.size()); + #endif + } static void serializeString(SerializationInfo *info) { @@ -277,7 +277,7 @@ static void serializeString(SerializationInfo *info) { uint32 length = static_cast(lua_strlen(info->luaState, -1)); info->writeStream->writeUint32LE(length); - const char* str = lua_tostring(info->luaState, -1); + const char *str = lua_tostring(info->luaState, -1); info->writeStream->write(str, length); } @@ -350,7 +350,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { lua_pushstring(info->luaState, "__persist not nil, boolean, or function"); lua_error(info->luaState); } - + // >>>>> permTbl indexTbl ...... obj metaTbl __persist lua_pushvalue(info->luaState, -3); // >>>>> permTbl indexTbl ...... obj metaTbl __persist obj @@ -369,7 +369,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { // Serialize the function serializeObject(info); - + lua_pop(info->luaState, 2); // >>>>> permTbl indexTbl ...... obj @@ -396,11 +396,11 @@ static void serializeTable(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ serializeObject(info); - + lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl - + lua_pushnil(info->luaState); // >>>>> permTbl indexTbl ...... tbl nil @@ -456,14 +456,14 @@ static void serializeFunction(SerializationInfo *info) { // Serialize the prototype pushProto(info->luaState, cl->l.p); // >>>>> permTbl indexTbl ...... func proto */ - + serializeObject(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func - + // Serialize upvalue values (not the upvalue objects themselves) - for (byte i=0; il.p->nups; i++) { + for (byte i = 0; i < cl->l.p->nups; i++) { // >>>>> permTbl indexTbl ...... func pushUpValue(info->luaState, cl->l.upvals[i]); // >>>>> permTbl indexTbl ...... func upval @@ -536,7 +536,7 @@ static void serializeThread(SerializationInfo *info) { } // >>>>> permTbl indexTbl ...... thread - + // Now, serialize the CallInfo stack // Again, we *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems @@ -550,7 +550,7 @@ static void serializeThread(SerializationInfo *info) { uint32 stackBase = static_cast(ci->base - threadState->stack); uint32 stackFunc = static_cast(ci->func - threadState->stack); uint32 stackTop = static_cast(ci->top - threadState->stack); - + info->writeStream->writeUint32LE(stackBase); info->writeStream->writeUint32LE(stackFunc); info->writeStream->writeUint32LE(stackTop); @@ -560,7 +560,7 @@ static void serializeThread(SerializationInfo *info) { uint32 savedpc = (ci != threadState->base_ci) ? static_cast(ci->savedpc - ci_func(ci)->l.p->code) : 0u; info->writeStream->writeUint32LE(savedpc); } - + // Serialize the state's other parameters, with the exception of upval stuff @@ -671,9 +671,9 @@ static void serializeProto(SerializationInfo *info) { lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto } - - // Serialize local variable infos + + // Serialize local variable infos info->writeStream->writeSint32LE(proto->sizelocvars); for (int i = 0; i < proto->sizelocvars; ++i) { @@ -748,7 +748,7 @@ static void serializeUpValue(SerializationInfo *info) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); - // We can't permit the upValue to linger around on the stack, as Lua + // We can't permit the upValue to linger around on the stack, as Lua // will bail if its GC finds it. lua_pop(info->luaState, 1); diff --git a/engines/sword25/util/lua_unserializer.cpp b/engines/sword25/util/lua_unserializer.cpp index c561a3d99f..69cb764dd2 100644 --- a/engines/sword25/util/lua_unserializer.cpp +++ b/engines/sword25/util/lua_unserializer.cpp @@ -79,7 +79,7 @@ void unserializeLua(lua_State *luaState, Common::ReadStream *readStream) { // Re-start garbage collection lua_gc(luaState, LUA_GCRESTART, 0); - + // Remove the indexTbl lua_replace(luaState, 2); // >>>>> permTbl rootObj @@ -106,17 +106,17 @@ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { } static void unserializeObject(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... + // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); byte isARealValue = info->readStream->readByte(); - if(isARealValue) { + if (isARealValue) { int index = info->readStream->readSint32LE(); int type = info->readStream->readSint32LE(); - switch(type) { + switch (type) { case LUA_TBOOLEAN: unserializeBoolean(info); break; @@ -156,9 +156,9 @@ static void unserializeObject(UnSerializationInfo *info) { assert(0); } - + // >>>>> permTbl indexTbl ...... obj - assert(lua_type(info->luaState, -1) == type || + assert(lua_type(info->luaState, -1) == type || type == PERMANENT_TYPE || // Remember, upvalues get a special dispensation, as described in boxUpValue (lua_type(info->luaState, -1) == LUA_TFUNCTION && type == LUA_TUPVAL)); @@ -168,7 +168,7 @@ static void unserializeObject(UnSerializationInfo *info) { } else { int index = info->readStream->readSint32LE(); - if(index == 0) { + if (index == 0) { lua_pushnil(info->luaState); // >>>>> permTbl indexTbl ...... nil } else { @@ -184,7 +184,7 @@ static void unserializeObject(UnSerializationInfo *info) { } // >>>>> permTbl indexTbl ...... obj/nil } - + // >>>>> permTbl indexTbl ...... obj/nil } @@ -201,8 +201,8 @@ static void unserializeBoolean(UnSerializationInfo *info) { } static void unserializeNumber(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... - + // >>>>> permTbl indexTbl ...... + // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); @@ -220,7 +220,7 @@ static void unserializeNumber(UnSerializationInfo *info) { static void unserializeString(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... - + // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); @@ -231,7 +231,7 @@ static void unserializeString(UnSerializationInfo *info) { lua_pushlstring(info->luaState, string, length); // >>>>> permTbl indexTbl ...... string - + delete[] string; } @@ -264,7 +264,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { // Unserialize metatable unserializeObject(info); // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? - + if (lua_istable(info->luaState, -1)) { // >>>>> permTbl indexTbl ...... tbl metaTbl lua_setmetatable(info->luaState, -2); @@ -343,7 +343,7 @@ void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { obj->gch.tt = type; } -#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) +#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) Closure *newLClosure(lua_State *luaState, byte numUpValues, Table *env) { Closure *newClosure = (Closure *)lua_malloc(luaState, sizeLclosure(numUpValues)); @@ -355,7 +355,7 @@ Closure *newLClosure(lua_State *luaState, byte numUpValues, Table *env) { newClosure->l.nupvalues = numUpValues; while (numUpValues--) { - newClosure->l.upvals[numUpValues] = NULL; + newClosure->l.upvals[numUpValues] = NULL; } return newClosure; @@ -431,7 +431,8 @@ static UpVal *createUpValue(lua_State *luaState, int stackpos) { upValue->u.l.next = NULL; const TValue *o2 = (TValue *)getObject(luaState, stackpos); - upValue->v->value = o2->value; upValue->v->tt = o2->tt; + upValue->v->value = o2->value; + upValue->v->tt = o2->tt; checkliveness(G(L), upValue->v); return upValue; @@ -471,7 +472,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { lua_pushnil(info->luaState); // >>>>> permTbl indexTbl ...... func nil - for(byte i = 0; i < numUpValues; ++i) { + for (byte i = 0; i < numUpValues; ++i) { lclosure->upvals[i] = createUpValue(info->luaState, -1); } @@ -491,7 +492,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func - for(byte i = 0; i < numUpValues; ++i) { + for (byte i = 0; i < numUpValues; ++i) { // >>>>> permTbl indexTbl ...... func unserializeObject(info); // >>>>> permTbl indexTbl ...... func func2 @@ -508,7 +509,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { unserializeObject(info); // >>>>> permTbl indexTbl ...... func ?fenv/nil? - if(!lua_isnil(info->luaState, -1)) { + if (!lua_isnil(info->luaState, -1)) { // >>>>> permTbl indexTbl ...... func fenv lua_setfenv(info->luaState, -2); // >>>>> permTbl indexTbl ...... func @@ -517,7 +518,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func } - + // >>>>> permTbl indexTbl ...... func } @@ -547,7 +548,7 @@ void lua_reallocstack(lua_State *L, int newsize) { void lua_growstack(lua_State *L, int n) { // Double size is enough? - if (n <= L->stacksize) { + if (n <= L->stacksize) { lua_reallocstack(L, 2 * L->stacksize); } else { lua_reallocstack(L, L->stacksize + n); @@ -583,13 +584,13 @@ void unboxUpVal(lua_State *luaState) { * that. */ static void GCUnlink(lua_State *luaState, GCObject *gco) { GCObject *prevslot; - if(G(luaState)->rootgc == gco) { + if (G(luaState)->rootgc == gco) { G(luaState)->rootgc = G(luaState)->rootgc->gch.next; return; } prevslot = G(luaState)->rootgc; - while(prevslot->gch.next != gco) { + while (prevslot->gch.next != gco) { prevslot = prevslot->gch.next; } @@ -604,7 +605,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { L2 = lua_newthread(info->luaState); lua_checkstack(info->luaState, 3); - + // L1: permTbl indexTbl ...... thread // L2: (empty) registerObjectInIndexTable(info, index); @@ -612,14 +613,14 @@ void unserializeThread(UnSerializationInfo *info, int index) { // First, deserialize the object stack uint32 stackSize = info->readStream->readUint32LE(); lua_growstack(info->luaState, (int)stackSize); - + // Make sure that the first stack element (a nil, representing // the imaginary top-level C function) is written to the very, // very bottom of the stack L2->top--; - for(uint32 i = 0; i < stackSize; ++i) { + for (uint32 i = 0; i < stackSize; ++i) { unserializeObject(info); - // L1: permTbl indexTbl ...... thread obj* + // L1: permTbl indexTbl ...... thread obj* } lua_xmove(info->luaState, L2, stackSize); @@ -628,18 +629,18 @@ void unserializeThread(UnSerializationInfo *info, int index) { // Hereafter, stacks refer to L1 - + // Now, deserialize the CallInfo stack uint32 numFrames = info->readStream->readUint32LE(); - lua_reallocCallInfo(L2, numFrames*2); - for(uint32 i = 0; i < numFrames; ++i) { + lua_reallocCallInfo(L2, numFrames * 2); + for (uint32 i = 0; i < numFrames; ++i) { CallInfo *ci = L2->base_ci + i; uint32 stackbase = info->readStream->readUint32LE(); uint32 stackfunc = info->readStream->readUint32LE(); uint32 stacktop = info->readStream->readUint32LE(); - + ci->nresults = info->readStream->readSint32LE(); uint32 savedpc = info->readStream->readUint32LE(); @@ -653,7 +654,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { ci->top = L2->stack + stacktop; ci->savedpc = (ci != L2->base_ci) ? ci_func(ci)->l.p->code + savedpc : 0; ci->tailcalls = 0; - + // Update the pointer each time, to keep the GC happy L2->ci = ci; } @@ -668,12 +669,12 @@ void unserializeThread(UnSerializationInfo *info, int index) { L2->errfunc = info->readStream->readUint32LE(); - + L2->base = L2->stack + stackbase; L2->top = L2->stack + stacktop; - // Finally, "reopen" upvalues. See serializeUpVal() for why we do this - UpVal* uv; + // Finally, "reopen" upvalues. See serializeUpVal() for why we do this + UpVal *uv; GCObject **nextslot = &L2->openupval; global_State *g = G(L2); @@ -688,7 +689,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... thread break; } - + // >>>>> permTbl indexTbl ...... thread boxedUpVal unboxUpVal(info->luaState); // >>>>> permTbl indexTbl ...... thread boxedUpVal @@ -765,15 +766,15 @@ Proto *lua_newproto(lua_State *luaState) { void unserializeProto(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... - - // We have to be careful. The GC expects a lot out of protos. In particular, we need - // to give the function a valid string for its source, and valid code, even before we - // actually read in the real code. + + // We have to be careful. The GC expects a lot out of protos. In particular, we need + // to give the function a valid string for its source, and valid code, even before we + // actually read in the real code. TString *source = lua_newlstr(info->luaState, "", 0); Proto *p = lua_newproto(info->luaState); p->source = source; - p->sizecode=1; - p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction)); + p->sizecode = 1; + p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction)); p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); p->maxstacksize = 2; p->sizek = 0; @@ -782,18 +783,18 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_checkstack(info->luaState, 2); pushProto(info->luaState, p); - // >>>>> permTbl indexTbl ...... proto + // >>>>> permTbl indexTbl ...... proto // We don't need to register early, since protos can never ever be - // involved in cyclic references + // involved in cyclic references // Read in constant references int sizek = info->readStream->readSint32LE(); lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); - for(int i = 0; i < sizek; ++i) { - // >>>>> permTbl indexTbl ...... proto + for (int i = 0; i < sizek; ++i) { + // >>>>> permTbl indexTbl ...... proto unserializeObject(info); - // >>>>> permTbl indexTbl ...... proto k + // >>>>> permTbl indexTbl ...... proto k setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); p->sizek++; @@ -807,8 +808,8 @@ void unserializeProto(UnSerializationInfo *info, int index) { int sizep = info->readStream->readSint32LE(); lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); - for(int i = 0; i < sizep; ++i) { - // >>>>> permTbl indexTbl ...... proto + for (int i = 0; i < sizep; ++i) { + // >>>>> permTbl indexTbl ...... proto unserializeObject(info); // >>>>> permTbl indexTbl ...... proto subproto @@ -816,22 +817,22 @@ void unserializeProto(UnSerializationInfo *info, int index) { p->sizep++; lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto + // >>>>> permTbl indexTbl ...... proto } - // >>>>> permTbl indexTbl ...... proto + // >>>>> permTbl indexTbl ...... proto // Read in code p->sizecode = info->readStream->readSint32LE(); lua_reallocvector(info->luaState, p->code, 1, p->sizecode, Instruction); info->readStream->read(p->code, sizeof(Instruction) * p->sizecode); - + /* Read in upvalue names */ p->sizeupvalues = info->readStream->readSint32LE(); if (p->sizeupvalues) { lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); - for(int i = 0; i < p->sizeupvalues; ++i) { + for (int i = 0; i < p->sizeupvalues; ++i) { // >>>>> permTbl indexTbl ...... proto unserializeObject(info); // >>>>> permTbl indexTbl ...... proto str @@ -847,7 +848,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { p->sizelocvars = info->readStream->readSint32LE(); if (p->sizelocvars) { lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); - for(int i = 0; i < p->sizelocvars; ++i) { + for (int i = 0; i < p->sizelocvars; ++i) { // >>>>> permTbl indexTbl ...... proto unserializeObject(info); // >>>>> permTbl indexTbl ...... proto str @@ -876,7 +877,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->lineinfo, 0, p->sizelineinfo, int); info->readStream->read(p->lineinfo, sizeof(int) * p->sizelineinfo); } - + /* Read in linedefined and lastlinedefined */ p->linedefined = info->readStream->readSint32LE(); @@ -895,7 +896,7 @@ Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTab c->l.isC = 0; c->l.env = elementTable; c->l.nupvalues = cast_byte(numElements); - + while (numElements--) { c->l.upvals[numElements] = NULL; } @@ -916,13 +917,13 @@ static UpVal *makeUpVal(lua_State *luaState, int stackPos) { return uv; } -/** +/** * The GC is not fond of finding upvalues in tables. We get around this * during persistence using a weakly keyed table, so that the GC doesn't * bother to mark them. This won't work in unpersisting, however, since * if we make the values weak they'll be collected (since nothing else * references them). Our solution, during unpersisting, is to represent - * upvalues as dummy functions, each with one upvalue. + * upvalues as dummy functions, each with one upvalue. */ static void boxupval_start(lua_State *luaState) { LClosure *closure; @@ -931,7 +932,7 @@ static void boxupval_start(lua_State *luaState) { // >>>>> ...... func closure->p = makeFakeProto(luaState, 1); - // Temporarily initialize the upvalue to nil + // Temporarily initialize the upvalue to nil lua_pushnil(luaState); closure->upvals[0] = makeUpVal(luaState, -1); lua_pop(luaState, 1); @@ -947,7 +948,7 @@ static void boxupval_finish(lua_State *luaState) { } void unserializeUpValue(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... + // >>>>> permTbl indexTbl ...... lua_checkstack(upi->L, 2); boxupval_start(upi->L); @@ -966,9 +967,9 @@ void unserializeUserData(UnSerializationInfo *info, int index) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); - + int isspecial = info->readStream->readSint32LE(); - if(isspecial) { + if (isspecial) { unserializeObject(info); // >>>>> permTbl indexTbl ...... specialFunc @@ -996,7 +997,7 @@ void unserializePermanent(UnSerializationInfo *info, int index) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); - + unserializeObject(info); // >>>>> permTbl indexTbl ...... permKey -- cgit v1.2.3 From 37b5ee24f520e46eae28c703d189939e0b18c65b Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Dec 2014 22:45:00 -0500 Subject: ACCESS: Rename ASurface copyFrom methods to avoid clash with Graphics::Surface --- engines/access/amazon/amazon_game.cpp | 8 +++---- engines/access/amazon/amazon_logic.cpp | 38 ++++++++++++++++---------------- engines/access/amazon/amazon_scripts.cpp | 30 ++++++++++++------------- engines/access/asurface.cpp | 16 +++++++------- engines/access/asurface.h | 10 ++++----- engines/access/char.cpp | 4 ++-- engines/access/martian/martian_game.cpp | 10 ++++----- engines/access/screen.cpp | 12 +++++----- engines/access/screen.h | 6 ++--- engines/access/scripts.cpp | 2 +- 10 files changed, 68 insertions(+), 68 deletions(-) diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 933a98aded..6c9a437e77 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -552,7 +552,7 @@ void AmazonEngine::startChapter(int chapter) { // Show chapter screen _files->loadScreen(96, 15); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); const int *chapImg = &CHAPTER_TABLE[_chapter - 1][0]; _screen->plotImage(_objectsTable[0], _chapter - 1, @@ -583,14 +583,14 @@ void AmazonEngine::startChapter(int chapter) { _screen->clearBuffer(); _files->loadScreen(96, 16); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); _screen->plotImage(_objectsTable[0], chapImg[0], Common::Point(90, 7)); _midi->newMusic(7, 1); _midi->newMusic(34, 0); _screen->forceFadeIn(); - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); _fonts._charSet._lo = 1; _fonts._charSet._hi = 10; @@ -670,7 +670,7 @@ void AmazonEngine::dead(int deathId) { _files->_setPaletteFlag = false; _files->loadScreen(94, 0); _files->_setPaletteFlag = true; - _buffer2.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); if (!isDemo() || deathId != 10) { for (int i = 0; i < 3; ++i) { diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 436a875688..7f802f3cde 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -106,8 +106,8 @@ void CampScene::mWhileDoOpen() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(1, 2); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); // Load animation data _vm->_animation->freeAnimationData(); @@ -148,7 +148,7 @@ void CampScene::mWhileDoOpen() { _vm->_animation->animate(0); _vm->_animation->animate(1); pan(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_newRects.clear(); _vm->plotList(); _vm->copyBlocks(); @@ -176,8 +176,8 @@ void CampScene::mWhileDoOpen() { } events.showCursor(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->freeCells(); _vm->_oldRects.clear(); @@ -323,8 +323,8 @@ void Opening::doTitle() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 3); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); screen.forceFadeIn(); _vm->_sound->playSound(1); @@ -347,13 +347,13 @@ void Opening::doTitle() { _vm->_files->loadScreen(0, 4); _vm->_sound->playSound(1); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); int id = COUNTDOWN[_pCount * 2]; int xp = COUNTDOWN[_pCount * 2 + 1]; _vm->_buffer2.plotImage(_vm->_objectsTable[0], id, Common::Point(xp, 71)); @@ -385,8 +385,8 @@ void Opening::doTitle() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 5); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); screen.forceFadeIn(); _vm->_midi->newMusic(1, 0); _vm->_events->_vbCount = 700; @@ -503,8 +503,8 @@ void Opening::doTent() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(2, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); _vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10); @@ -1276,8 +1276,8 @@ void Cast::doCast(int param1) { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(58, 1); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _xTrack = 0; _yTrack = -6; @@ -1319,7 +1319,7 @@ void Cast::doCast(int param1) { while (!_vm->shouldQuit()) { _vm->_images.clear(); pan(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_newRects.clear(); _vm->plotList(); _vm->copyBlocks(); @@ -1410,7 +1410,7 @@ void River::initRiver() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); screen.restorePalette(); screen.setBufferScan(); @@ -1744,7 +1744,7 @@ void River::mWhileDownRiver() { screen.savePalette(); if (!_vm->isDemo()) _vm->_files->loadScreen(95, 4); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); screen.restorePalette(); screen.setPalette(); screen.setBufferScan(); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 633188e4dd..0b2ddbc854 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -38,7 +38,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { void AmazonScripts::cLoop() { searchForSequence(); _vm->_images.clear(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_oldRects.clear(); _vm->_scripts->executeScript(); _vm->plotList1(); @@ -51,8 +51,8 @@ void AmazonScripts::mWhile1() { _vm->_events->hideCursor(); _vm->_files->loadScreen(14, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -86,8 +86,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 1); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -107,8 +107,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 2); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -138,8 +138,8 @@ void AmazonScripts::mWhile1() { _vm->_files->loadScreen(14, 3); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -159,8 +159,8 @@ void AmazonScripts::mWhile2() { _vm->_events->hideCursor(); _vm->_files->loadScreen(14, 0); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -190,8 +190,8 @@ void AmazonScripts::mWhile2() { _vm->_files->loadScreen(14, 3); _vm->_screen->setPalette(); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_events->showCursor(); _vm->_screen->setIconPalette(); @@ -240,8 +240,8 @@ void AmazonScripts::loadBackground(int param1, int param2) { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(param1, param2); - _vm->_buffer2.copyFrom(*_vm->_screen); - _vm->_buffer1.copyFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); _vm->_screen->forceFadeIn(); } diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 38af7add00..f45f121db4 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -186,7 +186,7 @@ void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Poi } } -void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) { +void ASurface::transBlitFrom(ASurface *src, const Common::Point &destPos) { if (getPixels() == nullptr) create(w, h); @@ -201,7 +201,7 @@ void ASurface::transCopyFrom(ASurface *src, const Common::Point &destPos) { } } -void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) { +void ASurface::transBlitFrom(ASurface *src, const Common::Rect &bounds) { const int SCALE_LIMIT = 0x100; int scaleX = SCALE_LIMIT * bounds.width() / src->w; int scaleY = SCALE_LIMIT * bounds.height() / src->h; @@ -247,11 +247,11 @@ void ASurface::transCopyFrom(ASurface *src, const Common::Rect &bounds) { } } -void ASurface::transCopyFrom(ASurface &src) { - copyFrom(src); +void ASurface::transBlitFrom(ASurface &src) { + blitFrom(src); } -void ASurface::copyFrom(Graphics::Surface &src) { +void ASurface::blitFrom(Graphics::Surface &src) { for (int y = 0; y < src.h; ++y) { const byte *srcP = (const byte *)src.getBasePtr(0, y); byte *destP = (byte *)getBasePtr(0, y); @@ -260,7 +260,7 @@ void ASurface::copyFrom(Graphics::Surface &src) { } void ASurface::copyBuffer(Graphics::Surface *src) { - copyFrom(*src); + blitFrom(*src); } void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) { @@ -272,14 +272,14 @@ void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) { } void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) { - transCopyFrom(frame, bounds); + transBlitFrom(frame, bounds); } void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) { ASurface flippedFrame; frame->flipHorizontal(flippedFrame); - transCopyFrom(&flippedFrame, bounds); + transBlitFrom(&flippedFrame, bounds); } void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) { diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 763e3e629e..4fb47b9c09 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -95,19 +95,19 @@ public: virtual void drawRect(); - virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); + virtual void transBlitFrom(ASurface *src, const Common::Point &destPos); - virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds); - virtual void transCopyFrom(ASurface &src); + virtual void transBlitFrom(ASurface &src); - virtual void copyFrom(Graphics::Surface &src); + virtual void blitFrom(Graphics::Surface &src); virtual void copyBuffer(Graphics::Surface *src); virtual void addDirtyRect(const Common::Rect &r) {} - void copyTo(ASurface *dest) { dest->copyFrom(*this); } + void copyTo(ASurface *dest) { dest->blitFrom(*this); } void saveBlock(const Common::Rect &bounds); diff --git a/engines/access/char.cpp b/engines/access/char.cpp index 5bc6707509..b359bcf13a 100644 --- a/engines/access/char.cpp +++ b/engines/access/char.cpp @@ -108,8 +108,8 @@ void CharManager::loadChar(int charId) { _vm->_screen->fadeIn(); } - _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.blitFrom(*_vm->_screen); + _vm->_buffer2.blitFrom(*_vm->_screen); _vm->_screen->setDisplayScan(); if (_charFlag != 2 && _charFlag != 3) { diff --git a/engines/access/martian/martian_game.cpp b/engines/access/martian/martian_game.cpp index 6392206209..4e4a5135a6 100644 --- a/engines/access/martian/martian_game.cpp +++ b/engines/access/martian/martian_game.cpp @@ -100,8 +100,8 @@ void MartianEngine::doTitle() { _files->_setPaletteFlag = false; _files->loadScreen(0, 3); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); + _buffer1.blitFrom(*_screen); _screen->forceFadeIn(); _sound->playSound(1); @@ -115,13 +115,13 @@ void MartianEngine::doTitle() { _files->loadScreen(0, 4); _sound->playSound(1); - _buffer2.copyFrom(*_screen); - _buffer1.copyFrom(*_screen); + _buffer2.blitFrom(*_screen); + _buffer1.blitFrom(*_screen); _sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; for (_pCount = 0; _pCount < 3; ++_pCount) { - _buffer2.copyFrom(_buffer1); + _buffer2.blitFrom(_buffer1); int id = READ_LE_UINT16(COUNTDOWN + _pCount * 4); int xp = READ_LE_UINT16(COUNTDOWN + _pCount * 4 + 2); _screen->plotImage(_objectsTable[0], id, Common::Point(xp, 71)); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index 35069ba683..d6fddb73b2 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -266,19 +266,19 @@ void Screen::drawRect() { ASurface::drawRect(); } -void Screen::transCopyFrom(ASurface *src, const Common::Point &destPos) { +void Screen::transBlitFrom(ASurface *src, const Common::Point &destPos) { addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h)); - ASurface::transCopyFrom(src, destPos); + ASurface::transBlitFrom(src, destPos); } -void Screen::transCopyFrom(ASurface *src, const Common::Rect &bounds) { +void Screen::transBlitFrom(ASurface *src, const Common::Rect &bounds) { addDirtyRect(bounds); - ASurface::transCopyFrom(src, bounds); + ASurface::transBlitFrom(src, bounds); } -void Screen::copyFrom(Graphics::Surface &src) { +void Screen::blitFrom(Graphics::Surface &src) { addDirtyRect(Common::Rect(0, 0, src.w, src.h)); - ASurface::copyFrom(src); + ASurface::blitFrom(src); } void Screen::copyBuffer(Graphics::Surface *src) { diff --git a/engines/access/screen.h b/engines/access/screen.h index 0fa111c21c..d45a533f9a 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -92,11 +92,11 @@ public: virtual void drawRect(); - virtual void transCopyFrom(ASurface *src, const Common::Point &destPos); + virtual void transBlitFrom(ASurface *src, const Common::Point &destPos); - virtual void transCopyFrom(ASurface *src, const Common::Rect &bounds); + virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds); - virtual void copyFrom(Graphics::Surface &src); + virtual void blitFrom(Graphics::Surface &src); virtual void copyBuffer(Graphics::Surface *src); diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 2e22d9a2ce..dfb9bd963f 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -73,7 +73,7 @@ void Scripts::charLoop() { _sequence = 2000; searchForSequence(); _vm->_images.clear(); - _vm->_buffer2.copyFrom(_vm->_buffer1); + _vm->_buffer2.blitFrom(_vm->_buffer1); _vm->_newRects.clear(); executeScript(); -- cgit v1.2.3 From 18df28f74da91105b8c1898bfe2351b22cbd435f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 19 Dec 2014 23:36:53 -0500 Subject: ACCESS: Extra initialization for various classes --- engines/access/access.cpp | 3 +++ engines/access/amazon/amazon_game.cpp | 9 ++++++++- engines/access/amazon/amazon_logic.cpp | 12 ++++++++++++ engines/access/amazon/amazon_logic.h | 2 ++ engines/access/animation.cpp | 1 + engines/access/asurface.cpp | 3 ++- engines/access/bubble_box.cpp | 7 +++---- engines/access/bubble_box.h | 4 ---- engines/access/font.cpp | 2 ++ engines/access/inventory.cpp | 1 + engines/access/player.cpp | 6 ++++++ engines/access/screen.cpp | 1 + engines/access/scripts.cpp | 2 ++ engines/access/video.cpp | 8 +++++++- 14 files changed, 50 insertions(+), 11 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 6ad1b22408..39e6c2b530 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -41,6 +41,7 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _events = nullptr; _files = nullptr; _inventory = nullptr; + _midi = nullptr; _player = nullptr; _room = nullptr; _screen = nullptr; @@ -92,6 +93,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _vidX = _vidY = 0; _cheatFl = false; _restartFl = false; + _et = 0; + _printEnd = 0; } AccessEngine::~AccessEngine() { diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 6c9a437e77..eb4fabdad9 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -61,9 +61,16 @@ AmazonEngine::AmazonEngine(OSystem *syst, const AccessGameDescription *gameDesc) _helpTbl[1] = _help2; _helpTbl[2] = _help3; + _chapter = 0; + _rawInactiveX = _rawInactiveY = 0; + _inactiveYOff = 0; + _hintLevel = 0; + _updateChapter = 0; + _oldTitleChapter = 0; + _iqValue = 0; + _chapterCells.push_back(CellIdent(0, 96, 17)); _inactive._spritesPtr = nullptr; - _inactive._altSpritesPtr = nullptr; _inactive._flags = _inactive._frameNumber = _inactive._offsetY = 0; _inactive._position = Common::Point(0, 0); } diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 7f802f3cde..d2ee17a230 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1371,6 +1371,18 @@ River::River(AmazonEngine *vm) : PannedScene(vm) { _deathCount = 0; _oldScrollCol = 0; _maxHits = 0; + _mapPtr = nullptr; + _canoeMoveCount = 0; + _canoeVXPos = 0; + _canoeFrame = 0; + _canoeDir = 0; + _canoeLane = 0; + _canoeYPos = 0; + _hitCount = 0; + _riverIndex = 0; + _topList = _botList = nullptr; + _deathType = 0; + _hitSafe = 0; } void River::setRiverPan() { diff --git a/engines/access/amazon/amazon_logic.h b/engines/access/amazon/amazon_logic.h index a1fb4eef77..0d962483e6 100644 --- a/engines/access/amazon/amazon_logic.h +++ b/engines/access/amazon/amazon_logic.h @@ -242,6 +242,8 @@ public: class InactivePlayer : public ImageEntry { public: SpriteResource *_altSpritesPtr; + + InactivePlayer() { _altSpritesPtr = nullptr; } }; } // End of namespace Amazon diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index 548e7db02d..cc699a27e3 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -63,6 +63,7 @@ Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Man _countdownTicks = stream->readUint16LE(); _currentLoopCount = stream->readSint16LE(); stream->readUint16LE(); // unk + _field10 = 0; Common::Array frameOffsets; uint16 ofs; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index f45f121db4..e9a2e8a427 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -102,7 +102,7 @@ void ImageEntryList::addToList(ImageEntry &ie) { int ASurface::_clipWidth; int ASurface::_clipHeight; -ASurface::ASurface() { +ASurface::ASurface(): Graphics::Surface() { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; _lastBoundsX = _lastBoundsY = 0; @@ -110,6 +110,7 @@ ASurface::ASurface() { _orgX1 = _orgY1 = 0; _orgX2 = _orgY2 = 0; _lColor = 0; + _maxChars = 0; } ASurface::~ASurface() { diff --git a/engines/access/bubble_box.cpp b/engines/access/bubble_box.cpp index e37a8142e8..28c211991c 100644 --- a/engines/access/bubble_box.cpp +++ b/engines/access/bubble_box.cpp @@ -27,13 +27,12 @@ namespace Access { BubbleBox::BubbleBox(AccessEngine *vm) : Manager(vm) { + _startItem = 0; + _startBox = 0; + _charCol = _rowOff = 0; _type = TYPE_2; _bounds = Common::Rect(64, 32, 64 + 130, 32 + 122); _bubbleDisplStr = ""; - _fieldD = 0; - _fieldE = 0; - _fieldF = 0; - _field10 = 0; } void BubbleBox::load(Common::SeekableReadStream *stream) { diff --git a/engines/access/bubble_box.h b/engines/access/bubble_box.h index 0130344c7e..0b3f139520 100644 --- a/engines/access/bubble_box.h +++ b/engines/access/bubble_box.h @@ -49,10 +49,6 @@ public: Common::StringArray _nameIndex; Common::String _bubbleTitle; Common::String _bubbleDisplStr; - int _fieldD; - int _fieldE; - int _fieldF; - int _field10; Common::Array _bubbles; public: diff --git a/engines/access/font.cpp b/engines/access/font.cpp index da8f0b6ec5..8af183f193 100644 --- a/engines/access/font.cpp +++ b/engines/access/font.cpp @@ -27,6 +27,8 @@ namespace Access { byte Font::_fontColors[4]; Font::Font() { + _bitWidth = 0; + _height = 0; } Font::~Font() { diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index 8db62a45fc..df499ba705 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -57,6 +57,7 @@ InventoryManager::InventoryManager(AccessEngine *vm) : Manager(vm) { _startAboutItem = 0; _startTravelItem = 0; _iconDisplayFlag = true; + _boxNum = 0; const char *const *names; const int *combineP; diff --git a/engines/access/player.cpp b/engines/access/player.cpp index d547aedc1d..bcd553c6dc 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -73,6 +73,12 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() { _playerDirection = NONE; _xFlag = _yFlag = 0; _inactiveYOff = 0; + + _sideWalkMin = _sideWalkMax = 0; + _upWalkMin = _upWalkMax = 0; + _downWalkMin = _downWalkMax = 0; + _diagUpWalkMin = _diagUpWalkMax = 0; + _diagDownWalkMin = _diagDownWalkMax = 0; } Player::~Player() { diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index d6fddb73b2..970a8f3079 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -56,6 +56,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _bufferBytesWide = _vWindowBytesWide = this->w; _vWindowLinesTall = this->h; + _vWindowWidth = _vWindowHeight = 0; _clipWidth = _vWindowBytesWide - 1; _clipHeight = _vWindowLinesTall - 1; _startCycle = 0; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index dfb9bd963f..074c781352 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -29,10 +29,12 @@ namespace Access { Scripts::Scripts(AccessEngine *vm) : Manager(vm) { _resource = nullptr; + _specialFunction = -1; _data = nullptr; _sequence = 0; _endFlag = false; _returnCode = 0; + _scriptCommand = 0; _choice = 0; _choiceStart = 0; _charsOrg = Common::Point(0, 0); diff --git a/engines/access/video.cpp b/engines/access/video.cpp index b7d5652e5b..920c066898 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -27,10 +27,16 @@ namespace Access { VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _vidSurface = nullptr; + _videoData = nullptr; + _startCoord = nullptr; + _frameCount = 0; + _xCount = 0; + _scanCount = 0; + _frameSize = 0; _videoFrame = 0; _soundFlag = false; _soundFrame = 0; - _videoData = nullptr; + _videoEnd = false; } VideoPlayer::~VideoPlayer() { -- cgit v1.2.3 From a7bfa55aa802b7f6adfe85cb981af9f2f42c2586 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 20 Dec 2014 10:01:52 -0500 Subject: ACCESS: Fix compiler warnings --- engines/access/amazon/amazon_logic.cpp | 13 +++++-------- engines/access/decompress.cpp | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index d2ee17a230..97bd9de650 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1492,11 +1492,11 @@ void River::initRiver() { _maxHits = 2 - _vm->_riverFlag; _saveRiver = false; - Font &font2 = _vm->_fonts._font2; - font2._fontColors[0] = 0; - font2._fontColors[1] = 33; - font2._fontColors[2] = 34; - font2._fontColors[3] = 35; + // Set font colors for drawing using font2 + Font::_fontColors[0] = 0; + Font::_fontColors[1] = 33; + Font::_fontColors[2] = 34; + Font::_fontColors[3] = 35; } void River::resetPositions() { @@ -1522,8 +1522,6 @@ void River::checkRiverPan() { } bool River::riverJumpTest() { - Screen &screen = *_vm->_screen; - if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) { int val = *++_mapPtr; if (val == 0xFF) @@ -1921,7 +1919,6 @@ void River::synchronize(Common::Serializer &s) { if (_vm->_player->_roomNumber == 45) { if (s.isSaving()) { // Set river properties to be saved out - Screen &screen = *_vm->_screen; _rScrollRow = _vm->_scrollRow; _rScrollCol = _vm->_scrollCol; _rScrollX = _vm->_scrollX; diff --git a/engines/access/decompress.cpp b/engines/access/decompress.cpp index 62bff87860..c5656afa51 100644 --- a/engines/access/decompress.cpp +++ b/engines/access/decompress.cpp @@ -32,8 +32,9 @@ void LzwDecompressor::decompress(byte *source, byte *dest) { _source = source; - byte litByte; - uint16 copyLength, maxCodeValue, code, nextCode, lastCode, oldCode; + byte litByte = 0; + uint16 oldCode = 0; + uint16 copyLength, maxCodeValue, code, nextCode, lastCode; byte *copyBuf = new byte[8192]; -- cgit v1.2.3 From 7cb18f8e7ac47e8c8c0b738401534ec0b99c2507 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 20 Dec 2014 10:59:16 -0500 Subject: ACCESS: Fix crash in the introduction sequence --- engines/access/amazon/amazon_logic.cpp | 14 +++++++------- engines/access/asurface.cpp | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 97bd9de650..e6a96b67d6 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -148,7 +148,7 @@ void CampScene::mWhileDoOpen() { _vm->_animation->animate(0); _vm->_animation->animate(1); pan(); - _vm->_buffer2.blitFrom(_vm->_buffer1); + _vm->_buffer2.copyFrom(_vm->_buffer1); _vm->_newRects.clear(); _vm->plotList(); _vm->copyBlocks(); @@ -176,8 +176,8 @@ void CampScene::mWhileDoOpen() { } events.showCursor(); - _vm->_buffer2.blitFrom(*_vm->_screen); - _vm->_buffer1.blitFrom(*_vm->_screen); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); _vm->freeCells(); _vm->_oldRects.clear(); @@ -323,8 +323,8 @@ void Opening::doTitle() { _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 3); - _vm->_buffer2.blitFrom(*_vm->_screen); - _vm->_buffer1.blitFrom(*_vm->_screen); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); screen.forceFadeIn(); _vm->_sound->playSound(1); @@ -347,8 +347,8 @@ void Opening::doTitle() { _vm->_files->loadScreen(0, 4); _vm->_sound->playSound(1); - _vm->_buffer2.blitFrom(*_vm->_screen); - _vm->_buffer1.blitFrom(*_vm->_screen); + _vm->_buffer2.copyFrom(*_vm->_screen); + _vm->_buffer1.copyFrom(*_vm->_screen); _vm->_sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index e9a2e8a427..5f4372d5af 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -253,6 +253,7 @@ void ASurface::transBlitFrom(ASurface &src) { } void ASurface::blitFrom(Graphics::Surface &src) { + assert(w >= src.w && h >= src.h); for (int y = 0; y < src.h; ++y) { const byte *srcP = (const byte *)src.getBasePtr(0, y); byte *destP = (byte *)getBasePtr(0, y); -- cgit v1.2.3 From b41b3e1a89d7646561697b1bc3636345230a9f12 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 20 Dec 2014 13:26:32 +0200 Subject: ZVISION: Fix code formatting --- engines/zvision/file/search_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 30c269c290..d0d4e43d12 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -265,7 +265,7 @@ void SearchManager::addDir(const Common::String &name) { void SearchManager::listDirRecursive(Common::List &_list, const Common::FSNode &fsNode, int depth) { Common::FSList fsList; - if ( fsNode.getChildren(fsList) ) { + if (fsNode.getChildren(fsList)) { _list.push_back(fsNode.getPath()); -- cgit v1.2.3 From 0f590561bd0fe7238fcfd5fcee0d8a4dc11b9979 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 20 Dec 2014 13:27:16 +0200 Subject: ZVISION: Simplify check Thanks to DrMcCoy for spotting this --- engines/zvision/sound/zork_raw.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index 8688039325..b2c88b34df 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -73,10 +73,7 @@ RawChunkStream::RawChunk RawChunkStream::readNextChunk(Common::SeekableReadStrea tmp.size = 0; tmp.data = NULL; - if (!stream) - return tmp; - - if (stream && (stream->size() == 0 || stream->eos())) + if (!stream || stream->size() == 0 || stream->eos()) return tmp; tmp.size = (stream->size() - stream->pos()) * 2; -- cgit v1.2.3 From 200b05246c3e90e61fe6d2e21507b0b936d0ff2b Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 14 Sep 2014 15:07:50 +0200 Subject: AUDIO: Wrap around in the Timestamp constructor The "making of" video in the Xbox version of Myst III is unusually long. VideoDecoder::FixedRateVideoTrack::getFrameTime would trigger an overflow. --- audio/timestamp.cpp | 6 ++---- test/audio/timestamp.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/audio/timestamp.cpp b/audio/timestamp.cpp index 1ce971631c..63752812e1 100644 --- a/audio/timestamp.cpp +++ b/audio/timestamp.cpp @@ -39,12 +39,10 @@ Timestamp::Timestamp(uint ms, uint fr) { Timestamp::Timestamp(uint s, uint frames, uint fr) { assert(fr > 0); - _secs = s; + _secs = s + (frames / fr); _framerateFactor = 1000 / Common::gcd(1000, fr); _framerate = fr * _framerateFactor; - _numFrames = frames * _framerateFactor; - - normalize(); + _numFrames = (frames % fr) * _framerateFactor; } Timestamp Timestamp::convertToFramerate(uint newFramerate) const { diff --git a/test/audio/timestamp.h b/test/audio/timestamp.h index ca56e34a4d..ec42a55ec4 100644 --- a/test/audio/timestamp.h +++ b/test/audio/timestamp.h @@ -2,6 +2,8 @@ #include "audio/timestamp.h" +#include + class TimestampTestSuite : public CxxTest::TestSuite { public: @@ -238,4 +240,15 @@ class TimestampTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(c.numberOfFrames(), 11025); TS_ASSERT_EQUALS(c.totalNumberOfFrames(), 33075); } + + void test_no_overflow() { + // The constructor should not overflow and give incoherent values + const Audio::Timestamp a = Audio::Timestamp(0, UINT_MAX, 1000); + + int secs = UINT_MAX / 1000; + int frames = UINT_MAX % 1000; + + TS_ASSERT_EQUALS(a.secs(), secs); + TS_ASSERT_EQUALS(a.numberOfFrames(), frames); + } }; -- cgit v1.2.3 From d497b45b1c8e13a67946522927dcbbcbc795af9a Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Sun, 21 Dec 2014 03:58:19 -0600 Subject: COMMON: Fix typo that caused uint64 reads to return a uint32 --- common/stream.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/stream.h b/common/stream.h index 5655f0fcb4..251995001c 100644 --- a/common/stream.h +++ b/common/stream.h @@ -266,7 +266,7 @@ public: * if a read error occurred (for which client code can check by * calling err() and eos() ). */ - uint32 readUint64LE() { + uint64 readUint64LE() { uint64 val; read(&val, 8); return FROM_LE_64(val); @@ -305,7 +305,7 @@ public: * if a read error occurred (for which client code can check by * calling err() and eos() ). */ - uint32 readUint64BE() { + uint64 readUint64BE() { uint64 val; read(&val, 8); return FROM_BE_64(val); -- cgit v1.2.3 From 93167fabb55741a9606efa0088cf348c8ff2019e Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Sun, 21 Dec 2014 04:12:43 -0600 Subject: TEST: Create test cases for reading uint64 from a stream --- test/common/memoryreadstream.h | 16 ++++++++++------ test/common/memoryreadstreamendian.h | 32 ++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/test/common/memoryreadstream.h b/test/common/memoryreadstream.h index adef861a5e..79c4079e9b 100644 --- a/test/common/memoryreadstream.h +++ b/test/common/memoryreadstream.h @@ -60,28 +60,32 @@ class MemoryReadStreamTestSuite : public CxxTest::TestSuite { } void test_seek_read_le() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStream ms(contents, sizeof(contents)); TS_ASSERT_EQUALS(ms.readUint16LE(), 0x0201UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32LE(), 0x06050403UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0E0D0C0B0A090807ULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } void test_seek_read_be() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStream ms(contents, sizeof(contents)); TS_ASSERT_EQUALS(ms.readUint16BE(), 0x0102UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32BE(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } diff --git a/test/common/memoryreadstreamendian.h b/test/common/memoryreadstreamendian.h index 35e804c70b..515128ea2a 100644 --- a/test/common/memoryreadstreamendian.h +++ b/test/common/memoryreadstreamendian.h @@ -60,54 +60,62 @@ class MemoryReadStreamEndianTestSuite : public CxxTest::TestSuite { } void test_seek_read_le() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStreamEndian ms(contents, sizeof(contents), false); TS_ASSERT_EQUALS(ms.readUint16LE(), 0x0201UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32LE(), 0x06050403UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0E0D0C0B0A090807ULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } void test_seek_read_be() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStreamEndian ms(contents, sizeof(contents), false); TS_ASSERT_EQUALS(ms.readUint16BE(), 0x0102UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32BE(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } void test_seek_read_le2() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStreamEndian ms(contents, sizeof(contents), false); TS_ASSERT_EQUALS(ms.readUint16(), 0x0201UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32(), 0x06050403UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0E0D0C0B0A090807ULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } void test_seek_read_be2() { - byte contents[] = { 1, 2, 3, 4, 5, 6, 7 }; + byte contents[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; Common::MemoryReadStreamEndian ms(contents, sizeof(contents), true); TS_ASSERT_EQUALS(ms.readUint16(), 0x0102UL); TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readByte(), 0x07); - TS_ASSERT_EQUALS(ms.pos(), 7); + TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.pos(), 14); + TS_ASSERT_EQUALS(ms.readByte(), 0x0F); + TS_ASSERT_EQUALS(ms.pos(), 15); TS_ASSERT(!ms.eos()); } }; -- cgit v1.2.3 From 0433eda4dec8b6ac660aacec2ae3866461214ce3 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 21 Dec 2014 18:25:57 +0000 Subject: CGE2: Add detection for new English freeware version --- engines/cge2/detection.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp index 6e1b93d0b8..4acdea3fde 100644 --- a/engines/cge2/detection.cpp +++ b/engines/cge2/detection.cpp @@ -80,6 +80,16 @@ static const ADGameDescription gameDescriptions[] = { }, Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) }, + + { + "sfinx", "Freeware v1.1", + { + {"vol.cat", 0, "f158e469dccbebc5a632eb848df89779", 129024}, + {"vol.dat", 0, "d40a6b4ae173d6930be54ba56bee15d5", 34182773}, + AD_LISTEND + }, + Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, GUIO1(GAMEOPTION_COLOR_BLIND_DEFAULT_OFF) + }, AD_TABLE_END_MARKER }; -- cgit v1.2.3 From bb1df52da8be0322d5f04ddd371dc3c68eb3812a Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 21 Dec 2014 18:26:40 +0000 Subject: CREDITS: Add credits for Sfinx translation to English --- AUTHORS | 6 ++++++ devtools/credits.pl | 6 ++++++ gui/credits.h | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/AUTHORS b/AUTHORS index 9470217230..8e90a625c9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -524,6 +524,12 @@ Other contributions Victor Gonzalez - Soltys Spanish translation Alejandro Gomez de la Munoza - Soltys Spanish translation + CGE2: + Arnaud Boutonne - Sfinx English translation + Thierry Crozat - Sfinx English translation + Peter Bozso - Sfinx English translation editor + Ryan Clark - Sfinx English translation editor + Drascula: Thierry Crozat - Improve French translation diff --git a/devtools/credits.pl b/devtools/credits.pl index 1c2ece80ed..e919c0b8ba 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -1092,6 +1092,12 @@ begin_credits("Credits"); add_person("Víctor González", "IlDucci", "Soltys Spanish translation"); add_person("Alejandro Gómez de la Muñoza", "TheFireRed", "Soltys Spanish translation"); end_section(); + begin_section("CGE2"); + add_person("Arnaud Boutonné", "Strangerke", "Sfinx English translation"); + add_person("Thierry Crozat", "criezy", "Sfinx English translation"); + add_person("Peter Bozsó", "uruk", "Sfinx English translation editor"); + add_person("Ryan Clark", "", "Sfinx English translation editor"); + end_section(); begin_section("Drascula"); add_person("Thierry Crozat", "criezy", "Improve French translation"); end_section(); diff --git a/gui/credits.h b/gui/credits.h index 5b33797a63..0610609983 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -630,6 +630,18 @@ static const char *credits[] = { "C0""Alejandro G\363mez de la Mu\361oza", "C2""Soltys Spanish translation", "", +"C1""CGE2", +"A0""Arnaud Boutonne", +"C0""Arnaud Boutonn\351", +"C2""Sfinx English translation", +"C0""Thierry Crozat", +"C2""Sfinx English translation", +"A0""Peter Bozso", +"C0""Peter Bozs\363", +"C2""Sfinx English translation editor", +"C0""Ryan Clark", +"C2""Sfinx English translation editor", +"", "C1""Drascula", "C0""Thierry Crozat", "C2""Improve French translation", -- cgit v1.2.3 From e34b5be8e3d4842e273f08821b6a7bd7ba65e843 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 21 Dec 2014 22:13:28 +0200 Subject: MT32: Update to munt 1.5.0 This syncs with munt commit 4041a16a5d --- NEWS | 3 + audio/softsynth/mt32/Analog.cpp | 348 ++++++++++++++++++++++++ audio/softsynth/mt32/Analog.h | 57 ++++ audio/softsynth/mt32/BReverbModel.cpp | 10 +- audio/softsynth/mt32/BReverbModel.h | 2 +- audio/softsynth/mt32/LA32FloatWaveGenerator.cpp | 2 +- audio/softsynth/mt32/LA32Ramp.cpp | 2 +- audio/softsynth/mt32/LA32WaveGenerator.cpp | 10 +- audio/softsynth/mt32/MemoryRegion.h | 124 +++++++++ audio/softsynth/mt32/MidiEventQueue.h | 67 +++++ audio/softsynth/mt32/Part.cpp | 1 + audio/softsynth/mt32/Partial.cpp | 5 +- audio/softsynth/mt32/PartialManager.cpp | 1 + audio/softsynth/mt32/Poly.cpp | 1 + audio/softsynth/mt32/Poly.h | 1 + audio/softsynth/mt32/ROMInfo.cpp | 15 +- audio/softsynth/mt32/ROMInfo.h | 4 +- audio/softsynth/mt32/Structures.h | 47 ++-- audio/softsynth/mt32/Synth.cpp | 248 +++++++++++------ audio/softsynth/mt32/Synth.h | 347 +++++++++-------------- audio/softsynth/mt32/TVA.cpp | 1 + audio/softsynth/mt32/TVF.cpp | 1 + audio/softsynth/mt32/TVP.cpp | 1 + audio/softsynth/mt32/Tables.cpp | 5 +- audio/softsynth/mt32/Tables.h | 15 +- audio/softsynth/mt32/Types.h | 40 +++ audio/softsynth/mt32/internals.h | 83 ++++++ audio/softsynth/mt32/module.mk | 1 + audio/softsynth/mt32/mt32emu.h | 67 +---- 29 files changed, 1086 insertions(+), 423 deletions(-) create mode 100644 audio/softsynth/mt32/Analog.cpp create mode 100644 audio/softsynth/mt32/Analog.h create mode 100644 audio/softsynth/mt32/MemoryRegion.h create mode 100644 audio/softsynth/mt32/MidiEventQueue.h create mode 100644 audio/softsynth/mt32/Types.h create mode 100644 audio/softsynth/mt32/internals.h diff --git a/NEWS b/NEWS index 762af70962..470ddc01bd 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ For a more comprehensive changelog of the latest experimental code, see: New Games: - Added support for Sfinx. + General: + - Updated Munt MT-32 emulation code to version 1.5.0. + Broken Sword 1: - Fix speech endianness detection on big endian systems for the mac version (bug #6720). diff --git a/audio/softsynth/mt32/Analog.cpp b/audio/softsynth/mt32/Analog.cpp new file mode 100644 index 0000000000..8ac28e401a --- /dev/null +++ b/audio/softsynth/mt32/Analog.cpp @@ -0,0 +1,348 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +//#include +#include "Analog.h" + +namespace MT32Emu { + +#if MT32EMU_USE_FLOAT_SAMPLES + +/* FIR approximation of the overall impulse response of the cascade composed of the sample & hold circuit and the low pass filter + * of the MT-32 first generation. + * The coefficients below are found by windowing the inverse DFT of the 1024 pin frequency response converted to the minimum phase. + * The frequency response of the LPF is computed directly, the effect of the S&H is approximated by multiplying the LPF frequency + * response by the corresponding sinc. Although, the LPF has DC gain of 3.2, we ignore this in the emulation and use normalised model. + * The peak gain of the normalised cascade appears about 1.7 near 11.8 kHz. Relative error doesn't exceed 1% for the frequencies + * below 12.5 kHz. In the higher frequency range, the relative error is below 8%. Peak error value is at 16 kHz. + */ +static const float COARSE_LPF_TAPS_MT32[] = { + 1.272473681f, -0.220267785f, -0.158039905f, 0.179603785f, -0.111484097f, 0.054137498f, -0.023518029f, 0.010997169f, -0.006935698f +}; + +// Similar approximation for new MT-32 and CM-32L/LAPC-I LPF. As the voltage controlled amplifier was introduced, LPF has unity DC gain. +// The peak gain value shifted towards higher frequencies and a bit higher about 1.83 near 13 kHz. +static const float COARSE_LPF_TAPS_CM32L[] = { + 1.340615635f, -0.403331694f, 0.036005517f, 0.066156844f, -0.069672532f, 0.049563806f, -0.031113416f, 0.019169774f, -0.012421368f +}; + +#else + +static const unsigned int COARSE_LPF_FRACTION_BITS = 14; + +// Integer versions of the FIRs above multiplied by (1 << 14) and rounded. +static const SampleEx COARSE_LPF_TAPS_MT32[] = { + 20848, -3609, -2589, 2943, -1827, 887, -385, 180, -114 +}; + +static const SampleEx COARSE_LPF_TAPS_CM32L[] = { + 21965, -6608, 590, 1084, -1142, 812, -510, 314, -204 +}; + +#endif + +/* Combined FIR that both approximates the impulse response of the analogue circuits of sample & hold and the low pass filter + * in the audible frequency range (below 20 kHz) and attenuates unwanted mirror spectra above 28 kHz as well. It is a polyphase + * filter intended for resampling the signal to 48 kHz yet for applying high frequency boost. + * As with the filter above, the analogue LPF frequency response is obtained for 1536 pin grid for range up to 96 kHz and multiplied + * by the corresponding sinc. The result is further squared, windowed and passed to generalised Parks-McClellan routine as a desired response. + * Finally, the minimum phase factor is found that's essentially the coefficients below. + * Relative error in the audible frequency range doesn't exceed 0.0006%, attenuation in the stopband is better than 100 dB. + * This level of performance makes it nearly bit-accurate for standard 16-bit sample resolution. + */ + +// FIR version for MT-32 first generation. +static const float ACCURATE_LPF_TAPS_MT32[] = { + 0.003429281f, 0.025929869f, 0.096587777f, 0.228884848f, 0.372413431f, 0.412386503f, 0.263980018f, + -0.014504962f, -0.237394528f, -0.257043496f, -0.103436603f, 0.063996095f, 0.124562333f, 0.083703206f, + 0.013921662f, -0.033475018f, -0.046239712f, -0.029310921f, 0.00126585f, 0.021060961f, 0.017925605f, + 0.003559874f, -0.005105248f, -0.005647917f, -0.004157918f, -0.002065664f, 0.00158747f, 0.003762585f, + 0.001867137f, -0.001090028f, -0.001433979f, -0.00022367f, 4.34308E-05f, -0.000247827f, 0.000157087f, + 0.000605823f, 0.000197317f, -0.000370511f, -0.000261202f, 9.96069E-05f, 9.85073E-05f, -5.28754E-05f, + -1.00912E-05f, 7.69943E-05f, 2.03162E-05f, -5.67967E-05f, -3.30637E-05f, 1.61958E-05f, 1.73041E-05f +}; + +// FIR version for new MT-32 and CM-32L/LAPC-I. +static const float ACCURATE_LPF_TAPS_CM32L[] = { + 0.003917452f, 0.030693861f, 0.116424199f, 0.275101674f, 0.43217361f, 0.431247894f, 0.183255659f, + -0.174955671f, -0.354240244f, -0.212401714f, 0.072259178f, 0.204655344f, 0.108336211f, -0.039099027f, + -0.075138174f, -0.026261906f, 0.00582663f, 0.003052193f, 0.00613657f, 0.017017951f, 0.008732535f, + -0.011027427f, -0.012933664f, 0.001158097f, 0.006765958f, 0.00046778f, -0.002191106f, 0.001561017f, + 0.001842871f, -0.001996876f, -0.002315836f, 0.000980965f, 0.001817454f, -0.000243272f, -0.000972848f, + 0.000149941f, 0.000498886f, -0.000204436f, -0.000347415f, 0.000142386f, 0.000249137f, -4.32946E-05f, + -0.000131231f, 3.88575E-07f, 4.48813E-05f, -1.31906E-06f, -1.03499E-05f, 7.71971E-06f, 2.86721E-06f +}; + +// According to the CM-64 PCB schematic, there is a difference in the values of the LPF entrance resistors for the reverb and non-reverb channels. +// This effectively results in non-unity LPF DC gain for the reverb channel of 0.68 while the LPF has unity DC gain for the LA32 output channels. +// In emulation, the reverb output gain is multiplied by this factor to compensate for the LPF gain difference. +static const float CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR = 0.68f; + +static const unsigned int OUTPUT_GAIN_FRACTION_BITS = 8; +static const float OUTPUT_GAIN_MULTIPLIER = float(1 << OUTPUT_GAIN_FRACTION_BITS); + +static const unsigned int COARSE_LPF_DELAY_LINE_LENGTH = 8; // Must be a power of 2 +static const unsigned int ACCURATE_LPF_DELAY_LINE_LENGTH = 16; // Must be a power of 2 +static const unsigned int ACCURATE_LPF_NUMBER_OF_PHASES = 3; // Upsampling factor +static const unsigned int ACCURATE_LPF_PHASE_INCREMENT_REGULAR = 2; // Downsampling factor +static const unsigned int ACCURATE_LPF_PHASE_INCREMENT_OVERSAMPLED = 1; // No downsampling +static const Bit32u ACCURATE_LPF_DELTAS_REGULAR[][ACCURATE_LPF_NUMBER_OF_PHASES] = { { 0, 0, 0 }, { 1, 1, 0 }, { 1, 2, 1 } }; +static const Bit32u ACCURATE_LPF_DELTAS_OVERSAMPLED[][ACCURATE_LPF_NUMBER_OF_PHASES] = { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 } }; + +class AbstractLowPassFilter { +public: + static AbstractLowPassFilter &createLowPassFilter(AnalogOutputMode mode, bool oldMT32AnalogLPF); + static void muteRingBuffer(SampleEx *ringBuffer, unsigned int length); + + virtual ~AbstractLowPassFilter() {} + virtual SampleEx process(SampleEx sample) = 0; + virtual bool hasNextSample() const; + virtual unsigned int getOutputSampleRate() const; + virtual unsigned int estimateInSampleCount(unsigned int outSamples) const; + virtual void addPositionIncrement(unsigned int) {} +}; + +class NullLowPassFilter : public AbstractLowPassFilter { +public: + SampleEx process(SampleEx sample); +}; + +class CoarseLowPassFilter : public AbstractLowPassFilter { +private: + const SampleEx * const LPF_TAPS; + SampleEx ringBuffer[COARSE_LPF_DELAY_LINE_LENGTH]; + unsigned int ringBufferPosition; + +public: + CoarseLowPassFilter(bool oldMT32AnalogLPF); + SampleEx process(SampleEx sample); +}; + +class AccurateLowPassFilter : public AbstractLowPassFilter { +private: + const float * const LPF_TAPS; + const Bit32u (* const deltas)[ACCURATE_LPF_NUMBER_OF_PHASES]; + const unsigned int phaseIncrement; + const unsigned int outputSampleRate; + + SampleEx ringBuffer[ACCURATE_LPF_DELAY_LINE_LENGTH]; + unsigned int ringBufferPosition; + unsigned int phase; + +public: + AccurateLowPassFilter(bool oldMT32AnalogLPF, bool oversample); + SampleEx process(SampleEx sample); + bool hasNextSample() const; + unsigned int getOutputSampleRate() const; + unsigned int estimateInSampleCount(unsigned int outSamples) const; + void addPositionIncrement(unsigned int positionIncrement); +}; + +Analog::Analog(const AnalogOutputMode mode, const ControlROMFeatureSet *controlROMFeatures) : + leftChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())), + rightChannelLPF(AbstractLowPassFilter::createLowPassFilter(mode, controlROMFeatures->isOldMT32AnalogLPF())), + synthGain(0), + reverbGain(0) +{} + +Analog::~Analog() { + delete &leftChannelLPF; + delete &rightChannelLPF; +} + +void Analog::process(Sample **outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, Bit32u outLength) { + if (outStream == NULL) { + leftChannelLPF.addPositionIncrement(outLength); + rightChannelLPF.addPositionIncrement(outLength); + return; + } + + while (0 < (outLength--)) { + SampleEx outSampleL; + SampleEx outSampleR; + + if (leftChannelLPF.hasNextSample()) { + outSampleL = leftChannelLPF.process(0); + outSampleR = rightChannelLPF.process(0); + } else { + SampleEx inSampleL = ((SampleEx)*(nonReverbLeft++) + (SampleEx)*(reverbDryLeft++)) * synthGain + (SampleEx)*(reverbWetLeft++) * reverbGain; + SampleEx inSampleR = ((SampleEx)*(nonReverbRight++) + (SampleEx)*(reverbDryRight++)) * synthGain + (SampleEx)*(reverbWetRight++) * reverbGain; + +#if !MT32EMU_USE_FLOAT_SAMPLES + inSampleL >>= OUTPUT_GAIN_FRACTION_BITS; + inSampleR >>= OUTPUT_GAIN_FRACTION_BITS; +#endif + + outSampleL = leftChannelLPF.process(inSampleL); + outSampleR = rightChannelLPF.process(inSampleR); + } + + *((*outStream)++) = Synth::clipSampleEx(outSampleL); + *((*outStream)++) = Synth::clipSampleEx(outSampleR); + } +} + +unsigned int Analog::getOutputSampleRate() const { + return leftChannelLPF.getOutputSampleRate(); +} + +Bit32u Analog::getDACStreamsLength(Bit32u outputLength) const { + return leftChannelLPF.estimateInSampleCount(outputLength); +} + +void Analog::setSynthOutputGain(float useSynthGain) { +#if MT32EMU_USE_FLOAT_SAMPLES + synthGain = useSynthGain; +#else + if (OUTPUT_GAIN_MULTIPLIER < useSynthGain) useSynthGain = OUTPUT_GAIN_MULTIPLIER; + synthGain = SampleEx(useSynthGain * OUTPUT_GAIN_MULTIPLIER); +#endif +} + +void Analog::setReverbOutputGain(float useReverbGain, bool mt32ReverbCompatibilityMode) { + if (!mt32ReverbCompatibilityMode) useReverbGain *= CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR; +#if MT32EMU_USE_FLOAT_SAMPLES + reverbGain = useReverbGain; +#else + if (OUTPUT_GAIN_MULTIPLIER < useReverbGain) useReverbGain = OUTPUT_GAIN_MULTIPLIER; + reverbGain = SampleEx(useReverbGain * OUTPUT_GAIN_MULTIPLIER); +#endif +} + +AbstractLowPassFilter &AbstractLowPassFilter::createLowPassFilter(AnalogOutputMode mode, bool oldMT32AnalogLPF) { + switch (mode) { + case AnalogOutputMode_COARSE: + return *new CoarseLowPassFilter(oldMT32AnalogLPF); + case AnalogOutputMode_ACCURATE: + return *new AccurateLowPassFilter(oldMT32AnalogLPF, false); + case AnalogOutputMode_OVERSAMPLED: + return *new AccurateLowPassFilter(oldMT32AnalogLPF, true); + default: + return *new NullLowPassFilter; + } +} + +void AbstractLowPassFilter::muteRingBuffer(SampleEx *ringBuffer, unsigned int length) { + +#if MT32EMU_USE_FLOAT_SAMPLES + + SampleEx *p = ringBuffer; + while (length--) { + *(p++) = 0.0f; + } + +#else + + memset(ringBuffer, 0, length * sizeof(SampleEx)); + +#endif + +} + +bool AbstractLowPassFilter::hasNextSample() const { + return false; +} + +unsigned int AbstractLowPassFilter::getOutputSampleRate() const { + return SAMPLE_RATE; +} + +unsigned int AbstractLowPassFilter::estimateInSampleCount(unsigned int outSamples) const { + return outSamples; +} + +SampleEx NullLowPassFilter::process(const SampleEx inSample) { + return inSample; +} + +CoarseLowPassFilter::CoarseLowPassFilter(bool oldMT32AnalogLPF) : + LPF_TAPS(oldMT32AnalogLPF ? COARSE_LPF_TAPS_MT32 : COARSE_LPF_TAPS_CM32L), + ringBufferPosition(0) +{ + muteRingBuffer(ringBuffer, COARSE_LPF_DELAY_LINE_LENGTH); +} + +SampleEx CoarseLowPassFilter::process(const SampleEx inSample) { + static const unsigned int DELAY_LINE_MASK = COARSE_LPF_DELAY_LINE_LENGTH - 1; + + SampleEx sample = LPF_TAPS[COARSE_LPF_DELAY_LINE_LENGTH] * ringBuffer[ringBufferPosition]; + ringBuffer[ringBufferPosition] = Synth::clipSampleEx(inSample); + + for (unsigned int i = 0; i < COARSE_LPF_DELAY_LINE_LENGTH; i++) { + sample += LPF_TAPS[i] * ringBuffer[(i + ringBufferPosition) & DELAY_LINE_MASK]; + } + + ringBufferPosition = (ringBufferPosition - 1) & DELAY_LINE_MASK; + +#if !MT32EMU_USE_FLOAT_SAMPLES + sample >>= COARSE_LPF_FRACTION_BITS; +#endif + + return sample; +} + +AccurateLowPassFilter::AccurateLowPassFilter(const bool oldMT32AnalogLPF, const bool oversample) : + LPF_TAPS(oldMT32AnalogLPF ? ACCURATE_LPF_TAPS_MT32 : ACCURATE_LPF_TAPS_CM32L), + deltas(oversample ? ACCURATE_LPF_DELTAS_OVERSAMPLED : ACCURATE_LPF_DELTAS_REGULAR), + phaseIncrement(oversample ? ACCURATE_LPF_PHASE_INCREMENT_OVERSAMPLED : ACCURATE_LPF_PHASE_INCREMENT_REGULAR), + outputSampleRate(SAMPLE_RATE * ACCURATE_LPF_NUMBER_OF_PHASES / phaseIncrement), + ringBufferPosition(0), + phase(0) +{ + muteRingBuffer(ringBuffer, ACCURATE_LPF_DELAY_LINE_LENGTH); +} + +SampleEx AccurateLowPassFilter::process(const SampleEx inSample) { + static const unsigned int DELAY_LINE_MASK = ACCURATE_LPF_DELAY_LINE_LENGTH - 1; + + float sample = (phase == 0) ? LPF_TAPS[ACCURATE_LPF_DELAY_LINE_LENGTH * ACCURATE_LPF_NUMBER_OF_PHASES] * ringBuffer[ringBufferPosition] : 0.0f; + if (!hasNextSample()) { + ringBuffer[ringBufferPosition] = inSample; + } + + for (unsigned int tapIx = phase, delaySampleIx = 0; delaySampleIx < ACCURATE_LPF_DELAY_LINE_LENGTH; delaySampleIx++, tapIx += ACCURATE_LPF_NUMBER_OF_PHASES) { + sample += LPF_TAPS[tapIx] * ringBuffer[(delaySampleIx + ringBufferPosition) & DELAY_LINE_MASK]; + } + + phase += phaseIncrement; + if (ACCURATE_LPF_NUMBER_OF_PHASES <= phase) { + phase -= ACCURATE_LPF_NUMBER_OF_PHASES; + ringBufferPosition = (ringBufferPosition - 1) & DELAY_LINE_MASK; + } + + return SampleEx(ACCURATE_LPF_NUMBER_OF_PHASES * sample); +} + +bool AccurateLowPassFilter::hasNextSample() const { + return phaseIncrement <= phase; +} + +unsigned int AccurateLowPassFilter::getOutputSampleRate() const { + return outputSampleRate; +} + +unsigned int AccurateLowPassFilter::estimateInSampleCount(unsigned int outSamples) const { + Bit32u cycleCount = outSamples / ACCURATE_LPF_NUMBER_OF_PHASES; + Bit32u remainder = outSamples - cycleCount * ACCURATE_LPF_NUMBER_OF_PHASES; + return cycleCount * phaseIncrement + deltas[remainder][phase]; +} + +void AccurateLowPassFilter::addPositionIncrement(const unsigned int positionIncrement) { + phase = (phase + positionIncrement * phaseIncrement) % ACCURATE_LPF_NUMBER_OF_PHASES; +} + +} diff --git a/audio/softsynth/mt32/Analog.h b/audio/softsynth/mt32/Analog.h new file mode 100644 index 0000000000..a48db72485 --- /dev/null +++ b/audio/softsynth/mt32/Analog.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MT32EMU_ANALOG_H +#define MT32EMU_ANALOG_H + +#include "mt32emu.h" + +namespace MT32Emu { + +class AbstractLowPassFilter; + +/* Analog class is dedicated to perform fair emulation of analogue circuitry of hardware units that is responsible + * for processing output signal after the DAC. It appears that the analogue circuit labeled "LPF" on the schematic + * also applies audible changes to the signal spectra. There is a significant boost of higher frequencies observed + * aside from quite poor attenuation of the mirror spectra above 16 kHz which is due to a relatively low filter order. + * + * As the final mixing of multiplexed output signal is performed after the DAC, this function is migrated here from Synth. + * Saying precisely, mixing is performed within the LPF as the entrance resistors are actually components of a LPF + * designed using the multiple feedback topology. Nevertheless, the schematic separates them. + */ +class Analog { +public: + Analog(AnalogOutputMode mode, const ControlROMFeatureSet *controlROMFeatures); + ~Analog(); + void process(Sample **outStream, const Sample *nonReverbLeft, const Sample *nonReverbRight, const Sample *reverbDryLeft, const Sample *reverbDryRight, const Sample *reverbWetLeft, const Sample *reverbWetRight, const Bit32u outLength); + unsigned int getOutputSampleRate() const; + Bit32u getDACStreamsLength(Bit32u outputLength) const; + void setSynthOutputGain(float synthGain); + void setReverbOutputGain(float reverbGain, bool mt32ReverbCompatibilityMode); + +private: + AbstractLowPassFilter &leftChannelLPF; + AbstractLowPassFilter &rightChannelLPF; + SampleEx synthGain; + SampleEx reverbGain; + + Analog(Analog &); +}; + +} + +#endif diff --git a/audio/softsynth/mt32/BReverbModel.cpp b/audio/softsynth/mt32/BReverbModel.cpp index 37b3e9670d..5e02db8f99 100644 --- a/audio/softsynth/mt32/BReverbModel.cpp +++ b/audio/softsynth/mt32/BReverbModel.cpp @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -//#include +//#include #include "mt32emu.h" #include "BReverbModel.h" @@ -501,9 +501,9 @@ void BReverbModel::process(const Sample *inLeft, const Sample *inRight, Sample * * Analysing of the algorithm suggests that the overflow is most probable when the combs output is added below. * So, despite this isn't actually accurate, we only add the check here for performance reasons. */ - Sample outSample = Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s((Bit32s)outL1 + Bit32s(outL1 >> 1)) + (Bit32s)outL2) + Bit32s(outL2 >> 1)) + (Bit32s)outL3); + Sample outSample = Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx((SampleEx)outL1 + SampleEx(outL1 >> 1)) + (SampleEx)outL2) + SampleEx(outL2 >> 1)) + (SampleEx)outL3); #else - Sample outSample = Synth::clipBit16s((Bit32s)outL1 + Bit32s(outL1 >> 1) + (Bit32s)outL2 + Bit32s(outL2 >> 1) + (Bit32s)outL3); + Sample outSample = Synth::clipSampleEx((SampleEx)outL1 + SampleEx(outL1 >> 1) + (SampleEx)outL2 + SampleEx(outL2 >> 1) + (SampleEx)outL3); #endif *(outLeft++) = weirdMul(outSample, wetLevel, 0xFF); } @@ -515,9 +515,9 @@ void BReverbModel::process(const Sample *inLeft, const Sample *inRight, Sample * Sample outSample = 1.5f * (outR1 + outR2) + outR3; #elif MT32EMU_BOSS_REVERB_PRECISE_MODE // See the note above for the left channel output. - Sample outSample = Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s(Synth::clipBit16s((Bit32s)outR1 + Bit32s(outR1 >> 1)) + (Bit32s)outR2) + Bit32s(outR2 >> 1)) + (Bit32s)outR3); + Sample outSample = Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx(Synth::clipSampleEx((SampleEx)outR1 + SampleEx(outR1 >> 1)) + (SampleEx)outR2) + SampleEx(outR2 >> 1)) + (SampleEx)outR3); #else - Sample outSample = Synth::clipBit16s((Bit32s)outR1 + Bit32s(outR1 >> 1) + (Bit32s)outR2 + Bit32s(outR2 >> 1) + (Bit32s)outR3); + Sample outSample = Synth::clipSampleEx((SampleEx)outR1 + SampleEx(outR1 >> 1) + (SampleEx)outR2 + SampleEx(outR2 >> 1) + (SampleEx)outR3); #endif *(outRight++) = weirdMul(outSample, wetLevel, 0xFF); } diff --git a/audio/softsynth/mt32/BReverbModel.h b/audio/softsynth/mt32/BReverbModel.h index 9b840900c3..764daf1a9e 100644 --- a/audio/softsynth/mt32/BReverbModel.h +++ b/audio/softsynth/mt32/BReverbModel.h @@ -95,7 +95,6 @@ class BReverbModel { const bool tapDelayMode; Bit32u dryAmp; Bit32u wetLevel; - void mute(); static const BReverbSettings &getCM32L_LAPCSettings(const ReverbMode mode); static const BReverbSettings &getMT32Settings(const ReverbMode mode); @@ -107,6 +106,7 @@ public: void open(); // May be called multiple times without an open() in between. void close(); + void mute(); void setParameters(Bit8u time, Bit8u level); void process(const Sample *inLeft, const Sample *inRight, Sample *outLeft, Sample *outRight, unsigned long numSamples); bool isActive() const; diff --git a/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp b/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp index 9265d80c88..42d820ebad 100644 --- a/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp +++ b/audio/softsynth/mt32/LA32FloatWaveGenerator.cpp @@ -18,7 +18,7 @@ //#include #include "mt32emu.h" #include "mmath.h" -#include "LA32FloatWaveGenerator.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/LA32Ramp.cpp b/audio/softsynth/mt32/LA32Ramp.cpp index 454612c842..2b31a330d2 100644 --- a/audio/softsynth/mt32/LA32Ramp.cpp +++ b/audio/softsynth/mt32/LA32Ramp.cpp @@ -50,8 +50,8 @@ We haven't fully explored: //#include #include "mt32emu.h" -#include "LA32Ramp.h" #include "mmath.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/LA32WaveGenerator.cpp b/audio/softsynth/mt32/LA32WaveGenerator.cpp index 7ac7cc6aaa..765f75fa61 100644 --- a/audio/softsynth/mt32/LA32WaveGenerator.cpp +++ b/audio/softsynth/mt32/LA32WaveGenerator.cpp @@ -15,15 +15,15 @@ * along with this program. If not, see . */ -//#include -#include "mt32emu.h" -#include "mmath.h" -#include "LA32WaveGenerator.h" - #if MT32EMU_USE_FLOAT_SAMPLES #include "LA32FloatWaveGenerator.cpp" #else +//#include +#include "mt32emu.h" +#include "mmath.h" +#include "internals.h" + namespace MT32Emu { static const Bit32u SINE_SEGMENT_RELATIVE_LENGTH = 1 << 18; diff --git a/audio/softsynth/mt32/MemoryRegion.h b/audio/softsynth/mt32/MemoryRegion.h new file mode 100644 index 0000000000..c0cb041e11 --- /dev/null +++ b/audio/softsynth/mt32/MemoryRegion.h @@ -0,0 +1,124 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MT32EMU_MEMORY_REGION_H +#define MT32EMU_MEMORY_REGION_H + +namespace MT32Emu { + +enum MemoryRegionType { + MR_PatchTemp, MR_RhythmTemp, MR_TimbreTemp, MR_Patches, MR_Timbres, MR_System, MR_Display, MR_Reset +}; + +class MemoryRegion { +private: + Synth *synth; + Bit8u *realMemory; + Bit8u *maxTable; +public: + MemoryRegionType type; + Bit32u startAddr, entrySize, entries; + + MemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable, MemoryRegionType useType, Bit32u useStartAddr, Bit32u useEntrySize, Bit32u useEntries) { + synth = useSynth; + realMemory = useRealMemory; + maxTable = useMaxTable; + type = useType; + startAddr = useStartAddr; + entrySize = useEntrySize; + entries = useEntries; + } + int lastTouched(Bit32u addr, Bit32u len) const { + return (offset(addr) + len - 1) / entrySize; + } + int firstTouchedOffset(Bit32u addr) const { + return offset(addr) % entrySize; + } + int firstTouched(Bit32u addr) const { + return offset(addr) / entrySize; + } + Bit32u regionEnd() const { + return startAddr + entrySize * entries; + } + bool contains(Bit32u addr) const { + return addr >= startAddr && addr < regionEnd(); + } + int offset(Bit32u addr) const { + return addr - startAddr; + } + Bit32u getClampedLen(Bit32u addr, Bit32u len) const { + if (addr + len > regionEnd()) + return regionEnd() - addr; + return len; + } + Bit32u next(Bit32u addr, Bit32u len) const { + if (addr + len > regionEnd()) { + return regionEnd() - addr; + } + return 0; + } + Bit8u getMaxValue(int off) const { + if (maxTable == NULL) + return 0xFF; + return maxTable[off % entrySize]; + } + Bit8u *getRealMemory() const { + return realMemory; + } + bool isReadable() const { + return getRealMemory() != NULL; + } + void read(unsigned int entry, unsigned int off, Bit8u *dst, unsigned int len) const; + void write(unsigned int entry, unsigned int off, const Bit8u *src, unsigned int len, bool init = false) const; +}; + +class PatchTempMemoryRegion : public MemoryRegion { +public: + PatchTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_PatchTemp, MT32EMU_MEMADDR(0x030000), sizeof(MemParams::PatchTemp), 9) {} +}; +class RhythmTempMemoryRegion : public MemoryRegion { +public: + RhythmTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_RhythmTemp, MT32EMU_MEMADDR(0x030110), sizeof(MemParams::RhythmTemp), 85) {} +}; +class TimbreTempMemoryRegion : public MemoryRegion { +public: + TimbreTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_TimbreTemp, MT32EMU_MEMADDR(0x040000), sizeof(TimbreParam), 8) {} +}; +class PatchesMemoryRegion : public MemoryRegion { +public: + PatchesMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Patches, MT32EMU_MEMADDR(0x050000), sizeof(PatchParam), 128) {} +}; +class TimbresMemoryRegion : public MemoryRegion { +public: + TimbresMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Timbres, MT32EMU_MEMADDR(0x080000), sizeof(MemParams::PaddedTimbre), 64 + 64 + 64 + 64) {} +}; +class SystemMemoryRegion : public MemoryRegion { +public: + SystemMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_System, MT32EMU_MEMADDR(0x100000), sizeof(MemParams::System), 1) {} +}; +class DisplayMemoryRegion : public MemoryRegion { +public: + DisplayMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Display, MT32EMU_MEMADDR(0x200000), MAX_SYSEX_SIZE - 1, 1) {} +}; +class ResetMemoryRegion : public MemoryRegion { +public: + ResetMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Reset, MT32EMU_MEMADDR(0x7F0000), 0x3FFF, 1) {} +}; + +} + +#endif diff --git a/audio/softsynth/mt32/MidiEventQueue.h b/audio/softsynth/mt32/MidiEventQueue.h new file mode 100644 index 0000000000..b1948c5f8e --- /dev/null +++ b/audio/softsynth/mt32/MidiEventQueue.h @@ -0,0 +1,67 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MT32EMU_MIDI_EVENT_QUEUE_H +#define MT32EMU_MIDI_EVENT_QUEUE_H + +namespace MT32Emu { + +/** + * Used to safely store timestamped MIDI events in a local queue. + */ +struct MidiEvent { + Bit32u shortMessageData; + const Bit8u *sysexData; + Bit32u sysexLength; + Bit32u timestamp; + + ~MidiEvent(); + void setShortMessage(Bit32u shortMessageData, Bit32u timestamp); + void setSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp); +}; + +/** + * Simple queue implementation using a ring buffer to store incoming MIDI event before the synth actually processes it. + * It is intended to: + * - get rid of prerenderer while retaining graceful partial abortion + * - add fair emulation of the MIDI interface delays + * - extend the synth interface with the default implementation of a typical rendering loop. + * THREAD SAFETY: + * It is safe to use either in a single thread environment or when there are only two threads - one performs only reading + * and one performs only writing. More complicated usage requires external synchronisation. + */ +class MidiEventQueue { +private: + MidiEvent * const ringBuffer; + const Bit32u ringBufferMask; + volatile Bit32u startPosition; + volatile Bit32u endPosition; + +public: + MidiEventQueue(Bit32u ringBufferSize = DEFAULT_MIDI_EVENT_QUEUE_SIZE); // Must be a power of 2 + ~MidiEventQueue(); + void reset(); + bool pushShortMessage(Bit32u shortMessageData, Bit32u timestamp); + bool pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp); + const MidiEvent *peekMidiEvent(); + void dropMidiEvent(); + bool isFull() const; +}; + +} + +#endif diff --git a/audio/softsynth/mt32/Part.cpp b/audio/softsynth/mt32/Part.cpp index d92473b5db..cffc3ed744 100644 --- a/audio/softsynth/mt32/Part.cpp +++ b/audio/softsynth/mt32/Part.cpp @@ -19,6 +19,7 @@ //#include #include "mt32emu.h" +#include "internals.h" #include "PartialManager.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/Partial.cpp b/audio/softsynth/mt32/Partial.cpp index 7dcc6e945a..7348087509 100644 --- a/audio/softsynth/mt32/Partial.cpp +++ b/audio/softsynth/mt32/Partial.cpp @@ -21,6 +21,7 @@ #include "mt32emu.h" #include "mmath.h" +#include "internals.h" namespace MT32Emu { @@ -312,8 +313,8 @@ bool Partial::produceOutput(Sample *leftBuf, Sample *rightBuf, unsigned long len // Though, it is unknown whether this overflow is exploited somewhere. Sample leftOut = Sample((sample * leftPanValue) >> 8); Sample rightOut = Sample((sample * rightPanValue) >> 8); - *leftBuf = Synth::clipBit16s((Bit32s)*leftBuf + (Bit32s)leftOut); - *rightBuf = Synth::clipBit16s((Bit32s)*rightBuf + (Bit32s)rightOut); + *leftBuf = Synth::clipSampleEx((SampleEx)*leftBuf + (SampleEx)leftOut); + *rightBuf = Synth::clipSampleEx((SampleEx)*rightBuf + (SampleEx)rightOut); leftBuf++; rightBuf++; #endif diff --git a/audio/softsynth/mt32/PartialManager.cpp b/audio/softsynth/mt32/PartialManager.cpp index fe73087581..8ca6e4e3d7 100644 --- a/audio/softsynth/mt32/PartialManager.cpp +++ b/audio/softsynth/mt32/PartialManager.cpp @@ -18,6 +18,7 @@ //#include #include "mt32emu.h" +#include "internals.h" #include "PartialManager.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/Poly.cpp b/audio/softsynth/mt32/Poly.cpp index e07ceb4231..badcd8fb96 100644 --- a/audio/softsynth/mt32/Poly.cpp +++ b/audio/softsynth/mt32/Poly.cpp @@ -16,6 +16,7 @@ */ #include "mt32emu.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/Poly.h b/audio/softsynth/mt32/Poly.h index 9c6431ce36..e2614369bb 100644 --- a/audio/softsynth/mt32/Poly.h +++ b/audio/softsynth/mt32/Poly.h @@ -21,6 +21,7 @@ namespace MT32Emu { class Part; +class Partial; enum PolyState { POLY_Playing, diff --git a/audio/softsynth/mt32/ROMInfo.cpp b/audio/softsynth/mt32/ROMInfo.cpp index eb9622620f..7c0127078b 100644 --- a/audio/softsynth/mt32/ROMInfo.cpp +++ b/audio/softsynth/mt32/ROMInfo.cpp @@ -21,8 +21,8 @@ namespace MT32Emu { static const ROMInfo *getKnownROMInfoFromList(unsigned int index) { - static const ControlROMFeatureSet MT32_COMPATIBLE(true); - static const ControlROMFeatureSet CM32L_COMPATIBLE(false); + static const ControlROMFeatureSet MT32_COMPATIBLE(true, true); + static const ControlROMFeatureSet CM32L_COMPATIBLE(false, false); // Known ROMs static const ROMInfo CTRL_MT32_V1_04 = {65536, "5a5cb5a77d7d55ee69657c2f870416daed52dea7", ROMInfo::Control, "ctrl_mt32_1_04", "MT-32 Control v1.04", ROMInfo::Full, NULL, &MT32_COMPATIBLE}; @@ -106,7 +106,6 @@ void ROMImage::freeROMImage(const ROMImage *romImage) { delete romImage; } - Common::File* ROMImage::getFile() const { return file; } @@ -115,11 +114,17 @@ const ROMInfo* ROMImage::getROMInfo() const { return romInfo; } -ControlROMFeatureSet::ControlROMFeatureSet(bool useDefaultReverbMT32Compatible) : defaultReverbMT32Compatible(useDefaultReverbMT32Compatible) { -} +ControlROMFeatureSet::ControlROMFeatureSet(bool useDefaultReverbMT32Compatible, bool useOldMT32AnalogLPF) : + defaultReverbMT32Compatible(useDefaultReverbMT32Compatible), + oldMT32AnalogLPF(useOldMT32AnalogLPF) +{} bool ControlROMFeatureSet::isDefaultReverbMT32Compatible() const { return defaultReverbMT32Compatible; } +bool ControlROMFeatureSet::isOldMT32AnalogLPF() const { + return oldMT32AnalogLPF; +} + } diff --git a/audio/softsynth/mt32/ROMInfo.h b/audio/softsynth/mt32/ROMInfo.h index cecbb6054f..4682620a15 100644 --- a/audio/softsynth/mt32/ROMInfo.h +++ b/audio/softsynth/mt32/ROMInfo.h @@ -77,10 +77,12 @@ public: struct ControlROMFeatureSet { private: unsigned int defaultReverbMT32Compatible : 1; + unsigned int oldMT32AnalogLPF : 1; public: - ControlROMFeatureSet(bool defaultReverbMT32Compatible); + ControlROMFeatureSet(bool defaultReverbMT32Compatible, bool oldMT32AnalogLPF); bool isDefaultReverbMT32Compatible() const; + bool isOldMT32AnalogLPF() const; }; } diff --git a/audio/softsynth/mt32/Structures.h b/audio/softsynth/mt32/Structures.h index 35dcee90d6..4dada3a847 100644 --- a/audio/softsynth/mt32/Structures.h +++ b/audio/softsynth/mt32/Structures.h @@ -31,19 +31,6 @@ namespace MT32Emu { #define MT32EMU_ALIGN_PACKED __attribute__((packed)) #endif -typedef unsigned int Bit32u; -typedef signed int Bit32s; -typedef unsigned short int Bit16u; -typedef signed short int Bit16s; -typedef unsigned char Bit8u; -typedef signed char Bit8s; - -#if MT32EMU_USE_FLOAT_SAMPLES -typedef float Sample; -#else -typedef Bit16s Sample; -#endif - // The following structures represent the MT-32's memory // Since sysex allows this memory to be written to in blocks of bytes, // we keep this packed so that we can copy data into the various @@ -184,7 +171,37 @@ struct MemParams { #pragma pack() #endif -struct ControlROMPCMStruct; +struct ControlROMMap { + Bit16u idPos; + Bit16u idLen; + const char *idBytes; + Bit16u pcmTable; // 4 * pcmCount bytes + Bit16u pcmCount; + Bit16u timbreAMap; // 128 bytes + Bit16u timbreAOffset; + bool timbreACompressed; + Bit16u timbreBMap; // 128 bytes + Bit16u timbreBOffset; + bool timbreBCompressed; + Bit16u timbreRMap; // 2 * timbreRCount bytes + Bit16u timbreRCount; + Bit16u rhythmSettings; // 4 * rhythmSettingsCount bytes + Bit16u rhythmSettingsCount; + Bit16u reserveSettings; // 9 bytes + Bit16u panSettings; // 8 bytes + Bit16u programSettings; // 8 bytes + Bit16u rhythmMaxTable; // 4 bytes + Bit16u patchMaxTable; // 16 bytes + Bit16u systemMaxTable; // 23 bytes + Bit16u timbreMaxTable; // 72 bytes +}; + +struct ControlROMPCMStruct { + Bit8u pos; + Bit8u len; + Bit8u pitchLSB; + Bit8u pitchMSB; +}; struct PCMWaveEntry { Bit32u addr; @@ -216,8 +233,6 @@ struct PatchCache { const TimbreParam::PartialParam *partialParam; }; -class Partial; // Forward reference for class defined in partial.h - } #endif diff --git a/audio/softsynth/mt32/Synth.cpp b/audio/softsynth/mt32/Synth.cpp index 3bff429875..6df7eb9e31 100644 --- a/audio/softsynth/mt32/Synth.cpp +++ b/audio/softsynth/mt32/Synth.cpp @@ -22,12 +22,19 @@ #include "mt32emu.h" #include "mmath.h" -#include "PartialManager.h" +#include "internals.h" + +#include "Analog.h" #include "BReverbModel.h" -#include "common/debug.h" +#include "MemoryRegion.h" +#include "MidiEventQueue.h" +#include "PartialManager.h" namespace MT32Emu { +// MIDI interface data transfer rate in samples. Used to simulate the transfer delay. +static const double MIDI_DATA_TRANSFER_RATE = (double)SAMPLE_RATE / 31250.0 * 8.0; + static const ControlROMMap ControlROMMaps[7] = { // ID IDc IDbytes PCMmap PCMc tmbrA tmbrAO, tmbrAC tmbrB tmbrBO, tmbrBC tmbrR trC rhythm rhyC rsrv panpot prog rhyMax patMax sysMax timMax {0x4014, 22, "\000 ver1.04 14 July 87 ", 0x3000, 128, 0x8000, 0x0000, false, 0xC000, 0x4000, false, 0x3200, 30, 0x73A6, 85, 0x57C7, 0x57E2, 0x57D0, 0x5252, 0x525E, 0x526E, 0x520A}, @@ -46,18 +53,15 @@ static inline void advanceStreamPosition(Sample *&stream, Bit32u posDelta) { } } -Bit8u Synth::calcSysexChecksum(const Bit8u *data, Bit32u len, Bit8u checksum) { +Bit8u Synth::calcSysexChecksum(const Bit8u *data, const Bit32u len, const Bit8u initChecksum) { + unsigned int checksum = -initChecksum; for (unsigned int i = 0; i < len; i++) { - checksum = checksum + data[i]; + checksum -= data[i]; } - checksum = checksum & 0x7f; - if (checksum) { - checksum = 0x80 - checksum; - } - return checksum; + return Bit8u(checksum & 0x7f); } -Synth::Synth(ReportHandler *useReportHandler) { +Synth::Synth(ReportHandler *useReportHandler) : mt32ram(*new MemParams()), mt32default(*new MemParams()) { isOpen = false; reverbOverridden = false; partialCount = DEFAULT_MAX_PARTIALS; @@ -75,6 +79,7 @@ Synth::Synth(ReportHandler *useReportHandler) { reverbModels[i] = NULL; } reverbModel = NULL; + analog = NULL; setDACInputMode(DACInputMode_NICE); setMIDIDelayMode(MIDIDelayMode_DELAY_SHORT_MESSAGES_ONLY); setOutputGain(1.0f); @@ -92,6 +97,8 @@ Synth::~Synth() { if (isDefaultReportHandler) { delete reportHandler; } + delete &mt32ram; + delete &mt32default; } void ReportHandler::showLCDMessage(const char *data) { @@ -126,7 +133,7 @@ void Synth::printDebug(const char *fmt, ...) { va_list ap; va_start(ap, fmt); #if MT32EMU_DEBUG_SAMPLESTAMPS > 0 - reportHandler->printDebug("[%u] ", renderedSampleCount); + reportHandler->printDebug("[%u] ", (char *)&renderedSampleCount); #endif reportHandler->printDebug(fmt, ap); va_end(ap); @@ -211,10 +218,7 @@ MIDIDelayMode Synth::getMIDIDelayMode() const { void Synth::setOutputGain(float newOutputGain) { if (newOutputGain < 0.0f) newOutputGain = -newOutputGain; outputGain = newOutputGain; -#if !MT32EMU_USE_FLOAT_SAMPLES - if (256.0f < newOutputGain) newOutputGain = 256.0f; - effectiveOutputGain = int(newOutputGain * 256.0f); -#endif + if (analog != NULL) analog->setSynthOutputGain(newOutputGain); } float Synth::getOutputGain() const { @@ -224,13 +228,7 @@ float Synth::getOutputGain() const { void Synth::setReverbOutputGain(float newReverbOutputGain) { if (newReverbOutputGain < 0.0f) newReverbOutputGain = -newReverbOutputGain; reverbOutputGain = newReverbOutputGain; - if (!isMT32ReverbCompatibilityMode()) newReverbOutputGain *= CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR; -#if MT32EMU_USE_FLOAT_SAMPLES - effectiveReverbOutputGain = newReverbOutputGain; -#else - if (256.0f < newReverbOutputGain) newReverbOutputGain = 256.0f; - effectiveReverbOutputGain = int(newReverbOutputGain * 256.0f); -#endif + if (analog != NULL) analog->setReverbOutputGain(newReverbOutputGain, isMT32ReverbCompatibilityMode()); } float Synth::getReverbOutputGain() const { @@ -393,7 +391,11 @@ bool Synth::initTimbres(Bit16u mapAddress, Bit16u offset, int count, int startTi return true; } -bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount) { +bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, AnalogOutputMode analogOutputMode) { + return open(controlROMImage, pcmROMImage, DEFAULT_MAX_PARTIALS, analogOutputMode); +} + +bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount, AnalogOutputMode analogOutputMode) { if (isOpen) { return false; } @@ -548,6 +550,10 @@ bool Synth::open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, u midiQueue = new MidiEventQueue(); + analog = new Analog(analogOutputMode, controlROMFeatures); + setOutputGain(outputGain); + setReverbOutputGain(reverbOutputGain); + isOpen = true; isEnabled = false; @@ -565,6 +571,9 @@ void Synth::close(bool forced) { delete midiQueue; midiQueue = NULL; + delete analog; + analog = NULL; + delete partialManager; partialManager = NULL; @@ -603,16 +612,37 @@ void Synth::flushMIDIQueue() { } } -void Synth::setMIDIEventQueueSize(Bit32u useSize) { - if (midiQueue != NULL) { - flushMIDIQueue(); - delete midiQueue; - midiQueue = new MidiEventQueue(useSize); +Bit32u Synth::setMIDIEventQueueSize(Bit32u useSize) { + static const Bit32u MAX_QUEUE_SIZE = (1 << 24); // This results in about 256 Mb - much greater than any reasonable value + + if (midiQueue == NULL) return 0; + flushMIDIQueue(); + + // Find a power of 2 that is >= useSize + Bit32u binarySize = 1; + if (useSize < MAX_QUEUE_SIZE) { + // Using simple linear search as this isn't time critical + while (binarySize < useSize) binarySize <<= 1; + } else { + binarySize = MAX_QUEUE_SIZE; } + delete midiQueue; + midiQueue = new MidiEventQueue(binarySize); + return binarySize; } Bit32u Synth::getShortMessageLength(Bit32u msg) { - if ((msg & 0xF0) == 0xF0) return 1; + if ((msg & 0xF0) == 0xF0) { + switch (msg & 0xFF) { + case 0xF1: + case 0xF3: + return 2; + case 0xF2: + return 3; + default: + return 1; + } + } // NOTE: This calculation isn't quite correct // as it doesn't consider the running status byte return ((msg & 0xE0) == 0xC0) ? 2 : 3; @@ -638,6 +668,7 @@ bool Synth::playMsg(Bit32u msg, Bit32u timestamp) { if (midiDelayMode != MIDIDelayMode_IMMEDIATE) { timestamp = addMIDIInterfaceDelay(getShortMessageLength(msg), timestamp); } + if (!isEnabled) isEnabled = true; return midiQueue->pushShortMessage(msg, timestamp); } @@ -650,16 +681,19 @@ bool Synth::playSysex(const Bit8u *sysex, Bit32u len, Bit32u timestamp) { if (midiDelayMode == MIDIDelayMode_DELAY_ALL) { timestamp = addMIDIInterfaceDelay(len, timestamp); } + if (!isEnabled) isEnabled = true; return midiQueue->pushSysex(sysex, len, timestamp); } void Synth::playMsgNow(Bit32u msg) { - // FIXME: Implement active sensing + // NOTE: Active sense IS implemented in real hardware. However, realtime processing is clearly out of the library scope. + // It is assumed that realtime consumers of the library respond to these MIDI events as appropriate. + unsigned char code = (unsigned char)((msg & 0x0000F0) >> 4); unsigned char chan = (unsigned char)(msg & 0x00000F); unsigned char note = (unsigned char)((msg & 0x007F00) >> 8); unsigned char velocity = (unsigned char)((msg & 0x7F0000) >> 16); - isEnabled = true; + if (!isEnabled) isEnabled = true; //printDebug("Playing chan %d, code 0x%01x note: 0x%02x", chan, code, note); @@ -831,7 +865,7 @@ void Synth::playSysexWithoutHeader(unsigned char device, unsigned char command, printDebug("playSysexWithoutHeader: Message is too short (%d bytes)!", len); return; } - unsigned char checksum = calcSysexChecksum(sysex, len - 1, 0); + Bit8u checksum = calcSysexChecksum(sysex, len - 1); if (checksum != sysex[len - 1]) { printDebug("playSysexWithoutHeader: Message checksum is incorrect (provided: %02x, expected: %02x)!", sysex[len - 1], checksum); return; @@ -1410,9 +1444,8 @@ void MidiEvent::setSysex(const Bit8u *useSysexData, Bit32u useSysexLength, Bit32 memcpy(dstSysexData, useSysexData, sysexLength); } -MidiEventQueue::MidiEventQueue(Bit32u useRingBufferSize) : ringBufferSize(useRingBufferSize) { - ringBuffer = new MidiEvent[ringBufferSize]; - memset(ringBuffer, 0, ringBufferSize * sizeof(MidiEvent)); +MidiEventQueue::MidiEventQueue(Bit32u useRingBufferSize) : ringBuffer(new MidiEvent[useRingBufferSize]), ringBufferMask(useRingBufferSize - 1) { + memset(ringBuffer, 0, useRingBufferSize * sizeof(MidiEvent)); reset(); } @@ -1426,7 +1459,7 @@ void MidiEventQueue::reset() { } bool MidiEventQueue::pushShortMessage(Bit32u shortMessageData, Bit32u timestamp) { - unsigned int newEndPosition = (endPosition + 1) % ringBufferSize; + Bit32u newEndPosition = (endPosition + 1) & ringBufferMask; // Is ring buffer full? if (startPosition == newEndPosition) return false; ringBuffer[endPosition].setShortMessage(shortMessageData, timestamp); @@ -1435,7 +1468,7 @@ bool MidiEventQueue::pushShortMessage(Bit32u shortMessageData, Bit32u timestamp) } bool MidiEventQueue::pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp) { - unsigned int newEndPosition = (endPosition + 1) % ringBufferSize; + Bit32u newEndPosition = (endPosition + 1) & ringBufferMask; // Is ring buffer full? if (startPosition == newEndPosition) return false; ringBuffer[endPosition].setSysex(sysexData, sysexLength, timestamp); @@ -1450,31 +1483,36 @@ const MidiEvent *MidiEventQueue::peekMidiEvent() { void MidiEventQueue::dropMidiEvent() { // Is ring buffer empty? if (startPosition != endPosition) { - startPosition = (startPosition + 1) % ringBufferSize; + startPosition = (startPosition + 1) & ringBufferMask; } } +bool MidiEventQueue::isFull() const { + return startPosition == ((endPosition + 1) & ringBufferMask); +} + +unsigned int Synth::getStereoOutputSampleRate() const { + return (analog == NULL) ? SAMPLE_RATE : analog->getOutputSampleRate(); +} + void Synth::render(Sample *stream, Bit32u len) { - Sample tmpNonReverbLeft[MAX_SAMPLES_PER_RUN]; - Sample tmpNonReverbRight[MAX_SAMPLES_PER_RUN]; - Sample tmpReverbDryLeft[MAX_SAMPLES_PER_RUN]; - Sample tmpReverbDryRight[MAX_SAMPLES_PER_RUN]; - Sample tmpReverbWetLeft[MAX_SAMPLES_PER_RUN]; - Sample tmpReverbWetRight[MAX_SAMPLES_PER_RUN]; + if (!isEnabled) { + renderedSampleCount += analog->getDACStreamsLength(len); + analog->process(NULL, NULL, NULL, NULL, NULL, NULL, NULL, len); + muteSampleBuffer(stream, len << 1); + return; + } + + // As in AnalogOutputMode_ACCURATE mode output is upsampled, buffer size MAX_SAMPLES_PER_RUN is more than enough. + Sample tmpNonReverbLeft[MAX_SAMPLES_PER_RUN], tmpNonReverbRight[MAX_SAMPLES_PER_RUN]; + Sample tmpReverbDryLeft[MAX_SAMPLES_PER_RUN], tmpReverbDryRight[MAX_SAMPLES_PER_RUN]; + Sample tmpReverbWetLeft[MAX_SAMPLES_PER_RUN], tmpReverbWetRight[MAX_SAMPLES_PER_RUN]; while (len > 0) { - Bit32u thisLen = len > MAX_SAMPLES_PER_RUN ? MAX_SAMPLES_PER_RUN : len; - renderStreams(tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, thisLen); - for (Bit32u i = 0; i < thisLen; i++) { -#if MT32EMU_USE_FLOAT_SAMPLES - *(stream++) = tmpNonReverbLeft[i] + tmpReverbDryLeft[i] + tmpReverbWetLeft[i]; - *(stream++) = tmpNonReverbRight[i] + tmpReverbDryRight[i] + tmpReverbWetRight[i]; -#else - *(stream++) = clipBit16s((Bit32s)tmpNonReverbLeft[i] + (Bit32s)tmpReverbDryLeft[i] + (Bit32s)tmpReverbWetLeft[i]); - *(stream++) = clipBit16s((Bit32s)tmpNonReverbRight[i] + (Bit32s)tmpReverbDryRight[i] + (Bit32s)tmpReverbWetRight[i]); -#endif - } - len -= thisLen; + Bit32u thisPassLen = len > MAX_SAMPLES_PER_RUN ? MAX_SAMPLES_PER_RUN : len; + renderStreams(tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, analog->getDACStreamsLength(thisPassLen)); + analog->process(&stream, tmpNonReverbLeft, tmpNonReverbRight, tmpReverbDryLeft, tmpReverbDryRight, tmpReverbWetLeft, tmpReverbWetRight, thisPassLen); + len -= thisPassLen; } } @@ -1518,7 +1556,10 @@ void Synth::renderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample // In GENERATION2 units, the output from LA32 goes to the Boss chip already bit-shifted. // In NICE mode, it's also better to increase volume before the reverb processing to preserve accuracy. void Synth::produceLA32Output(Sample *buffer, Bit32u len) { -#if !MT32EMU_USE_FLOAT_SAMPLES +#if MT32EMU_USE_FLOAT_SAMPLES + (void)buffer; + (void)len; +#else switch (dacInputMode) { case DACInputMode_GENERATION2: while (len--) { @@ -1528,7 +1569,7 @@ void Synth::produceLA32Output(Sample *buffer, Bit32u len) { break; case DACInputMode_NICE: while (len--) { - *buffer = clipBit16s(Bit32s(*buffer) << 1); + *buffer = clipSampleEx(SampleEx(*buffer) << 1); ++buffer; } break; @@ -1538,26 +1579,16 @@ void Synth::produceLA32Output(Sample *buffer, Bit32u len) { #endif } -void Synth::convertSamplesToOutput(Sample *buffer, Bit32u len, bool reverb) { - if (dacInputMode == DACInputMode_PURE) return; - +void Synth::convertSamplesToOutput(Sample *buffer, Bit32u len) { #if MT32EMU_USE_FLOAT_SAMPLES - float gain = reverb ? effectiveReverbOutputGain : outputGain; - while (len--) { - *(buffer++) *= gain; - } + (void)buffer; + (void)len; #else - int gain = reverb ? effectiveReverbOutputGain : effectiveOutputGain; if (dacInputMode == DACInputMode_GENERATION1) { while (len--) { - Bit32s target = Bit16s((*buffer & 0x8000) | ((*buffer << 1) & 0x7FFE)); - *(buffer++) = clipBit16s((target * gain) >> 8); + *buffer = Sample((*buffer & 0x8000) | ((*buffer << 1) & 0x7FFE)); + ++buffer; } - return; - } - while (len--) { - *buffer = clipBit16s((Bit32s(*buffer) * gain) >> 8); - ++buffer; } #endif } @@ -1566,18 +1597,18 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl // Even if LA32 output isn't desired, we proceed anyway with temp buffers Sample tmpBufNonReverbLeft[MAX_SAMPLES_PER_RUN], tmpBufNonReverbRight[MAX_SAMPLES_PER_RUN]; if (nonReverbLeft == NULL) nonReverbLeft = tmpBufNonReverbLeft; - if (nonReverbLeft == NULL) nonReverbRight = tmpBufNonReverbRight; + if (nonReverbRight == NULL) nonReverbRight = tmpBufNonReverbRight; Sample tmpBufReverbDryLeft[MAX_SAMPLES_PER_RUN], tmpBufReverbDryRight[MAX_SAMPLES_PER_RUN]; if (reverbDryLeft == NULL) reverbDryLeft = tmpBufReverbDryLeft; if (reverbDryRight == NULL) reverbDryRight = tmpBufReverbDryRight; - muteSampleBuffer(nonReverbLeft, len); - muteSampleBuffer(nonReverbRight, len); - muteSampleBuffer(reverbDryLeft, len); - muteSampleBuffer(reverbDryRight, len); - if (isEnabled) { + muteSampleBuffer(nonReverbLeft, len); + muteSampleBuffer(nonReverbRight, len); + muteSampleBuffer(reverbDryLeft, len); + muteSampleBuffer(reverbDryRight, len); + for (unsigned int i = 0; i < getPartialCount(); i++) { if (partialManager->shouldReverb(i)) { partialManager->produceOutput(i, reverbDryLeft, reverbDryRight, len); @@ -1591,8 +1622,8 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl if (isReverbEnabled()) { reverbModel->process(reverbDryLeft, reverbDryRight, reverbWetLeft, reverbWetRight, len); - if (reverbWetLeft != NULL) convertSamplesToOutput(reverbWetLeft, len, true); - if (reverbWetRight != NULL) convertSamplesToOutput(reverbWetRight, len, true); + if (reverbWetLeft != NULL) convertSamplesToOutput(reverbWetLeft, len); + if (reverbWetRight != NULL) convertSamplesToOutput(reverbWetRight, len); } else { muteSampleBuffer(reverbWetLeft, len); muteSampleBuffer(reverbWetRight, len); @@ -1601,15 +1632,20 @@ void Synth::doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sampl // Don't bother with conversion if the output is going to be unused if (nonReverbLeft != tmpBufNonReverbLeft) { produceLA32Output(nonReverbLeft, len); - convertSamplesToOutput(nonReverbLeft, len, false); + convertSamplesToOutput(nonReverbLeft, len); } if (nonReverbRight != tmpBufNonReverbRight) { produceLA32Output(nonReverbRight, len); - convertSamplesToOutput(nonReverbRight, len, false); + convertSamplesToOutput(nonReverbRight, len); } - if (reverbDryLeft != tmpBufReverbDryLeft) convertSamplesToOutput(reverbDryLeft, len, false); - if (reverbDryRight != tmpBufReverbDryRight) convertSamplesToOutput(reverbDryRight, len, false); + if (reverbDryLeft != tmpBufReverbDryLeft) convertSamplesToOutput(reverbDryLeft, len); + if (reverbDryRight != tmpBufReverbDryRight) convertSamplesToOutput(reverbDryRight, len); } else { + // Avoid muting buffers that wasn't requested + if (nonReverbLeft != tmpBufNonReverbLeft) muteSampleBuffer(nonReverbLeft, len); + if (nonReverbRight != tmpBufNonReverbRight) muteSampleBuffer(nonReverbRight, len); + if (reverbDryLeft != tmpBufReverbDryLeft) muteSampleBuffer(reverbDryLeft, len); + if (reverbDryRight != tmpBufReverbDryRight) muteSampleBuffer(reverbDryRight, len); muteSampleBuffer(reverbWetLeft, len); muteSampleBuffer(reverbWetRight, len); } @@ -1651,14 +1687,48 @@ bool Synth::isActive() const { return false; } -const Partial *Synth::getPartial(unsigned int partialNum) const { - return partialManager->getPartial(partialNum); -} - unsigned int Synth::getPartialCount() const { return partialCount; } +void Synth::getPartStates(bool *partStates) const { + for (int partNumber = 0; partNumber < 9; partNumber++) { + const Part *part = parts[partNumber]; + partStates[partNumber] = part->getActiveNonReleasingPartialCount() > 0; + } +} + +void Synth::getPartialStates(PartialState *partialStates) const { + static const PartialState partialPhaseToState[8] = { + PartialState_ATTACK, PartialState_ATTACK, PartialState_ATTACK, PartialState_ATTACK, + PartialState_SUSTAIN, PartialState_SUSTAIN, PartialState_RELEASE, PartialState_INACTIVE + }; + + for (unsigned int partialNum = 0; partialNum < getPartialCount(); partialNum++) { + const Partial *partial = partialManager->getPartial(partialNum); + partialStates[partialNum] = partial->isActive() ? partialPhaseToState[partial->getTVA()->getPhase()] : PartialState_INACTIVE; + } +} + +unsigned int Synth::getPlayingNotes(unsigned int partNumber, Bit8u *keys, Bit8u *velocities) const { + unsigned int playingNotes = 0; + if (isOpen && (partNumber < 9)) { + const Part *part = parts[partNumber]; + const Poly *poly = part->getFirstActivePoly(); + while (poly != NULL) { + keys[playingNotes] = (Bit8u)poly->getKey(); + velocities[playingNotes] = (Bit8u)poly->getVelocity(); + playingNotes++; + poly = poly->getNext(); + } + } + return playingNotes; +} + +const char *Synth::getPatchName(unsigned int partNumber) const { + return (!isOpen || partNumber > 8) ? NULL : parts[partNumber]->getCurrentInstr(); +} + const Part *Synth::getPart(unsigned int partNum) const { if (partNum > 8) { return NULL; diff --git a/audio/softsynth/mt32/Synth.h b/audio/softsynth/mt32/Synth.h index 37fb7b280a..97d4644ee2 100644 --- a/audio/softsynth/mt32/Synth.h +++ b/audio/softsynth/mt32/Synth.h @@ -19,15 +19,31 @@ #define MT32EMU_SYNTH_H //#include +//#include namespace MT32Emu { -class TableInitialiser; +class Analog; +class BReverbModel; +class MemoryRegion; +class MidiEventQueue; +class Part; +class Poly; class Partial; class PartialManager; -class Part; -class ROMImage; -class BReverbModel; + +class PatchTempMemoryRegion; +class RhythmTempMemoryRegion; +class TimbreTempMemoryRegion; +class PatchesMemoryRegion; +class TimbresMemoryRegion; +class SystemMemoryRegion; +class DisplayMemoryRegion; +class ResetMemoryRegion; + +struct ControlROMMap; +struct PCMWaveEntry; +struct MemParams; /** * Methods for emulating the connection between the LA32 and the DAC, which involves @@ -43,8 +59,7 @@ enum DACInputMode { // Produces samples that exactly match the bits output from the emulated LA32. // * Nicer overdrive characteristics than the DAC hacks (it simply clips samples within range) // * Much less likely to overdrive than any other mode. - // * Half the volume of any of the other modes, meaning its volume relative to the reverb - // output when mixed together directly will sound wrong. + // * Half the volume of any of the other modes. // * Output gain is ignored for both LA32 and reverb output. // * Perfect for developers while debugging :) DACInputMode_PURE, @@ -60,6 +75,7 @@ enum DACInputMode { DACInputMode_GENERATION2 }; +// Methods for emulating the effective delay of incoming MIDI messages introduced by a MIDI interface. enum MIDIDelayMode { // Process incoming MIDI events immediately. MIDIDelayMode_IMMEDIATE, @@ -72,6 +88,35 @@ enum MIDIDelayMode { MIDIDelayMode_DELAY_ALL }; +// Methods for emulating the effects of analogue circuits of real hardware units on the output signal. +enum AnalogOutputMode { + // Only digital path is emulated. The output samples correspond to the digital signal at the DAC entrance. + AnalogOutputMode_DIGITAL_ONLY, + // Coarse emulation of LPF circuit. High frequencies are boosted, sample rate remains unchanged. + AnalogOutputMode_COARSE, + // Finer emulation of LPF circuit. Output signal is upsampled to 48 kHz to allow emulation of audible mirror spectra above 16 kHz, + // which is passed through the LPF circuit without significant attenuation. + AnalogOutputMode_ACCURATE, + // Same as AnalogOutputMode_ACCURATE mode but the output signal is 2x oversampled, i.e. the output sample rate is 96 kHz. + // This makes subsequent resampling easier. Besides, due to nonlinear passband of the LPF emulated, it takes fewer number of MACs + // compared to a regular LPF FIR implementations. + AnalogOutputMode_OVERSAMPLED +}; + +enum ReverbMode { + REVERB_MODE_ROOM, + REVERB_MODE_HALL, + REVERB_MODE_PLATE, + REVERB_MODE_TAP_DELAY +}; + +enum PartialState { + PartialState_INACTIVE, + PartialState_ATTACK, + PartialState_SUSTAIN, + PartialState_RELEASE +}; + const Bit8u SYSEX_MANUFACTURER_ROLAND = 0x41; const Bit8u SYSEX_MDL_MT32 = 0x16; @@ -87,148 +132,10 @@ const Bit8u SYSEX_CMD_EOD = 0x45; // End of data const Bit8u SYSEX_CMD_ERR = 0x4E; // Communications error const Bit8u SYSEX_CMD_RJC = 0x4F; // Rejection -const int MAX_SYSEX_SIZE = 512; +const int MAX_SYSEX_SIZE = 512; // FIXME: Does this correspond to a real MIDI buffer used in h/w devices? const unsigned int CONTROL_ROM_SIZE = 64 * 1024; -struct ControlROMPCMStruct { - Bit8u pos; - Bit8u len; - Bit8u pitchLSB; - Bit8u pitchMSB; -}; - -struct ControlROMMap { - Bit16u idPos; - Bit16u idLen; - const char *idBytes; - Bit16u pcmTable; // 4 * pcmCount bytes - Bit16u pcmCount; - Bit16u timbreAMap; // 128 bytes - Bit16u timbreAOffset; - bool timbreACompressed; - Bit16u timbreBMap; // 128 bytes - Bit16u timbreBOffset; - bool timbreBCompressed; - Bit16u timbreRMap; // 2 * timbreRCount bytes - Bit16u timbreRCount; - Bit16u rhythmSettings; // 4 * rhythmSettingsCount bytes - Bit16u rhythmSettingsCount; - Bit16u reserveSettings; // 9 bytes - Bit16u panSettings; // 8 bytes - Bit16u programSettings; // 8 bytes - Bit16u rhythmMaxTable; // 4 bytes - Bit16u patchMaxTable; // 16 bytes - Bit16u systemMaxTable; // 23 bytes - Bit16u timbreMaxTable; // 72 bytes -}; - -enum MemoryRegionType { - MR_PatchTemp, MR_RhythmTemp, MR_TimbreTemp, MR_Patches, MR_Timbres, MR_System, MR_Display, MR_Reset -}; - -enum ReverbMode { - REVERB_MODE_ROOM, - REVERB_MODE_HALL, - REVERB_MODE_PLATE, - REVERB_MODE_TAP_DELAY -}; - -class MemoryRegion { -private: - Synth *synth; - Bit8u *realMemory; - Bit8u *maxTable; -public: - MemoryRegionType type; - Bit32u startAddr, entrySize, entries; - - MemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable, MemoryRegionType useType, Bit32u useStartAddr, Bit32u useEntrySize, Bit32u useEntries) { - synth = useSynth; - realMemory = useRealMemory; - maxTable = useMaxTable; - type = useType; - startAddr = useStartAddr; - entrySize = useEntrySize; - entries = useEntries; - } - int lastTouched(Bit32u addr, Bit32u len) const { - return (offset(addr) + len - 1) / entrySize; - } - int firstTouchedOffset(Bit32u addr) const { - return offset(addr) % entrySize; - } - int firstTouched(Bit32u addr) const { - return offset(addr) / entrySize; - } - Bit32u regionEnd() const { - return startAddr + entrySize * entries; - } - bool contains(Bit32u addr) const { - return addr >= startAddr && addr < regionEnd(); - } - int offset(Bit32u addr) const { - return addr - startAddr; - } - Bit32u getClampedLen(Bit32u addr, Bit32u len) const { - if (addr + len > regionEnd()) - return regionEnd() - addr; - return len; - } - Bit32u next(Bit32u addr, Bit32u len) const { - if (addr + len > regionEnd()) { - return regionEnd() - addr; - } - return 0; - } - Bit8u getMaxValue(int off) const { - if (maxTable == NULL) - return 0xFF; - return maxTable[off % entrySize]; - } - Bit8u *getRealMemory() const { - return realMemory; - } - bool isReadable() const { - return getRealMemory() != NULL; - } - void read(unsigned int entry, unsigned int off, Bit8u *dst, unsigned int len) const; - void write(unsigned int entry, unsigned int off, const Bit8u *src, unsigned int len, bool init = false) const; -}; - -class PatchTempMemoryRegion : public MemoryRegion { -public: - PatchTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_PatchTemp, MT32EMU_MEMADDR(0x030000), sizeof(MemParams::PatchTemp), 9) {} -}; -class RhythmTempMemoryRegion : public MemoryRegion { -public: - RhythmTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_RhythmTemp, MT32EMU_MEMADDR(0x030110), sizeof(MemParams::RhythmTemp), 85) {} -}; -class TimbreTempMemoryRegion : public MemoryRegion { -public: - TimbreTempMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_TimbreTemp, MT32EMU_MEMADDR(0x040000), sizeof(TimbreParam), 8) {} -}; -class PatchesMemoryRegion : public MemoryRegion { -public: - PatchesMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Patches, MT32EMU_MEMADDR(0x050000), sizeof(PatchParam), 128) {} -}; -class TimbresMemoryRegion : public MemoryRegion { -public: - TimbresMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_Timbres, MT32EMU_MEMADDR(0x080000), sizeof(MemParams::PaddedTimbre), 64 + 64 + 64 + 64) {} -}; -class SystemMemoryRegion : public MemoryRegion { -public: - SystemMemoryRegion(Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable) : MemoryRegion(useSynth, useRealMemory, useMaxTable, MR_System, MT32EMU_MEMADDR(0x100000), sizeof(MemParams::System), 1) {} -}; -class DisplayMemoryRegion : public MemoryRegion { -public: - DisplayMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Display, MT32EMU_MEMADDR(0x200000), MAX_SYSEX_SIZE - 1, 1) {} -}; -class ResetMemoryRegion : public MemoryRegion { -public: - ResetMemoryRegion(Synth *useSynth) : MemoryRegion(useSynth, NULL, NULL, MR_Reset, MT32EMU_MEMADDR(0x7F0000), 0x3FFF, 1) {} -}; - class ReportHandler { friend class Synth; @@ -254,47 +161,6 @@ protected: virtual void onProgramChanged(int /* partNum */, int /* bankNum */, const char * /* patchName */) {} }; -/** - * Used to safely store timestamped MIDI events in a local queue. - */ -struct MidiEvent { - Bit32u shortMessageData; - const Bit8u *sysexData; - Bit32u sysexLength; - Bit32u timestamp; - - ~MidiEvent(); - void setShortMessage(Bit32u shortMessageData, Bit32u timestamp); - void setSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp); -}; - -/** - * Simple queue implementation using a ring buffer to store incoming MIDI event before the synth actually processes it. - * It is intended to: - * - get rid of prerenderer while retaining graceful partial abortion - * - add fair emulation of the MIDI interface delays - * - extend the synth interface with the default implementation of a typical rendering loop. - * THREAD SAFETY: - * It is safe to use either in a single thread environment or when there are only two threads - one performs only reading - * and one performs only writing. More complicated usage requires external synchronisation. - */ -class MidiEventQueue { -private: - MidiEvent *ringBuffer; - Bit32u ringBufferSize; - volatile Bit32u startPosition; - volatile Bit32u endPosition; - -public: - MidiEventQueue(Bit32u ringBufferSize = DEFAULT_MIDI_EVENT_QUEUE_SIZE); - ~MidiEventQueue(); - void reset(); - bool pushShortMessage(Bit32u shortMessageData, Bit32u timestamp); - bool pushSysex(const Bit8u *sysexData, Bit32u sysexLength, Bit32u timestamp); - const MidiEvent *peekMidiEvent(); - void dropMidiEvent(); -}; - class Synth { friend class Part; friend class RhythmPart; @@ -335,7 +201,7 @@ private: volatile Bit32u lastReceivedMIDIEventTimestamp; volatile Bit32u renderedSampleCount; - MemParams mt32ram, mt32default; + MemParams &mt32ram, &mt32default; BReverbModel *reverbModels[4]; BReverbModel *reverbModel; @@ -346,12 +212,6 @@ private: float outputGain; float reverbOutputGain; -#if MT32EMU_USE_FLOAT_SAMPLES - float effectiveReverbOutputGain; -#else - int effectiveOutputGain; - int effectiveReverbOutputGain; -#endif bool reversedStereoEnabled; @@ -368,11 +228,12 @@ private: // We emulate this by delaying new MIDI events processing until abortion finishes. Poly *abortingPoly; - Bit32u getShortMessageLength(Bit32u msg); + Analog *analog; + Bit32u addMIDIInterfaceDelay(Bit32u len, Bit32u timestamp); void produceLA32Output(Sample *buffer, Bit32u len); - void convertSamplesToOutput(Sample *buffer, Bit32u len, bool reverb); + void convertSamplesToOutput(Sample *buffer, Bit32u len); bool isAbortingPoly() const; void doRenderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample *reverbDryLeft, Sample *reverbDryRight, Sample *reverbWetLeft, Sample *reverbWetRight, Bit32u len); @@ -404,13 +265,20 @@ private: void newTimbreSet(int partNum, Bit8u timbreGroup, const char patchName[]); void printDebug(const char *fmt, ...); + // partNum should be 0..7 for Part 1..8, or 8 for Rhythm + const Part *getPart(unsigned int partNum) const; + public: - static inline Bit16s clipBit16s(Bit32s sample) { + static inline Sample clipSampleEx(SampleEx sampleEx) { +#if MT32EMU_USE_FLOAT_SAMPLES + return sampleEx; +#else // Clamp values above 32767 to 32767, and values below -32768 to -32768 // FIXME: Do we really need this stuff? I think these branches are very well predicted. Instead, this introduces a chain. // The version below is actually a bit faster on my system... - //return ((sample + 0x8000) & ~0xFFFF) ? (sample >> 31) ^ 0x7FFF : (Bit16s)sample; - return ((-0x8000 <= sample) && (sample <= 0x7FFF)) ? (Bit16s)sample : (sample >> 31) ^ 0x7FFF; + //return ((sampleEx + 0x8000) & ~0xFFFF) ? (sampleEx >> 31) ^ 0x7FFF : (Sample)sampleEx; + return ((-0x8000 <= sampleEx) && (sampleEx <= 0x7FFF)) ? (Sample)sampleEx : (sampleEx >> 31) ^ 0x7FFF; +#endif } static inline void muteSampleBuffer(Sample *buffer, Bit32u len) { @@ -426,7 +294,8 @@ public: #endif } - static Bit8u calcSysexChecksum(const Bit8u *data, Bit32u len, Bit8u checksum); + static Bit32u getShortMessageLength(Bit32u msg); + static Bit8u calcSysexChecksum(const Bit8u *data, const Bit32u len, const Bit8u initChecksum = 0); // Optionally sets callbacks for reporting various errors, information and debug messages Synth(ReportHandler *useReportHandler = NULL); @@ -435,8 +304,12 @@ public: // Used to initialise the MT-32. Must be called before any other function. // Returns true if initialization was sucessful, otherwise returns false. // controlROMImage and pcmROMImage represent Control and PCM ROM images for use by synth. - // usePartialCount sets the maximum number of partials playing simultaneously for this session. - bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount = DEFAULT_MAX_PARTIALS); + // usePartialCount sets the maximum number of partials playing simultaneously for this session (optional). + // analogOutputMode sets the mode for emulation of analogue circuitry of the hardware units (optional). + bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, unsigned int usePartialCount = DEFAULT_MAX_PARTIALS, AnalogOutputMode analogOutputMode = AnalogOutputMode_COARSE); + + // Overloaded method which opens the synth with default partial count. + bool open(const ROMImage &controlROMImage, const ROMImage &pcmROMImage, AnalogOutputMode analogOutputMode); // Closes the MT-32 and deallocates any memory used by the synthesizer void close(bool forced = false); @@ -444,29 +317,34 @@ public: // All the enqueued events are processed by the synth immediately. void flushMIDIQueue(); - // Sets size of the internal MIDI event queue. + // Sets size of the internal MIDI event queue. The queue size is set to the minimum power of 2 that is greater or equal to the size specified. // The queue is flushed before reallocation. - void setMIDIEventQueueSize(Bit32u); + // Returns the actual queue size being used. + Bit32u setMIDIEventQueueSize(Bit32u); // Enqueues a MIDI event for subsequent playback. - // The minimum delay involves the delay introduced while the event is transferred via MIDI interface + // The MIDI event will be processed not before the specified timestamp. + // The timestamp is measured as the global rendered sample count since the synth was created (at the native sample rate 32000 Hz). + // The minimum delay involves emulation of the delay introduced while the event is transferred via MIDI interface // and emulation of the MCU busy-loop while it frees partials for use by a new Poly. - // Calls from multiple threads must be synchronised, although, - // no synchronisation is required with the rendering thread. + // Calls from multiple threads must be synchronised, although, no synchronisation is required with the rendering thread. + // The methods return false if the MIDI event queue is full and the message cannot be enqueued. - // The MIDI event will be processed not before the specified timestamp. - // The timestamp is measured as the global rendered sample count since the synth was created. + // Enqueues a single short MIDI message. The message must contain a status byte. bool playMsg(Bit32u msg, Bit32u timestamp); + // Enqueues a single well formed System Exclusive MIDI message. bool playSysex(const Bit8u *sysex, Bit32u len, Bit32u timestamp); - // The MIDI event will be processed ASAP. + + // Overloaded methods for the MIDI events to be processed ASAP. bool playMsg(Bit32u msg); bool playSysex(const Bit8u *sysex, Bit32u len); // WARNING: // The methods below don't ensure minimum 1-sample delay between sequential MIDI events, // and a sequence of NoteOn and immediately succeeding NoteOff messages is always silent. + // A thread that invokes these methods must be explicitly synchronised with the thread performing sample rendering. - // Sends a 4-byte MIDI message to the MT-32 for immediate playback. + // Sends a short MIDI message to the synth for immediate playback. The message must contain a status byte. void playMsgNow(Bit32u msg); void playMsgOnPart(unsigned char part, unsigned char code, unsigned char note, unsigned char velocity); @@ -495,12 +373,17 @@ public: void setMIDIDelayMode(MIDIDelayMode mode); MIDIDelayMode getMIDIDelayMode() const; - // Sets output gain factor. Applied to all output samples and unrelated with the synth's Master volume. + // Sets output gain factor for synth output channels. Applied to all output samples and unrelated with the synth's Master volume, + // it rather corresponds to the gain of the output analog circuitry of the hardware units. However, together with setReverbOutputGain() + // it offers to the user a capability to control the gain of reverb and non-reverb output channels independently. // Ignored in DACInputMode_PURE void setOutputGain(float); float getOutputGain() const; - // Sets output gain factor for the reverb wet output. setOutputGain() doesn't change reverb output gain. + // Sets output gain factor for the reverb wet output channels. It rather corresponds to the gain of the output + // analog circuitry of the hardware units. However, together with setOutputGain() it offers to the user a capability + // to control the gain of reverb and non-reverb output channels independently. + // // Note: We're currently emulate CM-32L/CM-64 reverb quite accurately and the reverb output level closely // corresponds to the level of digital capture. Although, according to the CM-64 PCB schematic, // there is a difference in the reverb analogue circuit, and the resulting output gain is 0.68 @@ -512,12 +395,21 @@ public: void setReversedStereoEnabled(bool enabled); bool isReversedStereoEnabled(); - // Renders samples to the specified output stream. - // The length is in frames, not bytes (in 16-bit stereo, - // one frame is 4 bytes). + // Returns actual sample rate used in emulation of stereo analog circuitry of hardware units. + // See comment for render() below. + unsigned int getStereoOutputSampleRate() const; + + // Renders samples to the specified output stream as if they were sampled at the analog stereo output. + // When AnalogOutputMode is set to ACCURATE, the output signal is upsampled to 48 kHz in order + // to retain emulation accuracy in whole audible frequency spectra. Otherwise, native digital signal sample rate is retained. + // getStereoOutputSampleRate() can be used to query actual sample rate of the output signal. + // The length is in frames, not bytes (in 16-bit stereo, one frame is 4 bytes). void render(Sample *stream, Bit32u len); - // Renders samples to the specified output streams (any or all of which may be NULL). + // Renders samples to the specified output streams as if they appeared at the DAC entrance. + // No further processing performed in analog circuitry emulation is applied to the signal. + // NULL may be specified in place of any or all of the stream buffers. + // The length is in samples, not bytes. void renderStreams(Sample *nonReverbLeft, Sample *nonReverbRight, Sample *reverbDryLeft, Sample *reverbDryRight, Sample *reverbWetLeft, Sample *reverbWetRight, Bit32u len); // Returns true when there is at least one active partial, otherwise false. @@ -526,15 +418,28 @@ public: // Returns true if hasActivePartials() returns true, or reverb is (somewhat unreliably) detected as being active. bool isActive() const; - const Partial *getPartial(unsigned int partialNum) const; - // Returns the maximum number of partials playing simultaneously. unsigned int getPartialCount() const; - void readMemory(Bit32u addr, Bit32u len, Bit8u *data); + // Fills in current states of all the parts into the array provided. The array must have at least 9 entries to fit values for all the parts. + // If the value returned for a part is true, there is at least one active non-releasing partial playing on this part. + // This info is useful in emulating behaviour of LCD display of the hardware units. + void getPartStates(bool *partStates) const; - // partNum should be 0..7 for Part 1..8, or 8 for Rhythm - const Part *getPart(unsigned int partNum) const; + // Fills in current states of all the partials into the array provided. The array must be large enough to accommodate states of all the partials. + void getPartialStates(PartialState *partialStates) const; + + // Fills in information about currently playing notes on the specified part into the arrays provided. The arrays must be large enough + // to accommodate data for all the playing notes. The maximum number of simultaneously playing notes cannot exceed the number of partials. + // Argument partNumber should be 0..7 for Part 1..8, or 8 for Rhythm. + // Returns the number of currently playing notes on the specified part. + unsigned int getPlayingNotes(unsigned int partNumber, Bit8u *keys, Bit8u *velocities) const; + + // Returns name of the patch set on the specified part. + // Argument partNumber should be 0..7 for Part 1..8, or 8 for Rhythm. + const char *getPatchName(unsigned int partNumber) const; + + void readMemory(Bit32u addr, Bit32u len, Bit8u *data); }; } diff --git a/audio/softsynth/mt32/TVA.cpp b/audio/softsynth/mt32/TVA.cpp index 3fefb791f2..894e53f14a 100644 --- a/audio/softsynth/mt32/TVA.cpp +++ b/audio/softsynth/mt32/TVA.cpp @@ -23,6 +23,7 @@ #include "mt32emu.h" #include "mmath.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/TVF.cpp b/audio/softsynth/mt32/TVF.cpp index bf8d50a7c9..164cf2b4cb 100644 --- a/audio/softsynth/mt32/TVF.cpp +++ b/audio/softsynth/mt32/TVF.cpp @@ -19,6 +19,7 @@ #include "mt32emu.h" #include "mmath.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/TVP.cpp b/audio/softsynth/mt32/TVP.cpp index 374646e5f1..a8003d96dc 100644 --- a/audio/softsynth/mt32/TVP.cpp +++ b/audio/softsynth/mt32/TVP.cpp @@ -19,6 +19,7 @@ //#include #include "mt32emu.h" +#include "internals.h" namespace MT32Emu { diff --git a/audio/softsynth/mt32/Tables.cpp b/audio/softsynth/mt32/Tables.cpp index ae9f11fff0..7e165b5a7a 100644 --- a/audio/softsynth/mt32/Tables.cpp +++ b/audio/softsynth/mt32/Tables.cpp @@ -16,14 +16,15 @@ */ //#include -//#include -//#include #include "mt32emu.h" #include "mmath.h" +#include "Tables.h" namespace MT32Emu { +// UNUSED: const int MIDDLEC = 60; + const Tables &Tables::getInstance() { static const Tables instance; return instance; diff --git a/audio/softsynth/mt32/Tables.h b/audio/softsynth/mt32/Tables.h index e7b97af515..8865c7fac8 100644 --- a/audio/softsynth/mt32/Tables.h +++ b/audio/softsynth/mt32/Tables.h @@ -20,24 +20,11 @@ namespace MT32Emu { -// Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent. -// In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator. -// The output from the synth is supposed to be resampled to convert the sample rate. -const unsigned int SAMPLE_RATE = 32000; - -// MIDI interface data transfer rate in samples. Used to simulate the transfer delay. -const double MIDI_DATA_TRANSFER_RATE = (double)SAMPLE_RATE / 31250.0 * 8.0; - -const float CM32L_REVERB_TO_LA32_ANALOG_OUTPUT_GAIN_FACTOR = 0.68f; - -const int MIDDLEC = 60; - -class Synth; - class Tables { private: Tables(); Tables(Tables &); + ~Tables() {} public: static const Tables &getInstance(); diff --git a/audio/softsynth/mt32/Types.h b/audio/softsynth/mt32/Types.h new file mode 100644 index 0000000000..934b1a1173 --- /dev/null +++ b/audio/softsynth/mt32/Types.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MT32EMU_TYPES_H +#define MT32EMU_TYPES_H + +namespace MT32Emu { + +typedef unsigned int Bit32u; +typedef signed int Bit32s; +typedef unsigned short int Bit16u; +typedef signed short int Bit16s; +typedef unsigned char Bit8u; +typedef signed char Bit8s; + +#if MT32EMU_USE_FLOAT_SAMPLES +typedef float Sample; +typedef float SampleEx; +#else +typedef Bit16s Sample; +typedef Bit32s SampleEx; +#endif + +} + +#endif diff --git a/audio/softsynth/mt32/internals.h b/audio/softsynth/mt32/internals.h new file mode 100644 index 0000000000..ef56819a42 --- /dev/null +++ b/audio/softsynth/mt32/internals.h @@ -0,0 +1,83 @@ +/* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher + * Copyright (C) 2011, 2012, 2013, 2014 Dean Beeler, Jerome Fisher, Sergey V. Mikayev + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 2.1 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +#ifndef MT32EMU_INTERNALS_H +#define MT32EMU_INTERNALS_H + +// Debugging + +// 0: Standard debug output is not stamped with the rendered sample count +// 1: Standard debug output is stamped with the rendered sample count +// NOTE: The "samplestamp" corresponds to the end of the last completed rendering run. +// This is important to bear in mind for debug output that occurs during a run. +#define MT32EMU_DEBUG_SAMPLESTAMPS 0 + +// 0: No debug output for initialisation progress +// 1: Debug output for initialisation progress +#define MT32EMU_MONITOR_INIT 0 + +// 0: No debug output for MIDI events +// 1: Debug output for weird MIDI events +#define MT32EMU_MONITOR_MIDI 0 + +// 0: No debug output for note on/off +// 1: Basic debug output for note on/off +// 2: Comprehensive debug output for note on/off +#define MT32EMU_MONITOR_INSTRUMENTS 0 + +// 0: No debug output for partial allocations +// 1: Show partial stats when an allocation fails +// 2: Show partial stats with every new poly +// 3: Show individual partial allocations/deactivations +#define MT32EMU_MONITOR_PARTIALS 0 + +// 0: No debug output for sysex +// 1: Basic debug output for sysex +#define MT32EMU_MONITOR_SYSEX 0 + +// 0: No debug output for sysex writes to the timbre areas +// 1: Debug output with the name and location of newly-written timbres +// 2: Complete dump of timbre parameters for newly-written timbres +#define MT32EMU_MONITOR_TIMBRES 0 + +// 0: No TVA/TVF-related debug output. +// 1: Shows changes to TVA/TVF target, increment and phase. +#define MT32EMU_MONITOR_TVA 0 +#define MT32EMU_MONITOR_TVF 0 + +// Configuration + +// If non-zero, deletes reverb buffers that are not in use to save memory. +// If zero, keeps reverb buffers for all modes around all the time to avoid allocating/freeing in the critical path. +#define MT32EMU_REDUCE_REVERB_MEMORY 1 + +// 0: Maximum speed at the cost of a bit lower emulation accuracy. +// 1: Maximum achievable emulation accuracy. +#define MT32EMU_BOSS_REVERB_PRECISE_MODE 0 + +#include "Structures.h" +#include "Tables.h" +#include "Poly.h" +#include "LA32Ramp.h" +#include "LA32WaveGenerator.h" +#include "TVA.h" +#include "TVP.h" +#include "TVF.h" +#include "Partial.h" +#include "Part.h" + +#endif diff --git a/audio/softsynth/mt32/module.mk b/audio/softsynth/mt32/module.mk index 1c8aa125ab..f966da8d08 100644 --- a/audio/softsynth/mt32/module.mk +++ b/audio/softsynth/mt32/module.mk @@ -1,6 +1,7 @@ MODULE := audio/softsynth/mt32 MODULE_OBJS := \ + Analog.o \ BReverbModel.o \ LA32Ramp.o \ LA32WaveGenerator.o \ diff --git a/audio/softsynth/mt32/mt32emu.h b/audio/softsynth/mt32/mt32emu.h index d738a5de35..1574c08f0d 100644 --- a/audio/softsynth/mt32/mt32emu.h +++ b/audio/softsynth/mt32/mt32emu.h @@ -18,63 +18,20 @@ #ifndef MT32EMU_MT32EMU_H #define MT32EMU_MT32EMU_H -// Debugging - -// 0: Standard debug output is not stamped with the rendered sample count -// 1: Standard debug output is stamped with the rendered sample count -// NOTE: The "samplestamp" corresponds to the end of the last completed rendering run. -// This is important to bear in mind for debug output that occurs during a run. -#define MT32EMU_DEBUG_SAMPLESTAMPS 0 - -// 0: No debug output for initialisation progress -// 1: Debug output for initialisation progress -#define MT32EMU_MONITOR_INIT 0 - -// 0: No debug output for MIDI events -// 1: Debug output for weird MIDI events -#define MT32EMU_MONITOR_MIDI 0 - -// 0: No debug output for note on/off -// 1: Basic debug output for note on/off -// 2: Comprehensive debug output for note on/off -#define MT32EMU_MONITOR_INSTRUMENTS 0 - -// 0: No debug output for partial allocations -// 1: Show partial stats when an allocation fails -// 2: Show partial stats with every new poly -// 3: Show individual partial allocations/deactivations -#define MT32EMU_MONITOR_PARTIALS 0 - -// 0: No debug output for sysex -// 1: Basic debug output for sysex -#define MT32EMU_MONITOR_SYSEX 0 - -// 0: No debug output for sysex writes to the timbre areas -// 1: Debug output with the name and location of newly-written timbres -// 2: Complete dump of timbre parameters for newly-written timbres -#define MT32EMU_MONITOR_TIMBRES 0 - -// 0: No TVA/TVF-related debug output. -// 1: Shows changes to TVA/TVF target, increment and phase. -#define MT32EMU_MONITOR_TVA 0 -#define MT32EMU_MONITOR_TVF 0 - // Configuration -// If non-zero, deletes reverb buffers that are not in use to save memory. -// If zero, keeps reverb buffers for all modes around all the time to avoid allocating/freeing in the critical path. -#define MT32EMU_REDUCE_REVERB_MEMORY 1 - -// 0: Maximum speed at the cost of a bit lower emulation accuracy. -// 1: Maximum achievable emulation accuracy. -#define MT32EMU_BOSS_REVERB_PRECISE_MODE 0 - // 0: Use 16-bit signed samples and refined wave generator based on logarithmic fixed-point computations and LUTs. Maximum emulation accuracy and speed. // 1: Use float samples in the wave generator and renderer. Maximum output quality and minimum noise. #define MT32EMU_USE_FLOAT_SAMPLES 0 namespace MT32Emu { +// Sample rate to use in mixing. With the progress of development, we've found way too many thing dependent. +// In order to achieve further advance in emulation accuracy, sample rate made fixed throughout the emulator, +// except the emulation of analogue path. +// The output from the synth is supposed to be resampled externally in order to convert to the desired sample rate. +const unsigned int SAMPLE_RATE = 32000; + // The default value for the maximum number of partials playing simultaneously. const unsigned int DEFAULT_MAX_PARTIALS = 32; @@ -97,17 +54,7 @@ const unsigned int MAX_SAMPLES_PER_RUN = 4096; const unsigned int DEFAULT_MIDI_EVENT_QUEUE_SIZE = 1024; } -#include "Structures.h" -#include "common/file.h" -#include "Tables.h" -#include "Poly.h" -#include "LA32Ramp.h" -#include "LA32WaveGenerator.h" -#include "TVA.h" -#include "TVP.h" -#include "TVF.h" -#include "Partial.h" -#include "Part.h" +#include "Types.h" #include "ROMInfo.h" #include "Synth.h" -- cgit v1.2.3 From 965dafe31b1c1f7c4684c0d2cbdb3461e3fddac8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 21 Dec 2014 23:33:01 +0200 Subject: ZVISION: Implement the "dumpallscripts" console command again --- engines/zvision/core/console.cpp | 40 ++++++++++++++++++++++++++------- engines/zvision/core/console.h | 1 + engines/zvision/file/search_manager.cpp | 7 ++++++ engines/zvision/file/search_manager.h | 18 +++++++-------- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 4dd10d6f40..0789f8d4fb 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,6 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -205,6 +206,20 @@ bool Console::cmdLocation(int argc, const char **argv) { return true; } +void dumpFile(Common::SeekableReadStream *s, const char *outName) { + byte *buffer = new byte[s->size()]; + s->read(buffer, s->size()); + + Common::DumpFile dumpFile; + dumpFile.open(outName); + + dumpFile.write(buffer, s->size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; +} + bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { debugPrintf("Use %s to dump a file\n", argv[0]); @@ -217,17 +232,26 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - byte *buffer = new byte[f.size()]; - f.read(buffer, f.size()); + dumpFile(&f, argv[1]); - Common::DumpFile dumpFile; - dumpFile.open(argv[1]); + return true; +} - dumpFile.write(buffer, f.size()); - dumpFile.flush(); - dumpFile.close(); +bool Console::cmdDumpAllScripts(int argc, const char **argv) { + Common::String fileName; + Common::SeekableReadStream *in; - delete[] buffer; + SearchManager::MatchList fileList; + _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); + + for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { + fileName = iter->_value.name; + debugPrintf("Dumping %s\n", fileName.c_str()); + + in = iter->_value.arch->createReadStreamForMember(iter->_value.name); + dumpFile(in, fileName.c_str()); + delete in; + } return true; } diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 299bd6127f..7e27fe8f26 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -46,6 +46,7 @@ private: bool cmdSetPanoramaScale(int argc, const char **argv); bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); + bool cmdDumpAllScripts(int argc, const char **argv); }; } // End of namespace ZVision diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index d0d4e43d12..7a907df39c 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -275,4 +275,11 @@ void SearchManager::listDirRecursive(Common::List &_list, const } } +void SearchManager::listMembersWithExtension(MatchList &fileList, Common::String extension) { + for (SearchManager::MatchList::iterator it = _files.begin(); it != _files.end(); ++it) { + if (it->_key.hasSuffix(extension)) + fileList[it->_key] = it->_value; + } +} + } // End of namespace ZVision diff --git a/engines/zvision/file/search_manager.h b/engines/zvision/file/search_manager.h index fdd70fd381..b9ed02ec13 100644 --- a/engines/zvision/file/search_manager.h +++ b/engines/zvision/file/search_manager.h @@ -47,25 +47,23 @@ public: void loadZix(const Common::String &name); -private: - - void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); - struct Node { Common::String name; Common::Archive *arch; }; - Common::List _dirList; - typedef Common::HashMap MatchList; - Common::List _archList; - MatchList _files; - - Common::String _root; + void listMembersWithExtension(MatchList &fileList, Common::String extension); private: + + void listDirRecursive(Common::List &dirList, const Common::FSNode &fsNode, int depth); + + Common::List _dirList; + Common::List _archList; + Common::String _root; + MatchList _files; }; } -- cgit v1.2.3 From e5ecd500cfbf1c91da31dab0a5a71ff43ed82033 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 21 Dec 2014 23:33:48 +0200 Subject: ZVISION: Document some controls that are only used in Zork: Nemesis --- engines/zvision/scripting/controls/fist_control.h | 1 + engines/zvision/scripting/controls/hotmov_control.h | 1 + engines/zvision/scripting/controls/paint_control.h | 1 + engines/zvision/scripting/controls/titler_control.h | 1 + engines/zvision/scripting/scr_file_handling.cpp | 4 ++++ 5 files changed, 8 insertions(+) diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index 0a6b977ead..bad2daa6d5 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -34,6 +34,7 @@ namespace Video { namespace ZVision { +// Only used in Zork Nemesis, it handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) class FistControl : public Control { public: FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index b18d44c7a6..640fab00c0 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -34,6 +34,7 @@ namespace Video { namespace ZVision { +// Only used in Zork Nemesis, it handles movies where the player needs to click on something (mj7g, vw3g) class HotMovControl : public Control { public: HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h index 8097290ac2..0e5b59b821 100644 --- a/engines/zvision/scripting/controls/paint_control.h +++ b/engines/zvision/scripting/controls/paint_control.h @@ -32,6 +32,7 @@ namespace ZVision { +// Only used in Zork Nemesis, it's the painting puzzle screen in Lucien's room in Irondune (ch4g) class PaintControl : public Control { public: PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h index 075e47c9e9..86bb398b3c 100644 --- a/engines/zvision/scripting/controls/titler_control.h +++ b/engines/zvision/scripting/controls/titler_control.h @@ -32,6 +32,7 @@ namespace ZVision { +// Only used in Zork Nemesis - it's the death screen with the Restore/Exit buttons class TitlerControl : public Control { public: TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index c117da5ec2..47b8b0aa39 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -358,12 +358,16 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS } else if (controlType.equalsIgnoreCase("safe")) { return new SafeControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("hotmovie")) { + // Only used in Zork Nemesis, it handles movies where the player needs to click on something (mj7g, vw3g) return new HotMovControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("fist")) { + // Only used in Zork Nemesis, it handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) return new FistControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("paint")) { + // Only used in Zork Nemesis, it's the painting puzzle screen in Lucien's room in Irondune (ch4g) return new PaintControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("titler")) { + // Only used in Zork Nemesis - it's the death screen with the Restore/Exit buttons (cjde) return new TitlerControl(_engine, key, stream); } return NULL; -- cgit v1.2.3 From 24f0cce9c6b0da33d1558059c6fbdb966eb5fb4e Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Dec 2014 22:28:25 +0100 Subject: ACCESS: Fix bug in setHorizontalCode() --- engines/access/amazon/amazon_logic.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index e6a96b67d6..4a313e8880 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -1035,7 +1035,7 @@ void Guard::setHorizontalCode() { if (_bottomRight.x < screen._orgX1) _gCode2 |= 8; - else if (_bottomRight.y > screen._orgX2) + else if (_bottomRight.x > screen._orgX2) _gCode2 |= 2; } -- cgit v1.2.3 From 4a1ddd5d0c8760dbdee967d8152c8e0e650eb4df Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Dec 2014 22:49:18 +0100 Subject: ACCESS: Remove unused variable --- engines/access/access.cpp | 1 - engines/access/access.h | 1 - engines/access/amazon/amazon_game.cpp | 1 - 3 files changed, 3 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 39e6c2b530..67255ff5ea 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -93,7 +93,6 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _vidX = _vidY = 0; _cheatFl = false; _restartFl = false; - _et = 0; _printEnd = 0; } diff --git a/engines/access/access.h b/engines/access/access.h index a082b969c4..be007e0cb8 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -191,7 +191,6 @@ public: bool _canSaveLoad; Resource *_establish; - int _et; int _printEnd; int _txtPages; int _narateFile; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index eb4fabdad9..d6b759b308 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -268,7 +268,6 @@ void AmazonEngine::doEstablish(int screenId, int estabIndex) { _screen->_maxChars = 37; _screen->_printOrg = _screen->_printStart = Common::Point(48, 35); loadEstablish(estabIndex); - _et = estabIndex; uint16 msgOffset; if (!isCD()) msgOffset = READ_LE_UINT16(_establish->data() + (estabIndex * 2)); -- cgit v1.2.3 From 8bc30d0dfbc538c3631692a807d37e9007958da9 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Dec 2014 22:53:20 +0100 Subject: ACCESS: Initialize header in videoPlayer constructor --- engines/access/video.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 920c066898..edc0bcda27 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -29,6 +29,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _vidSurface = nullptr; _videoData = nullptr; _startCoord = nullptr; + _frameCount = 0; _xCount = 0; _scanCount = 0; @@ -37,6 +38,10 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _soundFlag = false; _soundFrame = 0; _videoEnd = false; + + _header._frameCount = 0; + _header._width = _header._height = 0; + _header._flags = 0; } VideoPlayer::~VideoPlayer() { -- cgit v1.2.3 From 99087c7f454970665391004321c0fc510cdaf9bd Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 21 Dec 2014 22:55:24 +0100 Subject: ACCESS: Use enum instead of int to initialize video flag --- engines/access/video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/access/video.cpp b/engines/access/video.cpp index edc0bcda27..63d0aa5c89 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -41,7 +41,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _header._frameCount = 0; _header._width = _header._height = 0; - _header._flags = 0; + _header._flags = VIDEOFLAG_NONE; } VideoPlayer::~VideoPlayer() { -- cgit v1.2.3 From dfae161386a2ad9e6828f71e90dd19598ca52f36 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:26:53 +0200 Subject: ZVISION: Implement the Venus hint system in Zork: Nemesis --- engines/zvision/core/events.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 6cf0ae5d0d..f0cf3f0789 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -145,6 +145,11 @@ void ZVision::cheatCodes(uint8 key) { getBufferedKey(2), getBufferedKey(1), getBufferedKey(0), 0); + + // Show the Venus screen when "?" or "/" is pressed while inside the temple world + if (_scriptManager->getStateValue(StateKey_VenusEnable) == 1) + if ((checkCode("?") || checkCode("/")) && _scriptManager->getStateValue(StateKey_World) == 't') + _scriptManager->changeLocation('g', 'j', 'h', 'e', 0); } void ZVision::processEvents() { -- cgit v1.2.3 From 41dbbe346c4b46b4b48cdb38687216b1dd254fb4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:29:19 +0200 Subject: ZVISION: Also allow the movement when the cursor is within screen edges This matches the behavior of the original in Zork: Nemesis. ZGI already fills the screen horizontally --- engines/zvision/core/events.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index f0cf3f0789..81ad28f29b 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -284,26 +284,30 @@ void ZVision::onMouseMove(const Common::Point &pos) { // | // ^ - if (_workingWindow.contains(pos)) { - cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord); + // Clip the horizontal mouse position to the working window + Common::Point clippedPos = pos; + clippedPos.x = CLIP(pos.x, _workingWindow.left + 1, _workingWindow.right - 1); + + if (_workingWindow.contains(clippedPos)) { + cursorWasChanged = _scriptManager->onMouseMove(clippedPos, imageCoord); RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { - if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { + if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; - } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { + } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -311,21 +315,21 @@ void ZVision::onMouseMove(const Common::Point &pos) { _mouseVelocity = 0; } } else if (renderState == RenderTable::TILT) { - if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { + if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; - } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { + } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) mspeed = 400 >> 4; - _mouseVelocity = (((pos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From b0e6c30ee288130d6b904a6f770044564b0490e6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:45:34 +0200 Subject: ZVISION: Fix Venus key code handling in commit dfae161 --- engines/zvision/core/events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 81ad28f29b..6e8cf1fe4f 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -148,7 +148,7 @@ void ZVision::cheatCodes(uint8 key) { // Show the Venus screen when "?" or "/" is pressed while inside the temple world if (_scriptManager->getStateValue(StateKey_VenusEnable) == 1) - if ((checkCode("?") || checkCode("/")) && _scriptManager->getStateValue(StateKey_World) == 't') + if (getBufferedKey(0) == 0xBF && _scriptManager->getStateValue(StateKey_World) == 't') _scriptManager->changeLocation('g', 'j', 'h', 'e', 0); } -- cgit v1.2.3 From 85644b887944dc4fc261827ae812a4e4684651bb Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 00:54:08 +0200 Subject: ZVISION: Prefix some class member variables with an underscore --- engines/zvision/scripting/sidefx/ttytext_node.cpp | 6 +- engines/zvision/text/text.cpp | 132 +++++++++++----------- engines/zvision/text/text.h | 30 ++--- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp index 9a7fa01649..2930118524 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.cpp +++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp @@ -57,7 +57,7 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file delete infile; } _img.create(_r.width(), _r.height(), _engine->_pixelFormat); - _style.sharp = true; + _style._sharp = true; _style.readAllStyle(_txtbuf); _style.setFont(_fnt); _engine->getScriptManager()->setStateValue(_key, 1); @@ -96,7 +96,7 @@ bool ttyTextNode::process(uint32 deltaTimeInMillis) { if (ret & TXT_RET_HASSTBOX) { Common::String buf; - buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style.statebox)); + buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox)); for (uint8 j = 0; j < buf.size(); j++) outchar(buf[j]); @@ -158,7 +158,7 @@ void ttyTextNode::newline() { } void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_pixelFormat.RGBToColor(_style.red, _style.green, _style.blue); + uint32 clr = _engine->_pixelFormat.RGBToColor(_style._red, _style._green, _style._blue); if (_dx + _fnt.getCharWidth(chr) > _r.width()) newline(); diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 406c36e5b0..08b57914c2 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -39,21 +39,21 @@ namespace ZVision { cTxtStyle::cTxtStyle() { - fontname = "Arial"; - blue = 255; - green = 255; - red = 255; - bold = false; - escapement = 0; - italic = false; - justify = TXT_JUSTIFY_LEFT; - newline = false; - size = 12; - skipcolor = false; - strikeout = false; - underline = false; - statebox = 0; - sharp = false; + _fontname = "Arial"; + _blue = 255; + _green = 255; + _red = 255; + _bold = false; + _escapement = 0; + _italic = false; + _justify = TXT_JUSTIFY_LEFT; + _newline = false; + _size = 12; + _skipcolor = false; + _strikeout = false; + _underline = false; + _statebox = 0; + _sharp = false; } txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { @@ -80,10 +80,10 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (_tmp.lastChar() == '"') _tmp.deleteLastChar(); - fontname = _tmp; + _fontname = _tmp; } else { if (!tokenizer.empty()) - fontname = token; + _fontname = token; } retval |= TXT_RET_FNTCHG; @@ -91,8 +91,8 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); - if (blue != tmp) { - blue = tmp; + if (_blue != tmp) { + _blue = tmp; retval |= TXT_RET_FNTSTL; } } @@ -100,8 +100,8 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); - if (red != tmp) { - red = tmp; + if (_red != tmp) { + _red = tmp; retval |= TXT_RET_FNTSTL; } } @@ -109,23 +109,23 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); - if (green != tmp) { - green = tmp; + if (_green != tmp) { + _green = tmp; retval |= TXT_RET_FNTSTL; } } } else if (token.matchString("newline", true)) { if ((retval & TXT_RET_NEWLN) == 0) - newline = 0; + _newline = 0; - newline++; + _newline++; retval |= TXT_RET_NEWLN; } else if (token.matchString("point", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); - if (size != tmp) { - size = tmp; + if (_size != tmp) { + _size = tmp; retval |= TXT_RET_FNTCHG; } } @@ -133,19 +133,19 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); int32 tmp = atoi(token.c_str()); - escapement = tmp; + _escapement = tmp; } } else if (token.matchString("italic", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("on", true)) { - if (italic != true) { - italic = true; + if (_italic != true) { + _italic = true; retval |= TXT_RET_FNTSTL; } } else if (token.matchString("off", true)) { - if (italic != false) { - italic = false; + if (_italic != false) { + _italic = false; retval |= TXT_RET_FNTSTL; } } @@ -154,13 +154,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("on", true)) { - if (underline != true) { - underline = true; + if (_underline != true) { + _underline = true; retval |= TXT_RET_FNTSTL; } } else if (token.matchString("off", true)) { - if (underline != false) { - underline = false; + if (_underline != false) { + _underline = false; retval |= TXT_RET_FNTSTL; } } @@ -169,13 +169,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("on", true)) { - if (strikeout != true) { - strikeout = true; + if (_strikeout != true) { + _strikeout = true; retval |= TXT_RET_FNTSTL; } } else if (token.matchString("off", true)) { - if (strikeout != false) { - strikeout = false; + if (_strikeout != false) { + _strikeout = false; retval |= TXT_RET_FNTSTL; } } @@ -184,13 +184,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("on", true)) { - if (bold != true) { - bold = true; + if (_bold != true) { + _bold = true; retval |= TXT_RET_FNTSTL; } } else if (token.matchString("off", true)) { - if (bold != false) { - bold = false; + if (_bold != false) { + _bold = false; retval |= TXT_RET_FNTSTL; } } @@ -199,9 +199,9 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("on", true)) { - skipcolor = true; + _skipcolor = true; } else if (token.matchString("off", true)) { - skipcolor = false; + _skipcolor = false; } } } else if (token.matchString("image", true)) { @@ -209,18 +209,18 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { } else if (token.matchString("statebox", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); - statebox = atoi(token.c_str()); + _statebox = atoi(token.c_str()); retval |= TXT_RET_HASSTBOX; } } else if (token.matchString("justify", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); if (token.matchString("center", true)) - justify = TXT_JUSTIFY_CENTER; + _justify = TXT_JUSTIFY_CENTER; else if (token.matchString("left", true)) - justify = TXT_JUSTIFY_LEFT; + _justify = TXT_JUSTIFY_LEFT; else if (token.matchString("right", true)) - justify = TXT_JUSTIFY_RIGHT; + _justify = TXT_JUSTIFY_RIGHT; } } } @@ -247,19 +247,19 @@ void cTxtStyle::readAllStyle(const Common::String &txt) { void cTxtStyle::setFontStyle(StyledTTFont &font) { uint tempStyle = 0; - if (bold) + if (_bold) tempStyle |= StyledTTFont::STTF_BOLD; - if (italic) + if (_italic) tempStyle |= StyledTTFont::STTF_ITALIC; - if (underline) + if (_underline) tempStyle |= StyledTTFont::STTF_UNDERLINE; - if (strikeout) + if (_strikeout) tempStyle |= StyledTTFont::STTF_STRIKEOUT; - if (sharp) + if (_sharp) tempStyle |= StyledTTFont::STTF_SHARP; font.setStyle(tempStyle); @@ -268,27 +268,27 @@ void cTxtStyle::setFontStyle(StyledTTFont &font) { void cTxtStyle::setFont(StyledTTFont &font) { uint tempStyle = 0; - if (bold) + if (_bold) tempStyle |= StyledTTFont::STTF_BOLD; - if (italic) + if (_italic) tempStyle |= StyledTTFont::STTF_ITALIC; - if (underline) + if (_underline) tempStyle |= StyledTTFont::STTF_UNDERLINE; - if (strikeout) + if (_strikeout) tempStyle |= StyledTTFont::STTF_STRIKEOUT; - if (sharp) + if (_sharp) tempStyle |= StyledTTFont::STTF_SHARP; - font.loadFont(fontname, size, tempStyle); + font.loadFont(_fontname, _size, tempStyle); } Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) { style.setFontStyle(fnt); - uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue); + uint32 clr = _engine->_pixelFormat.RGBToColor(style._red, style._green, style._blue); return fnt.renderSolidText(txt, clr); } @@ -307,13 +307,13 @@ int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Gra dst.fillRect(Common::Rect(dst.w, dst.h), 0); - uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle.red, fontStyle.green, fontStyle.blue); + uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue); int16 w; w = font.getStringWidth(txt); - drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle.justify); + drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle._justify); return w; } @@ -352,7 +352,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac int16 prevbufspace = 0, prevtxtspace = 0; while (i < stringlen) { - TxtJustify[currentline] = style.justify; + TxtJustify[currentline] = style._justify; if (text[i] == '<') { int16 ret = 0; @@ -396,7 +396,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac if (ret & TXT_RET_HASSTBOX) { Common::String buf3; - buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style.statebox)); + buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style._statebox)); buf += buf3; textPosition += buf3.size(); } diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index ecec3ccde6..c3c60f6b76 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -55,21 +55,21 @@ public: void setFont(StyledTTFont &font); public: - Common::String fontname; - txtJustify justify; // 0 - center, 1-left, 2-right - int16 size; - uint8 red; // 0-255 - uint8 green; // 0-255 - uint8 blue; // 0-255 - int8 newline; - int8 escapement; - bool italic; - bool bold; - bool underline; - bool strikeout; - bool skipcolor; - int32 statebox; - bool sharp; + Common::String _fontname; + txtJustify _justify; // 0 - center, 1-left, 2-right + int16 _size; + uint8 _red; // 0-255 + uint8 _green; // 0-255 + uint8 _blue; // 0-255 + int8 _newline; + int8 _escapement; + bool _italic; + bool _bold; + bool _underline; + bool _strikeout; + bool _skipcolor; + int32 _statebox; + bool _sharp; // char image ?? }; -- cgit v1.2.3 From c2d83d287faec2bdfd6fac7d665c156670c7b7f7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 02:50:34 +0200 Subject: ZVISION: Allow dumping any file type via the new "dumpfiles" command --- engines/zvision/core/console.cpp | 11 ++++++++--- engines/zvision/core/console.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 0789f8d4fb..07d3114ec8 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,7 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); - registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); + registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -237,12 +237,17 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } -bool Console::cmdDumpAllScripts(int argc, const char **argv) { +bool Console::cmdDumpFiles(int argc, const char **argv) { Common::String fileName; Common::SeekableReadStream *in; + if (argc != 2) { + debugPrintf("Use %s to dump all files with a specific extension\n", argv[0]); + return true; + } + SearchManager::MatchList fileList; - _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); + _engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]); for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { fileName = iter->_value.name; diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h index 7e27fe8f26..a7bd88ebc3 100644 --- a/engines/zvision/core/console.h +++ b/engines/zvision/core/console.h @@ -46,7 +46,7 @@ private: bool cmdSetPanoramaScale(int argc, const char **argv); bool cmdLocation(int argc, const char **argv); bool cmdDumpFile(int argc, const char **argv); - bool cmdDumpAllScripts(int argc, const char **argv); + bool cmdDumpFiles(int argc, const char **argv); }; } // End of namespace ZVision -- cgit v1.2.3 From f364756bcfa952e85c2111270ffda15c9809a4b8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 02:52:55 +0200 Subject: ZVISION: Add support for GNU Freefont fonts. Also, cleanup font loading The Freefont fonts can just be dropped into the extras ScummVM folder, to get the game working under non-Windows systems --- engines/zvision/graphics/truetype_font.cpp | 145 +++++++++++------------------ 1 file changed, 54 insertions(+), 91 deletions(-) diff --git a/engines/zvision/graphics/truetype_font.cpp b/engines/zvision/graphics/truetype_font.cpp index 2dbd7ca358..5c8aa03f6a 100644 --- a/engines/zvision/graphics/truetype_font.cpp +++ b/engines/zvision/graphics/truetype_font.cpp @@ -54,105 +54,68 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st } bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + struct FontStyle { + const char *zorkFont; + const char *fontBase; + const char *freeFontBase; + const char *freeFontItalicName; + }; + + const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic" }, + { "*times*", "times", "FreeSerif", "Italic" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, + { "*garamond*", "gara", "FreeSerif", "Italic" }, + { "*courier new*", "cour", "FreeMono", "Oblique" }, + { "*courier*", "cour", "FreeMono", "Oblique" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, + { "*arial*", "arial", "FreeSans", "Oblique" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, + }; + Common::String newFontName; - if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "timesbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "timesbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "timesi.ttf"; - else - newFontName = "times.ttf"; - - } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "courbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "courbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "couri.ttf"; - else - newFontName = "cour.ttf"; - - } else if (fontName.matchString("*century schoolbook*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "censcbkbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "censcbkbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "censcbki.ttf"; - else - newFontName = "censcbk.ttf"; - - } else if (fontName.matchString("*garamond*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "garabi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "garabd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "garai.ttf"; - else - newFontName = "gara.ttf"; - - } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) { - if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) - newFontName = "arialbi.ttf"; - else if (_style & STTF_BOLD) - newFontName = "arialbd.ttf"; - else if (_style & STTF_ITALIC) - newFontName = "ariali.ttf"; - else - newFontName = "arial.ttf"; + Common::String freeFontName; + + for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { + if (fontName.matchString(systemFonts[i].zorkFont, true)) { + newFontName = systemFonts[i].fontBase; + freeFontName = systemFonts[i].freeFontBase; + + if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { + newFontName += "bi"; + freeFontName += "Bold"; + freeFontName += systemFonts[i].freeFontItalicName; + } else if (_style & STTF_BOLD) { + newFontName += "bd"; + freeFontName += "Bold"; + } else if (_style & STTF_ITALIC) { + newFontName += "i"; + freeFontName += systemFonts[i].freeFontItalicName; + } - } else { + newFontName += ".ttf"; + freeFontName += ".ttf"; + break; + } + } + + if (newFontName.empty()) { debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); newFontName = "arial.ttf"; + freeFontName = "FreeSans.ttf"; } bool sharp = (_style & STTF_SHARP) == STTF_SHARP; - Common::File *file = _engine->getSearchManager()->openFile(newFontName); - - if (!file) { - Common::SeekableReadStream *themeFile = nullptr; - if (ConfMan.hasKey("themepath")) { - Common::FSNode themePath(ConfMan.get("themepath")); - if (themePath.exists()) { - Common::FSNode scummModern = themePath.getChild("scummmodern.zip"); - if (scummModern.exists()) { - themeFile = scummModern.createReadStream(); - } - } - } - if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan. - themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); - } - if (themeFile) { - Common::Archive *themeArchive = Common::makeZipArchive(themeFile); - if (themeArchive->hasFile("FreeSans.ttf")) { - Common::SeekableReadStream *stream = nullptr; - stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); - Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - if (stream) - delete stream; - } - delete themeArchive; - themeArchive = nullptr; - } - } else { - Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - delete file; + Common::File file; + if (!file.open(newFontName) && !file.open(freeFontName)) + error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); + + Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; } _fntName = fontName; -- cgit v1.2.3 From b51852c641cf4d558d035d7d1dd9309d6d238647 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 02:58:18 +0200 Subject: ZVISION: Error out when the game string file isn't found --- engines/zvision/text/string_manager.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/engines/zvision/text/string_manager.cpp b/engines/zvision/text/string_manager.cpp index ec10b6220c..6b870d0b8d 100644 --- a/engines/zvision/text/string_manager.cpp +++ b/engines/zvision/text/string_manager.cpp @@ -43,21 +43,18 @@ StringManager::~StringManager() { } void StringManager::initialize(ZVisionGameId gameId) { - if (gameId == GID_NEMESIS) { - // TODO: Check this hardcoded filename against all versions of Nemesis + if (gameId == GID_NEMESIS) loadStrFile("nemesis.str"); - } else if (gameId == GID_GRANDINQUISITOR) { - // TODO: Check this hardcoded filename against all versions of Grand Inquisitor + else if (gameId == GID_GRANDINQUISITOR) loadStrFile("inquis.str"); - } } void StringManager::loadStrFile(const Common::String &fileName) { Common::File file; if (!_engine->getSearchManager()->openFile(file, fileName)) { - warning("%s does not exist. String parsing failed", fileName.c_str()); - return; + error("%s does not exist. String parsing failed", fileName.c_str()); } + uint lineNumber = 0; while (!file.eos()) { _lines[lineNumber] = readWideLine(file); -- cgit v1.2.3 From b0250e72d88dcb5ddda17aa8e32efc71a4f0e4af Mon Sep 17 00:00:00 2001 From: Fedor Date: Mon, 22 Dec 2014 19:55:10 +0300 Subject: VIDEO: Mark TheoraDecoder as used by pegasus --- video/theora_decoder.h | 1 + 1 file changed, 1 insertion(+) diff --git a/video/theora_decoder.h b/video/theora_decoder.h index b85388426b..feb4c6b49e 100644 --- a/video/theora_decoder.h +++ b/video/theora_decoder.h @@ -50,6 +50,7 @@ namespace Video { * * Decoder for Theora videos. * Video decoder used in engines: + * - pegasus * - sword25 * - wintermute */ -- cgit v1.2.3 From 04bc635dc702606911b8777a443b9e1f6322a6bf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 22 Dec 2014 19:05:56 +0100 Subject: ACCESS: Remove a couple of unused variables in CharManager --- engines/access/char.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/engines/access/char.h b/engines/access/char.h index e89cdae49f..6fb4934978 100644 --- a/engines/access/char.h +++ b/engines/access/char.h @@ -51,11 +51,8 @@ private: void charMenu(); public: Common::Array _charTable; - int _converseMode; int _charFlag; - // Fields that are included in savegames - int _conversation; public: CharManager(AccessEngine *vm); -- cgit v1.2.3 From fc9595efdc22aecb77800dca29fbe23291855c48 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 22 Dec 2014 19:16:11 +0100 Subject: ACCESS: Remove an unused variable in Animation manager --- engines/access/animation.cpp | 5 +---- engines/access/animation.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/engines/access/animation.cpp b/engines/access/animation.cpp index cc699a27e3..14d7c0d4cc 100644 --- a/engines/access/animation.cpp +++ b/engines/access/animation.cpp @@ -63,7 +63,6 @@ Animation::Animation(AccessEngine *vm, Common::SeekableReadStream *stream) : Man _countdownTicks = stream->readUint16LE(); _currentLoopCount = stream->readSint16LE(); stream->readUint16LE(); // unk - _field10 = 0; Common::Array frameOffsets; uint16 ofs; @@ -311,9 +310,7 @@ Animation *AnimationManager::setAnimation(int animId) { anim->_countdownTicks = anim->_initialTicks; anim->_frameNumber = 0; - anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : - anim->_loopCount; - anim->_field10 = 0; + anim->_currentLoopCount = (anim->_type != 3 && anim->_type != 4) ? 0 : anim->_loopCount; return anim; } diff --git a/engines/access/animation.h b/engines/access/animation.h index 722f5430ab..72621c4d11 100644 --- a/engines/access/animation.h +++ b/engines/access/animation.h @@ -106,7 +106,6 @@ public: int _loopCount; int _countdownTicks; int _currentLoopCount; - int _field10; public: Animation(AccessEngine *vm, Common::SeekableReadStream *stream); ~Animation(); -- cgit v1.2.3 From d1bc69426eac2458b46ab7fede31c6dd71314ccb Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 22 Dec 2014 19:41:40 +0100 Subject: ACCESS: Move variable from Room manager to local function --- engines/access/room.cpp | 6 +++--- engines/access/room.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/engines/access/room.cpp b/engines/access/room.cpp index f7c2eabd0f..607259ec6f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -370,9 +370,9 @@ void Room::loadPlayField(int fileNum, int subfile) { screen.loadRawPalette(playData->_stream); // Copy off the tile data - _tileSize = (int)header[2] << 8; - _tile = new byte[_tileSize]; - playData->_stream->read(_tile, _tileSize); + int tileSize = (int)header[2] << 8; + _tile = new byte[tileSize]; + playData->_stream->read(_tile, tileSize); // Copy off the playfield data _matrixSize = header[0] * header[1]; diff --git a/engines/access/room.h b/engines/access/room.h index 44279fa6b1..eec273e3f4 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -124,7 +124,6 @@ public: int _playFieldWidth; int _playFieldHeight; byte *_tile; - int _tileSize; int _selectCommand; bool _conFlag; public: -- cgit v1.2.3 From 58f7c12fa941265a79b453df9b32ec41c49d53c4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 22:11:07 +0200 Subject: ZVISION: Remove dead code --- engines/zvision/graphics/render_table.cpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/engines/zvision/graphics/render_table.cpp b/engines/zvision/graphics/render_table.cpp index c30e0bd472..df73247344 100644 --- a/engines/zvision/graphics/render_table.cpp +++ b/engines/zvision/graphics/render_table.cpp @@ -81,27 +81,6 @@ const Common::Point RenderTable::convertWarpedCoordToFlatCoord(const Common::Poi return newPoint; } -uint16 mixTwoRGB(uint16 colorOne, uint16 colorTwo, float percentColorOne) { - assert(percentColorOne < 1.0f); - - float rOne = float((colorOne & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift); - float rTwo = float((colorTwo & Graphics::ColorMasks<555>::kRedMask) >> Graphics::ColorMasks<555>::kRedShift); - float gOne = float((colorOne & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift); - float gTwo = float((colorTwo & Graphics::ColorMasks<555>::kGreenMask) >> Graphics::ColorMasks<555>::kGreenShift); - float bOne = float((colorOne & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift); - float bTwo = float((colorTwo & Graphics::ColorMasks<555>::kBlueMask) >> Graphics::ColorMasks<555>::kBlueShift); - - float rFinal = rOne * percentColorOne + rTwo * (1.0f - percentColorOne); - float gFinal = gOne * percentColorOne + gTwo * (1.0f - percentColorOne); - float bFinal = bOne * percentColorOne + bTwo * (1.0f - percentColorOne); - - uint16 returnColor = (byte(rFinal + 0.5f) << Graphics::ColorMasks<555>::kRedShift) | - (byte(gFinal + 0.5f) << Graphics::ColorMasks<555>::kGreenShift) | - (byte(bFinal + 0.5f) << Graphics::ColorMasks<555>::kBlueShift); - - return returnColor; -} - void RenderTable::mutateImage(uint16 *sourceBuffer, uint16 *destBuffer, uint32 destWidth, const Common::Rect &subRect) { uint32 destOffset = 0; -- cgit v1.2.3 From 4e60fa705fd22069565cdb17c907f91301a67dc5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 22 Dec 2014 22:23:36 +0200 Subject: ZVISION: Fix regression from commit 3806aa4418 --- engines/zvision/scripting/sidefx/music_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index 56598189f6..6be08b46dc 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -88,7 +88,7 @@ MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool } MusicNode::~MusicNode() { - if (!_loaded) + if (_loaded) _engine->_mixer->stopHandle(_handle); if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); -- cgit v1.2.3 From 3f36cc94e45d32dc4784c16ec91b6fc44dbf0ff7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 00:02:30 +0200 Subject: ZVISION: Limit the default engine delay for all animations This fixes the lag between frames for all in-game animations with a default frame delay --- engines/zvision/scripting/actions.cpp | 7 +++---- engines/zvision/scripting/sidefx/animation_node.cpp | 18 +++++------------- engines/zvision/scripting/sidefx/animation_node.h | 1 - 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 0422a2c028..0ada2edf81 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -577,7 +577,7 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c char fileName[25]; - // The two %*u are always 0 and dont seem to have a use + // The two %*u are usually 0 and dont seem to have a use sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate); if (_mask > 0) { @@ -1030,9 +1030,8 @@ bool ActionSyncSound::execute() { if (!(fx->getType() & SideFX::SIDEFX_ANIM)) return true; - AnimationNode *animnode = (AnimationNode *)fx; - if (animnode->getFrameDelay() > 200) // Hack for fix incorrect framedelay in some animpreload - animnode->setNewFrameDelay(66); // ~15fps + if (((AnimationNode *)fx)->getFrameDelay() > 200) + warning("ActionSyncSound: animation frame delay is higher than 200"); _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); return true; diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 3a21227d1a..56f1fa3e49 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -42,6 +42,11 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _animation = engine->loadAnimation(fileName); _frmDelay = 1000.0 / _animation->getDuration().framerate(); + // WORKAROUND: We do not allow the engine to delay more than 66 msec + // per frame (15fps max) + if (_frmDelay > 66) + _frmDelay = 66; + if (frate > 0) _frmDelay = 1000.0 / frate; } @@ -190,19 +195,6 @@ bool AnimationNode::stop() { return false; } -void AnimationNode::setNewFrameDelay(int32 newDelay) { - if (newDelay > 0) { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - playnode *nod = &(*it); - float percent = (float)nod->_delay / (float)_frmDelay; - nod->_delay = percent * newDelay; // Scale to new max - } - - _frmDelay = newDelay; - } -} - int32 AnimationNode::getFrameDelay() { return _frmDelay; } diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 3adfd91f32..74941aa764 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -73,7 +73,6 @@ public: bool stop(); - void setNewFrameDelay(int32 newDelay); int32 getFrameDelay(); }; -- cgit v1.2.3 From fb924089fc5f6968f5c86fc780131f67268e8de6 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 00:07:17 +0200 Subject: ZVISION: Avoid using color masks for in-game animations This fixes the transparency for some in-game animations. Since colors can be truncated with color masks, and since accurate colors are required for transparency, color masks can't be used. This fixes the transparency of the in-game item examination interface in ZGI --- engines/zvision/video/rlf_decoder.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index bdb5dc18bc..d51dee0c6a 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -30,8 +30,6 @@ #include "common/debug.h" #include "common/endian.h" -#include "graphics/colormasks.h" - namespace ZVision { RLFDecoder::~RLFDecoder() { @@ -62,7 +60,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) return; } - _currentFrameBuffer.create(_width, _height, Graphics::createPixelFormat<565>()); + _currentFrameBuffer.create(_width, _height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); _frameBufferByteSize = _width * _height * sizeof(uint16); _frames = new Frame[_frameCount]; @@ -243,8 +241,10 @@ void RLFDecoder::RLFVideoTrack::decodeMaskedRunLengthEncoding(int8 *source, int8 } byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::RGBToColor >(r, g, b); + // NOTE: Color masks can't be used here, since accurate colors + // are required to handle transparency correctly + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); WRITE_UINT16(dest + destOffset, destColor); sourceOffset += 2; @@ -290,8 +290,10 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 } byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::RGBToColor >(r, g, b); + // NOTE: Color masks can't be used here, since accurate colors + // are required to handle transparency correctly + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); WRITE_UINT16(dest + destOffset, destColor); sourceOffset += 2; @@ -307,8 +309,10 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 } byte r, g, b; - Graphics::colorToRGB >(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 sampleColor = Graphics::RGBToColor >(r, g, b); + // NOTE: Color masks can't be used here, since accurate colors + // are required to handle transparency correctly + Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); + uint16 sampleColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); sourceOffset += 2; numberOfCopy = numberOfSamples + 2; -- cgit v1.2.3 From 9bc0686e6076bbe5ca481c6696f0f7d3c86cd570 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 00:09:18 +0200 Subject: ZVISION: Remove leftover warning --- engines/zvision/scripting/actions.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 0ada2edf81..2a5046f146 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -1030,9 +1030,6 @@ bool ActionSyncSound::execute() { if (!(fx->getType() & SideFX::SIDEFX_ANIM)) return true; - if (((AnimationNode *)fx)->getFrameDelay() > 200) - warning("ActionSyncSound: animation frame delay is higher than 200"); - _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); return true; } -- cgit v1.2.3 From eb4645cda855b0ac919124fefc79c580883903d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 00:10:12 +0200 Subject: ZVISION: Spacing --- engines/zvision/video/rlf_decoder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index d51dee0c6a..b798093869 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -309,8 +309,8 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 } byte r, g, b; - // NOTE: Color masks can't be used here, since accurate colors - // are required to handle transparency correctly + // NOTE: Color masks can't be used here, since accurate colors + // are required to handle transparency correctly Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); uint16 sampleColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); sourceOffset += 2; -- cgit v1.2.3 From cfd00ad6afc09ca6990ce905b1a8db4ea1ad1602 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 22 Dec 2014 22:39:05 +0100 Subject: AGI: use Common::String::format when possible Use Common::String::format instead of a MAXPATHLEN-sized char[] buffer. --- engines/agi/detection.cpp | 6 ++---- engines/agi/loader_v2.cpp | 8 ++++---- engines/agi/loader_v3.cpp | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index e7285d8112..3230b4e5d3 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -276,15 +276,13 @@ SaveStateList AgiMetaEngine::listSaves(const char *target) const { int AgiMetaEngine::getMaximumSaveSlot() const { return 999; } void AgiMetaEngine::removeSaveState(const char *target, int slot) const { - char fileName[MAXPATHLEN]; - sprintf(fileName, "%s.%03d", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); g_system->getSavefileManager()->removeSavefile(fileName); } SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int slot) const { const uint32 AGIflag = MKTAG('A','G','I',':'); - char fileName[MAXPATHLEN]; - sprintf(fileName, "%s.%03d", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName); diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp index 787eeaa0c7..3f164b7fc0 100644 --- a/engines/agi/loader_v2.cpp +++ b/engines/agi/loader_v2.cpp @@ -135,13 +135,13 @@ int AgiLoader_v2::unloadResource(int t, int n) { */ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) { uint8 *data = NULL; - char x[MAXPATHLEN], *path; + char x[MAXPATHLEN]; Common::File fp; unsigned int sig; + Common::String path; - sprintf(x, "vol.%i", agid->volume); - path = x; - debugC(3, kDebugLevelResources, "Vol res: path = %s", path); + path = Common::String::format("vol.%i", agid->volume); + debugC(3, kDebugLevelResources, "Vol res: path = %s", path.c_str()); if (agid->offset != _EMPTY && fp.open(path)) { debugC(3, kDebugLevelResources, "loading resource at offset %d", agid->offset); diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index fa135e5476..b90c17a1f3 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -204,8 +204,7 @@ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) { Common::String path; debugC(3, kDebugLevelResources, "(%p)", (void *)agid); - sprintf(x, "vol.%i", agid->volume); - path = Common::String(_vm->_game.name) + x; + path = Common::String::format("%svol.%i", _vm->_game.name, agid->volume); if (agid->offset != _EMPTY && fp.open(path)) { fp.seek(agid->offset, SEEK_SET); -- cgit v1.2.3 From e8fd25e22f4bce6f6df1a49115ece58bc76bdda3 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 22 Dec 2014 22:43:46 +0100 Subject: DRASCULA: use Common::String::format when possible Use Common::String::format instead of a MAXPATHLEN-sized char[] buffer. --- engines/drascula/detection.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index 833363669d..a84bd11cb1 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -382,8 +382,7 @@ SaveStateList DrasculaMetaEngine::listSaves(const char *target) const { } SaveStateDescriptor DrasculaMetaEngine::querySaveMetaInfos(const char *target, int slot) const { - char fileName[MAXPATHLEN]; - sprintf(fileName, "%s.%03d", target, slot); + Common::String fileName = Common::String::format("%s.%03d", target, slot); Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName); -- cgit v1.2.3 From f29b3658b0caa7af2a3972de09069b9ba80eb494 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Mon, 22 Dec 2014 22:46:52 +0100 Subject: AGI: use shorter sizes for buffers Instead of allocate them with MAXPATHLEN as size, just give them the size for the data that are going to be written on them. --- engines/agi/loader_v2.cpp | 2 +- engines/agi/loader_v3.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/agi/loader_v2.cpp b/engines/agi/loader_v2.cpp index 3f164b7fc0..693c53c2bf 100644 --- a/engines/agi/loader_v2.cpp +++ b/engines/agi/loader_v2.cpp @@ -135,7 +135,7 @@ int AgiLoader_v2::unloadResource(int t, int n) { */ uint8 *AgiLoader_v2::loadVolRes(struct AgiDir *agid) { uint8 *data = NULL; - char x[MAXPATHLEN]; + char x[6]; Common::File fp; unsigned int sig; Common::String path; diff --git a/engines/agi/loader_v3.cpp b/engines/agi/loader_v3.cpp index b90c17a1f3..39759b4649 100644 --- a/engines/agi/loader_v3.cpp +++ b/engines/agi/loader_v3.cpp @@ -198,7 +198,7 @@ int AgiLoader_v3::unloadResource(int t, int n) { * NULL is returned if unsucsessful. */ uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) { - char x[MAXPATHLEN]; + char x[8]; uint8 *data = NULL, *compBuffer; Common::File fp; Common::String path; -- cgit v1.2.3 From 6a53c7cac10294d022e3eb5d47142ad46ef29bd9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 01:45:44 +0200 Subject: ZVISION: Ignore the special 0xCCCC character in subtitles This seems to be used as a newline character --- engines/zvision/text/text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 08b57914c2..4ea40a1d55 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -495,7 +495,7 @@ Common::String readWideLine(Common::SeekableReadStream &stream) { } else if (value >= 0x80 && value < 0x800) { asciiString += (char)(0xC0 | ((value >> 6) & 0x1F)); asciiString += (char)(0x80 | (value & 0x3F)); - } else if (value >= 0x800 && value < 0x10000) { + } else if (value >= 0x800 && value < 0x10000 && value != 0xCCCC) { asciiString += (char)(0xE0 | ((value >> 12) & 0xF)); asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); asciiString += (char)(0x80 | (value & 0x3F)); -- cgit v1.2.3 From 15154641ac5ea674a4865d9478074cf1b1d8a36b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 01:53:40 +0200 Subject: ZVISION: Move all of the text related code together --- engines/zvision/graphics/render_manager.h | 2 +- engines/zvision/graphics/subtitles.cpp | 108 ---------- engines/zvision/graphics/subtitles.h | 54 ----- engines/zvision/graphics/truetype_font.cpp | 228 ---------------------- engines/zvision/graphics/truetype_font.h | 84 -------- engines/zvision/module.mk | 4 +- engines/zvision/scripting/sidefx/music_node.h | 2 +- engines/zvision/scripting/sidefx/syncsound_node.h | 2 +- engines/zvision/scripting/sidefx/ttytext_node.h | 2 +- engines/zvision/text/string_manager.h | 2 +- engines/zvision/text/subtitles.cpp | 108 ++++++++++ engines/zvision/text/subtitles.h | 54 +++++ engines/zvision/text/text.cpp | 2 +- engines/zvision/text/text.h | 2 +- engines/zvision/text/truetype_font.cpp | 228 ++++++++++++++++++++++ engines/zvision/text/truetype_font.h | 84 ++++++++ engines/zvision/video/video.cpp | 2 +- engines/zvision/zvision.cpp | 2 +- 18 files changed, 485 insertions(+), 485 deletions(-) delete mode 100644 engines/zvision/graphics/subtitles.cpp delete mode 100644 engines/zvision/graphics/subtitles.h delete mode 100644 engines/zvision/graphics/truetype_font.cpp delete mode 100644 engines/zvision/graphics/truetype_font.h create mode 100644 engines/zvision/text/subtitles.cpp create mode 100644 engines/zvision/text/subtitles.h create mode 100644 engines/zvision/text/truetype_font.cpp create mode 100644 engines/zvision/text/truetype_font.h diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 29bbd8f411..711c607c7b 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -24,7 +24,7 @@ #define ZVISION_RENDER_MANAGER_H #include "zvision/graphics/render_table.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" #include "common/rect.h" #include "common/hashmap.h" diff --git a/engines/zvision/graphics/subtitles.cpp b/engines/zvision/graphics/subtitles.cpp deleted file mode 100644 index d2c56f0991..0000000000 --- a/engines/zvision/graphics/subtitles.cpp +++ /dev/null @@ -1,108 +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 "zvision/graphics/render_manager.h" -#include "zvision/graphics/subtitles.h" -#include "zvision/file/search_manager.h" -#include "zvision/text/text.h" - -namespace ZVision { - -Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : - _engine(engine), - _areaId(-1), - _subId(-1) { - Common::File file; - if (_engine->getSearchManager()->openFile(file, subname)) { - while (!file.eos()) { - Common::String str = file.readLine(); - if (str.lastChar() == '~') - str.deleteLastChar(); - - if (str.matchString("*Initialization*", true)) { - // Not used - } else if (str.matchString("*Rectangle*", true)) { - int32 x1, y1, x2, y2; - sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); - Common::Rect rct = Common::Rect(x1, y1, x2, y2); - _areaId = _engine->getRenderManager()->createSubArea(rct); - } else if (str.matchString("*TextFile*", true)) { - char filename[64]; - sscanf(str.c_str(), "%*[^:]:%s", filename); - Common::File txt; - if (_engine->getSearchManager()->openFile(txt, filename)) { - while (!txt.eos()) { - Common::String txtline = readWideLine(txt); - sub curSubtitle; - curSubtitle.start = -1; - curSubtitle.stop = -1; - curSubtitle.subStr = txtline; - - _subs.push_back(curSubtitle); - } - txt.close(); - } - } else { - int32 st; - int32 en; - int32 sb; - if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { - if (sb <= (int32)_subs.size()) { - _subs[sb].start = st; - _subs[sb].stop = en; - } - } - } - } - } -} - -Subtitle::~Subtitle() { - if (_areaId != -1) - _engine->getRenderManager()->deleteSubArea(_areaId); - - _subs.clear(); -} - -void Subtitle::process(int32 time) { - int16 j = -1; - for (uint16 i = 0; i < _subs.size(); i++) - if (time >= _subs[i].start && time <= _subs[i].stop) { - j = i; - break; - } - - if (j == -1 && _subId != -1) { - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, ""); - _subId = -1; - } - - if (j != -1 && j != _subId) { - if (_subs[j].subStr.size()) - if (_areaId != -1) - _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr); - _subId = j; - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/graphics/subtitles.h b/engines/zvision/graphics/subtitles.h deleted file mode 100644 index c3da6583a4..0000000000 --- a/engines/zvision/graphics/subtitles.h +++ /dev/null @@ -1,54 +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 ZVISION_SUBTITLES_H -#define ZVISION_SUBTITLES_H - -#include "zvision/zvision.h" - -namespace ZVision { - -class ZVision; - -class Subtitle { -public: - Subtitle(ZVision *engine, const Common::String &subname); - ~Subtitle(); - - void process(int32 time); -private: - ZVision *_engine; - int32 _areaId; - int16 _subId; - - struct sub { - int start; - int stop; - Common::String subStr; - }; - - Common::Array _subs; -}; - -} - -#endif diff --git a/engines/zvision/graphics/truetype_font.cpp b/engines/zvision/graphics/truetype_font.cpp deleted file mode 100644 index 5c8aa03f6a..0000000000 --- a/engines/zvision/graphics/truetype_font.cpp +++ /dev/null @@ -1,228 +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 "common/scummsys.h" -#include "common/config-manager.h" -#include "common/debug.h" -#include "common/file.h" -#include "common/system.h" -#include "common/unzip.h" -#include "graphics/font.h" -#include "graphics/fonts/ttf.h" -#include "graphics/surface.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/graphics/truetype_font.h" - -namespace ZVision { - -StyledTTFont::StyledTTFont(ZVision *engine) { - _engine = engine; - _style = 0; - _font = NULL; - _lineHeight = 0; -} - -StyledTTFont::~StyledTTFont() { - if (_font) - delete _font; -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { - _style = style; - return loadFont(fontName, point); -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { - struct FontStyle { - const char *zorkFont; - const char *fontBase; - const char *freeFontBase; - const char *freeFontItalicName; - }; - - const FontStyle systemFonts[] = { - { "*times new roman*", "times", "FreeSerif", "Italic" }, - { "*times*", "times", "FreeSerif", "Italic" }, - { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, - { "*garamond*", "gara", "FreeSerif", "Italic" }, - { "*courier new*", "cour", "FreeMono", "Oblique" }, - { "*courier*", "cour", "FreeMono", "Oblique" }, - { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, - { "*arial*", "arial", "FreeSans", "Oblique" }, - { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, - }; - - Common::String newFontName; - Common::String freeFontName; - - for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { - if (fontName.matchString(systemFonts[i].zorkFont, true)) { - newFontName = systemFonts[i].fontBase; - freeFontName = systemFonts[i].freeFontBase; - - if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { - newFontName += "bi"; - freeFontName += "Bold"; - freeFontName += systemFonts[i].freeFontItalicName; - } else if (_style & STTF_BOLD) { - newFontName += "bd"; - freeFontName += "Bold"; - } else if (_style & STTF_ITALIC) { - newFontName += "i"; - freeFontName += systemFonts[i].freeFontItalicName; - } - - newFontName += ".ttf"; - freeFontName += ".ttf"; - break; - } - } - - if (newFontName.empty()) { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - newFontName = "arial.ttf"; - freeFontName = "FreeSans.ttf"; - } - - bool sharp = (_style & STTF_SHARP) == STTF_SHARP; - - Common::File file; - if (!file.open(newFontName) && !file.open(freeFontName)) - error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); - - Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - - _fntName = fontName; - _lineHeight = point; - - if (_font) - return true; - return false; -} - -void StyledTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { - _style = newStyle; - loadFont(_fntName, _lineHeight); - } else { - _style = newStyle; - } -} - -int StyledTTFont::getFontHeight() { - if (_font) - return _font->getFontHeight(); - return 0; -} - -int StyledTTFont::getMaxCharWidth() { - if (_font) - return _font->getMaxCharWidth(); - return 0; -} - -int StyledTTFont::getCharWidth(byte chr) { - if (_font) - return _font->getCharWidth(chr); - return 0; -} - -int StyledTTFont::getKerningOffset(byte left, byte right) { - if (_font) - return _font->getKerningOffset(left, right); - return 0; -} - -void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { - if (_font) { - _font->drawChar(dst, chr, x, y, color); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - } -} - -void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { - if (_font) { - _font->drawString(dst, str, x, y, w, color, align); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - } -} - -int StyledTTFont::getStringWidth(const Common::String &str) { - if (_font) - return _font->getStringWidth(str); - return 0; -} - -Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { - Graphics::Surface *tmp = new Graphics::Surface; - if (_font) { - int16 w = _font->getStringWidth(str); - if (w && w < 1024) { - tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); - drawString(tmp, str, 0, 0, w, color); - } - } - return tmp; -} - -} // End of namespace ZVision diff --git a/engines/zvision/graphics/truetype_font.h b/engines/zvision/graphics/truetype_font.h deleted file mode 100644 index b5fac4af8a..0000000000 --- a/engines/zvision/graphics/truetype_font.h +++ /dev/null @@ -1,84 +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. - * - */ - -// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp - -#ifndef ZVISION_TRUETYPE_FONT_H -#define ZVISION_TRUETYPE_FONT_H - -#include "graphics/font.h" -#include "graphics/pixelformat.h" - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; - -// Styled TTF -class StyledTTFont { -public: - StyledTTFont(ZVision *engine); - ~StyledTTFont(); - - enum { - STTF_BOLD = 1, - STTF_ITALIC = 2, - STTF_UNDERLINE = 4, - STTF_STRIKEOUT = 8, - STTF_SHARP = 16 - }; - -private: - ZVision *_engine; - Graphics::Font *_font; - int _lineHeight; - uint _style; - Common::String _fntName; - -public: - bool loadFont(const Common::String &fontName, int32 point); - bool loadFont(const Common::String &fontName, int32 point, uint style); - void setStyle(uint newStyle); - - int getFontHeight(); - int getMaxCharWidth(); - int getCharWidth(byte chr); - int getKerningOffset(byte left, byte right); - - void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); - - void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); - int getStringWidth(const Common::String &str); - - Graphics::Surface *renderSolidText(const Common::String &str, uint32 color); - - bool isLoaded() { - return _font != NULL; - }; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 00652f0824..3ea31abe1b 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -17,8 +17,6 @@ MODULE_OBJS := \ graphics/effects/wave.o \ graphics/render_manager.o \ graphics/render_table.o \ - graphics/subtitles.o \ - graphics/truetype_font.o \ scripting/actions.o \ scripting/control.o \ scripting/controls/fist_control.o \ @@ -44,7 +42,9 @@ MODULE_OBJS := \ sound/midi.o \ sound/zork_raw.o \ text/string_manager.o \ + text/subtitles.o \ text/text.o \ + text/truetype_font.o \ video/rlf_decoder.o \ video/video.o \ video/zork_avi_decoder.o \ diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index 09bdc3707e..8f4a46f3fc 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/scripting/sidefx.h" -#include "zvision/graphics/subtitles.h" +#include "zvision/text/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h index 7cd02a8aef..5961fccab9 100644 --- a/engines/zvision/scripting/sidefx/syncsound_node.h +++ b/engines/zvision/scripting/sidefx/syncsound_node.h @@ -25,7 +25,7 @@ #include "audio/mixer.h" #include "zvision/scripting/sidefx.h" -#include "zvision/graphics/subtitles.h" +#include "zvision/text/subtitles.h" namespace Common { class String; diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h index b6cbed3e34..26d9be8e77 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.h +++ b/engines/zvision/scripting/sidefx/ttytext_node.h @@ -28,7 +28,7 @@ #include "zvision/scripting/sidefx.h" #include "zvision/text/text.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" namespace Common { class String; diff --git a/engines/zvision/text/string_manager.h b/engines/zvision/text/string_manager.h index b77ad65040..f4564ee1ec 100644 --- a/engines/zvision/text/string_manager.h +++ b/engines/zvision/text/string_manager.h @@ -24,7 +24,7 @@ #define ZVISION_STRING_MANAGER_H #include "zvision/detection.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" namespace Graphics { class FontManager; diff --git a/engines/zvision/text/subtitles.cpp b/engines/zvision/text/subtitles.cpp new file mode 100644 index 0000000000..acf4c37c2f --- /dev/null +++ b/engines/zvision/text/subtitles.cpp @@ -0,0 +1,108 @@ +/* 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 "zvision/graphics/render_manager.h" +#include "zvision/text/subtitles.h" +#include "zvision/file/search_manager.h" +#include "zvision/text/text.h" + +namespace ZVision { + +Subtitle::Subtitle(ZVision *engine, const Common::String &subname) : + _engine(engine), + _areaId(-1), + _subId(-1) { + Common::File file; + if (_engine->getSearchManager()->openFile(file, subname)) { + while (!file.eos()) { + Common::String str = file.readLine(); + if (str.lastChar() == '~') + str.deleteLastChar(); + + if (str.matchString("*Initialization*", true)) { + // Not used + } else if (str.matchString("*Rectangle*", true)) { + int32 x1, y1, x2, y2; + sscanf(str.c_str(), "%*[^:]:%d %d %d %d", &x1, &y1, &x2, &y2); + Common::Rect rct = Common::Rect(x1, y1, x2, y2); + _areaId = _engine->getRenderManager()->createSubArea(rct); + } else if (str.matchString("*TextFile*", true)) { + char filename[64]; + sscanf(str.c_str(), "%*[^:]:%s", filename); + Common::File txt; + if (_engine->getSearchManager()->openFile(txt, filename)) { + while (!txt.eos()) { + Common::String txtline = readWideLine(txt); + sub curSubtitle; + curSubtitle.start = -1; + curSubtitle.stop = -1; + curSubtitle.subStr = txtline; + + _subs.push_back(curSubtitle); + } + txt.close(); + } + } else { + int32 st; + int32 en; + int32 sb; + if (sscanf(str.c_str(), "%*[^:]:(%d,%d)=%d", &st, &en, &sb) == 3) { + if (sb <= (int32)_subs.size()) { + _subs[sb].start = st; + _subs[sb].stop = en; + } + } + } + } + } +} + +Subtitle::~Subtitle() { + if (_areaId != -1) + _engine->getRenderManager()->deleteSubArea(_areaId); + + _subs.clear(); +} + +void Subtitle::process(int32 time) { + int16 j = -1; + for (uint16 i = 0; i < _subs.size(); i++) + if (time >= _subs[i].start && time <= _subs[i].stop) { + j = i; + break; + } + + if (j == -1 && _subId != -1) { + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, ""); + _subId = -1; + } + + if (j != -1 && j != _subId) { + if (_subs[j].subStr.size()) + if (_areaId != -1) + _engine->getRenderManager()->updateSubArea(_areaId, _subs[j].subStr); + _subId = j; + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/text/subtitles.h b/engines/zvision/text/subtitles.h new file mode 100644 index 0000000000..c3da6583a4 --- /dev/null +++ b/engines/zvision/text/subtitles.h @@ -0,0 +1,54 @@ +/* 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 ZVISION_SUBTITLES_H +#define ZVISION_SUBTITLES_H + +#include "zvision/zvision.h" + +namespace ZVision { + +class ZVision; + +class Subtitle { +public: + Subtitle(ZVision *engine, const Common::String &subname); + ~Subtitle(); + + void process(int32 time); +private: + ZVision *_engine; + int32 _areaId; + int16 _subId; + + struct sub { + int start; + int stop; + Common::String subStr; + }; + + Common::Array _subs; +}; + +} + +#endif diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 4ea40a1d55..91a06883b6 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -33,7 +33,7 @@ #include "zvision/text/text.h" #include "zvision/graphics/render_manager.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" #include "zvision/scripting/script_manager.h" namespace ZVision { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index c3c60f6b76..c278b011c7 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -25,7 +25,7 @@ #define ZVISION_TEXT_H #include "zvision/detection.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" #include "zvision/zvision.h" namespace ZVision { diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp new file mode 100644 index 0000000000..f373afe437 --- /dev/null +++ b/engines/zvision/text/truetype_font.cpp @@ -0,0 +1,228 @@ +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/system.h" +#include "common/unzip.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/text/truetype_font.h" + +namespace ZVision { + +StyledTTFont::StyledTTFont(ZVision *engine) { + _engine = engine; + _style = 0; + _font = NULL; + _lineHeight = 0; +} + +StyledTTFont::~StyledTTFont() { + if (_font) + delete _font; +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { + _style = style; + return loadFont(fontName, point); +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + struct FontStyle { + const char *zorkFont; + const char *fontBase; + const char *freeFontBase; + const char *freeFontItalicName; + }; + + const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic" }, + { "*times*", "times", "FreeSerif", "Italic" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, + { "*garamond*", "gara", "FreeSerif", "Italic" }, + { "*courier new*", "cour", "FreeMono", "Oblique" }, + { "*courier*", "cour", "FreeMono", "Oblique" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, + { "*arial*", "arial", "FreeSans", "Oblique" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, + }; + + Common::String newFontName; + Common::String freeFontName; + + for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { + if (fontName.matchString(systemFonts[i].zorkFont, true)) { + newFontName = systemFonts[i].fontBase; + freeFontName = systemFonts[i].freeFontBase; + + if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { + newFontName += "bi"; + freeFontName += "Bold"; + freeFontName += systemFonts[i].freeFontItalicName; + } else if (_style & STTF_BOLD) { + newFontName += "bd"; + freeFontName += "Bold"; + } else if (_style & STTF_ITALIC) { + newFontName += "i"; + freeFontName += systemFonts[i].freeFontItalicName; + } + + newFontName += ".ttf"; + freeFontName += ".ttf"; + break; + } + } + + if (newFontName.empty()) { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + newFontName = "arial.ttf"; + freeFontName = "FreeSans.ttf"; + } + + bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + + Common::File file; + if (!file.open(newFontName) && !file.open(freeFontName)) + error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); + + Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + + _fntName = fontName; + _lineHeight = point; + + if (_font) + return true; + return false; +} + +void StyledTTFont::setStyle(uint newStyle) { + if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { + _style = newStyle; + loadFont(_fntName, _lineHeight); + } else { + _style = newStyle; + } +} + +int StyledTTFont::getFontHeight() { + if (_font) + return _font->getFontHeight(); + return 0; +} + +int StyledTTFont::getMaxCharWidth() { + if (_font) + return _font->getMaxCharWidth(); + return 0; +} + +int StyledTTFont::getCharWidth(byte chr) { + if (_font) + return _font->getCharWidth(chr); + return 0; +} + +int StyledTTFont::getKerningOffset(byte left, byte right) { + if (_font) + return _font->getKerningOffset(left, right); + return 0; +} + +void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { + if (_font) { + _font->drawChar(dst, chr, x, y, color); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + } +} + +void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { + if (_font) { + _font->drawString(dst, str, x, y, w, color, align); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + } +} + +int StyledTTFont::getStringWidth(const Common::String &str) { + if (_font) + return _font->getStringWidth(str); + return 0; +} + +Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { + Graphics::Surface *tmp = new Graphics::Surface; + if (_font) { + int16 w = _font->getStringWidth(str); + if (w && w < 1024) { + tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); + drawString(tmp, str, 0, 0, w, color); + } + } + return tmp; +} + +} // End of namespace ZVision diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h new file mode 100644 index 0000000000..b5fac4af8a --- /dev/null +++ b/engines/zvision/text/truetype_font.h @@ -0,0 +1,84 @@ +/* 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. + * + */ + +// This file is based on engines/wintermute/base/fonts/base_font_truetype.h/.cpp + +#ifndef ZVISION_TRUETYPE_FONT_H +#define ZVISION_TRUETYPE_FONT_H + +#include "graphics/font.h" +#include "graphics/pixelformat.h" + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; + +// Styled TTF +class StyledTTFont { +public: + StyledTTFont(ZVision *engine); + ~StyledTTFont(); + + enum { + STTF_BOLD = 1, + STTF_ITALIC = 2, + STTF_UNDERLINE = 4, + STTF_STRIKEOUT = 8, + STTF_SHARP = 16 + }; + +private: + ZVision *_engine; + Graphics::Font *_font; + int _lineHeight; + uint _style; + Common::String _fntName; + +public: + bool loadFont(const Common::String &fontName, int32 point); + bool loadFont(const Common::String &fontName, int32 point, uint style); + void setStyle(uint newStyle); + + int getFontHeight(); + int getMaxCharWidth(); + int getCharWidth(byte chr); + int getKerningOffset(byte left, byte right); + + void drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color); + + void drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align = Graphics::kTextAlignLeft); + int getStringWidth(const Common::String &str); + + Graphics::Surface *renderSolidText(const Common::String &str, uint32 color); + + bool isLoaded() { + return _font != NULL; + }; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 189fb22194..97fbd8721c 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -29,7 +29,7 @@ #include "zvision/zvision.h" #include "zvision/core/clock.h" #include "zvision/graphics/render_manager.h" -#include "zvision/graphics/subtitles.h" +#include "zvision/text/subtitles.h" #include "zvision/video/rlf_decoder.h" #include "zvision/video/zork_avi_decoder.h" diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index c32cceb26e..cf7ed288d7 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -33,7 +33,7 @@ #include "zvision/core/menu.h" #include "zvision/file/search_manager.h" #include "zvision/text/text.h" -#include "zvision/graphics/truetype_font.h" +#include "zvision/text/truetype_font.h" #include "zvision/sound/midi.h" #include "zvision/file/zfs_archive.h" -- cgit v1.2.3 From 7aeeeabba9de168e76ae4d82b7f033fc877d0671 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 01:57:37 +0200 Subject: ZVISION: Add a comment about the special 0xCCCC character --- engines/zvision/text/text.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 91a06883b6..d1dc784f3e 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -499,6 +499,8 @@ Common::String readWideLine(Common::SeekableReadStream &stream) { asciiString += (char)(0xE0 | ((value >> 12) & 0xF)); asciiString += (char)(0x80 | ((value >> 6) & 0x3F)); asciiString += (char)(0x80 | (value & 0x3F)); + } else if (value == 0xCCCC) { + // Ignore, this character is used as newline sometimes } else if (value >= 0x10000 && value < 0x200000) { asciiString += (char)(0xF0); asciiString += (char)(0x80 | ((value >> 12) & 0x3F)); -- cgit v1.2.3 From 99073f9b57580570b5ecec4cb00f020867f02672 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 02:20:17 +0200 Subject: ZVISION: Fix some buffer overruns with the usage of sscanf() --- engines/zvision/scripting/actions.cpp | 18 +++++++++--------- engines/zvision/scripting/controls/input_control.cpp | 2 +- engines/zvision/scripting/controls/lever_control.cpp | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 2a5046f146..5af847c61a 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -363,7 +363,7 @@ ActionInventory::ActionInventory(ZVision *engine, int32 slotkey, const Common::S _key = 0; char buf[25]; - sscanf(line.c_str(), "%25s %d", buf, &_key); + sscanf(line.c_str(), "%24s %d", buf, &_key); if (strcmp(buf, "add") == 0) { _type = 0; @@ -414,7 +414,7 @@ ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &lin _key = 0; _type = 0; char keytype[25]; - sscanf(line.c_str(), "%25s", keytype); + sscanf(line.c_str(), "%24s", keytype); if (keytype[0] == '"') { if (!scumm_stricmp(keytype, "\"ANIM\"")) _type = SideFX::SIDEFX_ANIM; @@ -475,7 +475,7 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l uint loop = 0; uint volume = 255; - sscanf(line.c_str(), "%u %25s %u %u", &type, fileNameBuffer, &loop, &volume); + sscanf(line.c_str(), "%u %24s %u %u", &type, fileNameBuffer, &loop, &volume); // type 4 are midi sound effect files if (type == 4) { @@ -578,7 +578,7 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c char fileName[25]; // The two %*u are usually 0 and dont seem to have a use - sscanf(line.c_str(), "%25s %*u %*u %d %d", fileName, &_mask, &_framerate); + sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate); if (_mask > 0) { byte r, g, b; @@ -645,7 +645,7 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C // The two %*u are always 0 and dont seem to have a use sscanf(line.c_str(), - "%25s %u %u %u %u %u %u %d %*u %*u %d %d", + "%24s %u %u %u %u %u %u %d %*u %*u %d %d", fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); if (_mask > 0) { @@ -863,7 +863,7 @@ ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, c char fileName[25]; int color; - sscanf(line.c_str(), "%u %u %25s %*u %d", &_x, &_y, fileName, &color); + sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &color); _fileName = Common::String(fileName); @@ -907,7 +907,7 @@ bool ActionSetPartialScreen::execute() { ActionSetScreen::ActionSetScreen(ZVision *engine, int32 slotkey, const Common::String &line) : ResultAction(engine, slotkey) { char fileName[25]; - sscanf(line.c_str(), "%25s", fileName); + sscanf(line.c_str(), "%24s", fileName); _fileName = Common::String(fileName); } @@ -966,7 +966,7 @@ ActionStreamVideo::ActionStreamVideo(ZVision *engine, int32 slotkey, const Commo char fileName[25]; uint skipline = 0; //skipline - render video with skip every second line, not skippable. - sscanf(line.c_str(), "%25s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); + sscanf(line.c_str(), "%24s %u %u %u %u %u %u", fileName, &_x1, &_y1, &_x2, &_y2, &_flags, &skipline); _fileName = Common::String(fileName); _skippable = true; @@ -1017,7 +1017,7 @@ ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::S char fileName[25]; int notUsed = 0; - sscanf(line.c_str(), "%d %d %25s", &_syncto, ¬Used, fileName); + sscanf(line.c_str(), "%d %d %24s", &_syncto, ¬Used, fileName); _fileName = Common::String(fileName); } diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index e75cc15743..d7734f6d7a 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -96,7 +96,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre } else if (param.matchString("cursor_animation", true)) { char fileName[25]; - sscanf(values.c_str(), "%25s %*u", fileName); + sscanf(values.c_str(), "%24s %*u", fileName); _animation = _engine->loadAnimation(fileName); _frame = -1; diff --git a/engines/zvision/scripting/controls/lever_control.cpp b/engines/zvision/scripting/controls/lever_control.cpp index 8faa18357c..bef51f0e91 100644 --- a/engines/zvision/scripting/controls/lever_control.cpp +++ b/engines/zvision/scripting/controls/lever_control.cpp @@ -64,12 +64,12 @@ LeverControl::LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStre while (!stream.eos() && !line.contains('}')) { if (param.matchString("descfile", true)) { char levFileName[25]; - sscanf(values.c_str(), "%25s", levFileName); + sscanf(values.c_str(), "%24s", levFileName); parseLevFile(levFileName); } else if (param.matchString("cursor", true)) { char cursorName[25]; - sscanf(values.c_str(), "%25s", cursorName); + sscanf(values.c_str(), "%24s", cursorName); _cursor = _engine->getCursorManager()->getCursorId(Common::String(cursorName)); } -- cgit v1.2.3 From 11cb47e89772ea59fc55d2801685d1a3505235a0 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:25:42 -0600 Subject: ZVISION: Remove unnecessary math --- engines/zvision/core/events.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 6e8cf1fe4f..72e7f33266 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -296,18 +296,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -318,18 +320,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - if (mspeed <= 0) - mspeed = 400 >> 4; _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; + if (mspeed <= 0) { + mspeed = 25; + } _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From 6548300a4182e1dc805b390678df800b05d07554 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:27:53 -0600 Subject: ZVISION: Use Common::Rational to simplify fixed point math --- engines/zvision/core/events.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 72e7f33266..ccd7772975 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -296,20 +296,21 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (ROTATION_SCREEN_EDGE_OFFSET + _workingWindow.left)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.x - (_workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -320,20 +321,20 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (clippedPos.y >= _workingWindow.top && clippedPos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; } else if (clippedPos.y <= _workingWindow.bottom && clippedPos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; - _mouseVelocity = (((clippedPos.y - (_workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET)) << 7) / ROTATION_SCREEN_EDGE_OFFSET * mspeed) >> 7; if (mspeed <= 0) { mspeed = 25; } + _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From 40bd4c485f9ab24e667e66a047214eb7dcef73e8 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:38:44 -0600 Subject: ZVISION: Clamp the rotation velocity to never be zero Before, if we set the in-game preferences to have very low rotation speed, the velocity ends up always being 0 - 0.99 Hence, when we convert back to an int, everything gets truncated to zero. Therefore, we clamp, in order to ensure the user can always move, no matter which setting they use. --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index ccd7772975..1920ffd769 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -299,7 +299,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_Left); @@ -310,7 +310,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -324,7 +324,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -334,7 +334,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3 From 9f1fd0dbff6e1702f49708c8ef4cc91f3b44ca4e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 11:03:02 +0200 Subject: ZVISION: Disable unused code --- engines/zvision/text/text.cpp | 8 +++++++- engines/zvision/text/text.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index d1dc784f3e..53fcafd027 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -44,10 +44,12 @@ cTxtStyle::cTxtStyle() { _green = 255; _red = 255; _bold = false; +#if 0 + _newline = false; _escapement = 0; +#endif _italic = false; _justify = TXT_JUSTIFY_LEFT; - _newline = false; _size = 12; _skipcolor = false; _strikeout = false; @@ -115,10 +117,12 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { } } } else if (token.matchString("newline", true)) { +#if 0 if ((retval & TXT_RET_NEWLN) == 0) _newline = 0; _newline++; +#endif retval |= TXT_RET_NEWLN; } else if (token.matchString("point", true)) { if (!tokenizer.empty()) { @@ -132,8 +136,10 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { } else if (token.matchString("escapement", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); +#if 0 int32 tmp = atoi(token.c_str()); _escapement = tmp; +#endif } } else if (token.matchString("italic", true)) { if (!tokenizer.empty()) { diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index c278b011c7..c044e91579 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -61,8 +61,10 @@ public: uint8 _red; // 0-255 uint8 _green; // 0-255 uint8 _blue; // 0-255 +#if 0 int8 _newline; int8 _escapement; +#endif bool _italic; bool _bold; bool _underline; -- cgit v1.2.3 From 490382098eb122e25aa895dc8de7330c22b1fcf8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 11:06:39 +0200 Subject: ZVISION: Disable more unused code --- engines/zvision/text/text.cpp | 4 ++++ engines/zvision/text/text.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 53fcafd027..8ddba3fbab 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -51,7 +51,9 @@ cTxtStyle::cTxtStyle() { _italic = false; _justify = TXT_JUSTIFY_LEFT; _size = 12; +#if 0 _skipcolor = false; +#endif _strikeout = false; _underline = false; _statebox = 0; @@ -204,11 +206,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) { } else if (token.matchString("skipcolor", true)) { if (!tokenizer.empty()) { token = tokenizer.nextToken(); +#if 0 if (token.matchString("on", true)) { _skipcolor = true; } else if (token.matchString("off", true)) { _skipcolor = false; } +#endif } } else if (token.matchString("image", true)) { // Not used diff --git a/engines/zvision/text/text.h b/engines/zvision/text/text.h index c044e91579..c942b8141a 100644 --- a/engines/zvision/text/text.h +++ b/engines/zvision/text/text.h @@ -69,7 +69,9 @@ public: bool _bold; bool _underline; bool _strikeout; +#if 0 bool _skipcolor; +#endif int32 _statebox; bool _sharp; // char image ?? -- cgit v1.2.3 From e8cc098cd4303a959e69769eae2d37dd949d27d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 11:54:39 +0200 Subject: ZVISION: Limit the engine delay, even when a custom frame rate is set --- engines/zvision/scripting/sidefx/animation_node.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 56f1fa3e49..4f26f039cc 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -42,13 +42,13 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _animation = engine->loadAnimation(fileName); _frmDelay = 1000.0 / _animation->getDuration().framerate(); + if (frate > 0) + _frmDelay = 1000.0 / frate; + // WORKAROUND: We do not allow the engine to delay more than 66 msec // per frame (15fps max) if (_frmDelay > 66) _frmDelay = 66; - - if (frate > 0) - _frmDelay = 1000.0 / frate; } AnimationNode::~AnimationNode() { -- cgit v1.2.3 From 78ba3e32466992ee7d01aabff493617a6401273e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 21:46:20 +0200 Subject: ZVISION: Add error checking when loading in-game animations and videos --- engines/zvision/video/rlf_decoder.cpp | 14 +++++++------- engines/zvision/video/video.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index b798093869..76fd70cf35 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -39,9 +39,13 @@ RLFDecoder::~RLFDecoder() { bool RLFDecoder::loadStream(Common::SeekableReadStream *stream) { close(); - addTrack(new RLFVideoTrack(stream)); - - return true; + // Check if the stream is valid + if (stream && !stream->err() && stream->readUint32BE() == MKTAG('F', 'E', 'L', 'R')) { + addTrack(new RLFVideoTrack(stream)); + return true; + } else { + return false; + } } RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) @@ -81,10 +85,6 @@ RLFDecoder::RLFVideoTrack::~RLFVideoTrack() { } bool RLFDecoder::RLFVideoTrack::readHeader() { - if (_readStream->readUint32BE() != MKTAG('F', 'E', 'L', 'R')) { - return false; - } - // Read the header _readStream->readUint32LE(); // Size1 _readStream->readUint32LE(); // Unknown1 diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 97fbd8721c..50a6fc136a 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -48,7 +48,12 @@ Video::VideoDecoder *ZVision::loadAnimation(const Common::String &fileName) { error("Unknown suffix for animation %s", fileName.c_str()); Common::File *_file = getSearchManager()->openFile(tmpFileName); - animation->loadStream(_file); + if (!_file) + error("Error opening %s", tmpFileName.c_str()); + + bool loaded = animation->loadStream(_file); + if (!loaded) + error("Error loading animation %s", tmpFileName.c_str()); return animation; } -- cgit v1.2.3 From 6edc16b6863c3957efa5ad23596e904d89f8627c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 21:54:53 +0200 Subject: ZVISION: Spacing --- engines/zvision/scripting/sidefx/animation_node.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 4f26f039cc..134ab1396f 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -111,7 +111,6 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { } if (frame) { - uint32 dstw; uint32 dsth; if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { -- cgit v1.2.3 From 6afeec129504a16ee67c77b35cd27f0808d566d2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 23 Dec 2014 21:55:42 +0200 Subject: ZVISION: Handle animation rewinding outside the RLF encoder --- engines/zvision/video/rlf_decoder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 76fd70cf35..f1ac10bf88 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -200,9 +200,8 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { } const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() { - // When an animation ends, rewind if (_curFrame == (int)_frameCount) - seek(Audio::Timestamp(0, getFrameRate().toInt())); + return NULL; applyFrameToCurrent(_curFrame); -- cgit v1.2.3 From 9948d3ca16ceff79dd3ccf6dde5024de04470f08 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 06:13:49 +0200 Subject: ZVISION: Add a hack to set the correct frame delay for RLF videos Also, use Common::Rational to avoid using floating point math --- engines/zvision/scripting/sidefx/animation_node.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 134ab1396f..1f62b61310 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -39,8 +39,20 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _mask(mask), _animation(NULL) { - _animation = engine->loadAnimation(fileName); - _frmDelay = 1000.0 / _animation->getDuration().framerate(); + if (fileName.hasSuffix(".rlf")) { + // HACK: Read the frame delay directly + Common::File *tmp = engine->getSearchManager()->openFile(fileName); + if (tmp) { + tmp->seek(176, SEEK_SET); + _frmDelay = tmp->readUint32LE() / 10; + delete tmp; + } + + _animation = engine->loadAnimation(fileName); + } else { + _animation = engine->loadAnimation(fileName); + _frmDelay = Common::Rational(1000, _animation->getDuration().framerate()).toInt(); + } if (frate > 0) _frmDelay = 1000.0 / frate; -- cgit v1.2.3 From c93776e1e05bd5a683459831d61542c134d7b856 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 13:55:49 +0200 Subject: ZVISION: Remove dead code --- engines/zvision/graphics/cursors/cursor.cpp | 29 ----------------------------- engines/zvision/graphics/cursors/cursor.h | 1 - 2 files changed, 30 deletions(-) diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp index 07323b45c4..515358fe59 100644 --- a/engines/zvision/graphics/cursors/cursor.cpp +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -36,35 +36,6 @@ ZorkCursor::ZorkCursor() _hotspotY(0) { } -ZorkCursor::ZorkCursor(const Common::String &fileName) - : _width(0), - _height(0), - _hotspotX(0), - _hotspotY(0) { - Common::File file; - if (!file.open(fileName)) - return; - - uint32 magic = file.readUint32BE(); - if (magic != MKTAG('Z', 'C', 'R', '1')) { - warning("%s is not a Zork Cursor file", fileName.c_str()); - return; - } - - _hotspotX = file.readUint16LE(); - _hotspotY = file.readUint16LE(); - _width = file.readUint16LE(); - _height = file.readUint16LE(); - - uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); - uint32 bytesRead = file.read(_surface.getPixels(), dataSize); - assert(bytesRead == dataSize); - - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); -} - ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) : _width(0), _height(0), diff --git a/engines/zvision/graphics/cursors/cursor.h b/engines/zvision/graphics/cursors/cursor.h index 0c1e99411f..6e0083520a 100644 --- a/engines/zvision/graphics/cursors/cursor.h +++ b/engines/zvision/graphics/cursors/cursor.h @@ -39,7 +39,6 @@ namespace ZVision { class ZorkCursor { public: ZorkCursor(); - ZorkCursor(const Common::String &fileName); ZorkCursor(ZVision *engine, const Common::String &fileName); ZorkCursor(const ZorkCursor &other); ~ZorkCursor(); -- cgit v1.2.3 From 702adaf9f807f19cd8849af737168461169734d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 14:04:56 +0200 Subject: ZVISION: Remove duplicate code --- engines/zvision/graphics/render_manager.cpp | 91 +---------------------------- 1 file changed, 1 insertion(+), 90 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index b9305f5dcc..2f0d2a3a2c 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -162,97 +162,8 @@ void RenderManager::renderImageToBackground(const Common::String &fileName, int1 } void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination) { - Common::File file; - - if (!_engine->getSearchManager()->openFile(file, fileName)) { - warning("Could not open file %s", fileName.c_str()); - return; - } - - // Read the magic number - // Some files are true TGA, while others are TGZ - uint32 fileType = file.readUint32BE(); - - uint32 imageWidth; - uint32 imageHeight; - Image::TGADecoder tga; - uint16 *buffer; bool isTransposed = _renderTable.getRenderState() == RenderTable::PANORAMA; - // All ZVision images are in RGB 555 - Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - destination.format = pixelFormat555; - - bool isTGZ; - - // Check for TGZ files - if (fileType == MKTAG('T', 'G', 'Z', '\0')) { - isTGZ = true; - - // TGZ files have a header and then Bitmap data that is compressed with LZSS - uint32 decompressedSize = file.readSint32LE(); - imageWidth = file.readSint32LE(); - imageHeight = file.readSint32LE(); - - LzssReadStream lzssStream(&file); - buffer = (uint16 *)(new uint16[decompressedSize]); - lzssStream.read(buffer, decompressedSize); - } else { - isTGZ = false; - - // Reset the cursor - file.seek(0); - - // Decode - if (!tga.loadStream(file)) { - warning("Error while reading TGA image"); - return; - } - - Graphics::Surface tgaSurface = *(tga.getSurface()); - imageWidth = tgaSurface.w; - imageHeight = tgaSurface.h; - - buffer = (uint16 *)tgaSurface.getPixels(); - } - - // Flip the width and height if transposed - if (isTransposed) { - uint16 temp = imageHeight; - imageHeight = imageWidth; - imageWidth = temp; - } - - // If the destination internal buffer is the same size as what we're copying into it, - // there is no need to free() and re-create - if (imageWidth != destination.w || imageHeight != destination.h) { - destination.create(imageWidth, imageHeight, pixelFormat555); - } - - // If transposed, 'un-transpose' the data while copying it to the destination - // Otherwise, just do a simple copy - if (isTransposed) { - uint16 *dest = (uint16 *)destination.getPixels(); - - for (uint32 y = 0; y < imageHeight; ++y) { - uint32 columnIndex = y * imageWidth; - - for (uint32 x = 0; x < imageWidth; ++x) { - dest[columnIndex + x] = buffer[x * imageHeight + y]; - } - } - } else { - memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel); - } - - // Cleanup - if (isTGZ) { - delete[] buffer; - } else { - tga.destroy(); - } - - // Convert in place to RGB 565 from RGB 555 - destination.convertToInPlace(_pixelFormat); + readImageToSurface(fileName, destination, isTransposed); } void RenderManager::readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed) { -- cgit v1.2.3 From bed532587b4235a3cb9f2596bf7e65afdf33568a Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 24 Dec 2014 10:35:13 -0500 Subject: VIDEO: Fix check to see if the frame rate is a whole number Thanks to Marisa-Chan for spotting --- video/video_decoder.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index dce96aae03..a4bc5b81a2 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -530,7 +530,9 @@ Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getFrameTime(uint frame) con // (which Audio::Timestamp doesn't support). Common::Rational frameRate = getFrameRate(); - if (frameRate == frameRate.toInt()) // The nice case (a whole number) + // Try to keep it in terms of the frame rate, if the frame rate is a whole + // number. + if (frameRate.getDenominator() == 1) return Audio::Timestamp(0, frame, frameRate.toInt()); // Convert as best as possible -- cgit v1.2.3 From 59cd015fc90fcbb92c365ae33fe767cdf7ae863f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 24 Dec 2014 10:36:55 -0500 Subject: SCI: Silence a gcc warning --- engines/sci/graphics/screen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 8b0e76332f..2f95bf7751 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -238,6 +238,8 @@ GfxScreen::GfxScreen(ResourceManager *resMan) : _resMan(resMan) { _vectorPutPixelPtr = &GfxScreen::putPixelDisplayUpscaled; _putPixelPtr = &GfxScreen::putPixelDisplayUpscaled; break; + case GFX_SCREEN_UPSCALED_DISABLED: + break; } } -- cgit v1.2.3 From 970116bc3821b38c9b4882178c6a34082e73698d Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 24 Dec 2014 20:15:57 +0100 Subject: SCI: added LSL3/German 5 1/4" floppy version --- engines/sci/detection_tables.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index d6bdef946b..7c9f54aedf 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -2069,6 +2069,20 @@ static const struct ADGameDescription SciGameDescriptions[] = { AD_LISTEND}, Common::DE_DEU, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Larry 3 - German DOS (German+English, 5 1/4" floppies) + // SCI interpreter version S.old.124 (executable), VERSION is "1.056" + {"lsl3", "", { + {"resource.map", 0, "2468da5d664bb6ca3df866074a05e43c", 8910}, + {"resource.001", 0, "3827a9b17b926e12dcc336860f50612a", 163326}, + {"resource.002", 0, "3827a9b17b926e12dcc336860f50612a", 312436}, + {"resource.003", 0, "3827a9b17b926e12dcc336860f50612a", 347307}, + {"resource.004", 0, "3827a9b17b926e12dcc336860f50612a", 332369}, + {"resource.005", 0, "3827a9b17b926e12dcc336860f50612a", 347654}, + {"resource.006", 0, "3827a9b17b926e12dcc336860f50612a", 326011}, + {"resource.007", 0, "3827a9b17b926e12dcc336860f50612a", 309553}, + AD_LISTEND}, + Common::DE_DEU, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, + // Larry 3 - French DOS (provided by richiefs in bug report #2670691, also includes english language) // Executable scanning reports "S.old.123" // SCI interpreter version 0.000.572 (just a guess) -- cgit v1.2.3 From 11d3227796a5d58a6e0f362e7982e27bf6d8fcd8 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Wed, 24 Dec 2014 20:20:39 +0100 Subject: SCI: fix typo in comment for LSL3/German --- engines/sci/detection_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/sci/detection_tables.h b/engines/sci/detection_tables.h index 7c9f54aedf..32d1a58765 100644 --- a/engines/sci/detection_tables.h +++ b/engines/sci/detection_tables.h @@ -2070,7 +2070,7 @@ static const struct ADGameDescription SciGameDescriptions[] = { Common::DE_DEU, Common::kPlatformDOS, ADGF_ADDENGLISH, GUIO5(GUIO_NOSPEECH, GAMEOPTION_EGA_UNDITHER, GAMEOPTION_PREFER_DIGITAL_SFX, GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_FB01_MIDI) }, // Larry 3 - German DOS (German+English, 5 1/4" floppies) - // SCI interpreter version S.old.124 (executable), VERSION is "1.056" + // SCI interpreter version S.old.114 (executable), VERSION is "1.056" {"lsl3", "", { {"resource.map", 0, "2468da5d664bb6ca3df866074a05e43c", 8910}, {"resource.001", 0, "3827a9b17b926e12dcc336860f50612a", 163326}, -- cgit v1.2.3 From 16e208318cf75dbe290060663119d1c533f4dd7b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:07:42 +0200 Subject: ZVISION: Plug a memory leak --- engines/zvision/scripting/sidefx/animation_node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 1f62b61310..bf3509f545 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -161,6 +161,7 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); else _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); + transposed->free(); delete transposed; } else { if (_mask > 0) -- cgit v1.2.3 From de2c9ed5bf9e3d41ad52de8aa0ddf383efa6b24d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:11:21 +0200 Subject: ZVISION: Disable unused code --- engines/zvision/graphics/render_manager.cpp | 2 ++ engines/zvision/graphics/render_manager.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 2f0d2a3a2c..01df82410f 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -983,9 +983,11 @@ void RenderManager::markDirty() { _backgroundDirtyRect = Common::Rect(_backgroundWidth, _backgroundHeight); } +#if 0 void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) { _currentBackgroundImage.fillRect(Common::Rect(_currentBackgroundImage.w, _currentBackgroundImage.h), _currentBackgroundImage.format.RGBToColor(r, g, b)); markDirty(); } +#endif } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 711c607c7b..c2dc169945 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -328,8 +328,10 @@ public: // Mark whole background surface as dirty void markDirty(); - // Fille background surface by color +#if 0 + // Fill background surface by color void bkgFill(uint8 r, uint8 g, uint8 b); +#endif }; } // End of namespace ZVision -- cgit v1.2.3 From 1bc9b13357e36f6f52e3dd6f8223ab569e5b5362 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:26:23 +0200 Subject: ZVISION: Introduce pixel formats for resources (555) and screen (565) --- engines/zvision/zvision.cpp | 8 +++++--- engines/zvision/zvision.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index cf7ed288d7..145b2ebeac 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -82,6 +82,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ + _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ + _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ _desiredFrameTime(33), /* ~30 fps */ _clock(_system), _scriptManager(nullptr), @@ -182,17 +184,17 @@ void ZVision::initialize() { } else if (_gameDescription->gameId == GID_NEMESIS) _searchManager->loadZix("NEMESIS.ZIX"); - initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_pixelFormat); + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); // Register random source _rnd = new Common::RandomSource("zvision"); // Create managers _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _pixelFormat); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _screenPixelFormat); _saveManager = new SaveManager(this); _stringManager = new StringManager(this); - _cursorManager = new CursorManager(this, &_pixelFormat); + _cursorManager = new CursorManager(this, &_screenPixelFormat); _textRenderer = new TextRenderer(this); _midiManager = new MidiManager(); diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 7ea10ed64d..a63b66f70f 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -69,6 +69,8 @@ public: */ Common::Rect _workingWindow; const Graphics::PixelFormat _pixelFormat; + const Graphics::PixelFormat _resourcePixelFormat; + const Graphics::PixelFormat _screenPixelFormat; private: enum { -- cgit v1.2.3 From 84341a889cfafc4c7ecef6cf7d6841df8353fe4b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:29:52 +0200 Subject: ZVISION: Let the cursor manager do pixel format conversion for cursors --- engines/zvision/graphics/cursors/cursor.cpp | 5 +---- engines/zvision/graphics/cursors/cursor_manager.cpp | 2 +- engines/zvision/graphics/cursors/cursor_manager.h | 4 ++-- engines/zvision/zvision.cpp | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp index 515358fe59..eb25e92860 100644 --- a/engines/zvision/graphics/cursors/cursor.cpp +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -57,12 +57,9 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) _height = file.readUint16LE(); uint dataSize = _width * _height * sizeof(uint16); - _surface.create(_width, _height, Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0)); + _surface.create(_width, _height, engine->_resourcePixelFormat); uint32 bytesRead = file.read(_surface.getPixels(), dataSize); assert(bytesRead == dataSize); - - // Convert to RGB 565 - _surface.convertToInPlace(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); } ZorkCursor::ZorkCursor(const ZorkCursor &other) { diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index 92fd461c72..a197c7ed87 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -45,7 +45,7 @@ const char *CursorManager::_zNemCursorFileNames[NUM_CURSORS] = { "00act", "arrow "hright", "hup", "00idle", "left", "right", "ssurr", "stilt", "turn", "up" }; -CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat) +CursorManager::CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat) : _engine(engine), _pixelFormat(pixelFormat), _cursorIsPushed(false), diff --git a/engines/zvision/graphics/cursors/cursor_manager.h b/engines/zvision/graphics/cursors/cursor_manager.h index bbfa085c23..35c605baf8 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.h +++ b/engines/zvision/graphics/cursors/cursor_manager.h @@ -58,7 +58,7 @@ enum CursorIndex { */ class CursorManager { public: - CursorManager(ZVision *engine, const Graphics::PixelFormat *pixelFormat); + CursorManager(ZVision *engine, const Graphics::PixelFormat pixelFormat); private: static const int NUM_CURSORS = 18; @@ -67,7 +67,7 @@ private: ZorkCursor _cursors[NUM_CURSORS + 2][2]; ZVision *_engine; - const Graphics::PixelFormat *_pixelFormat; + const Graphics::PixelFormat _pixelFormat; bool _cursorIsPushed; int _item; int _lastitem; diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 145b2ebeac..5978316451 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -194,7 +194,7 @@ void ZVision::initialize() { _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _screenPixelFormat); _saveManager = new SaveManager(this); _stringManager = new StringManager(this); - _cursorManager = new CursorManager(this, &_screenPixelFormat); + _cursorManager = new CursorManager(this, _resourcePixelFormat); _textRenderer = new TextRenderer(this); _midiManager = new MidiManager(); -- cgit v1.2.3 From e8e21fabe4dbe4effdfb3df05fd3fae75940f1c5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:40:54 +0200 Subject: ZVISION: Set all the internal graphics operations to use RGB555 (1/2) This is the first part of the changes to make the engine use RGB555 internally again. This is done to simplify the rendering pipeline - the engine will use RGB555 internally, but will output to RGB565. The overall changes have been broken into two commits, thus this first commit will break all the game colors --- engines/zvision/graphics/effect.h | 2 +- engines/zvision/graphics/effects/fog.cpp | 10 ++++----- engines/zvision/graphics/effects/light.cpp | 4 ++-- engines/zvision/scripting/actions.cpp | 25 ++-------------------- .../zvision/scripting/controls/input_control.cpp | 2 +- .../zvision/scripting/controls/titler_control.cpp | 2 +- engines/zvision/scripting/sidefx/ttytext_node.cpp | 4 ++-- engines/zvision/text/text.cpp | 4 ++-- engines/zvision/text/truetype_font.cpp | 2 +- engines/zvision/video/rlf_decoder.cpp | 22 ++++--------------- engines/zvision/video/rlf_decoder.h | 2 +- engines/zvision/zvision.cpp | 2 +- 12 files changed, 23 insertions(+), 58 deletions(-) diff --git a/engines/zvision/graphics/effect.h b/engines/zvision/graphics/effect.h index c6653c6037..234cd8209d 100644 --- a/engines/zvision/graphics/effect.h +++ b/engines/zvision/graphics/effect.h @@ -37,7 +37,7 @@ class Effect { public: Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) { - _surface.create(_region.width(), _region.height(), _engine->_pixelFormat); + _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat); } virtual ~Effect() {} diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp index f59e82a4a0..c28bdde330 100644 --- a/engines/zvision/graphics/effects/fog.cpp +++ b/engines/zvision/graphics/effects/fog.cpp @@ -79,10 +79,10 @@ const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) { if (it->inEffect) { // Not 100% equivalent, but looks nice and not buggy uint8 sr, sg, sb; - _engine->_pixelFormat.colorToRGB(lineBuf[i], sr, sg, sb); + _engine->_resourcePixelFormat.colorToRGB(lineBuf[i], sr, sg, sb); uint16 fogColor = *(uint16 *)_fog.getBasePtr((i + _pos) % _fog.w, j); uint8 dr, dg, db; - _engine->_pixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db); + _engine->_resourcePixelFormat.colorToRGB(_colorMap[fogColor & 0x1F], dr, dg, db); uint16 fr = dr + sr; if (fr > 255) fr = 255; @@ -92,7 +92,7 @@ const Graphics::Surface *FogFx::draw(const Graphics::Surface &srcSubRect) { uint16 fb = db + sb; if (fb > 255) fb = 255; - lineBuf[i] = _engine->_pixelFormat.RGBToColor(fr, fg, fb); + lineBuf[i] = _engine->_resourcePixelFormat.RGBToColor(fr, fg, fb); } cnt++; if (cnt >= it->count) { @@ -138,14 +138,14 @@ void FogFx::update() { // Not 100% equivalent, but looks nice and not buggy - _colorMap[31] = _engine->_pixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3); + _colorMap[31] = _engine->_resourcePixelFormat.RGBToColor(_r << 3, _g << 3, _b << 3); for (uint8 i = 0; i < 31; i++) { float perc = (float)i / 31.0; uint8 cr = (float)_r * perc; uint8 cg = (float)_g * perc; uint8 cb = (float)_b * perc; - _colorMap[i] = _engine->_pixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3); + _colorMap[i] = _engine->_resourcePixelFormat.RGBToColor(cr << 3, cg << 3, cb << 3); } } diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp index 00b3811d65..bf6513292f 100644 --- a/engines/zvision/graphics/effects/light.cpp +++ b/engines/zvision/graphics/effects/light.cpp @@ -59,10 +59,10 @@ const Graphics::Surface *LightFx::draw(const Graphics::Surface &srcSubRect) { if (_pos < 0) { uint8 cc = ((-_pos) & 0x1F) << 3; - dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc); + dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc); } else { uint8 cc = (_pos & 0x1F) << 3; - dcolor = _engine->_pixelFormat.RGBToColor(cc, cc, cc); + dcolor = _engine->_resourcePixelFormat.RGBToColor(cc, cc, cc); } for (uint16 j = 0; j < _surface.h; j++) { diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 5af847c61a..1b6e1e2fdc 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -580,12 +580,6 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c // The two %*u are usually 0 and dont seem to have a use sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate); - if (_mask > 0) { - byte r, g, b; - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b); - _mask = _engine->_pixelFormat.RGBToColor(r, g, b); - } - _fileName = Common::String(fileName); } @@ -648,12 +642,6 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C "%24s %u %u %u %u %u %u %d %*u %*u %d %d", fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); - if (_mask > 0) { - byte r, g, b; - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(_mask, r, g, b); - _mask = _engine->_pixelFormat.RGBToColor(r, g, b); - } - _fileName = Common::String(fileName); } @@ -861,21 +849,12 @@ ActionSetPartialScreen::ActionSetPartialScreen(ZVision *engine, int32 slotkey, c _y = 0; char fileName[25]; - int color; - sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &color); + sscanf(line.c_str(), "%u %u %24s %*u %d", &_x, &_y, fileName, &_backgroundColor); _fileName = Common::String(fileName); - if (color >= 0) { - byte r, g, b; - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(color, r, g, b); - _backgroundColor = _engine->_pixelFormat.RGBToColor(r, g, b); - } else { - _backgroundColor = color; - } - - if (color > 65535) { + if (_backgroundColor > 65535) { warning("Background color for ActionSetPartialScreen is bigger than a uint16"); } } diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index d7734f6d7a..e1e6e6ec9d 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -199,7 +199,7 @@ bool InputControl::process(uint32 deltaTimeInMillis) { // Blit the text using the RenderManager Graphics::Surface txt; - txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_pixelFormat); + txt.create(_textRectangle.width(), _textRectangle.height(), _engine->_resourcePixelFormat); if (!_readOnly || !_focused) _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index 10ba0af655..d6b1d34bae 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -67,7 +67,7 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt if (!_rectangle.isEmpty()) { _surface = new Graphics::Surface; - _surface->create(_rectangle.width(), _rectangle.height(), _engine->_pixelFormat); + _surface->create(_rectangle.width(), _rectangle.height(), _engine->_resourcePixelFormat); _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0); } } diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp index 2930118524..66a27e96c5 100644 --- a/engines/zvision/scripting/sidefx/ttytext_node.cpp +++ b/engines/zvision/scripting/sidefx/ttytext_node.cpp @@ -56,7 +56,7 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file delete infile; } - _img.create(_r.width(), _r.height(), _engine->_pixelFormat); + _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat); _style._sharp = true; _style.readAllStyle(_txtbuf); _style.setFont(_fnt); @@ -158,7 +158,7 @@ void ttyTextNode::newline() { } void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_pixelFormat.RGBToColor(_style._red, _style._green, _style._blue); + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue); if (_dx + _fnt.getCharWidth(chr) > _r.width()) newline(); diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index 8ddba3fbab..f28ba6ade3 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -298,7 +298,7 @@ void cTxtStyle::setFont(StyledTTFont &font) { Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) { style.setFontStyle(fnt); - uint32 clr = _engine->_pixelFormat.RGBToColor(style._red, style._green, style._blue); + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(style._red, style._green, style._blue); return fnt.renderSolidText(txt, clr); } @@ -317,7 +317,7 @@ int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Gra dst.fillRect(Common::Rect(dst.w, dst.h), 0); - uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue); + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue); int16 w; diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index f373afe437..f64c0ab3bc 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -218,7 +218,7 @@ Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint if (_font) { int16 w = _font->getStringWidth(str); if (w && w < 1024) { - tmp->create(w, _font->getFontHeight(), _engine->_pixelFormat); + tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat); drawString(tmp, str, 0, 0, w, color); } } diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index f1ac10bf88..260f912ade 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -64,7 +64,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) return; } - _currentFrameBuffer.create(_width, _height, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0)); + _currentFrameBuffer.create(_width, _height, getPixelFormat()); _frameBufferByteSize = _width * _height * sizeof(uint16); _frames = new Frame[_frameCount]; @@ -239,12 +239,7 @@ void RLFDecoder::RLFVideoTrack::decodeMaskedRunLengthEncoding(int8 *source, int8 return; } - byte r, g, b; - // NOTE: Color masks can't be used here, since accurate colors - // are required to handle transparency correctly - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); - WRITE_UINT16(dest + destOffset, destColor); + WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset)); sourceOffset += 2; destOffset += 2; @@ -288,12 +283,7 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 return; } - byte r, g, b; - // NOTE: Color masks can't be used here, since accurate colors - // are required to handle transparency correctly - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 destColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); - WRITE_UINT16(dest + destOffset, destColor); + WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset)); sourceOffset += 2; destOffset += 2; @@ -307,11 +297,7 @@ void RLFDecoder::RLFVideoTrack::decodeSimpleRunLengthEncoding(int8 *source, int8 return; } - byte r, g, b; - // NOTE: Color masks can't be used here, since accurate colors - // are required to handle transparency correctly - Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0).colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b); - uint16 sampleColor = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0).RGBToColor(r, g, b); + uint16 sampleColor = READ_LE_UINT16(source + sourceOffset); sourceOffset += 2; numberOfCopy = numberOfSamples + 2; diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h index f0f31c2128..d56ff2da92 100644 --- a/engines/zvision/video/rlf_decoder.h +++ b/engines/zvision/video/rlf_decoder.h @@ -45,7 +45,7 @@ private: uint16 getWidth() const { return _width; } uint16 getHeight() const { return _height; } - Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); /*RGB 565*/ } + Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); /* RGB 555 */ } int getCurFrame() const { return _curFrame; } int getFrameCount() const { return _frameCount; } const Graphics::Surface *decodeNextFrame(); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 5978316451..b865ae9e6e 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -191,7 +191,7 @@ void ZVision::initialize() { // Create managers _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _screenPixelFormat); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat); _saveManager = new SaveManager(this); _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, _resourcePixelFormat); -- cgit v1.2.3 From 5f8418394b925adfc62ee6d180515157190a8cd9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 22:54:24 +0200 Subject: ZVISION: Set all the internal graphics operations to use RGB555 (2/2) This is the second part of the changes to make the engine use RGB555 internally again. This is done to simplify the rendering pipeline - the engine will use RGB555 internally, but will output to RGB565. The overall changes have been broken into two commits, with this commit finishing all the changes. This is needed, as the game uses RGB555 graphics internally, but its AVI animations (full screen and in-game) use RGB565 --- .../zvision/graphics/cursors/cursor_manager.cpp | 2 +- engines/zvision/graphics/render_manager.cpp | 111 +++++++++++++-------- engines/zvision/graphics/render_manager.h | 2 + engines/zvision/video/video.cpp | 3 +- engines/zvision/zvision.cpp | 1 - engines/zvision/zvision.h | 1 - 6 files changed, 72 insertions(+), 48 deletions(-) diff --git a/engines/zvision/graphics/cursors/cursor_manager.cpp b/engines/zvision/graphics/cursors/cursor_manager.cpp index a197c7ed87..c364426bad 100644 --- a/engines/zvision/graphics/cursors/cursor_manager.cpp +++ b/engines/zvision/graphics/cursors/cursor_manager.cpp @@ -106,7 +106,7 @@ void CursorManager::initialize() { } void CursorManager::changeCursor(const ZorkCursor &cursor) { - CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, _pixelFormat); + CursorMan.replaceCursor(cursor.getSurface(), cursor.getWidth(), cursor.getHeight(), cursor.getHotspotX(), cursor.getHotspotY(), cursor.getKeyColor(), false, &_pixelFormat); } void CursorManager::cursorDown(bool pushed) { diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 01df82410f..07ed6d2e2b 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -127,14 +127,29 @@ void RenderManager::renderSceneToScreen() { } if (!outWndDirtyRect.isEmpty()) { - _system->copyRectToScreen(out->getBasePtr(outWndDirtyRect.left, outWndDirtyRect.top), out->pitch, - outWndDirtyRect.left + _workingWindow.left, - outWndDirtyRect.top + _workingWindow.top, - outWndDirtyRect.width(), - outWndDirtyRect.height()); + Common::Rect rect( + outWndDirtyRect.left + _workingWindow.left, + outWndDirtyRect.top + _workingWindow.top, + outWndDirtyRect.left + _workingWindow.left + outWndDirtyRect.width(), + outWndDirtyRect.top + _workingWindow.top + outWndDirtyRect.height() + ); + copyToScreen(*out, rect, outWndDirtyRect.left, outWndDirtyRect.top); } } +void RenderManager::copyToScreen(const Graphics::Surface &surface, Common::Rect &rect, int16 srcLeft, int16 srcTop) { + // Convert the surface to RGB565, if needed + Graphics::Surface *outSurface = surface.convertTo(_engine->_screenPixelFormat); + _system->copyRectToScreen(outSurface->getBasePtr(srcLeft, srcTop), + outSurface->pitch, + rect.left, + rect.top, + rect.width(), + rect.height()); + outSurface->free(); + delete outSurface; +} + void RenderManager::renderImageToBackground(const Common::String &fileName, int16 destX, int16 destY) { Graphics::Surface surface; readImageToSurface(fileName, surface); @@ -183,8 +198,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: Image::TGADecoder tga; uint16 *buffer; // All ZVision images are in RGB 555 - Graphics::PixelFormat pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); - destination.format = pixelFormat555; + destination.format = _engine->_resourcePixelFormat; bool isTGZ; @@ -229,7 +243,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: // If the destination internal buffer is the same size as what we're copying into it, // there is no need to free() and re-create if (imageWidth != destination.w || imageHeight != destination.h) { - destination.create(imageWidth, imageHeight, pixelFormat555); + destination.create(imageWidth, imageHeight, _engine->_resourcePixelFormat); } // If transposed, 'un-transpose' the data while copying it to the destination @@ -245,7 +259,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: } } } else { - memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * _pixelFormat.bytesPerPixel); + memcpy(destination.getPixels(), buffer, imageWidth * imageHeight * destination.format.bytesPerPixel); } // Cleanup @@ -254,9 +268,6 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: } else { tga.destroy(); } - - // Convert in place to RGB 565 from RGB 555 - destination.convertToInPlace(_pixelFormat); } const Common::Point RenderManager::screenSpaceToImageSpace(const Common::Point &point) { @@ -370,10 +381,6 @@ void RenderManager::scaleBuffer(const void *src, void *dst, uint32 srcWidth, uin } void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y) { - - if (src.format != dst.format) - return; - Common::Rect srcRect = _srcRect; if (srcRect.isEmpty()) srcRect = Common::Rect(src.w, src.h); @@ -384,8 +391,10 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (srcRect.isEmpty() || !srcRect.isValidRect()) return; + Graphics::Surface *srcAdapted = src.convertTo(dst.format); + // Copy srcRect from src surface to dst surface - const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + const byte *srcBuffer = (const byte *)srcAdapted->getBasePtr(srcRect.left, srcRect.top); int xx = _x; int yy = _y; @@ -395,8 +404,11 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (yy < 0) yy = 0; - if (_x >= dst.w || _y >= dst.h) + if (_x >= dst.w || _y >= dst.h) { + srcAdapted->free(); + delete srcAdapted; return; + } byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy); @@ -404,17 +416,16 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com int32 h = srcRect.height(); for (int32 y = 0; y < h; y++) { - memcpy(dstBuffer, srcBuffer, w * src.format.bytesPerPixel); - srcBuffer += src.pitch; + memcpy(dstBuffer, srcBuffer, w * srcAdapted->format.bytesPerPixel); + srcBuffer += srcAdapted->pitch; dstBuffer += dst.pitch; } + + srcAdapted->free(); + delete srcAdapted; } void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey) { - - if (src.format != dst.format) - return; - Common::Rect srcRect = _srcRect; if (srcRect.isEmpty()) srcRect = Common::Rect(src.w, src.h); @@ -425,10 +436,11 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (srcRect.isEmpty() || !srcRect.isValidRect()) return; - uint32 _keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1); + Graphics::Surface *srcAdapted = src.convertTo(dst.format); + uint32 keycolor = colorkey & ((1 << (src.format.bytesPerPixel << 3)) - 1); // Copy srcRect from src surface to dst surface - const byte *srcBuffer = (const byte *)src.getBasePtr(srcRect.left, srcRect.top); + const byte *srcBuffer = (const byte *)srcAdapted->getBasePtr(srcRect.left, srcRect.top); int xx = _x; int yy = _y; @@ -438,8 +450,11 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com if (yy < 0) yy = 0; - if (_x >= dst.w || _y >= dst.h) + if (_x >= dst.w || _y >= dst.h) { + srcAdapted->free(); + delete srcAdapted; return; + } byte *dstBuffer = (byte *)dst.getBasePtr(xx, yy); @@ -447,12 +462,12 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com int32 h = srcRect.height(); for (int32 y = 0; y < h; y++) { - switch (src.format.bytesPerPixel) { + switch (srcAdapted->format.bytesPerPixel) { case 1: { const uint *srcTemp = (const uint *)srcBuffer; uint *dstTemp = (uint *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*srcTemp != _keycolor) + if (*srcTemp != keycolor) *dstTemp = *srcTemp; srcTemp++; dstTemp++; @@ -464,7 +479,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com const uint16 *srcTemp = (const uint16 *)srcBuffer; uint16 *dstTemp = (uint16 *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*srcTemp != _keycolor) + if (*srcTemp != keycolor) *dstTemp = *srcTemp; srcTemp++; dstTemp++; @@ -476,7 +491,7 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com const uint32 *srcTemp = (const uint32 *)srcBuffer; uint32 *dstTemp = (uint32 *)dstBuffer; for (int32 x = 0; x < w; x++) { - if (*srcTemp != _keycolor) + if (*srcTemp != keycolor) *dstTemp = *srcTemp; srcTemp++; dstTemp++; @@ -487,9 +502,12 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com default: break; } - srcBuffer += src.pitch; + srcBuffer += srcAdapted->pitch; dstBuffer += dst.pitch; } + + srcAdapted->free(); + delete srcAdapted; } void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { @@ -699,12 +717,15 @@ void RenderManager::clearMenuSurface(const Common::Rect &r) { void RenderManager::renderMenuToScreen() { if (!_menuSurfaceDirtyRect.isEmpty()) { _menuSurfaceDirtyRect.clip(Common::Rect(_menuSurface.w, _menuSurface.h)); - if (!_menuSurfaceDirtyRect.isEmpty()) - _system->copyRectToScreen(_menuSurface.getBasePtr(_menuSurfaceDirtyRect.left, _menuSurfaceDirtyRect.top), _menuSurface.pitch, - _menuSurfaceDirtyRect.left + _menuArea.left, - _menuSurfaceDirtyRect.top + _menuArea.top, - _menuSurfaceDirtyRect.width(), - _menuSurfaceDirtyRect.height()); + if (!_menuSurfaceDirtyRect.isEmpty()) { + Common::Rect rect( + _menuSurfaceDirtyRect.left + _menuArea.left, + _menuSurfaceDirtyRect.top + _menuArea.top, + _menuSurfaceDirtyRect.left + _menuArea.left + _menuSurfaceDirtyRect.width(), + _menuSurfaceDirtyRect.top + _menuArea.top + _menuSurfaceDirtyRect.height() + ); + copyToScreen(_menuSurface, rect, _menuSurfaceDirtyRect.left, _menuSurfaceDirtyRect.top); + } _menuSurfaceDirtyRect = Common::Rect(); } } @@ -779,7 +800,7 @@ void RenderManager::processSubs(uint16 deltatime) { OneSubtitle *sub = &it->_value; if (sub->txt.size()) { Graphics::Surface *rndr = new Graphics::Surface(); - rndr->create(sub->r.width(), sub->r.height(), _pixelFormat); + rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); blitSurfaceToSurface(*rndr, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); rndr->free(); @@ -788,11 +809,13 @@ void RenderManager::processSubs(uint16 deltatime) { sub->redraw = false; } - _system->copyRectToScreen(_subtitleSurface.getPixels(), _subtitleSurface.pitch, - _subtitleArea.left, - _subtitleArea.top, - _subtitleSurface.w, - _subtitleSurface.h); + Common::Rect rect( + _subtitleArea.left, + _subtitleArea.top, + _subtitleArea.left + _subtitleSurface.w, + _subtitleArea.top + _subtitleSurface.h + ); + copyToScreen(_subtitleSurface, rect, 0, 0); } } diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index c2dc169945..d67ae29a3a 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -146,6 +146,8 @@ public: */ void renderSceneToScreen(); + void copyToScreen(const Graphics::Surface &surface, Common::Rect &rect, int16 srcLeft, int16 srcTop); + /** * Blits the image or a portion of the image to the background. * diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index 50a6fc136a..e67e6570c5 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -114,7 +114,8 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, _renderManager->scaleBuffer(frame->getPixels(), scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, scaled->w, scaled->h); frame = scaled; } - _system->copyRectToScreen((const byte *)frame->getPixels(), frame->pitch, x, y, finalWidth, finalHeight); + Common::Rect rect = Common::Rect(x, y, x + finalWidth, y + finalHeight); + _renderManager->copyToScreen(*frame, rect, 0, 0); _renderManager->processSubs(0); } } diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b865ae9e6e..db96884103 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -81,7 +81,6 @@ struct zvisionIniSettings { ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), - _pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /*RGB 565*/ _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ _desiredFrameTime(33), /* ~30 fps */ diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index a63b66f70f..e9b8ca4547 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -68,7 +68,6 @@ public: * edges of this Rectangle */ Common::Rect _workingWindow; - const Graphics::PixelFormat _pixelFormat; const Graphics::PixelFormat _resourcePixelFormat; const Graphics::PixelFormat _screenPixelFormat; -- cgit v1.2.3 From 75d78c71cc2190ae4afa655d27cdbc35a748f901 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 23:18:01 +0200 Subject: ZVISION: Plug another memory leak. Some cleanup --- engines/zvision/scripting/sidefx/animation_node.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index bf3509f545..dec70e2642 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -44,7 +44,7 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S Common::File *tmp = engine->getSearchManager()->openFile(fileName); if (tmp) { tmp->seek(176, SEEK_SET); - _frmDelay = tmp->readUint32LE() / 10; + _frmDelay = Common::Rational(tmp->readUint32LE(), 10).toInt(); delete tmp; } @@ -73,8 +73,10 @@ AnimationNode::~AnimationNode() { if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); - if ((*it)._scaled) + if ((*it)._scaled) { + (*it)._scaled->free(); delete(*it)._scaled; + } } _playList.clear(); @@ -109,8 +111,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->loop == 0) { if (nod->slot >= 0) _engine->getScriptManager()->setStateValue(nod->slot, 2); - if (nod->_scaled) + if (nod->_scaled) { + nod->_scaled->free(); delete nod->_scaled; + } _playList.erase(it); return _DisposeAfterUse; } @@ -142,6 +146,7 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) { if (nod->_scaled) if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { + nod->_scaled->free(); delete nod->_scaled; nod->_scaled = NULL; } @@ -197,8 +202,10 @@ bool AnimationNode::stop() { PlayNodes::iterator it = _playList.begin(); if (it != _playList.end()) { _engine->getScriptManager()->setStateValue((*it).slot, 2); - if ((*it)._scaled) + if ((*it)._scaled) { + (*it)._scaled->free(); delete(*it)._scaled; + } } _playList.clear(); -- cgit v1.2.3 From fa2d8d927b353162ac9ee434b4611e03b22246e8 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 24 Dec 2014 23:27:03 +0200 Subject: ZVISION: Plug more memory leaks --- engines/zvision/scripting/controls/paint_control.cpp | 12 +++++++++--- engines/zvision/scripting/controls/titler_control.cpp | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/engines/zvision/scripting/controls/paint_control.cpp b/engines/zvision/scripting/controls/paint_control.cpp index df06bb814e..62dde3d170 100644 --- a/engines/zvision/scripting/controls/paint_control.cpp +++ b/engines/zvision/scripting/controls/paint_control.cpp @@ -114,12 +114,18 @@ PaintControl::PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStre PaintControl::~PaintControl() { // Clear the state value back to 0 //_engine->getScriptManager()->setStateValue(_key, 0); - if (_paint) + if (_paint) { + _paint->free(); delete _paint; - if (_brush) + } + if (_brush) { + _brush->free(); delete _brush; - if (_bkg) + } + if (_bkg) { + _bkg->free(); delete _bkg; + } } bool PaintControl::onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos) { diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index d6b1d34bae..542e0a0b67 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -73,8 +73,10 @@ TitlerControl::TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadSt } TitlerControl::~TitlerControl() { - if (_surface) + if (_surface) { + _surface->free(); delete _surface; + } } void TitlerControl::setString(int strLine) { -- cgit v1.2.3 From 381b7592a49e5d022159b5684dbba32eceaa6657 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Thu, 25 Dec 2014 00:31:17 +0100 Subject: SCI: actor file format, add debug code kPortrait --- engines/sci/graphics/portrait.cpp | 51 +++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 668de616fb..959c0f6817 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -57,13 +57,39 @@ void Portrait::init() { // 4 bytes paletteSize (base 1) // -> 17 bytes // paletteSize bytes paletteData - // 14 bytes bitmap header - // -> 4 bytes unknown - // -> 2 bytes height - // -> 2 bytes width - // -> 6 bytes unknown - // height * width bitmap data - // another animation count times bitmap header and data + // + // bitmap-data follows, total of [animation count] + // 14 bytes bitmap header + // -> 4 bytes unknown + // -> 2 bytes height + // -> 2 bytes width + // -> 6 bytes unknown + // height * width bitmap data + // + // 4 bytes offset table size (may be larger than the actual known entries?!) + // 14 bytes all zeroes (dummy entry?!) + // + // 14 bytes for each entry + // -> 2 bytes displace X + // -> 2 bytes displace Y + // -> 2 bytes height (again) + // -> 2 bytes width (again) + // -> 6 bytes unknown (normally 01 00 00 00 00 00 for delta bitmaps, 00 00 00 00 00 00 for first bitmap) + // random data may be used as filler + // + // 4 bytes lip sync id table size (is [lip sync id count] * 4, should be 0x2E0 for all actors) + // 4 bytes per lip sync id + // -> 1 byte length of ID + // -> 3 bytes actual ID + // + // 4 bytes lip sync id data table size (seems to be the same for all actors, always 0x220 in size) + // 1 byte animation number or 0xFF as terminator + // 1 byte delay, if last byte was not terminator + // one array for every lip sync id + // + // 4 bytes appended, seem to be random + // 9E11120E for alex + // 9E9E9E9E for vizier int32 fileSize = 0; Common::SeekableReadStream *file = SearchMan.createReadStreamForMember("actors/" + _resourceName + ".bin"); @@ -202,6 +228,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint if (raveResource->size < 4000) { memcpy(debugPrint, raveResource->data, raveResource->size); debugPrint[raveResource->size] = 0; // set terminating NUL + debug("kPortrait: using actor %s", _resourceName.c_str()); debug("kPortrait (noun %d, verb %d, cond %d, seq %d)", noun, verb, cond, seq); debug("kPortrait: %s", debugPrint); } @@ -273,6 +300,10 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint raveLipSyncData = NULL; } +#ifdef DEBUG_PORTRAIT + debug("kPortrait: %d: %x", raveTicks, raveID); +#endif + timerPosition += raveTicks; // Wait till syncTime passed, then show specific animation bitmap @@ -294,6 +325,9 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint // Tick = 0xFF is the terminator for the data timerPositionWithin = timerPosition; raveLipSyncTicks = *raveLipSyncData++; +#ifdef DEBUG_PORTRAIT + debug("kPortrait: waiting %d", raveLipSyncTicks); +#endif while ( (raveLipSyncData < _lipSyncDataOffsetTableEnd) && (raveLipSyncTicks != 0xFF) ) { timerPositionWithin += raveLipSyncTicks; @@ -308,6 +342,9 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } while ((curPosition != -1) && (curPosition < timerPositionWithin) && (!userAbort)); raveLipSyncBitmapNr = *raveLipSyncData++; +#ifdef DEBUG_PORTRAIT + debug("kPortrait: showing bitmap %d", raveLipSyncBitmapNr); +#endif // bitmap nr within sync data is base 1, we need base 0 raveLipSyncBitmapNr--; -- cgit v1.2.3 From 319323c668003b284d51b84ec95a64ba7c072450 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 15:00:49 +0200 Subject: ZVISION: Document some of the ActionRegion effects --- engines/zvision/graphics/effects/fog.h | 1 + engines/zvision/scripting/actions.cpp | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h index 45d6f9596d..fe88707bbe 100644 --- a/engines/zvision/graphics/effects/fog.h +++ b/engines/zvision/graphics/effects/fog.h @@ -29,6 +29,7 @@ namespace ZVision { class ZVision; +// Used by Zork: Nemesis for the mixing chamber gas effect in the gas puzzle (location tt5e, when the blinds are down) class FogFx : public Effect { public: diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 1b6e1e2fdc..89b311e81c 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -704,7 +704,7 @@ bool ActionQuit::execute() { } ////////////////////////////////////////////////////////////////////////////// -// ActionRegion +// ActionRegion - only used by Zork: Nemesis ////////////////////////////////////////////////////////////////////////////// ActionRegion::ActionRegion(ZVision *engine, int32 slotkey, const Common::String &line) : diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 47b8b0aa39..cca492d649 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -264,6 +264,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("random", true)) { actionList.push_back(new ActionRandom(_engine, slot, args)); } else if (act.matchString("region", true)) { + // Only used by Zork: Nemesis actionList.push_back(new ActionRegion(_engine, slot, args)); } else if (act.matchString("restore_game", true)) { actionList.push_back(new ActionRestoreGame(_engine, slot, args)); -- cgit v1.2.3 From 5535cb02fc8dfaf2c77911c223c912f5b07bdb63 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 15:14:59 +0200 Subject: ZVISION: Resolve some TODOs --- engines/zvision/scripting/actions.h | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 1 + engines/zvision/scripting/script_manager.h | 3 +-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 292e25e19c..3501372c7f 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -338,7 +338,7 @@ private: uint16 _unk2; }; -// TODO: See if this exists in ZGI. It doesn't in ZNem +// Only used by ZGI (locations cd6e, cd6k, dg2f, dg4e, dv1j) class ActionUnloadAnimation : public ResultAction { public: ActionUnloadAnimation(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index cca492d649..83be3b5ad4 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -216,6 +216,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("animpreload", true)) { actionList.push_back(new ActionPreloadAnimation(_engine, slot, args)); } else if (act.matchString("animunload", true)) { + // Only used by ZGI (locations cd6e, cd6k, dg2f, dg4e, dv1j) actionList.push_back(new ActionUnloadAnimation(_engine, slot, args)); } else if (act.matchString("attenuate", true)) { actionList.push_back(new ActionAttenuate(_engine, slot, args)); diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 1e308faf0d..c5ade08e14 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -282,7 +282,7 @@ public: void inventoryDrop(int16 item); void inventoryCycle(); - // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it +private: /** * Parses a script file into triggers and events * @@ -291,7 +291,6 @@ public: */ void parseScrFile(const Common::String &fileName, ScriptScope &scope); -private: /** * Parses the stream into a Puzzle object * Helper method for parseScrFile. -- cgit v1.2.3 From 36c851d0e47b18205ac7ac91eb33666e4abe95ca Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 16:22:36 +0200 Subject: ZVISION: Fix frame rate for RLF videos and remove hack in AnimationNode _frameTime refers to msec, not ticks --- engines/zvision/scripting/sidefx/animation_node.cpp | 16 ++++------------ engines/zvision/video/rlf_decoder.h | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index dec70e2642..97c6eeeab5 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -39,20 +39,12 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _mask(mask), _animation(NULL) { - if (fileName.hasSuffix(".rlf")) { - // HACK: Read the frame delay directly - Common::File *tmp = engine->getSearchManager()->openFile(fileName); - if (tmp) { - tmp->seek(176, SEEK_SET); - _frmDelay = Common::Rational(tmp->readUint32LE(), 10).toInt(); - delete tmp; - } + _animation = engine->loadAnimation(fileName); - _animation = engine->loadAnimation(fileName); - } else { - _animation = engine->loadAnimation(fileName); + if (fileName.hasSuffix(".rlf")) + _frmDelay = _animation->getTimeToNextFrame(); + else _frmDelay = Common::Rational(1000, _animation->getDuration().framerate()).toInt(); - } if (frate > 0) _frmDelay = 1000.0 / frate; diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h index d56ff2da92..740f3fdd43 100644 --- a/engines/zvision/video/rlf_decoder.h +++ b/engines/zvision/video/rlf_decoder.h @@ -53,7 +53,7 @@ private: bool seek(const Audio::Timestamp &time); protected: - Common::Rational getFrameRate() const { return Common::Rational(60, _frameTime); } + Common::Rational getFrameRate() const { return Common::Rational(1000, _frameTime); } private: enum EncodingType { -- cgit v1.2.3 From 06fbca1e8109bdd3d1fdf72fc1056cbf658659e5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 20:10:24 +0200 Subject: ZVISION: Remove dead code --- engines/zvision/scripting/sidefx/animation_node.cpp | 4 ---- engines/zvision/scripting/sidefx/animation_node.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 97c6eeeab5..b966aa9cb8 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -206,8 +206,4 @@ bool AnimationNode::stop() { return false; } -int32 AnimationNode::getFrameDelay() { - return _frmDelay; -} - } // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 74941aa764..368f0291fd 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -72,8 +72,6 @@ public: void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1); bool stop(); - - int32 getFrameDelay(); }; } // End of namespace ZVision -- cgit v1.2.3 From dbbcf641874ace35b871226664370413de176c37 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 21:17:47 +0200 Subject: ZVISION: Use the search manager to open files in console commands --- engines/zvision/core/console.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 07d3114ec8..c7592c8d9d 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -79,12 +79,14 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine); Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); - } else if (argc == 4) { int isStereo = atoi(argv[3]); Common::File *file = new Common::File(); - file->open(argv[1]); + if (!_engine->getSearchManager()->openFile(*file, argv[1])) { + warning("File not found: %s", argv[1]); + return true; + } Audio::AudioStream *soundStream = makeRawZorkStream(file, atoi(argv[2]), isStereo == 0 ? false : true); Audio::SoundHandle handle; @@ -104,8 +106,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { } Common::File file; - if (!file.open(argv[1])) + if (!_engine->getSearchManager()->openFile(file, argv[1])) { + warning("File not found: %s", argv[1]); return true; + } Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine); -- cgit v1.2.3 From 11cf9b53ba138b5e069d7ffbd6af7f36b26a9add Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 21:19:19 +0200 Subject: ZVISION: Remove dead code, and fix bad usage of assert() Since some compilers, like MSVC, strip out asserts in non-debug builds, it's a bad idea to perform active commands within assert() statements. In this particular case, the engine would attempt to open a file in an assert statement --- engines/zvision/sound/zork_raw.cpp | 11 ++--------- engines/zvision/sound/zork_raw.h | 14 -------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/engines/zvision/sound/zork_raw.cpp b/engines/zvision/sound/zork_raw.cpp index b2c88b34df..6d1980b1af 100644 --- a/engines/zvision/sound/zork_raw.cpp +++ b/engines/zvision/sound/zork_raw.cpp @@ -213,7 +213,6 @@ RawZorkStream::RawZorkStream(uint32 rate, bool stereo, DisposeAfterUse::Flag dis } int RawZorkStream::readBuffer(int16 *buffer, const int numSamples) { - int32 bytesRead = _streamReader.readBuffer(buffer, _stream.get(), numSamples); if (_stream->eos()) @@ -241,16 +240,10 @@ Audio::RewindableAudioStream *makeRawZorkStream(Common::SeekableReadStream *stre return new RawZorkStream(rate, stereo, disposeAfterUse, stream); } -Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse) { - return makeRawZorkStream(new Common::MemoryReadStream(buffer, size, disposeAfterUse), rate, stereo, DisposeAfterUse::YES); -} - Audio::RewindableAudioStream *makeRawZorkStream(const Common::String &filePath, ZVision *engine) { Common::File *file = new Common::File(); - assert(engine->getSearchManager()->openFile(*file, filePath)); + if (!engine->getSearchManager()->openFile(*file, filePath)) + error("File not found: %s", filePath.c_str()); // Get the file name Common::StringTokenizer tokenizer(filePath, "/\\"); diff --git a/engines/zvision/sound/zork_raw.h b/engines/zvision/sound/zork_raw.h index 0b408d818c..892bad4d5f 100644 --- a/engines/zvision/sound/zork_raw.h +++ b/engines/zvision/sound/zork_raw.h @@ -122,20 +122,6 @@ public: bool rewind(); }; -/** - * Creates an audio stream, which plays from the given buffer. - * - * @param buffer Buffer to play from. - * @param size Size of the buffer in bytes. - * @param rate Rate of the sound data. - * @param dispose AfterUse Whether to free the buffer after use (with free!). - * @return The new SeekableAudioStream (or 0 on failure). - */ -Audio::RewindableAudioStream *makeRawZorkStream(const byte *buffer, uint32 size, - int rate, - bool stereo, - DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); - /** * Creates an audio stream, which plays from the given stream. * -- cgit v1.2.3 From 6c451c9cf481dcaa6261c34773b79689386ded42 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 21:48:59 +0200 Subject: ZVISION: Document where MIDI commands are used --- engines/zvision/scripting/actions.cpp | 4 +++- engines/zvision/scripting/sidefx/music_node.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 89b311e81c..be2079736e 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -477,7 +477,9 @@ ActionMusic::ActionMusic(ZVision *engine, int32 slotkey, const Common::String &l sscanf(line.c_str(), "%u %24s %u %u", &type, fileNameBuffer, &loop, &volume); - // type 4 are midi sound effect files + // Type 4 actions are MIDI commands, not files. These are only used by + // Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well + // as vr) if (type == 4) { _midi = true; int note; diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h index 8f4a46f3fc..3f1ca5cf7b 100644 --- a/engines/zvision/scripting/sidefx/music_node.h +++ b/engines/zvision/scripting/sidefx/music_node.h @@ -91,6 +91,7 @@ private: bool _loaded; }; +// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr) class MusicMidiNode : public MusicNodeBASE { public: MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); -- cgit v1.2.3 From 6368a6ea91364f90bcb0d5d9d88826d856181a52 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 22:00:55 +0200 Subject: ZVISION: Move the menu code together with the other scripting code --- engines/zvision/core/events.cpp | 2 +- engines/zvision/core/menu.cpp | 765 ------------------------------------- engines/zvision/core/menu.h | 125 ------ engines/zvision/module.mk | 2 +- engines/zvision/scripting/menu.cpp | 762 ++++++++++++++++++++++++++++++++++++ engines/zvision/scripting/menu.h | 125 ++++++ engines/zvision/zvision.cpp | 2 +- 7 files changed, 890 insertions(+), 893 deletions(-) delete mode 100644 engines/zvision/core/menu.cpp delete mode 100644 engines/zvision/core/menu.h create mode 100644 engines/zvision/scripting/menu.cpp create mode 100644 engines/zvision/scripting/menu.h diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 1920ffd769..89f1595460 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -28,7 +28,7 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/scripting/script_manager.h" -#include "zvision/core/menu.h" +#include "zvision/scripting/menu.h" #include "zvision/sound/zork_raw.h" #include "common/events.h" diff --git a/engines/zvision/core/menu.cpp b/engines/zvision/core/menu.cpp deleted file mode 100644 index 31e0d71370..0000000000 --- a/engines/zvision/core/menu.cpp +++ /dev/null @@ -1,765 +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 "common/scummsys.h" - -#include "zvision/core/menu.h" - -#include "zvision/graphics/render_manager.h" - -namespace ZVision { - -enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 -}; - -enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 -}; - -MenuHandler::MenuHandler(ZVision *engine) { - _engine = engine; - menuBarFlag = 0xFFFF; -} - -MenuZGI::MenuZGI(ZVision *engine) : - MenuHandler(engine) { - menuMouseFocus = -1; - inmenu = false; - scrolled[0] = false; - scrolled[1] = false; - scrolled[2] = false; - scrollPos[0] = 0.0; - scrollPos[1] = 0.0; - scrollPos[2] = 0.0; - mouseOnItem = -1; - redraw = false; - clean = false; - - char buf[24]; - for (int i = 1; i < 4; i++) { - sprintf(buf, "gmzau%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); - sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); - _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); - } - for (int i = 0; i < 4; i++) { - sprintf(buf, "gmzmu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); - sprintf(buf, "gmznu%2.2x1.tga", i); - _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); - } - - for (int i = 0; i < 50; i++) { - items[i][0] = NULL; - items[i][1] = NULL; - itemId[i] = 0; - } - - for (int i = 0; i < 12; i++) { - magic[i][0] = NULL; - magic[i][1] = NULL; - magicId[i] = 0; - } -} - -MenuZGI::~MenuZGI() { - for (int i = 0; i < 3; i++) { - menuback[i][0].free(); - menuback[i][1].free(); - } - for (int i = 0; i < 4; i++) { - menubar[i][0].free(); - menubar[i][1].free(); - } - for (int i = 0; i < 50; i++) { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - } - } - for (int i = 0; i < 12; i++) { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - } - } -} - -void MenuZGI::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); - if (mouseItem >= 0 && mouseItem < 0xE0) { - _engine->getScriptManager()->inventoryDrop(mouseItem); - _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); - - redraw = true; - } - } - } - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { - for (int i = 0; i < 12; i++) { - - uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (itemnum != 0) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - itemnum = 0xEE + i; - else - itemnum = 0xE0 + i; - } - if (itemnum) - if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) - _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); - } - - } - break; - - case menu_MAIN: - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->ifQuit(); - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - } - break; - } - } -} - -void MenuZGI::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - if (!inmenu) - redraw = true; - inmenu = true; - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - else if (itemCount > 50) - itemCount = 50; - - int lastItem = mouseOnItem; - - mouseOnItem = -1; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { - mouseOnItem = i; - break; - } - } - - if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) - redraw = true; - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { - int lastItem = mouseOnItem; - mouseOnItem = -1; - for (int i = 0; i < 12; i++) { - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { - mouseOnItem = i; - break; - } - } - - if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) - redraw = true; - - } - break; - - case menu_MAIN: { - int lastItem = mouseOnItem; - mouseOnItem = -1; - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], - 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(320 , - scrollPos[menu_MAIN], - 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], - 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], - 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; - } - - if (lastItem != mouseOnItem) - redraw = true; - } - break; - - default: - int cur_menu = menuMouseFocus; - if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menuMouseFocus = menu_MAIN; - scrolled[menu_MAIN] = false; - scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - } - - if (menuBarFlag & menuBar_Magic) - if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menuMouseFocus = menu_MAGIC; - scrolled[menu_MAGIC] = false; - scrollPos[menu_MAGIC] = 28; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); - } - - if (menuBarFlag & menuBar_Items) - if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menuMouseFocus = menu_ITEM; - scrolled[menu_ITEM] = false; - scrollPos[menu_ITEM] = 28 - 600; - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); - } - - if (cur_menu != menuMouseFocus) - clean = true; - - break; - } - } else { - if (inmenu) - clean = true; - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - menuMouseFocus = -1; - } -} - -void MenuZGI::process(uint32 deltatime) { - if (clean) { - _engine->getRenderManager()->clearMenuSurface(); - clean = false; - } - switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) - if (!scrolled[menu_ITEM]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_ITEM] += scrl; - - if (scrollPos[menu_ITEM] >= 0) { - scrolled[menu_ITEM] = true; - scrollPos [menu_ITEM] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); - - int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); - if (itemCount == 0) - itemCount = 20; - else if (itemCount > 50) - itemCount = 50; - - for (int i = 0; i < itemCount; i++) { - int itemspace = (600 - 28) / itemCount; - - bool inrect = false; - - if (mouseOnItem == i) - inrect = true; - - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); - - if (curItemId != 0) { - if (itemId[i] != curItemId) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", curItemId); - items[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", curItemId); - items[i][1] = _engine->getRenderManager()->loadImage(buf, false); - itemId[i] = curItemId; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); - - } else { - if (items[i][0]) { - items[i][0]->free(); - delete items[i][0]; - items[i][0] = NULL; - } - if (items[i][1]) { - items[i][1]->free(); - delete items[i][1]; - items[i][1] = NULL; - } - itemId[i] = 0; - } - } - - redraw = false; - } - break; - - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) - if (!scrolled[menu_MAGIC]) { - redraw = true; - float scrl = 600.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAGIC] += scrl; - - if (scrollPos[menu_MAGIC] >= 600) { - scrolled[menu_MAGIC] = true; - scrollPos [menu_MAGIC] = 600; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); - - for (int i = 0; i < 12; i++) { - bool inrect = false; - - if (mouseOnItem == i) - inrect = true; - - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); - if (curItemId) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) - curItemId = 0xEE + i; - else - curItemId = 0xE0 + i; - } - - if (curItemId != 0) { - if (itemId[i] != curItemId) { - char buf[16]; - sprintf(buf, "gmzwu%2.2x1.tga", curItemId); - magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); - sprintf(buf, "gmzxu%2.2x1.tga", curItemId); - magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); - magicId[i] = curItemId; - } - - if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - else - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); - - } else { - if (magic[i][0]) { - magic[i][0]->free(); - delete magic[i][0]; - magic[i][0] = NULL; - } - if (magic[i][1]) { - magic[i][1]->free(); - delete magic[i][1]; - magic[i][1] = NULL; - } - magicId[i] = 0; - } - } - redraw = false; - } - break; - - case menu_MAIN: - if (!scrolled[menu_MAIN]) { - redraw = true; - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos [menu_MAIN] += scrl; - - if (scrollPos[menu_MAIN] >= 0) { - scrolled[menu_MAIN] = true; - scrollPos [menu_MAIN] = 0; - } - } - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); - - if (menuBarFlag & menuBar_Exit) { - if (mouseOnItem == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Settings) { - if (mouseOnItem == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Restore) { - if (mouseOnItem == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); - } - if (menuBarFlag & menuBar_Save) { - if (mouseOnItem == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); - else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); - } - redraw = false; - } - break; - default: - if (redraw) { - if (inmenu) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); - - if (menuBarFlag & menuBar_Items) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); - - if (menuBarFlag & menuBar_Magic) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); - } - redraw = false; - } - break; - } -} - -MenuNemesis::MenuNemesis(ZVision *engine) : - MenuHandler(engine) { - inmenu = false; - scrolled = false; - scrollPos = 0.0; - mouseOnItem = -1; - redraw = false; - delay = 0; - - char buf[24]; - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) { - sprintf(buf, "butfrm%d%d.tga", i + 1, j); - _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); - } - - _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); - - frm = 0; -} - -MenuNemesis::~MenuNemesis() { - for (int i = 0; i < 4; i++) - for (int j = 0; j < 6; j++) - but[i][j].free(); - - menubar.free(); -} - -static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; - -void MenuNemesis::onMouseUp(const Common::Point &Pos) { - if (Pos.y < 40) { - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - _engine->ifQuit(); - frm = 5; - redraw = true; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); - frm = 5; - redraw = true; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); - frm = 5; - redraw = true; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); - frm = 5; - redraw = true; - } - } -} - -void MenuNemesis::onMouseMove(const Common::Point &Pos) { - if (Pos.y < 40) { - - inmenu = true; - - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); - - int lastItem = mouseOnItem; - mouseOnItem = -1; - - // Exit - if (menuBarFlag & menuBar_Exit) - if (Common::Rect(buts[3][1], - scrollPos, - buts[3][0] + buts[3][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; - } - - // Settings - if (menuBarFlag & menuBar_Settings) - if (Common::Rect(buts[2][1], - scrollPos, - buts[2][0] + buts[2][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; - } - - // Load - if (menuBarFlag & menuBar_Restore) - if (Common::Rect(buts[1][1], - scrollPos, - buts[1][0] + buts[1][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; - } - - // Save - if (menuBarFlag & menuBar_Save) - if (Common::Rect(buts[0][1], - scrollPos, - buts[0][0] + buts[0][1], - scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; - } - - if (lastItem != mouseOnItem) { - redraw = true; - frm = 0; - delay = 200; - } - } else { - inmenu = false; - if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) - _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); - mouseOnItem = -1; - } -} - -void MenuNemesis::process(uint32 deltatime) { - if (inmenu) { - if (!scrolled) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - scrollPos += scrl; - redraw = true; - } - - if (scrollPos >= 0) { - scrolled = true; - scrollPos = 0; - } - - if (mouseOnItem != -1) { - delay -= deltatime; - if (delay <= 0 && frm < 4) { - delay = 200; - frm++; - redraw = true; - } - } - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - - if (menuBarFlag & menuBar_Exit) - if (mouseOnItem == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - - if (menuBarFlag & menuBar_Settings) - if (mouseOnItem == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - - if (menuBarFlag & menuBar_Restore) - if (mouseOnItem == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - - if (menuBarFlag & menuBar_Save) - if (mouseOnItem == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); - - redraw = false; - } - } else { - scrolled = false; - if (scrollPos > -32) { - float scrl = 32.0 * 2.0 * (deltatime / 1000.0); - - if (scrl == 0) - scrl = 1.0; - - Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); - _engine->getRenderManager()->clearMenuSurface(cl); - - scrollPos -= scrl; - redraw = true; - } else - scrollPos = -32; - - if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - redraw = false; - } - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/menu.h b/engines/zvision/core/menu.h deleted file mode 100644 index ebe0bb50ac..0000000000 --- a/engines/zvision/core/menu.h +++ /dev/null @@ -1,125 +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 ZVISION_MENU_H -#define ZVISION_MENU_H - -#include "graphics/surface.h" -#include "common/rect.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" - -namespace ZVision { - -enum menuBar { - menuBar_Exit = 0x1, - menuBar_Settings = 0x2, - menuBar_Restore = 0x4, - menuBar_Save = 0x8, - menuBar_Items = 0x100, - menuBar_Magic = 0x200 -}; - -class MenuHandler { -public: - MenuHandler(ZVision *engine); - virtual ~MenuHandler() {}; - virtual void onMouseMove(const Common::Point &Pos) {}; - virtual void onMouseDown(const Common::Point &Pos) {}; - virtual void onMouseUp(const Common::Point &Pos) {}; - virtual void process(uint32 deltaTimeInMillis) {}; - - void setEnable(uint16 flags) { - menuBarFlag = flags; - } - uint16 getEnable() { - return menuBarFlag; - } -protected: - uint16 menuBarFlag; - ZVision *_engine; -}; - -class MenuZGI: public MenuHandler { -public: - MenuZGI(ZVision *engine); - ~MenuZGI(); - void onMouseMove(const Common::Point &Pos); - void onMouseUp(const Common::Point &Pos); - void process(uint32 deltaTimeInMillis); -private: - Graphics::Surface menuback[3][2]; - Graphics::Surface menubar[4][2]; - Graphics::Surface *items[50][2]; - uint itemId[50]; - - Graphics::Surface *magic[12][2]; - uint magicId[12]; - - int menuMouseFocus; - bool inmenu; - - int mouseOnItem; - - bool scrolled[3]; - int16 scrollPos[3]; - - enum { - menu_ITEM = 0, - menu_MAGIC = 1, - menu_MAIN = 2 - }; - - bool clean; - bool redraw; - -}; - -class MenuNemesis: public MenuHandler { -public: - MenuNemesis(ZVision *engine); - ~MenuNemesis(); - void onMouseMove(const Common::Point &Pos); - void onMouseUp(const Common::Point &Pos); - void process(uint32 deltaTimeInMillis); -private: - Graphics::Surface but[4][6]; - Graphics::Surface menubar; - - bool inmenu; - - int mouseOnItem; - - bool scrolled; - int16 scrollPos; - - bool redraw; - - int frm; - int16 delay; - -}; - -} - -#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 3ea31abe1b..6955d62534 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -4,7 +4,6 @@ MODULE_OBJS := \ core/console.o \ core/clock.o \ core/events.o \ - core/menu.o \ core/save_manager.o \ detection.o \ file/lzss_read_stream.o \ @@ -30,6 +29,7 @@ MODULE_OBJS := \ scripting/controls/slot_control.o \ scripting/controls/titler_control.o \ scripting/inventory.o \ + scripting/menu.o \ scripting/scr_file_handling.o \ scripting/script_manager.o \ scripting/sidefx/animation_node.o \ diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp new file mode 100644 index 0000000000..fa5e24f39f --- /dev/null +++ b/engines/zvision/scripting/menu.cpp @@ -0,0 +1,762 @@ +/* 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 "zvision/graphics/render_manager.h" +#include "zvision/scripting/menu.h" + +namespace ZVision { + +enum { + SLOT_START_SLOT = 151, + SLOT_SPELL_1 = 191, + SLOT_USER_CHOSE_THIS_SPELL = 205, + SLOT_REVERSED_SPELLBOOK = 206 +}; + +enum { + menu_MAIN_SAVE = 0, + menu_MAIN_REST = 1, + menu_MAIN_PREF = 2, + menu_MAIN_EXIT = 3 +}; + +MenuHandler::MenuHandler(ZVision *engine) { + _engine = engine; + menuBarFlag = 0xFFFF; +} + +MenuZGI::MenuZGI(ZVision *engine) : + MenuHandler(engine) { + menuMouseFocus = -1; + inmenu = false; + scrolled[0] = false; + scrolled[1] = false; + scrolled[2] = false; + scrollPos[0] = 0.0; + scrollPos[1] = 0.0; + scrollPos[2] = 0.0; + mouseOnItem = -1; + redraw = false; + clean = false; + + char buf[24]; + for (int i = 1; i < 4; i++) { + sprintf(buf, "gmzau%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][0], false); + sprintf(buf, "gmzau%2.2x1.tga", i + 0x10); + _engine->getRenderManager()->readImageToSurface(buf, menuback[i - 1][1], false); + } + for (int i = 0; i < 4; i++) { + sprintf(buf, "gmzmu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][0], false); + sprintf(buf, "gmznu%2.2x1.tga", i); + _engine->getRenderManager()->readImageToSurface(buf, menubar[i][1], false); + } + + for (int i = 0; i < 50; i++) { + items[i][0] = NULL; + items[i][1] = NULL; + itemId[i] = 0; + } + + for (int i = 0; i < 12; i++) { + magic[i][0] = NULL; + magic[i][1] = NULL; + magicId[i] = 0; + } +} + +MenuZGI::~MenuZGI() { + for (int i = 0; i < 3; i++) { + menuback[i][0].free(); + menuback[i][1].free(); + } + for (int i = 0; i < 4; i++) { + menubar[i][0].free(); + menubar[i][1].free(); + } + for (int i = 0; i < 50; i++) { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + } + } + for (int i = 0; i < 12; i++) { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + } + } +} + +void MenuZGI::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + switch (menuMouseFocus) { + case menu_ITEM: + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); + if (mouseItem >= 0 && mouseItem < 0xE0) { + _engine->getScriptManager()->inventoryDrop(mouseItem); + _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); + _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); + + redraw = true; + } + } + } + } + break; + + case menu_MAGIC: + if (menuBarFlag & menuBar_Magic) { + for (int i = 0; i < 12; i++) { + + uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (itemnum != 0) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + itemnum = 0xEE + i; + else + itemnum = 0xE0 + i; + } + if (itemnum) + if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) + _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); + } + + } + break; + + case menu_MAIN: + + // Exit + if (menuBarFlag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->ifQuit(); + } + + // Settings + if (menuBarFlag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + } + + // Load + if (menuBarFlag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + } + + // Save + if (menuBarFlag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + } + break; + } + } +} + +void MenuZGI::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + if (!inmenu) + redraw = true; + inmenu = true; + switch (menuMouseFocus) { + case menu_ITEM: + if (menuBarFlag & menuBar_Items) { + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; + + int lastItem = mouseOnItem; + + mouseOnItem = -1; + + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; + + if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, + scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + mouseOnItem = i; + break; + } + } + + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) + redraw = true; + } + break; + + case menu_MAGIC: + if (menuBarFlag & menuBar_Magic) { + int lastItem = mouseOnItem; + mouseOnItem = -1; + for (int i = 0; i < 12; i++) { + if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, + 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { + mouseOnItem = i; + break; + } + } + + if (lastItem != mouseOnItem) + if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || + _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) + redraw = true; + + } + break; + + case menu_MAIN: { + int lastItem = mouseOnItem; + mouseOnItem = -1; + + // Exit + if (menuBarFlag & menuBar_Exit) + if (Common::Rect(320 + 135, + scrollPos[menu_MAIN], + 320 + 135 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_EXIT; + } + + // Settings + if (menuBarFlag & menuBar_Settings) + if (Common::Rect(320 , + scrollPos[menu_MAIN], + 320 + 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_PREF; + } + + // Load + if (menuBarFlag & menuBar_Restore) + if (Common::Rect(320 - 135, + scrollPos[menu_MAIN], + 320, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_REST; + } + + // Save + if (menuBarFlag & menuBar_Save) + if (Common::Rect(320 - 135 * 2, + scrollPos[menu_MAIN], + 320 - 135, + scrollPos[menu_MAIN] + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_SAVE; + } + + if (lastItem != mouseOnItem) + redraw = true; + } + break; + + default: + int cur_menu = menuMouseFocus; + if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main + menuMouseFocus = menu_MAIN; + scrolled[menu_MAIN] = false; + scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + } + + if (menuBarFlag & menuBar_Magic) + if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic + menuMouseFocus = menu_MAGIC; + scrolled[menu_MAGIC] = false; + scrollPos[menu_MAGIC] = 28; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); + } + + if (menuBarFlag & menuBar_Items) + if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items + menuMouseFocus = menu_ITEM; + scrolled[menu_ITEM] = false; + scrollPos[menu_ITEM] = 28 - 600; + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); + } + + if (cur_menu != menuMouseFocus) + clean = true; + + break; + } + } else { + if (inmenu) + clean = true; + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + menuMouseFocus = -1; + } +} + +void MenuZGI::process(uint32 deltatime) { + if (clean) { + _engine->getRenderManager()->clearMenuSurface(); + clean = false; + } + switch (menuMouseFocus) { + case menu_ITEM: + if (menuBarFlag & menuBar_Items) + if (!scrolled[menu_ITEM]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_ITEM] += scrl; + + if (scrollPos[menu_ITEM] >= 0) { + scrolled[menu_ITEM] = true; + scrollPos [menu_ITEM] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); + + int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); + if (itemCount == 0) + itemCount = 20; + else if (itemCount > 50) + itemCount = 50; + + for (int i = 0; i < itemCount; i++) { + int itemspace = (600 - 28) / itemCount; + + bool inrect = false; + + if (mouseOnItem == i) + inrect = true; + + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + + if (curItemId != 0) { + if (itemId[i] != curItemId) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); + items[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); + items[i][1] = _engine->getRenderManager()->loadImage(buf, false); + itemId[i] = curItemId; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + + } else { + if (items[i][0]) { + items[i][0]->free(); + delete items[i][0]; + items[i][0] = NULL; + } + if (items[i][1]) { + items[i][1]->free(); + delete items[i][1]; + items[i][1] = NULL; + } + itemId[i] = 0; + } + } + + redraw = false; + } + break; + + case menu_MAGIC: + if (menuBarFlag & menuBar_Magic) + if (!scrolled[menu_MAGIC]) { + redraw = true; + float scrl = 600.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAGIC] += scrl; + + if (scrollPos[menu_MAGIC] >= 600) { + scrolled[menu_MAGIC] = true; + scrollPos [menu_MAGIC] = 600; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); + + for (int i = 0; i < 12; i++) { + bool inrect = false; + + if (mouseOnItem == i) + inrect = true; + + uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + if (curItemId) { + if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + curItemId = 0xEE + i; + else + curItemId = 0xE0 + i; + } + + if (curItemId != 0) { + if (itemId[i] != curItemId) { + char buf[16]; + sprintf(buf, "gmzwu%2.2x1.tga", curItemId); + magic[i][0] = _engine->getRenderManager()->loadImage(buf, false); + sprintf(buf, "gmzxu%2.2x1.tga", curItemId); + magic[i][1] = _engine->getRenderManager()->loadImage(buf, false); + magicId[i] = curItemId; + } + + if (inrect) + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + else + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + + } else { + if (magic[i][0]) { + magic[i][0]->free(); + delete magic[i][0]; + magic[i][0] = NULL; + } + if (magic[i][1]) { + magic[i][1]->free(); + delete magic[i][1]; + magic[i][1] = NULL; + } + magicId[i] = 0; + } + } + redraw = false; + } + break; + + case menu_MAIN: + if (!scrolled[menu_MAIN]) { + redraw = true; + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos [menu_MAIN] += scrl; + + if (scrollPos[menu_MAIN] >= 0) { + scrolled[menu_MAIN] = true; + scrollPos [menu_MAIN] = 0; + } + } + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); + + if (menuBarFlag & menuBar_Exit) { + if (mouseOnItem == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); + } + if (menuBarFlag & menuBar_Settings) { + if (mouseOnItem == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); + } + if (menuBarFlag & menuBar_Restore) { + if (mouseOnItem == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); + } + if (menuBarFlag & menuBar_Save) { + if (mouseOnItem == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); + else + _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); + } + redraw = false; + } + break; + default: + if (redraw) { + if (inmenu) { + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); + + if (menuBarFlag & menuBar_Items) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); + + if (menuBarFlag & menuBar_Magic) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); + } + redraw = false; + } + break; + } +} + +MenuNemesis::MenuNemesis(ZVision *engine) : + MenuHandler(engine) { + inmenu = false; + scrolled = false; + scrollPos = 0.0; + mouseOnItem = -1; + redraw = false; + delay = 0; + + char buf[24]; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) { + sprintf(buf, "butfrm%d%d.tga", i + 1, j); + _engine->getRenderManager()->readImageToSurface(buf, but[i][j], false); + } + + _engine->getRenderManager()->readImageToSurface("bar.tga", menubar, false); + + frm = 0; +} + +MenuNemesis::~MenuNemesis() { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 6; j++) + but[i][j].free(); + + menubar.free(); +} + +static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} }; + +void MenuNemesis::onMouseUp(const Common::Point &Pos) { + if (Pos.y < 40) { + // Exit + if (menuBarFlag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + _engine->ifQuit(); + frm = 5; + redraw = true; + } + + // Settings + if (menuBarFlag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); + frm = 5; + redraw = true; + } + + // Load + if (menuBarFlag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); + frm = 5; + redraw = true; + } + + // Save + if (menuBarFlag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); + frm = 5; + redraw = true; + } + } +} + +void MenuNemesis::onMouseMove(const Common::Point &Pos) { + if (Pos.y < 40) { + + inmenu = true; + + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 2) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); + + int lastItem = mouseOnItem; + mouseOnItem = -1; + + // Exit + if (menuBarFlag & menuBar_Exit) + if (Common::Rect(buts[3][1], + scrollPos, + buts[3][0] + buts[3][1], + scrollPos + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_EXIT; + } + + // Settings + if (menuBarFlag & menuBar_Settings) + if (Common::Rect(buts[2][1], + scrollPos, + buts[2][0] + buts[2][1], + scrollPos + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_PREF; + } + + // Load + if (menuBarFlag & menuBar_Restore) + if (Common::Rect(buts[1][1], + scrollPos, + buts[1][0] + buts[1][1], + scrollPos + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_REST; + } + + // Save + if (menuBarFlag & menuBar_Save) + if (Common::Rect(buts[0][1], + scrollPos, + buts[0][0] + buts[0][1], + scrollPos + 32).contains(Pos)) { + mouseOnItem = menu_MAIN_SAVE; + } + + if (lastItem != mouseOnItem) { + redraw = true; + frm = 0; + delay = 200; + } + } else { + inmenu = false; + if (_engine->getScriptManager()->getStateValue(StateKey_MenuState) != 0) + _engine->getScriptManager()->setStateValue(StateKey_MenuState, 0); + mouseOnItem = -1; + } +} + +void MenuNemesis::process(uint32 deltatime) { + if (inmenu) { + if (!scrolled) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + scrollPos += scrl; + redraw = true; + } + + if (scrollPos >= 0) { + scrolled = true; + scrollPos = 0; + } + + if (mouseOnItem != -1) { + delay -= deltatime; + if (delay <= 0 && frm < 4) { + delay = 200; + frm++; + redraw = true; + } + } + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + + if (menuBarFlag & menuBar_Exit) + if (mouseOnItem == menu_MAIN_EXIT) + _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); + + if (menuBarFlag & menuBar_Settings) + if (mouseOnItem == menu_MAIN_PREF) + _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); + + if (menuBarFlag & menuBar_Restore) + if (mouseOnItem == menu_MAIN_REST) + _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); + + if (menuBarFlag & menuBar_Save) + if (mouseOnItem == menu_MAIN_SAVE) + _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); + + redraw = false; + } + } else { + scrolled = false; + if (scrollPos > -32) { + float scrl = 32.0 * 2.0 * (deltatime / 1000.0); + + if (scrl == 0) + scrl = 1.0; + + Common::Rect cl(64, 32 + scrollPos - scrl, 64 + 512, 32 + scrollPos + 1); + _engine->getRenderManager()->clearMenuSurface(cl); + + scrollPos -= scrl; + redraw = true; + } else + scrollPos = -32; + + if (redraw) { + _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); + redraw = false; + } + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/menu.h b/engines/zvision/scripting/menu.h new file mode 100644 index 0000000000..ebe0bb50ac --- /dev/null +++ b/engines/zvision/scripting/menu.h @@ -0,0 +1,125 @@ +/* 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 ZVISION_MENU_H +#define ZVISION_MENU_H + +#include "graphics/surface.h" +#include "common/rect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" + +namespace ZVision { + +enum menuBar { + menuBar_Exit = 0x1, + menuBar_Settings = 0x2, + menuBar_Restore = 0x4, + menuBar_Save = 0x8, + menuBar_Items = 0x100, + menuBar_Magic = 0x200 +}; + +class MenuHandler { +public: + MenuHandler(ZVision *engine); + virtual ~MenuHandler() {}; + virtual void onMouseMove(const Common::Point &Pos) {}; + virtual void onMouseDown(const Common::Point &Pos) {}; + virtual void onMouseUp(const Common::Point &Pos) {}; + virtual void process(uint32 deltaTimeInMillis) {}; + + void setEnable(uint16 flags) { + menuBarFlag = flags; + } + uint16 getEnable() { + return menuBarFlag; + } +protected: + uint16 menuBarFlag; + ZVision *_engine; +}; + +class MenuZGI: public MenuHandler { +public: + MenuZGI(ZVision *engine); + ~MenuZGI(); + void onMouseMove(const Common::Point &Pos); + void onMouseUp(const Common::Point &Pos); + void process(uint32 deltaTimeInMillis); +private: + Graphics::Surface menuback[3][2]; + Graphics::Surface menubar[4][2]; + Graphics::Surface *items[50][2]; + uint itemId[50]; + + Graphics::Surface *magic[12][2]; + uint magicId[12]; + + int menuMouseFocus; + bool inmenu; + + int mouseOnItem; + + bool scrolled[3]; + int16 scrollPos[3]; + + enum { + menu_ITEM = 0, + menu_MAGIC = 1, + menu_MAIN = 2 + }; + + bool clean; + bool redraw; + +}; + +class MenuNemesis: public MenuHandler { +public: + MenuNemesis(ZVision *engine); + ~MenuNemesis(); + void onMouseMove(const Common::Point &Pos); + void onMouseUp(const Common::Point &Pos); + void process(uint32 deltaTimeInMillis); +private: + Graphics::Surface but[4][6]; + Graphics::Surface menubar; + + bool inmenu; + + int mouseOnItem; + + bool scrolled; + int16 scrollPos; + + bool redraw; + + int frm; + int16 delay; + +}; + +} + +#endif diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index db96884103..f692969942 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -30,7 +30,7 @@ #include "zvision/core/save_manager.h" #include "zvision/text/string_manager.h" #include "zvision/detection.h" -#include "zvision/core/menu.h" +#include "zvision/scripting/menu.h" #include "zvision/file/search_manager.h" #include "zvision/text/text.h" #include "zvision/text/truetype_font.h" -- cgit v1.2.3 From 3661bc4cf13ac9bb27e60969b4195acc82fee6c5 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Thu, 25 Dec 2014 22:11:29 +0200 Subject: ZVISION: Normalize and cleanup all the menu-related enums --- engines/zvision/core/events.cpp | 8 +- engines/zvision/scripting/menu.cpp | 289 ++++++++++++++--------------- engines/zvision/scripting/menu.h | 18 +- engines/zvision/scripting/script_manager.h | 7 +- 4 files changed, 160 insertions(+), 162 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 89f1595460..227cf213dc 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -43,19 +43,19 @@ void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { case Common::KEYCODE_s: - if (getMenuBarEnable() & menuBar_Save) + if (getMenuBarEnable() & kMenubarSave) _scriptManager->changeLocation('g', 'j', 's', 'e', 0); break; case Common::KEYCODE_r: - if (getMenuBarEnable() & menuBar_Restore) + if (getMenuBarEnable() & kMenubarRestore) _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); break; case Common::KEYCODE_p: - if (getMenuBarEnable() & menuBar_Settings) + if (getMenuBarEnable() & kMenubarSettings) _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); break; case Common::KEYCODE_q: - if (getMenuBarEnable() & menuBar_Exit) + if (getMenuBarEnable() & kMenubarExit) ifQuit(); break; default: diff --git a/engines/zvision/scripting/menu.cpp b/engines/zvision/scripting/menu.cpp index fa5e24f39f..16aa57e3ae 100644 --- a/engines/zvision/scripting/menu.cpp +++ b/engines/zvision/scripting/menu.cpp @@ -26,17 +26,16 @@ namespace ZVision { enum { - SLOT_START_SLOT = 151, - SLOT_SPELL_1 = 191, - SLOT_USER_CHOSE_THIS_SPELL = 205, - SLOT_REVERSED_SPELLBOOK = 206 + kMainMenuSave = 0, + kMainMenuLoad = 1, + kMainMenuPrefs = 2, + kMainMenuExit = 3 }; enum { - menu_MAIN_SAVE = 0, - menu_MAIN_REST = 1, - menu_MAIN_PREF = 2, - menu_MAIN_EXIT = 3 + kMenuItem = 0, + kMenuMagic = 1, + kMenuMain = 2 }; MenuHandler::MenuHandler(ZVision *engine) { @@ -119,8 +118,8 @@ MenuZGI::~MenuZGI() { void MenuZGI::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { + case kMenuItem: + if (menuBarFlag & kMenubarItems) { int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); if (itemCount == 0) itemCount = 20; @@ -128,13 +127,13 @@ void MenuZGI::onMouseUp(const Common::Point &Pos) { for (int i = 0; i < itemCount; i++) { int itemspace = (600 - 28) / itemCount; - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0, + scrollPos[kMenuItem] + itemspace * i + 28, 32).contains(Pos)) { int32 mouseItem = _engine->getScriptManager()->getStateValue(StateKey_InventoryItem); if (mouseItem >= 0 && mouseItem < 0xE0) { _engine->getScriptManager()->inventoryDrop(mouseItem); - _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i)); - _engine->getScriptManager()->setStateValue(SLOT_START_SLOT + i, mouseItem); + _engine->getScriptManager()->inventoryAdd(_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i)); + _engine->getScriptManager()->setStateValue(StateKey_Inv_StartSlot + i, mouseItem); redraw = true; } @@ -143,62 +142,62 @@ void MenuZGI::onMouseUp(const Common::Point &Pos) { } break; - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { + case kMenuMagic: + if (menuBarFlag & kMenubarMagic) { for (int i = 0; i < 12; i++) { - uint itemnum = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + uint itemnum = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i); if (itemnum != 0) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 1) itemnum = 0xEE + i; else itemnum = 0xE0 + i; } if (itemnum) if (_engine->getScriptManager()->getStateValue(StateKey_InventoryItem) == 0 || _engine->getScriptManager()->getStateValue(StateKey_InventoryItem) >= 0xE0) - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) - _engine->getScriptManager()->setStateValue(SLOT_USER_CHOSE_THIS_SPELL, itemnum); + if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0, + 668 + 47 * i - scrollPos[kMenuMagic] + 28, 32).contains(Pos)) + _engine->getScriptManager()->setStateValue(StateKey_Active_Spell, itemnum); } } break; - case menu_MAIN: + case kMenuMain: // Exit - if (menuBarFlag & menuBar_Exit) + if (menuBarFlag & kMenubarExit) if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { + scrollPos[kMenuMain] + 32).contains(Pos)) { _engine->ifQuit(); } // Settings - if (menuBarFlag & menuBar_Settings) + if (menuBarFlag & kMenubarSettings) if (Common::Rect(320 , - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { + scrollPos[kMenuMain] + 32).contains(Pos)) { _engine->getScriptManager()->changeLocation('g', 'j', 'p', 'e', 0); } // Load - if (menuBarFlag & menuBar_Restore) + if (menuBarFlag & kMenubarRestore) if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { + scrollPos[kMenuMain] + 32).contains(Pos)) { _engine->getScriptManager()->changeLocation('g', 'j', 'r', 'e', 0); } // Save - if (menuBarFlag & menuBar_Save) + if (menuBarFlag & kMenubarSave) if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { + scrollPos[kMenuMain] + 32).contains(Pos)) { _engine->getScriptManager()->changeLocation('g', 'j', 's', 'e', 0); } break; @@ -213,8 +212,8 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) { redraw = true; inmenu = true; switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) { + case kMenuItem: + if (menuBarFlag & kMenubarItems) { int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); if (itemCount == 0) itemCount = 20; @@ -228,78 +227,78 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) { for (int i = 0; i < itemCount; i++) { int itemspace = (600 - 28) / itemCount; - if (Common::Rect(scrollPos[menu_ITEM] + itemspace * i, 0, - scrollPos[menu_ITEM] + itemspace * i + 28, 32).contains(Pos)) { + if (Common::Rect(scrollPos[kMenuItem] + itemspace * i, 0, + scrollPos[kMenuItem] + itemspace * i + 28, 32).contains(Pos)) { mouseOnItem = i; break; } } if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_START_SLOT + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + lastItem)) + if (_engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + mouseOnItem) || + _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + lastItem)) redraw = true; } break; - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) { + case kMenuMagic: + if (menuBarFlag & kMenubarMagic) { int lastItem = mouseOnItem; mouseOnItem = -1; for (int i = 0; i < 12; i++) { - if (Common::Rect(668 + 47 * i - scrollPos[menu_MAGIC], 0, - 668 + 47 * i - scrollPos[menu_MAGIC] + 28, 32).contains(Pos)) { + if (Common::Rect(668 + 47 * i - scrollPos[kMenuMagic], 0, + 668 + 47 * i - scrollPos[kMenuMagic] + 28, 32).contains(Pos)) { mouseOnItem = i; break; } } if (lastItem != mouseOnItem) - if (_engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + mouseOnItem) || - _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + lastItem)) + if (_engine->getScriptManager()->getStateValue(StateKey_Spell_1 + mouseOnItem) || + _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + lastItem)) redraw = true; } break; - case menu_MAIN: { + case kMenuMain: { int lastItem = mouseOnItem; mouseOnItem = -1; // Exit - if (menuBarFlag & menuBar_Exit) + if (menuBarFlag & kMenubarExit) if (Common::Rect(320 + 135, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 + 135 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; + scrollPos[kMenuMain] + 32).contains(Pos)) { + mouseOnItem = kMainMenuExit; } // Settings - if (menuBarFlag & menuBar_Settings) + if (menuBarFlag & kMenubarSettings) if (Common::Rect(320 , - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 + 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; + scrollPos[kMenuMain] + 32).contains(Pos)) { + mouseOnItem = kMainMenuPrefs; } // Load - if (menuBarFlag & menuBar_Restore) + if (menuBarFlag & kMenubarRestore) if (Common::Rect(320 - 135, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; + scrollPos[kMenuMain] + 32).contains(Pos)) { + mouseOnItem = kMainMenuLoad; } // Save - if (menuBarFlag & menuBar_Save) + if (menuBarFlag & kMenubarSave) if (Common::Rect(320 - 135 * 2, - scrollPos[menu_MAIN], + scrollPos[kMenuMain], 320 - 135, - scrollPos[menu_MAIN] + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; + scrollPos[kMenuMain] + 32).contains(Pos)) { + mouseOnItem = kMainMenuSave; } if (lastItem != mouseOnItem) @@ -310,25 +309,25 @@ void MenuZGI::onMouseMove(const Common::Point &Pos) { default: int cur_menu = menuMouseFocus; if (Common::Rect(64, 0, 64 + 512, 8).contains(Pos)) { // Main - menuMouseFocus = menu_MAIN; - scrolled[menu_MAIN] = false; - scrollPos[menu_MAIN] = menuback[menu_MAIN][1].h - menuback[menu_MAIN][0].h; + menuMouseFocus = kMenuMain; + scrolled[kMenuMain] = false; + scrollPos[kMenuMain] = menuback[kMenuMain][1].h - menuback[kMenuMain][0].h; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 2); } - if (menuBarFlag & menuBar_Magic) + if (menuBarFlag & kMenubarMagic) if (Common::Rect(640 - 28, 0, 640, 32).contains(Pos)) { // Magic - menuMouseFocus = menu_MAGIC; - scrolled[menu_MAGIC] = false; - scrollPos[menu_MAGIC] = 28; + menuMouseFocus = kMenuMagic; + scrolled[kMenuMagic] = false; + scrollPos[kMenuMagic] = 28; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 3); } - if (menuBarFlag & menuBar_Items) + if (menuBarFlag & kMenubarItems) if (Common::Rect(0, 0, 28, 32).contains(Pos)) { // Items - menuMouseFocus = menu_ITEM; - scrolled[menu_ITEM] = false; - scrollPos[menu_ITEM] = 28 - 600; + menuMouseFocus = kMenuItem; + scrolled[kMenuItem] = false; + scrollPos[kMenuItem] = 28 - 600; _engine->getScriptManager()->setStateValue(StateKey_MenuState, 1); } @@ -353,24 +352,24 @@ void MenuZGI::process(uint32 deltatime) { clean = false; } switch (menuMouseFocus) { - case menu_ITEM: - if (menuBarFlag & menuBar_Items) - if (!scrolled[menu_ITEM]) { + case kMenuItem: + if (menuBarFlag & kMenubarItems) + if (!scrolled[kMenuItem]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); if (scrl == 0) scrl = 1.0; - scrollPos [menu_ITEM] += scrl; + scrollPos [kMenuItem] += scrl; - if (scrollPos[menu_ITEM] >= 0) { - scrolled[menu_ITEM] = true; - scrollPos [menu_ITEM] = 0; + if (scrollPos[kMenuItem] >= 0) { + scrolled[kMenuItem] = true; + scrollPos [kMenuItem] = 0; } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][0], scrollPos[menu_ITEM], 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][0], scrollPos[kMenuItem], 0); int itemCount = _engine->getScriptManager()->getStateValue(StateKey_Inv_TotalSlots); if (itemCount == 0) @@ -386,7 +385,7 @@ void MenuZGI::process(uint32 deltatime) { if (mouseOnItem == i) inrect = true; - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_START_SLOT + i); + uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Inv_StartSlot + i); if (curItemId != 0) { if (itemId[i] != curItemId) { @@ -399,9 +398,9 @@ void MenuZGI::process(uint32 deltatime) { } if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][1], scrollPos[kMenuItem] + itemspace * i, 0, 0); else - _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[menu_ITEM] + itemspace * i, 0, 0); + _engine->getRenderManager()->blitSurfaceToMenu(*items[i][0], scrollPos[kMenuItem] + itemspace * i, 0, 0); } else { if (items[i][0]) { @@ -422,24 +421,24 @@ void MenuZGI::process(uint32 deltatime) { } break; - case menu_MAGIC: - if (menuBarFlag & menuBar_Magic) - if (!scrolled[menu_MAGIC]) { + case kMenuMagic: + if (menuBarFlag & kMenubarMagic) + if (!scrolled[kMenuMagic]) { redraw = true; float scrl = 600.0 * (deltatime / 1000.0); if (scrl == 0) scrl = 1.0; - scrollPos [menu_MAGIC] += scrl; + scrollPos [kMenuMagic] += scrl; - if (scrollPos[menu_MAGIC] >= 600) { - scrolled[menu_MAGIC] = true; - scrollPos [menu_MAGIC] = 600; + if (scrollPos[kMenuMagic] >= 600) { + scrolled[kMenuMagic] = true; + scrollPos [kMenuMagic] = 600; } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][0], 640 - scrollPos[menu_MAGIC], 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][0], 640 - scrollPos[kMenuMagic], 0); for (int i = 0; i < 12; i++) { bool inrect = false; @@ -447,9 +446,9 @@ void MenuZGI::process(uint32 deltatime) { if (mouseOnItem == i) inrect = true; - uint curItemId = _engine->getScriptManager()->getStateValue(SLOT_SPELL_1 + i); + uint curItemId = _engine->getScriptManager()->getStateValue(StateKey_Spell_1 + i); if (curItemId) { - if (_engine->getScriptManager()->getStateValue(SLOT_REVERSED_SPELLBOOK) == 1) + if (_engine->getScriptManager()->getStateValue(StateKey_Reversed_Spellbooc) == 1) curItemId = 0xEE + i; else curItemId = 0xE0 + i; @@ -466,9 +465,9 @@ void MenuZGI::process(uint32 deltatime) { } if (inrect) - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][1], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0); else - _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[menu_MAGIC], 0, 0); + _engine->getRenderManager()->blitSurfaceToMenu(*magic[i][0], 668 + 47 * i - scrollPos[kMenuMagic], 0, 0); } else { if (magic[i][0]) { @@ -488,47 +487,47 @@ void MenuZGI::process(uint32 deltatime) { } break; - case menu_MAIN: - if (!scrolled[menu_MAIN]) { + case kMenuMain: + if (!scrolled[kMenuMain]) { redraw = true; float scrl = 32.0 * 2.0 * (deltatime / 1000.0); if (scrl == 0) scrl = 1.0; - scrollPos [menu_MAIN] += scrl; + scrollPos [kMenuMain] += scrl; - if (scrollPos[menu_MAIN] >= 0) { - scrolled[menu_MAIN] = true; - scrollPos [menu_MAIN] = 0; + if (scrollPos[kMenuMain] >= 0) { + scrolled[kMenuMain] = true; + scrollPos [kMenuMain] = 0; } } if (redraw) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][0], 30, scrollPos[menu_MAIN]); + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][0], 30, scrollPos[kMenuMain]); - if (menuBarFlag & menuBar_Exit) { - if (mouseOnItem == menu_MAIN_EXIT) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][1], 320 + 135, scrollPos[menu_MAIN]); + if (menuBarFlag & kMenubarExit) { + if (mouseOnItem == kMainMenuExit) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][1], 320 + 135, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_EXIT][0], 320 + 135, scrollPos[menu_MAIN]); + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuExit][0], 320 + 135, scrollPos[kMenuMain]); } - if (menuBarFlag & menuBar_Settings) { - if (mouseOnItem == menu_MAIN_PREF) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][1], 320, scrollPos[menu_MAIN]); + if (menuBarFlag & kMenubarSettings) { + if (mouseOnItem == kMainMenuPrefs) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][1], 320, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_PREF][0], 320, scrollPos[menu_MAIN]); + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuPrefs][0], 320, scrollPos[kMenuMain]); } - if (menuBarFlag & menuBar_Restore) { - if (mouseOnItem == menu_MAIN_REST) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][1], 320 - 135, scrollPos[menu_MAIN]); + if (menuBarFlag & kMenubarRestore) { + if (mouseOnItem == kMainMenuLoad) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][1], 320 - 135, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_REST][0], 320 - 135, scrollPos[menu_MAIN]); + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuLoad][0], 320 - 135, scrollPos[kMenuMain]); } - if (menuBarFlag & menuBar_Save) { - if (mouseOnItem == menu_MAIN_SAVE) - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][1], 320 - 135 * 2, scrollPos[menu_MAIN]); + if (menuBarFlag & kMenubarSave) { + if (mouseOnItem == kMainMenuSave) + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][1], 320 - 135 * 2, scrollPos[kMenuMain]); else - _engine->getRenderManager()->blitSurfaceToMenu(menubar[menu_MAIN_SAVE][0], 320 - 135 * 2, scrollPos[menu_MAIN]); + _engine->getRenderManager()->blitSurfaceToMenu(menubar[kMainMenuSave][0], 320 - 135 * 2, scrollPos[kMenuMain]); } redraw = false; } @@ -536,13 +535,13 @@ void MenuZGI::process(uint32 deltatime) { default: if (redraw) { if (inmenu) { - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAIN][1], 30, 0); + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMain][1], 30, 0); - if (menuBarFlag & menuBar_Items) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_ITEM][1], 0, 0); + if (menuBarFlag & kMenubarItems) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuItem][1], 0, 0); - if (menuBarFlag & menuBar_Magic) - _engine->getRenderManager()->blitSurfaceToMenu(menuback[menu_MAGIC][1], 640 - 28, 0); + if (menuBarFlag & kMenubarMagic) + _engine->getRenderManager()->blitSurfaceToMenu(menuback[kMenuMagic][1], 640 - 28, 0); } redraw = false; } @@ -584,7 +583,7 @@ static const int16 buts[4][2] = { {120 , 64}, {144, 184}, {128, 328}, {120, 456} void MenuNemesis::onMouseUp(const Common::Point &Pos) { if (Pos.y < 40) { // Exit - if (menuBarFlag & menuBar_Exit) + if (menuBarFlag & kMenubarExit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], @@ -595,7 +594,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) { } // Settings - if (menuBarFlag & menuBar_Settings) + if (menuBarFlag & kMenubarSettings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], @@ -606,7 +605,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) { } // Load - if (menuBarFlag & menuBar_Restore) + if (menuBarFlag & kMenubarRestore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], @@ -617,7 +616,7 @@ void MenuNemesis::onMouseUp(const Common::Point &Pos) { } // Save - if (menuBarFlag & menuBar_Save) + if (menuBarFlag & kMenubarSave) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], @@ -641,39 +640,39 @@ void MenuNemesis::onMouseMove(const Common::Point &Pos) { mouseOnItem = -1; // Exit - if (menuBarFlag & menuBar_Exit) + if (menuBarFlag & kMenubarExit) if (Common::Rect(buts[3][1], scrollPos, buts[3][0] + buts[3][1], scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_EXIT; + mouseOnItem = kMainMenuExit; } // Settings - if (menuBarFlag & menuBar_Settings) + if (menuBarFlag & kMenubarSettings) if (Common::Rect(buts[2][1], scrollPos, buts[2][0] + buts[2][1], scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_PREF; + mouseOnItem = kMainMenuPrefs; } // Load - if (menuBarFlag & menuBar_Restore) + if (menuBarFlag & kMenubarRestore) if (Common::Rect(buts[1][1], scrollPos, buts[1][0] + buts[1][1], scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_REST; + mouseOnItem = kMainMenuLoad; } // Save - if (menuBarFlag & menuBar_Save) + if (menuBarFlag & kMenubarSave) if (Common::Rect(buts[0][1], scrollPos, buts[0][0] + buts[0][1], scrollPos + 32).contains(Pos)) { - mouseOnItem = menu_MAIN_SAVE; + mouseOnItem = kMainMenuSave; } if (lastItem != mouseOnItem) { @@ -718,20 +717,20 @@ void MenuNemesis::process(uint32 deltatime) { if (redraw) { _engine->getRenderManager()->blitSurfaceToMenu(menubar, 64, scrollPos); - if (menuBarFlag & menuBar_Exit) - if (mouseOnItem == menu_MAIN_EXIT) + if (menuBarFlag & kMenubarExit) + if (mouseOnItem == kMainMenuExit) _engine->getRenderManager()->blitSurfaceToMenu(but[3][frm], buts[3][1], scrollPos); - if (menuBarFlag & menuBar_Settings) - if (mouseOnItem == menu_MAIN_PREF) + if (menuBarFlag & kMenubarSettings) + if (mouseOnItem == kMainMenuPrefs) _engine->getRenderManager()->blitSurfaceToMenu(but[2][frm], buts[2][1], scrollPos); - if (menuBarFlag & menuBar_Restore) - if (mouseOnItem == menu_MAIN_REST) + if (menuBarFlag & kMenubarRestore) + if (mouseOnItem == kMainMenuLoad) _engine->getRenderManager()->blitSurfaceToMenu(but[1][frm], buts[1][1], scrollPos); - if (menuBarFlag & menuBar_Save) - if (mouseOnItem == menu_MAIN_SAVE) + if (menuBarFlag & kMenubarSave) + if (mouseOnItem == kMainMenuSave) _engine->getRenderManager()->blitSurfaceToMenu(but[0][frm], buts[0][1], scrollPos); redraw = false; diff --git a/engines/zvision/scripting/menu.h b/engines/zvision/scripting/menu.h index ebe0bb50ac..a88587966f 100644 --- a/engines/zvision/scripting/menu.h +++ b/engines/zvision/scripting/menu.h @@ -32,12 +32,12 @@ namespace ZVision { enum menuBar { - menuBar_Exit = 0x1, - menuBar_Settings = 0x2, - menuBar_Restore = 0x4, - menuBar_Save = 0x8, - menuBar_Items = 0x100, - menuBar_Magic = 0x200 + kMenubarExit = 0x1, + kMenubarSettings = 0x2, + kMenubarRestore = 0x4, + kMenubarSave = 0x8, + kMenubarItems = 0x100, + kMenubarMagic = 0x200 }; class MenuHandler { @@ -84,12 +84,6 @@ private: bool scrolled[3]; int16 scrollPos[3]; - enum { - menu_ITEM = 0, - menu_MAGIC = 1, - menu_MAIN = 2 - }; - bool clean; bool redraw; diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index c5ade08e14..9f0f2f6e10 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -94,7 +94,12 @@ enum StateKey { StateKey_Inv_Cnt_Slot = 100, StateKey_Inv_1_Slot = 101, StateKey_Inv_49_Slot = 149, - StateKey_Inv_TotalSlots = 150 + // ZGI only + StateKey_Inv_TotalSlots = 150, + StateKey_Inv_StartSlot = 151, + StateKey_Spell_1 = 191, + StateKey_Active_Spell = 205, + StateKey_Reversed_Spellbooc = 206 }; struct Location { -- cgit v1.2.3 From 00a252fdc561b31379ddc5f568121b8040986add Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 03:58:37 +0200 Subject: ZVISION: Slight cleanup --- engines/zvision/core/save_manager.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp index 20bd39fde5..b45742154d 100644 --- a/engines/zvision/core/save_manager.cpp +++ b/engines/zvision/core/save_manager.cpp @@ -78,9 +78,6 @@ bool SaveManager::scummVMSaveLoadDialog(bool isSave) { } void SaveManager::saveGame(uint slot, const Common::String &saveName) { - // The games only support 20 slots - //assert(slot <= 1 && slot <= 20); - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); @@ -124,7 +121,6 @@ void SaveManager::autoSave() { } void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { - file->writeUint32BE(SAVEGAME_ID); // Write version @@ -148,9 +144,6 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S } Common::Error SaveManager::loadGame(uint slot) { - // The games only support 20 slots - //assert(slot <= 1 && slot <= 20); - Common::SeekableReadStream *saveFile = getSlotFile(slot); if (saveFile == 0) { return Common::kPathDoesNotExist; @@ -226,7 +219,13 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea // Check that the save version isn't newer than this binary if (header.version > SAVE_VERSION) { uint tempVersion = header.version; - GUI::MessageDialog dialog(Common::String::format("This save file uses version %u, but this engine only supports up to version %d. You will need an updated version of the engine to use this save file.", tempVersion, SAVE_VERSION), "OK"); + GUI::MessageDialog dialog( + Common::String::format( + "This save file uses version %u, but this engine only " + "supports up to version %d. You will need an updated version " + "of the engine to use this save file.", tempVersion, SAVE_VERSION + ), + "OK"); dialog.runModal(); } -- cgit v1.2.3 From 4d0ebfaa2285e2741a134db36fb4f5bd0317784d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 04:03:20 +0200 Subject: ZVISION: Move the save manager together with the other file classes --- engines/zvision/core/save_manager.cpp | 294 --------------------- engines/zvision/core/save_manager.h | 106 -------- engines/zvision/detection.cpp | 2 +- engines/zvision/file/save_manager.cpp | 294 +++++++++++++++++++++ engines/zvision/file/save_manager.h | 106 ++++++++ engines/zvision/module.mk | 2 +- engines/zvision/scripting/actions.cpp | 2 +- .../zvision/scripting/controls/save_control.cpp | 2 +- engines/zvision/scripting/script_manager.cpp | 2 +- engines/zvision/zvision.cpp | 2 +- 10 files changed, 406 insertions(+), 406 deletions(-) delete mode 100644 engines/zvision/core/save_manager.cpp delete mode 100644 engines/zvision/core/save_manager.h create mode 100644 engines/zvision/file/save_manager.cpp create mode 100644 engines/zvision/file/save_manager.h diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp deleted file mode 100644 index b45742154d..0000000000 --- a/engines/zvision/core/save_manager.cpp +++ /dev/null @@ -1,294 +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 "common/scummsys.h" - -#include "zvision/core/save_manager.h" -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" - -#include "common/system.h" -#include "common/translation.h" - -#include "graphics/surface.h" -#include "graphics/thumbnail.h" - -#include "gui/message.h" -#include "gui/saveload.h" - -namespace ZVision { - -const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); - -bool SaveManager::scummVMSaveLoadDialog(bool isSave) { - GUI::SaveLoadChooser *dialog; - Common::String desc; - int slot; - - if (isSave) { - dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - - slot = dialog->runModalWithCurrentTarget(); - desc = dialog->getResultString(); - - if (desc.empty()) { - // create our own description for the saved game, the user didnt enter it - desc = dialog->createDefaultSaveDescription(slot); - } - - if (desc.size() > 28) - desc = Common::String(desc.c_str(), 28); - } else { - dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - slot = dialog->runModalWithCurrentTarget(); - } - - delete dialog; - - if (slot < 0) - return false; - - if (isSave) { - saveGame(slot, desc); - return true; - } else { - Common::ErrorCode result = loadGame(slot).getCode(); - return (result == Common::kNoError); - } -} - -void SaveManager::saveGame(uint slot, const Common::String &saveName) { - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); - Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - - writeSaveGameHeader(file, saveName); - - _engine->getScriptManager()->serialize(file); - - file->finalize(); - delete file; -} - -void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { - Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); - Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); - - writeSaveGameHeader(file, saveName); - - file->write(stream->getData(), stream->size()); - - file->finalize(); - delete file; -} - -void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { - if (_tempSave) { - saveGame(slot, saveName, _tempSave); - flushSaveBuffer(); - } -} - -void SaveManager::autoSave() { - Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); - - writeSaveGameHeader(file, "auto"); - - _engine->getScriptManager()->serialize(file); - - // Cleanup - file->finalize(); - delete file; -} - -void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { - file->writeUint32BE(SAVEGAME_ID); - - // Write version - file->writeByte(SAVE_VERSION); - - // Write savegame name - file->writeString(saveName); - file->writeByte(0); - - // Create a thumbnail and save it - Graphics::saveThumbnail(*file); - - // Write out the save date/time - TimeDate td; - g_system->getTimeAndDate(td); - file->writeSint16LE(td.tm_year + 1900); - file->writeSint16LE(td.tm_mon + 1); - file->writeSint16LE(td.tm_mday); - file->writeSint16LE(td.tm_hour); - file->writeSint16LE(td.tm_min); -} - -Common::Error SaveManager::loadGame(uint slot) { - Common::SeekableReadStream *saveFile = getSlotFile(slot); - if (saveFile == 0) { - return Common::kPathDoesNotExist; - } - - // Read the header - SaveGameHeader header; - if (!readSaveGameHeader(saveFile, header)) { - return Common::kUnknownError; - } - - ScriptManager *scriptManager = _engine->getScriptManager(); - // Update the state table values - scriptManager->deserialize(saveFile); - - delete saveFile; - if (header.thumbnail) - delete header.thumbnail; - - return Common::kNoError; -} - -Common::Error SaveManager::loadGame(const Common::String &saveName) { - Common::File *saveFile = _engine->getSearchManager()->openFile(saveName); - if (saveFile == NULL) { - saveFile = new Common::File; - if (!saveFile->open(saveName)) { - delete saveFile; - return Common::kPathDoesNotExist; - } - } - - // Read the header - SaveGameHeader header; - if (!readSaveGameHeader(saveFile, header)) { - return Common::kUnknownError; - } - - ScriptManager *scriptManager = _engine->getScriptManager(); - // Update the state table values - scriptManager->deserialize(saveFile); - - delete saveFile; - if (header.thumbnail) - delete header.thumbnail; - - return Common::kNoError; -} - -bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { - uint32 tag = in->readUint32BE(); - // Check if it's original savegame than fill header structure - if (tag == MKTAG('Z', 'N', 'S', 'G')) { - header.saveYear = 0; - header.saveMonth = 0; - header.saveDay = 0; - header.saveHour = 0; - header.saveMinutes = 0; - header.saveName = "Original Save"; - header.thumbnail = NULL; - header.version = SAVE_ORIGINAL; - in->seek(-4, SEEK_CUR); - return true; - } - if (tag != SAVEGAME_ID) { - warning("File is not a ZVision save file. Aborting load"); - return false; - } - - // Read in the version - header.version = in->readByte(); - - // Check that the save version isn't newer than this binary - if (header.version > SAVE_VERSION) { - uint tempVersion = header.version; - GUI::MessageDialog dialog( - Common::String::format( - "This save file uses version %u, but this engine only " - "supports up to version %d. You will need an updated version " - "of the engine to use this save file.", tempVersion, SAVE_VERSION - ), - "OK"); - dialog.runModal(); - } - - // Read in the save name - header.saveName.clear(); - char ch; - while ((ch = (char)in->readByte()) != '\0') - header.saveName += ch; - - // Get the thumbnail - header.thumbnail = Graphics::loadThumbnail(*in); - if (!header.thumbnail) - return false; - - // Read in save date/time - header.saveYear = in->readSint16LE(); - header.saveMonth = in->readSint16LE(); - header.saveDay = in->readSint16LE(); - header.saveHour = in->readSint16LE(); - header.saveMinutes = in->readSint16LE(); - - return true; -} - -Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { - Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); - if (saveFile == NULL) { - // Try to load standard save file - Common::String filename; - if (_engine->getGameId() == GID_GRANDINQUISITOR) - filename = Common::String::format("inqsav%u.sav", slot); - else if (_engine->getGameId() == GID_NEMESIS) - filename = Common::String::format("nemsav%u.sav", slot); - - saveFile = _engine->getSearchManager()->openFile(filename); - if (saveFile == NULL) { - Common::File *tmpFile = new Common::File; - if (!tmpFile->open(filename)) { - delete tmpFile; - } else { - saveFile = tmpFile; - } - } - - } - - return saveFile; -} - -void SaveManager::prepareSaveBuffer() { - if (_tempSave) - delete _tempSave; - - _tempSave = new Common::MemoryWriteStreamDynamic; - - _engine->getScriptManager()->serialize(_tempSave); -} - -void SaveManager::flushSaveBuffer() { - if (_tempSave) - delete _tempSave; - - _tempSave = NULL; -} - -} // End of namespace ZVision diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h deleted file mode 100644 index 75841331e7..0000000000 --- a/engines/zvision/core/save_manager.h +++ /dev/null @@ -1,106 +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 ZVISION_SAVE_MANAGER_H -#define ZVISION_SAVE_MANAGER_H - -#include "common/savefile.h" -#include "common/memstream.h" - -namespace Common { -class String; -} - -namespace Graphics { -struct Surface; -} - -namespace ZVision { - -class ZVision; - -struct SaveGameHeader { - byte version; - Common::String saveName; - Graphics::Surface *thumbnail; - int saveYear, saveMonth, saveDay; - int saveHour, saveMinutes; -}; - -class SaveManager { -public: - SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} - ~SaveManager() { - flushSaveBuffer(); - } - -private: - ZVision *_engine; - static const uint32 SAVEGAME_ID; - - enum { - SAVE_ORIGINAL = 0, - SAVE_VERSION = 1 - }; - - Common::MemoryWriteStreamDynamic *_tempSave; - -public: - /** - * Called every room change. Saves the state of the room just before - * we switched rooms. Uses ZVision::generateAutoSaveFileName() to - * create the save file name. - */ - void autoSave(); - /** - * Copies the data from the last auto-save into a new save file. We - * can't use the current state data because the save menu *IS* a room. - * The file is named using ZVision::generateSaveFileName(slot) - * - * @param slot The save slot this save pertains to. Must be [1, 20] - * @param saveName The internal name for this save. This is NOT the name of the actual save file. - */ - void saveGame(uint slot, const Common::String &saveName); - void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); - void saveGameBuffered(uint slot, const Common::String &saveName); - /** - * Loads the state data from the save file that slot references. Uses - * ZVision::generateSaveFileName(slot) to get the save file name. - * - * @param slot The save slot to load. Must be [1, 20] - */ - Common::Error loadGame(uint slot); - Common::Error loadGame(const Common::String &saveName); - - Common::SeekableReadStream *getSlotFile(uint slot); - bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); - - void prepareSaveBuffer(); - void flushSaveBuffer(); - bool scummVMSaveLoadDialog(bool isSave); -private: - void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index ebf5bdcfdd..b8d6a74eee 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -26,7 +26,7 @@ #include "zvision/zvision.h" #include "zvision/detection.h" -#include "zvision/core/save_manager.h" +#include "zvision/file/save_manager.h" #include "zvision/scripting/script_manager.h" #include "common/translation.h" diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp new file mode 100644 index 0000000000..05df834497 --- /dev/null +++ b/engines/zvision/file/save_manager.cpp @@ -0,0 +1,294 @@ +/* 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 "common/scummsys.h" + +#include "zvision/zvision.h" +#include "zvision/file/save_manager.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" + +#include "common/system.h" +#include "common/translation.h" + +#include "graphics/surface.h" +#include "graphics/thumbnail.h" + +#include "gui/message.h" +#include "gui/saveload.h" + +namespace ZVision { + +const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G'); + +bool SaveManager::scummVMSaveLoadDialog(bool isSave) { + GUI::SaveLoadChooser *dialog; + Common::String desc; + int slot; + + if (isSave) { + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); + + slot = dialog->runModalWithCurrentTarget(); + desc = dialog->getResultString(); + + if (desc.empty()) { + // create our own description for the saved game, the user didnt enter it + desc = dialog->createDefaultSaveDescription(slot); + } + + if (desc.size() > 28) + desc = Common::String(desc.c_str(), 28); + } else { + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); + slot = dialog->runModalWithCurrentTarget(); + } + + delete dialog; + + if (slot < 0) + return false; + + if (isSave) { + saveGame(slot, desc); + return true; + } else { + Common::ErrorCode result = loadGame(slot).getCode(); + return (result == Common::kNoError); + } +} + +void SaveManager::saveGame(uint slot, const Common::String &saveName) { + Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); + Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); + + writeSaveGameHeader(file, saveName); + + _engine->getScriptManager()->serialize(file); + + file->finalize(); + delete file; +} + +void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { + Common::SaveFileManager *saveFileManager = g_system->getSavefileManager(); + Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot)); + + writeSaveGameHeader(file, saveName); + + file->write(stream->getData(), stream->size()); + + file->finalize(); + delete file; +} + +void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { + if (_tempSave) { + saveGame(slot, saveName, _tempSave); + flushSaveBuffer(); + } +} + +void SaveManager::autoSave() { + Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); + + writeSaveGameHeader(file, "auto"); + + _engine->getScriptManager()->serialize(file); + + // Cleanup + file->finalize(); + delete file; +} + +void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { + file->writeUint32BE(SAVEGAME_ID); + + // Write version + file->writeByte(SAVE_VERSION); + + // Write savegame name + file->writeString(saveName); + file->writeByte(0); + + // Create a thumbnail and save it + Graphics::saveThumbnail(*file); + + // Write out the save date/time + TimeDate td; + g_system->getTimeAndDate(td); + file->writeSint16LE(td.tm_year + 1900); + file->writeSint16LE(td.tm_mon + 1); + file->writeSint16LE(td.tm_mday); + file->writeSint16LE(td.tm_hour); + file->writeSint16LE(td.tm_min); +} + +Common::Error SaveManager::loadGame(uint slot) { + Common::SeekableReadStream *saveFile = getSlotFile(slot); + if (saveFile == 0) { + return Common::kPathDoesNotExist; + } + + // Read the header + SaveGameHeader header; + if (!readSaveGameHeader(saveFile, header)) { + return Common::kUnknownError; + } + + ScriptManager *scriptManager = _engine->getScriptManager(); + // Update the state table values + scriptManager->deserialize(saveFile); + + delete saveFile; + if (header.thumbnail) + delete header.thumbnail; + + return Common::kNoError; +} + +Common::Error SaveManager::loadGame(const Common::String &saveName) { + Common::File *saveFile = _engine->getSearchManager()->openFile(saveName); + if (saveFile == NULL) { + saveFile = new Common::File; + if (!saveFile->open(saveName)) { + delete saveFile; + return Common::kPathDoesNotExist; + } + } + + // Read the header + SaveGameHeader header; + if (!readSaveGameHeader(saveFile, header)) { + return Common::kUnknownError; + } + + ScriptManager *scriptManager = _engine->getScriptManager(); + // Update the state table values + scriptManager->deserialize(saveFile); + + delete saveFile; + if (header.thumbnail) + delete header.thumbnail; + + return Common::kNoError; +} + +bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) { + uint32 tag = in->readUint32BE(); + // Check if it's original savegame than fill header structure + if (tag == MKTAG('Z', 'N', 'S', 'G')) { + header.saveYear = 0; + header.saveMonth = 0; + header.saveDay = 0; + header.saveHour = 0; + header.saveMinutes = 0; + header.saveName = "Original Save"; + header.thumbnail = NULL; + header.version = SAVE_ORIGINAL; + in->seek(-4, SEEK_CUR); + return true; + } + if (tag != SAVEGAME_ID) { + warning("File is not a ZVision save file. Aborting load"); + return false; + } + + // Read in the version + header.version = in->readByte(); + + // Check that the save version isn't newer than this binary + if (header.version > SAVE_VERSION) { + uint tempVersion = header.version; + GUI::MessageDialog dialog( + Common::String::format( + "This save file uses version %u, but this engine only " + "supports up to version %d. You will need an updated version " + "of the engine to use this save file.", tempVersion, SAVE_VERSION + ), + "OK"); + dialog.runModal(); + } + + // Read in the save name + header.saveName.clear(); + char ch; + while ((ch = (char)in->readByte()) != '\0') + header.saveName += ch; + + // Get the thumbnail + header.thumbnail = Graphics::loadThumbnail(*in); + if (!header.thumbnail) + return false; + + // Read in save date/time + header.saveYear = in->readSint16LE(); + header.saveMonth = in->readSint16LE(); + header.saveDay = in->readSint16LE(); + header.saveHour = in->readSint16LE(); + header.saveMinutes = in->readSint16LE(); + + return true; +} + +Common::SeekableReadStream *SaveManager::getSlotFile(uint slot) { + Common::SeekableReadStream *saveFile = g_system->getSavefileManager()->openForLoading(_engine->generateSaveFileName(slot)); + if (saveFile == NULL) { + // Try to load standard save file + Common::String filename; + if (_engine->getGameId() == GID_GRANDINQUISITOR) + filename = Common::String::format("inqsav%u.sav", slot); + else if (_engine->getGameId() == GID_NEMESIS) + filename = Common::String::format("nemsav%u.sav", slot); + + saveFile = _engine->getSearchManager()->openFile(filename); + if (saveFile == NULL) { + Common::File *tmpFile = new Common::File; + if (!tmpFile->open(filename)) { + delete tmpFile; + } else { + saveFile = tmpFile; + } + } + + } + + return saveFile; +} + +void SaveManager::prepareSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = new Common::MemoryWriteStreamDynamic; + + _engine->getScriptManager()->serialize(_tempSave); +} + +void SaveManager::flushSaveBuffer() { + if (_tempSave) + delete _tempSave; + + _tempSave = NULL; +} + +} // End of namespace ZVision diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h new file mode 100644 index 0000000000..75841331e7 --- /dev/null +++ b/engines/zvision/file/save_manager.h @@ -0,0 +1,106 @@ +/* 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 ZVISION_SAVE_MANAGER_H +#define ZVISION_SAVE_MANAGER_H + +#include "common/savefile.h" +#include "common/memstream.h" + +namespace Common { +class String; +} + +namespace Graphics { +struct Surface; +} + +namespace ZVision { + +class ZVision; + +struct SaveGameHeader { + byte version; + Common::String saveName; + Graphics::Surface *thumbnail; + int saveYear, saveMonth, saveDay; + int saveHour, saveMinutes; +}; + +class SaveManager { +public: + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + ~SaveManager() { + flushSaveBuffer(); + } + +private: + ZVision *_engine; + static const uint32 SAVEGAME_ID; + + enum { + SAVE_ORIGINAL = 0, + SAVE_VERSION = 1 + }; + + Common::MemoryWriteStreamDynamic *_tempSave; + +public: + /** + * Called every room change. Saves the state of the room just before + * we switched rooms. Uses ZVision::generateAutoSaveFileName() to + * create the save file name. + */ + void autoSave(); + /** + * Copies the data from the last auto-save into a new save file. We + * can't use the current state data because the save menu *IS* a room. + * The file is named using ZVision::generateSaveFileName(slot) + * + * @param slot The save slot this save pertains to. Must be [1, 20] + * @param saveName The internal name for this save. This is NOT the name of the actual save file. + */ + void saveGame(uint slot, const Common::String &saveName); + void saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream); + void saveGameBuffered(uint slot, const Common::String &saveName); + /** + * Loads the state data from the save file that slot references. Uses + * ZVision::generateSaveFileName(slot) to get the save file name. + * + * @param slot The save slot to load. Must be [1, 20] + */ + Common::Error loadGame(uint slot); + Common::Error loadGame(const Common::String &saveName); + + Common::SeekableReadStream *getSlotFile(uint slot); + bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); + + void prepareSaveBuffer(); + void flushSaveBuffer(); + bool scummVMSaveLoadDialog(bool isSave); +private: + void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 6955d62534..8edd67b352 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -4,9 +4,9 @@ MODULE_OBJS := \ core/console.o \ core/clock.o \ core/events.o \ - core/save_manager.o \ detection.o \ file/lzss_read_stream.o \ + file/save_manager.o \ file/search_manager.o \ file/zfs_archive.o \ graphics/cursors/cursor_manager.o \ diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index be2079736e..ebbd09c8b9 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -29,6 +29,7 @@ #include "zvision/graphics/render_manager.h" #include "zvision/sound/zork_raw.h" #include "zvision/video/zork_avi_decoder.h" +#include "zvision/file/save_manager.h" #include "zvision/scripting/sidefx/timer_node.h" #include "zvision/scripting/sidefx/music_node.h" #include "zvision/scripting/sidefx/syncsound_node.h" @@ -42,7 +43,6 @@ #include "zvision/graphics/effects/fog.h" #include "zvision/graphics/effects/light.h" #include "zvision/graphics/effects/wave.h" -#include "zvision/core/save_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" #include "common/file.h" diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index b35611feca..3a4dc47fe8 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -29,7 +29,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/text/string_manager.h" -#include "zvision/core/save_manager.h" +#include "zvision/file/save_manager.h" #include "common/str.h" #include "common/stream.h" diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 4c1e69072d..2a4aa5fed0 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -27,7 +27,7 @@ #include "zvision/zvision.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/save_manager.h" +#include "zvision/file/save_manager.h" #include "zvision/scripting/actions.h" #include "zvision/scripting/sidefx/timer_node.h" diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index f692969942..11e417d4ac 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -27,7 +27,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/graphics/render_manager.h" #include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/core/save_manager.h" +#include "zvision/file/save_manager.h" #include "zvision/text/string_manager.h" #include "zvision/detection.h" #include "zvision/scripting/menu.h" -- cgit v1.2.3 From e4b2913e4ac5584803e65008c44addea05c3892a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 04:05:48 +0200 Subject: ZVISION: Reorder the detection entries --- engines/zvision/detection.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index b8d6a74eee..a361239e9e 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -100,28 +100,28 @@ static const ZVisionGameDescription gameDescriptions[] = { }, { - // Zork Grand Inquisitor English demo version + // Zork Grand Inquisitor English DVD version { "zgi", - "Demo", - AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239), + "DVD", + AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326), Common::EN_ANY, Common::kPlatformWindows, - ADGF_DEMO, + ADGF_NO_FLAGS, GUIO1(GUIO_NONE) }, GID_GRANDINQUISITOR }, { - // Zork Grand Inquisitor English DVD version + // Zork Grand Inquisitor English demo version { "zgi", - "DVD", - AD_ENTRY1s("SCRIPTS.ZFS", "03157a3399513bfaaf8dc6d5ab798b36", 8433326), + "Demo", + AD_ENTRY1s("SCRIPTS.ZFS", "71a2494fd2fb999347deb13401e9b998", 304239), Common::EN_ANY, Common::kPlatformWindows, - ADGF_NO_FLAGS, + ADGF_DEMO, GUIO1(GUIO_NONE) }, GID_GRANDINQUISITOR -- cgit v1.2.3 From 2350eca546396775c6e9ac9875ebd59bcc17663f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 12:04:21 +0200 Subject: ZVISION: Remove some unused actions. Cleanup --- engines/zvision/scripting/actions.cpp | 53 +++++-------------------- engines/zvision/scripting/actions.h | 26 ------------ engines/zvision/scripting/scr_file_handling.cpp | 6 ++- 3 files changed, 13 insertions(+), 72 deletions(-) diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index ebbd09c8b9..c26a93f529 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -242,23 +242,6 @@ bool ActionDisableControl::execute() { return true; } -////////////////////////////////////////////////////////////////////////////// -// ActionDisableVenus -////////////////////////////////////////////////////////////////////////////// - -ActionDisableVenus::ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { - _key = 0; - - sscanf(line.c_str(), "%d", &_key); -} - -bool ActionDisableVenus::execute() { - _engine->getScriptManager()->setStateValue(_key, 0); - - return true; -} - ////////////////////////////////////////////////////////////////////////////// // ActionDisplayMessage ////////////////////////////////////////////////////////////////////////////// @@ -295,7 +278,7 @@ bool ActionDissolve::execute() { } ////////////////////////////////////////////////////////////////////////////// -// ActionDistort +// ActionDistort - only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30) ////////////////////////////////////////////////////////////////////////////// ActionDistort::ActionDistort(ZVision *engine, int32 slotkey, const Common::String &line) : @@ -406,7 +389,7 @@ bool ActionInventory::execute() { } ////////////////////////////////////////////////////////////////////////////// -// ActionKill +// ActionKill - only used by ZGI ////////////////////////////////////////////////////////////////////////////// ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &line) : @@ -735,13 +718,13 @@ bool ActionRegion::execute() { if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; - Effect *effct = NULL; + Effect *effect = NULL; switch (_type) { case 0: { uint16 centerX, centerY, frames; double amplitude, waveln, speed; sscanf(_custom.c_str(), "%hu,%hu,%hu,%lf,%lf,%lf,", ¢erX, ¢erY, &frames, &litude, &waveln, &speed); - effct = new WaveFx(_engine, _slotKey, _rect, _unk1, frames, centerX, centerY, amplitude, waveln, speed); + effect = new WaveFx(_engine, _slotKey, _rect, _unk1, frames, centerX, centerY, amplitude, waveln, speed); } break; case 1: { @@ -753,7 +736,7 @@ bool ActionRegion::execute() { int8 minD; int8 maxD; EffectMap *_map = _engine->getRenderManager()->makeEffectMap(Common::Point(aX, aY), aD, _rect, &minD, &maxD); - effct = new LightFx(_engine, _slotKey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD); + effect = new LightFx(_engine, _slotKey, _rect, _unk1, _map, atoi(_custom.c_str()), minD, maxD); } break; case 9: { @@ -769,16 +752,16 @@ bool ActionRegion::execute() { _rect.setHeight(tempMask.h); EffectMap *_map = _engine->getRenderManager()->makeEffectMap(tempMask, 0); - effct = new FogFx(_engine, _slotKey, _rect, _unk1, _map, Common::String(buf)); + effect = new FogFx(_engine, _slotKey, _rect, _unk1, _map, Common::String(buf)); } break; default: break; } - if (effct) { - _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effct, _delay)); - _engine->getRenderManager()->addEffect(effct); + if (effect) { + _engine->getScriptManager()->addSideFX(new RegionNode(_engine, _slotKey, effect, _delay)); + _engine->getRenderManager()->addEffect(effect); } return true; @@ -899,24 +882,6 @@ bool ActionSetScreen::execute() { return true; } -////////////////////////////////////////////////////////////////////////////// -// ActionSetVenus -////////////////////////////////////////////////////////////////////////////// - -ActionSetVenus::ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line) : - ResultAction(engine, slotkey) { - _key = 0; - - sscanf(line.c_str(), "%d", &_key); -} - -bool ActionSetVenus::execute() { - if (_engine->getScriptManager()->getStateValue(_key)) - _engine->getScriptManager()->setStateValue(StateKey_Venus, _key); - - return true; -} - ////////////////////////////////////////////////////////////////////////////// // ActionStop ////////////////////////////////////////////////////////////////////////////// diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h index 3501372c7f..8d43309b74 100644 --- a/engines/zvision/scripting/actions.h +++ b/engines/zvision/scripting/actions.h @@ -124,14 +124,6 @@ private: uint8 _action; }; -class ActionDebug : public ResultAction { -public: - ActionDebug(ZVision *engine, int32 slotkey, const Common::String &line); - bool execute(); - -private: -}; - class ActionDelayRender : public ResultAction { public: ActionDelayRender(ZVision *engine, int32 slotkey, const Common::String &line); @@ -150,15 +142,6 @@ private: uint32 _key; }; -class ActionDisableVenus : public ResultAction { -public: - ActionDisableVenus(ZVision *engine, int32 slotkey, const Common::String &line); - bool execute(); - -private: - int32 _key; -}; - class ActionDisplayMessage : public ResultAction { public: ActionDisplayMessage(ZVision *engine, int32 slotkey, const Common::String &line); @@ -397,15 +380,6 @@ private: Common::String _fileName; }; -class ActionSetVenus : public ResultAction { -public: - ActionSetVenus(ZVision *engine, int32 slotkey, const Common::String &line); - bool execute(); - -private: - int32 _key; -}; - class ActionStop : public ResultAction { public: ActionStop(ZVision *engine, int32 slotkey, const Common::String &line); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 83be3b5ad4..fd5c158fcc 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -235,12 +235,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("disable_control", true)) { actionList.push_back(new ActionDisableControl(_engine, slot, args)); } else if (act.matchString("disable_venus", true)) { - actionList.push_back(new ActionDisableVenus(_engine, slot, args)); + // Not used. Purposely left empty } else if (act.matchString("display_message", true)) { actionList.push_back(new ActionDisplayMessage(_engine, slot, args)); } else if (act.matchString("dissolve", true)) { actionList.push_back(new ActionDissolve(_engine)); } else if (act.matchString("distort", true)) { + // Only used by Zork: Nemesis for the "treatment" puzzle in the Sanitarium (aj30) actionList.push_back(new ActionDistort(_engine, slot, args)); } else if (act.matchString("enable_control", true)) { actionList.push_back(new ActionEnableControl(_engine, slot, args)); @@ -249,6 +250,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("inventory", true)) { actionList.push_back(new ActionInventory(_engine, slot, args)); } else if (act.matchString("kill", true)) { + // Only used by ZGI actionList.push_back(new ActionKill(_engine, slot, args)); } else if (act.matchString("menu_bar_enable", true)) { actionList.push_back(new ActionMenuBarEnable(_engine, slot, args)); @@ -278,7 +280,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis } else if (act.matchString("set_screen", true)) { actionList.push_back(new ActionSetScreen(_engine, slot, args)); } else if (act.matchString("set_venus", true)) { - actionList.push_back(new ActionSetVenus(_engine, slot, args)); + // Not used. Purposely left empty } else if (act.matchString("stop", true)) { actionList.push_back(new ActionStop(_engine, slot, args)); } else if (act.matchString("streamvideo", true)) { -- cgit v1.2.3 From 4258750f5025e471ba682945e3091fdaa50c7bc9 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 12:07:21 +0200 Subject: ZVISION: Rename _halveDelay to _doubleFPS, to match its config setting --- engines/zvision/zvision.cpp | 12 ++++++------ engines/zvision/zvision.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 11e417d4ac..e9a4486ded 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -96,7 +96,7 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _menu(nullptr), _searchManager(nullptr), _textRenderer(nullptr), - _halveDelay(false), + _doubleFPS(false), _audioId(0), _frameRenderDelay(2), _keyboardVelocity(0), @@ -213,7 +213,7 @@ void ZVision::initialize() { // Create debugger console. It requires GFX to be initialized _console = new Console(this); - _halveDelay = ConfMan.getBool("doublefps"); + _doubleFPS = ConfMan.getBool("doublefps"); } Common::Error ZVision::run() { @@ -255,7 +255,7 @@ Common::Error ZVision::run() { // Ensure non-negative delay = delay < 0 ? 0 : delay; - if (_halveDelay) { + if (_doubleFPS) { delay >>= 1; } @@ -291,7 +291,7 @@ bool ZVision::askQuestion(const Common::String &str) { } } _system->updateScreen(); - if (_halveDelay) + if (_doubleFPS) _system->delayMillis(33); else _system->delayMillis(66); @@ -319,7 +319,7 @@ void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { break; } _system->updateScreen(); - if (_halveDelay) + if (_doubleFPS) _system->delayMillis(33); else _system->delayMillis(66); @@ -365,7 +365,7 @@ bool ZVision::canRender() { void ZVision::updateRotation() { int16 _velocity = _mouseVelocity + _keyboardVelocity; - if (_halveDelay) + if (_doubleFPS) _velocity /= 2; if (_velocity) { diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index e9b8ca4547..d3beae5e61 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -121,7 +121,7 @@ private: int _frameRenderDelay; int16 _mouseVelocity; int16 _keyboardVelocity; - bool _halveDelay; + bool _doubleFPS; bool _videoIsPlaying; uint8 _cheatBuffer[KEYBUF_SIZE]; -- cgit v1.2.3 From 5a72eea2bb102bafb6da112ea90ad1f4af11e1f2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 12:41:36 +0200 Subject: ZVISION: Move some event/rendering code out of the main engine code --- engines/zvision/core/events.cpp | 37 ++++++- engines/zvision/graphics/render_manager.cpp | 82 +++++++++++++++- engines/zvision/graphics/render_manager.h | 8 +- .../zvision/scripting/controls/save_control.cpp | 7 +- engines/zvision/zvision.cpp | 108 +-------------------- engines/zvision/zvision.h | 13 ++- 6 files changed, 133 insertions(+), 122 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 227cf213dc..70fd425949 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -39,6 +39,33 @@ namespace ZVision { +void ZVision::pushKeyToCheatBuf(uint8 key) { + for (int i = 0; i < KEYBUF_SIZE - 1; i++) + _cheatBuffer[i] = _cheatBuffer[i + 1]; + + _cheatBuffer[KEYBUF_SIZE - 1] = key; +} + +bool ZVision::checkCode(const char *code) { + int codeLen = strlen(code); + + if (codeLen > KEYBUF_SIZE) + return false; + + for (int i = 0; i < codeLen; i++) + if (code[i] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?') + return false; + + return true; +} + +uint8 ZVision::getBufferedKey(uint8 pos) { + if (pos >= KEYBUF_SIZE) + return 0; + else + return _cheatBuffer[KEYBUF_SIZE - pos - 1]; +} + void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { @@ -70,11 +97,11 @@ void ZVision::cheatCodes(uint8 key) { if (getGameId() == GID_GRANDINQUISITOR) { if (checkCode("IMNOTDEAF")) { // Unknown cheat - showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); + _renderManager->showDebugMsg(Common::String::format("IMNOTDEAF cheat or debug, not implemented")); } if (checkCode("3100OPB")) { - showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c", _scriptManager->getStateValue(StateKey_World), _scriptManager->getStateValue(StateKey_Room), _scriptManager->getStateValue(StateKey_Node), @@ -101,7 +128,7 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("77MASSAVE")) { - showDebugMsg(Common::String::format("Current location: %c%c%c%c", + _renderManager->showDebugMsg(Common::String::format("Current location: %c%c%c%c", _scriptManager->getStateValue(StateKey_World), _scriptManager->getStateValue(StateKey_Room), _scriptManager->getStateValue(StateKey_Node), @@ -131,13 +158,13 @@ void ZVision::cheatCodes(uint8 key) { } if (checkCode("FRAME")) - showDebugMsg(Common::String::format("FPS: ???, not implemented")); + _renderManager->showDebugMsg(Common::String::format("FPS: ???, not implemented")); if (checkCode("XYZZY")) _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); if (checkCode("COMPUTERARCH")) - showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); + _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) if (checkCode("GO????")) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 07ed6d2e2b..35e3b89b09 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -39,7 +39,7 @@ namespace ZVision { -RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat) +RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat, bool doubleFPS) : _engine(engine), _system(engine->_system), _workingWidth(workingWindow.width()), @@ -51,7 +51,8 @@ RenderManager::RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowH _backgroundWidth(0), _backgroundHeight(0), _backgroundOffset(0), - _renderTable(_workingWidth, _workingHeight) { + _renderTable(_workingWidth, _workingHeight), + _doubleFPS(doubleFPS) { _backgroundSurface.create(_workingWidth, _workingHeight, _pixelFormat); _effectSurface.create(_workingWidth, _workingHeight, _pixelFormat); @@ -1013,4 +1014,81 @@ void RenderManager::bkgFill(uint8 r, uint8 g, uint8 b) { } #endif +void RenderManager::timedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = createSubArea(); + updateSubArea(msgid, str); + processSubs(0); + renderSceneToScreen(); + deleteSubArea(msgid, milsecs); +} + +bool RenderManager::askQuestion(const Common::String &str) { + uint16 msgid = createSubArea(); + updateSubArea(msgid, str); + processSubs(0); + renderSceneToScreen(); + _engine->stopClock(); + + int result = 0; + + while (result == 0) { + Common::Event evnt; + while (_engine->getEventManager()->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN) { + switch (evnt.kbd.keycode) { + case Common::KEYCODE_y: + result = 2; + break; + case Common::KEYCODE_n: + result = 1; + break; + default: + break; + } + } + } + _system->updateScreen(); + if (_doubleFPS) + _system->delayMillis(33); + else + _system->delayMillis(66); + } + deleteSubArea(msgid); + _engine->startClock(); + return result == 2; +} + +void RenderManager::delayedMessage(const Common::String &str, uint16 milsecs) { + uint16 msgid = createSubArea(); + updateSubArea(msgid, str); + processSubs(0); + renderSceneToScreen(); + _engine->stopClock(); + + uint32 stopTime = _system->getMillis() + milsecs; + while (_system->getMillis() < stopTime) { + Common::Event evnt; + while (_engine->getEventManager()->pollEvent(evnt)) { + if (evnt.type == Common::EVENT_KEYDOWN && + (evnt.kbd.keycode == Common::KEYCODE_SPACE || + evnt.kbd.keycode == Common::KEYCODE_RETURN || + evnt.kbd.keycode == Common::KEYCODE_ESCAPE)) + break; + } + _system->updateScreen(); + if (_doubleFPS) + _system->delayMillis(33); + else + _system->delayMillis(66); + } + deleteSubArea(msgid); + _engine->startClock(); +} + +void RenderManager::showDebugMsg(const Common::String &msg, int16 delay) { + uint16 msgid = createSubArea(); + updateSubArea(msgid, msg); + deleteSubArea(msgid, delay); +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index d67ae29a3a..dbaa8fdc50 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -48,7 +48,7 @@ namespace ZVision { class RenderManager { public: - RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat); + RenderManager(ZVision *engine, uint32 windowWidth, uint32 windowHeight, const Common::Rect workingWindow, const Graphics::PixelFormat pixelFormat, bool doubleFPS); ~RenderManager(); private: @@ -137,6 +137,7 @@ private: // Visual effects list EffectsList _effects; + bool _doubleFPS; public: void initialize(); @@ -334,6 +335,11 @@ public: // Fill background surface by color void bkgFill(uint8 r, uint8 g, uint8 b); #endif + + bool askQuestion(const Common::String &str); + void delayedMessage(const Common::String &str, uint16 milsecs); + void timedMessage(const Common::String &str, uint16 milsecs); + void showDebugMsg(const Common::String &msg, int16 delay = 3000); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/controls/save_control.cpp b/engines/zvision/scripting/controls/save_control.cpp index 3a4dc47fe8..6cedddffeb 100644 --- a/engines/zvision/scripting/controls/save_control.cpp +++ b/engines/zvision/scripting/controls/save_control.cpp @@ -30,6 +30,7 @@ #include "zvision/text/string_manager.h" #include "zvision/file/save_manager.h" +#include "zvision/graphics/render_manager.h" #include "common/str.h" #include "common/stream.h" @@ -97,18 +98,18 @@ bool SaveControl::process(uint32 deltaTimeInMillis) { if (inp->getText().size() > 0) { bool toSave = true; if (iter->exist) - if (!_engine->askQuestion(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEXIST))) + if (!_engine->getRenderManager()->askQuestion(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEXIST))) toSave = false; if (toSave) { // FIXME: At this point, the screen shows the save control, so the save game thumbnails will always // show the save control _engine->getSaveManager()->saveGameBuffered(iter->saveId, inp->getText()); - _engine->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000); + _engine->getRenderManager()->delayedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVED), 2000); _engine->getScriptManager()->changeLocation(_engine->getScriptManager()->getLastMenuLocation()); } } else { - _engine->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000); + _engine->getRenderManager()->timedMessage(_engine->getStringManager()->getTextLine(StringManager::ZVISION_STR_SAVEEMPTY), 2000); } } else { _engine->getSaveManager()->loadGame(iter->saveId); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index e9a4486ded..575a7af6ab 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -190,7 +190,7 @@ void ZVision::initialize() { // Create managers _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS); _saveManager = new SaveManager(this); _stringManager = new StringManager(this); _cursorManager = new CursorManager(this, _resourcePixelFormat); @@ -265,77 +265,6 @@ Common::Error ZVision::run() { return Common::kNoError; } -bool ZVision::askQuestion(const Common::String &str) { - uint16 msgid = _renderManager->createSubArea(); - _renderManager->updateSubArea(msgid, str); - _renderManager->processSubs(0); - _renderManager->renderSceneToScreen(); - _clock.stop(); - - int result = 0; - - while (result == 0) { - Common::Event evnt; - while (_eventMan->pollEvent(evnt)) { - if (evnt.type == Common::EVENT_KEYDOWN) { - switch (evnt.kbd.keycode) { - case Common::KEYCODE_y: - result = 2; - break; - case Common::KEYCODE_n: - result = 1; - break; - default: - break; - } - } - } - _system->updateScreen(); - if (_doubleFPS) - _system->delayMillis(33); - else - _system->delayMillis(66); - } - _renderManager->deleteSubArea(msgid); - _clock.start(); - return result == 2; -} - -void ZVision::delayedMessage(const Common::String &str, uint16 milsecs) { - uint16 msgid = _renderManager->createSubArea(); - _renderManager->updateSubArea(msgid, str); - _renderManager->processSubs(0); - _renderManager->renderSceneToScreen(); - _clock.stop(); - - uint32 stopTime = _system->getMillis() + milsecs; - while (_system->getMillis() < stopTime) { - Common::Event evnt; - while (_eventMan->pollEvent(evnt)) { - if (evnt.type == Common::EVENT_KEYDOWN && - (evnt.kbd.keycode == Common::KEYCODE_SPACE || - evnt.kbd.keycode == Common::KEYCODE_RETURN || - evnt.kbd.keycode == Common::KEYCODE_ESCAPE)) - break; - } - _system->updateScreen(); - if (_doubleFPS) - _system->delayMillis(33); - else - _system->delayMillis(66); - } - _renderManager->deleteSubArea(msgid); - _clock.start(); -} - -void ZVision::timedMessage(const Common::String &str, uint16 milsecs) { - uint16 msgid = _renderManager->createSubArea(); - _renderManager->updateSubArea(msgid, str); - _renderManager->processSubs(0); - _renderManager->renderSceneToScreen(); - _renderManager->deleteSubArea(msgid, milsecs); -} - void ZVision::pauseEngineIntern(bool pause) { _mixer->pauseAll(pause); @@ -506,44 +435,11 @@ uint16 ZVision::getMenuBarEnable() { } bool ZVision::ifQuit() { - if (askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { + if (_renderManager->askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { quitGame(); return true; } return false; } -void ZVision::pushKeyToCheatBuf(uint8 key) { - for (int i = 0; i < KEYBUF_SIZE - 1; i++) - _cheatBuffer[i] = _cheatBuffer[i + 1]; - - _cheatBuffer[KEYBUF_SIZE - 1] = key; -} - -bool ZVision::checkCode(const char *code) { - int codeLen = strlen(code); - - if (codeLen > KEYBUF_SIZE) - return false; - - for (int i = 0; i < codeLen; i++) - if (code[i] != _cheatBuffer[KEYBUF_SIZE - codeLen + i] && code[i] != '?') - return false; - - return true; -} - -uint8 ZVision::getBufferedKey(uint8 pos) { - if (pos >= KEYBUF_SIZE) - return 0; - else - return _cheatBuffer[KEYBUF_SIZE - pos - 1]; -} - -void ZVision::showDebugMsg(const Common::String &msg, int16 delay) { - uint16 msgid = _renderManager->createSubArea(); - _renderManager->updateSubArea(msgid, msg); - _renderManager->deleteSubArea(msgid, delay); -} - } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index d3beae5e61..848b278f69 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -164,6 +164,14 @@ public: uint8 getZvisionKey(Common::KeyCode scummKeyCode); + void startClock() { + _clock.start(); + } + + void stopClock() { + _clock.stop(); + } + /** * Play a video until it is finished. This is a blocking call. It will call * _clock.stop() when the video starts and _clock.start() when the video finishes. @@ -181,10 +189,6 @@ public: Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); - bool askQuestion(const Common::String &str); - void delayedMessage(const Common::String &str, uint16 milsecs); - void timedMessage(const Common::String &str, uint16 milsecs); - void setRenderDelay(uint); bool canRender(); @@ -197,7 +201,6 @@ public: bool ifQuit(); void checkBorders(); - void showDebugMsg(const Common::String &msg, int16 delay = 3000); // Engine features bool hasFeature(EngineFeature f) const; -- cgit v1.2.3 From e8820d26e7d673f96c416f93dd16811107e94cb4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 12:42:01 +0200 Subject: ZVISION: Fix a warning --- engines/zvision/scripting/controls/input_control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index e1e6e6ec9d..4abc0c9e1b 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -223,7 +223,7 @@ bool InputControl::process(uint32 deltaTimeInMillis) { if (needDraw) { _animation->seekToFrame(_frame); const Graphics::Surface *srf = _animation->decodeNextFrame(); - uint32 xx = _textRectangle.left + _txtWidth; + int16 xx = _textRectangle.left + _txtWidth; if (xx >= _textRectangle.left + (_textRectangle.width() - (int16)_animation->getWidth())) xx = _textRectangle.left + _textRectangle.width() - (int16)_animation->getWidth(); _engine->getRenderManager()->blitSurfaceToBkg(*srf, xx, _textRectangle.top); -- cgit v1.2.3 From eea1ee445fcac7ecc53e31d258aac697d6b242f1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 13:14:24 +0200 Subject: ZVISION: Move more graphics code out of the main engine code --- engines/zvision/core/events.cpp | 17 ++- engines/zvision/graphics/render_manager.cpp | 133 +++++++++++++++++++++++ engines/zvision/graphics/render_manager.h | 4 + engines/zvision/scripting/actions.cpp | 5 +- engines/zvision/scripting/script_manager.cpp | 5 +- engines/zvision/zvision.cpp | 155 +-------------------------- engines/zvision/zvision.h | 17 +-- 7 files changed, 167 insertions(+), 169 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 70fd425949..5f29a6879c 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -30,6 +30,7 @@ #include "zvision/scripting/script_manager.h" #include "zvision/scripting/menu.h" #include "zvision/sound/zork_raw.h" +#include "zvision/text/string_manager.h" #include "common/events.h" #include "common/system.h" @@ -70,19 +71,19 @@ void ZVision::shortKeys(Common::Event event) { if (event.kbd.hasFlags(Common::KBD_CTRL)) { switch (event.kbd.keycode) { case Common::KEYCODE_s: - if (getMenuBarEnable() & kMenubarSave) + if (_menu->getEnable() & kMenubarSave) _scriptManager->changeLocation('g', 'j', 's', 'e', 0); break; case Common::KEYCODE_r: - if (getMenuBarEnable() & kMenubarRestore) + if (_menu->getEnable() & kMenubarRestore) _scriptManager->changeLocation('g', 'j', 'r', 'e', 0); break; case Common::KEYCODE_p: - if (getMenuBarEnable() & kMenubarSettings) + if (_menu->getEnable() & kMenubarSettings) _scriptManager->changeLocation('g', 'j', 'p', 'e', 0); break; case Common::KEYCODE_q: - if (getMenuBarEnable() & kMenubarExit) + if (_menu->getEnable() & kMenubarExit) ifQuit(); break; default: @@ -482,4 +483,12 @@ uint8 ZVision::getZvisionKey(Common::KeyCode scummKeyCode) { return 0; } +bool ZVision::ifQuit() { + if (_renderManager->askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { + quitGame(); + return true; + } + return false; +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 35e3b89b09..0a48ae6c16 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -1091,4 +1091,137 @@ void RenderManager::showDebugMsg(const Common::String &msg, int16 delay) { deleteSubArea(msgid, delay); } +void RenderManager::updateRotation() { + int16 _velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity(); + ScriptManager *scriptManager = _engine->getScriptManager(); + + if (_doubleFPS) + _velocity /= 2; + + if (_velocity) { + RenderTable::RenderState renderState = _renderTable.getRenderState(); + if (renderState == RenderTable::PANORAMA) { + int16 startPosition = scriptManager->getStateValue(StateKey_ViewPos); + + int16 newPosition = startPosition + (_renderTable.getPanoramaReverse() ? -_velocity : _velocity); + + int16 zeroPoint = _renderTable.getPanoramaZeroPoint(); + if (startPosition >= zeroPoint && newPosition < zeroPoint) + scriptManager->setStateValue(StateKey_Rounds, scriptManager->getStateValue(StateKey_Rounds) - 1); + if (startPosition <= zeroPoint && newPosition > zeroPoint) + scriptManager->setStateValue(StateKey_Rounds, scriptManager->getStateValue(StateKey_Rounds) + 1); + + int16 screenWidth = getBkgSize().x; + if (screenWidth) + newPosition %= screenWidth; + + if (newPosition < 0) + newPosition += screenWidth; + + setBackgroundPosition(newPosition); + } else if (renderState == RenderTable::TILT) { + int16 startPosition = scriptManager->getStateValue(StateKey_ViewPos); + + int16 newPosition = startPosition + _velocity; + + int16 screenHeight = getBkgSize().y; + int16 tiltGap = _renderTable.getTiltGap(); + + if (newPosition >= (screenHeight - tiltGap)) + newPosition = screenHeight - tiltGap; + if (newPosition <= tiltGap) + newPosition = tiltGap; + + setBackgroundPosition(newPosition); + } + } +} + +void RenderManager::checkBorders() { + RenderTable::RenderState renderState = _renderTable.getRenderState(); + if (renderState == RenderTable::PANORAMA) { + int16 startPosition = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + + int16 newPosition = startPosition; + + int16 screenWidth = getBkgSize().x; + + if (screenWidth) + newPosition %= screenWidth; + + if (newPosition < 0) + newPosition += screenWidth; + + if (startPosition != newPosition) + setBackgroundPosition(newPosition); + } else if (renderState == RenderTable::TILT) { + int16 startPosition = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + + int16 newPosition = startPosition; + + int16 screenHeight = getBkgSize().y; + int16 tiltGap = _renderTable.getTiltGap(); + + if (newPosition >= (screenHeight - tiltGap)) + newPosition = screenHeight - tiltGap; + if (newPosition <= tiltGap) + newPosition = tiltGap; + + if (startPosition != newPosition) + setBackgroundPosition(newPosition); + } +} + +void RenderManager::rotateTo(int16 _toPos, int16 _time) { + if (_renderTable.getRenderState() != RenderTable::PANORAMA) + return; + + if (_time == 0) + _time = 1; + + int32 maxX = getBkgSize().x; + int32 curX = getCurrentBackgroundOffset(); + int32 dx = 0; + + if (curX == _toPos) + return; + + if (curX > _toPos) { + if (curX - _toPos > maxX / 2) + dx = (_toPos + (maxX - curX)) / _time; + else + dx = -(curX - _toPos) / _time; + } else { + if (_toPos - curX > maxX / 2) + dx = -((maxX - _toPos) + curX) / _time; + else + dx = (_toPos - curX) / _time; + } + + _engine->stopClock(); + + for (int16 i = 0; i <= _time; i++) { + if (i == _time) + curX = _toPos; + else + curX += dx; + + if (curX < 0) + curX = maxX - curX; + else if (curX >= maxX) + curX %= maxX; + + setBackgroundPosition(curX); + + prepareBackground(); + renderSceneToScreen(); + + _system->updateScreen(); + + _system->delayMillis(500 / _time); + } + + _engine->startClock(); +} + } // End of namespace ZVision diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index dbaa8fdc50..30e51456e9 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -340,6 +340,10 @@ public: void delayedMessage(const Common::String &str, uint16 milsecs); void timedMessage(const Common::String &str, uint16 milsecs); void showDebugMsg(const Common::String &msg, int16 delay = 3000); + + void checkBorders(); + void rotateTo(int16 to, int16 time); + void updateRotation(); }; } // End of namespace ZVision diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index c26a93f529..7c3463b6d0 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -30,6 +30,7 @@ #include "zvision/sound/zork_raw.h" #include "zvision/video/zork_avi_decoder.h" #include "zvision/file/save_manager.h" +#include "zvision/scripting/menu.h" #include "zvision/scripting/sidefx/timer_node.h" #include "zvision/scripting/sidefx/music_node.h" #include "zvision/scripting/sidefx/syncsound_node.h" @@ -439,7 +440,7 @@ ActionMenuBarEnable::ActionMenuBarEnable(ZVision *engine, int32 slotkey, const C } bool ActionMenuBarEnable::execute() { - _engine->menuBarEnable(_menus); + _engine->getMenuHandler()->setEnable(_menus); return true; } @@ -819,7 +820,7 @@ ActionRotateTo::ActionRotateTo(ZVision *engine, int32 slotkey, const Common::Str } bool ActionRotateTo::execute() { - _engine->rotateTo(_toPos, _time); + _engine->getRenderManager()->rotateTo(_toPos, _time); return true; } diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 2a4aa5fed0..1a2b8362f5 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -29,6 +29,7 @@ #include "zvision/graphics/cursors/cursor_manager.h" #include "zvision/file/save_manager.h" #include "zvision/scripting/actions.h" +#include "zvision/scripting/menu.h" #include "zvision/scripting/sidefx/timer_node.h" #include "common/algorithm.h" @@ -583,7 +584,7 @@ void ScriptManager::ChangeLocationReal() { _referenceTable.clear(); addPuzzlesToReferenceTable(universe); - _engine->menuBarEnable(0xFFFF); + _engine->getMenuHandler()->setEnable(0xFFFF); if (_nextLocation.world != _currentLocation.world) { cleanScriptScope(nodeview); @@ -652,7 +653,7 @@ void ScriptManager::ChangeLocationReal() { execScope(nodeview); } - _engine->checkBorders(); + _engine->getRenderManager()->checkBorders(); } void ScriptManager::serialize(Common::WriteStream *stream) { diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 575a7af6ab..bd215f4f62 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -232,7 +232,7 @@ Common::Error ZVision::run() { _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); processEvents(); - updateRotation(); + _renderManager->updateRotation(); _scriptManager->update(deltaTime); _menu->process(deltaTime); @@ -244,7 +244,7 @@ Common::Error ZVision::run() { _renderManager->renderSceneToScreen(); // Update the screen - if (_frameRenderDelay <= 0) { + if (canRender()) { _system->updateScreen(); } else { _frameRenderDelay--; @@ -291,155 +291,4 @@ bool ZVision::canRender() { return _frameRenderDelay <= 0; } -void ZVision::updateRotation() { - int16 _velocity = _mouseVelocity + _keyboardVelocity; - - if (_doubleFPS) - _velocity /= 2; - - if (_velocity) { - RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); - if (renderState == RenderTable::PANORAMA) { - int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - - int16 newPosition = startPosition + (_renderManager->getRenderTable()->getPanoramaReverse() ? -_velocity : _velocity); - - int16 zeroPoint = _renderManager->getRenderTable()->getPanoramaZeroPoint(); - if (startPosition >= zeroPoint && newPosition < zeroPoint) - _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) - 1); - if (startPosition <= zeroPoint && newPosition > zeroPoint) - _scriptManager->setStateValue(StateKey_Rounds, _scriptManager->getStateValue(StateKey_Rounds) + 1); - - int16 screenWidth = _renderManager->getBkgSize().x; - if (screenWidth) - newPosition %= screenWidth; - - if (newPosition < 0) - newPosition += screenWidth; - - _renderManager->setBackgroundPosition(newPosition); - } else if (renderState == RenderTable::TILT) { - int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - - int16 newPosition = startPosition + _velocity; - - int16 screenHeight = _renderManager->getBkgSize().y; - int16 tiltGap = _renderManager->getRenderTable()->getTiltGap(); - - if (newPosition >= (screenHeight - tiltGap)) - newPosition = screenHeight - tiltGap; - if (newPosition <= tiltGap) - newPosition = tiltGap; - - _renderManager->setBackgroundPosition(newPosition); - } - } -} - -void ZVision::checkBorders() { - RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); - if (renderState == RenderTable::PANORAMA) { - int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - - int16 newPosition = startPosition; - - int16 screenWidth = _renderManager->getBkgSize().x; - - if (screenWidth) - newPosition %= screenWidth; - - if (newPosition < 0) - newPosition += screenWidth; - - if (startPosition != newPosition) - _renderManager->setBackgroundPosition(newPosition); - } else if (renderState == RenderTable::TILT) { - int16 startPosition = _scriptManager->getStateValue(StateKey_ViewPos); - - int16 newPosition = startPosition; - - int16 screenHeight = _renderManager->getBkgSize().y; - int16 tiltGap = _renderManager->getRenderTable()->getTiltGap(); - - if (newPosition >= (screenHeight - tiltGap)) - newPosition = screenHeight - tiltGap; - if (newPosition <= tiltGap) - newPosition = tiltGap; - - if (startPosition != newPosition) - _renderManager->setBackgroundPosition(newPosition); - } -} - -void ZVision::rotateTo(int16 _toPos, int16 _time) { - if (_renderManager->getRenderTable()->getRenderState() != RenderTable::PANORAMA) - return; - - if (_time == 0) - _time = 1; - - int32 maxX = _renderManager->getBkgSize().x; - int32 curX = _renderManager->getCurrentBackgroundOffset(); - int32 dx = 0; - - if (curX == _toPos) - return; - - if (curX > _toPos) { - if (curX - _toPos > maxX / 2) - dx = (_toPos + (maxX - curX)) / _time; - else - dx = -(curX - _toPos) / _time; - } else { - if (_toPos - curX > maxX / 2) - dx = -((maxX - _toPos) + curX) / _time; - else - dx = (_toPos - curX) / _time; - } - - _clock.stop(); - - for (int16 i = 0; i <= _time; i++) { - if (i == _time) - curX = _toPos; - else - curX += dx; - - if (curX < 0) - curX = maxX - curX; - else if (curX >= maxX) - curX %= maxX; - - _renderManager->setBackgroundPosition(curX); - - _renderManager->prepareBackground(); - _renderManager->renderSceneToScreen(); - - _system->updateScreen(); - - _system->delayMillis(500 / _time); - } - - _clock.start(); -} - -void ZVision::menuBarEnable(uint16 menus) { - if (_menu) - _menu->setEnable(menus); -} - -uint16 ZVision::getMenuBarEnable() { - if (_menu) - return _menu->getEnable(); - return 0; -} - -bool ZVision::ifQuit() { - if (_renderManager->askQuestion(_stringManager->getTextLine(StringManager::ZVISION_STR_EXITPROMT))) { - quitGame(); - return true; - } - return false; -} - } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 848b278f69..dc1ac1b8cb 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -155,12 +155,21 @@ public: MidiManager *getMidiManager() const { return _midiManager; } + MenuHandler *getMenuHandler() const { + return _menu; + } Common::RandomSource *getRandomSource() const { return _rnd; } ZVisionGameId getGameId() const { return _gameDescription->gameId; } + int16 getKeyboardVelocity() const { + return _keyboardVelocity; + } + int16 getMouseVelocity() const { + return _mouseVelocity; + } uint8 getZvisionKey(Common::KeyCode scummKeyCode); @@ -184,8 +193,6 @@ public: void playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, Subtitle *sub = NULL); Video::VideoDecoder *loadAnimation(const Common::String &fileName); - void rotateTo(int16 to, int16 time); - Common::String generateSaveFileName(uint slot); Common::String generateAutoSaveFileName(); @@ -195,13 +202,8 @@ public: void loadSettings(); void saveSettings(); - void menuBarEnable(uint16 menus); - uint16 getMenuBarEnable(); - bool ifQuit(); - void checkBorders(); - // Engine features bool hasFeature(EngineFeature f) const; bool canLoadGameStateCurrently(); @@ -218,7 +220,6 @@ private: void processEvents(); void onMouseMove(const Common::Point &pos); - void updateRotation(); void registerDefaultSettings(); void shortKeys(Common::Event); -- cgit v1.2.3 From e5f0ee2271f4a43ff05b82380ab22eade9763702 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 18:22:18 +0200 Subject: ZVISION: Implement auto-saving --- engines/zvision/detection.cpp | 5 +++++ engines/zvision/file/save_manager.cpp | 14 +++++--------- engines/zvision/file/save_manager.h | 10 +++++++--- engines/zvision/scripting/script_manager.cpp | 4 ---- engines/zvision/zvision.cpp | 8 ++++---- engines/zvision/zvision.h | 1 - 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index a361239e9e..4fcb5c040b 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -308,6 +308,11 @@ SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, in if (successfulRead) { SaveStateDescriptor desc(slot, header.saveName); + // Do not allow save slot 0 (used for auto-saving) to be deleted or + // overwritten. + desc.setDeletableFlag(slot != 0); + desc.setWriteProtectedFlag(slot == 0); + desc.setThumbnail(header.thumbnail); if (header.version > 0) { diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index 05df834497..042fafd38e 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -87,6 +87,8 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName) { file->finalize(); delete file; + + _lastSaveTime = g_system->getMillis(); } void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) { @@ -99,6 +101,8 @@ void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::Me file->finalize(); delete file; + + _lastSaveTime = g_system->getMillis(); } void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { @@ -109,15 +113,7 @@ void SaveManager::saveGameBuffered(uint slot, const Common::String &saveName) { } void SaveManager::autoSave() { - Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName()); - - writeSaveGameHeader(file, "auto"); - - _engine->getScriptManager()->serialize(file); - - // Cleanup - file->finalize(); - delete file; + saveGame(0, "Auto save"); } void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName) { diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h index 75841331e7..fc8db67566 100644 --- a/engines/zvision/file/save_manager.h +++ b/engines/zvision/file/save_manager.h @@ -48,13 +48,18 @@ struct SaveGameHeader { class SaveManager { public: - SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL) {} + SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL), _lastSaveTime(0) {} ~SaveManager() { flushSaveBuffer(); } + uint32 getLastSaveTime() const { + return _lastSaveTime; + } + private: ZVision *_engine; + uint32 _lastSaveTime; static const uint32 SAVEGAME_ID; enum { @@ -67,8 +72,7 @@ private: public: /** * Called every room change. Saves the state of the room just before - * we switched rooms. Uses ZVision::generateAutoSaveFileName() to - * create the save file name. + * the room changes. */ void autoSave(); /** diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index 1a2b8362f5..d0ebb18944 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -569,10 +569,6 @@ void ScriptManager::ChangeLocationReal() { } else { if (_currentLocation.world == 'g' && _currentLocation.room == 'j') _engine->getSaveManager()->flushSaveBuffer(); - else { - // Auto save - //_engine->getSaveManager()->autoSave(); - } } setStateValue(StateKey_World, _nextLocation.world); diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index bd215f4f62..b3fc02ee15 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -259,6 +259,10 @@ Common::Error ZVision::run() { delay >>= 1; } + if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { + _saveManager->autoSave(); + } + _system->delayMillis(delay); } @@ -279,10 +283,6 @@ Common::String ZVision::generateSaveFileName(uint slot) { return Common::String::format("%s.%03u", _targetName.c_str(), slot); } -Common::String ZVision::generateAutoSaveFileName() { - return Common::String::format("%s.auto", _targetName.c_str()); -} - void ZVision::setRenderDelay(uint delay) { _frameRenderDelay = delay; } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index dc1ac1b8cb..6664d0cd5d 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -194,7 +194,6 @@ public: Video::VideoDecoder *loadAnimation(const Common::String &fileName); Common::String generateSaveFileName(uint slot); - Common::String generateAutoSaveFileName(); void setRenderDelay(uint); bool canRender(); -- cgit v1.2.3 From 2becc76d5c16d15d5a7a6733b40f7c59e7391c12 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 19:56:37 +0200 Subject: ZVISION: Correct the script names of the location-specific cheats --- engines/zvision/core/events.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 5f29a6879c..4438474078 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -119,9 +119,9 @@ void ZVision::cheatCodes(uint8 key) { } // There are 3 more cheats in script files: - // - "EAT ME": gjcr.scr - // - "WHOAMI": hp1e.scr - // - "HUISOK": uh1f.scr + // - "WHOAMI": gjcr.scr + // - "HUISOK": hp1e.scr + // - "EAT ME": uh1f.scr } else if (getGameId() == GID_NEMESIS) { if (checkCode("CHLOE")) { _scriptManager->changeLocation('t', 'm', '2', 'g', 0); -- cgit v1.2.3 From db37cfb1b04fb6d1fb21ef3bd3c0b90128bf4d89 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 22:30:32 +0200 Subject: ZVISION: Remove duplicate blitting code for images and animations --- engines/zvision/graphics/render_manager.cpp | 67 +++++----------------- engines/zvision/graphics/render_manager.h | 11 +--- engines/zvision/scripting/actions.cpp | 12 ++++ .../zvision/scripting/sidefx/animation_node.cpp | 10 +--- engines/zvision/text/text.cpp | 7 ++- 5 files changed, 36 insertions(+), 71 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 0a48ae6c16..7bbde81e4c 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -104,7 +104,8 @@ void RenderManager::renderSceneToScreen() { post = (*it)->draw(_currentBackgroundImage.getSubArea(rect)); else post = (*it)->draw(_effectSurface.getSubArea(rect)); - blitSurfaceToSurface(*post, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top); + Common::Rect empty; + blitSurfaceToSurface(*post, empty, _effectSurface, screenSpaceLocation.left, screenSpaceLocation.top); screenSpaceLocation.clip(windowRect); if (_backgroundSurfaceDirtyRect .isEmpty()) { _backgroundSurfaceDirtyRect = screenSpaceLocation; @@ -511,30 +512,12 @@ void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, const Com delete srcAdapted; } -void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y) { +void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey) { Common::Rect empt; - blitSurfaceToSurface(src, empt, dst, x, y); -} - -void RenderManager::blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey) { - Common::Rect empt; - blitSurfaceToSurface(src, empt, dst, x, y, colorkey); -} - -void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y) { - Common::Rect empt; - blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y); - Common::Rect dirty(src.w, src.h); - dirty.translate(x, y); - if (_backgroundDirtyRect.isEmpty()) - _backgroundDirtyRect = dirty; + if (colorkey >= 0) + blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey); else - _backgroundDirtyRect.extend(dirty); -} - -void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey) { - Common::Rect empt; - blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y, colorkey); + blitSurfaceToSurface(src, empt, _currentBackgroundImage, x, y); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); if (_backgroundDirtyRect.isEmpty()) @@ -543,23 +526,10 @@ void RenderManager::blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, _backgroundDirtyRect.extend(dirty); } -void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect) { - if (src.w == _dstRect.width() && src.h == _dstRect.height()) - blitSurfaceToBkg(src, _dstRect.left, _dstRect.top); - else { - Graphics::Surface *tmp = new Graphics::Surface; - tmp->create(_dstRect.width(), _dstRect.height(), src.format); - scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); - blitSurfaceToBkg(*tmp, _dstRect.left, _dstRect.top); - tmp->free(); - delete tmp; - } -} - -void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey) { - if (src.w == _dstRect.width() && src.h == _dstRect.height()) +void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey) { + if (src.w == _dstRect.width() && src.h == _dstRect.height()) { blitSurfaceToBkg(src, _dstRect.left, _dstRect.top, colorkey); - else { + } else { Graphics::Surface *tmp = new Graphics::Surface; tmp->create(_dstRect.width(), _dstRect.height(), src.format); scaleBuffer(src.getPixels(), tmp->getPixels(), src.w, src.h, src.format.bytesPerPixel, _dstRect.width(), _dstRect.height()); @@ -569,20 +539,12 @@ void RenderManager::blitSurfaceToBkgScaled(const Graphics::Surface &src, const C } } -void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y) { +void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey) { Common::Rect empt; - blitSurfaceToSurface(src, empt, _menuSurface, x, y); - Common::Rect dirty(src.w, src.h); - dirty.translate(x, y); - if (_menuSurfaceDirtyRect.isEmpty()) - _menuSurfaceDirtyRect = dirty; + if (colorkey >= 0) + blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey); else - _menuSurfaceDirtyRect.extend(dirty); -} - -void RenderManager::blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey) { - Common::Rect empt; - blitSurfaceToSurface(src, empt, _menuSurface, x, y, colorkey); + blitSurfaceToSurface(src, empt, _menuSurface, x, y); Common::Rect dirty(src.w, src.h); dirty.translate(x, y); if (_menuSurfaceDirtyRect.isEmpty()) @@ -803,7 +765,8 @@ void RenderManager::processSubs(uint16 deltatime) { Graphics::Surface *rndr = new Graphics::Surface(); rndr->create(sub->r.width(), sub->r.height(), _engine->_resourcePixelFormat); _engine->getTextRenderer()->drawTxtInOneLine(sub->txt, *rndr); - blitSurfaceToSurface(*rndr, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); + Common::Rect empty; + blitSurfaceToSurface(*rndr, empty, _subtitleSurface, sub->r.left - _subtitleArea.left + _workingWindow.left, sub->r.top - _subtitleArea.top + _workingWindow.top); rndr->free(); delete rndr; } diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 30e51456e9..a7e49b7758 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -230,20 +230,15 @@ public: // Blitting surface-to-surface methods void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int x, int y); void blitSurfaceToSurface(const Graphics::Surface &src, const Common::Rect &_srcRect , Graphics::Surface &dst, int _x, int _y, uint32 colorkey); - void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y); - void blitSurfaceToSurface(const Graphics::Surface &src, Graphics::Surface &dst, int x, int y, uint32 colorkey); // Blitting surface-to-background methods - void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y); - void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, uint32 colorkey); + void blitSurfaceToBkg(const Graphics::Surface &src, int x, int y, int32 colorkey = -1); // Blitting surface-to-background methods with scale - void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect); - void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, uint32 colorkey); + void blitSurfaceToBkgScaled(const Graphics::Surface &src, const Common::Rect &_dstRect, int32 colorkey = -1); // Blitting surface-to-menu methods - void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y); - void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, uint32 colorkey); + void blitSurfaceToMenu(const Graphics::Surface &src, int x, int y, int32 colorkey = -1); // Subtitles methods diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index 7c3463b6d0..a91476760d 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -566,6 +566,12 @@ ActionPreloadAnimation::ActionPreloadAnimation(ZVision *engine, int32 slotkey, c // The two %*u are usually 0 and dont seem to have a use sscanf(line.c_str(), "%24s %*u %*u %d %d", fileName, &_mask, &_framerate); + // Mask 0 means "no transparency" in this case. Since we use a common blitting + // code for images and animations, we set it to -1 to avoid confusion with + // color 0, which is used as a mask in some images + if (_mask == 0) + _mask = -1; + _fileName = Common::String(fileName); } @@ -628,6 +634,12 @@ ActionPlayAnimation::ActionPlayAnimation(ZVision *engine, int32 slotkey, const C "%24s %u %u %u %u %u %u %d %*u %*u %d %d", fileName, &_x, &_y, &_x2, &_y2, &_start, &_end, &_loopCount, &_mask, &_framerate); + // Mask 0 means "no transparency" in this case. Since we use a common blitting + // code for images and animations, we set it to -1 to avoid confusion with + // color 0, which is used as a mask in some images + if (_mask == 0) + _mask = -1; + _fileName = Common::String(fileName); } diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index b966aa9cb8..7759758f56 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -154,17 +154,11 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); - if (_mask > 0) - _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top); + _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); transposed->free(); delete transposed; } else { - if (_mask > 0) - _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); - else - _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top); + _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); } } } diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp index f28ba6ade3..a5ed044424 100644 --- a/engines/zvision/text/text.cpp +++ b/engines/zvision/text/text.cpp @@ -462,15 +462,16 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac j++; } dx = 0; + Common::Rect empty; for (int32 jj = 0; jj < j; jj++) { if (TxtJustify[i] == TXT_JUSTIFY_LEFT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); else if (TxtJustify[i] == TXT_JUSTIFY_CENTER) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT) - _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); + _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0); dx += TxtSurfaces[i][jj]->w; } -- cgit v1.2.3 From a9701d04c17b6f565e5602f12546bfe7aa2848af Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 22:35:02 +0200 Subject: ZVISION: Remove duplicate image loading code --- engines/zvision/graphics/render_manager.cpp | 14 ++------------ engines/zvision/graphics/render_manager.h | 6 ++---- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 7bbde81e4c..73483f2309 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -568,28 +568,18 @@ Graphics::Surface *RenderManager::getBkgRect(Common::Rect &rect) { return srf; } -Graphics::Surface *RenderManager::loadImage(Common::String &file) { +Graphics::Surface *RenderManager::loadImage(Common::String file) { Graphics::Surface *tmp = new Graphics::Surface; readImageToSurface(file, *tmp); return tmp; } -Graphics::Surface *RenderManager::loadImage(const char *file) { - Common::String str = Common::String(file); - return loadImage(str); -} - -Graphics::Surface *RenderManager::loadImage(Common::String &file, bool transposed) { +Graphics::Surface *RenderManager::loadImage(Common::String file, bool transposed) { Graphics::Surface *tmp = new Graphics::Surface; readImageToSurface(file, *tmp, transposed); return tmp; } -Graphics::Surface *RenderManager::loadImage(const char *file, bool transposed) { - Common::String str = Common::String(file); - return loadImage(str, transposed); -} - void RenderManager::prepareBackground() { _backgroundDirtyRect.clip(_backgroundWidth, _backgroundHeight); RenderTable::RenderState state = _renderTable.getRenderState(); diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index a7e49b7758..d9a6c88896 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -263,10 +263,8 @@ public: Graphics::Surface *getBkgRect(Common::Rect &rect); // Load image into new surface - Graphics::Surface *loadImage(const char *file); - Graphics::Surface *loadImage(Common::String &file); - Graphics::Surface *loadImage(const char *file, bool transposed); - Graphics::Surface *loadImage(Common::String &file, bool transposed); + Graphics::Surface *loadImage(Common::String file); + Graphics::Surface *loadImage(Common::String file, bool transposed); // Clear whole/area of menu surface void clearMenuSurface(); -- cgit v1.2.3 From 85142cd0d7fb6e24fc45b2c61611f848b8c4a102 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 22:48:58 +0200 Subject: ZVISION: Remove duplicate subtitle code --- engines/zvision/graphics/render_manager.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 73483f2309..4f7b16c833 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -698,18 +698,9 @@ uint16 RenderManager::createSubArea(const Common::Rect &area) { } uint16 RenderManager::createSubArea() { - _subid++; - - OneSubtitle sub; - sub.redraw = false; - sub.timer = -1; - sub.todelete = false; - sub.r = Common::Rect(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom); - sub.r.translate(-_workingWindow.left, -_workingWindow.top); - - _subsList[_subid] = sub; - - return _subid; + Common::Rect r(_subtitleArea.left, _subtitleArea.top, _subtitleArea.right, _subtitleArea.bottom); + r.translate(-_workingWindow.left, -_workingWindow.top); + return createSubArea(r); } void RenderManager::deleteSubArea(uint16 id) { -- cgit v1.2.3 From 19ce38d40e9f273335b06a62bcb0d3643602080c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 22:51:33 +0200 Subject: ZVISION: Turn off subtitles, if requested --- engines/zvision/graphics/render_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 4f7b16c833..4f26123fc8 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -737,7 +737,7 @@ void RenderManager::processSubs(uint16 deltatime) { } } - if (redraw) { + if (redraw && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) { _subtitleSurface.fillRect(Common::Rect(_subtitleSurface.w, _subtitleSurface.h), 0); for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { -- cgit v1.2.3 From f9595b11fc2bef08d84a00b81f9b2884f77897b0 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 26 Dec 2014 23:18:54 +0200 Subject: ZVISION: Add an FPS timer (accessible with F10, or the "FRAME" cheat) --- engines/zvision/core/events.cpp | 18 +++++++++++++----- engines/zvision/zvision.cpp | 19 ++++++++++++++++++- engines/zvision/zvision.h | 7 +++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index 4438474078..7804130e2a 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -158,15 +158,18 @@ void ZVision::cheatCodes(uint8 key) { } } - if (checkCode("FRAME")) - _renderManager->showDebugMsg(Common::String::format("FPS: ???, not implemented")); + if (checkCode("FRAME")) { + Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); + _renderManager->showDebugMsg(fpsStr); + } + + if (checkCode("COMPUTERARCH")) + _renderManager->showDebugMsg("COMPUTERARCH: var-viewer not implemented"); + // This cheat essentially toggles the GOxxxx cheat below if (checkCode("XYZZY")) _scriptManager->setStateValue(StateKey_DebugCheats, 1 - _scriptManager->getStateValue(StateKey_DebugCheats)); - if (checkCode("COMPUTERARCH")) - _renderManager->showDebugMsg(Common::String::format("COMPUTERARCH: var-viewer not implemented")); - if (_scriptManager->getStateValue(StateKey_DebugCheats) == 1) if (checkCode("GO????")) _scriptManager->changeLocation(getBufferedKey(3), @@ -240,6 +243,11 @@ void ZVision::processEvents() { _scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2; break; + case Common::KEYCODE_F10: { + Common::String fpsStr = Common::String::format("FPS: %d", getFPS()); + _renderManager->showDebugMsg(fpsStr); + } + break; default: break; } diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index b3fc02ee15..615574bbcd 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -101,7 +101,9 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) _frameRenderDelay(2), _keyboardVelocity(0), _mouseVelocity(0), - _videoIsPlaying(false) { + _videoIsPlaying(false), + _renderedFrameCount(0), + _fps(0) { debug(1, "ZVision::ZVision"); @@ -130,6 +132,8 @@ ZVision::~ZVision() { delete _rnd; delete _midiManager; + getTimerManager()->removeTimerProc(&fpsTimerCallback); + // Remove all of our debug levels DebugMan.clearAllDebugChannels(); } @@ -214,6 +218,9 @@ void ZVision::initialize() { // Create debugger console. It requires GFX to be initialized _console = new Console(this); _doubleFPS = ConfMan.getBool("doublefps"); + + // Initialize FPS timer callback + getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); } Common::Error ZVision::run() { @@ -246,6 +253,7 @@ Common::Error ZVision::run() { // Update the screen if (canRender()) { _system->updateScreen(); + _renderedFrameCount++; } else { _frameRenderDelay--; } @@ -291,4 +299,13 @@ bool ZVision::canRender() { return _frameRenderDelay <= 0; } +void ZVision::fpsTimerCallback(void *refCon) { + ((ZVision *)refCon)->fpsTimer(); +} + +void ZVision::fpsTimer() { + _fps = _renderedFrameCount; + _renderedFrameCount = 0; +} + } // End of namespace ZVision diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 6664d0cd5d..5482060cd0 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -119,6 +119,8 @@ private: Common::Event _event; int _frameRenderDelay; + int _renderedFrameCount; + int _fps; int16 _mouseVelocity; int16 _keyboardVelocity; bool _doubleFPS; @@ -197,6 +199,11 @@ public: void setRenderDelay(uint); bool canRender(); + static void fpsTimerCallback(void *refCon); + void fpsTimer(); + int getFPS() const { + return _fps; + } void loadSettings(); void saveSettings(); -- cgit v1.2.3 From eb46e837969f2f650b5debaa387e63127b83db6c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 00:00:07 +0200 Subject: ZVISION: Quit with an error message dialog if no font files are found --- engines/zvision/zvision.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 615574bbcd..fe8e129800 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -46,8 +46,8 @@ #include "common/system.h" #include "common/file.h" +#include "gui/message.h" #include "engines/util.h" - #include "audio/mixer.h" namespace ZVision { @@ -230,6 +230,22 @@ Common::Error ZVision::run() { if (ConfMan.hasKey("save_slot")) _saveManager->loadGame(ConfMan.getInt("save_slot")); + // Before starting, make absolutely sure that the user has copied the needed fonts + if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf")) { + GUI::MessageDialog dialog( + "Before playing this game, you'll need to copy the required " + "fonts in ScummVM's extras directory, or the game directory. " + "On Windows, you'll need the following font files from the Windows " + "font directory: Times New Roman, Century Schoolbook, Garamond, " + "Courier New and Arial. Alternatively, you can download the GNU " + "FreeFont package. You'll need all the fonts from that package, " + "i.e. FreeMono, FreeSans and FreeSerif." + ); + dialog.runModal(); + quitGame(); + return Common::kUnknownError; + } + // Main loop while (!shouldQuit()) { _clock.update(); -- cgit v1.2.3 From fd34456bb8bcbf39667df50eb6d14a9f4fbe7087 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 01:02:51 +0200 Subject: ZVISION: Delete the render manager after the script manager on quit This is necessary, as the script manager may include references to the render manager, such as side effects in Zork: Nemesis. Fixes a crash on engine exit when the current scene contains such effects --- engines/zvision/zvision.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index fe8e129800..7c26eba030 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -127,8 +127,8 @@ ZVision::~ZVision() { delete _cursorManager; delete _stringManager; delete _saveManager; - delete _renderManager; delete _scriptManager; + delete _renderManager; // should be deleted after the script manager delete _rnd; delete _midiManager; -- cgit v1.2.3 From 192c3df6a1b65a5e08b5fd0e2a82792393240378 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 02:20:51 +0200 Subject: CREDITS: Update the credits for the ZVISION engine --- AUTHORS | 2 ++ devtools/credits.pl | 2 ++ gui/credits.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/AUTHORS b/AUTHORS index 8e90a625c9..3e8c65e5e2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -261,6 +261,8 @@ ScummVM Team ZVision: Adrian Astley + Filippos Karapetis + Anton Yarcev Backend Teams ------------- diff --git a/devtools/credits.pl b/devtools/credits.pl index e919c0b8ba..69eede756d 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -791,6 +791,8 @@ begin_credits("Credits"); begin_section("ZVision"); add_person("Adrian Astley", "RichieSams", ""); + add_person("Filippos Karapetis", "[md5]", ""); + add_person("Anton Yarcev", "Marisa-Chan", ""); end_section(); end_section(); diff --git a/gui/credits.h b/gui/credits.h index 0610609983..c7d9199db9 100644 --- a/gui/credits.h +++ b/gui/credits.h @@ -324,6 +324,8 @@ static const char *credits[] = { "", "C1""ZVision", "C0""Adrian Astley", +"C0""Filippos Karapetis", +"C0""Anton Yarcev", "", "", "C1""Backend Teams", -- cgit v1.2.3 From 569c06b5105c7bae0a72d4abc72cf5db51541702 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 11:10:14 +0100 Subject: SCI: Fix warning --- engines/sci/engine/state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index c07dc925e0..527c8f0ae0 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -205,7 +205,7 @@ static kLanguage charToLanguage(const char c) { Common::String SciEngine::getSciLanguageString(const Common::String &str, kLanguage requestedLanguage, kLanguage *secondaryLanguage, uint16 *languageSplitter) const { kLanguage foundLanguage = K_LANG_NONE; - const byte *textPtr = (byte *)str.c_str(); + const byte *textPtr = (const byte *)str.c_str(); byte curChar = 0; byte curChar2 = 0; -- cgit v1.2.3 From ba40b3ea4905716fc8dd6f01bfec6d414b6b9a58 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 14:27:37 +0200 Subject: ZVISION: Clean up the game settings --- engines/zvision/detection.cpp | 66 ++++++++++++++++++++++-------------- engines/zvision/zvision.cpp | 78 ++++++++++++++++++++++++++++++------------- 2 files changed, 95 insertions(+), 49 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index 4fcb5c040b..c613278fec 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -55,6 +55,10 @@ static const PlainGameDescriptor zVisionGames[] = { namespace ZVision { +#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 +#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2 +#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3 + static const ZVisionGameDescription gameDescriptions[] = { { @@ -66,7 +70,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO1(GUIO_NONE) + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS) }, GID_NEMESIS }, @@ -80,7 +84,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, - GUIO1(GUIO_NONE) + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS) }, GID_NEMESIS }, @@ -94,7 +98,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, - GUIO1(GUIO_NONE) + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) }, GID_GRANDINQUISITOR }, @@ -108,7 +112,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, - GUIO1(GUIO_NONE) + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) }, GID_GRANDINQUISITOR }, @@ -122,7 +126,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, - GUIO1(GUIO_NONE) + GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) }, GID_GRANDINQUISITOR }, @@ -140,23 +144,43 @@ static const char *directoryGlobs[] = { 0 }; -static const ExtraGuiOption ZVisionExtraGuiOption = { - _s("Use original save/load screens"), - _s("Use the original save/load screens, instead of the ScummVM ones"), - "originalsaveload", - false -}; +static const ADExtraGuiOptionsMap optionsList[] = { + { + GAMEOPTION_ORIGINAL_SAVELOAD, + { + _s("Use original save/load screens"), + _s("Use the original save/load screens, instead of the ScummVM ones"), + "originalsaveload", + false + } + }, -static const ExtraGuiOption ZVisionExtraGuiOption2 = { - _s("Double FPS"), - _s("Halve the update delay"), - "doublefps", - false + { + GAMEOPTION_DOUBLE_FPS, + { + _s("Double FPS"), + _s("Halve the update delay"), + "doublefps", + false + } + }, + + { + GAMEOPTION_ENABLE_VENUS, + { + _s("Enable Venus"), + _s("Enable the Venus help system"), + "venusenabled", + true + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR }; class ZVisionMetaEngine : public AdvancedMetaEngine { public: - ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames) { + ZVisionMetaEngine() : AdvancedMetaEngine(ZVision::gameDescriptions, sizeof(ZVision::ZVisionGameDescription), zVisionGames, optionsList) { _maxScanDepth = 2; _directoryGlobs = directoryGlobs; _singleid = "zvision"; @@ -172,7 +196,6 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; - virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const; SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; void removeSaveState(const char *target, int slot) const; @@ -223,13 +246,6 @@ bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG return gd != 0; } -const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String &target) const { - ExtraGuiOptions options; - options.push_back(ZVisionExtraGuiOption); - options.push_back(ZVisionExtraGuiOption2); - return options; -} - SaveStateList ZVisionMetaEngine::listSaves(const char *target) const { Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); ZVision::SaveGameHeader header; diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 7c26eba030..5f4924d7cf 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -57,25 +57,29 @@ namespace ZVision { struct zvisionIniSettings { const char *name; int16 slot; - int16 deflt; + int16 defaultValue; // -1: use the bool value + bool defaultBoolValue; + bool allowEditing; } settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { - {"ZVision_KeyboardTurnSpeed", StateKey_KbdRotateSpeed, 5}, - {"ZVision_PanaRotateSpeed", StateKey_RotateSpeed, 540}, - {"ZVision_QSoundEnabled", StateKey_Qsound, 1}, - {"ZVision_VenusEnabled", StateKey_VenusEnable, 1}, - {"ZVision_HighQuality", StateKey_HighQuality, 1}, - {"ZVision_Platform", StateKey_Platform, 0}, - {"ZVision_InstallLevel", StateKey_InstallLevel, 0}, - {"ZVision_CountryCode", StateKey_CountryCode, 0}, - {"ZVision_CPU", StateKey_CPU, 1}, - {"ZVision_MovieCursor", StateKey_MovieCursor, 1}, - {"ZVision_NoAnimWhileTurning", StateKey_NoTurnAnim, 0}, - {"ZVision_Win958", StateKey_WIN958, 0}, - {"ZVision_ShowErrorDialogs", StateKey_ShowErrorDlg, 0}, - {"ZVision_ShowSubtitles", StateKey_Subtitles, 1}, - {"ZVision_DebugCheats", StateKey_DebugCheats, 0}, - {"ZVision_JapaneseFonts", StateKey_JapanFonts, 0}, - {"ZVision_Brightness", StateKey_Brightness, 0} + // Hardcoded settings + {"qsoundenabled", StateKey_Qsound, 1, false, false}, + {"highquality", StateKey_HighQuality, 1, false, false}, + {"platform", StateKey_Platform, 0, false, false}, + {"installlevel", StateKey_InstallLevel, 0, false, false}, + {"countrycode", StateKey_CountryCode, 0, false, false}, + {"cpu", StateKey_CPU, 1, false, false}, + {"moviecursor", StateKey_MovieCursor, 1, false, false}, + {"noanimwhileturning", StateKey_NoTurnAnim, 0, false, false}, + {"win958", StateKey_WIN958, 0, false, false}, + {"showerrordialogs", StateKey_ShowErrorDlg, 0, false, false}, + {"japanesefonts", StateKey_JapanFonts, 0, false, false}, + {"brightness", StateKey_Brightness, 0, false, false}, + {"debugcheats", StateKey_DebugCheats, 1, false, false}, + // Editable settings + {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, + {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, + {"venusenabled", StateKey_VenusEnable, -1, true, true}, + {"subtitles", StateKey_Subtitles, -1, true, true}, }; ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) @@ -139,14 +143,33 @@ ZVision::~ZVision() { } void ZVision::registerDefaultSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) - ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].deflt); + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue); + else + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue); + } + } + + ConfMan.registerDefault("originalsaveload", false); ConfMan.registerDefault("doublefps", false); } void ZVision::loadSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) - _scriptManager->setStateValue(settingsKeys[i].slot, ConfMan.getInt(settingsKeys[i].name)); + int16 value = 0; + bool boolValue = false; + + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].defaultValue >= 0) { + value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; + } else { + boolValue = value = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; + value = (boolValue) ? 1 : 0; + } + + _scriptManager->setStateValue(settingsKeys[i].slot, value); + } if (getGameId() == GID_NEMESIS) _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); @@ -155,8 +178,15 @@ void ZVision::loadSettings() { } void ZVision::saveSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) - ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); + else + ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1)); + } + } + ConfMan.flushToDisk(); } -- cgit v1.2.3 From e862172460640188363873b9fa1fb46a3f4c7f78 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 14:29:17 +0200 Subject: ZVISION: Add some advanced engine features, and document the engine --- engines/zvision/zvision.cpp | 10 ++++++++++ engines/zvision/zvision.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 5f4924d7cf..03103553cc 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -345,6 +345,16 @@ bool ZVision::canRender() { return _frameRenderDelay <= 0; } +GUI::Debugger *ZVision::getDebugger() { + return _console; +} + +void ZVision::syncSoundSettings() { + Engine::syncSoundSettings(); + + _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0); +} + void ZVision::fpsTimerCallback(void *refCon) { ((ZVision *)refCon)->fpsTimer(); } diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h index 5482060cd0..ad22ddaaa2 100644 --- a/engines/zvision/zvision.h +++ b/engines/zvision/zvision.h @@ -41,6 +41,17 @@ namespace Video { class VideoDecoder; } +/** + * This is the namespace of the ZVision engine. + * + * Status of this engine: complete + * + * Games using this engine: + * - Zork Nemesis: The Forbidden Lands + * - Zork: Grand Inquisitor + * + */ + namespace ZVision { struct ZVisionGameDescription; @@ -205,6 +216,9 @@ public: return _fps; } + GUI::Debugger *getDebugger(); + void syncSoundSettings(); + void loadSettings(); void saveSettings(); -- cgit v1.2.3 From 39eab59388c6dc43d1f2c72ee708807ef1bdb198 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Dec 2014 15:31:43 +0100 Subject: ACCESS: Rewrite sound queueing (WIP) --- engines/access/amazon/amazon_logic.cpp | 52 ++++++++++++++++++---------------- engines/access/events.cpp | 2 ++ engines/access/sound.cpp | 50 ++++++++++++++++++++------------ engines/access/sound.h | 5 +++- 4 files changed, 66 insertions(+), 43 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 4a313e8880..c045377f8a 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -341,15 +341,12 @@ void Opening::doTitle() { _vm->_objectsTable[0] = new SpriteResource(_vm, spriteData); delete spriteData; - _vm->_sound->playSound(1); - _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 4); _vm->_sound->playSound(1); _vm->_buffer2.copyFrom(*_vm->_screen); _vm->_buffer1.copyFrom(*_vm->_screen); - _vm->_sound->playSound(1); const int COUNTDOWN[6] = { 2, 0x80, 1, 0x7d, 0, 0x87 }; for (_pCount = 0; _pCount < 3 && !_vm->shouldQuit(); ++_pCount) { @@ -508,40 +505,47 @@ void Opening::doTent() { _vm->_screen->forceFadeIn(); _vm->_video->setVideo(_vm->_screen, Common::Point(126, 73), FileIdent(2, 1), 10); + int previousFrame = -1; while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { _vm->_video->playVideo(); - if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34)) - _vm->_sound->playSound(4); - else if (_vm->_video->_videoFrame == 36) { - if (step != 2) { - _vm->_sound->playSound(2); - step = 2; - } - } else if (_vm->_video->_videoFrame == 18) { - if (step != 1) { - _vm->_midi->newMusic(73, 1); - _vm->_midi->newMusic(11, 0); - step = 1; - _vm->_sound->playSound(1); + if (previousFrame != _vm->_video->_videoFrame) { + previousFrame = _vm->_video->_videoFrame; + + if ((_vm->_video->_videoFrame == 32) || (_vm->_video->_videoFrame == 34)) + _vm->_sound->playSound(4); + else if (_vm->_video->_videoFrame == 36) { + if (step != 2) { + _vm->_sound->playSound(2); + step = 2; + } + } else if (_vm->_video->_videoFrame == 18) { + if (step != 1) { + _vm->_midi->newMusic(73, 1); + _vm->_midi->newMusic(11, 0); + step = 1; + _vm->_sound->playSound(1); + } } } - _vm->_events->pollEventsAndWait(); } _vm->_sound->playSound(5); _vm->_video->setVideo(_vm->_screen, Common::Point(43, 11), FileIdent(2, 2), 10); + previousFrame = -1; while (!_vm->shouldQuit() && !_vm->_video->_videoEnd) { _vm->_video->playVideo(); - if (_vm->_video->_videoFrame == 26) { - _vm->_sound->playSound(5); - } else if (_vm->_video->_videoFrame == 15) { - if (step !=3) { - _vm->_sound->playSound(3); - step = 3; + if (previousFrame != _vm->_video->_videoFrame) { + previousFrame = _vm->_video->_videoFrame; + if (_vm->_video->_videoFrame == 26) { + _vm->_sound->playSound(5); + } else if (_vm->_video->_videoFrame == 15) { + if (step !=3) { + _vm->_sound->playSound(3); + step = 3; + } } } - _vm->_events->pollEventsAndWait(); } diff --git a/engines/access/events.cpp b/engines/access/events.cpp index 0867b09765..6ffe67acfb 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -140,6 +140,8 @@ void EventsManager::pollEvents(bool skipTimers) { if (checkForNextTimerUpdate() && !skipTimers) nextTimer(); + _vm->_sound->checkSoundQueue(); + _wheelUp = _wheelDown = false; Common::Event event; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index a7d96dac9a..82199a8286 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -22,7 +22,6 @@ #include "common/algorithm.h" #include "audio/mixer.h" -#include "audio/audiostream.h" #include "audio/decoders/raw.h" #include "audio/decoders/wave.h" #include "access/access.h" @@ -44,7 +43,19 @@ void SoundManager::clearSounds() { for (uint i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]._res; + _soundTable.clear(); + + if (_mixer->isSoundHandleActive(_effectsHandle)) + _mixer->stopHandle(_effectsHandle); + + if (_queue.size()) + _queue.remove_at(0); + + while (_queue.size()) { + delete _queue[0]; + _queue.remove_at(0); + } } void SoundManager::queueSound(int idx, int fileNum, int subfile) { @@ -77,19 +88,14 @@ void SoundManager::playSound(Resource *res, int priority) { debugC(1, kDebugSound, "playSound"); byte *resourceData = res->data(); - Audio::SoundHandle audioHandle; - Audio::RewindableAudioStream *audioStream = 0; assert(res->_size >= 32); - // HACK: Simulates queueing for the rare sounds played one after the other - while (_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType)) - ; - if (READ_BE_UINT32(resourceData) == MKTAG('R','I','F','F')) { // CD version uses WAVE-files Common::SeekableReadStream *waveStream = new Common::MemoryReadStream(resourceData, res->_size, DisposeAfterUse::NO); - audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); + Audio::RewindableAudioStream *audioStream = Audio::makeWAVStream(waveStream, DisposeAfterUse::YES); + _queue.push_back(audioStream); } else if (READ_BE_UINT32(resourceData) == MKTAG('S', 'T', 'E', 'V')) { // sound files have a fixed header of 32 bytes in total @@ -130,22 +136,30 @@ void SoundManager::playSound(Resource *res, int priority) { return; } - audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); + Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); + _queue.push_back(audioStream); } else error("Unknown format"); - audioHandle = Audio::SoundHandle(); - _mixer->playStream(Audio::Mixer::kSFXSoundType, &audioHandle, - audioStream, -1, _mixer->kMaxChannelVolume, 0, + if (!_mixer->isSoundHandleActive(_effectsHandle)) + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, + _queue[0], -1, _mixer->kMaxChannelVolume, 0, DisposeAfterUse::NO); +} + +void SoundManager::checkSoundQueue() { + debugC(5, kDebugSound, "checkSoundQueue"); + + if (_queue.empty() || _mixer->isSoundHandleActive(_effectsHandle)) + return; + + _queue.remove_at(0); - /* - Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); - audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, audioStream, -1, - Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::YES, false); - */ + if (_queue.size()) + _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, + _queue[0], -1, _mixer->kMaxChannelVolume, 0, + DisposeAfterUse::YES); } void SoundManager::loadSounds(Common::Array &sounds) { diff --git a/engines/access/sound.h b/engines/access/sound.h index d0f4584fac..c276648477 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -24,6 +24,7 @@ #define ACCESS_SOUND_H #include "common/scummsys.h" +#include "audio/audiostream.h" #include "audio/mixer.h" #include "access/files.h" #include "audio/midiplayer.h" @@ -47,7 +48,8 @@ class SoundManager { private: AccessEngine *_vm; Audio::Mixer *_mixer; - Audio::SoundHandle _soundHandle; + Audio::SoundHandle _effectsHandle; + Common::Array _queue; void clearSounds(); @@ -63,6 +65,7 @@ public: void queueSound(int idx, int fileNum, int subfile); void playSound(int soundIndex); + void checkSoundQueue(); Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); -- cgit v1.2.3 From 1016838bd5e556a4882f2b07e993ea9e78d12f7f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 16:33:43 +0200 Subject: ZVISION: Add support for disabling animations while turning Also, clean up and document game configuration options, and add a TODO for QSound support --- engines/zvision/detection.cpp | 27 ++++++++++++++------ .../zvision/scripting/sidefx/animation_node.cpp | 25 +++++++++++++------ engines/zvision/scripting/sidefx/distort_node.cpp | 1 - engines/zvision/zvision.cpp | 29 +++++++++++----------- 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp index c613278fec..1eaff83413 100644 --- a/engines/zvision/detection.cpp +++ b/engines/zvision/detection.cpp @@ -55,9 +55,10 @@ static const PlainGameDescriptor zVisionGames[] = { namespace ZVision { -#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 -#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2 -#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3 +#define GAMEOPTION_ORIGINAL_SAVELOAD GUIO_GAMEOPTIONS1 +#define GAMEOPTION_DOUBLE_FPS GUIO_GAMEOPTIONS2 +#define GAMEOPTION_ENABLE_VENUS GUIO_GAMEOPTIONS3 +#define GAMEOPTION_DISABLE_ANIM_WHILE_TURNING GUIO_GAMEOPTIONS4 static const ZVisionGameDescription gameDescriptions[] = { @@ -70,7 +71,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformDOS, ADGF_NO_FLAGS, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS) + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) }, GID_NEMESIS }, @@ -84,7 +85,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, - GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS) + GUIO4(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_ENABLE_VENUS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) }, GID_NEMESIS }, @@ -98,7 +99,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, - GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) }, GID_GRANDINQUISITOR }, @@ -112,7 +113,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_NO_FLAGS, - GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) }, GID_GRANDINQUISITOR }, @@ -126,7 +127,7 @@ static const ZVisionGameDescription gameDescriptions[] = { Common::EN_ANY, Common::kPlatformWindows, ADGF_DEMO, - GUIO2(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS) + GUIO3(GAMEOPTION_ORIGINAL_SAVELOAD, GAMEOPTION_DOUBLE_FPS, GAMEOPTION_DISABLE_ANIM_WHILE_TURNING) }, GID_GRANDINQUISITOR }, @@ -175,6 +176,16 @@ static const ADExtraGuiOptionsMap optionsList[] = { } }, + { + GAMEOPTION_DISABLE_ANIM_WHILE_TURNING, + { + _s("Disable animation while turning"), + _s("Disable animation while turning in panoramic mode"), + "noanimwhileturning", + false + } + }, + AD_EXTRA_GUI_OPTIONS_TERMINATOR }; diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 7759758f56..3dd80f3699 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -75,6 +75,17 @@ AnimationNode::~AnimationNode() { } bool AnimationNode::process(uint32 deltaTimeInMillis) { + ScriptManager *scriptManager = _engine->getScriptManager(); + RenderManager *renderManager = _engine->getRenderManager(); + RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState(); + bool isPanorama = (renderState == RenderTable::PANORAMA); + int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity(); + + // Do not update animation nodes in panoramic mode while turning, if the user + // has set this option + if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity) + return false; + PlayNodes::iterator it = _playList.begin(); if (it != _playList.end()) { playnode *nod = &(*it); @@ -93,7 +104,7 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { nod->_delay = _frmDelay; if (nod->slot) - _engine->getScriptManager()->setStateValue(nod->slot, 1); + scriptManager->setStateValue(nod->slot, 1); } else { nod->_curFrame++; @@ -102,7 +113,7 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (nod->loop == 0) { if (nod->slot >= 0) - _engine->getScriptManager()->setStateValue(nod->slot, 2); + scriptManager->setStateValue(nod->slot, 2); if (nod->_scaled) { nod->_scaled->free(); delete nod->_scaled; @@ -121,7 +132,7 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (frame) { uint32 dstw; uint32 dsth; - if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + if (isPanorama) { dstw = nod->pos.height(); dsth = nod->pos.width(); } else { @@ -148,17 +159,17 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { nod->_scaled->create(dstw, dsth, frame->format); } - _engine->getRenderManager()->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); + renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); frame = nod->_scaled; } - if (_engine->getRenderManager()->getRenderTable()->getRenderState() == RenderTable::PANORAMA) { + if (isPanorama) { Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); - _engine->getRenderManager()->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); + renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); transposed->free(); delete transposed; } else { - _engine->getRenderManager()->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); + renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); } } } diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp index 0d5c8b1ed5..7d25adc031 100644 --- a/engines/zvision/scripting/sidefx/distort_node.cpp +++ b/engines/zvision/scripting/sidefx/distort_node.cpp @@ -65,7 +65,6 @@ DistortNode::~DistortNode() { } bool DistortNode::process(uint32 deltaTimeInMillis) { - float updTime = deltaTimeInMillis / (1000.0 / 60.0); if (_incr) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 03103553cc..a28ad862d9 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -62,22 +62,23 @@ struct zvisionIniSettings { bool allowEditing; } settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { // Hardcoded settings - {"qsoundenabled", StateKey_Qsound, 1, false, false}, - {"highquality", StateKey_HighQuality, 1, false, false}, - {"platform", StateKey_Platform, 0, false, false}, - {"installlevel", StateKey_InstallLevel, 0, false, false}, - {"countrycode", StateKey_CountryCode, 0, false, false}, - {"cpu", StateKey_CPU, 1, false, false}, - {"moviecursor", StateKey_MovieCursor, 1, false, false}, - {"noanimwhileturning", StateKey_NoTurnAnim, 0, false, false}, - {"win958", StateKey_WIN958, 0, false, false}, - {"showerrordialogs", StateKey_ShowErrorDlg, 0, false, false}, - {"japanesefonts", StateKey_JapanFonts, 0, false, false}, - {"brightness", StateKey_Brightness, 0, false, false}, - {"debugcheats", StateKey_DebugCheats, 1, false, false}, + //{"platform", StateKey_Platform, 0, false, false}, // 0 = Windows, 1 = DOS, 2 = DOS, unused + //{"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, unused + //{"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, unused + //{"cpu", StateKey_CPU, 1, false, false}, // always 1 = Pentium (0 is 486), unused + //{"win958", StateKey_WIN958, 0, false, false}, // unused, probably Windows version flag + //{"showerrordialogs", StateKey_ShowErrorDlg, 0, false, false}, // unused + //{"japanesefonts", StateKey_JapanFonts, 0, false, false}, + //{"brightness", StateKey_Brightness, 0, false, false}, + //{"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused + //{"highquality", StateKey_HighQuality, 0, false, false}, // performance related, always high + //{"moviecursor", StateKey_MovieCursor, 0, false, false}, // show mouse cursor in movies, unused + {"qsoundenabled", StateKey_Qsound, 1, false, false}, // 1 = enable QSound - TODO: not supported yet + {"debugcheats", StateKey_DebugCheats, 1, false, false}, // always start with the GOxxxx cheat enabled // Editable settings {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, + {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation {"venusenabled", StateKey_VenusEnable, -1, true, true}, {"subtitles", StateKey_Subtitles, -1, true, true}, }; @@ -164,7 +165,7 @@ void ZVision::loadSettings() { if (settingsKeys[i].defaultValue >= 0) { value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; } else { - boolValue = value = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; + boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; value = (boolValue) ? 1 : 0; } -- cgit v1.2.3 From b3712cc877482e150a3532fa0f21f5c03dc839f1 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sat, 27 Dec 2014 16:36:41 +0200 Subject: ZVISION: Remove dead code (uint is always > 0) --- engines/zvision/video/rlf_decoder.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 260f912ade..1478822d00 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -164,11 +164,6 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { if ((uint)_curFrame == frame) return true; - if (frame < 0) { - _curFrame = 0; - return false; - } - int closestFrame = _curFrame; int distance = (int)frame - _curFrame; -- cgit v1.2.3 From 6fe9bdf6c6f63320e351c348970c2864af708c42 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Dec 2014 16:05:23 +0100 Subject: ACCESS: Fix speech --- engines/access/access.cpp | 6 ++++-- engines/access/sound.cpp | 4 ++++ engines/access/sound.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 67255ff5ea..080a8ef975 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -227,7 +227,8 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _sound->playSound(0); _scripts->cmdFreeSound(); - _events->pollEvents(); + while(_sound->isSFXPlaying() && !shouldQuit()) + _events->pollEvents(); if (_events->isKeyMousePressed()) { _sndSubFile += soundsLeft; @@ -258,7 +259,8 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _sound->playSound(0); _scripts->cmdFreeSound(); - _events->pollEvents(); + while(_sound->isSFXPlaying() && !shouldQuit()) + _events->pollEvents(); if (_events->_leftButton) { _events->debounceLeft(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 82199a8286..cfc8b7a64c 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -162,6 +162,10 @@ void SoundManager::checkSoundQueue() { DisposeAfterUse::YES); } +bool SoundManager::isSFXPlaying() { + return _mixer->isSoundHandleActive(_effectsHandle); +} + void SoundManager::loadSounds(Common::Array &sounds) { debugC(1, kDebugSound, "loadSounds"); diff --git a/engines/access/sound.h b/engines/access/sound.h index c276648477..3646c2cc16 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -66,6 +66,7 @@ public: void playSound(int soundIndex); void checkSoundQueue(); + bool isSFXPlaying(); Resource *loadSound(int fileNum, int subfile); void loadSounds(Common::Array &sounds); -- cgit v1.2.3 From 3c3ff0a3aab13b876e0425c365402ff334743282 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Dec 2014 16:46:33 +0100 Subject: ACCESS: Remove two useless variables --- engines/access/scripts.cpp | 2 +- engines/access/sound.cpp | 2 -- engines/access/sound.h | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 074c781352..1bd24894d7 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -794,7 +794,7 @@ void Scripts::cmdFreeSound() { charLoop(); _vm->_events->pollEvents(); - } while (!_vm->shouldQuit() && sound._playingSound); + } while (!_vm->shouldQuit() && sound.isSFXPlaying()); // Free the sounds while (sound._soundTable.size() > 0) { diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index cfc8b7a64c..fc574dc083 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -30,8 +30,6 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { - _playingSound = false; - _isVoice = false; } SoundManager::~SoundManager() { diff --git a/engines/access/sound.h b/engines/access/sound.h index 3646c2cc16..384e9ac615 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -56,8 +56,6 @@ private: void playSound(Resource *res, int priority); public: Common::Array _soundTable; - bool _playingSound; - bool _isVoice; public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); -- cgit v1.2.3 From 6a7834a05ed880cba32f0adb87950179c4ec404c Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Dec 2014 16:55:07 +0100 Subject: ACCESS: Rename loadSoundTable --- engines/access/amazon/amazon_logic.cpp | 4 ++-- engines/access/amazon/amazon_scripts.cpp | 2 +- engines/access/sound.cpp | 4 ++-- engines/access/sound.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index c045377f8a..82f0edfa6e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -317,8 +317,8 @@ void Opening::doTitle() { _vm->_events->hideCursor(); if (!_vm->isDemo()) { - _vm->_sound->queueSound(0, 98, 30); - _vm->_sound->queueSound(1, 98, 8); + _vm->_sound->loadSoundTable(0, 98, 30); + _vm->_sound->loadSoundTable(1, 98, 8); _vm->_files->_setPaletteFlag = false; _vm->_files->loadScreen(0, 3); diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 0b2ddbc854..92acb3686d 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -95,7 +95,7 @@ void AmazonScripts::mWhile1() { _vm->_oldRects.clear(); _sequence = 2200; - _vm->_sound->queueSound(0, 14, 15); + _vm->_sound->loadSoundTable(0, 14, 15); do { cLoop(); diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index fc574dc083..53b611b65b 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -56,8 +56,8 @@ void SoundManager::clearSounds() { } } -void SoundManager::queueSound(int idx, int fileNum, int subfile) { - debugC(1, kDebugSound, "queueSound(%d, %d, %d)", idx, fileNum, subfile); +void SoundManager::loadSoundTable(int idx, int fileNum, int subfile) { + debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile); Resource *soundResource; diff --git a/engines/access/sound.h b/engines/access/sound.h index 384e9ac615..7109438f43 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -60,7 +60,7 @@ public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); - void queueSound(int idx, int fileNum, int subfile); + void loadSoundTable(int idx, int fileNum, int subfile); void playSound(int soundIndex); void checkSoundQueue(); -- cgit v1.2.3 From 576bab349c862b16fcca1e9e0fb3fbb52cc6edc4 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 27 Dec 2014 17:21:04 +0100 Subject: ACCESS: Use loadSoundTable instead of push_back in several places --- engines/access/access.cpp | 9 +++++---- engines/access/amazon/amazon_game.cpp | 4 ++-- engines/access/amazon/amazon_logic.cpp | 12 ++++++------ engines/access/sound.cpp | 4 ++-- engines/access/sound.h | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 080a8ef975..7f59ae7ad6 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -222,14 +222,14 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { _events->clearEvents(); while (!shouldQuit()) { _sound->freeSounds(); - Resource *sound = _sound->loadSound(_narateFile + 99, _sndSubFile); - _sound->_soundTable.push_back(SoundEntry(sound, 1)); + _sound->loadSoundTable(0, _narateFile + 99, _sndSubFile); _sound->playSound(0); - _scripts->cmdFreeSound(); while(_sound->isSFXPlaying() && !shouldQuit()) _events->pollEvents(); + _scripts->cmdFreeSound(); + if (_events->isKeyMousePressed()) { _sndSubFile += soundsLeft; break; @@ -257,11 +257,12 @@ void AccessEngine::speakText(ASurface *s, const Common::String &msg) { Resource *res = _sound->loadSound(_narateFile + 99, _sndSubFile); _sound->_soundTable.push_back(SoundEntry(res, 1)); _sound->playSound(0); - _scripts->cmdFreeSound(); while(_sound->isSFXPlaying() && !shouldQuit()) _events->pollEvents(); + _scripts->cmdFreeSound(); + if (_events->_leftButton) { _events->debounceLeft(); _sndSubFile += soundsLeft; diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index d6b759b308..4c9df7b8ff 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -528,8 +528,8 @@ void AmazonEngine::startChapter(int chapter) { _sound->freeSounds(); if (isCD()) { - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 0), 1)); - _sound->_soundTable.push_back(SoundEntry(_sound->loadSound(115, 1), 1)); + _sound->loadSoundTable(0, 115, 0); + _sound->loadSoundTable(1, 115, 1); _sound->playSound(0); _sound->playSound(1); diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 82f0edfa6e..6dffb85e5e 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -490,12 +490,12 @@ void Opening::doTent() { _vm->_screen->setDisplayScan(); _vm->_screen->forceFadeOut(); _vm->_events->hideCursor(); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 39), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 14), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 15), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 16), 1)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 31), 2)); - _vm->_sound->_soundTable.push_back(SoundEntry(_vm->_sound->loadSound(98, 52), 2)); + _vm->_sound->loadSoundTable(0, 98, 39); + _vm->_sound->loadSoundTable(1, 98, 14); + _vm->_sound->loadSoundTable(2, 98, 15); + _vm->_sound->loadSoundTable(3, 98, 16); + _vm->_sound->loadSoundTable(4, 98, 31, 2); + _vm->_sound->loadSoundTable(5, 98, 52, 2); _vm->_sound->playSound(0); _vm->_files->_setPaletteFlag = false; diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 53b611b65b..221b409aa9 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -56,7 +56,7 @@ void SoundManager::clearSounds() { } } -void SoundManager::loadSoundTable(int idx, int fileNum, int subfile) { +void SoundManager::loadSoundTable(int idx, int fileNum, int subfile, int priority) { debugC(1, kDebugSound, "loadSoundTable(%d, %d, %d)", idx, fileNum, subfile); Resource *soundResource; @@ -67,7 +67,7 @@ void SoundManager::loadSoundTable(int idx, int fileNum, int subfile) { delete _soundTable[idx]._res; soundResource = _vm->_files->loadFile(fileNum, subfile); _soundTable[idx]._res = soundResource; - _soundTable[idx]._priority = 1; + _soundTable[idx]._priority = priority; } Resource *SoundManager::loadSound(int fileNum, int subfile) { diff --git a/engines/access/sound.h b/engines/access/sound.h index 7109438f43..90f6656e26 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -60,7 +60,7 @@ public: SoundManager(AccessEngine *vm, Audio::Mixer *mixer); ~SoundManager(); - void loadSoundTable(int idx, int fileNum, int subfile); + void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1); void playSound(int soundIndex); void checkSoundQueue(); -- cgit v1.2.3 From 99fabffde0c8f88d02bba341cd9d504483b86409 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 27 Dec 2014 20:51:39 +0200 Subject: ZVISION: Clean up settings and initialize the ones used by game scripts --- engines/zvision/zvision.cpp | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index a28ad862d9..0d06f3ce90 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -52,7 +52,7 @@ namespace ZVision { -#define ZVISION_SETTINGS_KEYS_COUNT 17 +#define ZVISION_SETTINGS_KEYS_COUNT 11 struct zvisionIniSettings { const char *name; @@ -62,25 +62,18 @@ struct zvisionIniSettings { bool allowEditing; } settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { // Hardcoded settings - //{"platform", StateKey_Platform, 0, false, false}, // 0 = Windows, 1 = DOS, 2 = DOS, unused - //{"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, unused - //{"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, unused - //{"cpu", StateKey_CPU, 1, false, false}, // always 1 = Pentium (0 is 486), unused - //{"win958", StateKey_WIN958, 0, false, false}, // unused, probably Windows version flag - //{"showerrordialogs", StateKey_ShowErrorDlg, 0, false, false}, // unused - //{"japanesefonts", StateKey_JapanFonts, 0, false, false}, - //{"brightness", StateKey_Brightness, 0, false, false}, - //{"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused - //{"highquality", StateKey_HighQuality, 0, false, false}, // performance related, always high - //{"moviecursor", StateKey_MovieCursor, 0, false, false}, // show mouse cursor in movies, unused - {"qsoundenabled", StateKey_Qsound, 1, false, false}, // 1 = enable QSound - TODO: not supported yet - {"debugcheats", StateKey_DebugCheats, 1, false, false}, // always start with the GOxxxx cheat enabled + {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused + {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused + {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr + {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused + {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet + {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled // Editable settings {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, - {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, + {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation {"venusenabled", StateKey_VenusEnable, -1, true, true}, - {"subtitles", StateKey_Subtitles, -1, true, true}, + {"subtitles", StateKey_Subtitles, -1, true, true} }; ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) -- cgit v1.2.3 From 58f328b9af50d66bf8d1be1b19e6059f706ef226 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 22:22:28 +0100 Subject: ZVISION: Slightly clarify font error message --- engines/zvision/zvision.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 0d06f3ce90..88cc1e2fea 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -258,12 +258,12 @@ Common::Error ZVision::run() { if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf")) { GUI::MessageDialog dialog( "Before playing this game, you'll need to copy the required " - "fonts in ScummVM's extras directory, or the game directory. " + "fonts into ScummVM's extras directory, or into the game directory. " "On Windows, you'll need the following font files from the Windows " "font directory: Times New Roman, Century Schoolbook, Garamond, " "Courier New and Arial. Alternatively, you can download the GNU " "FreeFont package. You'll need all the fonts from that package, " - "i.e. FreeMono, FreeSans and FreeSerif." + "i.e., FreeMono, FreeSans and FreeSerif." ); dialog.runModal(); quitGame(); -- cgit v1.2.3 From 02eada1d0ddd5f5c179ca39840bb7f73286df6e1 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:12:54 +0100 Subject: ZVISION: Fix Zork AVI audio on BE systems --- engines/zvision/video/zork_avi_decoder.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index 67fab0a114..5618250d79 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -45,8 +45,14 @@ void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *s RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream); delete stream; - if (chunk.data) - _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_STEREO); + if (chunk.data) { + byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; +#ifdef SCUMM_LITTLE_ENDIAN + // RawChunkStream produces native endianness int16 + flags |= Audio::FLAG_LITTLE_ENDIAN; +#endif + _audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); + } } else { AVIAudioTrack::queueSound(stream); } -- cgit v1.2.3 From 5791f600e9b9808714b40a63acd09b5657c855f5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:35:35 +0100 Subject: ZVISION: Fix TGZ images on BE systems --- engines/zvision/graphics/render_manager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 4f26123fc8..a178c97639 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -209,13 +209,17 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: isTGZ = true; // TGZ files have a header and then Bitmap data that is compressed with LZSS - uint32 decompressedSize = file.readSint32LE(); + uint32 decompressedSize = file.readSint32LE() / 2; imageWidth = file.readSint32LE(); imageHeight = file.readSint32LE(); LzssReadStream lzssStream(&file); buffer = (uint16 *)(new uint16[decompressedSize]); - lzssStream.read(buffer, decompressedSize); + lzssStream.read(buffer, 2 * decompressedSize); +#ifndef SCUMMVM_LITTLE_ENDIAN + for (uint32 i = 0; i < decompressedSize; ++i) + buffer[i] = FROM_LE_16(buffer[i]); +#endif } else { isTGZ = false; -- cgit v1.2.3 From cd595cb0ea65b5bd8b79cb7af35457d032d82e98 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:35:47 +0100 Subject: ZVISION: Fix cursors on BE systems --- engines/zvision/graphics/cursors/cursor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp index eb25e92860..1b471d88b8 100644 --- a/engines/zvision/graphics/cursors/cursor.cpp +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -60,6 +60,12 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) _surface.create(_width, _height, engine->_resourcePixelFormat); uint32 bytesRead = file.read(_surface.getPixels(), dataSize); assert(bytesRead == dataSize); + +#ifndef SCUMMVM_LITTLE_ENDIAN + int16 *buffer = (int16 *)_surface.getPixels(); + for (uint32 i = 0; i < dataSize / 2; ++i) + buffer[i] = FROM_LE_16(buffer[i]); +#endif } ZorkCursor::ZorkCursor(const ZorkCursor &other) { -- cgit v1.2.3 From 4931aee954704a7ee984ce8cee85bdbec3ddb640 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:51:59 +0100 Subject: ZVISION: Fix typo --- engines/zvision/graphics/cursors/cursor.cpp | 2 +- engines/zvision/graphics/render_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/graphics/cursors/cursor.cpp b/engines/zvision/graphics/cursors/cursor.cpp index 1b471d88b8..f32c68645d 100644 --- a/engines/zvision/graphics/cursors/cursor.cpp +++ b/engines/zvision/graphics/cursors/cursor.cpp @@ -61,7 +61,7 @@ ZorkCursor::ZorkCursor(ZVision *engine, const Common::String &fileName) uint32 bytesRead = file.read(_surface.getPixels(), dataSize); assert(bytesRead == dataSize); -#ifndef SCUMMVM_LITTLE_ENDIAN +#ifndef SCUMM_LITTLE_ENDIAN int16 *buffer = (int16 *)_surface.getPixels(); for (uint32 i = 0; i < dataSize / 2; ++i) buffer[i] = FROM_LE_16(buffer[i]); diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index a178c97639..033d099042 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -216,7 +216,7 @@ void RenderManager::readImageToSurface(const Common::String &fileName, Graphics: LzssReadStream lzssStream(&file); buffer = (uint16 *)(new uint16[decompressedSize]); lzssStream.read(buffer, 2 * decompressedSize); -#ifndef SCUMMVM_LITTLE_ENDIAN +#ifndef SCUMM_LITTLE_ENDIAN for (uint32 i = 0; i < decompressedSize; ++i) buffer[i] = FROM_LE_16(buffer[i]); #endif -- cgit v1.2.3 From c823a6e825a6474c75f1ddecfcb67a602393fae6 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 27 Dec 2014 23:52:18 +0100 Subject: ZVISION: Fix cmdRawToWav on BE systems --- engines/zvision/core/console.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index c7592c8d9d..b5e542d777 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -138,6 +138,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { output.writeUint32LE(file.size() * 2); int16 *buffer = new int16[file.size()]; audioStream->readBuffer(buffer, file.size()); +#ifndef SCUMM_LITTLE_ENDIAN + for (int i = 0; i < file.size(); ++i) + buffer[i] = TO_LE_16(buffer[i]); +#endif output.write(buffer, file.size() * 2); delete[] buffer; -- cgit v1.2.3 From 329c9386c6db79b3c52fbd6712f3ae1718d04c1f Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 28 Dec 2014 00:22:30 +0100 Subject: SCI: improve kPortrait debug support + fix --- engines/sci/graphics/portrait.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp index 959c0f6817..3311f47022 100644 --- a/engines/sci/graphics/portrait.cpp +++ b/engines/sci/graphics/portrait.cpp @@ -230,7 +230,7 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint debugPrint[raveResource->size] = 0; // set terminating NUL debug("kPortrait: using actor %s", _resourceName.c_str()); debug("kPortrait (noun %d, verb %d, cond %d, seq %d)", noun, verb, cond, seq); - debug("kPortrait: %s", debugPrint); + debug("kPortrait: rave data is '%s'", debugPrint); } #endif @@ -301,7 +301,11 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint } #ifdef DEBUG_PORTRAIT - debug("kPortrait: %d: %x", raveTicks, raveID); + if (raveID & 0x0ff) { + debug("kPortrait: rave '%c%c' after %d ticks", raveID >> 8, raveID & 0x0ff, raveTicks); + } else if (raveID) { + debug("kPortrait: rave '%c' after %d ticks", raveID >> 8, raveTicks); + } #endif timerPosition += raveTicks; @@ -325,10 +329,9 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint // Tick = 0xFF is the terminator for the data timerPositionWithin = timerPosition; raveLipSyncTicks = *raveLipSyncData++; -#ifdef DEBUG_PORTRAIT - debug("kPortrait: waiting %d", raveLipSyncTicks); -#endif while ( (raveLipSyncData < _lipSyncDataOffsetTableEnd) && (raveLipSyncTicks != 0xFF) ) { + if (raveLipSyncTicks) + raveLipSyncTicks--; // 1 -> wait 0 ticks, 2 -> wait 1 tick, etc. timerPositionWithin += raveLipSyncTicks; do { @@ -343,7 +346,11 @@ void Portrait::doit(Common::Point position, uint16 resourceId, uint16 noun, uint raveLipSyncBitmapNr = *raveLipSyncData++; #ifdef DEBUG_PORTRAIT - debug("kPortrait: showing bitmap %d", raveLipSyncBitmapNr); + if (!raveLipSyncTicks) { + debug("kPortrait: showing frame %d", raveLipSyncBitmapNr); + } else { + debug("kPortrait: showing frame %d after %d ticks", raveLipSyncBitmapNr, raveLipSyncTicks); + } #endif // bitmap nr within sync data is base 1, we need base 0 -- cgit v1.2.3 From d0ac19062526e5617d08b587e64aee00fd395876 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 28 Dec 2014 04:43:22 -0500 Subject: ZVISION: Use VideoDecoder facilities better in AnimationNode setEndFrame() will ensure the audio stops when it is supposed to. Also removes the hack of retrieving the frame rate through the getDuration()'s timestamp return value. Thanks to md5 for testing --- .../zvision/scripting/sidefx/animation_node.cpp | 99 ++++++++++++---------- engines/zvision/scripting/sidefx/animation_node.h | 2 +- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 3dd80f3699..1657a6e0ec 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -40,19 +40,18 @@ AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::S _animation(NULL) { _animation = engine->loadAnimation(fileName); + _animation->start(); - if (fileName.hasSuffix(".rlf")) - _frmDelay = _animation->getTimeToNextFrame(); - else - _frmDelay = Common::Rational(1000, _animation->getDuration().framerate()).toInt(); + if (frate > 0) { + _frmDelayOverride = (int32)(1000.0 / frate); - if (frate > 0) - _frmDelay = 1000.0 / frate; - - // WORKAROUND: We do not allow the engine to delay more than 66 msec - // per frame (15fps max) - if (_frmDelay > 66) - _frmDelay = 66; + // WORKAROUND: We do not allow the engine to delay more than 66 msec + // per frame (15fps max) + if (_frmDelayOverride > 66) + _frmDelayOverride = 66; + } else { + _frmDelayOverride = 0; + } } AnimationNode::~AnimationNode() { @@ -90,44 +89,52 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (it != _playList.end()) { playnode *nod = &(*it); - nod->_delay -= deltaTimeInMillis; - if (nod->_delay <= 0) { - nod->_delay += _frmDelay; - - const Graphics::Surface *frame = NULL; - - if (nod->_curFrame == -1) { // Start of new playlist node - nod->_curFrame = nod->start; - - _animation->seekToFrame(nod->_curFrame); - frame = _animation->decodeNextFrame(); - - nod->_delay = _frmDelay; - if (nod->slot) - scriptManager->setStateValue(nod->slot, 1); - } else { - nod->_curFrame++; - - if (nod->_curFrame > nod->stop) { - nod->loop--; - - if (nod->loop == 0) { - if (nod->slot >= 0) - scriptManager->setStateValue(nod->slot, 2); - if (nod->_scaled) { - nod->_scaled->free(); - delete nod->_scaled; - } - _playList.erase(it); - return _DisposeAfterUse; - } - - nod->_curFrame = nod->start; - _animation->seekToFrame(nod->_curFrame); + if (nod->_curFrame == -1) { + // The node is just beginning playback + nod->_curFrame = nod->start; + + _animation->seekToFrame(nod->start); + _animation->setEndFrame(nod->stop); + + nod->_delay = deltaTimeInMillis; // Force the frame to draw + if (nod->slot) + scriptManager->setStateValue(nod->slot, 1); + } else if (_animation->endOfVideo()) { + // The node has reached the end; check if we need to loop + nod->loop--; + + if (nod->loop == 0) { + if (nod->slot >= 0) + scriptManager->setStateValue(nod->slot, 2); + if (nod->_scaled) { + nod->_scaled->free(); + delete nod->_scaled; } + _playList.erase(it); + return _DisposeAfterUse; + } - frame = _animation->decodeNextFrame(); + nod->_curFrame = nod->start; + _animation->seekToFrame(nod->start); + } + + // Check if we need to draw a frame + bool needsUpdate = false; + if (_frmDelayOverride == 0) { + // If not overridden, use the VideoDecoder's check + needsUpdate = _animation->needsUpdate(); + } else { + // Otherwise, implement our own timing + nod->_delay -= deltaTimeInMillis; + + if (nod->_delay <= 0) { + nod->_delay += _frmDelayOverride; + needsUpdate = true; } + } + + if (needsUpdate) { + const Graphics::Surface *frame = _animation->decodeNextFrame(); if (frame) { uint32 dstw; diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 368f0291fd..64270ebc79 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -64,7 +64,7 @@ private: bool _DisposeAfterUse; Video::VideoDecoder *_animation; - int32 _frmDelay; + int32 _frmDelayOverride; public: bool process(uint32 deltaTimeInMillis); -- cgit v1.2.3 From 46cd10c5255a7c99620a335094d5af3ccf5a2092 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 28 Dec 2014 11:35:53 +0100 Subject: ACCESS: Fix DisposeAfterUse flags in sound code (thanks to fuzzie) --- engines/access/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 221b409aa9..da267bdc4c 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -134,7 +134,7 @@ void SoundManager::playSound(Resource *res, int priority) { return; } - Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0); + Audio::RewindableAudioStream *audioStream = Audio::makeRawStream(resourceData + 32, sampleSize, sampleRate, 0, DisposeAfterUse::NO); _queue.push_back(audioStream); } else @@ -143,7 +143,7 @@ void SoundManager::playSound(Resource *res, int priority) { if (!_mixer->isSoundHandleActive(_effectsHandle)) _mixer->playStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, _queue[0], -1, _mixer->kMaxChannelVolume, 0, - DisposeAfterUse::NO); + DisposeAfterUse::YES); } void SoundManager::checkSoundQueue() { -- cgit v1.2.3 From 78b2c87d510f1ad83e8915e15b7e345a2512d99a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 28 Dec 2014 15:27:55 +0200 Subject: ZVISION: Document some more controls --- engines/zvision/scripting/control.cpp | 1 + engines/zvision/scripting/controls/fist_control.h | 2 +- engines/zvision/scripting/controls/hotmov_control.h | 2 +- engines/zvision/scripting/controls/lever_control.h | 1 + engines/zvision/scripting/controls/paint_control.h | 2 +- engines/zvision/scripting/controls/safe_control.h | 1 + engines/zvision/scripting/controls/titler_control.h | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 15 +++++++++------ 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/engines/zvision/scripting/control.cpp b/engines/zvision/scripting/control.cpp index 127f35ef12..81123eb99b 100644 --- a/engines/zvision/scripting/control.cpp +++ b/engines/zvision/scripting/control.cpp @@ -72,6 +72,7 @@ void Control::parsePanoramaControl(ZVision *engine, Common::SeekableReadStream & renderTable->generateRenderTable(); } +// Only used in Zork Nemesis, handles tilt controls (ZGI doesn't have a tilt view) void Control::parseTiltControl(ZVision *engine, Common::SeekableReadStream &stream) { RenderTable *renderTable = engine->getRenderManager()->getRenderTable(); renderTable->setRenderState(RenderTable::TILT); diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index bad2daa6d5..a41d8511ea 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -34,7 +34,7 @@ namespace Video { namespace ZVision { -// Only used in Zork Nemesis, it handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) +// Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) class FistControl : public Control { public: FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index 640fab00c0..01c83b5837 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -34,7 +34,7 @@ namespace Video { namespace ZVision { -// Only used in Zork Nemesis, it handles movies where the player needs to click on something (mj7g, vw3g) +// Only used in Zork Nemesis, handles movies where the player needs to click on something (mj7g, vw3g) class HotMovControl : public Control { public: HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/lever_control.h b/engines/zvision/scripting/controls/lever_control.h index fdf4a649dc..8787234c51 100644 --- a/engines/zvision/scripting/controls/lever_control.h +++ b/engines/zvision/scripting/controls/lever_control.h @@ -34,6 +34,7 @@ namespace Video { namespace ZVision { +// Only used in Zork Nemesis, handles draggable levers (te2e, tm7e, tp2e, tt2e, tz2e) class LeverControl : public Control { public: LeverControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/paint_control.h b/engines/zvision/scripting/controls/paint_control.h index 0e5b59b821..8c01f0e68a 100644 --- a/engines/zvision/scripting/controls/paint_control.h +++ b/engines/zvision/scripting/controls/paint_control.h @@ -32,7 +32,7 @@ namespace ZVision { -// Only used in Zork Nemesis, it's the painting puzzle screen in Lucien's room in Irondune (ch4g) +// Only used in Zork Nemesis, handles the painting puzzle screen in Lucien's room in Irondune (ch4g) class PaintControl : public Control { public: PaintControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h index 6e1095e304..2577ff4f79 100644 --- a/engines/zvision/scripting/controls/safe_control.h +++ b/engines/zvision/scripting/controls/safe_control.h @@ -34,6 +34,7 @@ namespace Video { namespace ZVision { +// Only used in Zork Nemesis, handles the safe in the Asylum (ac4g) class SafeControl : public Control { public: SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/controls/titler_control.h b/engines/zvision/scripting/controls/titler_control.h index 86bb398b3c..dd96e4a846 100644 --- a/engines/zvision/scripting/controls/titler_control.h +++ b/engines/zvision/scripting/controls/titler_control.h @@ -32,7 +32,7 @@ namespace ZVision { -// Only used in Zork Nemesis - it's the death screen with the Restore/Exit buttons +// Only used in Zork Nemesis, handles the death screen with the Restore/Exit buttons class TitlerControl : public Control { public: TitlerControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index fd5c158fcc..4e8c8a6b33 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -349,29 +349,32 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS Control::parsePanoramaControl(_engine, stream); return NULL; } else if (controlType.equalsIgnoreCase("tilt")) { + // Only used in Zork Nemesis, handles tilt controls (ZGI doesn't have a tilt view) Control::parseTiltControl(_engine, stream); return NULL; - } else if (controlType.equalsIgnoreCase("lever")) { - return new LeverControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("slot")) { return new SlotControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("input")) { return new InputControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("save")) { return new SaveControl(_engine, key, stream); + } else if (controlType.equalsIgnoreCase("lever")) { + // Only used in Zork Nemesis, handles draggable levers (te2e, tm7e, tp2e, tt2e, tz2e) + return new LeverControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("safe")) { + // Only used in Zork Nemesis, handles the safe in the Asylum (ac4g) return new SafeControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("hotmovie")) { - // Only used in Zork Nemesis, it handles movies where the player needs to click on something (mj7g, vw3g) + // Only used in Zork Nemesis, handles movies where the player needs to click on something (mj7g, vw3g) return new HotMovControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("fist")) { - // Only used in Zork Nemesis, it handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) + // Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) return new FistControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("paint")) { - // Only used in Zork Nemesis, it's the painting puzzle screen in Lucien's room in Irondune (ch4g) + // Only used in Zork Nemesis, handles the painting puzzle screen in Lucien's room in Irondune (ch4g) return new PaintControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("titler")) { - // Only used in Zork Nemesis - it's the death screen with the Restore/Exit buttons (cjde) + // Only used in Zork Nemesis, handles the death screen with the Restore/Exit buttons (cjde) return new TitlerControl(_engine, key, stream); } return NULL; -- cgit v1.2.3 From dd347dec83e0d074585cdfd99aa93a17da94ccd4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 28 Dec 2014 16:57:00 +0200 Subject: DEBUGGER: Extend the md5 and md5mac commands to handle any chunk length This will be useful in matching the MD5 checksums with what the advanced detector returns --- gui/debugger.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/gui/debugger.cpp b/gui/debugger.cpp index 216bd626fe..466681e89d 100644 --- a/gui/debugger.cpp +++ b/gui/debugger.cpp @@ -522,11 +522,25 @@ struct ArchiveMemberLess { bool Debugger::cmdMd5(int argc, const char **argv) { if (argc < 2) { - debugPrintf("md5 \n"); + debugPrintf("md5 [-n length] \n"); } else { + uint32 length = 0; + uint paramOffset = 0; + + // If the user supplied an -n parameter, set the bytes to read + if (!strcmp(argv[1], "-n")) { + // Make sure that we have at least two more parameters + if (argc < 4) { + debugPrintf("md5 [-n length] \n"); + return true; + } + length = atoi(argv[2]); + paramOffset = 2; + } + // Assume that spaces are part of a single filename. - Common::String filename = argv[1]; - for (int i = 2; i < argc; i++) { + Common::String filename = argv[1 + paramOffset]; + for (int i = 2 + paramOffset; i < argc; i++) { filename = filename + " " + argv[i]; } Common::ArchiveMemberList list; @@ -536,9 +550,9 @@ bool Debugger::cmdMd5(int argc, const char **argv) { } else { sort(list.begin(), list.end(), ArchiveMemberLess()); for (Common::ArchiveMemberList::iterator iter = list.begin(); iter != list.end(); ++iter) { - Common::ReadStream *stream = (*iter)->createReadStream(); - Common::String md5 = Common::computeStreamMD5AsString(*stream, 0); - debugPrintf("%s %s\n", md5.c_str(), (*iter)->getDisplayName().c_str()); + Common::SeekableReadStream *stream = (*iter)->createReadStream(); + Common::String md5 = Common::computeStreamMD5AsString(*stream, length); + debugPrintf("%s %s %d\n", md5.c_str(), (*iter)->getDisplayName().c_str(), stream->size()); delete stream; } } @@ -548,11 +562,25 @@ bool Debugger::cmdMd5(int argc, const char **argv) { bool Debugger::cmdMd5Mac(int argc, const char **argv) { if (argc < 2) { - debugPrintf("md5mac \n"); + debugPrintf("md5mac [-n length] \n"); } else { + uint32 length = 0; + uint paramOffset = 0; + + // If the user supplied an -n parameter, set the bytes to read + if (!strcmp(argv[1], "-n")) { + // Make sure that we have at least two more parameters + if (argc < 4) { + debugPrintf("md5mac [-n length] \n"); + return true; + } + length = atoi(argv[2]); + paramOffset = 2; + } + // Assume that spaces are part of a single filename. - Common::String filename = argv[1]; - for (int i = 2; i < argc; i++) { + Common::String filename = argv[1 + paramOffset]; + for (int i = 2 + paramOffset; i < argc; i++) { filename = filename + " " + argv[i]; } Common::MacResManager macResMan; @@ -568,13 +596,13 @@ bool Debugger::cmdMd5Mac(int argc, const char **argv) { } else { // The resource fork is probably the most relevant one. if (macResMan.hasResFork()) { - Common::String md5 = macResMan.computeResForkMD5AsString(0); - debugPrintf("%s %s (resource)\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + Common::String md5 = macResMan.computeResForkMD5AsString(length); + debugPrintf("%s %s (resource) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), macResMan.getResForkDataSize()); } if (macResMan.hasDataFork()) { - Common::ReadStream *stream = macResMan.getDataFork(); - Common::String md5 = Common::computeStreamMD5AsString(*stream, 0); - debugPrintf("%s %s (data)\n", md5.c_str(), macResMan.getBaseFileName().c_str()); + Common::SeekableReadStream *stream = macResMan.getDataFork(); + Common::String md5 = Common::computeStreamMD5AsString(*stream, length); + debugPrintf("%s %s (data) %d\n", md5.c_str(), macResMan.getBaseFileName().c_str(), stream->size()); } } macResMan.close(); -- cgit v1.2.3 From 587b1ad69c200ee5b5c987328a65bd8092d9ea4f Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 28 Dec 2014 18:42:18 +0200 Subject: ZVISION: The fist control is only used in one location --- engines/zvision/scripting/controls/fist_control.h | 2 +- engines/zvision/scripting/scr_file_handling.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index a41d8511ea..74e8f8d8a5 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -34,7 +34,7 @@ namespace Video { namespace ZVision { -// Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) +// Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td9e) class FistControl : public Control { public: FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp index 4e8c8a6b33..227c43557c 100644 --- a/engines/zvision/scripting/scr_file_handling.cpp +++ b/engines/zvision/scripting/scr_file_handling.cpp @@ -368,7 +368,7 @@ Control *ScriptManager::parseControl(Common::String &line, Common::SeekableReadS // Only used in Zork Nemesis, handles movies where the player needs to click on something (mj7g, vw3g) return new HotMovControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("fist")) { - // Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td60, td90, td9e) + // Only used in Zork Nemesis, handles the door lock puzzle with the skeletal fingers (td9e) return new FistControl(_engine, key, stream); } else if (controlType.equalsIgnoreCase("paint")) { // Only used in Zork Nemesis, handles the painting puzzle screen in Lucien's room in Irondune (ch4g) -- cgit v1.2.3 From f1d6ba7085be53cb641f71ef726dadf3f075b311 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 28 Dec 2014 23:35:14 +0100 Subject: ACCESS: Remove useless variable --- engines/access/player.cpp | 1 - engines/access/player.h | 1 - 2 files changed, 2 deletions(-) diff --git a/engines/access/player.cpp b/engines/access/player.cpp index bcd553c6dc..e47daf532c 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -48,7 +48,6 @@ Player::Player(AccessEngine *vm) : Manager(vm), ImageEntry() { _playerSprites1 = nullptr; _manPal1 = nullptr; _frameNumber = 0; - _monData = nullptr; _rawTempL = 0; _rawXTemp = 0; _rawYTempL = 0; diff --git a/engines/access/player.h b/engines/access/player.h index 26caec681f..329cc15ed2 100644 --- a/engines/access/player.h +++ b/engines/access/player.h @@ -84,7 +84,6 @@ public: Direction _playerDirection; SpriteResource *_playerSprites; // Fields in original Player structure - byte *_monData; int _walkOffRight[PLAYER_DATA_COUNT]; int _walkOffLeft[PLAYER_DATA_COUNT]; int _walkOffUp[PLAYER_DATA_COUNT]; -- cgit v1.2.3 From 6d55998b40f62518959f849922919b6b0562981e Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 28 Dec 2014 21:19:27 -0500 Subject: ZVISION: Make the rest of the controls properly use VideoDecoder timing The hacky use of getDuration() to retrieve the framerate() is gone Thanks to md5 for testing (and for filling in a few gaps since I was coding in the blind ;)) --- .../zvision/scripting/controls/fist_control.cpp | 53 +++++++--------------- engines/zvision/scripting/controls/fist_control.h | 5 -- .../zvision/scripting/controls/hotmov_control.cpp | 53 +++++++++------------- .../zvision/scripting/controls/hotmov_control.h | 4 -- .../zvision/scripting/controls/input_control.cpp | 19 ++------ .../zvision/scripting/controls/safe_control.cpp | 53 ++++++---------------- engines/zvision/scripting/controls/safe_control.h | 7 --- 7 files changed, 58 insertions(+), 136 deletions(-) diff --git a/engines/zvision/scripting/controls/fist_control.cpp b/engines/zvision/scripting/controls/fist_control.cpp index 34a64b4298..4a8e8b1bbd 100644 --- a/engines/zvision/scripting/controls/fist_control.cpp +++ b/engines/zvision/scripting/controls/fist_control.cpp @@ -46,10 +46,6 @@ FistControl::FistControl(ZVision *engine, uint32 key, Common::SeekableReadStream _order = 0; _fistnum = 0; - _frameCur = -1; - _frameEnd = -1; - _frameTime = 0; - _lastRenderedFrame = -1; _animationId = 0; clearFistArray(_fistsUp); @@ -95,41 +91,23 @@ FistControl::~FistControl() { _entries.clear(); } -void FistControl::renderFrame(uint frameNumber) { - if ((int32)frameNumber == _lastRenderedFrame) - return; - - _lastRenderedFrame = frameNumber; - - const Graphics::Surface *frameData; - - if (_animation) { - _animation->seekToFrame(frameNumber); - frameData = _animation->decodeNextFrame(); - if (frameData) - _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect); - } -} - bool FistControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_frameCur >= 0 && _frameEnd >= 0) - if (_frameCur <= _frameEnd) { - _frameTime -= deltaTimeInMillis; - - if (_frameTime <= 0) { - _frameTime = 1000.0 / _animation->getDuration().framerate(); - - renderFrame(_frameCur); - - _frameCur++; + if (_animation && _animation->isPlaying()) { + if (_animation->endOfVideo()) { + _animation->stop(); + _engine->getScriptManager()->setStateValue(_animationId, 2); + return false; + } - if (_frameCur > _frameEnd) - _engine->getScriptManager()->setStateValue(_animationId, 2); - } + if (_animation->needsUpdate()) { + const Graphics::Surface *frameData = _animation->decodeNextFrame(); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _anmRect); } + } return false; } @@ -160,9 +138,12 @@ bool FistControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P for (int i = 0; i < _numEntries; i++) if (_entries[i]._bitsStrt == oldStatus && _entries[i]._bitsEnd == _fiststatus) { - _frameCur = _entries[i]._anmStrt; - _frameEnd = _entries[i]._anmEnd; - _frameTime = 0; + if (_animation) { + _animation->stop(); + _animation->seekToFrame(_entries[i]._anmStrt); + _animation->setEndFrame(_entries[i]._anmEnd); + _animation->start(); + } _engine->getScriptManager()->setStateValue(_animationId, 1); _engine->getScriptManager()->setStateValue(_soundKey, _entries[i]._sound); diff --git a/engines/zvision/scripting/controls/fist_control.h b/engines/zvision/scripting/controls/fist_control.h index 74e8f8d8a5..d7cbcb1f71 100644 --- a/engines/zvision/scripting/controls/fist_control.h +++ b/engines/zvision/scripting/controls/fist_control.h @@ -64,10 +64,6 @@ private: Video::VideoDecoder *_animation; Common::Rect _anmRect; int32 _soundKey; - int32 _frameCur; - int32 _frameEnd; - int32 _frameTime; - int32 _lastRenderedFrame; int32 _animationId; public: @@ -76,7 +72,6 @@ public: bool process(uint32 deltaTimeInMillis); private: - void renderFrame(uint frameNumber); void readDescFile(const Common::String &fileName); void clearFistArray(Common::Array< Common::Array > &arr); uint32 readBits(const char *str); diff --git a/engines/zvision/scripting/controls/hotmov_control.cpp b/engines/zvision/scripting/controls/hotmov_control.cpp index e77272ec73..182447a990 100644 --- a/engines/zvision/scripting/controls/hotmov_control.cpp +++ b/engines/zvision/scripting/controls/hotmov_control.cpp @@ -41,10 +41,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt : Control(engine, key, CONTROL_HOTMOV) { _animation = NULL; _cycle = 0; - _curFrame = -1; - _lastRenderedFrame = -1; _frames.clear(); - _frameTime = 0; _cyclesCount = 0; _framesCount = 0; @@ -78,6 +75,7 @@ HotMovControl::HotMovControl(ZVision *engine, uint32 key, Common::SeekableReadSt sscanf(values.c_str(), "%s", filename); values = Common::String(filename); _animation = _engine->loadAnimation(values); + _animation->start(); } else if (param.matchString("venus_id", true)) { _venusId = atoi(values.c_str()); } @@ -95,41 +93,26 @@ HotMovControl::~HotMovControl() { _frames.clear(); } -void HotMovControl::renderFrame(uint frameNumber) { - if ((int)frameNumber == _lastRenderedFrame) - return; - - _lastRenderedFrame = frameNumber; - - const Graphics::Surface *frameData; - - if (_animation) { - _animation->seekToFrame(frameNumber); - frameData = _animation->decodeNextFrame(); - if (frameData) - _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle); - } -} - bool HotMovControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; if (_cycle < _cyclesCount) { - _frameTime -= deltaTimeInMillis; + if (_animation && _animation->endOfVideo()) { + _cycle++; - if (_frameTime <= 0) { - _curFrame++; - if (_curFrame >= _framesCount) { - _curFrame = 0; - _cycle++; - } - if (_cycle != _cyclesCount) - renderFrame(_curFrame); - else + if (_cycle == _cyclesCount) { _engine->getScriptManager()->setStateValue(_key, 2); + return false; + } + + _animation->rewind(); + } - _frameTime = 1000.0 / _animation->getDuration().framerate(); + if (_animation && _animation->needsUpdate()) { + const Graphics::Surface *frameData = _animation->decodeNextFrame(); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkgScaled(*frameData, _rectangle); } } @@ -140,8 +123,11 @@ bool HotMovControl::onMouseMove(const Common::Point &screenSpacePos, const Commo if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; + if (!_animation) + return false; + if (_cycle < _cyclesCount) { - if (_frames[_curFrame].contains(backgroundImageSpacePos)) { + if (_frames[_animation->getCurFrame()].contains(backgroundImageSpacePos)) { _engine->getCursorManager()->changeCursor(CursorIndex_Active); return true; } @@ -154,8 +140,11 @@ bool HotMovControl::onMouseUp(const Common::Point &screenSpacePos, const Common: if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; + if (!_animation) + return false; + if (_cycle < _cyclesCount) { - if (_frames[_curFrame].contains(backgroundImageSpacePos)) { + if (_frames[_animation->getCurFrame()].contains(backgroundImageSpacePos)) { setVenus(); _engine->getScriptManager()->setStateValue(_key, 1); return true; diff --git a/engines/zvision/scripting/controls/hotmov_control.h b/engines/zvision/scripting/controls/hotmov_control.h index 01c83b5837..99d1fd0979 100644 --- a/engines/zvision/scripting/controls/hotmov_control.h +++ b/engines/zvision/scripting/controls/hotmov_control.h @@ -42,9 +42,6 @@ public: private: int32 _framesCount; - int32 _frameTime; - int32 _curFrame; - int32 _lastRenderedFrame; int32 _cycle; int32 _cyclesCount; Video::VideoDecoder *_animation; @@ -56,7 +53,6 @@ public: bool process(uint32 deltaTimeInMillis); private: - void renderFrame(uint frameNumber); void readHsFile(const Common::String &fileName); }; diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 4abc0c9e1b..47da27fa08 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -46,9 +46,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre _enterPressed(false), _readOnly(false), _txtWidth(0), - _animation(NULL), - _frameDelay(0), - _frame(-1) { + _animation(NULL) { // Loop until we find the closing brace Common::String line = stream.readLine(); _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); @@ -99,8 +97,7 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(values.c_str(), "%24s %*u", fileName); _animation = _engine->loadAnimation(fileName); - _frame = -1; - _frameDelay = 0; + _animation->start(); } else if (param.matchString("focus", true)) { _focused = true; _engine->getScriptManager()->setFocusControlKey(_key); @@ -212,16 +209,10 @@ bool InputControl::process(uint32 deltaTimeInMillis) { } if (_animation && !_readOnly && _focused) { - bool needDraw = true;// = _textChanged; - _frameDelay -= deltaTimeInMillis; - if (_frameDelay <= 0) { - _frame = (_frame + 1) % _animation->getFrameCount(); - _frameDelay = 1000.0 / _animation->getDuration().framerate(); - needDraw = true; - } + if (_animation->endOfVideo()) + _animation->rewind(); - if (needDraw) { - _animation->seekToFrame(_frame); + if (_animation->needsUpdate()) { const Graphics::Surface *srf = _animation->decodeNextFrame(); int16 xx = _textRectangle.left + _txtWidth; if (xx >= _textRectangle.left + (_textRectangle.width() - (int16)_animation->getWidth())) diff --git a/engines/zvision/scripting/controls/safe_control.cpp b/engines/zvision/scripting/controls/safe_control.cpp index 71be692431..6ba34106d0 100644 --- a/engines/zvision/scripting/controls/safe_control.cpp +++ b/engines/zvision/scripting/controls/safe_control.cpp @@ -49,10 +49,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream _outerRadiusSqr = 0; _zeroPointer = 0; _startPointer = 0; - _curFrame = -1; _targetFrame = 0; - _frameTime = 0; - _lastRenderedFrame = -1; // Loop until we find the closing brace Common::String line = stream.readLine(); @@ -64,6 +61,7 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream while (!stream.eos() && !line.contains('}')) { if (param.matchString("animation", true)) { _animation = _engine->loadAnimation(values); + _animation->start(); } else if (param.matchString("rectangle", true)) { int x; int y; @@ -104,7 +102,9 @@ SafeControl::SafeControl(ZVision *engine, uint32 key, Common::SeekableReadStream _engine->getScriptManager()->trimCommentsAndWhiteSpace(&line); getParams(line, param, values); } - renderFrame(_curState); + + if (_animation) + _animation->seekToFrame(_curState); } SafeControl::~SafeControl() { @@ -113,44 +113,20 @@ SafeControl::~SafeControl() { } -void SafeControl::renderFrame(uint frameNumber) { - if (frameNumber == 0) { - _lastRenderedFrame = frameNumber; - } else if ((int16)frameNumber < _lastRenderedFrame) { - _lastRenderedFrame = frameNumber; - frameNumber = (_statesCount * 2) - frameNumber; - } else { - _lastRenderedFrame = frameNumber; - } - - const Graphics::Surface *frameData; - int x = _rectangle.left; - int y = _rectangle.top; - - _animation->seekToFrame(frameNumber); - frameData = _animation->decodeNextFrame(); - if (frameData) - _engine->getRenderManager()->blitSurfaceToBkg(*frameData, x, y); -} - bool SafeControl::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED) return false; - if (_curFrame != _targetFrame) { - _frameTime -= deltaTimeInMillis; - - if (_frameTime <= 0) { - if (_curFrame < _targetFrame) { - _curFrame++; - renderFrame(_curFrame); - } else if (_curFrame > _targetFrame) { - _curFrame--; - renderFrame(_curFrame); - } - _frameTime = 1000.0 / _animation->getDuration().framerate(); - } + if (_animation && _animation->getCurFrame() != _targetFrame && _animation->needsUpdate()) { + // If we're past the target frame, move back one + if (_animation->getCurFrame() > _targetFrame) + _animation->seekToFrame(_animation->getCurFrame() - 1); + + const Graphics::Surface *frameData = _animation->decodeNextFrame(); + if (frameData) + _engine->getRenderManager()->blitSurfaceToBkg(*frameData, _rectangle.left, _rectangle.top); } + return false; } @@ -187,7 +163,8 @@ bool SafeControl::onMouseUp(const Common::Point &screenSpacePos, const Common::P int16 tmp2 = (m_state + _curState - _zeroPointer + _statesCount - 1) % _statesCount; - _curFrame = (_curState + _statesCount - _startPointer) % _statesCount; + if (_animation) + _animation->seekToFrame((_curState + _statesCount - _startPointer) % _statesCount); _curState = (_statesCount * 2 + tmp2) % _statesCount; diff --git a/engines/zvision/scripting/controls/safe_control.h b/engines/zvision/scripting/controls/safe_control.h index 2577ff4f79..3e8c17635c 100644 --- a/engines/zvision/scripting/controls/safe_control.h +++ b/engines/zvision/scripting/controls/safe_control.h @@ -52,19 +52,12 @@ private: int32 _outerRadiusSqr; int16 _zeroPointer; int16 _startPointer; - int16 _curFrame; int16 _targetFrame; - int32 _frameTime; - - int16 _lastRenderedFrame; public: bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); bool process(uint32 deltaTimeInMillis); - -private: - void renderFrame(uint frameNumber); }; } // End of namespace ZVision -- cgit v1.2.3 From 83dd389d255ae63affc3600742d564a8d2cb914c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 29 Dec 2014 12:13:43 +0200 Subject: CREDITS: Update credits for ZVision again --- devtools/credits.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/credits.pl b/devtools/credits.pl index 69eede756d..7dc954a6a7 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -792,7 +792,7 @@ begin_credits("Credits"); begin_section("ZVision"); add_person("Adrian Astley", "RichieSams", ""); add_person("Filippos Karapetis", "[md5]", ""); - add_person("Anton Yarcev", "Marisa-Chan", ""); + add_person("Anton Yarcev", "Zidane", ""); end_section(); end_section(); -- cgit v1.2.3 From f4d5b150f1e4b786f2f6f79a1acd3315da9a8699 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 29 Dec 2014 12:34:55 +0200 Subject: ZVISION: Show system messages when subtitles are disabled Thanks to Marisa-Chan for spotting this --- engines/zvision/graphics/render_manager.cpp | 2 +- engines/zvision/scripting/sidefx/music_node.cpp | 2 +- engines/zvision/scripting/sidefx/syncsound_node.cpp | 2 +- engines/zvision/video/video.cpp | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 033d099042..1b80b379bf 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -741,7 +741,7 @@ void RenderManager::processSubs(uint16 deltatime) { } } - if (redraw && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) { + if (redraw) { _subtitleSurface.fillRect(Common::Rect(_subtitleSurface.w, _subtitleSurface.h), 0); for (SubtitleMap::iterator it = _subsList.begin(); it != _subsList.end(); it++) { diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp index 6be08b46dc..0cada6d748 100644 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ b/engines/zvision/scripting/sidefx/music_node.cpp @@ -137,7 +137,7 @@ bool MusicNode::process(uint32 deltaTimeInMillis) { if (_pantrack || _volume != _newvol) setVolume(_newvol); - if (_sub) + if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); } return false; diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp index c1f139694b..eec320bf2e 100644 --- a/engines/zvision/scripting/sidefx/syncsound_node.cpp +++ b/engines/zvision/scripting/sidefx/syncsound_node.cpp @@ -76,7 +76,7 @@ bool SyncSoundNode::process(uint32 deltaTimeInMillis) { if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) return stop(); - if (_sub) + if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); } return false; diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp index e67e6570c5..0913b28818 100644 --- a/engines/zvision/video/video.cpp +++ b/engines/zvision/video/video.cpp @@ -29,6 +29,7 @@ #include "zvision/zvision.h" #include "zvision/core/clock.h" #include "zvision/graphics/render_manager.h" +#include "zvision/scripting//script_manager.h" #include "zvision/text/subtitles.h" #include "zvision/video/rlf_decoder.h" #include "zvision/video/zork_avi_decoder.h" @@ -75,6 +76,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, uint16 y = _workingWindow.top + dst.top; uint16 finalWidth = dst.width() < _workingWindow.width() ? dst.width() : _workingWindow.width(); uint16 finalHeight = dst.height() < _workingWindow.height() ? dst.height() : _workingWindow.height(); + bool showSubs = (_scriptManager->getStateValue(StateKey_Subtitles) == 1); _clock.stop(); vid.start(); @@ -106,7 +108,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect, if (vid.needsUpdate()) { const Graphics::Surface *frame = vid.decodeNextFrame(); - if (sub) + if (sub && showSubs) sub->process(vid.getCurFrame()); if (frame) { -- cgit v1.2.3 From bbfff93c6455247d9875003cdfd18c09d0c30e0f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 29 Dec 2014 14:56:02 +0100 Subject: GUI: Do not overwrite write protected saves in grid based save dialog. This fixes overwriting of, for example, autosaves in the grid based save load dialog when using "New Save". --- gui/saveload-dialog.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp index 339ec95c50..a333c5fe57 100644 --- a/gui/saveload-dialog.cpp +++ b/gui/saveload-dialog.cpp @@ -654,16 +654,25 @@ void SaveLoadChooserGrid::open() { // In case there was a gap found use the slot. if (lastSlot + 1 < curSlot) { - _nextFreeSaveSlot = lastSlot + 1; - break; + // Check that the save slot can be used for user saves. + SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), lastSlot + 1); + if (!desc.getWriteProtectedFlag()) { + _nextFreeSaveSlot = lastSlot + 1; + break; + } } lastSlot = curSlot; } // Use the next available slot otherwise. - if (_nextFreeSaveSlot == -1 && lastSlot + 1 < _metaEngine->getMaximumSaveSlot()) { - _nextFreeSaveSlot = lastSlot + 1; + const int maxSlot = _metaEngine->getMaximumSaveSlot(); + for (int i = lastSlot; _nextFreeSaveSlot == -1 && i < maxSlot; ++i) { + // Check that the save slot can be used for user saves. + SaveStateDescriptor desc = _metaEngine->querySaveMetaInfos(_target.c_str(), i + 1); + if (!desc.getWriteProtectedFlag()) { + _nextFreeSaveSlot = i + 1; + } } } -- cgit v1.2.3 From 45280d035afe29dc1f8971eac713ea1fdb64bfb5 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Mon, 29 Dec 2014 15:30:12 +0600 Subject: ZVISION: Fix font error message condition --- engines/zvision/zvision.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 88cc1e2fea..10e0aaedc4 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -255,7 +255,7 @@ Common::Error ZVision::run() { _saveManager->loadGame(ConfMan.getInt("save_slot")); // Before starting, make absolutely sure that the user has copied the needed fonts - if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf")) { + if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) { GUI::MessageDialog dialog( "Before playing this game, you'll need to copy the required " "fonts into ScummVM's extras directory, or into the game directory. " -- cgit v1.2.3 From 47b90ef3cde832b6314bbcc0321cb074408d944e Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 24 Dec 2014 09:31:02 +0600 Subject: ZVISION: Search fonts in game directory (e.g. in game/FONTS/) --- engines/zvision/text/truetype_font.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index f64c0ab3bc..85d9fa5a29 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -108,7 +108,7 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { bool sharp = (_style & STTF_SHARP) == STTF_SHARP; Common::File file; - if (!file.open(newFontName) && !file.open(freeFontName)) + if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display -- cgit v1.2.3 From 0c4e0673c3a7d17aef7c586251c3990104163bc3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Dec 2014 03:08:39 +0200 Subject: ZVISION: Further cleanup to the AnimationNode class --- engines/zvision/scripting/sidefx/animation_node.cpp | 20 ++++++-------------- engines/zvision/scripting/sidefx/animation_node.h | 6 ++---- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index 1657a6e0ec..a0870bf7c2 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -33,14 +33,13 @@ namespace ZVision { -AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse) +AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse) : SideFX(engine, controlKey, SIDEFX_ANIM), - _DisposeAfterUse(DisposeAfterUse), + _disposeAfterUse(disposeAfterUse), _mask(mask), _animation(NULL) { _animation = engine->loadAnimation(fileName); - _animation->start(); if (frate > 0) { _frmDelayOverride = (int32)(1000.0 / frate); @@ -89,12 +88,10 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { if (it != _playList.end()) { playnode *nod = &(*it); - if (nod->_curFrame == -1) { + if (!_animation->isPlaying()) { // The node is just beginning playback - nod->_curFrame = nod->start; - + _animation->start(); _animation->seekToFrame(nod->start); - _animation->setEndFrame(nod->stop); nod->_delay = deltaTimeInMillis; // Force the frame to draw if (nod->slot) @@ -111,10 +108,9 @@ bool AnimationNode::process(uint32 deltaTimeInMillis) { delete nod->_scaled; } _playList.erase(it); - return _DisposeAfterUse; + return _disposeAfterUse; } - nod->_curFrame = nod->start; _animation->seekToFrame(nod->start); } @@ -190,13 +186,9 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.loop = loops; nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = startFrame; - nod.stop = endFrame; - - if (nod.stop >= (int)_animation->getFrameCount()) - nod.stop = _animation->getFrameCount() - 1; + _animation->setEndFrame(CLIP(endFrame, 0,_animation->getFrameCount() - 1)); nod.slot = slot; - nod._curFrame = -1; nod._delay = 0; nod._scaled = NULL; _playList.push_back(nod); diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h index 64270ebc79..1dc0dc71b8 100644 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ b/engines/zvision/scripting/sidefx/animation_node.h @@ -41,16 +41,14 @@ class ZVision; class AnimationNode : public SideFX { public: - AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool DisposeAfterUse = true); + AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true); ~AnimationNode(); struct playnode { Common::Rect pos; int32 slot; int32 start; - int32 stop; int32 loop; - int32 _curFrame; int32 _delay; Graphics::Surface *_scaled; }; @@ -61,7 +59,7 @@ private: PlayNodes _playList; int32 _mask; - bool _DisposeAfterUse; + bool _disposeAfterUse; Video::VideoDecoder *_animation; int32 _frmDelayOverride; -- cgit v1.2.3 From 7182b4f704a312427dc701ccc8452331ca66faae Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Dec 2014 03:51:15 +0200 Subject: ZVISION: Initialize the starting frame to -1 in RLF animations --- engines/zvision/video/rlf_decoder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 1478822d00..6e2000f93c 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -56,7 +56,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) _height(0), _frameTime(0), _frames(0), - _curFrame(0), + _curFrame(-1), _frameBufferByteSize(0) { if (!readHeader()) { -- cgit v1.2.3 From 6c3af3c2e7b8d2852669c141944964c82a11ce1b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Dec 2014 03:51:31 +0200 Subject: ZVISION: White space --- engines/zvision/scripting/sidefx/animation_node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp index a0870bf7c2..07eda692c1 100644 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ b/engines/zvision/scripting/sidefx/animation_node.cpp @@ -186,7 +186,7 @@ void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int st nod.loop = loops; nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = startFrame; - _animation->setEndFrame(CLIP(endFrame, 0,_animation->getFrameCount() - 1)); + _animation->setEndFrame(CLIP(endFrame, 0, _animation->getFrameCount() - 1)); nod.slot = slot; nod._delay = 0; -- cgit v1.2.3 From f74ba29753de23bad9a07f531fc4c03ea3375594 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 30 Dec 2014 03:45:14 +0100 Subject: SCUMM: Enable Day of the Tentacle easter egg Instead of returning to the launcher, a game may now specify a list of "chained" games and optional save slots. The first game is popped from the list and started. Quitting still quits the entire ScummVM. It seemed like the sensible thing to do. --- base/main.cpp | 50 +++++++++++++++++++++++++++++++++++++++++---- engines/scumm/saveload.cpp | 2 +- engines/scumm/script_v6.cpp | 6 +++++- engines/scumm/scumm.cpp | 44 ++++++++++++++++++++++++++++++++++++--- engines/scumm/scumm.h | 2 +- 5 files changed, 94 insertions(+), 10 deletions(-) diff --git a/base/main.cpp b/base/main.cpp index b5de7d94d2..b9bd97dbef 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -523,22 +523,64 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { } #endif + // At this point, we usually return to the launcher. However, the + // game may have requested that one or more other games be "chained" + // to the current one, with optional save slots to start the games + // at. At the time of writing, this is used for the Maniac Mansion + // easter egg in Day of the Tentacle. + + Common::String chainedGames, nextGame, saveSlot; + + if (ConfMan.hasKey("chained_games", Common::ConfigManager::kTransientDomain)) { + chainedGames = ConfMan.get("chained_games", Common::ConfigManager::kTransientDomain); + } + // Discard any command line options. It's unlikely that the user // wanted to apply them to *all* games ever launched. ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); - // Clear the active config domain - ConfMan.setActiveDomain(""); + if (!chainedGames.empty()) { + if (chainedGames.contains(',')) { + for (uint i = 0; i < chainedGames.size(); i++) { + if (chainedGames[i] == ',') { + chainedGames.erase(0, i + 1); + break; + } + nextGame += chainedGames[i]; + } + ConfMan.set("chained_games", chainedGames, Common::ConfigManager::kTransientDomain); + } else { + nextGame = chainedGames; + chainedGames.clear(); + ConfMan.removeKey("chained_games", Common::ConfigManager::kTransientDomain); + } + if (nextGame.contains(':')) { + for (int i = nextGame.size() - 1; i >= 0; i--) { + if (nextGame[i] == ':') { + nextGame.erase(i); + break; + } + saveSlot = nextGame[i] + saveSlot; + } + ConfMan.setInt("save_slot", atoi(saveSlot.c_str()), Common::ConfigManager::kTransientDomain); + } + // Start the next game + ConfMan.setActiveDomain(nextGame); + } else { + // Clear the active config domain + ConfMan.setActiveDomain(""); + } PluginManager::instance().loadAllPlugins(); // only for cached manager - } else { GUI::displayErrorDialog(_("Could not find any engine capable of running the selected game")); } // reset the graphics to default setupGraphics(system); - launcherDialog(); + if (0 == ConfMan.getActiveDomain()) { + launcherDialog(); + } } PluginManager::instance().unloadAllPlugins(); PluginManager::destroy(); diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 0c0f6be73b..e5673c1803 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -149,7 +149,7 @@ void ScummEngine::requestSave(int slot, const Common::String &name) { void ScummEngine::requestLoad(int slot) { _saveLoadSlot = slot; - _saveTemporaryState = false; + _saveTemporaryState = (slot == 100); _saveLoadFlag = 2; // 2 for load } diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index d2f4133f74..6c81f17f2f 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -2597,7 +2597,11 @@ void ScummEngine_v6::o6_kernelSetFunctions() { fadeIn(args[1]); break; case 8: - startManiac(); + if (startManiac()) { + // This is so that the surprised exclamation happens + // after we return to the game again, not before. + o6_breakHere(); + } break; case 9: killAllScriptsExceptCurrent(); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 6040344c2c..34ae957951 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -2597,9 +2597,47 @@ void ScummEngine_v90he::runBootscript() { } #endif -void ScummEngine::startManiac() { - debug(0, "stub startManiac()"); - displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But ScummVM doesn't do that yet. To play it, go to 'Add Game' in the ScummVM start menu and select the 'Maniac' directory inside the Tentacle game directory.")); +bool ScummEngine::startManiac() { + Common::String currentPath = ConfMan.get("path"); + Common::String maniacTarget; + + // Look for a game with a game path pointing to a 'Maniac' directory + // as a subdirectory to the current game. + Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains(); + for (; iter != ConfMan.endGameDomains(); ++iter) { + Common::ConfigManager::Domain &dom = iter->_value; + Common::String path = dom.getVal("path"); + + if (path.hasPrefix(currentPath)) { + path.erase(0, currentPath.size() + 1); + if (path.equalsIgnoreCase("maniac")) { + maniacTarget = dom.getVal("gameid"); + break; + } + } + } + + if (!maniacTarget.empty()) { + // Request a temporary save game to be made. + _saveLoadFlag = 1; + _saveLoadSlot = 100; + _saveTemporaryState = true; + + // Set up the chanined games to Maniac Mansion, and then back + // to the current game again with that save slot. + ConfMan.set("chained_games", maniacTarget + "," + ConfMan.getActiveDomainName() + ":100", Common::ConfigManager::kTransientDomain); + + // Force a return to the launcher. This will start the first + // chained game. + Common::EventManager *eventMan = g_system->getEventManager(); + Common::Event event; + event.type = Common::EVENT_RTL; + eventMan->pushEvent(event); + return true; + } else { + displayMessage(0, "%s", _("Usually, Maniac Mansion would start now. But for that to work, the game files for Maniac Mansion have to be in the 'Maniac' directory inside the Tentacle game directory, and the game has to be added to ScummVM.")); + return false; + } } #pragma mark - diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 967909e505..30b4d61880 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -654,7 +654,7 @@ protected: int getScriptSlot(); void startScene(int room, Actor *a, int b); - void startManiac(); + bool startManiac(); public: void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0); -- cgit v1.2.3 From 68d3ebd57b0313e517032681a119b47956803e71 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 01:10:36 -0600 Subject: ZVISION: Rename some scripting classes to better represent what the classes are Also, rename the graphics 'Effect' class in order to avoid naming clashes (and/or coder confusion) with the newly named ScriptingEffect class. Lastly, add some documentation for the classes for further clarity. --- engines/zvision/graphics/effect.h | 83 ------- engines/zvision/graphics/effects/fog.cpp | 2 +- engines/zvision/graphics/effects/fog.h | 4 +- engines/zvision/graphics/effects/light.cpp | 2 +- engines/zvision/graphics/effects/light.h | 4 +- engines/zvision/graphics/effects/wave.cpp | 2 +- engines/zvision/graphics/effects/wave.h | 4 +- engines/zvision/graphics/graphics_effect.h | 83 +++++++ engines/zvision/graphics/render_manager.cpp | 2 +- engines/zvision/graphics/render_manager.h | 6 +- engines/zvision/module.mk | 14 +- engines/zvision/scripting/actions.cpp | 66 +++--- engines/zvision/scripting/control.h | 5 + .../zvision/scripting/effects/animation_effect.cpp | 213 ++++++++++++++++++ .../zvision/scripting/effects/animation_effect.h | 77 +++++++ .../zvision/scripting/effects/distort_effect.cpp | 104 +++++++++ engines/zvision/scripting/effects/distort_effect.h | 63 ++++++ engines/zvision/scripting/effects/music_effect.cpp | 248 +++++++++++++++++++++ engines/zvision/scripting/effects/music_effect.h | 135 +++++++++++ .../zvision/scripting/effects/region_effect.cpp | 56 +++++ engines/zvision/scripting/effects/region_effect.h | 57 +++++ .../zvision/scripting/effects/syncsound_effect.cpp | 85 +++++++ .../zvision/scripting/effects/syncsound_effect.h | 56 +++++ engines/zvision/scripting/effects/timer_effect.cpp | 81 +++++++ engines/zvision/scripting/effects/timer_effect.h | 59 +++++ .../zvision/scripting/effects/ttytext_effect.cpp | 174 +++++++++++++++ engines/zvision/scripting/effects/ttytext_effect.h | 73 ++++++ engines/zvision/scripting/script_manager.cpp | 8 +- engines/zvision/scripting/script_manager.h | 10 +- engines/zvision/scripting/scripting_effect.h | 124 +++++++++++ engines/zvision/scripting/sidefx.h | 114 ---------- .../zvision/scripting/sidefx/animation_node.cpp | 213 ------------------ engines/zvision/scripting/sidefx/animation_node.h | 77 ------- engines/zvision/scripting/sidefx/distort_node.cpp | 104 --------- engines/zvision/scripting/sidefx/distort_node.h | 63 ------ engines/zvision/scripting/sidefx/music_node.cpp | 248 --------------------- engines/zvision/scripting/sidefx/music_node.h | 135 ----------- engines/zvision/scripting/sidefx/region_node.cpp | 56 ----- engines/zvision/scripting/sidefx/region_node.h | 57 ----- .../zvision/scripting/sidefx/syncsound_node.cpp | 85 ------- engines/zvision/scripting/sidefx/syncsound_node.h | 56 ----- engines/zvision/scripting/sidefx/timer_node.cpp | 81 ------- engines/zvision/scripting/sidefx/timer_node.h | 59 ----- engines/zvision/scripting/sidefx/ttytext_node.cpp | 174 --------------- engines/zvision/scripting/sidefx/ttytext_node.h | 73 ------ 45 files changed, 1755 insertions(+), 1740 deletions(-) delete mode 100644 engines/zvision/graphics/effect.h create mode 100644 engines/zvision/graphics/graphics_effect.h create mode 100644 engines/zvision/scripting/effects/animation_effect.cpp create mode 100644 engines/zvision/scripting/effects/animation_effect.h create mode 100644 engines/zvision/scripting/effects/distort_effect.cpp create mode 100644 engines/zvision/scripting/effects/distort_effect.h create mode 100644 engines/zvision/scripting/effects/music_effect.cpp create mode 100644 engines/zvision/scripting/effects/music_effect.h create mode 100644 engines/zvision/scripting/effects/region_effect.cpp create mode 100644 engines/zvision/scripting/effects/region_effect.h create mode 100644 engines/zvision/scripting/effects/syncsound_effect.cpp create mode 100644 engines/zvision/scripting/effects/syncsound_effect.h create mode 100644 engines/zvision/scripting/effects/timer_effect.cpp create mode 100644 engines/zvision/scripting/effects/timer_effect.h create mode 100644 engines/zvision/scripting/effects/ttytext_effect.cpp create mode 100644 engines/zvision/scripting/effects/ttytext_effect.h create mode 100644 engines/zvision/scripting/scripting_effect.h delete mode 100644 engines/zvision/scripting/sidefx.h delete mode 100644 engines/zvision/scripting/sidefx/animation_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/animation_node.h delete mode 100644 engines/zvision/scripting/sidefx/distort_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/distort_node.h delete mode 100644 engines/zvision/scripting/sidefx/music_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/music_node.h delete mode 100644 engines/zvision/scripting/sidefx/region_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/region_node.h delete mode 100644 engines/zvision/scripting/sidefx/syncsound_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/syncsound_node.h delete mode 100644 engines/zvision/scripting/sidefx/timer_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/timer_node.h delete mode 100644 engines/zvision/scripting/sidefx/ttytext_node.cpp delete mode 100644 engines/zvision/scripting/sidefx/ttytext_node.h diff --git a/engines/zvision/graphics/effect.h b/engines/zvision/graphics/effect.h deleted file mode 100644 index 234cd8209d..0000000000 --- a/engines/zvision/graphics/effect.h +++ /dev/null @@ -1,83 +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 EFFECT_H_INCLUDED -#define EFFECT_H_INCLUDED - -#include "common/rect.h" -#include "common/list.h" -#include "graphics/surface.h" - -#include "zvision/zvision.h" - -namespace ZVision { - -class ZVision; - -class Effect { -public: - - Effect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) { - _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat); - } - virtual ~Effect() {} - - uint32 getKey() { - return _key; - } - - Common::Rect getRegion() { - return _region; - } - - bool isPort() { - return _ported; - } - - virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) { - return &_surface; - } - - virtual void update() {} - -protected: - ZVision *_engine; - uint32 _key; - Common::Rect _region; - bool _ported; - Graphics::Surface _surface; - -// Static member functions -public: - -}; - -struct EffectMapUnit { - uint32 count; - bool inEffect; -}; - -typedef Common::List EffectMap; - -} // End of namespace ZVision - -#endif // EFFECT_H_INCLUDED diff --git a/engines/zvision/graphics/effects/fog.cpp b/engines/zvision/graphics/effects/fog.cpp index c28bdde330..32a01915d3 100644 --- a/engines/zvision/graphics/effects/fog.cpp +++ b/engines/zvision/graphics/effects/fog.cpp @@ -31,7 +31,7 @@ namespace ZVision { FogFx::FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds): - Effect(engine, key, region, ported) { + GraphicsEffect(engine, key, region, ported) { _map = Map; diff --git a/engines/zvision/graphics/effects/fog.h b/engines/zvision/graphics/effects/fog.h index fe88707bbe..498347609e 100644 --- a/engines/zvision/graphics/effects/fog.h +++ b/engines/zvision/graphics/effects/fog.h @@ -23,14 +23,14 @@ #ifndef ZVISION_FOG_H #define ZVISION_FOG_H -#include "zvision/graphics/effect.h" +#include "zvision/graphics/graphics_effect.h" namespace ZVision { class ZVision; // Used by Zork: Nemesis for the mixing chamber gas effect in the gas puzzle (location tt5e, when the blinds are down) -class FogFx : public Effect { +class FogFx : public GraphicsEffect { public: FogFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, const Common::String &clouds); diff --git a/engines/zvision/graphics/effects/light.cpp b/engines/zvision/graphics/effects/light.cpp index bf6513292f..39341687f8 100644 --- a/engines/zvision/graphics/effects/light.cpp +++ b/engines/zvision/graphics/effects/light.cpp @@ -30,7 +30,7 @@ namespace ZVision { LightFx::LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD, int8 maxD): - Effect(engine, key, region, ported) { + GraphicsEffect(engine, key, region, ported) { _map = Map; _delta = delta; _up = true; diff --git a/engines/zvision/graphics/effects/light.h b/engines/zvision/graphics/effects/light.h index ae87d66cb3..cd73a585ec 100644 --- a/engines/zvision/graphics/effects/light.h +++ b/engines/zvision/graphics/effects/light.h @@ -23,13 +23,13 @@ #ifndef LIGHTFX_H_INCLUDED #define LIGHTFX_H_INCLUDED -#include "zvision/graphics/effect.h" +#include "zvision/graphics/graphics_effect.h" namespace ZVision { class ZVision; -class LightFx : public Effect { +class LightFx : public GraphicsEffect { public: LightFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, EffectMap *Map, int8 delta, int8 minD = -127, int8 maxD = 127); diff --git a/engines/zvision/graphics/effects/wave.cpp b/engines/zvision/graphics/effects/wave.cpp index 1b3aa040e8..cec631611b 100644 --- a/engines/zvision/graphics/effects/wave.cpp +++ b/engines/zvision/graphics/effects/wave.cpp @@ -30,7 +30,7 @@ namespace ZVision { WaveFx::WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd): - Effect(engine, key, region, ported) { + GraphicsEffect(engine, key, region, ported) { _frame = 0; _frameCount = frames; diff --git a/engines/zvision/graphics/effects/wave.h b/engines/zvision/graphics/effects/wave.h index 2e813ed5b6..8e912372d7 100644 --- a/engines/zvision/graphics/effects/wave.h +++ b/engines/zvision/graphics/effects/wave.h @@ -24,13 +24,13 @@ #define WAVEFX_H_INCLUDED #include "common/array.h" -#include "zvision/graphics/effect.h" +#include "zvision/graphics/graphics_effect.h" namespace ZVision { class ZVision; -class WaveFx : public Effect { +class WaveFx : public GraphicsEffect { public: WaveFx(ZVision *engine, uint32 key, Common::Rect region, bool ported, int16 frames, int16 centerX, int16 centerY, float ampl, float waveln, float spd); diff --git a/engines/zvision/graphics/graphics_effect.h b/engines/zvision/graphics/graphics_effect.h new file mode 100644 index 0000000000..bfa266b11d --- /dev/null +++ b/engines/zvision/graphics/graphics_effect.h @@ -0,0 +1,83 @@ +/* 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 GRAPHICS_EFFECT_H_INCLUDED +#define GRAPHICS_EFFECT_H_INCLUDED + +#include "common/rect.h" +#include "common/list.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" + +namespace ZVision { + +class ZVision; + +class GraphicsEffect { +public: + + GraphicsEffect(ZVision *engine, uint32 key, Common::Rect region, bool ported) : _engine(engine), _key(key), _region(region), _ported(ported) { + _surface.create(_region.width(), _region.height(), _engine->_resourcePixelFormat); + } + virtual ~GraphicsEffect() {} + + uint32 getKey() { + return _key; + } + + Common::Rect getRegion() { + return _region; + } + + bool isPort() { + return _ported; + } + + virtual const Graphics::Surface *draw(const Graphics::Surface &srcSubRect) { + return &_surface; + } + + virtual void update() {} + +protected: + ZVision *_engine; + uint32 _key; + Common::Rect _region; + bool _ported; + Graphics::Surface _surface; + +// Static member functions +public: + +}; + +struct EffectMapUnit { + uint32 count; + bool inEffect; +}; + +typedef Common::List EffectMap; + +} // End of namespace ZVision + +#endif // GRAPHICS_EFFECT_H_INCLUDED diff --git a/engines/zvision/graphics/render_manager.cpp b/engines/zvision/graphics/render_manager.cpp index 1b80b379bf..a1cc8ac53c 100644 --- a/engines/zvision/graphics/render_manager.cpp +++ b/engines/zvision/graphics/render_manager.cpp @@ -772,7 +772,7 @@ Common::Point RenderManager::getBkgSize() { return Common::Point(_backgroundWidth, _backgroundHeight); } -void RenderManager::addEffect(Effect *_effect) { +void RenderManager::addEffect(GraphicsEffect *_effect) { _effects.push_back(_effect); } diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index d9a6c88896..9002d66b47 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -31,7 +31,7 @@ #include "graphics/surface.h" -#include "effect.h" +#include "graphics_effect.h" class OSystem; @@ -61,7 +61,7 @@ private: }; typedef Common::HashMap SubtitleMap; - typedef Common::List EffectsList; + typedef Common::List EffectsList; private: ZVision *_engine; @@ -302,7 +302,7 @@ public: void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination, bool transposed); // Add visual effect to effects list - void addEffect(Effect *_effect); + void addEffect(GraphicsEffect *_effect); // Delete effect(s) by ID (ID equal to slot of action:region that create this effect) void deleteEffect(uint32 ID); diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk index 8edd67b352..93fba2879d 100644 --- a/engines/zvision/module.mk +++ b/engines/zvision/module.mk @@ -32,13 +32,13 @@ MODULE_OBJS := \ scripting/menu.o \ scripting/scr_file_handling.o \ scripting/script_manager.o \ - scripting/sidefx/animation_node.o \ - scripting/sidefx/distort_node.o \ - scripting/sidefx/music_node.o \ - scripting/sidefx/region_node.o \ - scripting/sidefx/syncsound_node.o \ - scripting/sidefx/timer_node.o \ - scripting/sidefx/ttytext_node.o \ + scripting/effects/animation_effect.o \ + scripting/effects/distort_effect.o \ + scripting/effects/music_effect.o \ + scripting/effects/region_effect.o \ + scripting/effects/syncsound_effect.o \ + scripting/effects/timer_effect.o \ + scripting/effects/ttytext_effect.o \ sound/midi.o \ sound/zork_raw.o \ text/string_manager.o \ diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp index a91476760d..a61fa26223 100644 --- a/engines/zvision/scripting/actions.cpp +++ b/engines/zvision/scripting/actions.cpp @@ -31,16 +31,16 @@ #include "zvision/video/zork_avi_decoder.h" #include "zvision/file/save_manager.h" #include "zvision/scripting/menu.h" -#include "zvision/scripting/sidefx/timer_node.h" -#include "zvision/scripting/sidefx/music_node.h" -#include "zvision/scripting/sidefx/syncsound_node.h" -#include "zvision/scripting/sidefx/animation_node.h" -#include "zvision/scripting/sidefx/distort_node.h" -#include "zvision/scripting/sidefx/ttytext_node.h" -#include "zvision/scripting/sidefx/region_node.h" +#include "zvision/scripting/effects/timer_effect.h" +#include "zvision/scripting/effects/music_effect.h" +#include "zvision/scripting/effects/syncsound_effect.h" +#include "zvision/scripting/effects/animation_effect.h" +#include "zvision/scripting/effects/distort_effect.h" +#include "zvision/scripting/effects/ttytext_effect.h" +#include "zvision/scripting/effects/region_effect.h" #include "zvision/scripting/controls/titler_control.h" #include "zvision/graphics/render_table.h" -#include "zvision/graphics/effect.h" +#include "zvision/graphics/graphics_effect.h" #include "zvision/graphics/effects/fog.h" #include "zvision/graphics/effects/light.h" #include "zvision/graphics/effects/wave.h" @@ -106,8 +106,8 @@ ActionAttenuate::ActionAttenuate(ZVision *engine, int32 slotkey, const Common::S } bool ActionAttenuate::execute() { - SideFX *fx = _engine->getScriptManager()->getSideFX(_key); - if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_key); + if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNode *mus = (MusicNode *)fx; mus->setVolume(255 - (abs(_attenuation) >> 7)); } @@ -157,8 +157,8 @@ ActionCrossfade::ActionCrossfade(ZVision *engine, int32 slotkey, const Common::S bool ActionCrossfade::execute() { if (_keyOne) { - SideFX *fx = _engine->getScriptManager()->getSideFX(_keyOne); - if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyOne); + if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNode *mus = (MusicNode *)fx; if (_oneStartVolume >= 0) mus->setVolume((_oneStartVolume * 255) / 100); @@ -168,8 +168,8 @@ bool ActionCrossfade::execute() { } if (_keyTwo) { - SideFX *fx = _engine->getScriptManager()->getSideFX(_keyTwo); - if (fx && fx->getType() == SideFX::SIDEFX_AUDIO) { + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_keyTwo); + if (fx && fx->getType() == ScriptingEffect::SCRIPTING_EFFECT_AUDIO) { MusicNode *mus = (MusicNode *)fx; if (_twoStartVolume >= 0) mus->setVolume((_twoStartVolume * 255) / 100); @@ -401,28 +401,28 @@ ActionKill::ActionKill(ZVision *engine, int32 slotkey, const Common::String &lin sscanf(line.c_str(), "%24s", keytype); if (keytype[0] == '"') { if (!scumm_stricmp(keytype, "\"ANIM\"")) - _type = SideFX::SIDEFX_ANIM; + _type = ScriptingEffect::SCRIPTING_EFFECT_ANIM; else if (!scumm_stricmp(keytype, "\"AUDIO\"")) - _type = SideFX::SIDEFX_AUDIO; + _type = ScriptingEffect::SCRIPTING_EFFECT_AUDIO; else if (!scumm_stricmp(keytype, "\"DISTORT\"")) - _type = SideFX::SIDEFX_DISTORT; + _type = ScriptingEffect::SCRIPTING_EFFECT_DISTORT; else if (!scumm_stricmp(keytype, "\"PANTRACK\"")) - _type = SideFX::SIDEFX_PANTRACK; + _type = ScriptingEffect::SCRIPTING_EFFECT_PANTRACK; else if (!scumm_stricmp(keytype, "\"REGION\"")) - _type = SideFX::SIDEFX_REGION; + _type = ScriptingEffect::SCRIPTING_EFFECT_REGION; else if (!scumm_stricmp(keytype, "\"TIMER\"")) - _type = SideFX::SIDEFX_TIMER; + _type = ScriptingEffect::SCRIPTING_EFFECT_TIMER; else if (!scumm_stricmp(keytype, "\"TTYTEXT\"")) - _type = SideFX::SIDEFX_TTYTXT; + _type = ScriptingEffect::SCRIPTING_EFFECT_TTYTXT; else if (!scumm_stricmp(keytype, "\"ALL\"")) - _type = SideFX::SIDEFX_ALL; + _type = ScriptingEffect::SCRIPTING_EFFECT_ALL; } else _key = atoi(keytype); } bool ActionKill::execute() { if (_type) - _engine->getScriptManager()->killSideFxType((SideFX::SideFXType)_type); + _engine->getScriptManager()->killSideFxType((ScriptingEffect::ScriptingEffectType)_type); else _engine->getScriptManager()->killSideFx(_key); return true; @@ -580,10 +580,10 @@ ActionPreloadAnimation::~ActionPreloadAnimation() { } bool ActionPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey); + AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey); if (!nod) { - nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate, false); + nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate, false); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); @@ -603,9 +603,9 @@ ActionUnloadAnimation::ActionUnloadAnimation(ZVision *engine, int32 slotkey, con } bool ActionUnloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_key); + AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_key); - if (nod && nod->getType() == SideFX::SIDEFX_ANIM) + if (nod && nod->getType() == ScriptingEffect::SCRIPTING_EFFECT_ANIM) _engine->getScriptManager()->deleteSideFx(_key); return true; @@ -648,10 +648,10 @@ ActionPlayAnimation::~ActionPlayAnimation() { } bool ActionPlayAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_slotKey); + AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_slotKey); if (!nod) { - nod = new AnimationNode(_engine, _slotKey, _fileName, _mask, _framerate); + nod = new AnimationEffect(_engine, _slotKey, _fileName, _mask, _framerate); _engine->getScriptManager()->addSideFX(nod); } else nod->stop(); @@ -683,7 +683,7 @@ ActionPlayPreloadAnimation::ActionPlayPreloadAnimation(ZVision *engine, int32 sl } bool ActionPlayPreloadAnimation::execute() { - AnimationNode *nod = (AnimationNode *)_engine->getScriptManager()->getSideFX(_controlKey); + AnimationEffect *nod = (AnimationEffect *)_engine->getScriptManager()->getSideFX(_controlKey); if (nod) nod->addPlayNode(_slotKey, _x1, _y1, _x2, _y2, _startFrame, _endFrame, _loopCount); @@ -731,7 +731,7 @@ bool ActionRegion::execute() { if (_engine->getScriptManager()->getSideFX(_slotKey)) return true; - Effect *effect = NULL; + GraphicsEffect *effect = NULL; switch (_type) { case 0: { uint16 centerX, centerY, frames; @@ -982,11 +982,11 @@ ActionSyncSound::ActionSyncSound(ZVision *engine, int32 slotkey, const Common::S } bool ActionSyncSound::execute() { - SideFX *fx = _engine->getScriptManager()->getSideFX(_syncto); + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_syncto); if (!fx) return true; - if (!(fx->getType() & SideFX::SIDEFX_ANIM)) + if (!(fx->getType() & ScriptingEffect::SCRIPTING_EFFECT_ANIM)) return true; _engine->getScriptManager()->addSideFX(new SyncSoundNode(_engine, _slotKey, _fileName, _syncto)); diff --git a/engines/zvision/scripting/control.h b/engines/zvision/scripting/control.h index 803d0cf1ce..108b83fd00 100644 --- a/engines/zvision/scripting/control.h +++ b/engines/zvision/scripting/control.h @@ -36,6 +36,11 @@ namespace ZVision { class ZVision; +/** + * The base class for all Controls. + * + * Controls are the things that the user interacts with. Ex: A lever on the door + */ class Control { public: diff --git a/engines/zvision/scripting/effects/animation_effect.cpp b/engines/zvision/scripting/effects/animation_effect.cpp new file mode 100644 index 0000000000..c3cbc25406 --- /dev/null +++ b/engines/zvision/scripting/effects/animation_effect.cpp @@ -0,0 +1,213 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/animation_effect.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/scripting/script_manager.h" + +#include "graphics/surface.h" +#include "video/video_decoder.h" + +namespace ZVision { + +AnimationEffect::AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse) + : ScriptingEffect(engine, controlKey, SCRIPTING_EFFECT_ANIM), + _disposeAfterUse(disposeAfterUse), + _mask(mask), + _animation(NULL) { + + _animation = engine->loadAnimation(fileName); + + if (frate > 0) { + _frmDelayOverride = (int32)(1000.0 / frate); + + // WORKAROUND: We do not allow the engine to delay more than 66 msec + // per frame (15fps max) + if (_frmDelayOverride > 66) + _frmDelayOverride = 66; + } else { + _frmDelayOverride = 0; + } +} + +AnimationEffect::~AnimationEffect() { + if (_animation) + delete _animation; + + _engine->getScriptManager()->setStateValue(_key, 2); + + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + _engine->getScriptManager()->setStateValue((*it).slot, 2); + + if ((*it)._scaled) { + (*it)._scaled->free(); + delete(*it)._scaled; + } + } + + _playList.clear(); +} + +bool AnimationEffect::process(uint32 deltaTimeInMillis) { + ScriptManager *scriptManager = _engine->getScriptManager(); + RenderManager *renderManager = _engine->getRenderManager(); + RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState(); + bool isPanorama = (renderState == RenderTable::PANORAMA); + int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity(); + + // Do not update animation nodes in panoramic mode while turning, if the user + // has set this option + if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity) + return false; + + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + playnode *nod = &(*it); + + if (!_animation->isPlaying()) { + // The node is just beginning playback + _animation->start(); + _animation->seekToFrame(nod->start); + + nod->_delay = deltaTimeInMillis; // Force the frame to draw + if (nod->slot) + scriptManager->setStateValue(nod->slot, 1); + } else if (_animation->endOfVideo()) { + // The node has reached the end; check if we need to loop + nod->loop--; + + if (nod->loop == 0) { + if (nod->slot >= 0) + scriptManager->setStateValue(nod->slot, 2); + if (nod->_scaled) { + nod->_scaled->free(); + delete nod->_scaled; + } + _playList.erase(it); + return _disposeAfterUse; + } + + _animation->seekToFrame(nod->start); + } + + // Check if we need to draw a frame + bool needsUpdate = false; + if (_frmDelayOverride == 0) { + // If not overridden, use the VideoDecoder's check + needsUpdate = _animation->needsUpdate(); + } else { + // Otherwise, implement our own timing + nod->_delay -= deltaTimeInMillis; + + if (nod->_delay <= 0) { + nod->_delay += _frmDelayOverride; + needsUpdate = true; + } + } + + if (needsUpdate) { + const Graphics::Surface *frame = _animation->decodeNextFrame(); + + if (frame) { + uint32 dstw; + uint32 dsth; + if (isPanorama) { + dstw = nod->pos.height(); + dsth = nod->pos.width(); + } else { + dstw = nod->pos.width(); + dsth = nod->pos.height(); + } + + // We only scale down the animation to fit its frame, not up, otherwise we + // end up with distorted animations - e.g. the armor visor in location cz1e + // in Nemesis (one of the armors inside Irondune), or the planet in location + // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only + // when a simple 2x filter is requested (e.g. the alchemists and cup sequence + // in Nemesis) + if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) { + if (nod->_scaled) + if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { + nod->_scaled->free(); + delete nod->_scaled; + nod->_scaled = NULL; + } + + if (!nod->_scaled) { + nod->_scaled = new Graphics::Surface; + nod->_scaled->create(dstw, dsth, frame->format); + } + + renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); + frame = nod->_scaled; + } + + if (isPanorama) { + Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); + renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); + transposed->free(); + delete transposed; + } else { + renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); + } + } + } + } + + return false; +} + +void AnimationEffect::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) { + playnode nod; + nod.loop = loops; + nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); + nod.start = startFrame; + _animation->setEndFrame(CLIP(endFrame, 0, _animation->getFrameCount() - 1)); + + nod.slot = slot; + nod._delay = 0; + nod._scaled = NULL; + _playList.push_back(nod); +} + +bool AnimationEffect::stop() { + PlayNodes::iterator it = _playList.begin(); + if (it != _playList.end()) { + _engine->getScriptManager()->setStateValue((*it).slot, 2); + if ((*it)._scaled) { + (*it)._scaled->free(); + delete(*it)._scaled; + } + } + + _playList.clear(); + + // We don't need to delete, it's may be reused + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/animation_effect.h b/engines/zvision/scripting/effects/animation_effect.h new file mode 100644 index 0000000000..a564b83ff3 --- /dev/null +++ b/engines/zvision/scripting/effects/animation_effect.h @@ -0,0 +1,77 @@ +/* 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 ZVISION_ANIMATION_NODE_H +#define ZVISION_ANIMATION_NODE_H + +#include "zvision/scripting/scripting_effect.h" +#include "common/rect.h" +#include "common/list.h" + +namespace Graphics { +struct Surface; +} + +namespace Video { + class VideoDecoder; +} + +namespace ZVision { + +class ZVision; + +class AnimationEffect : public ScriptingEffect { +public: + AnimationEffect(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true); + ~AnimationEffect(); + + struct playnode { + Common::Rect pos; + int32 slot; + int32 start; + int32 loop; + int32 _delay; + Graphics::Surface *_scaled; + }; + +private: + typedef Common::List PlayNodes; + + PlayNodes _playList; + + int32 _mask; + bool _disposeAfterUse; + + Video::VideoDecoder *_animation; + int32 _frmDelayOverride; + +public: + bool process(uint32 deltaTimeInMillis); + + void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1); + + bool stop(); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/distort_effect.cpp b/engines/zvision/scripting/effects/distort_effect.cpp new file mode 100644 index 0000000000..78c4a1b9a8 --- /dev/null +++ b/engines/zvision/scripting/effects/distort_effect.cpp @@ -0,0 +1,104 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/distort_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/graphics/render_table.h" + +#include "common/stream.h" + +namespace ZVision { + +DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale) + : ScriptingEffect(engine, key, SCRIPTING_EFFECT_DISTORT) { + + _angle = _engine->getRenderManager()->getRenderTable()->getAngle(); + _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale(); + + _speed = speed; + _incr = true; + _startAngle = startAngle; + _endAngle = endAngle; + _startLineScale = startLineScale; + _endLineScale = endLineScale; + + _curFrame = 1.0; + + _diffAngle = endAngle - startAngle; + _diffLinScale = endLineScale - startLineScale; + + _frmSpeed = (float)speed / 15.0; + _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); + if (_frames <= 0) + _frames = 1; + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +DistortNode::~DistortNode() { + setParams(_angle, _linScale); +} + +bool DistortNode::process(uint32 deltaTimeInMillis) { + float updTime = deltaTimeInMillis / (1000.0 / 60.0); + + if (_incr) + _curFrame += updTime; + else + _curFrame -= updTime; + + if (_curFrame < 1.0) { + _curFrame = 1.0; + _incr = true; + } else if (_curFrame > _frames) { + _curFrame = _frames; + _incr = false; + } + + float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed); + setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale); + + return false; +} + +void DistortNode::setParams(float angl, float linScale) { + RenderTable *table = _engine->getRenderManager()->getRenderTable(); + if (table->getRenderState() == RenderTable::PANORAMA) { + table->setPanoramaFoV(angl); + table->setPanoramaScale(linScale); + table->generateRenderTable(); + _engine->getRenderManager()->markDirty(); + } else if (table->getRenderState() == RenderTable::TILT) { + table->setTiltFoV(angl); + table->setTiltScale(linScale); + table->generateRenderTable(); + _engine->getRenderManager()->markDirty(); + } +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/distort_effect.h b/engines/zvision/scripting/effects/distort_effect.h new file mode 100644 index 0000000000..c64f10e6ff --- /dev/null +++ b/engines/zvision/scripting/effects/distort_effect.h @@ -0,0 +1,63 @@ +/* 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 ZVISION_DISTORT_NODE_H +#define ZVISION_DISTORT_NODE_H + +#include "zvision/scripting/scripting_effect.h" + +namespace ZVision { + +class ZVision; + +class DistortNode : public ScriptingEffect { +public: + DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale); + ~DistortNode(); + + bool process(uint32 deltaTimeInMillis); + +private: + int16 _speed; + float _startAngle; + float _endAngle; + float _startLineScale; + float _endLineScale; + + float _frmSpeed; + float _diffAngle; + float _diffLinScale; + bool _incr; + int16 _frames; + + float _curFrame; + + float _angle; + float _linScale; + +private: + void setParams(float angl, float linScale); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/music_effect.cpp b/engines/zvision/scripting/effects/music_effect.cpp new file mode 100644 index 0000000000..102f330305 --- /dev/null +++ b/engines/zvision/scripting/effects/music_effect.cpp @@ -0,0 +1,248 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/music_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/midi.h" +#include "zvision/sound/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + +namespace ZVision { + +MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) + : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) { + _loop = loop; + _volume = volume; + _crossfade = false; + _crossfadeTarget = 0; + _crossfadeTime = 0; + _attenuate = 0; + _pantrack = false; + _pantrackPosition = 0; + _sub = NULL; + _stereo = false; + _loaded = false; + + Audio::RewindableAudioStream *audioStream = NULL; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (_engine->getSearchManager()->openFile(*file, filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + if (audioStream) { + _stereo = audioStream->isStereo(); + + if (_loop) { + Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); + } else { + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); + } + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); + + // Change filename.raw into filename.sub + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); + + _loaded = true; + } +} + +MusicNode::~MusicNode() { + if (_loaded) + _engine->_mixer->stopHandle(_handle); + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + if (_sub) + delete _sub; + debug(1, "MusicNode: %d destroyed\n", _key); +} + +void MusicNode::setPanTrack(int16 pos) { + if (!_stereo) { + _pantrack = true; + _pantrackPosition = pos; + setVolume(_volume); + } +} + +void MusicNode::unsetPanTrack() { + _pantrack = false; + setVolume(_volume); +} + +void MusicNode::setFade(int32 time, uint8 target) { + _crossfadeTarget = target; + _crossfadeTime = time; + _crossfade = true; +} + +bool MusicNode::process(uint32 deltaTimeInMillis) { + if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle)) + return stop(); + else { + uint8 _newvol = _volume; + + if (_crossfade) { + if (_crossfadeTime > 0) { + if ((int32)deltaTimeInMillis > _crossfadeTime) + deltaTimeInMillis = _crossfadeTime; + _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis; + _crossfadeTime -= deltaTimeInMillis; + } else { + _crossfade = false; + _newvol = _crossfadeTarget; + } + } + + if (_pantrack || _volume != _newvol) + setVolume(_newvol); + + if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); + } + return false; +} + +void MusicNode::setVolume(uint8 newVolume) { + if (!_loaded) + return; + if (_pantrack) { + int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); + curX -= _pantrackPosition; + int32 _width = _engine->getRenderManager()->getBkgSize().x; + if (curX < (-_width) / 2) + curX += _width; + else if (curX >= _width / 2) + curX -= _width; + + float norm = (float)curX / ((float)_width / 2.0); + float lvl = fabs(norm); + if (lvl > 0.5) + lvl = (lvl - 0.5) * 1.7; + else + lvl = 1.0; + + float bal = sin(-norm * 3.1415926) * 127.0; + + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, bal); + _engine->_mixer->setChannelVolume(_handle, newVolume * lvl); + } + } else { + if (_engine->_mixer->isSoundHandleActive(_handle)) { + _engine->_mixer->setChannelBalance(_handle, 0); + _engine->_mixer->setChannelVolume(_handle, newVolume); + } + } + + _volume = newVolume; +} + +PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) + : ScriptingEffect(engine, key, SCRIPTING_EFFECT_PANTRACK) { + _slot = slot; + + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(slot); + if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) { + MusicNodeBASE *mus = (MusicNodeBASE *)fx; + mus->setPanTrack(pos); + } +} + +PanTrackNode::~PanTrackNode() { + ScriptingEffect *fx = _engine->getScriptManager()->getSideFX(_slot); + if (fx && fx->getType() == SCRIPTING_EFFECT_AUDIO) { + MusicNodeBASE *mus = (MusicNodeBASE *)fx; + mus->unsetPanTrack(); + } +} + +MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) + : MusicNodeBASE(engine, key, SCRIPTING_EFFECT_AUDIO) { + _volume = volume; + _prog = program; + _noteNumber = note; + _pan = 0; + + _chan = _engine->getMidiManager()->getFreeChannel(); + + if (_chan >= 0) { + _engine->getMidiManager()->setVolume(_chan, _volume); + _engine->getMidiManager()->setPan(_chan, _pan); + _engine->getMidiManager()->setProgram(_chan, _prog); + _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume); + } + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +MusicMidiNode::~MusicMidiNode() { + if (_chan >= 0) { + _engine->getMidiManager()->noteOff(_chan); + } + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); +} + +void MusicMidiNode::setPanTrack(int16 pos) { +} + +void MusicMidiNode::unsetPanTrack() { +} + +void MusicMidiNode::setFade(int32 time, uint8 target) { +} + +bool MusicMidiNode::process(uint32 deltaTimeInMillis) { + return false; +} + +void MusicMidiNode::setVolume(uint8 newVolume) { + if (_chan >= 0) { + _engine->getMidiManager()->setVolume(_chan, newVolume); + } + _volume = newVolume; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/music_effect.h b/engines/zvision/scripting/effects/music_effect.h new file mode 100644 index 0000000000..31d538f668 --- /dev/null +++ b/engines/zvision/scripting/effects/music_effect.h @@ -0,0 +1,135 @@ +/* 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 ZVISION_MUSIC_NODE_H +#define ZVISION_MUSIC_NODE_H + +#include "audio/mixer.h" +#include "zvision/scripting/scripting_effect.h" +#include "zvision/text/subtitles.h" + +namespace Common { +class String; +} + +namespace ZVision { + +class MusicNodeBASE : public ScriptingEffect { +public: + MusicNodeBASE(ZVision *engine, uint32 key, ScriptingEffectType type) : ScriptingEffect(engine, key, type) {} + ~MusicNodeBASE() {} + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + virtual bool process(uint32 deltaTimeInMillis) = 0; + + virtual void setVolume(uint8 volume) = 0; + + virtual void setPanTrack(int16 pos) = 0; + virtual void unsetPanTrack() = 0; + + virtual void setFade(int32 time, uint8 target) = 0; +}; + +class MusicNode : public MusicNodeBASE { +public: + MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); + ~MusicNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + + void setVolume(uint8 volume); + + void setPanTrack(int16 pos); + void unsetPanTrack(); + + void setFade(int32 time, uint8 target); + +private: + bool _pantrack; + int32 _pantrackPosition; + int32 _attenuate; + uint8 _volume; + bool _loop; + bool _crossfade; + uint8 _crossfadeTarget; + int32 _crossfadeTime; + bool _stereo; + Audio::SoundHandle _handle; + Subtitle *_sub; + bool _loaded; +}; + +// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr) +class MusicMidiNode : public MusicNodeBASE { +public: + MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); + ~MusicMidiNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + + void setVolume(uint8 volume); + + void setPanTrack(int16 pos); + void unsetPanTrack(); + + void setFade(int32 time, uint8 target); + +private: + int8 _chan; + int8 _noteNumber; + int8 _pan; + int8 _volume; + int8 _prog; +}; + +class PanTrackNode : public ScriptingEffect { +public: + PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); + ~PanTrackNode(); + +private: + uint32 _slot; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/region_effect.cpp b/engines/zvision/scripting/effects/region_effect.cpp new file mode 100644 index 0000000000..78061cf4de --- /dev/null +++ b/engines/zvision/scripting/effects/region_effect.cpp @@ -0,0 +1,56 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/region_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" + +namespace ZVision { + +RegionNode::RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay) + : ScriptingEffect(engine, key, SCRIPTING_EFFECT_REGION) { + _effect = effect; + _delay = delay; + _timeLeft = 0; +} + +RegionNode::~RegionNode() { + _engine->getRenderManager()->deleteEffect(_key); +} + +bool RegionNode::process(uint32 deltaTimeInMillis) { + _timeLeft -= deltaTimeInMillis; + + if (_timeLeft <= 0) { + _timeLeft = _delay; + if (_effect) + _effect->update(); + } + + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/region_effect.h b/engines/zvision/scripting/effects/region_effect.h new file mode 100644 index 0000000000..4fc16224ff --- /dev/null +++ b/engines/zvision/scripting/effects/region_effect.h @@ -0,0 +1,57 @@ +/* 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 ZVISION_REGION_NODE_H +#define ZVISION_REGION_NODE_H + +#include "graphics/surface.h" + +#include "zvision/scripting/scripting_effect.h" +#include "zvision/graphics/graphics_effect.h" + +namespace ZVision { + +class ZVision; + +class RegionNode : public ScriptingEffect { +public: + RegionNode(ZVision *engine, uint32 key, GraphicsEffect *effect, uint32 delay); + ~RegionNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + +private: + int32 _timeLeft; + uint32 _delay; + GraphicsEffect *_effect; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/syncsound_effect.cpp b/engines/zvision/scripting/effects/syncsound_effect.cpp new file mode 100644 index 0000000000..70ba97deb8 --- /dev/null +++ b/engines/zvision/scripting/effects/syncsound_effect.cpp @@ -0,0 +1,85 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/syncsound_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/sound/zork_raw.h" + +#include "common/stream.h" +#include "common/file.h" +#include "audio/decoders/wave.h" + +namespace ZVision { + +SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) + : ScriptingEffect(engine, key, SCRIPTING_EFFECT_AUDIO) { + _syncto = syncto; + _sub = NULL; + + Audio::RewindableAudioStream *audioStream = NULL; + + if (filename.contains(".wav")) { + Common::File *file = new Common::File(); + if (_engine->getSearchManager()->openFile(*file, filename)) { + audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); + } + } else { + audioStream = makeRawZorkStream(filename, _engine); + } + + _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream); + + Common::String subname = filename; + subname.setChar('s', subname.size() - 3); + subname.setChar('u', subname.size() - 2); + subname.setChar('b', subname.size() - 1); + + if (_engine->getSearchManager()->hasFile(subname)) + _sub = new Subtitle(_engine, subname); +} + +SyncSoundNode::~SyncSoundNode() { + _engine->_mixer->stopHandle(_handle); + if (_sub) + delete _sub; +} + +bool SyncSoundNode::process(uint32 deltaTimeInMillis) { + if (! _engine->_mixer->isSoundHandleActive(_handle)) + return stop(); + else { + + if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) + return stop(); + + if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) + _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); + } + return false; +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/syncsound_effect.h b/engines/zvision/scripting/effects/syncsound_effect.h new file mode 100644 index 0000000000..0eabff77a3 --- /dev/null +++ b/engines/zvision/scripting/effects/syncsound_effect.h @@ -0,0 +1,56 @@ +/* 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 ZVISION_SYNCSOUND_NODE_H +#define ZVISION_SYNCSOUND_NODE_H + +#include "audio/mixer.h" +#include "zvision/scripting/scripting_effect.h" +#include "zvision/text/subtitles.h" + +namespace Common { +class String; +} + +namespace ZVision { +class SyncSoundNode : public ScriptingEffect { +public: + SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto); + ~SyncSoundNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + int32 _syncto; + Audio::SoundHandle _handle; + Subtitle *_sub; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/timer_effect.cpp b/engines/zvision/scripting/effects/timer_effect.cpp new file mode 100644 index 0000000000..778f9dec6c --- /dev/null +++ b/engines/zvision/scripting/effects/timer_effect.cpp @@ -0,0 +1,81 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/timer_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" + +#include "common/stream.h" + +namespace ZVision { + +TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) + : ScriptingEffect(engine, key, SCRIPTING_EFFECT_TIMER) { + _timeLeft = 0; + + if (_engine->getGameId() == GID_NEMESIS) + _timeLeft = timeInSeconds * 1000; + else if (_engine->getGameId() == GID_GRANDINQUISITOR) + _timeLeft = timeInSeconds * 100; + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); +} + +TimerNode::~TimerNode() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); + if (timeLeft > 0) + _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill +} + +bool TimerNode::process(uint32 deltaTimeInMillis) { + _timeLeft -= deltaTimeInMillis; + + if (_timeLeft <= 0) + return stop(); + + return false; +} + +bool TimerNode::stop() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + return true; +} + +void TimerNode::serialize(Common::WriteStream *stream) { + stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); + stream->writeUint32LE(8); // size + stream->writeUint32LE(_key); + stream->writeUint32LE(_timeLeft); +} + +void TimerNode::deserialize(Common::SeekableReadStream *stream) { + _timeLeft = stream->readUint32LE(); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/timer_effect.h b/engines/zvision/scripting/effects/timer_effect.h new file mode 100644 index 0000000000..5e45d54d7d --- /dev/null +++ b/engines/zvision/scripting/effects/timer_effect.h @@ -0,0 +1,59 @@ +/* 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 ZVISION_TIMER_NODE_H +#define ZVISION_TIMER_NODE_H + +#include "zvision/scripting/scripting_effect.h" + +namespace ZVision { + +class ZVision; + +class TimerNode : public ScriptingEffect { +public: + TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); + ~TimerNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); + void serialize(Common::WriteStream *stream); + void deserialize(Common::SeekableReadStream *stream); + inline bool needsSerialization() { + return true; + } + + bool stop(); + +private: + int32 _timeLeft; +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/effects/ttytext_effect.cpp b/engines/zvision/scripting/effects/ttytext_effect.cpp new file mode 100644 index 0000000000..c60b3aa8c5 --- /dev/null +++ b/engines/zvision/scripting/effects/ttytext_effect.cpp @@ -0,0 +1,174 @@ +/* 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 "common/scummsys.h" + +#include "zvision/scripting/effects/ttytext_effect.h" + +#include "zvision/zvision.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/text/text.h" + +#include "common/stream.h" +#include "common/file.h" + +namespace ZVision { + +ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : + ScriptingEffect(engine, key, SCRIPTING_EFFECT_TTYTXT), + _fnt(engine) { + _delay = delay; + _r = r; + _txtpos = 0; + _nexttime = 0; + _dx = 0; + _dy = 0; + + Common::File *infile = _engine->getSearchManager()->openFile(file); + if (infile) { + while (!infile->eos()) { + Common::String asciiLine = readWideLine(*infile); + if (asciiLine.empty()) { + continue; + } + _txtbuf += asciiLine; + } + + delete infile; + } + _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat); + _style._sharp = true; + _style.readAllStyle(_txtbuf); + _style.setFont(_fnt); + _engine->getScriptManager()->setStateValue(_key, 1); +} + +ttyTextNode::~ttyTextNode() { + _engine->getScriptManager()->setStateValue(_key, 2); + _img.free(); +} + +bool ttyTextNode::process(uint32 deltaTimeInMillis) { + _nexttime -= deltaTimeInMillis; + + if (_nexttime < 0) { + if (_txtpos < _txtbuf.size()) { + if (_txtbuf[_txtpos] == '<') { + int32 strt = _txtpos; + int32 endt = 0; + int16 ret = 0; + while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) + _txtpos++; + endt = _txtpos; + if (strt != -1) + if ((endt - strt - 1) > 0) + ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); + + if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { + if (ret & TXT_RET_FNTCHG) + _style.setFont(_fnt); + if (ret & TXT_RET_FNTSTL) + _style.setFontStyle(_fnt); + + if (ret & TXT_RET_NEWLN) + newline(); + } + + if (ret & TXT_RET_HASSTBOX) { + Common::String buf; + buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox)); + + for (uint8 j = 0; j < buf.size(); j++) + outchar(buf[j]); + } + + _txtpos++; + } else { + int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]); + + uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + if (chr == ' ') { + uint32 i = _txtpos + charsz; + uint16 width = _fnt.getCharWidth(chr); + + while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') { + + int8 chsz = getUtf8CharSize(_txtbuf[i]); + uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos); + + width += _fnt.getCharWidth(uchr); + + i += chsz; + } + + if (_dx + width > _r.width()) + newline(); + else + outchar(chr); + } else + outchar(chr); + + _txtpos += charsz; + } + _nexttime = _delay; + _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top); + } else + return stop(); + } + + return false; +} + +void ttyTextNode::scroll() { + int32 scrl = 0; + while (_dy - scrl > _r.height() - _fnt.getFontHeight()) + scrl += _fnt.getFontHeight(); + int8 *pixels = (int8 *)_img.getPixels(); + for (uint16 h = scrl; h < _img.h; h++) + memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch); + + _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0); + _dy -= scrl; +} + +void ttyTextNode::newline() { + _dy += _fnt.getFontHeight(); + _dx = 0; +} + +void ttyTextNode::outchar(uint16 chr) { + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue); + + if (_dx + _fnt.getCharWidth(chr) > _r.width()) + newline(); + + if (_dy + _fnt.getFontHeight() >= _r.height()) + scroll(); + + _fnt.drawChar(&_img, chr, _dx, _dy, clr); + + _dx += _fnt.getCharWidth(chr); +} + +} // End of namespace ZVision diff --git a/engines/zvision/scripting/effects/ttytext_effect.h b/engines/zvision/scripting/effects/ttytext_effect.h new file mode 100644 index 0000000000..8d8a2518c7 --- /dev/null +++ b/engines/zvision/scripting/effects/ttytext_effect.h @@ -0,0 +1,73 @@ +/* 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 ZVISION_TTYTEXT_NODE_H +#define ZVISION_TTYTEXT_NODE_H + +#include "common/rect.h" +#include "graphics/surface.h" + +#include "zvision/scripting/scripting_effect.h" +#include "zvision/text/text.h" +#include "zvision/text/truetype_font.h" + +namespace Common { +class String; +} + +namespace ZVision { +class ttyTextNode : public ScriptingEffect { +public: + ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay); + ~ttyTextNode(); + + /** + * Decrement the timer by the delta time. If the timer is finished, set the status + * in _globalState and let this node be deleted + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + bool process(uint32 deltaTimeInMillis); +private: + Common::Rect _r; + + cTxtStyle _style; + StyledTTFont _fnt; + Common::String _txtbuf; + uint32 _txtpos; + + int32 _delay; + int32 _nexttime; + Graphics::Surface _img; + int16 _dx; + int16 _dy; +private: + + void newline(); + void scroll(); + void outchar(uint16 chr); +}; + +} // End of namespace ZVision + +#endif diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp index d0ebb18944..464e8bfe4d 100644 --- a/engines/zvision/scripting/script_manager.cpp +++ b/engines/zvision/scripting/script_manager.cpp @@ -30,7 +30,7 @@ #include "zvision/file/save_manager.h" #include "zvision/scripting/actions.h" #include "zvision/scripting/menu.h" -#include "zvision/scripting/sidefx/timer_node.h" +#include "zvision/scripting/effects/timer_effect.h" #include "common/algorithm.h" #include "common/hashmap.h" @@ -382,11 +382,11 @@ void ScriptManager::setFocusControlKey(uint32 key) { _currentlyFocusedControl = key; } -void ScriptManager::addSideFX(SideFX *fx) { +void ScriptManager::addSideFX(ScriptingEffect *fx) { _activeSideFx.push_back(fx); } -SideFX *ScriptManager::getSideFX(uint32 key) { +ScriptingEffect *ScriptManager::getSideFX(uint32 key) { for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end(); ++iter) { if ((*iter)->getKey() == key) { return (*iter); @@ -430,7 +430,7 @@ void ScriptManager::killSideFx(uint32 key) { } } -void ScriptManager::killSideFxType(SideFX::SideFXType type) { +void ScriptManager::killSideFxType(ScriptingEffect::ScriptingEffectType type) { for (SideFXList::iterator iter = _activeSideFx.begin(); iter != _activeSideFx.end();) { if ((*iter)->getType() & type) { (*iter)->kill(); diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h index 9f0f2f6e10..78c1b77dea 100644 --- a/engines/zvision/scripting/script_manager.h +++ b/engines/zvision/scripting/script_manager.h @@ -25,7 +25,7 @@ #include "zvision/scripting/puzzle.h" #include "zvision/scripting/control.h" -#include "zvision/scripting/sidefx.h" +#include "zvision/scripting/scripting_effect.h" #include "common/hashmap.h" #include "common/queue.h" @@ -116,7 +116,7 @@ typedef Common::List PuzzleList; typedef Common::Queue PuzzleQueue; typedef Common::List ControlList; typedef Common::HashMap StateMap; -typedef Common::List SideFXList; +typedef Common::List SideFXList; typedef Common::List EventList; class ScriptManager { @@ -196,12 +196,12 @@ public: // Only change focus control without call focus/unfocus. void setFocusControlKey(uint32 key); - void addSideFX(SideFX *fx); - SideFX *getSideFX(uint32 key); + void addSideFX(ScriptingEffect *fx); + ScriptingEffect *getSideFX(uint32 key); void deleteSideFx(uint32 key); void stopSideFx(uint32 key); void killSideFx(uint32 key); - void killSideFxType(SideFX::SideFXType type); + void killSideFxType(ScriptingEffect::ScriptingEffectType type); void addEvent(Common::Event); void flushEvent(Common::EventType type); diff --git a/engines/zvision/scripting/scripting_effect.h b/engines/zvision/scripting/scripting_effect.h new file mode 100644 index 0000000000..0af1d9c21c --- /dev/null +++ b/engines/zvision/scripting/scripting_effect.h @@ -0,0 +1,124 @@ +/* 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 SCRIPTING_EFFECT_H_INCLUDED +#define SCRIPTING_EFFECT_H_INCLUDED + +namespace Common { +class SeekableReadStream; +struct Point; +class WriteStream; +} + +namespace ZVision { + +class ZVision; + +/** + * The base class that represents effects created from Actions. + * This class is virtual. + * + * Detailed Description: + * A scene has Controls. By interacting with the controls, the user + * causes Actions to execute. Certain Actions create 'effects', for + * example, a sound or an animation. This is the base class for + * those effects. + */ +class ScriptingEffect { +public: + + enum ScriptingEffectType { + SCRIPTING_EFFECT_ANIM = 1, + SCRIPTING_EFFECT_AUDIO = 2, + SCRIPTING_EFFECT_DISTORT = 4, + SCRIPTING_EFFECT_PANTRACK = 8, + SCRIPTING_EFFECT_REGION = 16, + SCRIPTING_EFFECT_TIMER = 32, + SCRIPTING_EFFECT_TTYTXT = 64, + SCRIPTING_EFFECT_UNKNOWN = 128, + SCRIPTING_EFFECT_ALL = 255 + }; + + ScriptingEffect() : _engine(0), _key(0), _type(SCRIPTING_EFFECT_UNKNOWN) {} + ScriptingEffect(ZVision *engine, uint32 key, ScriptingEffectType type) : _engine(engine), _key(key), _type(type) {} + virtual ~ScriptingEffect() {} + + uint32 getKey() { + return _key; + } + ScriptingEffectType getType() { + return _type; + } + + virtual bool process(uint32 deltaTimeInMillis) { + return false; + } + /** + * Serialize a SideFX for save game use. This should only be used if a SideFX needs + * to save values that would be different from initialization. AKA a TimerNode needs to + * store the amount of time left on the timer. Any Controls overriding this *MUST* write + * their key as the first data outputted. The default implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override deserialize() + * and needsSerialization() + * + * @param stream Stream to write any needed data to + */ + virtual void serialize(Common::WriteStream *stream) {} + /** + * De-serialize data from a save game stream. This should only be implemented if the + * SideFX also implements serialize(). The calling method assumes the size of the + * data read from the stream exactly equals that written in serialize(). The default + * implementation is NOP. + * + * NOTE: If this method is overridden, you MUST also override serialize() + * and needsSerialization() + * + * @param stream Save game file stream + */ + virtual void deserialize(Common::SeekableReadStream *stream) {} + /** + * If a SideFX overrides serialize() and deserialize(), this should return true + * + * @return Does the SideFX need save game serialization? + */ + virtual inline bool needsSerialization() { + return false; + } + + virtual bool stop() { + return true; + } + virtual void kill() {} + +protected: + ZVision *_engine; + uint32 _key; + ScriptingEffectType _type; + +// Static member functions +public: + +}; +} // End of namespace ZVision + +#endif // SCRIPTING_EFFECT_H_INCLUDED diff --git a/engines/zvision/scripting/sidefx.h b/engines/zvision/scripting/sidefx.h deleted file mode 100644 index 5bb14f0cdd..0000000000 --- a/engines/zvision/scripting/sidefx.h +++ /dev/null @@ -1,114 +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 SIDEFX_H_INCLUDED -#define SIDEFX_H_INCLUDED - -namespace Common { -class SeekableReadStream; -struct Point; -class WriteStream; -} - -namespace ZVision { - -class ZVision; - -class SideFX { -public: - - enum SideFXType { - SIDEFX_ANIM = 1, - SIDEFX_AUDIO = 2, - SIDEFX_DISTORT = 4, - SIDEFX_PANTRACK = 8, - SIDEFX_REGION = 16, - SIDEFX_TIMER = 32, - SIDEFX_TTYTXT = 64, - SIDEFX_UNK = 128, - SIDEFX_ALL = 255 - }; - - SideFX() : _engine(0), _key(0), _type(SIDEFX_UNK) {} - SideFX(ZVision *engine, uint32 key, SideFXType type) : _engine(engine), _key(key), _type(type) {} - virtual ~SideFX() {} - - uint32 getKey() { - return _key; - } - SideFXType getType() { - return _type; - } - - virtual bool process(uint32 deltaTimeInMillis) { - return false; - } - /** - * Serialize a SideFX for save game use. This should only be used if a SideFX needs - * to save values that would be different from initialization. AKA a TimerNode needs to - * store the amount of time left on the timer. Any Controls overriding this *MUST* write - * their key as the first data outputted. The default implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override deserialize() - * and needsSerialization() - * - * @param stream Stream to write any needed data to - */ - virtual void serialize(Common::WriteStream *stream) {} - /** - * De-serialize data from a save game stream. This should only be implemented if the - * SideFX also implements serialize(). The calling method assumes the size of the - * data read from the stream exactly equals that written in serialize(). The default - * implementation is NOP. - * - * NOTE: If this method is overridden, you MUST also override serialize() - * and needsSerialization() - * - * @param stream Save game file stream - */ - virtual void deserialize(Common::SeekableReadStream *stream) {} - /** - * If a SideFX overrides serialize() and deserialize(), this should return true - * - * @return Does the SideFX need save game serialization? - */ - virtual inline bool needsSerialization() { - return false; - } - - virtual bool stop() { - return true; - } - virtual void kill() {} - -protected: - ZVision *_engine; - uint32 _key; - SideFXType _type; - -// Static member functions -public: - -}; -} // End of namespace ZVision - -#endif // SIDEFX_H_INCLUDED diff --git a/engines/zvision/scripting/sidefx/animation_node.cpp b/engines/zvision/scripting/sidefx/animation_node.cpp deleted file mode 100644 index 07eda692c1..0000000000 --- a/engines/zvision/scripting/sidefx/animation_node.cpp +++ /dev/null @@ -1,213 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/animation_node.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/scripting/script_manager.h" - -#include "graphics/surface.h" -#include "video/video_decoder.h" - -namespace ZVision { - -AnimationNode::AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse) - : SideFX(engine, controlKey, SIDEFX_ANIM), - _disposeAfterUse(disposeAfterUse), - _mask(mask), - _animation(NULL) { - - _animation = engine->loadAnimation(fileName); - - if (frate > 0) { - _frmDelayOverride = (int32)(1000.0 / frate); - - // WORKAROUND: We do not allow the engine to delay more than 66 msec - // per frame (15fps max) - if (_frmDelayOverride > 66) - _frmDelayOverride = 66; - } else { - _frmDelayOverride = 0; - } -} - -AnimationNode::~AnimationNode() { - if (_animation) - delete _animation; - - _engine->getScriptManager()->setStateValue(_key, 2); - - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - _engine->getScriptManager()->setStateValue((*it).slot, 2); - - if ((*it)._scaled) { - (*it)._scaled->free(); - delete(*it)._scaled; - } - } - - _playList.clear(); -} - -bool AnimationNode::process(uint32 deltaTimeInMillis) { - ScriptManager *scriptManager = _engine->getScriptManager(); - RenderManager *renderManager = _engine->getRenderManager(); - RenderTable::RenderState renderState = renderManager->getRenderTable()->getRenderState(); - bool isPanorama = (renderState == RenderTable::PANORAMA); - int16 velocity = _engine->getMouseVelocity() + _engine->getKeyboardVelocity(); - - // Do not update animation nodes in panoramic mode while turning, if the user - // has set this option - if (scriptManager->getStateValue(StateKey_NoTurnAnim) == 1 && isPanorama && velocity) - return false; - - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - playnode *nod = &(*it); - - if (!_animation->isPlaying()) { - // The node is just beginning playback - _animation->start(); - _animation->seekToFrame(nod->start); - - nod->_delay = deltaTimeInMillis; // Force the frame to draw - if (nod->slot) - scriptManager->setStateValue(nod->slot, 1); - } else if (_animation->endOfVideo()) { - // The node has reached the end; check if we need to loop - nod->loop--; - - if (nod->loop == 0) { - if (nod->slot >= 0) - scriptManager->setStateValue(nod->slot, 2); - if (nod->_scaled) { - nod->_scaled->free(); - delete nod->_scaled; - } - _playList.erase(it); - return _disposeAfterUse; - } - - _animation->seekToFrame(nod->start); - } - - // Check if we need to draw a frame - bool needsUpdate = false; - if (_frmDelayOverride == 0) { - // If not overridden, use the VideoDecoder's check - needsUpdate = _animation->needsUpdate(); - } else { - // Otherwise, implement our own timing - nod->_delay -= deltaTimeInMillis; - - if (nod->_delay <= 0) { - nod->_delay += _frmDelayOverride; - needsUpdate = true; - } - } - - if (needsUpdate) { - const Graphics::Surface *frame = _animation->decodeNextFrame(); - - if (frame) { - uint32 dstw; - uint32 dsth; - if (isPanorama) { - dstw = nod->pos.height(); - dsth = nod->pos.width(); - } else { - dstw = nod->pos.width(); - dsth = nod->pos.height(); - } - - // We only scale down the animation to fit its frame, not up, otherwise we - // end up with distorted animations - e.g. the armor visor in location cz1e - // in Nemesis (one of the armors inside Irondune), or the planet in location - // aa10 in Nemesis (Juperon, outside the asylum). We do allow scaling up only - // when a simple 2x filter is requested (e.g. the alchemists and cup sequence - // in Nemesis) - if (frame->w > dstw || frame->h > dsth || (frame->w == dstw / 2 && frame->h == dsth / 2)) { - if (nod->_scaled) - if (nod->_scaled->w != dstw || nod->_scaled->h != dsth) { - nod->_scaled->free(); - delete nod->_scaled; - nod->_scaled = NULL; - } - - if (!nod->_scaled) { - nod->_scaled = new Graphics::Surface; - nod->_scaled->create(dstw, dsth, frame->format); - } - - renderManager->scaleBuffer(frame->getPixels(), nod->_scaled->getPixels(), frame->w, frame->h, frame->format.bytesPerPixel, dstw, dsth); - frame = nod->_scaled; - } - - if (isPanorama) { - Graphics::Surface *transposed = RenderManager::tranposeSurface(frame); - renderManager->blitSurfaceToBkg(*transposed, nod->pos.left, nod->pos.top, _mask); - transposed->free(); - delete transposed; - } else { - renderManager->blitSurfaceToBkg(*frame, nod->pos.left, nod->pos.top, _mask); - } - } - } - } - - return false; -} - -void AnimationNode::addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops) { - playnode nod; - nod.loop = loops; - nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); - nod.start = startFrame; - _animation->setEndFrame(CLIP(endFrame, 0, _animation->getFrameCount() - 1)); - - nod.slot = slot; - nod._delay = 0; - nod._scaled = NULL; - _playList.push_back(nod); -} - -bool AnimationNode::stop() { - PlayNodes::iterator it = _playList.begin(); - if (it != _playList.end()) { - _engine->getScriptManager()->setStateValue((*it).slot, 2); - if ((*it)._scaled) { - (*it)._scaled->free(); - delete(*it)._scaled; - } - } - - _playList.clear(); - - // We don't need to delete, it's may be reused - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/animation_node.h b/engines/zvision/scripting/sidefx/animation_node.h deleted file mode 100644 index 1dc0dc71b8..0000000000 --- a/engines/zvision/scripting/sidefx/animation_node.h +++ /dev/null @@ -1,77 +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 ZVISION_ANIMATION_NODE_H -#define ZVISION_ANIMATION_NODE_H - -#include "zvision/scripting/sidefx.h" -#include "common/rect.h" -#include "common/list.h" - -namespace Graphics { -struct Surface; -} - -namespace Video { - class VideoDecoder; -} - -namespace ZVision { - -class ZVision; - -class AnimationNode : public SideFX { -public: - AnimationNode(ZVision *engine, uint32 controlKey, const Common::String &fileName, int32 mask, int32 frate, bool disposeAfterUse = true); - ~AnimationNode(); - - struct playnode { - Common::Rect pos; - int32 slot; - int32 start; - int32 loop; - int32 _delay; - Graphics::Surface *_scaled; - }; - -private: - typedef Common::List PlayNodes; - - PlayNodes _playList; - - int32 _mask; - bool _disposeAfterUse; - - Video::VideoDecoder *_animation; - int32 _frmDelayOverride; - -public: - bool process(uint32 deltaTimeInMillis); - - void addPlayNode(int32 slot, int x, int y, int x2, int y2, int startFrame, int endFrame, int loops = 1); - - bool stop(); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/distort_node.cpp b/engines/zvision/scripting/sidefx/distort_node.cpp deleted file mode 100644 index 7d25adc031..0000000000 --- a/engines/zvision/scripting/sidefx/distort_node.cpp +++ /dev/null @@ -1,104 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/distort_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/graphics/render_table.h" - -#include "common/stream.h" - -namespace ZVision { - -DistortNode::DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale) - : SideFX(engine, key, SIDEFX_DISTORT) { - - _angle = _engine->getRenderManager()->getRenderTable()->getAngle(); - _linScale = _engine->getRenderManager()->getRenderTable()->getLinscale(); - - _speed = speed; - _incr = true; - _startAngle = startAngle; - _endAngle = endAngle; - _startLineScale = startLineScale; - _endLineScale = endLineScale; - - _curFrame = 1.0; - - _diffAngle = endAngle - startAngle; - _diffLinScale = endLineScale - startLineScale; - - _frmSpeed = (float)speed / 15.0; - _frames = ceil((5.0 - _frmSpeed * 2.0) / _frmSpeed); - if (_frames <= 0) - _frames = 1; - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); -} - -DistortNode::~DistortNode() { - setParams(_angle, _linScale); -} - -bool DistortNode::process(uint32 deltaTimeInMillis) { - float updTime = deltaTimeInMillis / (1000.0 / 60.0); - - if (_incr) - _curFrame += updTime; - else - _curFrame -= updTime; - - if (_curFrame < 1.0) { - _curFrame = 1.0; - _incr = true; - } else if (_curFrame > _frames) { - _curFrame = _frames; - _incr = false; - } - - float diff = (1.0 / (5.0 - (_curFrame * _frmSpeed))) / (5.0 - _frmSpeed); - setParams(_startAngle + diff * _diffAngle, _startLineScale + diff * _diffLinScale); - - return false; -} - -void DistortNode::setParams(float angl, float linScale) { - RenderTable *table = _engine->getRenderManager()->getRenderTable(); - if (table->getRenderState() == RenderTable::PANORAMA) { - table->setPanoramaFoV(angl); - table->setPanoramaScale(linScale); - table->generateRenderTable(); - _engine->getRenderManager()->markDirty(); - } else if (table->getRenderState() == RenderTable::TILT) { - table->setTiltFoV(angl); - table->setTiltScale(linScale); - table->generateRenderTable(); - _engine->getRenderManager()->markDirty(); - } -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/distort_node.h b/engines/zvision/scripting/sidefx/distort_node.h deleted file mode 100644 index 787a69bdde..0000000000 --- a/engines/zvision/scripting/sidefx/distort_node.h +++ /dev/null @@ -1,63 +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 ZVISION_DISTORT_NODE_H -#define ZVISION_DISTORT_NODE_H - -#include "zvision/scripting/sidefx.h" - -namespace ZVision { - -class ZVision; - -class DistortNode : public SideFX { -public: - DistortNode(ZVision *engine, uint32 key, int16 speed, float startAngle, float endAngle, float startLineScale, float endLineScale); - ~DistortNode(); - - bool process(uint32 deltaTimeInMillis); - -private: - int16 _speed; - float _startAngle; - float _endAngle; - float _startLineScale; - float _endLineScale; - - float _frmSpeed; - float _diffAngle; - float _diffLinScale; - bool _incr; - int16 _frames; - - float _curFrame; - - float _angle; - float _linScale; - -private: - void setParams(float angl, float linScale); -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/music_node.cpp b/engines/zvision/scripting/sidefx/music_node.cpp deleted file mode 100644 index 0cada6d748..0000000000 --- a/engines/zvision/scripting/sidefx/music_node.cpp +++ /dev/null @@ -1,248 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/music_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/sound/midi.h" -#include "zvision/sound/zork_raw.h" - -#include "common/stream.h" -#include "common/file.h" -#include "audio/decoders/wave.h" - -namespace ZVision { - -MusicNode::MusicNode(ZVision *engine, uint32 key, Common::String &filename, bool loop, int8 volume) - : MusicNodeBASE(engine, key, SIDEFX_AUDIO) { - _loop = loop; - _volume = volume; - _crossfade = false; - _crossfadeTarget = 0; - _crossfadeTime = 0; - _attenuate = 0; - _pantrack = false; - _pantrackPosition = 0; - _sub = NULL; - _stereo = false; - _loaded = false; - - Audio::RewindableAudioStream *audioStream = NULL; - - if (filename.contains(".wav")) { - Common::File *file = new Common::File(); - if (_engine->getSearchManager()->openFile(*file, filename)) { - audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); - } - } else { - audioStream = makeRawZorkStream(filename, _engine); - } - - if (audioStream) { - _stereo = audioStream->isStereo(); - - if (_loop) { - Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopingAudioStream, -1, _volume); - } else { - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream, -1, _volume); - } - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); - - // Change filename.raw into filename.sub - Common::String subname = filename; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); - - if (_engine->getSearchManager()->hasFile(subname)) - _sub = new Subtitle(_engine, subname); - - _loaded = true; - } -} - -MusicNode::~MusicNode() { - if (_loaded) - _engine->_mixer->stopHandle(_handle); - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - if (_sub) - delete _sub; - debug(1, "MusicNode: %d destroyed\n", _key); -} - -void MusicNode::setPanTrack(int16 pos) { - if (!_stereo) { - _pantrack = true; - _pantrackPosition = pos; - setVolume(_volume); - } -} - -void MusicNode::unsetPanTrack() { - _pantrack = false; - setVolume(_volume); -} - -void MusicNode::setFade(int32 time, uint8 target) { - _crossfadeTarget = target; - _crossfadeTime = time; - _crossfade = true; -} - -bool MusicNode::process(uint32 deltaTimeInMillis) { - if (!_loaded || ! _engine->_mixer->isSoundHandleActive(_handle)) - return stop(); - else { - uint8 _newvol = _volume; - - if (_crossfade) { - if (_crossfadeTime > 0) { - if ((int32)deltaTimeInMillis > _crossfadeTime) - deltaTimeInMillis = _crossfadeTime; - _newvol += floor(((float)(_crossfadeTarget - _newvol) / (float)_crossfadeTime)) * (float)deltaTimeInMillis; - _crossfadeTime -= deltaTimeInMillis; - } else { - _crossfade = false; - _newvol = _crossfadeTarget; - } - } - - if (_pantrack || _volume != _newvol) - setVolume(_newvol); - - if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) - _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); - } - return false; -} - -void MusicNode::setVolume(uint8 newVolume) { - if (!_loaded) - return; - if (_pantrack) { - int curX = _engine->getScriptManager()->getStateValue(StateKey_ViewPos); - curX -= _pantrackPosition; - int32 _width = _engine->getRenderManager()->getBkgSize().x; - if (curX < (-_width) / 2) - curX += _width; - else if (curX >= _width / 2) - curX -= _width; - - float norm = (float)curX / ((float)_width / 2.0); - float lvl = fabs(norm); - if (lvl > 0.5) - lvl = (lvl - 0.5) * 1.7; - else - lvl = 1.0; - - float bal = sin(-norm * 3.1415926) * 127.0; - - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, bal); - _engine->_mixer->setChannelVolume(_handle, newVolume * lvl); - } - } else { - if (_engine->_mixer->isSoundHandleActive(_handle)) { - _engine->_mixer->setChannelBalance(_handle, 0); - _engine->_mixer->setChannelVolume(_handle, newVolume); - } - } - - _volume = newVolume; -} - -PanTrackNode::PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos) - : SideFX(engine, key, SIDEFX_PANTRACK) { - _slot = slot; - - SideFX *fx = _engine->getScriptManager()->getSideFX(slot); - if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNodeBASE *mus = (MusicNodeBASE *)fx; - mus->setPanTrack(pos); - } -} - -PanTrackNode::~PanTrackNode() { - SideFX *fx = _engine->getScriptManager()->getSideFX(_slot); - if (fx && fx->getType() == SIDEFX_AUDIO) { - MusicNodeBASE *mus = (MusicNodeBASE *)fx; - mus->unsetPanTrack(); - } -} - -MusicMidiNode::MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume) - : MusicNodeBASE(engine, key, SIDEFX_AUDIO) { - _volume = volume; - _prog = program; - _noteNumber = note; - _pan = 0; - - _chan = _engine->getMidiManager()->getFreeChannel(); - - if (_chan >= 0) { - _engine->getMidiManager()->setVolume(_chan, _volume); - _engine->getMidiManager()->setPan(_chan, _pan); - _engine->getMidiManager()->setProgram(_chan, _prog); - _engine->getMidiManager()->noteOn(_chan, _noteNumber, _volume); - } - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); -} - -MusicMidiNode::~MusicMidiNode() { - if (_chan >= 0) { - _engine->getMidiManager()->noteOff(_chan); - } - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); -} - -void MusicMidiNode::setPanTrack(int16 pos) { -} - -void MusicMidiNode::unsetPanTrack() { -} - -void MusicMidiNode::setFade(int32 time, uint8 target) { -} - -bool MusicMidiNode::process(uint32 deltaTimeInMillis) { - return false; -} - -void MusicMidiNode::setVolume(uint8 newVolume) { - if (_chan >= 0) { - _engine->getMidiManager()->setVolume(_chan, newVolume); - } - _volume = newVolume; -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/music_node.h b/engines/zvision/scripting/sidefx/music_node.h deleted file mode 100644 index 3f1ca5cf7b..0000000000 --- a/engines/zvision/scripting/sidefx/music_node.h +++ /dev/null @@ -1,135 +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 ZVISION_MUSIC_NODE_H -#define ZVISION_MUSIC_NODE_H - -#include "audio/mixer.h" -#include "zvision/scripting/sidefx.h" -#include "zvision/text/subtitles.h" - -namespace Common { -class String; -} - -namespace ZVision { - -class MusicNodeBASE : public SideFX { -public: - MusicNodeBASE(ZVision *engine, uint32 key, SideFXType type) : SideFX(engine, key, type) {} - ~MusicNodeBASE() {} - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - virtual bool process(uint32 deltaTimeInMillis) = 0; - - virtual void setVolume(uint8 volume) = 0; - - virtual void setPanTrack(int16 pos) = 0; - virtual void unsetPanTrack() = 0; - - virtual void setFade(int32 time, uint8 target) = 0; -}; - -class MusicNode : public MusicNodeBASE { -public: - MusicNode(ZVision *engine, uint32 key, Common::String &file, bool loop, int8 volume); - ~MusicNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - - void setVolume(uint8 volume); - - void setPanTrack(int16 pos); - void unsetPanTrack(); - - void setFade(int32 time, uint8 target); - -private: - bool _pantrack; - int32 _pantrackPosition; - int32 _attenuate; - uint8 _volume; - bool _loop; - bool _crossfade; - uint8 _crossfadeTarget; - int32 _crossfadeTime; - bool _stereo; - Audio::SoundHandle _handle; - Subtitle *_sub; - bool _loaded; -}; - -// Only used by Zork: Nemesis, for the flute and piano puzzles (tj4e and ve6f, as well as vr) -class MusicMidiNode : public MusicNodeBASE { -public: - MusicMidiNode(ZVision *engine, uint32 key, int8 program, int8 note, int8 volume); - ~MusicMidiNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - - void setVolume(uint8 volume); - - void setPanTrack(int16 pos); - void unsetPanTrack(); - - void setFade(int32 time, uint8 target); - -private: - int8 _chan; - int8 _noteNumber; - int8 _pan; - int8 _volume; - int8 _prog; -}; - -class PanTrackNode : public SideFX { -public: - PanTrackNode(ZVision *engine, uint32 key, uint32 slot, int16 pos); - ~PanTrackNode(); - -private: - uint32 _slot; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/region_node.cpp b/engines/zvision/scripting/sidefx/region_node.cpp deleted file mode 100644 index de613d8af2..0000000000 --- a/engines/zvision/scripting/sidefx/region_node.cpp +++ /dev/null @@ -1,56 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/region_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" - -namespace ZVision { - -RegionNode::RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay) - : SideFX(engine, key, SIDEFX_REGION) { - _effect = effect; - _delay = delay; - _timeLeft = 0; -} - -RegionNode::~RegionNode() { - _engine->getRenderManager()->deleteEffect(_key); -} - -bool RegionNode::process(uint32 deltaTimeInMillis) { - _timeLeft -= deltaTimeInMillis; - - if (_timeLeft <= 0) { - _timeLeft = _delay; - if (_effect) - _effect->update(); - } - - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/region_node.h b/engines/zvision/scripting/sidefx/region_node.h deleted file mode 100644 index ec716b6e3e..0000000000 --- a/engines/zvision/scripting/sidefx/region_node.h +++ /dev/null @@ -1,57 +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 ZVISION_REGION_NODE_H -#define ZVISION_REGION_NODE_H - -#include "graphics/surface.h" - -#include "zvision/scripting/sidefx.h" -#include "zvision/graphics/effect.h" - -namespace ZVision { - -class ZVision; - -class RegionNode : public SideFX { -public: - RegionNode(ZVision *engine, uint32 key, Effect *effect, uint32 delay); - ~RegionNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - -private: - int32 _timeLeft; - uint32 _delay; - Effect *_effect; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/syncsound_node.cpp b/engines/zvision/scripting/sidefx/syncsound_node.cpp deleted file mode 100644 index eec320bf2e..0000000000 --- a/engines/zvision/scripting/sidefx/syncsound_node.cpp +++ /dev/null @@ -1,85 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/syncsound_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/sound/zork_raw.h" - -#include "common/stream.h" -#include "common/file.h" -#include "audio/decoders/wave.h" - -namespace ZVision { - -SyncSoundNode::SyncSoundNode(ZVision *engine, uint32 key, Common::String &filename, int32 syncto) - : SideFX(engine, key, SIDEFX_AUDIO) { - _syncto = syncto; - _sub = NULL; - - Audio::RewindableAudioStream *audioStream = NULL; - - if (filename.contains(".wav")) { - Common::File *file = new Common::File(); - if (_engine->getSearchManager()->openFile(*file, filename)) { - audioStream = Audio::makeWAVStream(file, DisposeAfterUse::YES); - } - } else { - audioStream = makeRawZorkStream(filename, _engine); - } - - _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, audioStream); - - Common::String subname = filename; - subname.setChar('s', subname.size() - 3); - subname.setChar('u', subname.size() - 2); - subname.setChar('b', subname.size() - 1); - - if (_engine->getSearchManager()->hasFile(subname)) - _sub = new Subtitle(_engine, subname); -} - -SyncSoundNode::~SyncSoundNode() { - _engine->_mixer->stopHandle(_handle); - if (_sub) - delete _sub; -} - -bool SyncSoundNode::process(uint32 deltaTimeInMillis) { - if (! _engine->_mixer->isSoundHandleActive(_handle)) - return stop(); - else { - - if (_engine->getScriptManager()->getSideFX(_syncto) == NULL) - return stop(); - - if (_sub && _engine->getScriptManager()->getStateValue(StateKey_Subtitles) == 1) - _sub->process(_engine->_mixer->getSoundElapsedTime(_handle) / 100); - } - return false; -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/syncsound_node.h b/engines/zvision/scripting/sidefx/syncsound_node.h deleted file mode 100644 index 5961fccab9..0000000000 --- a/engines/zvision/scripting/sidefx/syncsound_node.h +++ /dev/null @@ -1,56 +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 ZVISION_SYNCSOUND_NODE_H -#define ZVISION_SYNCSOUND_NODE_H - -#include "audio/mixer.h" -#include "zvision/scripting/sidefx.h" -#include "zvision/text/subtitles.h" - -namespace Common { -class String; -} - -namespace ZVision { -class SyncSoundNode : public SideFX { -public: - SyncSoundNode(ZVision *engine, uint32 key, Common::String &file, int32 syncto); - ~SyncSoundNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); -private: - int32 _syncto; - Audio::SoundHandle _handle; - Subtitle *_sub; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/timer_node.cpp b/engines/zvision/scripting/sidefx/timer_node.cpp deleted file mode 100644 index 170f6e7472..0000000000 --- a/engines/zvision/scripting/sidefx/timer_node.cpp +++ /dev/null @@ -1,81 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/timer_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" - -#include "common/stream.h" - -namespace ZVision { - -TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) - : SideFX(engine, key, SIDEFX_TIMER) { - _timeLeft = 0; - - if (_engine->getGameId() == GID_NEMESIS) - _timeLeft = timeInSeconds * 1000; - else if (_engine->getGameId() == GID_GRANDINQUISITOR) - _timeLeft = timeInSeconds * 100; - - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 1); -} - -TimerNode::~TimerNode() { - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); - if (timeLeft > 0) - _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill -} - -bool TimerNode::process(uint32 deltaTimeInMillis) { - _timeLeft -= deltaTimeInMillis; - - if (_timeLeft <= 0) - return stop(); - - return false; -} - -bool TimerNode::stop() { - if (_key != StateKey_NotSet) - _engine->getScriptManager()->setStateValue(_key, 2); - return true; -} - -void TimerNode::serialize(Common::WriteStream *stream) { - stream->writeUint32BE(MKTAG('T', 'I', 'M', 'R')); - stream->writeUint32LE(8); // size - stream->writeUint32LE(_key); - stream->writeUint32LE(_timeLeft); -} - -void TimerNode::deserialize(Common::SeekableReadStream *stream) { - _timeLeft = stream->readUint32LE(); -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/timer_node.h b/engines/zvision/scripting/sidefx/timer_node.h deleted file mode 100644 index 7a26aff251..0000000000 --- a/engines/zvision/scripting/sidefx/timer_node.h +++ /dev/null @@ -1,59 +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 ZVISION_TIMER_NODE_H -#define ZVISION_TIMER_NODE_H - -#include "zvision/scripting/sidefx.h" - -namespace ZVision { - -class ZVision; - -class TimerNode : public SideFX { -public: - TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); - ~TimerNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); - void serialize(Common::WriteStream *stream); - void deserialize(Common::SeekableReadStream *stream); - inline bool needsSerialization() { - return true; - } - - bool stop(); - -private: - int32 _timeLeft; -}; - -} // End of namespace ZVision - -#endif diff --git a/engines/zvision/scripting/sidefx/ttytext_node.cpp b/engines/zvision/scripting/sidefx/ttytext_node.cpp deleted file mode 100644 index 66a27e96c5..0000000000 --- a/engines/zvision/scripting/sidefx/ttytext_node.cpp +++ /dev/null @@ -1,174 +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 "common/scummsys.h" - -#include "zvision/scripting/sidefx/ttytext_node.h" - -#include "zvision/zvision.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/text/text.h" - -#include "common/stream.h" -#include "common/file.h" - -namespace ZVision { - -ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay) : - SideFX(engine, key, SIDEFX_TTYTXT), - _fnt(engine) { - _delay = delay; - _r = r; - _txtpos = 0; - _nexttime = 0; - _dx = 0; - _dy = 0; - - Common::File *infile = _engine->getSearchManager()->openFile(file); - if (infile) { - while (!infile->eos()) { - Common::String asciiLine = readWideLine(*infile); - if (asciiLine.empty()) { - continue; - } - _txtbuf += asciiLine; - } - - delete infile; - } - _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat); - _style._sharp = true; - _style.readAllStyle(_txtbuf); - _style.setFont(_fnt); - _engine->getScriptManager()->setStateValue(_key, 1); -} - -ttyTextNode::~ttyTextNode() { - _engine->getScriptManager()->setStateValue(_key, 2); - _img.free(); -} - -bool ttyTextNode::process(uint32 deltaTimeInMillis) { - _nexttime -= deltaTimeInMillis; - - if (_nexttime < 0) { - if (_txtpos < _txtbuf.size()) { - if (_txtbuf[_txtpos] == '<') { - int32 strt = _txtpos; - int32 endt = 0; - int16 ret = 0; - while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) - _txtpos++; - endt = _txtpos; - if (strt != -1) - if ((endt - strt - 1) > 0) - ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); - - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (ret & TXT_RET_FNTCHG) - _style.setFont(_fnt); - if (ret & TXT_RET_FNTSTL) - _style.setFontStyle(_fnt); - - if (ret & TXT_RET_NEWLN) - newline(); - } - - if (ret & TXT_RET_HASSTBOX) { - Common::String buf; - buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox)); - - for (uint8 j = 0; j < buf.size(); j++) - outchar(buf[j]); - } - - _txtpos++; - } else { - int8 charsz = getUtf8CharSize(_txtbuf[_txtpos]); - - uint16 chr = readUtf8Char(_txtbuf.c_str() + _txtpos); - - if (chr == ' ') { - uint32 i = _txtpos + charsz; - uint16 width = _fnt.getCharWidth(chr); - - while (i < _txtbuf.size() && _txtbuf[i] != ' ' && _txtbuf[i] != '<') { - - int8 chsz = getUtf8CharSize(_txtbuf[i]); - uint16 uchr = readUtf8Char(_txtbuf.c_str() + _txtpos); - - width += _fnt.getCharWidth(uchr); - - i += chsz; - } - - if (_dx + width > _r.width()) - newline(); - else - outchar(chr); - } else - outchar(chr); - - _txtpos += charsz; - } - _nexttime = _delay; - _engine->getRenderManager()->blitSurfaceToBkg(_img, _r.left, _r.top); - } else - return stop(); - } - - return false; -} - -void ttyTextNode::scroll() { - int32 scrl = 0; - while (_dy - scrl > _r.height() - _fnt.getFontHeight()) - scrl += _fnt.getFontHeight(); - int8 *pixels = (int8 *)_img.getPixels(); - for (uint16 h = scrl; h < _img.h; h++) - memcpy(pixels + _img.pitch * (h - scrl), pixels + _img.pitch * h, _img.pitch); - - _img.fillRect(Common::Rect(0, _img.h - scrl, _img.w, _img.h), 0); - _dy -= scrl; -} - -void ttyTextNode::newline() { - _dy += _fnt.getFontHeight(); - _dx = 0; -} - -void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue); - - if (_dx + _fnt.getCharWidth(chr) > _r.width()) - newline(); - - if (_dy + _fnt.getFontHeight() >= _r.height()) - scroll(); - - _fnt.drawChar(&_img, chr, _dx, _dy, clr); - - _dx += _fnt.getCharWidth(chr); -} - -} // End of namespace ZVision diff --git a/engines/zvision/scripting/sidefx/ttytext_node.h b/engines/zvision/scripting/sidefx/ttytext_node.h deleted file mode 100644 index 26d9be8e77..0000000000 --- a/engines/zvision/scripting/sidefx/ttytext_node.h +++ /dev/null @@ -1,73 +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 ZVISION_TTYTEXT_NODE_H -#define ZVISION_TTYTEXT_NODE_H - -#include "common/rect.h" -#include "graphics/surface.h" - -#include "zvision/scripting/sidefx.h" -#include "zvision/text/text.h" -#include "zvision/text/truetype_font.h" - -namespace Common { -class String; -} - -namespace ZVision { -class ttyTextNode : public SideFX { -public: - ttyTextNode(ZVision *engine, uint32 key, const Common::String &file, const Common::Rect &r, int32 delay); - ~ttyTextNode(); - - /** - * Decrement the timer by the delta time. If the timer is finished, set the status - * in _globalState and let this node be deleted - * - * @param deltaTimeInMillis The number of milliseconds that have passed since last frame - * @return If true, the node can be deleted after process() finishes - */ - bool process(uint32 deltaTimeInMillis); -private: - Common::Rect _r; - - cTxtStyle _style; - StyledTTFont _fnt; - Common::String _txtbuf; - uint32 _txtpos; - - int32 _delay; - int32 _nexttime; - Graphics::Surface _img; - int16 _dx; - int16 _dy; -private: - - void newline(); - void scroll(); - void outchar(uint16 chr); -}; - -} // End of namespace ZVision - -#endif -- cgit v1.2.3 From 1f5736a9020796e6986a15ea4d3b627b81233241 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 01:19:54 -0600 Subject: ZVISION: Update function documentation to represent the changes to the internal pixel format Aka: We keep everything as 555, and only convert to 565 before we send everything to the backend --- engines/zvision/graphics/render_manager.h | 6 +- engines/zvision/zvision.cpp | 720 +++++++++++++++--------------- 2 files changed, 362 insertions(+), 364 deletions(-) diff --git a/engines/zvision/graphics/render_manager.h b/engines/zvision/graphics/render_manager.h index 9002d66b47..c22f9a78c9 100644 --- a/engines/zvision/graphics/render_manager.h +++ b/engines/zvision/graphics/render_manager.h @@ -277,8 +277,7 @@ public: void prepareBackground(); /** - * Reads an image file pixel data into a Surface buffer. In the process - * it converts the pixel data from RGB 555 to RGB 565. Also, if the image + * Reads an image file pixel data into a Surface buffer. Also, if the image * is transposed, it will un-transpose the pixel data. The function will * call destination::create() if the dimensions of destination do not match * up with the dimensions of the image. @@ -289,8 +288,7 @@ public: void readImageToSurface(const Common::String &fileName, Graphics::Surface &destination); /** - * Reads an image file pixel data into a Surface buffer. In the process - * it converts the pixel data from RGB 555 to RGB 565. Also, if the image + * Reads an image file pixel data into a Surface buffer. Also, if the image * is transposed, it will un-transpose the pixel data. The function will * call destination::create() if the dimensions of destination do not match * up with the dimensions of the image. diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index 10e0aaedc4..a70f9d8e39 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -1,361 +1,361 @@ -/* 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 "common/scummsys.h" - -#include "zvision/zvision.h" -#include "zvision/core/console.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/file/save_manager.h" -#include "zvision/text/string_manager.h" -#include "zvision/detection.h" -#include "zvision/scripting/menu.h" -#include "zvision/file/search_manager.h" -#include "zvision/text/text.h" -#include "zvision/text/truetype_font.h" -#include "zvision/sound/midi.h" -#include "zvision/file/zfs_archive.h" - -#include "common/config-manager.h" -#include "common/str.h" -#include "common/debug.h" -#include "common/debug-channels.h" -#include "common/textconsole.h" -#include "common/error.h" -#include "common/system.h" -#include "common/file.h" - -#include "gui/message.h" -#include "engines/util.h" -#include "audio/mixer.h" - -namespace ZVision { - -#define ZVISION_SETTINGS_KEYS_COUNT 11 - -struct zvisionIniSettings { - const char *name; - int16 slot; - int16 defaultValue; // -1: use the bool value - bool defaultBoolValue; - bool allowEditing; -} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { - // Hardcoded settings - {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused - {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused - {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr - {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused - {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet - {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled - // Editable settings - {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, - {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr - {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation - {"venusenabled", StateKey_VenusEnable, -1, true, true}, - {"subtitles", StateKey_Subtitles, -1, true, true} -}; - -ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) - : Engine(syst), - _gameDescription(gameDesc), - _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ - _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ - _desiredFrameTime(33), /* ~30 fps */ - _clock(_system), - _scriptManager(nullptr), - _renderManager(nullptr), - _saveManager(nullptr), - _stringManager(nullptr), - _cursorManager(nullptr), - _midiManager(nullptr), - _rnd(nullptr), - _console(nullptr), - _menu(nullptr), - _searchManager(nullptr), - _textRenderer(nullptr), - _doubleFPS(false), - _audioId(0), - _frameRenderDelay(2), - _keyboardVelocity(0), - _mouseVelocity(0), - _videoIsPlaying(false), - _renderedFrameCount(0), - _fps(0) { - - debug(1, "ZVision::ZVision"); - - uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; - uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; - _workingWindow = Common::Rect( - (WINDOW_WIDTH - workingWindowWidth) / 2, - (WINDOW_HEIGHT - workingWindowHeight) / 2, - ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth, - ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight - ); - - memset(_cheatBuffer, 0, sizeof(_cheatBuffer)); -} - -ZVision::~ZVision() { - debug(1, "ZVision::~ZVision"); - - // Dispose of resources - delete _console; - delete _cursorManager; - delete _stringManager; - delete _saveManager; - delete _scriptManager; - delete _renderManager; // should be deleted after the script manager - delete _rnd; - delete _midiManager; - - getTimerManager()->removeTimerProc(&fpsTimerCallback); - - // Remove all of our debug levels - DebugMan.clearAllDebugChannels(); -} - -void ZVision::registerDefaultSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].allowEditing) { - if (settingsKeys[i].defaultValue >= 0) - ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue); - else - ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue); - } - } - - ConfMan.registerDefault("originalsaveload", false); - ConfMan.registerDefault("doublefps", false); -} - -void ZVision::loadSettings() { - int16 value = 0; - bool boolValue = false; - - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].defaultValue >= 0) { - value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; - } else { - boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; - value = (boolValue) ? 1 : 0; - } - - _scriptManager->setStateValue(settingsKeys[i].slot, value); - } - - if (getGameId() == GID_NEMESIS) - _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); - else - _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0); -} - -void ZVision::saveSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].allowEditing) { - if (settingsKeys[i].defaultValue >= 0) - ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); - else - ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1)); - } - } - - ConfMan.flushToDisk(); -} - -void ZVision::initialize() { - const Common::FSNode gameDataDir(ConfMan.get("path")); - - _searchManager = new SearchManager(ConfMan.get("path"), 6); - - _searchManager->addDir("FONTS"); - _searchManager->addDir("addon"); - - if (_gameDescription->gameId == GID_GRANDINQUISITOR) { - _searchManager->loadZix("INQUIS.ZIX"); - _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC"); - _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC"); - _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC"); - _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC"); - _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC"); - _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC"); - _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC"); - _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC"); - _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC"); - _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC"); - _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC"); - _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC"); - _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC"); - _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); - } else if (_gameDescription->gameId == GID_NEMESIS) - _searchManager->loadZix("NEMESIS.ZIX"); - - initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); - - // Register random source - _rnd = new Common::RandomSource("zvision"); - - // Create managers - _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS); - _saveManager = new SaveManager(this); - _stringManager = new StringManager(this); - _cursorManager = new CursorManager(this, _resourcePixelFormat); - _textRenderer = new TextRenderer(this); - _midiManager = new MidiManager(); - - if (_gameDescription->gameId == GID_GRANDINQUISITOR) - _menu = new MenuZGI(this); - else - _menu = new MenuNemesis(this); - - // Initialize the managers - _cursorManager->initialize(); - _scriptManager->initialize(); - _stringManager->initialize(_gameDescription->gameId); - - registerDefaultSettings(); - - loadSettings(); - - // Create debugger console. It requires GFX to be initialized - _console = new Console(this); - _doubleFPS = ConfMan.getBool("doublefps"); - - // Initialize FPS timer callback - getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); -} - -Common::Error ZVision::run() { - initialize(); - - // Check if a saved game is to be loaded from the launcher - if (ConfMan.hasKey("save_slot")) - _saveManager->loadGame(ConfMan.getInt("save_slot")); - - // Before starting, make absolutely sure that the user has copied the needed fonts +/* 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 "common/scummsys.h" + +#include "zvision/zvision.h" +#include "zvision/core/console.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" +#include "zvision/file/save_manager.h" +#include "zvision/text/string_manager.h" +#include "zvision/detection.h" +#include "zvision/scripting/menu.h" +#include "zvision/file/search_manager.h" +#include "zvision/text/text.h" +#include "zvision/text/truetype_font.h" +#include "zvision/sound/midi.h" +#include "zvision/file/zfs_archive.h" + +#include "common/config-manager.h" +#include "common/str.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/textconsole.h" +#include "common/error.h" +#include "common/system.h" +#include "common/file.h" + +#include "gui/message.h" +#include "engines/util.h" +#include "audio/mixer.h" + +namespace ZVision { + +#define ZVISION_SETTINGS_KEYS_COUNT 11 + +struct zvisionIniSettings { + const char *name; + int16 slot; + int16 defaultValue; // -1: use the bool value + bool defaultBoolValue; + bool allowEditing; +} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { + // Hardcoded settings + {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused + {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused + {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr + {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused + {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet + {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled + // Editable settings + {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, + {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr + {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation + {"venusenabled", StateKey_VenusEnable, -1, true, true}, + {"subtitles", StateKey_Subtitles, -1, true, true} +}; + +ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) + : Engine(syst), + _gameDescription(gameDesc), + _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ + _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ + _desiredFrameTime(33), /* ~30 fps */ + _clock(_system), + _scriptManager(nullptr), + _renderManager(nullptr), + _saveManager(nullptr), + _stringManager(nullptr), + _cursorManager(nullptr), + _midiManager(nullptr), + _rnd(nullptr), + _console(nullptr), + _menu(nullptr), + _searchManager(nullptr), + _textRenderer(nullptr), + _doubleFPS(false), + _audioId(0), + _frameRenderDelay(2), + _keyboardVelocity(0), + _mouseVelocity(0), + _videoIsPlaying(false), + _renderedFrameCount(0), + _fps(0) { + + debug(1, "ZVision::ZVision"); + + uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; + uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; + _workingWindow = Common::Rect( + (WINDOW_WIDTH - workingWindowWidth) / 2, + (WINDOW_HEIGHT - workingWindowHeight) / 2, + ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth, + ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight + ); + + memset(_cheatBuffer, 0, sizeof(_cheatBuffer)); +} + +ZVision::~ZVision() { + debug(1, "ZVision::~ZVision"); + + // Dispose of resources + delete _console; + delete _cursorManager; + delete _stringManager; + delete _saveManager; + delete _scriptManager; + delete _renderManager; // should be deleted after the script manager + delete _rnd; + delete _midiManager; + + getTimerManager()->removeTimerProc(&fpsTimerCallback); + + // Remove all of our debug levels + DebugMan.clearAllDebugChannels(); +} + +void ZVision::registerDefaultSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue); + else + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue); + } + } + + ConfMan.registerDefault("originalsaveload", false); + ConfMan.registerDefault("doublefps", false); +} + +void ZVision::loadSettings() { + int16 value = 0; + bool boolValue = false; + + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].defaultValue >= 0) { + value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; + } else { + boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; + value = (boolValue) ? 1 : 0; + } + + _scriptManager->setStateValue(settingsKeys[i].slot, value); + } + + if (getGameId() == GID_NEMESIS) + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); + else + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0); +} + +void ZVision::saveSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); + else + ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1)); + } + } + + ConfMan.flushToDisk(); +} + +void ZVision::initialize() { + const Common::FSNode gameDataDir(ConfMan.get("path")); + + _searchManager = new SearchManager(ConfMan.get("path"), 6); + + _searchManager->addDir("FONTS"); + _searchManager->addDir("addon"); + + if (_gameDescription->gameId == GID_GRANDINQUISITOR) { + _searchManager->loadZix("INQUIS.ZIX"); + _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC"); + _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC"); + _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC"); + _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC"); + _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC"); + _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC"); + _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC"); + _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC"); + _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC"); + _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC"); + _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC"); + _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC"); + _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC"); + _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); + } else if (_gameDescription->gameId == GID_NEMESIS) + _searchManager->loadZix("NEMESIS.ZIX"); + + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); + + // Register random source + _rnd = new Common::RandomSource("zvision"); + + // Create managers + _scriptManager = new ScriptManager(this); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS); + _saveManager = new SaveManager(this); + _stringManager = new StringManager(this); + _cursorManager = new CursorManager(this, _resourcePixelFormat); + _textRenderer = new TextRenderer(this); + _midiManager = new MidiManager(); + + if (_gameDescription->gameId == GID_GRANDINQUISITOR) + _menu = new MenuZGI(this); + else + _menu = new MenuNemesis(this); + + // Initialize the managers + _cursorManager->initialize(); + _scriptManager->initialize(); + _stringManager->initialize(_gameDescription->gameId); + + registerDefaultSettings(); + + loadSettings(); + + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); + _doubleFPS = ConfMan.getBool("doublefps"); + + // Initialize FPS timer callback + getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); +} + +Common::Error ZVision::run() { + initialize(); + + // Check if a saved game is to be loaded from the launcher + if (ConfMan.hasKey("save_slot")) + _saveManager->loadGame(ConfMan.getInt("save_slot")); + + // Before starting, make absolutely sure that the user has copied the needed fonts if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) { - GUI::MessageDialog dialog( - "Before playing this game, you'll need to copy the required " - "fonts into ScummVM's extras directory, or into the game directory. " - "On Windows, you'll need the following font files from the Windows " - "font directory: Times New Roman, Century Schoolbook, Garamond, " - "Courier New and Arial. Alternatively, you can download the GNU " - "FreeFont package. You'll need all the fonts from that package, " - "i.e., FreeMono, FreeSans and FreeSerif." - ); - dialog.runModal(); - quitGame(); - return Common::kUnknownError; - } - - // Main loop - while (!shouldQuit()) { - _clock.update(); - uint32 currentTime = _clock.getLastMeasuredTime(); - uint32 deltaTime = _clock.getDeltaTime(); - - _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); - - processEvents(); - _renderManager->updateRotation(); - - _scriptManager->update(deltaTime); - _menu->process(deltaTime); - - // Render the backBuffer to the screen - _renderManager->prepareBackground(); - _renderManager->renderMenuToScreen(); - _renderManager->processSubs(deltaTime); - _renderManager->renderSceneToScreen(); - - // Update the screen - if (canRender()) { - _system->updateScreen(); - _renderedFrameCount++; - } else { - _frameRenderDelay--; - } - - // Calculate the frame delay based off a desired frame time - int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); - // Ensure non-negative - delay = delay < 0 ? 0 : delay; - - if (_doubleFPS) { - delay >>= 1; - } - - if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { - _saveManager->autoSave(); - } - - _system->delayMillis(delay); - } - - return Common::kNoError; -} - -void ZVision::pauseEngineIntern(bool pause) { - _mixer->pauseAll(pause); - - if (pause) { - _clock.stop(); - } else { - _clock.start(); - } -} - -Common::String ZVision::generateSaveFileName(uint slot) { - return Common::String::format("%s.%03u", _targetName.c_str(), slot); -} - -void ZVision::setRenderDelay(uint delay) { - _frameRenderDelay = delay; -} - -bool ZVision::canRender() { - return _frameRenderDelay <= 0; -} - -GUI::Debugger *ZVision::getDebugger() { - return _console; -} - -void ZVision::syncSoundSettings() { - Engine::syncSoundSettings(); - - _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0); -} - -void ZVision::fpsTimerCallback(void *refCon) { - ((ZVision *)refCon)->fpsTimer(); -} - -void ZVision::fpsTimer() { - _fps = _renderedFrameCount; - _renderedFrameCount = 0; -} - -} // End of namespace ZVision + GUI::MessageDialog dialog( + "Before playing this game, you'll need to copy the required " + "fonts into ScummVM's extras directory, or into the game directory. " + "On Windows, you'll need the following font files from the Windows " + "font directory: Times New Roman, Century Schoolbook, Garamond, " + "Courier New and Arial. Alternatively, you can download the GNU " + "FreeFont package. You'll need all the fonts from that package, " + "i.e., FreeMono, FreeSans and FreeSerif." + ); + dialog.runModal(); + quitGame(); + return Common::kUnknownError; + } + + // Main loop + while (!shouldQuit()) { + _clock.update(); + uint32 currentTime = _clock.getLastMeasuredTime(); + uint32 deltaTime = _clock.getDeltaTime(); + + _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); + + processEvents(); + _renderManager->updateRotation(); + + _scriptManager->update(deltaTime); + _menu->process(deltaTime); + + // Render the backBuffer to the screen + _renderManager->prepareBackground(); + _renderManager->renderMenuToScreen(); + _renderManager->processSubs(deltaTime); + _renderManager->renderSceneToScreen(); + + // Update the screen + if (canRender()) { + _system->updateScreen(); + _renderedFrameCount++; + } else { + _frameRenderDelay--; + } + + // Calculate the frame delay based off a desired frame time + int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); + // Ensure non-negative + delay = delay < 0 ? 0 : delay; + + if (_doubleFPS) { + delay >>= 1; + } + + if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { + _saveManager->autoSave(); + } + + _system->delayMillis(delay); + } + + return Common::kNoError; +} + +void ZVision::pauseEngineIntern(bool pause) { + _mixer->pauseAll(pause); + + if (pause) { + _clock.stop(); + } else { + _clock.start(); + } +} + +Common::String ZVision::generateSaveFileName(uint slot) { + return Common::String::format("%s.%03u", _targetName.c_str(), slot); +} + +void ZVision::setRenderDelay(uint delay) { + _frameRenderDelay = delay; +} + +bool ZVision::canRender() { + return _frameRenderDelay <= 0; +} + +GUI::Debugger *ZVision::getDebugger() { + return _console; +} + +void ZVision::syncSoundSettings() { + Engine::syncSoundSettings(); + + _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0); +} + +void ZVision::fpsTimerCallback(void *refCon) { + ((ZVision *)refCon)->fpsTimer(); +} + +void ZVision::fpsTimer() { + _fps = _renderedFrameCount; + _renderedFrameCount = 0; +} + +} // End of namespace ZVision -- cgit v1.2.3 From df605069552d680e203b7e16f3bcd0fb31825c2c Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 01:51:22 -0600 Subject: ZVISION: Restore LF line ending that was accidentally changed in 1f5736a9020796e6986a15ea4d3b627b81233241 --- engines/zvision/zvision.cpp | 722 ++++++++++++++++++++++---------------------- 1 file changed, 361 insertions(+), 361 deletions(-) diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp index a70f9d8e39..54991aced3 100644 --- a/engines/zvision/zvision.cpp +++ b/engines/zvision/zvision.cpp @@ -1,361 +1,361 @@ -/* 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 "common/scummsys.h" - -#include "zvision/zvision.h" -#include "zvision/core/console.h" -#include "zvision/scripting/script_manager.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/graphics/cursors/cursor_manager.h" -#include "zvision/file/save_manager.h" -#include "zvision/text/string_manager.h" -#include "zvision/detection.h" -#include "zvision/scripting/menu.h" -#include "zvision/file/search_manager.h" -#include "zvision/text/text.h" -#include "zvision/text/truetype_font.h" -#include "zvision/sound/midi.h" -#include "zvision/file/zfs_archive.h" - -#include "common/config-manager.h" -#include "common/str.h" -#include "common/debug.h" -#include "common/debug-channels.h" -#include "common/textconsole.h" -#include "common/error.h" -#include "common/system.h" -#include "common/file.h" - -#include "gui/message.h" -#include "engines/util.h" -#include "audio/mixer.h" - -namespace ZVision { - -#define ZVISION_SETTINGS_KEYS_COUNT 11 - -struct zvisionIniSettings { - const char *name; - int16 slot; - int16 defaultValue; // -1: use the bool value - bool defaultBoolValue; - bool allowEditing; -} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { - // Hardcoded settings - {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused - {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused - {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr - {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused - {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet - {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled - // Editable settings - {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, - {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr - {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation - {"venusenabled", StateKey_VenusEnable, -1, true, true}, - {"subtitles", StateKey_Subtitles, -1, true, true} -}; - -ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) - : Engine(syst), - _gameDescription(gameDesc), - _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ - _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ - _desiredFrameTime(33), /* ~30 fps */ - _clock(_system), - _scriptManager(nullptr), - _renderManager(nullptr), - _saveManager(nullptr), - _stringManager(nullptr), - _cursorManager(nullptr), - _midiManager(nullptr), - _rnd(nullptr), - _console(nullptr), - _menu(nullptr), - _searchManager(nullptr), - _textRenderer(nullptr), - _doubleFPS(false), - _audioId(0), - _frameRenderDelay(2), - _keyboardVelocity(0), - _mouseVelocity(0), - _videoIsPlaying(false), - _renderedFrameCount(0), - _fps(0) { - - debug(1, "ZVision::ZVision"); - - uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; - uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; - _workingWindow = Common::Rect( - (WINDOW_WIDTH - workingWindowWidth) / 2, - (WINDOW_HEIGHT - workingWindowHeight) / 2, - ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth, - ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight - ); - - memset(_cheatBuffer, 0, sizeof(_cheatBuffer)); -} - -ZVision::~ZVision() { - debug(1, "ZVision::~ZVision"); - - // Dispose of resources - delete _console; - delete _cursorManager; - delete _stringManager; - delete _saveManager; - delete _scriptManager; - delete _renderManager; // should be deleted after the script manager - delete _rnd; - delete _midiManager; - - getTimerManager()->removeTimerProc(&fpsTimerCallback); - - // Remove all of our debug levels - DebugMan.clearAllDebugChannels(); -} - -void ZVision::registerDefaultSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].allowEditing) { - if (settingsKeys[i].defaultValue >= 0) - ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue); - else - ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue); - } - } - - ConfMan.registerDefault("originalsaveload", false); - ConfMan.registerDefault("doublefps", false); -} - -void ZVision::loadSettings() { - int16 value = 0; - bool boolValue = false; - - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].defaultValue >= 0) { - value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; - } else { - boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; - value = (boolValue) ? 1 : 0; - } - - _scriptManager->setStateValue(settingsKeys[i].slot, value); - } - - if (getGameId() == GID_NEMESIS) - _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); - else - _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0); -} - -void ZVision::saveSettings() { - for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { - if (settingsKeys[i].allowEditing) { - if (settingsKeys[i].defaultValue >= 0) - ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); - else - ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1)); - } - } - - ConfMan.flushToDisk(); -} - -void ZVision::initialize() { - const Common::FSNode gameDataDir(ConfMan.get("path")); - - _searchManager = new SearchManager(ConfMan.get("path"), 6); - - _searchManager->addDir("FONTS"); - _searchManager->addDir("addon"); - - if (_gameDescription->gameId == GID_GRANDINQUISITOR) { - _searchManager->loadZix("INQUIS.ZIX"); - _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC"); - _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC"); - _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC"); - _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC"); - _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC"); - _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC"); - _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC"); - _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC"); - _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC"); - _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC"); - _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC"); - _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC"); - _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC"); - _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); - } else if (_gameDescription->gameId == GID_NEMESIS) - _searchManager->loadZix("NEMESIS.ZIX"); - - initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); - - // Register random source - _rnd = new Common::RandomSource("zvision"); - - // Create managers - _scriptManager = new ScriptManager(this); - _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS); - _saveManager = new SaveManager(this); - _stringManager = new StringManager(this); - _cursorManager = new CursorManager(this, _resourcePixelFormat); - _textRenderer = new TextRenderer(this); - _midiManager = new MidiManager(); - - if (_gameDescription->gameId == GID_GRANDINQUISITOR) - _menu = new MenuZGI(this); - else - _menu = new MenuNemesis(this); - - // Initialize the managers - _cursorManager->initialize(); - _scriptManager->initialize(); - _stringManager->initialize(_gameDescription->gameId); - - registerDefaultSettings(); - - loadSettings(); - - // Create debugger console. It requires GFX to be initialized - _console = new Console(this); - _doubleFPS = ConfMan.getBool("doublefps"); - - // Initialize FPS timer callback - getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); -} - -Common::Error ZVision::run() { - initialize(); - - // Check if a saved game is to be loaded from the launcher - if (ConfMan.hasKey("save_slot")) - _saveManager->loadGame(ConfMan.getInt("save_slot")); - - // Before starting, make absolutely sure that the user has copied the needed fonts - if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) { - GUI::MessageDialog dialog( - "Before playing this game, you'll need to copy the required " - "fonts into ScummVM's extras directory, or into the game directory. " - "On Windows, you'll need the following font files from the Windows " - "font directory: Times New Roman, Century Schoolbook, Garamond, " - "Courier New and Arial. Alternatively, you can download the GNU " - "FreeFont package. You'll need all the fonts from that package, " - "i.e., FreeMono, FreeSans and FreeSerif." - ); - dialog.runModal(); - quitGame(); - return Common::kUnknownError; - } - - // Main loop - while (!shouldQuit()) { - _clock.update(); - uint32 currentTime = _clock.getLastMeasuredTime(); - uint32 deltaTime = _clock.getDeltaTime(); - - _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); - - processEvents(); - _renderManager->updateRotation(); - - _scriptManager->update(deltaTime); - _menu->process(deltaTime); - - // Render the backBuffer to the screen - _renderManager->prepareBackground(); - _renderManager->renderMenuToScreen(); - _renderManager->processSubs(deltaTime); - _renderManager->renderSceneToScreen(); - - // Update the screen - if (canRender()) { - _system->updateScreen(); - _renderedFrameCount++; - } else { - _frameRenderDelay--; - } - - // Calculate the frame delay based off a desired frame time - int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); - // Ensure non-negative - delay = delay < 0 ? 0 : delay; - - if (_doubleFPS) { - delay >>= 1; - } - - if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { - _saveManager->autoSave(); - } - - _system->delayMillis(delay); - } - - return Common::kNoError; -} - -void ZVision::pauseEngineIntern(bool pause) { - _mixer->pauseAll(pause); - - if (pause) { - _clock.stop(); - } else { - _clock.start(); - } -} - -Common::String ZVision::generateSaveFileName(uint slot) { - return Common::String::format("%s.%03u", _targetName.c_str(), slot); -} - -void ZVision::setRenderDelay(uint delay) { - _frameRenderDelay = delay; -} - -bool ZVision::canRender() { - return _frameRenderDelay <= 0; -} - -GUI::Debugger *ZVision::getDebugger() { - return _console; -} - -void ZVision::syncSoundSettings() { - Engine::syncSoundSettings(); - - _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0); -} - -void ZVision::fpsTimerCallback(void *refCon) { - ((ZVision *)refCon)->fpsTimer(); -} - -void ZVision::fpsTimer() { - _fps = _renderedFrameCount; - _renderedFrameCount = 0; -} - -} // End of namespace ZVision +/* 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 "common/scummsys.h" + +#include "zvision/zvision.h" +#include "zvision/core/console.h" +#include "zvision/scripting/script_manager.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/graphics/cursors/cursor_manager.h" +#include "zvision/file/save_manager.h" +#include "zvision/text/string_manager.h" +#include "zvision/detection.h" +#include "zvision/scripting/menu.h" +#include "zvision/file/search_manager.h" +#include "zvision/text/text.h" +#include "zvision/text/truetype_font.h" +#include "zvision/sound/midi.h" +#include "zvision/file/zfs_archive.h" + +#include "common/config-manager.h" +#include "common/str.h" +#include "common/debug.h" +#include "common/debug-channels.h" +#include "common/textconsole.h" +#include "common/error.h" +#include "common/system.h" +#include "common/file.h" + +#include "gui/message.h" +#include "engines/util.h" +#include "audio/mixer.h" + +namespace ZVision { + +#define ZVISION_SETTINGS_KEYS_COUNT 11 + +struct zvisionIniSettings { + const char *name; + int16 slot; + int16 defaultValue; // -1: use the bool value + bool defaultBoolValue; + bool allowEditing; +} settingsKeys[ZVISION_SETTINGS_KEYS_COUNT] = { + // Hardcoded settings + {"countrycode", StateKey_CountryCode, 0, false, false}, // always 0 = US, subtitles are shown for codes 0 - 4, unused + {"lineskipvideo", StateKey_VideoLineSkip, 0, false, false}, // video line skip, 0 = default, 1 = always, 2 = pixel double when possible, unused + {"installlevel", StateKey_InstallLevel, 0, false, false}, // 0 = full, checked by universe.scr + {"highquality", StateKey_HighQuality, -1, true, false}, // high panorama quality, unused + {"qsoundenabled", StateKey_Qsound, -1, true, false}, // 1 = enable QSound - TODO: not supported yet + {"debugcheats", StateKey_DebugCheats, -1, true, false}, // always start with the GOxxxx cheat enabled + // Editable settings + {"keyboardturnspeed", StateKey_KbdRotateSpeed, 5, false, true}, + {"panarotatespeed", StateKey_RotateSpeed, 540, false, true}, // checked by universe.scr + {"noanimwhileturning", StateKey_NoTurnAnim, -1, false, true}, // toggle playing animations during pana rotation + {"venusenabled", StateKey_VenusEnable, -1, true, true}, + {"subtitles", StateKey_Subtitles, -1, true, true} +}; + +ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc) + : Engine(syst), + _gameDescription(gameDesc), + _resourcePixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0), /* RGB 555 */ + _screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), /* RGB 565 */ + _desiredFrameTime(33), /* ~30 fps */ + _clock(_system), + _scriptManager(nullptr), + _renderManager(nullptr), + _saveManager(nullptr), + _stringManager(nullptr), + _cursorManager(nullptr), + _midiManager(nullptr), + _rnd(nullptr), + _console(nullptr), + _menu(nullptr), + _searchManager(nullptr), + _textRenderer(nullptr), + _doubleFPS(false), + _audioId(0), + _frameRenderDelay(2), + _keyboardVelocity(0), + _mouseVelocity(0), + _videoIsPlaying(false), + _renderedFrameCount(0), + _fps(0) { + + debug(1, "ZVision::ZVision"); + + uint16 workingWindowWidth = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_WIDTH : ZGI_WORKING_WINDOW_WIDTH; + uint16 workingWindowHeight = (gameDesc->gameId == GID_NEMESIS) ? ZNM_WORKING_WINDOW_HEIGHT : ZGI_WORKING_WINDOW_HEIGHT; + _workingWindow = Common::Rect( + (WINDOW_WIDTH - workingWindowWidth) / 2, + (WINDOW_HEIGHT - workingWindowHeight) / 2, + ((WINDOW_WIDTH - workingWindowWidth) / 2) + workingWindowWidth, + ((WINDOW_HEIGHT - workingWindowHeight) / 2) + workingWindowHeight + ); + + memset(_cheatBuffer, 0, sizeof(_cheatBuffer)); +} + +ZVision::~ZVision() { + debug(1, "ZVision::~ZVision"); + + // Dispose of resources + delete _console; + delete _cursorManager; + delete _stringManager; + delete _saveManager; + delete _scriptManager; + delete _renderManager; // should be deleted after the script manager + delete _rnd; + delete _midiManager; + + getTimerManager()->removeTimerProc(&fpsTimerCallback); + + // Remove all of our debug levels + DebugMan.clearAllDebugChannels(); +} + +void ZVision::registerDefaultSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultValue); + else + ConfMan.registerDefault(settingsKeys[i].name, settingsKeys[i].defaultBoolValue); + } + } + + ConfMan.registerDefault("originalsaveload", false); + ConfMan.registerDefault("doublefps", false); +} + +void ZVision::loadSettings() { + int16 value = 0; + bool boolValue = false; + + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].defaultValue >= 0) { + value = (settingsKeys[i].allowEditing) ? ConfMan.getInt(settingsKeys[i].name) : settingsKeys[i].defaultValue; + } else { + boolValue = (settingsKeys[i].allowEditing) ? ConfMan.getBool(settingsKeys[i].name) : settingsKeys[i].defaultBoolValue; + value = (boolValue) ? 1 : 0; + } + + _scriptManager->setStateValue(settingsKeys[i].slot, value); + } + + if (getGameId() == GID_NEMESIS) + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 1); + else + _scriptManager->setStateValue(StateKey_ExecScopeStyle, 0); +} + +void ZVision::saveSettings() { + for (int i = 0; i < ZVISION_SETTINGS_KEYS_COUNT; i++) { + if (settingsKeys[i].allowEditing) { + if (settingsKeys[i].defaultValue >= 0) + ConfMan.setInt(settingsKeys[i].name, _scriptManager->getStateValue(settingsKeys[i].slot)); + else + ConfMan.setBool(settingsKeys[i].name, (_scriptManager->getStateValue(settingsKeys[i].slot) == 1)); + } + } + + ConfMan.flushToDisk(); +} + +void ZVision::initialize() { + const Common::FSNode gameDataDir(ConfMan.get("path")); + + _searchManager = new SearchManager(ConfMan.get("path"), 6); + + _searchManager->addDir("FONTS"); + _searchManager->addDir("addon"); + + if (_gameDescription->gameId == GID_GRANDINQUISITOR) { + _searchManager->loadZix("INQUIS.ZIX"); + _searchManager->addPatch("C000H01Q.RAW", "C000H01Q.SRC"); + _searchManager->addPatch("CM00H01Q.RAW", "CM00H01Q.SRC"); + _searchManager->addPatch("DM00H01Q.RAW", "DM00H01Q.SRC"); + _searchManager->addPatch("E000H01Q.RAW", "E000H01Q.SRC"); + _searchManager->addPatch("EM00H50Q.RAW", "EM00H50Q.SRC"); + _searchManager->addPatch("GJNPH65P.RAW", "GJNPH65P.SRC"); + _searchManager->addPatch("GJNPH72P.RAW", "GJNPH72P.SRC"); + _searchManager->addPatch("H000H01Q.RAW", "H000H01Q.SRC"); + _searchManager->addPatch("M000H01Q.RAW", "M000H01Q.SRC"); + _searchManager->addPatch("P000H01Q.RAW", "P000H01Q.SRC"); + _searchManager->addPatch("Q000H01Q.RAW", "Q000H01Q.SRC"); + _searchManager->addPatch("SW00H01Q.RAW", "SW00H01Q.SRC"); + _searchManager->addPatch("T000H01Q.RAW", "T000H01Q.SRC"); + _searchManager->addPatch("U000H01Q.RAW", "U000H01Q.SRC"); + } else if (_gameDescription->gameId == GID_NEMESIS) + _searchManager->loadZix("NEMESIS.ZIX"); + + initGraphics(WINDOW_WIDTH, WINDOW_HEIGHT, true, &_screenPixelFormat); + + // Register random source + _rnd = new Common::RandomSource("zvision"); + + // Create managers + _scriptManager = new ScriptManager(this); + _renderManager = new RenderManager(this, WINDOW_WIDTH, WINDOW_HEIGHT, _workingWindow, _resourcePixelFormat, _doubleFPS); + _saveManager = new SaveManager(this); + _stringManager = new StringManager(this); + _cursorManager = new CursorManager(this, _resourcePixelFormat); + _textRenderer = new TextRenderer(this); + _midiManager = new MidiManager(); + + if (_gameDescription->gameId == GID_GRANDINQUISITOR) + _menu = new MenuZGI(this); + else + _menu = new MenuNemesis(this); + + // Initialize the managers + _cursorManager->initialize(); + _scriptManager->initialize(); + _stringManager->initialize(_gameDescription->gameId); + + registerDefaultSettings(); + + loadSettings(); + + // Create debugger console. It requires GFX to be initialized + _console = new Console(this); + _doubleFPS = ConfMan.getBool("doublefps"); + + // Initialize FPS timer callback + getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS"); +} + +Common::Error ZVision::run() { + initialize(); + + // Check if a saved game is to be loaded from the launcher + if (ConfMan.hasKey("save_slot")) + _saveManager->loadGame(ConfMan.getInt("save_slot")); + + // Before starting, make absolutely sure that the user has copied the needed fonts + if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf") && !_searchManager->hasFile("FreeSans.ttf") ) { + GUI::MessageDialog dialog( + "Before playing this game, you'll need to copy the required " + "fonts into ScummVM's extras directory, or into the game directory. " + "On Windows, you'll need the following font files from the Windows " + "font directory: Times New Roman, Century Schoolbook, Garamond, " + "Courier New and Arial. Alternatively, you can download the GNU " + "FreeFont package. You'll need all the fonts from that package, " + "i.e., FreeMono, FreeSans and FreeSerif." + ); + dialog.runModal(); + quitGame(); + return Common::kUnknownError; + } + + // Main loop + while (!shouldQuit()) { + _clock.update(); + uint32 currentTime = _clock.getLastMeasuredTime(); + uint32 deltaTime = _clock.getDeltaTime(); + + _cursorManager->setItemID(_scriptManager->getStateValue(StateKey_InventoryItem)); + + processEvents(); + _renderManager->updateRotation(); + + _scriptManager->update(deltaTime); + _menu->process(deltaTime); + + // Render the backBuffer to the screen + _renderManager->prepareBackground(); + _renderManager->renderMenuToScreen(); + _renderManager->processSubs(deltaTime); + _renderManager->renderSceneToScreen(); + + // Update the screen + if (canRender()) { + _system->updateScreen(); + _renderedFrameCount++; + } else { + _frameRenderDelay--; + } + + // Calculate the frame delay based off a desired frame time + int delay = _desiredFrameTime - int32(_system->getMillis() - currentTime); + // Ensure non-negative + delay = delay < 0 ? 0 : delay; + + if (_doubleFPS) { + delay >>= 1; + } + + if (canSaveGameStateCurrently() && shouldPerformAutoSave(_saveManager->getLastSaveTime())) { + _saveManager->autoSave(); + } + + _system->delayMillis(delay); + } + + return Common::kNoError; +} + +void ZVision::pauseEngineIntern(bool pause) { + _mixer->pauseAll(pause); + + if (pause) { + _clock.stop(); + } else { + _clock.start(); + } +} + +Common::String ZVision::generateSaveFileName(uint slot) { + return Common::String::format("%s.%03u", _targetName.c_str(), slot); +} + +void ZVision::setRenderDelay(uint delay) { + _frameRenderDelay = delay; +} + +bool ZVision::canRender() { + return _frameRenderDelay <= 0; +} + +GUI::Debugger *ZVision::getDebugger() { + return _console; +} + +void ZVision::syncSoundSettings() { + Engine::syncSoundSettings(); + + _scriptManager->setStateValue(StateKey_Subtitles, ConfMan.getBool("subtitles") ? 1 : 0); +} + +void ZVision::fpsTimerCallback(void *refCon) { + ((ZVision *)refCon)->fpsTimer(); +} + +void ZVision::fpsTimer() { + _fps = _renderedFrameCount; + _renderedFrameCount = 0; +} + +} // End of namespace ZVision -- cgit v1.2.3 From cc916625d9025ffaa898854c4de19da5dc2e2925 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 30 Dec 2014 10:47:51 +0100 Subject: SCUMM: Add a "chained games manager" This replaces the somewhat ugly use of the config manager to store the chained games. --- base/main.cpp | 38 ++++++++------------------------------ engines/engine.cpp | 31 +++++++++++++++++++++++++++++++ engines/engine.h | 28 ++++++++++++++++++++++++++++ engines/scumm/scumm.cpp | 3 ++- 4 files changed, 69 insertions(+), 31 deletions(-) diff --git a/base/main.cpp b/base/main.cpp index b9bd97dbef..0f5ebc7845 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -529,43 +529,21 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) { // at. At the time of writing, this is used for the Maniac Mansion // easter egg in Day of the Tentacle. - Common::String chainedGames, nextGame, saveSlot; + Common::String chainedGame; + int saveSlot = -1; - if (ConfMan.hasKey("chained_games", Common::ConfigManager::kTransientDomain)) { - chainedGames = ConfMan.get("chained_games", Common::ConfigManager::kTransientDomain); - } + ChainedGamesMan.pop(chainedGame, saveSlot); // Discard any command line options. It's unlikely that the user // wanted to apply them to *all* games ever launched. ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); - if (!chainedGames.empty()) { - if (chainedGames.contains(',')) { - for (uint i = 0; i < chainedGames.size(); i++) { - if (chainedGames[i] == ',') { - chainedGames.erase(0, i + 1); - break; - } - nextGame += chainedGames[i]; - } - ConfMan.set("chained_games", chainedGames, Common::ConfigManager::kTransientDomain); - } else { - nextGame = chainedGames; - chainedGames.clear(); - ConfMan.removeKey("chained_games", Common::ConfigManager::kTransientDomain); - } - if (nextGame.contains(':')) { - for (int i = nextGame.size() - 1; i >= 0; i--) { - if (nextGame[i] == ':') { - nextGame.erase(i); - break; - } - saveSlot = nextGame[i] + saveSlot; - } - ConfMan.setInt("save_slot", atoi(saveSlot.c_str()), Common::ConfigManager::kTransientDomain); + if (!chainedGame.empty()) { + if (saveSlot != -1) { + ConfMan.setInt("save_slot", saveSlot, Common::ConfigManager::kTransientDomain); } - // Start the next game - ConfMan.setActiveDomain(nextGame); + // Start the chained game + ConfMan.setActiveDomain(chainedGame); } else { // Clear the active config domain ConfMan.setActiveDomain(""); diff --git a/engines/engine.cpp b/engines/engine.cpp index c63437f800..24008dd073 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -45,6 +45,7 @@ #include "common/taskbar.h" #include "common/textconsole.h" #include "common/translation.h" +#include "common/singleton.h" #include "backends/keymapper/keymapper.h" @@ -101,6 +102,36 @@ static void defaultErrorHandler(const char *msg) { } } +// Chained games manager + +ChainedGamesManager::ChainedGamesManager() { + clear(); +} + +void ChainedGamesManager::clear() { + _chainedGames.clear(); +} + +void ChainedGamesManager::push(const Common::String target, const int slot) { + Game game; + game.target = target; + game.slot = slot; + _chainedGames.push(game); +} + +bool ChainedGamesManager::pop(Common::String &target, int &slot) { + if (_chainedGames.empty()) { + return false; + } + Game game = _chainedGames.pop(); + target = game.target; + slot = game.slot; + return true; +} + +namespace Common { +DECLARE_SINGLETON(ChainedGamesManager); +} Engine::Engine(OSystem *syst) : _system(syst), diff --git a/engines/engine.h b/engines/engine.h index e325cc1ba2..d3415d584c 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -27,6 +27,8 @@ #include "common/str.h" #include "common/language.h" #include "common/platform.h" +#include "common/queue.h" +#include "common/singleton.h" class OSystem; @@ -334,6 +336,32 @@ protected: }; +// Chained games + +/** + * Singleton class which manages chained games. A chained game is one that + * starts automatically, optionally loading a saved game, instead of returning + * to the launcher. + */ +class ChainedGamesManager : public Common::Singleton { +private: + struct Game { + Common::String target; + int slot; + }; + + Common::Queue _chainedGames; + +public: + ChainedGamesManager(); + void clear(); + void push(const Common::String target, const int slot = -1); + bool pop(Common::String &target, int &slot); +}; + +/** Convenience shortcut for accessing the chained games manager. */ +#define ChainedGamesMan ChainedGamesManager::instance() + // FIXME: HACK for MidiEmu & error() extern Engine *g_engine; diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 34ae957951..9518ed4e5c 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -2625,7 +2625,8 @@ bool ScummEngine::startManiac() { // Set up the chanined games to Maniac Mansion, and then back // to the current game again with that save slot. - ConfMan.set("chained_games", maniacTarget + "," + ConfMan.getActiveDomainName() + ":100", Common::ConfigManager::kTransientDomain); + ChainedGamesMan.push(maniacTarget); + ChainedGamesMan.push(ConfMan.getActiveDomainName(), 100); // Force a return to the launcher. This will start the first // chained game. -- cgit v1.2.3 From 7dc316cced4c7a45a376d76a6ca0c84bd563132f Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 30 Dec 2014 10:54:49 +0100 Subject: SCUMM: Add secret "easter_egg" config key This makes it possible to override the detection of Maniac Mansion when starting the Day of the Tentacle easter egg. There is no GUI for setting this, no error handling, and setting it to Day of the Tentacle itself is probably a bad idea... --- engines/scumm/scumm.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 9518ed4e5c..7d927b0cda 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -2601,20 +2601,24 @@ bool ScummEngine::startManiac() { Common::String currentPath = ConfMan.get("path"); Common::String maniacTarget; - // Look for a game with a game path pointing to a 'Maniac' directory - // as a subdirectory to the current game. - Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains(); - for (; iter != ConfMan.endGameDomains(); ++iter) { - Common::ConfigManager::Domain &dom = iter->_value; - Common::String path = dom.getVal("path"); - - if (path.hasPrefix(currentPath)) { - path.erase(0, currentPath.size() + 1); - if (path.equalsIgnoreCase("maniac")) { - maniacTarget = dom.getVal("gameid"); - break; + if (!ConfMan.hasKey("easter_egg")) { + // Look for a game with a game path pointing to a 'Maniac' directory + // as a subdirectory to the current game. + Common::ConfigManager::DomainMap::iterator iter = ConfMan.beginGameDomains(); + for (; iter != ConfMan.endGameDomains(); ++iter) { + Common::ConfigManager::Domain &dom = iter->_value; + Common::String path = dom.getVal("path"); + + if (path.hasPrefix(currentPath)) { + path.erase(0, currentPath.size() + 1); + if (path.equalsIgnoreCase("maniac")) { + maniacTarget = dom.getVal("gameid"); + break; + } } } + } else { + maniacTarget = ConfMan.get("easter_egg"); } if (!maniacTarget.empty()) { -- cgit v1.2.3 From 88ba96aa3cb76c7d251a60f32d41f415a40b3dc4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Dec 2014 12:55:19 +0200 Subject: ZVISION: Fix an off-by-one error in the RLF decoder A regression from 7f61a09478. The current frame is the currently displayed frame, not the frame that should be displayed next. Thanks to clone2727 and Marisa-Chan for the explanation and fixes --- engines/zvision/video/rlf_decoder.cpp | 16 ++++++++-------- engines/zvision/video/rlf_decoder.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/engines/zvision/video/rlf_decoder.cpp b/engines/zvision/video/rlf_decoder.cpp index 6e2000f93c..db598a25b6 100644 --- a/engines/zvision/video/rlf_decoder.cpp +++ b/engines/zvision/video/rlf_decoder.cpp @@ -56,7 +56,7 @@ RLFDecoder::RLFVideoTrack::RLFVideoTrack(Common::SeekableReadStream *stream) _height(0), _frameTime(0), _frames(0), - _curFrame(-1), + _displayedFrame(-1), _frameBufferByteSize(0) { if (!readHeader()) { @@ -161,11 +161,11 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { uint frame = getFrameAtTime(time); assert(frame < (int)_frameCount); - if ((uint)_curFrame == frame) + if ((uint)_displayedFrame == frame) return true; - int closestFrame = _curFrame; - int distance = (int)frame - _curFrame; + int closestFrame = _displayedFrame; + int distance = (int)frame - closestFrame; if (distance < 0) { for (uint i = 0; i < _completeFrames.size(); ++i) { @@ -189,18 +189,18 @@ bool RLFDecoder::RLFVideoTrack::seek(const Audio::Timestamp &time) { applyFrameToCurrent(i); } - _curFrame = frame; + _displayedFrame = frame - 1; return true; } const Graphics::Surface *RLFDecoder::RLFVideoTrack::decodeNextFrame() { - if (_curFrame == (int)_frameCount) + if (_displayedFrame >= (int)_frameCount) return NULL; - applyFrameToCurrent(_curFrame); + _displayedFrame++; + applyFrameToCurrent(_displayedFrame); - _curFrame++; return &_currentFrameBuffer; } diff --git a/engines/zvision/video/rlf_decoder.h b/engines/zvision/video/rlf_decoder.h index 740f3fdd43..8b8cbaecd5 100644 --- a/engines/zvision/video/rlf_decoder.h +++ b/engines/zvision/video/rlf_decoder.h @@ -46,7 +46,7 @@ private: uint16 getWidth() const { return _width; } uint16 getHeight() const { return _height; } Graphics::PixelFormat getPixelFormat() const { return Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); /* RGB 555 */ } - int getCurFrame() const { return _curFrame; } + int getCurFrame() const { return _displayedFrame; } int getFrameCount() const { return _frameCount; } const Graphics::Surface *decodeNextFrame(); bool isSeekable() const { return true; } @@ -121,7 +121,7 @@ private: Frame *_frames; Common::Array _completeFrames; - int _curFrame; + int _displayedFrame; Graphics::Surface _currentFrameBuffer; uint32 _frameBufferByteSize; -- cgit v1.2.3 From 64979d5e453bd279c88e559d295d47b175a6559b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 30 Dec 2014 15:38:03 +0200 Subject: ZVISION: Fix regression in the handling of multiple animations A regression from 0c4e0673c3. Thanks to Marisa-Chan for noticing --- engines/zvision/scripting/effects/animation_effect.cpp | 10 +++++++--- engines/zvision/scripting/effects/animation_effect.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/engines/zvision/scripting/effects/animation_effect.cpp b/engines/zvision/scripting/effects/animation_effect.cpp index c3cbc25406..511a0db353 100644 --- a/engines/zvision/scripting/effects/animation_effect.cpp +++ b/engines/zvision/scripting/effects/animation_effect.cpp @@ -88,10 +88,13 @@ bool AnimationEffect::process(uint32 deltaTimeInMillis) { if (it != _playList.end()) { playnode *nod = &(*it); - if (!_animation->isPlaying()) { + if (nod->_curFrame == -1) { // The node is just beginning playback + nod->_curFrame = nod->start; + _animation->start(); _animation->seekToFrame(nod->start); + _animation->setEndFrame(nod->stop); nod->_delay = deltaTimeInMillis; // Force the frame to draw if (nod->slot) @@ -111,6 +114,7 @@ bool AnimationEffect::process(uint32 deltaTimeInMillis) { return _disposeAfterUse; } + nod->_curFrame = nod->start; _animation->seekToFrame(nod->start); } @@ -186,9 +190,9 @@ void AnimationEffect::addPlayNode(int32 slot, int x, int y, int x2, int y2, int nod.loop = loops; nod.pos = Common::Rect(x, y, x2 + 1, y2 + 1); nod.start = startFrame; - _animation->setEndFrame(CLIP(endFrame, 0, _animation->getFrameCount() - 1)); - + nod.stop = CLIP(endFrame, 0, _animation->getFrameCount() - 1); nod.slot = slot; + nod._curFrame = -1; nod._delay = 0; nod._scaled = NULL; _playList.push_back(nod); diff --git a/engines/zvision/scripting/effects/animation_effect.h b/engines/zvision/scripting/effects/animation_effect.h index a564b83ff3..fd6e24ab8b 100644 --- a/engines/zvision/scripting/effects/animation_effect.h +++ b/engines/zvision/scripting/effects/animation_effect.h @@ -48,7 +48,9 @@ public: Common::Rect pos; int32 slot; int32 start; + int32 stop; int32 loop; + int32 _curFrame; int32 _delay; Graphics::Surface *_scaled; }; -- cgit v1.2.3 From d9ae84808f6314ec8c3b7b0a73e3e746bc8fc201 Mon Sep 17 00:00:00 2001 From: Fedor Strizhnev Date: Tue, 30 Dec 2014 17:18:28 +0300 Subject: SYMBIAN: Add symbian support for access and princes engines --- backends/platform/symbian/AdaptAllMMPs.pl | 2 + .../symbian/BuildPackageUpload_LocalSettings.pl | 40 ++++++----- backends/platform/symbian/help/ScummVM.rtf | 78 ++++++++++++---------- .../platform/symbian/mmp/scummvm_access.mmp.in | 52 +++++++++++++++ .../platform/symbian/mmp/scummvm_prince.mmp.in | 52 +++++++++++++++ 5 files changed, 169 insertions(+), 55 deletions(-) create mode 100644 backends/platform/symbian/mmp/scummvm_access.mmp.in create mode 100644 backends/platform/symbian/mmp/scummvm_prince.mmp.in diff --git a/backends/platform/symbian/AdaptAllMMPs.pl b/backends/platform/symbian/AdaptAllMMPs.pl index 6eed7f0690..ead28ba4b1 100644 --- a/backends/platform/symbian/AdaptAllMMPs.pl +++ b/backends/platform/symbian/AdaptAllMMPs.pl @@ -48,12 +48,14 @@ chdir("../../../"); "mmp/scummvm_voyeur.mmp", "mmp/scummvm_wintermute.mmp", # New engines + "mmp/scummvm_access.mmp", "mmp/scummvm_avalanche.mmp", "mmp/scummvm_bbvs.mmp", "mmp/scummvm_cge2.mmp", "mmp/scummvm_fullpipe.mmp", "mmp/scummvm_lastexpress.mmp", "mmp/scummvm_mads.mmp", + "mmp/scummvm_prince.mmp", "mmp/scummvm_sword25.mmp", "mmp/scummvm_testbed.mmp", "mmp/scummvm_zvision.mmp", diff --git a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl index f9b376d674..8c19631524 100644 --- a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl +++ b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl @@ -3,32 +3,36 @@ @WorkingEngines = qw( agos agi cine cge composer cruise draci dreamweb - drascula hugo gob groovie kyra lastexpress - lure made mohawk parallaction pegasus queen - saga sci scumm sky sword1 sword2 teenagent tinsel - toltecs tony toon touche tsage tucker wintermute - bbvs fullpipe hopkins mortevielle mads cge2 - neverhood testbed avalanche zvision voyeur + drascula hugo gob groovie hopkins kyra lastexpress + lure made mohawk mortevielle neverhood parallaction + pegasus queen saga sci scumm sky sword1 sword2 + teenagent tinsel toltecs tony toon touche tsage + tucker voyeur wintermute + access avalanche bbvs cge2 fullpipe mads prince + testbed zvision ); -#### New engines -#### sword25 + +#### sword25 yet not added + +#### In progress engines are : +#### access avalanche bbvs cge2 fullpipe mads prince +#### testbed zvision @WorkingEngines_1st = qw( - cge2 cine composer cruise drascula groovie - lastexpress made parallaction queen - saga scumm touche tucker wintermute - avalanche zvision voyeur + cine composer cruise drascula groovie + lastexpress made parallaction queen saga + scumm touche tucker wintermute voyeur + access avalanche cge2 zvision ); @WorkingEngines_2nd = qw( - agi agos bbvs cge draci gob hopkins - hugo kyra lure mohawk pegasus sci - sky sword1 sword2 teenagent mads + agi agos cge draci dreamweb gob hopkins + hugo kyra lure mohawk mortevielle neverhood + pegasus sci sky sword1 sword2 teenagent tinsel tsage toltecs tony toon - dreamweb fullpipe mortevielle - neverhood testbed + bbvs fullpipe mads prince testbed ); -#### sword25 +#### sword25 yet not added @TestingEngines = qw( diff --git a/backends/platform/symbian/help/ScummVM.rtf b/backends/platform/symbian/help/ScummVM.rtf index 8e9d37363c..15b2105ecd 100644 --- a/backends/platform/symbian/help/ScummVM.rtf +++ b/backends/platform/symbian/help/ScummVM.rtf @@ -51,24 +51,27 @@ Synonyms;}{\*\cs33 \additive \super \sbasedon10 endnote reference;}{\s34\ql \fi- {\listoverride\listid-125\listoverridecount0\ls12}{\listoverride\listid-120\listoverridecount0\ls13}{\listoverride\listid-129\listoverridecount0\ls14}{\listoverride\listid-119\listoverridecount0\ls15}{\listoverride\listid-125\listoverridecount0\ls16} {\listoverride\listid-120\listoverridecount0\ls17}{\listoverride\listid-129\listoverridecount0\ls18}{\listoverride\listid-119\listoverridecount0\ls19}{\listoverride\listid-125\listoverridecount0\ls20}{\listoverride\listid-120\listoverridecount0\ls21} {\listoverride\listid-129\listoverridecount0\ls22}{\listoverride\listid-119\listoverridecount0\ls23}{\listoverride\listid-125\listoverridecount0\ls24}{\listoverride\listid-120\listoverridecount0\ls25}{\listoverride\listid-129\listoverridecount0\ls26} -{\listoverride\listid-119\listoverridecount0\ls27}{\listoverride\listid-125\listoverridecount0\ls28}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1 -\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls29}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel -\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls30}}{\info{\author Fedor} -{\operator Fedor}{\creatim\yr2013\mo11\dy30\hr23\min4}{\revtim\yr2014\mo9\dy9\hr19\min22}{\version99}{\edmins93}{\nofpages8}{\nofwords1514}{\nofchars8634}{\*\company DEV}{\nofcharsws0}{\vern8249}}\margl1701\margr850\margt1134\margb1134 -\deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl \fet0{\*\template -E:\\Documents and Settings\\Administrator\\Application Data\\Microsoft\\\'d8\'e0\'e1\'eb\'ee\'ed\'fb\\cshelp2000.dot}\sectd \linex0\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang -{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang -{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain -\s17\ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \i\f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\lang1033\langfe1033\langnp1033 Author: Fedor Strizhniou.}{\f28 -\par }{\lang1033\langfe1033\langnp1033 Date: November 2013}{\f28 -\par }{\lang1033\langfe1033\langnp1033 Version: 1.7.0 +{\listoverride\listid-119\listoverridecount0\ls27}{\listoverride\listid-125\listoverridecount0\ls28}{\listoverride\listid-120\listoverridecount0\ls29}{\listoverride\listid-129\listoverridecount0\ls30}{\listoverride\listid-119\listoverridecount0\ls31} +{\listoverride\listid-125\listoverridecount0\ls32}{\listoverride\listid-120\listoverridecount0\ls33}{\listoverride\listid-129\listoverridecount0\ls34}{\listoverride\listid-119\listoverridecount0\ls35}{\listoverride\listid-125\listoverridecount0\ls36} +{\listoverride\listid-120\listoverridecount0\ls37}{\listoverride\listid-129\listoverridecount0\ls38}{\listoverride\listid-119\listoverridecount0\ls39}{\listoverride\listid-125\listoverridecount0\ls40}{\listoverride\listid-2\listoverridecount1{\lfolevel +\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 +}}\ls41}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr +\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls42}}{\info{\author Fedor}{\operator Fedor}{\creatim\yr2013\mo11\dy30\hr23\min4}{\revtim\yr2014\mo12\dy29\hr22\min52}{\version102}{\edmins95}{\nofpages8}{\nofwords1514}{\nofchars8634} +{\*\company DEV}{\nofcharsws0}{\vern8249}}\margl1701\margr850\margt1134\margb1134 \deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0 +\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl \fet0{\*\template E:\\Documents and Settings\\Administrator\\Application Data\\Microsoft\\\'d8\'e0\'e1\'eb\'ee\'ed\'fb\\cshelp2000.dot}\sectd \linex0\sectdefaultcl {\*\pnseclvl1 +\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5 +\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang +{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s17\ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \i\f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 { +\lang1033\langfe1033\langnp1033 Author: Fedor Strizhniou.}{\f28 +\par }{\lang1033\langfe1033\langnp1033 Date: November 2014}{\f28 +\par }{\lang1033\langfe1033\langnp1033 Version: 1.8.0 \par }\pard\plain \s1\ql \li0\ri0\sb360\sa240\keepn\widctlpar\nooverflow\faroman\outlinelevel0\rin0\lin0\itap0 \b\f1\fs32\lang2057\langfe1033\kerning28\cgrid\langnp2057\langfenp1033 {ScummVM Help \par }\pard\plain \s16\ql \li0\ri0\sb360\sa240\keepn\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \b\f1\fs32\cf9\lang2057\langfe1033\kerning28\cgrid\langnp2057\langfenp1033 {\lang1033\langfe1033\langnp1033 0x100039ce}{\lang1059\langfe1033\langnp1059 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 About ScummVM Help -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {About ScummVM Help +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {About ScummVM Help \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }{ This help file based on ScummVM forum thread with some elaborations(in Anotherguest section) and text correction. If you wish add some text or translate you may download and modify source document from https://sourceforge.net/projects/scummvms60git/ and t @@ -79,8 +82,8 @@ hen send me to fedor_qd@mail.ru \par }{\f29 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 1st guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, UIQ, UIQ3, S80, s80, S90, s90 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, UIQ, UIQ3, S80, s80, S90, s90 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }{UIQ3 devices: To the top right (holding the phone portrait) you four icons, from the top they are \par @@ -126,17 +129,17 @@ through directorylist (one hand use perhaps!?) or save games etc. Keyboard mode of events that ScummVM receives from SDL. \par What are these Shrinked, Zoomed and Upscaled modes anyway? \par -\par Shrink displays the game on your screen but in a shrinked way, either in Portrait or Landscape mode, so not all the pixels c -an be seen. Zoom mode uses the maximum resolution of your phone displaying a smaller part of the game zoomed at 1:1 pixels. For scrolling in S60 Zoom mode: 0+Cursor keys to scroll around, 0+Ok button to center view. Upscale tries to fill the larger screen -s on S80/S90 devices in a better way for low resolution games. Currently it uses a pixel interpolation upscaling routine. +\par Shrink displays the game on your screen but in a shrinked way, either in Port +rait or Landscape mode, so not all the pixels can be seen. Zoom mode uses the maximum resolution of your phone displaying a smaller part of the game zoomed at 1:1 pixels. For scrolling in S60 Zoom mode: 0+Cursor keys to scroll around, 0+Ok button to cente +r view. Upscale tries to fill the larger screens on S80/S90 devices in a better way for low resolution games. Currently it uses a pixel interpolation upscaling routine. \par \par You can also use a bluetooth mouse with S60v3 devices to control your game. You need the bluetooth hid library from Hinkka http://koti.mbnet.fi/hinkka/Download.html to get it to work properly. \par }{\f29 \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 2nd guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par \par }{More user-friendly guide for Nokia phones (based on N96 but should apply to most phones) @@ -161,9 +164,8 @@ s on S80/S90 devices in a better way for low resolution games. Currently it uses \par }{1 - Change Input. \par This is the option you'll probably use the most. There are three settings; A,C and J. \par -\par A - - This is the "Text Input" mode. It allows you to type directly into ScummVM as if you were using a keyboard. Type the same way you would when sending a text message off of your phone. Please note that the pointer is disabled when in this mode. Don't forge -t to exit Configuration Mode before typing! +\par A - This is the "Text Input" mode. It allows you to type directly into ScummVM as if you were using a keyboard. Type the same way you would when sending a text message o +ff of your phone. Please note that the pointer is disabled when in this mode. Don't forget to exit Configuration Mode before typing! \par \par C - This is the "Cursor" mode. This emulates the arrow keys of the keyboard. Some games require using this instead of the mouse (e.g. the destruction derby section towards the end of Full Throttle). \par @@ -178,8 +180,9 @@ t to exit Configuration Mode before typing! \par Only applies to Landscape mode, simply swaps the screen output between having the phone tilted on its left side or on its right side. \par \par 4 - Toggle Zoom On and Off -\par Zooms in on a portion of the screen. Handy for when you are looking through a screen for items or having trouble reading subtitles. Use the navigation buttons for panning around - the play area. Don't forget you'll have to exit out of Configuration Mode before you can move the pointer again. Exiting Configuration Mode does not reset the zoom level. +\par Zooms in on a portion of the screen. Handy for when you are looking through a screen fo +r items or having trouble reading subtitles. Use the navigation buttons for panning around the play area. Don't forget you'll have to exit out of Configuration Mode before you can move the pointer again. Exiting Configuration Mode does not reset the zoom +level. \par }{\f29 \par }{5 & 6 - Unused \par @@ -200,12 +203,12 @@ t to exit Configuration Mode before typing! \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 3rd guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par -\par }{ScummVM keys on Nokia e71 (most likely on any other qwerty-device, too), tested on version 0.14.0svn (Feb. 18 2009 - 05:56:07). Number keys are inserted by first pressing fn-key (leftmost key at bottom row on E71) and then pressing correct key (e.g. 5 is fn+g). You don't have to press both keys simultaneously. +\par }{ScummVM keys on Nokia e71 (most likely on any other qwerty-device, too), tested on version 0.14.0svn (Feb. 18 20 +09 05:56:07). Number keys are inserted by first pressing fn-key (leftmost key at bottom row on E71) and then pressing correct key (e.g. 5 is fn+g). You don't have to press both keys simultaneously. \par \par Basic keys: \par @@ -255,9 +258,8 @@ t to exit Configuration Mode before typing! \par p -- punch (hand) \par \par AGI games (King's Quest, Police Quest etc.): -\par The - games work beautifully on the E71, but there's some stupid bugs (in input). I recall finding some debug keys and "last sentence" / "inventory" -keys in earlier version, but I can't find them any more. Also you can't turn on sirens in Police Quest, which -kinda makes it unplayable. +\par The games work beautifully on the E71, but there's some stupid bugs (in input). I recall finding some debug keys and "last sentence" / "inventory" -keys in earlier version, but I can't find them any more. Also you can't turn on sirens in Police Quest, whi +ch kinda makes it unplayable. \par \par There's good side and bad side to each input mode: \par Keyboard (I use this primarily) @@ -278,9 +280,10 @@ kinda makes it unplayable. \par }{\f28 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {ScummVM1 engines list -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls30\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls30\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines -\par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {agi +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls42\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls42\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines +\par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {access +\par agi \par agos \par \tab AGOS2 \par cge2 @@ -312,8 +315,8 @@ kinda makes it unplayable. \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {ScummVM2 engines list -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls30\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls30\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls42\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls42\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines \par }\pard\plain \ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {avalanche \par cge \par composer @@ -330,6 +333,7 @@ kinda makes it unplayable. \par \tab RIVEN \par mortevielle \par pegasus +\par prince \par sci \par \tab SCI32 \par sky diff --git a/backends/platform/symbian/mmp/scummvm_access.mmp.in b/backends/platform/symbian/mmp/scummvm_access.mmp.in new file mode 100644 index 0000000000..4f8b258ec0 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_access.mmp.in @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2013 The ScummVM project + * + * 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. + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_access.lib +TARGETTYPE lib +#include "config.mmh" + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\access + +//START_AUTO_OBJECTS_ACCESS_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_ACCESS_// + diff --git a/backends/platform/symbian/mmp/scummvm_prince.mmp.in b/backends/platform/symbian/mmp/scummvm_prince.mmp.in new file mode 100644 index 0000000000..7dfec04f46 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_prince.mmp.in @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2013 The ScummVM project + * Copyright (C) 2014 Strizniou Fedor + * + * 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. + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_prince.lib +TARGETTYPE lib +#include "config.mmh" + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\prince + +//START_AUTO_OBJECTS_PRINCE_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_PRINCE_// -- cgit v1.2.3 From da18e796d0d2f928ef8b1d0988f4457329d2f31e Mon Sep 17 00:00:00 2001 From: Fedor Strizhnev Date: Tue, 30 Dec 2014 17:18:28 +0300 Subject: SYMBIAN: Add symbian support for access and prince engines --- backends/platform/symbian/AdaptAllMMPs.pl | 2 + .../symbian/BuildPackageUpload_LocalSettings.pl | 40 ++++++----- backends/platform/symbian/help/ScummVM.rtf | 78 ++++++++++++---------- .../platform/symbian/mmp/scummvm_access.mmp.in | 52 +++++++++++++++ .../platform/symbian/mmp/scummvm_prince.mmp.in | 52 +++++++++++++++ 5 files changed, 169 insertions(+), 55 deletions(-) create mode 100644 backends/platform/symbian/mmp/scummvm_access.mmp.in create mode 100644 backends/platform/symbian/mmp/scummvm_prince.mmp.in diff --git a/backends/platform/symbian/AdaptAllMMPs.pl b/backends/platform/symbian/AdaptAllMMPs.pl index 6eed7f0690..ead28ba4b1 100644 --- a/backends/platform/symbian/AdaptAllMMPs.pl +++ b/backends/platform/symbian/AdaptAllMMPs.pl @@ -48,12 +48,14 @@ chdir("../../../"); "mmp/scummvm_voyeur.mmp", "mmp/scummvm_wintermute.mmp", # New engines + "mmp/scummvm_access.mmp", "mmp/scummvm_avalanche.mmp", "mmp/scummvm_bbvs.mmp", "mmp/scummvm_cge2.mmp", "mmp/scummvm_fullpipe.mmp", "mmp/scummvm_lastexpress.mmp", "mmp/scummvm_mads.mmp", + "mmp/scummvm_prince.mmp", "mmp/scummvm_sword25.mmp", "mmp/scummvm_testbed.mmp", "mmp/scummvm_zvision.mmp", diff --git a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl index f9b376d674..8c19631524 100644 --- a/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl +++ b/backends/platform/symbian/BuildPackageUpload_LocalSettings.pl @@ -3,32 +3,36 @@ @WorkingEngines = qw( agos agi cine cge composer cruise draci dreamweb - drascula hugo gob groovie kyra lastexpress - lure made mohawk parallaction pegasus queen - saga sci scumm sky sword1 sword2 teenagent tinsel - toltecs tony toon touche tsage tucker wintermute - bbvs fullpipe hopkins mortevielle mads cge2 - neverhood testbed avalanche zvision voyeur + drascula hugo gob groovie hopkins kyra lastexpress + lure made mohawk mortevielle neverhood parallaction + pegasus queen saga sci scumm sky sword1 sword2 + teenagent tinsel toltecs tony toon touche tsage + tucker voyeur wintermute + access avalanche bbvs cge2 fullpipe mads prince + testbed zvision ); -#### New engines -#### sword25 + +#### sword25 yet not added + +#### In progress engines are : +#### access avalanche bbvs cge2 fullpipe mads prince +#### testbed zvision @WorkingEngines_1st = qw( - cge2 cine composer cruise drascula groovie - lastexpress made parallaction queen - saga scumm touche tucker wintermute - avalanche zvision voyeur + cine composer cruise drascula groovie + lastexpress made parallaction queen saga + scumm touche tucker wintermute voyeur + access avalanche cge2 zvision ); @WorkingEngines_2nd = qw( - agi agos bbvs cge draci gob hopkins - hugo kyra lure mohawk pegasus sci - sky sword1 sword2 teenagent mads + agi agos cge draci dreamweb gob hopkins + hugo kyra lure mohawk mortevielle neverhood + pegasus sci sky sword1 sword2 teenagent tinsel tsage toltecs tony toon - dreamweb fullpipe mortevielle - neverhood testbed + bbvs fullpipe mads prince testbed ); -#### sword25 +#### sword25 yet not added @TestingEngines = qw( diff --git a/backends/platform/symbian/help/ScummVM.rtf b/backends/platform/symbian/help/ScummVM.rtf index 8e9d37363c..15b2105ecd 100644 --- a/backends/platform/symbian/help/ScummVM.rtf +++ b/backends/platform/symbian/help/ScummVM.rtf @@ -51,24 +51,27 @@ Synonyms;}{\*\cs33 \additive \super \sbasedon10 endnote reference;}{\s34\ql \fi- {\listoverride\listid-125\listoverridecount0\ls12}{\listoverride\listid-120\listoverridecount0\ls13}{\listoverride\listid-129\listoverridecount0\ls14}{\listoverride\listid-119\listoverridecount0\ls15}{\listoverride\listid-125\listoverridecount0\ls16} {\listoverride\listid-120\listoverridecount0\ls17}{\listoverride\listid-129\listoverridecount0\ls18}{\listoverride\listid-119\listoverridecount0\ls19}{\listoverride\listid-125\listoverridecount0\ls20}{\listoverride\listid-120\listoverridecount0\ls21} {\listoverride\listid-129\listoverridecount0\ls22}{\listoverride\listid-119\listoverridecount0\ls23}{\listoverride\listid-125\listoverridecount0\ls24}{\listoverride\listid-120\listoverridecount0\ls25}{\listoverride\listid-129\listoverridecount0\ls26} -{\listoverride\listid-119\listoverridecount0\ls27}{\listoverride\listid-125\listoverridecount0\ls28}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1 -\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls29}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel -\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls30}}{\info{\author Fedor} -{\operator Fedor}{\creatim\yr2013\mo11\dy30\hr23\min4}{\revtim\yr2014\mo9\dy9\hr19\min22}{\version99}{\edmins93}{\nofpages8}{\nofwords1514}{\nofchars8634}{\*\company DEV}{\nofcharsws0}{\vern8249}}\margl1701\margr850\margt1134\margb1134 -\deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl \fet0{\*\template -E:\\Documents and Settings\\Administrator\\Application Data\\Microsoft\\\'d8\'e0\'e1\'eb\'ee\'ed\'fb\\cshelp2000.dot}\sectd \linex0\sectdefaultcl {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang -{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang -{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain -\s17\ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \i\f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\lang1033\langfe1033\langnp1033 Author: Fedor Strizhniou.}{\f28 -\par }{\lang1033\langfe1033\langnp1033 Date: November 2013}{\f28 -\par }{\lang1033\langfe1033\langnp1033 Version: 1.7.0 +{\listoverride\listid-119\listoverridecount0\ls27}{\listoverride\listid-125\listoverridecount0\ls28}{\listoverride\listid-120\listoverridecount0\ls29}{\listoverride\listid-129\listoverridecount0\ls30}{\listoverride\listid-119\listoverridecount0\ls31} +{\listoverride\listid-125\listoverridecount0\ls32}{\listoverride\listid-120\listoverridecount0\ls33}{\listoverride\listid-129\listoverridecount0\ls34}{\listoverride\listid-119\listoverridecount0\ls35}{\listoverride\listid-125\listoverridecount0\ls36} +{\listoverride\listid-120\listoverridecount0\ls37}{\listoverride\listid-129\listoverridecount0\ls38}{\listoverride\listid-119\listoverridecount0\ls39}{\listoverride\listid-125\listoverridecount0\ls40}{\listoverride\listid-2\listoverridecount1{\lfolevel +\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 +}}\ls41}{\listoverride\listid-2\listoverridecount1{\lfolevel\listoverrideformat{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelold\levelspace0\levelindent283{\leveltext\'01\u-3991 ?;}{\levelnumbers;}\f30\chbrdr +\brdrnone\brdrcf1 \chshdng0\chcfpat1\chcbpat1\fbias0 \fi-283\li283 }}\ls42}}{\info{\author Fedor}{\operator Fedor}{\creatim\yr2013\mo11\dy30\hr23\min4}{\revtim\yr2014\mo12\dy29\hr22\min52}{\version102}{\edmins95}{\nofpages8}{\nofwords1514}{\nofchars8634} +{\*\company DEV}{\nofcharsws0}{\vern8249}}\margl1701\margr850\margt1134\margb1134 \deftab708\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0 +\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl \fet0{\*\template E:\\Documents and Settings\\Administrator\\Application Data\\Microsoft\\\'d8\'e0\'e1\'eb\'ee\'ed\'fb\\cshelp2000.dot}\sectd \linex0\sectdefaultcl {\*\pnseclvl1 +\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{\*\pnseclvl5 +\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang +{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s17\ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \i\f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 { +\lang1033\langfe1033\langnp1033 Author: Fedor Strizhniou.}{\f28 +\par }{\lang1033\langfe1033\langnp1033 Date: November 2014}{\f28 +\par }{\lang1033\langfe1033\langnp1033 Version: 1.8.0 \par }\pard\plain \s1\ql \li0\ri0\sb360\sa240\keepn\widctlpar\nooverflow\faroman\outlinelevel0\rin0\lin0\itap0 \b\f1\fs32\lang2057\langfe1033\kerning28\cgrid\langnp2057\langfenp1033 {ScummVM Help \par }\pard\plain \s16\ql \li0\ri0\sb360\sa240\keepn\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \b\f1\fs32\cf9\lang2057\langfe1033\kerning28\cgrid\langnp2057\langfenp1033 {\lang1033\langfe1033\langnp1033 0x100039ce}{\lang1059\langfe1033\langnp1059 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 About ScummVM Help -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {About ScummVM Help +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {About ScummVM Help \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }{ This help file based on ScummVM forum thread with some elaborations(in Anotherguest section) and text correction. If you wish add some text or translate you may download and modify source document from https://sourceforge.net/projects/scummvms60git/ and t @@ -79,8 +82,8 @@ hen send me to fedor_qd@mail.ru \par }{\f29 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 1st guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, UIQ, UIQ3, S80, s80, S90, s90 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, UIQ, UIQ3, S80, s80, S90, s90 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par }{UIQ3 devices: To the top right (holding the phone portrait) you four icons, from the top they are \par @@ -126,17 +129,17 @@ through directorylist (one hand use perhaps!?) or save games etc. Keyboard mode of events that ScummVM receives from SDL. \par What are these Shrinked, Zoomed and Upscaled modes anyway? \par -\par Shrink displays the game on your screen but in a shrinked way, either in Portrait or Landscape mode, so not all the pixels c -an be seen. Zoom mode uses the maximum resolution of your phone displaying a smaller part of the game zoomed at 1:1 pixels. For scrolling in S60 Zoom mode: 0+Cursor keys to scroll around, 0+Ok button to center view. Upscale tries to fill the larger screen -s on S80/S90 devices in a better way for low resolution games. Currently it uses a pixel interpolation upscaling routine. +\par Shrink displays the game on your screen but in a shrinked way, either in Port +rait or Landscape mode, so not all the pixels can be seen. Zoom mode uses the maximum resolution of your phone displaying a smaller part of the game zoomed at 1:1 pixels. For scrolling in S60 Zoom mode: 0+Cursor keys to scroll around, 0+Ok button to cente +r view. Upscale tries to fill the larger screens on S80/S90 devices in a better way for low resolution games. Currently it uses a pixel interpolation upscaling routine. \par \par You can also use a bluetooth mouse with S60v3 devices to control your game. You need the bluetooth hid library from Hinkka http://koti.mbnet.fi/hinkka/Download.html to get it to work properly. \par }{\f29 \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 2nd guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par \par }{More user-friendly guide for Nokia phones (based on N96 but should apply to most phones) @@ -161,9 +164,8 @@ s on S80/S90 devices in a better way for low resolution games. Currently it uses \par }{1 - Change Input. \par This is the option you'll probably use the most. There are three settings; A,C and J. \par -\par A - - This is the "Text Input" mode. It allows you to type directly into ScummVM as if you were using a keyboard. Type the same way you would when sending a text message off of your phone. Please note that the pointer is disabled when in this mode. Don't forge -t to exit Configuration Mode before typing! +\par A - This is the "Text Input" mode. It allows you to type directly into ScummVM as if you were using a keyboard. Type the same way you would when sending a text message o +ff of your phone. Please note that the pointer is disabled when in this mode. Don't forget to exit Configuration Mode before typing! \par \par C - This is the "Cursor" mode. This emulates the arrow keys of the keyboard. Some games require using this instead of the mouse (e.g. the destruction derby section towards the end of Full Throttle). \par @@ -178,8 +180,9 @@ t to exit Configuration Mode before typing! \par Only applies to Landscape mode, simply swaps the screen output between having the phone tilted on its left side or on its right side. \par \par 4 - Toggle Zoom On and Off -\par Zooms in on a portion of the screen. Handy for when you are looking through a screen for items or having trouble reading subtitles. Use the navigation buttons for panning around - the play area. Don't forget you'll have to exit out of Configuration Mode before you can move the pointer again. Exiting Configuration Mode does not reset the zoom level. +\par Zooms in on a portion of the screen. Handy for when you are looking through a screen fo +r items or having trouble reading subtitles. Use the navigation buttons for panning around the play area. Don't forget you'll have to exit out of Configuration Mode before you can move the pointer again. Exiting Configuration Mode does not reset the zoom +level. \par }{\f29 \par }{5 & 6 - Unused \par @@ -200,12 +203,12 @@ t to exit Configuration Mode before typing! \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\b0\f28 3rd guide -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls29\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls29\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls41\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls41\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Controls, Virtual keyboard, Shortcuts, ScummVM, Tips, S60, s60 \par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {\f28 \par -\par }{ScummVM keys on Nokia e71 (most likely on any other qwerty-device, too), tested on version 0.14.0svn (Feb. 18 2009 - 05:56:07). Number keys are inserted by first pressing fn-key (leftmost key at bottom row on E71) and then pressing correct key (e.g. 5 is fn+g). You don't have to press both keys simultaneously. +\par }{ScummVM keys on Nokia e71 (most likely on any other qwerty-device, too), tested on version 0.14.0svn (Feb. 18 20 +09 05:56:07). Number keys are inserted by first pressing fn-key (leftmost key at bottom row on E71) and then pressing correct key (e.g. 5 is fn+g). You don't have to press both keys simultaneously. \par \par Basic keys: \par @@ -255,9 +258,8 @@ t to exit Configuration Mode before typing! \par p -- punch (hand) \par \par AGI games (King's Quest, Police Quest etc.): -\par The - games work beautifully on the E71, but there's some stupid bugs (in input). I recall finding some debug keys and "last sentence" / "inventory" -keys in earlier version, but I can't find them any more. Also you can't turn on sirens in Police Quest, which -kinda makes it unplayable. +\par The games work beautifully on the E71, but there's some stupid bugs (in input). I recall finding some debug keys and "last sentence" / "inventory" -keys in earlier version, but I can't find them any more. Also you can't turn on sirens in Police Quest, whi +ch kinda makes it unplayable. \par \par There's good side and bad side to each input mode: \par Keyboard (I use this primarily) @@ -278,9 +280,10 @@ kinda makes it unplayable. \par }{\f28 \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {ScummVM1 engines list -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls30\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls30\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines -\par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {agi +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls42\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls42\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines +\par }\pard\plain \ql \li0\ri0\sa120\widctlpar{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {access +\par agi \par agos \par \tab AGOS2 \par cge2 @@ -312,8 +315,8 @@ kinda makes it unplayable. \par \par }\pard\plain \s2\ql \li0\ri0\sb120\sa120\keepn\widctlpar\brdrt\brdrs\brdrw30\brsp20 \brdrb\brdrs\brdrw30\brsp20 \tqr\tx9072{\*\pn \pnlvlcont\ilvl0\ls0\pnrnot0\pndec }\nooverflow\faroman\outlinelevel1\rin0\lin0\itap0 \b\f1\fs24\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {ScummVM2 engines list -\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls30\pnrnot0 -\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls30\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines +\par {\pntext\pard\plain\s26 \f30\fs20\lang2057\langfe1033\langnp2057\langfenp1033 \loch\af30\dbch\af0\hich\f30 \'69\tab}}\pard\plain \s26\ql \fi-283\li283\ri0\sa120\widctlpar\brdrb\brdrs\brdrw15\brsp20 {\*\pn \pnlvlblt\ilvl0\ls42\pnrnot0 +\pnf30\pnstart1\pnindent283\pnhang{\pntxtb i}}\nooverflow\faroman\ls42\rin0\lin283\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {Supported engines \par }\pard\plain \ql \li0\ri0\sa120\widctlpar\nooverflow\faroman\rin0\lin0\itap0 \f1\fs20\lang2057\langfe1033\cgrid\langnp2057\langfenp1033 {avalanche \par cge \par composer @@ -330,6 +333,7 @@ kinda makes it unplayable. \par \tab RIVEN \par mortevielle \par pegasus +\par prince \par sci \par \tab SCI32 \par sky diff --git a/backends/platform/symbian/mmp/scummvm_access.mmp.in b/backends/platform/symbian/mmp/scummvm_access.mmp.in new file mode 100644 index 0000000000..4f8b258ec0 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_access.mmp.in @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2013 The ScummVM project + * + * 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. + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_access.lib +TARGETTYPE lib +#include "config.mmh" + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\access + +//START_AUTO_OBJECTS_ACCESS_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_ACCESS_// + diff --git a/backends/platform/symbian/mmp/scummvm_prince.mmp.in b/backends/platform/symbian/mmp/scummvm_prince.mmp.in new file mode 100644 index 0000000000..7dfec04f46 --- /dev/null +++ b/backends/platform/symbian/mmp/scummvm_prince.mmp.in @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL + * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System + * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer + * Copyright (C) 2005-2013 The ScummVM project + * Copyright (C) 2014 Strizniou Fedor + * + * 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. + * + */ + +// +// EPOC MMP makefile project for ScummVM +// + +// *** Definitions + +TARGET scummvm_prince.lib +TARGETTYPE lib +#include "config.mmh" + +//START_AUTO_MACROS_SLAVE// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_MACROS_SLAVE// + +// *** SOURCE files + +SOURCEPATH ..\..\..\..\engines\prince + +//START_AUTO_OBJECTS_PRINCE_// + + // empty base file, will be updated by Perl build scripts + +//STOP_AUTO_OBJECTS_PRINCE_// -- cgit v1.2.3 From e27f5f69882345e45d6b2f1c8b449ea622d7d464 Mon Sep 17 00:00:00 2001 From: Fedor Strizhnev Date: Tue, 30 Dec 2014 19:05:27 +0300 Subject: Symbian: completely disabled MT32 --- backends/platform/symbian/AdaptAllMMPs.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backends/platform/symbian/AdaptAllMMPs.pl b/backends/platform/symbian/AdaptAllMMPs.pl index ead28ba4b1..6b9f918a51 100644 --- a/backends/platform/symbian/AdaptAllMMPs.pl +++ b/backends/platform/symbian/AdaptAllMMPs.pl @@ -105,6 +105,7 @@ my @sections_scumm = ("", "ENABLE_SCUMM_7_8", "ENABLE_HE"); # special sections f # files excluded from build, case insensitive, will be matched in filename string only my @excludes_snd = ( "mt32.*", + "Analog.cpp", "fluidsynth.cpp", "i386.cpp", "part.*", @@ -193,6 +194,7 @@ ParseModule("_tucker", "tucker", \@section_empty); ParseModule("_voyeur" ,"voyeur", \@section_empty); ParseModule("_wintermute","wintermute", \@section_empty); ##### new engines +ParseModule("_access" ,"access", \@section_empty); ParseModule("_avalanche" ,"avalanche", \@section_empty); ParseModule("_bbvs" ,"bbvs", \@section_empty); ParseModule("_cge2" ,"cge2", \@section_empty); @@ -200,6 +202,7 @@ ParseModule("_fullpipe" ,"fullpipe", \@section_empty); ParseModule("_lastexpress","lastexpress", \@section_empty); ParseModule("_m4", "m4", \@section_empty); ParseModule("_mads" ,"mads", \@section_empty); +ParseModule("_prince" ,"prince", \@section_empty); ParseModule("_sword25" ,"sword25", \@section_empty); ParseModule("_testbed" ,"testbed", \@section_empty); ParseModule("_zvision" ,"zvision", \@section_empty); -- cgit v1.2.3 From 2fb116f10eaa1bf682a220c33016fc61492af4fe Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 13:32:44 -0600 Subject: SWORD25: Move all lua serialization helper functions to their own file --- engines/sword25/util/lua_serialization_util.cpp | 269 +++++++++++++++++ engines/sword25/util/lua_serialization_util.h | 55 ++++ engines/sword25/util/lua_serializer.cpp | 56 ++-- engines/sword25/util/lua_unserializer.cpp | 368 ++---------------------- 4 files changed, 376 insertions(+), 372 deletions(-) diff --git a/engines/sword25/util/lua_serialization_util.cpp b/engines/sword25/util/lua_serialization_util.cpp index 80c5f86b20..fc3f73eca6 100644 --- a/engines/sword25/util/lua_serialization_util.cpp +++ b/engines/sword25/util/lua_serialization_util.cpp @@ -27,10 +27,20 @@ #include "lua/lobject.h" #include "lua/lstate.h" #include "lua/lgc.h" +#include "lua/lopcodes.h" namespace Lua { +void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) { + global_State *globalState = G(luaState); + + block = (*globalState->frealloc)(globalState->ud, block, osize, nsize); + globalState->totalbytes = (globalState->totalbytes - osize) + nsize; + + return block; +} + void pushObject(lua_State *luaState, TValue *obj) { setobj2s(luaState, luaState->top, obj); @@ -74,4 +84,263 @@ StkId getObject(lua_State *luaState, int stackpos) { } } +void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { + global_State *globalState = G(luaState); + + obj->gch.next = globalState->rootgc; + globalState->rootgc = obj; + obj->gch.marked = luaC_white(globalState); + obj->gch.tt = type; +} + +Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) { + Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements)); + lua_linkObjToGC(luaState, obj2gco(c), LUA_TFUNCTION); + + c->l.isC = 0; + c->l.env = elementTable; + c->l.nupvalues = cast_byte(numElements); + + while (numElements--) { + c->l.upvals[numElements] = NULL; + } + + return c; +} + +void pushClosure(lua_State *luaState, Closure *closure) { + TValue obj; + setclvalue(luaState, &obj, closure); + pushObject(luaState, &obj); +} + +Proto *createProto(lua_State *luaState) { + Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO); + + newProto->k = NULL; + newProto->sizek = 0; + newProto->p = NULL; + newProto->sizep = 0; + newProto->code = NULL; + newProto->sizecode = 0; + newProto->sizelineinfo = 0; + newProto->sizeupvalues = 0; + newProto->nups = 0; + newProto->upvalues = NULL; + newProto->numparams = 0; + newProto->is_vararg = 0; + newProto->maxstacksize = 0; + newProto->lineinfo = NULL; + newProto->sizelocvars = 0; + newProto->locvars = NULL; + newProto->linedefined = 0; + newProto->lastlinedefined = 0; + newProto->source = NULL; + + return newProto; +} + +TString *createString(lua_State *luaState, const char *str, size_t len) { + TString *res; + lua_pushlstring(luaState, str, len); + + res = rawtsvalue(luaState->top - 1); + lua_pop(luaState, 1); + + return res; +} + +Proto *makeFakeProto(lua_State *L, lu_byte nups) { + Proto *p = createProto(L); + + p->sizelineinfo = 1; + p->lineinfo = lua_newVector(L, 1, int); + p->lineinfo[0] = 1; + p->sizecode = 1; + p->code = lua_newVector(L, 1, Instruction); + p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); + p->source = createString(L, "", 0); + p->maxstacksize = 2; + p->nups = nups; + p->sizek = 0; + p->sizep = 0; + + return p; +} + +UpVal *createUpValue(lua_State *luaState, int stackpos) { + UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal)); + lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL); + upValue->tt = LUA_TUPVAL; + upValue->v = &upValue->u.value; + upValue->u.l.prev = NULL; + upValue->u.l.next = NULL; + + const TValue *o2 = (TValue *)getObject(luaState, stackpos); + upValue->v->value = o2->value; + upValue->v->tt = o2->tt; + checkliveness(G(L), upValue->v); + + return upValue; +} + +void unboxUpValue(lua_State *luaState) { + // >>>>> ...... func + LClosure *lcl; + UpVal *uv; + + lcl = (LClosure *)clvalue(getObject(luaState, -1)); + uv = lcl->upvals[0]; + + lua_pop(luaState, 1); + // >>>>> ...... + + pushUpValue(luaState, uv); + // >>>>> ...... upValue +} + +size_t appendStackToStack_reverse(lua_State *from, lua_State *to) { + for (StkId id = from->top - 1; id >= from->stack; --id) { + setobj2s(to, to->top, id); + to->top++; + } + + return from->top - from->stack; +} + +void correctStack(lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + +void lua_reallocstack(lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + + lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack + newsize; + correctStack(L, oldstack); +} + +void lua_growstack(lua_State *L, int n) { + // Double size is enough? + if (n <= L->stacksize) { + lua_reallocstack(L, 2 * L->stacksize); + } else { + lua_reallocstack(L, L->stacksize + n); + } +} + +void lua_reallocCallInfo(lua_State *lauState, int newsize) { + CallInfo *oldci = lauState->base_ci; + lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo); + + lauState->size_ci = newsize; + lauState->ci = (lauState->ci - oldci) + lauState->base_ci; + lauState->end_ci = lauState->base_ci + lauState->size_ci - 1; +} + +void GCUnlink(lua_State *luaState, GCObject *gco) { + GCObject *prevslot; + if (G(luaState)->rootgc == gco) { + G(luaState)->rootgc = G(luaState)->rootgc->gch.next; + return; + } + + prevslot = G(luaState)->rootgc; + while (prevslot->gch.next != gco) { + prevslot = prevslot->gch.next; + } + + prevslot->gch.next = prevslot->gch.next->gch.next; +} + +TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) { + lua_pushlstring(luaState, str, len); + TString *luaStr = &(luaState->top - 1)->value.gc->ts; + + lua_pop(luaState, 1); + + return luaStr; +} + +void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) { + global_State *g = G(luaState); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + +Proto *lua_newproto(lua_State *luaState) { + Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_link(luaState, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + +UpVal *makeUpValue(lua_State *luaState, int stackPos) { + UpVal *uv = lua_new(luaState, UpVal); + lua_link(luaState, (GCObject *)uv, LUA_TUPVAL); + uv->tt = LUA_TUPVAL; + uv->v = &uv->u.value; + uv->u.l.prev = NULL; + uv->u.l.next = NULL; + + setobj(luaState, uv->v, getObject(luaState, stackPos)); + + return uv; +} + +void boxUpValue_start(lua_State *luaState) { + LClosure *closure; + closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt)); + pushClosure(luaState, (Closure *)closure); + // >>>>> ...... func + closure->p = makeFakeProto(luaState, 1); + + // Temporarily initialize the upvalue to nil + lua_pushnil(luaState); + closure->upvals[0] = makeUpValue(luaState, -1); + lua_pop(luaState, 1); +} + +void boxUpValue_finish(lua_State *luaState) { + // >>>>> ...... func obj + LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2)); + + lcl->upvals[0]->u.value = *getObject(luaState, -1); + lua_pop(luaState, 1); + // >>>>> ...... func +} + } // End of namespace Lua diff --git a/engines/sword25/util/lua_serialization_util.h b/engines/sword25/util/lua_serialization_util.h index 6c55d0dd53..345996f606 100644 --- a/engines/sword25/util/lua_serialization_util.h +++ b/engines/sword25/util/lua_serialization_util.h @@ -32,12 +32,67 @@ typedef TValue *StkId; namespace Lua { +#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize) +#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e)) +#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T)))) +#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T))) +#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T)) + +void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize); + void pushObject(lua_State *luaState, TValue *obj); void pushProto(lua_State *luaState, Proto *proto); void pushUpValue(lua_State *luaState, UpVal *upval); void pushString(lua_State *luaState, TString *str); + StkId getObject(lua_State *luaState, int stackpos); +void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type); + +#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) + +Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable); +void pushClosure(lua_State *luaState, Closure *closure); + +Proto *createProto(lua_State *luaState); +Proto *makeFakeProto(lua_State *L, lu_byte nups); + +TString *createString(lua_State *luaState, const char *str, size_t len); + +UpVal *createUpValue(lua_State *luaState, int stackpos); +void unboxUpValue(lua_State *luaState); + +/* Appends one stack to another stack, but the stack is reversed in the process */ +size_t appendStackToStack_reverse(lua_State *from, lua_State *to); +void correctStack(lua_State *L, TValue *oldstack); +void lua_reallocstack(lua_State *L, int newsize); +void lua_growstack(lua_State *L, int n); + +void lua_reallocCallInfo(lua_State *lauState, int newsize); + +/* Does basically the opposite of luaC_link(). + * Right now this function is rather inefficient; it requires traversing the + * entire root GC set in order to find one object. If the GC list were doubly + * linked this would be much easier, but there's no reason for Lua to have + * that. */ +void GCUnlink(lua_State *luaState, GCObject *gco); + +TString *lua_newlstr(lua_State *luaState, const char *str, size_t len); +void lua_link(lua_State *luaState, GCObject *o, lu_byte tt); +Proto *lua_newproto(lua_State *luaState) ; + +UpVal *makeUpValue(lua_State *luaState, int stackPos); +/** + * The GC is not fond of finding upvalues in tables. We get around this + * during persistence using a weakly keyed table, so that the GC doesn't + * bother to mark them. This won't work in unpersisting, however, since + * if we make the values weak they'll be collected (since nothing else + * references them). Our solution, during unpersisting, is to represent + * upvalues as dummy functions, each with one upvalue. + */ +void boxUpValue_start(lua_State *luaState); +void boxUpValue_finish(lua_State *luaState); + } // End of namespace Lua #endif diff --git a/engines/sword25/util/lua_serializer.cpp b/engines/sword25/util/lua_serializer.cpp index c6c5f99342..55b6257324 100644 --- a/engines/sword25/util/lua_serializer.cpp +++ b/engines/sword25/util/lua_serializer.cpp @@ -42,7 +42,7 @@ struct SerializationInfo { uint counter; }; -static void serializeObject(SerializationInfo *info); +static void serialize(SerializationInfo *info); static void serializeBoolean(SerializationInfo *info); static void serializeNumber(SerializationInfo *info); @@ -103,14 +103,14 @@ void serializeLua(lua_State *luaState, Common::WriteStream *writeStream) { // >>>>> permTbl indexTbl rootObj // Serialize the root recursively - serializeObject(&info); + serialize(&info); // Return the stack back to the original state lua_remove(luaState, 2); // >>>>> permTbl rootObj } -static void serializeObject(SerializationInfo *info) { +static void serialize(SerializationInfo *info) { // The stack can potentially have many things on it // The object we want to serialize is the item on the top of the stack // >>>>> permTbl indexTbl rootObj ...... obj @@ -188,7 +188,7 @@ static void serializeObject(SerializationInfo *info) { info->writeStream->writeSint32LE(PERMANENT_TYPE); // Serialize the key - serializeObject(info); + serialize(info); // Pop the key off the stack lua_pop(info->luaState, 1); @@ -368,7 +368,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { info->writeStream->writeSint32LE(1); // Serialize the function - serializeObject(info); + serialize(info); lua_pop(info->luaState, 2); // >>>>> permTbl indexTbl ...... obj @@ -395,7 +395,7 @@ static void serializeTable(SerializationInfo *info) { } // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl @@ -412,13 +412,13 @@ static void serializeTable(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... tbl k v k */ // Serialize the key - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl k v */ // Serialize the value - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl k */ @@ -430,7 +430,7 @@ static void serializeTable(SerializationInfo *info) { lua_pushnil(info->luaState); // >>>>> permTbl indexTbl ...... tbl - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl @@ -457,7 +457,7 @@ static void serializeFunction(SerializationInfo *info) { pushProto(info->luaState, cl->l.p); // >>>>> permTbl indexTbl ...... func proto */ - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func @@ -468,7 +468,7 @@ static void serializeFunction(SerializationInfo *info) { pushUpValue(info->luaState, cl->l.upvals[i]); // >>>>> permTbl indexTbl ...... func upval - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func @@ -492,23 +492,13 @@ static void serializeFunction(SerializationInfo *info) { } // >>>>> permTbl indexTbl ...... func fenv/nil - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func } } -/* Appends one stack to another stack, but the stack is reversed in the process */ -static size_t appendStackToStack_rev(lua_State *from, lua_State *to) { - for (StkId id = from->top - 1; id >= from->stack; --id) { - setobj2s(to, to->top, id); - to->top++; - } - - return from->top - from->stack; -} - static void serializeThread(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... thread lua_State *threadState = lua_tothread(info->luaState, -1); @@ -525,12 +515,12 @@ static void serializeThread(SerializationInfo *info) { // Persist the stack // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems - uint32 stackSize = static_cast(appendStackToStack_rev(threadState, info->luaState)); + uint32 stackSize = static_cast(appendStackToStack_reverse(threadState, info->luaState)); info->writeStream->writeUint32LE(stackSize); // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ for (; stackSize > 0; --stackSize) { - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); } @@ -592,7 +582,7 @@ static void serializeThread(SerializationInfo *info) { pushUpValue(info->luaState, upVal); // >>>>> permTbl indexTbl ...... thread upVal - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... thread @@ -607,7 +597,7 @@ static void serializeThread(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... thread nil // Use nil as a terminator - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... thread @@ -627,7 +617,7 @@ static void serializeProto(SerializationInfo *info) { pushObject(info->luaState, &proto->k[i]); // >>>>> permTbl indexTbl ...... proto const - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -643,7 +633,7 @@ static void serializeProto(SerializationInfo *info) { pushProto(info->luaState, proto->p[i]); // >>>>> permTbl indexTbl ...... proto subProto */ - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -666,7 +656,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->upvalues[i]); // >>>>> permTbl indexTbl ...... proto str - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -680,7 +670,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->locvars[i].varname); // >>>>> permTbl indexTbl ...... proto str - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -694,7 +684,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->source); // >>>>> permTbl indexTbl ...... proto sourceStr - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -757,7 +747,7 @@ static void serializeUpValue(SerializationInfo *info) { pushObject(info->luaState, upValue->v); // >>>>> permTbl indexTbl ...... obj - serializeObject(info); + serialize(info); // >>>>> permTbl indexTbl ...... obj } @@ -787,7 +777,7 @@ static void serializeUserData(SerializationInfo *info) { } // >>>>> permTbl rootObj ...... udata metaTbl/nil - serializeObject(info); + serialize(info); lua_pop(info->luaState, 1); /* perms reftbl ... udata */ diff --git a/engines/sword25/util/lua_unserializer.cpp b/engines/sword25/util/lua_unserializer.cpp index 69cb764dd2..803c79c8c2 100644 --- a/engines/sword25/util/lua_unserializer.cpp +++ b/engines/sword25/util/lua_unserializer.cpp @@ -40,7 +40,7 @@ struct UnSerializationInfo { Common::ReadStream *readStream; }; -static void unserializeObject(UnSerializationInfo *info); +static void unserialize(UnSerializationInfo *info); static void unserializeBoolean(UnSerializationInfo *info); static void unserializeNumber(UnSerializationInfo *info); @@ -74,7 +74,7 @@ void unserializeLua(lua_State *luaState, Common::ReadStream *readStream) { lua_gc(luaState, LUA_GCSTOP, 0); // Unserialize the root object - unserializeObject(&info); + unserialize(&info); // >>>>> permTbl indexTbl rootObj // Re-start garbage collection @@ -85,7 +85,7 @@ void unserializeLua(lua_State *luaState, Common::ReadStream *readStream) { // >>>>> permTbl rootObj } -/* The object is left on the stack. This is primarily used by unpersist, but +/* The object is left on the stack. This is primarily used by unserialize, but * may be used by GCed objects that may incur cycles in order to preregister * the object. */ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { @@ -105,7 +105,7 @@ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... obj } -static void unserializeObject(UnSerializationInfo *info) { +static void unserialize(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -241,7 +241,7 @@ static void unserializeSpecialTable(UnSerializationInfo *info, int index) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... spfunc lua_call(info->luaState, 0, 1); @@ -262,7 +262,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... tbl // Unserialize metatable - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? if (lua_istable(info->luaState, -1)) { @@ -279,7 +279,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { while (1) { // >>>>> permTbl indexTbl ...... tbl - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... tbl key/nil // The table serialization is nil terminated @@ -292,7 +292,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { } // >>>>> permTbl indexTbl ...... tbl key - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... tbl value lua_rawset(info->luaState, -3); @@ -317,142 +317,6 @@ void unserializeTable(UnSerializationInfo *info, int index) { } } - - -void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) { - global_State *globalState = G(luaState); - - block = (*globalState->frealloc)(globalState->ud, block, osize, nsize); - globalState->totalbytes = (globalState->totalbytes - osize) + nsize; - - return block; -} - -#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize) -#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e)) -#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T)))) -#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T))) -#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T)) - -void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { - global_State *globalState = G(luaState); - - obj->gch.next = globalState->rootgc; - globalState->rootgc = obj; - obj->gch.marked = luaC_white(globalState); - obj->gch.tt = type; -} - -#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) - -Closure *newLClosure(lua_State *luaState, byte numUpValues, Table *env) { - Closure *newClosure = (Closure *)lua_malloc(luaState, sizeLclosure(numUpValues)); - - lua_linkObjToGC(luaState, obj2gco(newClosure), LUA_TFUNCTION); - - newClosure->l.isC = 0; - newClosure->l.env = env; - newClosure->l.nupvalues = numUpValues; - - while (numUpValues--) { - newClosure->l.upvals[numUpValues] = NULL; - } - - return newClosure; -} - -static void pushClosure(lua_State *luaState, Closure *closure) { - TValue obj; - setclvalue(luaState, &obj, closure); - pushObject(luaState, &obj); -} - -Proto *createProto(lua_State *luaState) { - Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto)); - lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO); - - newProto->k = NULL; - newProto->sizek = 0; - newProto->p = NULL; - newProto->sizep = 0; - newProto->code = NULL; - newProto->sizecode = 0; - newProto->sizelineinfo = 0; - newProto->sizeupvalues = 0; - newProto->nups = 0; - newProto->upvalues = NULL; - newProto->numparams = 0; - newProto->is_vararg = 0; - newProto->maxstacksize = 0; - newProto->lineinfo = NULL; - newProto->sizelocvars = 0; - newProto->locvars = NULL; - newProto->linedefined = 0; - newProto->lastlinedefined = 0; - newProto->source = NULL; - - return newProto; -} - -TString *createString(lua_State *luaState, const char *str, size_t len) { - TString *res; - lua_pushlstring(luaState, str, len); - - res = rawtsvalue(luaState->top - 1); - lua_pop(luaState, 1); - - return res; -} - -static Proto *makeFakeProto(lua_State *L, lu_byte nups) { - Proto *p = createProto(L); - - p->sizelineinfo = 1; - p->lineinfo = lua_newVector(L, 1, int); - p->lineinfo[0] = 1; - p->sizecode = 1; - p->code = lua_newVector(L, 1, Instruction); - p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); - p->source = createString(L, "", 0); - p->maxstacksize = 2; - p->nups = nups; - p->sizek = 0; - p->sizep = 0; - - return p; -} - -static UpVal *createUpValue(lua_State *luaState, int stackpos) { - UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal)); - lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL); - upValue->tt = LUA_TUPVAL; - upValue->v = &upValue->u.value; - upValue->u.l.prev = NULL; - upValue->u.l.next = NULL; - - const TValue *o2 = (TValue *)getObject(luaState, stackpos); - upValue->v->value = o2->value; - upValue->v->tt = o2->tt; - checkliveness(G(L), upValue->v); - - return upValue; -} - -static void unboxUpValue(lua_State *luaState) { - // >>>>> ...... func - LClosure *lcl; - UpVal *uv; - - lcl = (LClosure *)clvalue(getObject(luaState, -1)); - uv = lcl->upvals[0]; - - lua_pop(luaState, 1); - // >>>>> ...... - - pushUpValue(luaState, uv); - // >>>>> ...... upValue -} - void unserializeFunction(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... @@ -461,7 +325,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { byte numUpValues = info->readStream->readByte(); - LClosure *lclosure = (LClosure *)newLClosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt)); + LClosure *lclosure = (LClosure *)lua_newLclosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt)); pushClosure(info->luaState, (Closure *)lclosure); // >>>>> permTbl indexTbl ...... func @@ -484,7 +348,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { registerObjectInIndexTable(info, index); // Now that it's safe, we can get the real proto - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... func proto lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc); @@ -494,7 +358,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { for (byte i = 0; i < numUpValues; ++i) { // >>>>> permTbl indexTbl ...... func - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... func func2 unboxUpValue(info->luaState); @@ -506,7 +370,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { } // Finally, the fenv - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... func ?fenv/nil? if (!lua_isnil(info->luaState, -1)) { @@ -522,81 +386,6 @@ void unserializeFunction(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... func } -static void correctStack(lua_State *L, TValue *oldstack) { - CallInfo *ci; - GCObject *up; - L->top = (L->top - oldstack) + L->stack; - for (up = L->openupval; up != NULL; up = up->gch.next) - gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; - for (ci = L->base_ci; ci <= L->ci; ci++) { - ci->top = (ci->top - oldstack) + L->stack; - ci->base = (ci->base - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; - } - L->base = (L->base - oldstack) + L->stack; -} - -void lua_reallocstack(lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int realsize = newsize + 1 + EXTRA_STACK; - - lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue); - L->stacksize = realsize; - L->stack_last = L->stack + newsize; - correctStack(L, oldstack); -} - -void lua_growstack(lua_State *L, int n) { - // Double size is enough? - if (n <= L->stacksize) { - lua_reallocstack(L, 2 * L->stacksize); - } else { - lua_reallocstack(L, L->stacksize + n); - } -} - -void lua_reallocCallInfo(lua_State *lauState, int newsize) { - CallInfo *oldci = lauState->base_ci; - lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo); - - lauState->size_ci = newsize; - lauState->ci = (lauState->ci - oldci) + lauState->base_ci; - lauState->end_ci = lauState->base_ci + lauState->size_ci - 1; -} - -void unboxUpVal(lua_State *luaState) { - // >>>>> ... func - LClosure *lcl; - UpVal *uv; - - lcl = (LClosure *)(&getObject(luaState, -1)->value.gc->cl); - uv = lcl->upvals[0]; - lua_pop(luaState, 1); - // >>>>> ... - pushUpValue(luaState, uv); - // >>>>> ... upVal -} - -/* Does basically the opposite of luaC_link(). - * Right now this function is rather inefficient; it requires traversing the - * entire root GC set in order to find one object. If the GC list were doubly - * linked this would be much easier, but there's no reason for Lua to have - * that. */ -static void GCUnlink(lua_State *luaState, GCObject *gco) { - GCObject *prevslot; - if (G(luaState)->rootgc == gco) { - G(luaState)->rootgc = G(luaState)->rootgc->gch.next; - return; - } - - prevslot = G(luaState)->rootgc; - while (prevslot->gch.next != gco) { - prevslot = prevslot->gch.next; - } - - prevslot->gch.next = prevslot->gch.next->gch.next; -} - void unserializeThread(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... @@ -619,7 +408,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { // very bottom of the stack L2->top--; for (uint32 i = 0; i < stackSize; ++i) { - unserializeObject(info); + unserialize(info); // L1: permTbl indexTbl ...... thread obj* } @@ -679,7 +468,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { global_State *g = G(L2); while (true) { - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... thread upVal/nil // The list is terminated by a nil @@ -691,7 +480,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { } // >>>>> permTbl indexTbl ...... thread boxedUpVal - unboxUpVal(info->luaState); + unboxUpValue(info->luaState); // >>>>> permTbl indexTbl ...... thread boxedUpVal uv = &(getObject(info->luaState, -1)->value.gc->uv); @@ -722,48 +511,6 @@ void unserializeThread(UnSerializationInfo *info, int index) { } } -TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) { - lua_pushlstring(luaState, str, len); - TString *luaStr = &(luaState->top - 1)->value.gc->ts; - - lua_pop(luaState, 1); - - return luaStr; -} - -void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) { - global_State *g = G(luaState); - o->gch.next = g->rootgc; - g->rootgc = o; - o->gch.marked = luaC_white(g); - o->gch.tt = tt; -} - -Proto *lua_newproto(lua_State *luaState) { - Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto)); - lua_link(luaState, obj2gco(f), LUA_TPROTO); - f->k = NULL; - f->sizek = 0; - f->p = NULL; - f->sizep = 0; - f->code = NULL; - f->sizecode = 0; - f->sizelineinfo = 0; - f->sizeupvalues = 0; - f->nups = 0; - f->upvalues = NULL; - f->numparams = 0; - f->is_vararg = 0; - f->maxstacksize = 0; - f->lineinfo = NULL; - f->sizelocvars = 0; - f->locvars = NULL; - f->linedefined = 0; - f->lastlinedefined = 0; - f->source = NULL; - return f; -} - void unserializeProto(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... @@ -793,7 +540,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); for (int i = 0; i < sizek; ++i) { // >>>>> permTbl indexTbl ...... proto - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... proto k setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); @@ -810,7 +557,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); for (int i = 0; i < sizep; ++i) { // >>>>> permTbl indexTbl ...... proto - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... proto subproto p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc; @@ -834,7 +581,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); for (int i = 0; i < p->sizeupvalues; ++i) { // >>>>> permTbl indexTbl ...... proto - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... proto str p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -850,7 +597,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); for (int i = 0; i < p->sizelocvars; ++i) { // >>>>> permTbl indexTbl ...... proto - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... proto str p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -864,7 +611,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... proto // Read in source string - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... proto sourceStr p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -890,75 +637,18 @@ void unserializeProto(UnSerializationInfo *info, int index) { p->maxstacksize = info->readStream->readByte(); } -Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) { - Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements)); - lua_link(luaState, obj2gco(c), LUA_TFUNCTION); - c->l.isC = 0; - c->l.env = elementTable; - c->l.nupvalues = cast_byte(numElements); - - while (numElements--) { - c->l.upvals[numElements] = NULL; - } - - return c; -} - -static UpVal *makeUpVal(lua_State *luaState, int stackPos) { - UpVal *uv = lua_new(luaState, UpVal); - lua_link(luaState, (GCObject *)uv, LUA_TUPVAL); - uv->tt = LUA_TUPVAL; - uv->v = &uv->u.value; - uv->u.l.prev = NULL; - uv->u.l.next = NULL; - - setobj(luaState, uv->v, getObject(luaState, stackPos)); - - return uv; -} - -/** - * The GC is not fond of finding upvalues in tables. We get around this - * during persistence using a weakly keyed table, so that the GC doesn't - * bother to mark them. This won't work in unpersisting, however, since - * if we make the values weak they'll be collected (since nothing else - * references them). Our solution, during unpersisting, is to represent - * upvalues as dummy functions, each with one upvalue. - */ -static void boxupval_start(lua_State *luaState) { - LClosure *closure; - closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt)); - pushClosure(luaState, (Closure *)closure); - // >>>>> ...... func - closure->p = makeFakeProto(luaState, 1); - - // Temporarily initialize the upvalue to nil - lua_pushnil(luaState); - closure->upvals[0] = makeUpVal(luaState, -1); - lua_pop(luaState, 1); -} - -static void boxupval_finish(lua_State *luaState) { - // >>>>> ...... func obj - LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2)); - - lcl->upvals[0]->u.value = *getObject(luaState, -1); - lua_pop(luaState, 1); - // >>>>> ...... func -} - void unserializeUpValue(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... - lua_checkstack(upi->L, 2); + lua_checkstack(info->luaState, 2); - boxupval_start(upi->L); + boxUpValue_start(info->luaState); // >>>>> permTbl indexTbl ...... func registerObjectInIndexTable(info, index); - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... func obj - boxupval_finish(upi->L); + boxUpValue_finish(info->luaState); // >>>>> permTbl indexTbl ...... func } @@ -970,7 +660,7 @@ void unserializeUserData(UnSerializationInfo *info, int index) { int isspecial = info->readStream->readSint32LE(); if (isspecial) { - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... specialFunc lua_call(info->luaState, 0, 1); @@ -981,12 +671,12 @@ void unserializeUserData(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... udata registerObjectInIndexTable(info, index); - info->readStream->read(lua_touserdata(upi->L, -1), length); + info->readStream->read(lua_touserdata(info->luaState, -1), length); - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... udata metaTable/nil - lua_setmetatable(upi->L, -2); + lua_setmetatable(info->luaState, -2); // >>>>> permTbl indexTbl ...... udata } // >>>>> permTbl indexTbl ...... udata @@ -998,7 +688,7 @@ void unserializePermanent(UnSerializationInfo *info, int index) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); - unserializeObject(info); + unserialize(info); // >>>>> permTbl indexTbl ...... permKey lua_gettable(info->luaState, 1); -- cgit v1.2.3 From 0b8482b55fb38147927d2c27478aae59c0f98dab Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 13:42:02 -0600 Subject: SWORD25: Update module.mk with lua serialization changes --- engines/sword25/module.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk index 234baec165..0135f53783 100644 --- a/engines/sword25/module.mk +++ b/engines/sword25/module.mk @@ -82,9 +82,10 @@ MODULE_OBJS := \ util/lua/lvm.o \ util/lua/lzio.o \ util/lua/scummvm_file.o \ - util/pluto/pdep.o \ - util/pluto/pluto.o \ - util/pluto/plzio.o + util/double_serializer.o \ + util/lua_serialization_util.o \ + util/lua_serializer.o \ + util/lua_unserializer.o # This module can be built as a plugin ifeq ($(ENABLE_SWORD25), DYNAMIC_PLUGIN) -- cgit v1.2.3 From a188b31d15711bd86725ca4feb0dc36fb2ab71ac Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 13:42:45 -0600 Subject: SWORD25: Use new lua serialization functions to persist state --- engines/sword25/kernel/outputpersistenceblock.cpp | 7 +++ engines/sword25/kernel/outputpersistenceblock.h | 1 + engines/sword25/script/luascript.cpp | 61 +++++------------------ 3 files changed, 20 insertions(+), 49 deletions(-) diff --git a/engines/sword25/kernel/outputpersistenceblock.cpp b/engines/sword25/kernel/outputpersistenceblock.cpp index 9003b5d58a..3e25fce5c7 100644 --- a/engines/sword25/kernel/outputpersistenceblock.cpp +++ b/engines/sword25/kernel/outputpersistenceblock.cpp @@ -41,6 +41,13 @@ OutputPersistenceBlock::OutputPersistenceBlock() { _data.reserve(INITIAL_BUFFER_SIZE); } +void OutputPersistenceBlock::write(const void *data, uint32 size) { + writeMarker(BLOCK_MARKER); + + write(size); + rawWrite(data, size); +} + void OutputPersistenceBlock::write(int32 value) { writeMarker(SINT_MARKER); value = TO_LE_32(value); diff --git a/engines/sword25/kernel/outputpersistenceblock.h b/engines/sword25/kernel/outputpersistenceblock.h index c7d8dfc6aa..bdbd20d3e0 100644 --- a/engines/sword25/kernel/outputpersistenceblock.h +++ b/engines/sword25/kernel/outputpersistenceblock.h @@ -41,6 +41,7 @@ class OutputPersistenceBlock : public PersistenceBlock { public: OutputPersistenceBlock(); + void write(const void *data, uint32 size); void write(int32 value); void write(uint32 value); void write(float value); diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index f62a08005b..6cf287c643 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -29,7 +29,7 @@ * */ -#include "common/array.h" +#include "common/memstream.h" #include "common/debug-channels.h" #include "sword25/sword25.h" @@ -43,7 +43,7 @@ #include "sword25/util/lua/lua.h" #include "sword25/util/lua/lualib.h" #include "sword25/util/lua/lauxlib.h" -#include "sword25/util/pluto/pluto.h" +#include "sword25/util/lua_serialization.h" namespace Sword25 { @@ -112,10 +112,6 @@ bool LuaScriptEngine::init() { // Place the error handler function in the Lua registry, and remember the index _pcallErrorhandlerRegistryIndex = luaL_ref(_state, LUA_REGISTRYINDEX); - // Initialize the Pluto-Persistence library - luaopen_pluto(_state); - lua_pop(_state, 1); - // Initialize debugging callback if (DebugMan.isDebugChannelEnabled(kDebugScript)) { int mask = 0; @@ -383,19 +379,8 @@ bool pushPermanentsTable(lua_State *L, PERMANENT_TABLE_TYPE tableType) { return true; } -} - -namespace { -int chunkwriter(lua_State *L, const void *p, size_t sz, void *ud) { - Common::Array & chunkData = *reinterpret_cast * >(ud); - const byte *buffer = reinterpret_cast(p); - while (sz--) - chunkData.push_back(*buffer++); - - return 1; -} -} +} // End of anonymous namespace bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) { // Empty the Lua stack. pluto_persist() xepects that the stack is empty except for its parameters @@ -409,12 +394,12 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) { pushPermanentsTable(_state, PTT_PERSIST); lua_getglobal(_state, "_G"); - // Lua persists and stores the data in a Common::Array - Common::Array chunkData; - pluto_persist(_state, chunkwriter, &chunkData); + // Lua persists and stores the data in a WriteStream + Common::MemoryWriteStreamDynamic writeStream; + Lua::serializeLua(_state, &writeStream); // Persistenzdaten in den Writer schreiben. - writer.writeByteArray(chunkData); + writer.write(writeStream.getData(), writeStream.size()); // Die beiden Tabellen vom Stack nehmen. lua_pop(_state, 2); @@ -424,24 +409,6 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) { namespace { -struct ChunkreaderData { - void *BufferPtr; - size_t Size; - bool BufferReturned; -}; - -const char *chunkreader(lua_State *L, void *ud, size_t *sz) { - ChunkreaderData &cd = *reinterpret_cast(ud); - - if (!cd.BufferReturned) { - cd.BufferReturned = true; - *sz = cd.Size; - return reinterpret_cast(cd.BufferPtr); - } else { - return 0; - } -} - void clearGlobalTable(lua_State *L, const char **exceptions) { // Iterate over all elements of the global table lua_pushvalue(L, LUA_GLOBALSINDEX); @@ -479,7 +446,8 @@ void clearGlobalTable(lua_State *L, const char **exceptions) { // Perform garbage collection, so that all removed elements are deleted lua_gc(L, LUA_GCCOLLECT, 0); } -} + +} // End of anonymous namespace bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) { // Empty the Lua stack. pluto_persist() xepects that the stack is empty except for its parameters @@ -512,14 +480,9 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) { // Persisted Lua data Common::Array chunkData; reader.readByteArray(chunkData); + Common::MemoryReadStream readStream(&chunkData[0], chunkData.size(), DisposeAfterUse::NO); - // Chunk-Reader initialisation. It is used with pluto_unpersist to restore read data - ChunkreaderData cd; - cd.BufferPtr = &chunkData[0]; - cd.Size = chunkData.size(); - cd.BufferReturned = false; - - pluto_unpersist(_state, chunkreader, &cd); + Lua::unserializeLua(_state, &readStream); // Permanents-Table is removed from stack lua_remove(_state, -2); @@ -527,7 +490,7 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) { // The read elements in the global table about lua_pushnil(_state); while (lua_next(_state, -2) != 0) { - // The referenec to the global table (_G) must not be overwritten, or ticks from Lua total + // The reference to the global table (_G) must not be overwritten, or ticks from Lua total bool isGlobalReference = lua_isstring(_state, -2) && strcmp(lua_tostring(_state, -2), "_G") == 0; if (!isGlobalReference) { lua_pushvalue(_state, -2); -- cgit v1.2.3 From 97c35714ce3986b99848a780f6b195a63f8910b7 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 15:19:29 -0600 Subject: SWORD25: Rename lua serialization functions to use 'persist' in order to match the rest of the engine --- engines/sword25/module.mk | 6 +- engines/sword25/script/luascript.cpp | 6 +- engines/sword25/util/lua_persist.cpp | 787 ++++++++++++++++++++++++ engines/sword25/util/lua_persistence.h | 44 ++ engines/sword25/util/lua_persistence_util.cpp | 346 +++++++++++ engines/sword25/util/lua_persistence_util.h | 98 +++ engines/sword25/util/lua_serialization.h | 44 -- engines/sword25/util/lua_serialization_util.cpp | 346 ----------- engines/sword25/util/lua_serialization_util.h | 98 --- engines/sword25/util/lua_serializer.cpp | 787 ------------------------ engines/sword25/util/lua_unpersist.cpp | 698 +++++++++++++++++++++ engines/sword25/util/lua_unserializer.cpp | 698 --------------------- 12 files changed, 1979 insertions(+), 1979 deletions(-) create mode 100644 engines/sword25/util/lua_persist.cpp create mode 100644 engines/sword25/util/lua_persistence.h create mode 100644 engines/sword25/util/lua_persistence_util.cpp create mode 100644 engines/sword25/util/lua_persistence_util.h delete mode 100644 engines/sword25/util/lua_serialization.h delete mode 100644 engines/sword25/util/lua_serialization_util.cpp delete mode 100644 engines/sword25/util/lua_serialization_util.h delete mode 100644 engines/sword25/util/lua_serializer.cpp create mode 100644 engines/sword25/util/lua_unpersist.cpp delete mode 100644 engines/sword25/util/lua_unserializer.cpp diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk index 0135f53783..129b4f040e 100644 --- a/engines/sword25/module.mk +++ b/engines/sword25/module.mk @@ -83,9 +83,9 @@ MODULE_OBJS := \ util/lua/lzio.o \ util/lua/scummvm_file.o \ util/double_serializer.o \ - util/lua_serialization_util.o \ - util/lua_serializer.o \ - util/lua_unserializer.o + util/lua_persistence_util.o \ + util/lua_persist.o \ + util/lua_unpersist.o # This module can be built as a plugin ifeq ($(ENABLE_SWORD25), DYNAMIC_PLUGIN) diff --git a/engines/sword25/script/luascript.cpp b/engines/sword25/script/luascript.cpp index 6cf287c643..e93289596b 100644 --- a/engines/sword25/script/luascript.cpp +++ b/engines/sword25/script/luascript.cpp @@ -43,7 +43,7 @@ #include "sword25/util/lua/lua.h" #include "sword25/util/lua/lualib.h" #include "sword25/util/lua/lauxlib.h" -#include "sword25/util/lua_serialization.h" +#include "sword25/util/lua_persistence.h" namespace Sword25 { @@ -396,7 +396,7 @@ bool LuaScriptEngine::persist(OutputPersistenceBlock &writer) { // Lua persists and stores the data in a WriteStream Common::MemoryWriteStreamDynamic writeStream; - Lua::serializeLua(_state, &writeStream); + Lua::persistLua(_state, &writeStream); // Persistenzdaten in den Writer schreiben. writer.write(writeStream.getData(), writeStream.size()); @@ -482,7 +482,7 @@ bool LuaScriptEngine::unpersist(InputPersistenceBlock &reader) { reader.readByteArray(chunkData); Common::MemoryReadStream readStream(&chunkData[0], chunkData.size(), DisposeAfterUse::NO); - Lua::unserializeLua(_state, &readStream); + Lua::unpersistLua(_state, &readStream); // Permanents-Table is removed from stack lua_remove(_state, -2); diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp new file mode 100644 index 0000000000..b9c0b13e11 --- /dev/null +++ b/engines/sword25/util/lua_persist.cpp @@ -0,0 +1,787 @@ +/* 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 "sword25/util/lua_persistence.h" + +#include "sword25/util/double_serializer.h" +#include "sword25/util/lua_persistence_util.h" + +#include "common/stream.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" +#include "lua/lgc.h" + + +namespace Lua { + +#define PERMANENT_TYPE 101 + +struct SerializationInfo { + lua_State *luaState; + Common::WriteStream *writeStream; + uint counter; +}; + +static void serialize(SerializationInfo *info); + +static void serializeBoolean(SerializationInfo *info); +static void serializeNumber(SerializationInfo *info); +static void serializeString(SerializationInfo *info); +static void serializeTable(SerializationInfo *info); +static void serializeFunction(SerializationInfo *info); +static void serializeThread(SerializationInfo *info); +static void serializeProto(SerializationInfo *info); +static void serializeUpValue(SerializationInfo *info); +static void serializeUserData(SerializationInfo *info); + + +void persistLua(lua_State *luaState, Common::WriteStream *writeStream) { + SerializationInfo info; + info.luaState = luaState; + info.writeStream = writeStream; + info.counter = 0u; + + // The process starts with the lua stack as follows: + // >>>>> permTbl rootObj + // That's the table of permanents and the root object to be serialized + + // Make sure there is enough room on the stack + lua_checkstack(luaState, 4); + assert(lua_gettop(luaState) == 2); + // And that the root isn't nil + assert(!lua_isnil(luaState, 2)); + + // Create a table to hold indexes of everything that's serialized + // This allows us to only serialize an object once + // Every other time, just reference the index + lua_newtable(luaState); + // >>>>> permTbl rootObj indexTbl + + // Now we're going to make the table weakly keyed. This prevents the + // GC from visiting it and trying to mark things it doesn't want to + // mark in tables, e.g. upvalues. All objects in the table are + // a priori reachable, so it doesn't matter that we do this. + + // Create the metatable + lua_newtable(luaState); + // >>>>> permTbl rootObj indexTbl metaTbl + + lua_pushstring(luaState, "__mode"); + // >>>>> permTbl rootObj indexTbl metaTbl "__mode" + + lua_pushstring(luaState, "k"); + // >>>>> permTbl rootObj indexTbl metaTbl "__mode" "k" + + lua_settable(luaState, 4); + // >>>>> permTbl rootObj indexTbl metaTbl + + lua_setmetatable(luaState, 3); + // >>>>> permTbl rootObj indexTbl + + // Swap the indexTable and the rootObj + lua_insert(luaState, 2); + // >>>>> permTbl indexTbl rootObj + + // Serialize the root recursively + serialize(&info); + + // Return the stack back to the original state + lua_remove(luaState, 2); + // >>>>> permTbl rootObj +} + +static void serialize(SerializationInfo *info) { + // The stack can potentially have many things on it + // The object we want to serialize is the item on the top of the stack + // >>>>> permTbl indexTbl rootObj ...... obj + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // If the object has already been written, don't write it again + // Instead write the index of the object from the indexTbl + + // Check the indexTbl + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + lua_rawget(info->luaState, 2); + // >>>>> permTbl indexTbl rootObj ...... obj ?index? + + // If the index isn't nil, the object has already been written + if (!lua_isnil(info->luaState, -1)) { + // Write out a flag that indicates that it's an index + info->writeStream->writeByte(0); + + // Retrieve the index from the stack + uint *index = (uint *)lua_touserdata(info->luaState, -1); + + // Write out the index + info->writeStream->writeUint32LE(*index); + + // Pop the index off the stack + lua_pop(info->luaState, 1); + + return; + } + + // Pop the nil off the stack + lua_pop(info->luaState, 1); + + // Write out a flag that indicates that this is a real object + info->writeStream->writeByte(1); + + // If the object itself is nil, then write out a zero as a placeholder + if (lua_isnil(info->luaState, -1)) { + info->writeStream->writeByte(0); + + return; + } + + // Add the object to the indexTbl + + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + uint *ref = (uint *)lua_newuserdata(info->luaState, sizeof(uint)); + *ref = ++(info->counter); + // >>>>> permTbl indexTbl rootObj ...... obj obj index + + lua_rawset(info->luaState, 2); + // >>>>> permTbl indexTbl rootObj ...... obj + + + // Write out the index + info->writeStream->writeUint32LE(info->counter); + + + // Objects that are in the permanents table are serialized in a special way + + lua_pushvalue(info->luaState, -1); + // >>>>> permTbl indexTbl rootObj ...... obj obj + + lua_gettable(info->luaState, 1); + // >>>>> permTbl indexTbl rootObj ...... obj obj ?permKey? + + if (!lua_isnil(info->luaState, -1)) { + // Write out the type + info->writeStream->writeSint32LE(PERMANENT_TYPE); + + // Serialize the key + serialize(info); + + // Pop the key off the stack + lua_pop(info->luaState, 1); + + return; + } + + // Pop the nil off the stack + lua_pop(info->luaState, 1); + + // Query the type of the object + int objType = lua_type(info->luaState, -1); + + // Write it out + info->writeStream->writeSint32LE(objType); + + // Serialize the object by its type + + switch (objType) { + case LUA_TBOOLEAN: + serializeBoolean(info); + break; + case LUA_TLIGHTUSERDATA: + // You can't serialize a pointer + // It would be meaningless on the next run + assert(0); + break; + case LUA_TNUMBER: + serializeNumber(info); + break; + case LUA_TSTRING: + serializeString(info); + break; + case LUA_TTABLE: + serializeTable(info); + break; + case LUA_TFUNCTION: + serializeFunction(info); + break; + case LUA_TTHREAD: + serializeThread(info); + break; + case LUA_TPROTO: + serializeProto(info); + break; + case LUA_TUPVAL: + serializeUpValue(info); + break; + case LUA_TUSERDATA: + serializeUserData(info); + break; + default: + assert(0); + } +} + +static void serializeBoolean(SerializationInfo *info) { + int value = lua_toboolean(info->luaState, -1); + + info->writeStream->writeSint32LE(value); +} + +static void serializeNumber(SerializationInfo *info) { + lua_Number value = lua_tonumber(info->luaState, -1); + + #if 1 + Util::SerializedDouble serializedValue(Util::encodeDouble(value)); + + info->writeStream->writeUint32LE(serializedValue.significandOne); + info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); + info->writeStream->writeSint16LE(serializedValue.exponent); + #else + // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. + // Also, I don't know if we can assume all compilers use IEEE double + // Therefore, I have chosen to store the double as a string. + Common::String buffer = Common::String::format("%f", value); + + info->writeStream->write(buffer.c_str(), buffer.size()); + #endif + +} + +static void serializeString(SerializationInfo *info) { + // Hard cast to a uint32 to force size_t to an explicit size + // *Theoretically* this could truncate, but if we have a 4gb string, we have bigger problems + uint32 length = static_cast(lua_strlen(info->luaState, -1)); + info->writeStream->writeUint32LE(length); + + const char *str = lua_tostring(info->luaState, -1); + info->writeStream->write(str, length); +} + +/* Choose whether to do a regular or special persistence based on an object's + * metatable. "default" is whether the object, if it doesn't have a __persist + * entry, is literally persistable or not. + * Pushes the unpersist closure and returns true if special persistence is + * used. */ +static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 4); + + // Check whether we should persist literally, or via the __persist metafunction + if (!lua_getmetatable(info->luaState, -1)) { + if (defaction) { + // Write out a flag declaring that the object isn't special and should be persisted normally + info->writeStream->writeSint32LE(0); + + return false; + } else { + lua_pushstring(info->luaState, "Type not literally persistable by default"); + lua_error(info->luaState); + + return false; // Not reached + } + } + + // >>>>> permTbl indexTbl ...... obj metaTbl + lua_pushstring(info->luaState, "__persist"); + // >>>>> permTbl indexTbl rootObj ...... obj metaTbl "__persist" + + lua_rawget(info->luaState, -2); + // >>>>> permTbl indexTbl ...... obj metaTbl ?__persist? + + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... obj metaTbl nil + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + if (defaction) { + // Write out a flag declaring that the object isn't special and should be persisted normally + info->writeStream->writeSint32LE(0); + + return false; + } else { + lua_pushstring(info->luaState, "Type not literally persistable by default"); + lua_error(info->luaState); + + return false; // Return false + } + + } else if (lua_isboolean(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... obj metaTbl bool + if (lua_toboolean(info->luaState, -1)) { + // Write out a flag declaring that the object isn't special and should be persisted normally + info->writeStream->writeSint32LE(0); + + // >>>>> permTbl indexTbl ...... obj metaTbl true */ + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + return false; + } else { + lua_pushstring(info->luaState, "Metatable forbade persistence"); + lua_error(info->luaState); + + return false; // Not reached + } + } else if (!lua_isfunction(info->luaState, -1)) { + lua_pushstring(info->luaState, "__persist not nil, boolean, or function"); + lua_error(info->luaState); + } + + // >>>>> permTbl indexTbl ...... obj metaTbl __persist + lua_pushvalue(info->luaState, -3); + // >>>>> permTbl indexTbl ...... obj metaTbl __persist obj + + // >>>>> permTbl indexTbl ...... obj metaTbl ?func? + + if (!lua_isfunction(info->luaState, -1)) { + lua_pushstring(info->luaState, "__persist function did not return a function"); + lua_error(info->luaState); + } + + // >>>>> permTbl indexTbl ...... obj metaTbl func + + // Write out a flag that the function exists + info->writeStream->writeSint32LE(1); + + // Serialize the function + serialize(info); + + lua_pop(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj + + return true; +} + +static void serializeTable(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... tbl + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 3); + + // Test if the object needs special serialization + if (serializeSpecialObject(info, 1)) { + return; + } + + // >>>>> permTbl indexTbl ...... tbl + + // First, serialize the metatable (if any) + if (!lua_getmetatable(info->luaState, -1)) { + lua_pushnil(info->luaState); + } + + // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + + + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... tbl nil + + // Now, persist all k/v pairs + while (lua_next(info->luaState, -2)) { + // >>>>> permTbl indexTbl ...... tbl k v */ + + lua_pushvalue(info->luaState, -2); + // >>>>> permTbl indexTbl ...... tbl k v k */ + + // Serialize the key + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl k v */ + + // Serialize the value + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl k */ + } + + // >>>>> permTbl indexTbl ...... tbl + + // Terminate the list with a nil + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... tbl + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl +} + +static void serializeFunction(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... func + Closure *cl = clvalue(getObject(info->luaState, -1)); + lua_checkstack(info->luaState, 2); + + if (cl->c.isC) { + /* It's a C function. For now, we aren't going to allow + * persistence of C closures, even if the "C proto" is + * already in the permanents table. */ + lua_pushstring(info->luaState, "Attempt to persist a C function"); + lua_error(info->luaState); + } else { + // It's a Lua closure + + // We don't really _NEED_ the number of upvals, but it'll simplify things a bit + info->writeStream->writeByte(cl->l.p->nups); + + // Serialize the prototype + pushProto(info->luaState, cl->l.p); + // >>>>> permTbl indexTbl ...... func proto */ + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + // Serialize upvalue values (not the upvalue objects themselves) + for (byte i = 0; i < cl->l.p->nups; i++) { + // >>>>> permTbl indexTbl ...... func + pushUpValue(info->luaState, cl->l.upvals[i]); + // >>>>> permTbl indexTbl ...... func upval + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // >>>>> permTbl indexTbl ...... func + + // Serialize function environment + lua_getfenv(info->luaState, -1); + // >>>>> permTbl indexTbl ...... func fenv + + if (lua_equal(info->luaState, -1, LUA_GLOBALSINDEX)) { + // Function has the default fenv + + // >>>>> permTbl indexTbl ...... func _G + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... func nil + } + + // >>>>> permTbl indexTbl ...... func fenv/nil + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } +} + +static void serializeThread(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... thread + lua_State *threadState = lua_tothread(info->luaState, -1); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, threadState->top - threadState->stack + 1); + + if (info->luaState == threadState) { + lua_pushstring(info->luaState, "Can't persist currently running thread"); + lua_error(info->luaState); + return; /* not reached */ + } + + // Persist the stack + + // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems + uint32 stackSize = static_cast(appendStackToStack_reverse(threadState, info->luaState)); + info->writeStream->writeUint32LE(stackSize); + + // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ + for (; stackSize > 0; --stackSize) { + serialize(info); + + lua_pop(info->luaState, 1); + } + + // >>>>> permTbl indexTbl ...... thread + + // Now, serialize the CallInfo stack + + // Again, we *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems + uint32 numFrames = static_cast((threadState->ci - threadState->base_ci) + 1); + info->writeStream->writeUint32LE(numFrames); + + for (uint32 i = 0; i < numFrames; i++) { + CallInfo *ci = threadState->base_ci + i; + + // Same argument as above about truncation + uint32 stackBase = static_cast(ci->base - threadState->stack); + uint32 stackFunc = static_cast(ci->func - threadState->stack); + uint32 stackTop = static_cast(ci->top - threadState->stack); + + info->writeStream->writeUint32LE(stackBase); + info->writeStream->writeUint32LE(stackFunc); + info->writeStream->writeUint32LE(stackTop); + + info->writeStream->writeSint32LE(ci->nresults); + + uint32 savedpc = (ci != threadState->base_ci) ? static_cast(ci->savedpc - ci_func(ci)->l.p->code) : 0u; + info->writeStream->writeUint32LE(savedpc); + } + + + // Serialize the state's other parameters, with the exception of upval stuff + + assert(threadState->nCcalls <= 1); + info->writeStream->writeByte(threadState->status); + + // Same argument as above about truncation + uint32 stackBase = static_cast(threadState->base - threadState->stack); + uint32 stackFunc = static_cast(threadState->top - threadState->stack); + info->writeStream->writeUint32LE(stackBase); + info->writeStream->writeUint32LE(stackFunc); + + // Same argument as above about truncation + uint32 stackOffset = static_cast(threadState->errfunc); + info->writeStream->writeUint32LE(stackOffset); + + // Finally, record upvalues which need to be reopened + // See the comment above serializeUpVal() for why we do this + + UpVal *upVal; + + // >>>>> permTbl indexTbl ...... thread + for (GCObject *gcObject = threadState->openupval; gcObject != NULL; gcObject = upVal->next) { + upVal = gco2uv(gcObject); + + /* Make sure upvalue is really open */ + assert(upVal->v != &upVal->u.value); + + pushUpValue(info->luaState, upVal); + // >>>>> permTbl indexTbl ...... thread upVal + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + + // Same argument as above about truncation + uint32 stackpos = static_cast(upVal->v - threadState->stack); + info->writeStream->writeUint32LE(stackpos); + } + + // >>>>> permTbl indexTbl ...... thread + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... thread nil + + // Use nil as a terminator + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread +} + +static void serializeProto(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... proto + Proto *proto = gco2p(getObject(info->luaState, -1)->value.gc); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // Serialize constant refs */ + info->writeStream->writeSint32LE(proto->sizek); + + for (int i = 0; i < proto->sizek; ++i) { + pushObject(info->luaState, &proto->k[i]); + // >>>>> permTbl indexTbl ...... proto const + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + // >>>>> permTbl indexTbl ...... proto + + // Serialize inner Proto refs + info->writeStream->writeSint32LE(proto->sizep); + + for (int i = 0; i < proto->sizep; ++i) + { + pushProto(info->luaState, proto->p[i]); + // >>>>> permTbl indexTbl ...... proto subProto */ + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + // >>>>> permTbl indexTbl ...... proto + + // Serialize the code + info->writeStream->writeSint32LE(proto->sizecode); + + uint32 len = static_cast(sizeof(Instruction) * proto->sizecode); + info->writeStream->write(proto->code, len); + + + // Serialize upvalue names + info->writeStream->writeSint32LE(proto->sizeupvalues); + + for (int i = 0; i < proto->sizeupvalues; ++i) + { + pushString(info->luaState, proto->upvalues[i]); + // >>>>> permTbl indexTbl ...... proto str + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + + + // Serialize local variable infos + info->writeStream->writeSint32LE(proto->sizelocvars); + + for (int i = 0; i < proto->sizelocvars; ++i) { + pushString(info->luaState, proto->locvars[i].varname); + // >>>>> permTbl indexTbl ...... proto str + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + info->writeStream->writeSint32LE(proto->locvars[i].startpc); + info->writeStream->writeSint32LE(proto->locvars[i].endpc); + } + + + // Serialize source string + pushString(info->luaState, proto->source); + // >>>>> permTbl indexTbl ...... proto sourceStr + + serialize(info); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + // Serialize line numbers + info->writeStream->writeSint32LE(proto->sizelineinfo); + + if (proto->sizelineinfo) { + uint32 len = static_cast(sizeof(int) * proto->sizelineinfo); + info->writeStream->write(proto->lineinfo, len); + } + + // Serialize linedefined and lastlinedefined + info->writeStream->writeSint32LE(proto->linedefined); + info->writeStream->writeSint32LE(proto->lastlinedefined); + + + // Serialize misc values + info->writeStream->writeByte(proto->nups); + info->writeStream->writeByte(proto->numparams); + info->writeStream->writeByte(proto->is_vararg); + info->writeStream->writeByte(proto->maxstacksize); +} + +/* Upvalues are tricky. Here's why. + * + * A particular upvalue may be either "open", in which case its member v + * points into a thread's stack, or "closed" in which case it points to the + * upvalue itself. An upvalue is closed under any of the following conditions: + * -- The function that initially declared the variable "local" returns + * -- The thread in which the closure was created is garbage collected + * + * To make things wackier, just because a thread is reachable by Lua doesn't + * mean it's in our root set. We need to be able to treat an open upvalue + * from an unreachable thread as a closed upvalue. + * + * The solution: + * (a) For the purposes of serializing, don't indicate whether an upvalue is + * closed or not. + * (b) When unserializing, pretend that all upvalues are closed. + * (c) When serializing, persist all open upvalues referenced by a thread + * that is persisted, and tag each one with the corresponding stack position + * (d) When unserializing, "reopen" each of these upvalues as the thread is + * unserialized + */ +static void serializeUpValue(SerializationInfo *info) { + // >>>>> permTbl indexTbl ...... upval + assert(ttype(getObject(info->luaState, -1)) == LUA_TUPVAL); + UpVal *upValue = gco2uv(getObject(info->luaState, -1)->value.gc); + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + // We can't permit the upValue to linger around on the stack, as Lua + // will bail if its GC finds it. + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... + + pushObject(info->luaState, upValue->v); + // >>>>> permTbl indexTbl ...... obj + + serialize(info); + // >>>>> permTbl indexTbl ...... obj +} + +static void serializeUserData(SerializationInfo *info) { + // >>>>> permTbl rootObj ...... udata + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + // Test if the object needs special serialization + if (serializeSpecialObject(info, 0)) { + return; + } + + // Use literal persistence + + // Hard cast to a uint32 length + // This could lead to truncation, but if we have a 4gb block of data, we have bigger problems + uint32 length = static_cast(uvalue(getObject(info->luaState, -1))->len); + info->writeStream->writeUint32LE(length); + + info->writeStream->write(lua_touserdata(info->luaState, -1), length); + + // Serialize the metatable (if any) + if (!lua_getmetatable(info->luaState, -1)) { + lua_pushnil(info->luaState); + } + + // >>>>> permTbl rootObj ...... udata metaTbl/nil + serialize(info); + + lua_pop(info->luaState, 1); + /* perms reftbl ... udata */ +} + + +} // End of namespace Lua diff --git a/engines/sword25/util/lua_persistence.h b/engines/sword25/util/lua_persistence.h new file mode 100644 index 0000000000..cf7d7e03ca --- /dev/null +++ b/engines/sword25/util/lua_persistence.h @@ -0,0 +1,44 @@ +/* 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 LUA_SERIALIZATION_H +#define LUA_SERIALIZATION_H + +#include "sword25/util/lua/lua.h" + + +namespace Common { +class WriteStream; +class ReadStream; +} + + +namespace Lua { + +#define PERMANENT_TYPE 101 + +void persistLua(lua_State *luaState, Common::WriteStream *writeStream); +void unpersistLua(lua_State *luaState, Common::ReadStream *readStream); + +} // End of namespace Lua + +#endif diff --git a/engines/sword25/util/lua_persistence_util.cpp b/engines/sword25/util/lua_persistence_util.cpp new file mode 100644 index 0000000000..8365f5d483 --- /dev/null +++ b/engines/sword25/util/lua_persistence_util.cpp @@ -0,0 +1,346 @@ +/* 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 distri8buted 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 "sword25/util/lua_persistence_util.h" + +#include "common/scummsys.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" +#include "lua/lgc.h" +#include "lua/lopcodes.h" + + +namespace Lua { + +void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) { + global_State *globalState = G(luaState); + + block = (*globalState->frealloc)(globalState->ud, block, osize, nsize); + globalState->totalbytes = (globalState->totalbytes - osize) + nsize; + + return block; +} + +void pushObject(lua_State *luaState, TValue *obj) { + setobj2s(luaState, luaState->top, obj); + + api_check(luaState, luaState->top < luaState->ci->top); + luaState->top++; +} + +void pushProto(lua_State *luaState, Proto *proto) { + TValue obj; + setptvalue(luaState, &obj, proto); + + pushObject(luaState, &obj); +} + +void pushUpValue(lua_State *luaState, UpVal *upval) { + TValue obj; + + obj.value.gc = cast(GCObject *, upval); + obj.tt = LUA_TUPVAL; + checkliveness(G(L), obj); + + pushObject(luaState, &obj); +} + +void pushString(lua_State *luaState, TString *str) { + TValue o; + setsvalue(luaState, &o, str); + + pushObject(luaState, &o); +} + +/* A simple reimplementation of the unfortunately static function luaA_index. + * Does not support the global table, registry, or upvalues. */ +StkId getObject(lua_State *luaState, int stackpos) { + if (stackpos > 0) { + lua_assert(luaState->base + stackpos - 1 < luaState->top); + return luaState->base + stackpos - 1; + } else { + lua_assert(L->top - stackpos >= L->base); + return luaState->top + stackpos; + } +} + +void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { + global_State *globalState = G(luaState); + + obj->gch.next = globalState->rootgc; + globalState->rootgc = obj; + obj->gch.marked = luaC_white(globalState); + obj->gch.tt = type; +} + +Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) { + Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements)); + lua_linkObjToGC(luaState, obj2gco(c), LUA_TFUNCTION); + + c->l.isC = 0; + c->l.env = elementTable; + c->l.nupvalues = cast_byte(numElements); + + while (numElements--) { + c->l.upvals[numElements] = NULL; + } + + return c; +} + +void pushClosure(lua_State *luaState, Closure *closure) { + TValue obj; + setclvalue(luaState, &obj, closure); + pushObject(luaState, &obj); +} + +Proto *createProto(lua_State *luaState) { + Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO); + + newProto->k = NULL; + newProto->sizek = 0; + newProto->p = NULL; + newProto->sizep = 0; + newProto->code = NULL; + newProto->sizecode = 0; + newProto->sizelineinfo = 0; + newProto->sizeupvalues = 0; + newProto->nups = 0; + newProto->upvalues = NULL; + newProto->numparams = 0; + newProto->is_vararg = 0; + newProto->maxstacksize = 0; + newProto->lineinfo = NULL; + newProto->sizelocvars = 0; + newProto->locvars = NULL; + newProto->linedefined = 0; + newProto->lastlinedefined = 0; + newProto->source = NULL; + + return newProto; +} + +TString *createString(lua_State *luaState, const char *str, size_t len) { + TString *res; + lua_pushlstring(luaState, str, len); + + res = rawtsvalue(luaState->top - 1); + lua_pop(luaState, 1); + + return res; +} + +Proto *makeFakeProto(lua_State *L, lu_byte nups) { + Proto *p = createProto(L); + + p->sizelineinfo = 1; + p->lineinfo = lua_newVector(L, 1, int); + p->lineinfo[0] = 1; + p->sizecode = 1; + p->code = lua_newVector(L, 1, Instruction); + p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); + p->source = createString(L, "", 0); + p->maxstacksize = 2; + p->nups = nups; + p->sizek = 0; + p->sizep = 0; + + return p; +} + +UpVal *createUpValue(lua_State *luaState, int stackpos) { + UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal)); + lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL); + upValue->tt = LUA_TUPVAL; + upValue->v = &upValue->u.value; + upValue->u.l.prev = NULL; + upValue->u.l.next = NULL; + + const TValue *o2 = (TValue *)getObject(luaState, stackpos); + upValue->v->value = o2->value; + upValue->v->tt = o2->tt; + checkliveness(G(L), upValue->v); + + return upValue; +} + +void unboxUpValue(lua_State *luaState) { + // >>>>> ...... func + LClosure *lcl; + UpVal *uv; + + lcl = (LClosure *)clvalue(getObject(luaState, -1)); + uv = lcl->upvals[0]; + + lua_pop(luaState, 1); + // >>>>> ...... + + pushUpValue(luaState, uv); + // >>>>> ...... upValue +} + +size_t appendStackToStack_reverse(lua_State *from, lua_State *to) { + for (StkId id = from->top - 1; id >= from->stack; --id) { + setobj2s(to, to->top, id); + to->top++; + } + + return from->top - from->stack; +} + +void correctStack(lua_State *L, TValue *oldstack) { + CallInfo *ci; + GCObject *up; + L->top = (L->top - oldstack) + L->stack; + for (up = L->openupval; up != NULL; up = up->gch.next) + gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; + for (ci = L->base_ci; ci <= L->ci; ci++) { + ci->top = (ci->top - oldstack) + L->stack; + ci->base = (ci->base - oldstack) + L->stack; + ci->func = (ci->func - oldstack) + L->stack; + } + L->base = (L->base - oldstack) + L->stack; +} + +void lua_reallocstack(lua_State *L, int newsize) { + TValue *oldstack = L->stack; + int realsize = newsize + 1 + EXTRA_STACK; + + lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + L->stacksize = realsize; + L->stack_last = L->stack + newsize; + correctStack(L, oldstack); +} + +void lua_growstack(lua_State *L, int n) { + // Double size is enough? + if (n <= L->stacksize) { + lua_reallocstack(L, 2 * L->stacksize); + } else { + lua_reallocstack(L, L->stacksize + n); + } +} + +void lua_reallocCallInfo(lua_State *lauState, int newsize) { + CallInfo *oldci = lauState->base_ci; + lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo); + + lauState->size_ci = newsize; + lauState->ci = (lauState->ci - oldci) + lauState->base_ci; + lauState->end_ci = lauState->base_ci + lauState->size_ci - 1; +} + +void GCUnlink(lua_State *luaState, GCObject *gco) { + GCObject *prevslot; + if (G(luaState)->rootgc == gco) { + G(luaState)->rootgc = G(luaState)->rootgc->gch.next; + return; + } + + prevslot = G(luaState)->rootgc; + while (prevslot->gch.next != gco) { + prevslot = prevslot->gch.next; + } + + prevslot->gch.next = prevslot->gch.next->gch.next; +} + +TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) { + lua_pushlstring(luaState, str, len); + TString *luaStr = &(luaState->top - 1)->value.gc->ts; + + lua_pop(luaState, 1); + + return luaStr; +} + +void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) { + global_State *g = G(luaState); + o->gch.next = g->rootgc; + g->rootgc = o; + o->gch.marked = luaC_white(g); + o->gch.tt = tt; +} + +Proto *lua_newproto(lua_State *luaState) { + Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto)); + lua_link(luaState, obj2gco(f), LUA_TPROTO); + f->k = NULL; + f->sizek = 0; + f->p = NULL; + f->sizep = 0; + f->code = NULL; + f->sizecode = 0; + f->sizelineinfo = 0; + f->sizeupvalues = 0; + f->nups = 0; + f->upvalues = NULL; + f->numparams = 0; + f->is_vararg = 0; + f->maxstacksize = 0; + f->lineinfo = NULL; + f->sizelocvars = 0; + f->locvars = NULL; + f->linedefined = 0; + f->lastlinedefined = 0; + f->source = NULL; + return f; +} + +UpVal *makeUpValue(lua_State *luaState, int stackPos) { + UpVal *uv = lua_new(luaState, UpVal); + lua_link(luaState, (GCObject *)uv, LUA_TUPVAL); + uv->tt = LUA_TUPVAL; + uv->v = &uv->u.value; + uv->u.l.prev = NULL; + uv->u.l.next = NULL; + + setobj(luaState, uv->v, getObject(luaState, stackPos)); + + return uv; +} + +void boxUpValue_start(lua_State *luaState) { + LClosure *closure; + closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt)); + pushClosure(luaState, (Closure *)closure); + // >>>>> ...... func + closure->p = makeFakeProto(luaState, 1); + + // Temporarily initialize the upvalue to nil + lua_pushnil(luaState); + closure->upvals[0] = makeUpValue(luaState, -1); + lua_pop(luaState, 1); +} + +void boxUpValue_finish(lua_State *luaState) { + // >>>>> ...... func obj + LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2)); + + lcl->upvals[0]->u.value = *getObject(luaState, -1); + lua_pop(luaState, 1); + // >>>>> ...... func +} + +} // End of namespace Lua diff --git a/engines/sword25/util/lua_persistence_util.h b/engines/sword25/util/lua_persistence_util.h new file mode 100644 index 0000000000..345996f606 --- /dev/null +++ b/engines/sword25/util/lua_persistence_util.h @@ -0,0 +1,98 @@ +/* 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 distri8buted 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 LUA_SERIALIZATION_UTIL_H +#define LUA_SERIALIZATION_UTIL_H + + +struct lua_State; + +#include "lua/lobject.h" + +typedef TValue *StkId; + +namespace Lua { + +#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize) +#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e)) +#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T)))) +#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T))) +#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T)) + +void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize); + +void pushObject(lua_State *luaState, TValue *obj); +void pushProto(lua_State *luaState, Proto *proto); +void pushUpValue(lua_State *luaState, UpVal *upval); +void pushString(lua_State *luaState, TString *str); + +StkId getObject(lua_State *luaState, int stackpos); + +void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type); + +#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) + +Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable); +void pushClosure(lua_State *luaState, Closure *closure); + +Proto *createProto(lua_State *luaState); +Proto *makeFakeProto(lua_State *L, lu_byte nups); + +TString *createString(lua_State *luaState, const char *str, size_t len); + +UpVal *createUpValue(lua_State *luaState, int stackpos); +void unboxUpValue(lua_State *luaState); + +/* Appends one stack to another stack, but the stack is reversed in the process */ +size_t appendStackToStack_reverse(lua_State *from, lua_State *to); +void correctStack(lua_State *L, TValue *oldstack); +void lua_reallocstack(lua_State *L, int newsize); +void lua_growstack(lua_State *L, int n); + +void lua_reallocCallInfo(lua_State *lauState, int newsize); + +/* Does basically the opposite of luaC_link(). + * Right now this function is rather inefficient; it requires traversing the + * entire root GC set in order to find one object. If the GC list were doubly + * linked this would be much easier, but there's no reason for Lua to have + * that. */ +void GCUnlink(lua_State *luaState, GCObject *gco); + +TString *lua_newlstr(lua_State *luaState, const char *str, size_t len); +void lua_link(lua_State *luaState, GCObject *o, lu_byte tt); +Proto *lua_newproto(lua_State *luaState) ; + +UpVal *makeUpValue(lua_State *luaState, int stackPos); +/** + * The GC is not fond of finding upvalues in tables. We get around this + * during persistence using a weakly keyed table, so that the GC doesn't + * bother to mark them. This won't work in unpersisting, however, since + * if we make the values weak they'll be collected (since nothing else + * references them). Our solution, during unpersisting, is to represent + * upvalues as dummy functions, each with one upvalue. + */ +void boxUpValue_start(lua_State *luaState); +void boxUpValue_finish(lua_State *luaState); + +} // End of namespace Lua + +#endif diff --git a/engines/sword25/util/lua_serialization.h b/engines/sword25/util/lua_serialization.h deleted file mode 100644 index 549ea7968d..0000000000 --- a/engines/sword25/util/lua_serialization.h +++ /dev/null @@ -1,44 +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 LUA_SERIALIZATION_H -#define LUA_SERIALIZATION_H - -#include "sword25/util/lua/lua.h" - - -namespace Common { -class WriteStream; -class ReadStream; -} - - -namespace Lua { - -#define PERMANENT_TYPE 101 - -void serializeLua(lua_State *luaState, Common::WriteStream *writeStream); -void unserializeLua(lua_State *luaState, Common::ReadStream *readStream); - -} // End of namespace Lua - -#endif diff --git a/engines/sword25/util/lua_serialization_util.cpp b/engines/sword25/util/lua_serialization_util.cpp deleted file mode 100644 index fc3f73eca6..0000000000 --- a/engines/sword25/util/lua_serialization_util.cpp +++ /dev/null @@ -1,346 +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 distri8buted 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 "sword25/util/lua_serialization_util.h" - -#include "common/scummsys.h" - -#include "lua/lobject.h" -#include "lua/lstate.h" -#include "lua/lgc.h" -#include "lua/lopcodes.h" - - -namespace Lua { - -void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize) { - global_State *globalState = G(luaState); - - block = (*globalState->frealloc)(globalState->ud, block, osize, nsize); - globalState->totalbytes = (globalState->totalbytes - osize) + nsize; - - return block; -} - -void pushObject(lua_State *luaState, TValue *obj) { - setobj2s(luaState, luaState->top, obj); - - api_check(luaState, luaState->top < luaState->ci->top); - luaState->top++; -} - -void pushProto(lua_State *luaState, Proto *proto) { - TValue obj; - setptvalue(luaState, &obj, proto); - - pushObject(luaState, &obj); -} - -void pushUpValue(lua_State *luaState, UpVal *upval) { - TValue obj; - - obj.value.gc = cast(GCObject *, upval); - obj.tt = LUA_TUPVAL; - checkliveness(G(L), obj); - - pushObject(luaState, &obj); -} - -void pushString(lua_State *luaState, TString *str) { - TValue o; - setsvalue(luaState, &o, str); - - pushObject(luaState, &o); -} - -/* A simple reimplementation of the unfortunately static function luaA_index. - * Does not support the global table, registry, or upvalues. */ -StkId getObject(lua_State *luaState, int stackpos) { - if (stackpos > 0) { - lua_assert(luaState->base + stackpos - 1 < luaState->top); - return luaState->base + stackpos - 1; - } else { - lua_assert(L->top - stackpos >= L->base); - return luaState->top + stackpos; - } -} - -void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type) { - global_State *globalState = G(luaState); - - obj->gch.next = globalState->rootgc; - globalState->rootgc = obj; - obj->gch.marked = luaC_white(globalState); - obj->gch.tt = type; -} - -Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable) { - Closure *c = (Closure *)lua_malloc(luaState, sizeLclosure(numElements)); - lua_linkObjToGC(luaState, obj2gco(c), LUA_TFUNCTION); - - c->l.isC = 0; - c->l.env = elementTable; - c->l.nupvalues = cast_byte(numElements); - - while (numElements--) { - c->l.upvals[numElements] = NULL; - } - - return c; -} - -void pushClosure(lua_State *luaState, Closure *closure) { - TValue obj; - setclvalue(luaState, &obj, closure); - pushObject(luaState, &obj); -} - -Proto *createProto(lua_State *luaState) { - Proto *newProto = (Proto *)lua_malloc(luaState, sizeof(Proto)); - lua_linkObjToGC(luaState, obj2gco(newProto), LUA_TPROTO); - - newProto->k = NULL; - newProto->sizek = 0; - newProto->p = NULL; - newProto->sizep = 0; - newProto->code = NULL; - newProto->sizecode = 0; - newProto->sizelineinfo = 0; - newProto->sizeupvalues = 0; - newProto->nups = 0; - newProto->upvalues = NULL; - newProto->numparams = 0; - newProto->is_vararg = 0; - newProto->maxstacksize = 0; - newProto->lineinfo = NULL; - newProto->sizelocvars = 0; - newProto->locvars = NULL; - newProto->linedefined = 0; - newProto->lastlinedefined = 0; - newProto->source = NULL; - - return newProto; -} - -TString *createString(lua_State *luaState, const char *str, size_t len) { - TString *res; - lua_pushlstring(luaState, str, len); - - res = rawtsvalue(luaState->top - 1); - lua_pop(luaState, 1); - - return res; -} - -Proto *makeFakeProto(lua_State *L, lu_byte nups) { - Proto *p = createProto(L); - - p->sizelineinfo = 1; - p->lineinfo = lua_newVector(L, 1, int); - p->lineinfo[0] = 1; - p->sizecode = 1; - p->code = lua_newVector(L, 1, Instruction); - p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); - p->source = createString(L, "", 0); - p->maxstacksize = 2; - p->nups = nups; - p->sizek = 0; - p->sizep = 0; - - return p; -} - -UpVal *createUpValue(lua_State *luaState, int stackpos) { - UpVal *upValue = (UpVal *)lua_malloc(luaState, sizeof(UpVal)); - lua_linkObjToGC(luaState, (GCObject *)upValue, LUA_TUPVAL); - upValue->tt = LUA_TUPVAL; - upValue->v = &upValue->u.value; - upValue->u.l.prev = NULL; - upValue->u.l.next = NULL; - - const TValue *o2 = (TValue *)getObject(luaState, stackpos); - upValue->v->value = o2->value; - upValue->v->tt = o2->tt; - checkliveness(G(L), upValue->v); - - return upValue; -} - -void unboxUpValue(lua_State *luaState) { - // >>>>> ...... func - LClosure *lcl; - UpVal *uv; - - lcl = (LClosure *)clvalue(getObject(luaState, -1)); - uv = lcl->upvals[0]; - - lua_pop(luaState, 1); - // >>>>> ...... - - pushUpValue(luaState, uv); - // >>>>> ...... upValue -} - -size_t appendStackToStack_reverse(lua_State *from, lua_State *to) { - for (StkId id = from->top - 1; id >= from->stack; --id) { - setobj2s(to, to->top, id); - to->top++; - } - - return from->top - from->stack; -} - -void correctStack(lua_State *L, TValue *oldstack) { - CallInfo *ci; - GCObject *up; - L->top = (L->top - oldstack) + L->stack; - for (up = L->openupval; up != NULL; up = up->gch.next) - gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; - for (ci = L->base_ci; ci <= L->ci; ci++) { - ci->top = (ci->top - oldstack) + L->stack; - ci->base = (ci->base - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; - } - L->base = (L->base - oldstack) + L->stack; -} - -void lua_reallocstack(lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int realsize = newsize + 1 + EXTRA_STACK; - - lua_reallocvector(L, L->stack, L->stacksize, realsize, TValue); - L->stacksize = realsize; - L->stack_last = L->stack + newsize; - correctStack(L, oldstack); -} - -void lua_growstack(lua_State *L, int n) { - // Double size is enough? - if (n <= L->stacksize) { - lua_reallocstack(L, 2 * L->stacksize); - } else { - lua_reallocstack(L, L->stacksize + n); - } -} - -void lua_reallocCallInfo(lua_State *lauState, int newsize) { - CallInfo *oldci = lauState->base_ci; - lua_reallocvector(lauState, lauState->base_ci, lauState->size_ci, newsize, CallInfo); - - lauState->size_ci = newsize; - lauState->ci = (lauState->ci - oldci) + lauState->base_ci; - lauState->end_ci = lauState->base_ci + lauState->size_ci - 1; -} - -void GCUnlink(lua_State *luaState, GCObject *gco) { - GCObject *prevslot; - if (G(luaState)->rootgc == gco) { - G(luaState)->rootgc = G(luaState)->rootgc->gch.next; - return; - } - - prevslot = G(luaState)->rootgc; - while (prevslot->gch.next != gco) { - prevslot = prevslot->gch.next; - } - - prevslot->gch.next = prevslot->gch.next->gch.next; -} - -TString *lua_newlstr(lua_State *luaState, const char *str, size_t len) { - lua_pushlstring(luaState, str, len); - TString *luaStr = &(luaState->top - 1)->value.gc->ts; - - lua_pop(luaState, 1); - - return luaStr; -} - -void lua_link(lua_State *luaState, GCObject *o, lu_byte tt) { - global_State *g = G(luaState); - o->gch.next = g->rootgc; - g->rootgc = o; - o->gch.marked = luaC_white(g); - o->gch.tt = tt; -} - -Proto *lua_newproto(lua_State *luaState) { - Proto *f = (Proto *)lua_malloc(luaState, sizeof(Proto)); - lua_link(luaState, obj2gco(f), LUA_TPROTO); - f->k = NULL; - f->sizek = 0; - f->p = NULL; - f->sizep = 0; - f->code = NULL; - f->sizecode = 0; - f->sizelineinfo = 0; - f->sizeupvalues = 0; - f->nups = 0; - f->upvalues = NULL; - f->numparams = 0; - f->is_vararg = 0; - f->maxstacksize = 0; - f->lineinfo = NULL; - f->sizelocvars = 0; - f->locvars = NULL; - f->linedefined = 0; - f->lastlinedefined = 0; - f->source = NULL; - return f; -} - -UpVal *makeUpValue(lua_State *luaState, int stackPos) { - UpVal *uv = lua_new(luaState, UpVal); - lua_link(luaState, (GCObject *)uv, LUA_TUPVAL); - uv->tt = LUA_TUPVAL; - uv->v = &uv->u.value; - uv->u.l.prev = NULL; - uv->u.l.next = NULL; - - setobj(luaState, uv->v, getObject(luaState, stackPos)); - - return uv; -} - -void boxUpValue_start(lua_State *luaState) { - LClosure *closure; - closure = (LClosure *)lua_newLclosure(luaState, 1, hvalue(&luaState->l_gt)); - pushClosure(luaState, (Closure *)closure); - // >>>>> ...... func - closure->p = makeFakeProto(luaState, 1); - - // Temporarily initialize the upvalue to nil - lua_pushnil(luaState); - closure->upvals[0] = makeUpValue(luaState, -1); - lua_pop(luaState, 1); -} - -void boxUpValue_finish(lua_State *luaState) { - // >>>>> ...... func obj - LClosure *lcl = (LClosure *)clvalue(getObject(luaState, -2)); - - lcl->upvals[0]->u.value = *getObject(luaState, -1); - lua_pop(luaState, 1); - // >>>>> ...... func -} - -} // End of namespace Lua diff --git a/engines/sword25/util/lua_serialization_util.h b/engines/sword25/util/lua_serialization_util.h deleted file mode 100644 index 345996f606..0000000000 --- a/engines/sword25/util/lua_serialization_util.h +++ /dev/null @@ -1,98 +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 distri8buted 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 LUA_SERIALIZATION_UTIL_H -#define LUA_SERIALIZATION_UTIL_H - - -struct lua_State; - -#include "lua/lobject.h" - -typedef TValue *StkId; - -namespace Lua { - -#define lua_malloc(luaState, nsize) lua_realloc(luaState, nullptr, 0, nsize) -#define lua_reallocv(luaState, block, on, n, e) lua_realloc(luaState, block, (on) * (e), (n) * (e)) -#define lua_reallocvector(luaState, vec, oldn, n, T) ((vec) = (T *)(lua_reallocv(luaState, vec, oldn, n, sizeof(T)))) -#define lua_newVector(luaState, num, T) ((T *)lua_reallocv(luaState, nullptr, 0, num, sizeof(T))) -#define lua_new(luaState,T) (T *)lua_malloc(luaState, sizeof(T)) - -void *lua_realloc(lua_State *luaState, void *block, size_t osize, size_t nsize); - -void pushObject(lua_State *luaState, TValue *obj); -void pushProto(lua_State *luaState, Proto *proto); -void pushUpValue(lua_State *luaState, UpVal *upval); -void pushString(lua_State *luaState, TString *str); - -StkId getObject(lua_State *luaState, int stackpos); - -void lua_linkObjToGC(lua_State *luaState, GCObject *obj, lu_byte type); - -#define sizeLclosure(n) ((sizeof(LClosure)) + sizeof(TValue *) * ((n) - 1)) - -Closure *lua_newLclosure(lua_State *luaState, int numElements, Table *elementTable); -void pushClosure(lua_State *luaState, Closure *closure); - -Proto *createProto(lua_State *luaState); -Proto *makeFakeProto(lua_State *L, lu_byte nups); - -TString *createString(lua_State *luaState, const char *str, size_t len); - -UpVal *createUpValue(lua_State *luaState, int stackpos); -void unboxUpValue(lua_State *luaState); - -/* Appends one stack to another stack, but the stack is reversed in the process */ -size_t appendStackToStack_reverse(lua_State *from, lua_State *to); -void correctStack(lua_State *L, TValue *oldstack); -void lua_reallocstack(lua_State *L, int newsize); -void lua_growstack(lua_State *L, int n); - -void lua_reallocCallInfo(lua_State *lauState, int newsize); - -/* Does basically the opposite of luaC_link(). - * Right now this function is rather inefficient; it requires traversing the - * entire root GC set in order to find one object. If the GC list were doubly - * linked this would be much easier, but there's no reason for Lua to have - * that. */ -void GCUnlink(lua_State *luaState, GCObject *gco); - -TString *lua_newlstr(lua_State *luaState, const char *str, size_t len); -void lua_link(lua_State *luaState, GCObject *o, lu_byte tt); -Proto *lua_newproto(lua_State *luaState) ; - -UpVal *makeUpValue(lua_State *luaState, int stackPos); -/** - * The GC is not fond of finding upvalues in tables. We get around this - * during persistence using a weakly keyed table, so that the GC doesn't - * bother to mark them. This won't work in unpersisting, however, since - * if we make the values weak they'll be collected (since nothing else - * references them). Our solution, during unpersisting, is to represent - * upvalues as dummy functions, each with one upvalue. - */ -void boxUpValue_start(lua_State *luaState); -void boxUpValue_finish(lua_State *luaState); - -} // End of namespace Lua - -#endif diff --git a/engines/sword25/util/lua_serializer.cpp b/engines/sword25/util/lua_serializer.cpp deleted file mode 100644 index 55b6257324..0000000000 --- a/engines/sword25/util/lua_serializer.cpp +++ /dev/null @@ -1,787 +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 "sword25/util/lua_serialization.h" - -#include "sword25/util/double_serializer.h" -#include "sword25/util/lua_serialization_util.h" - -#include "common/stream.h" - -#include "lua/lobject.h" -#include "lua/lstate.h" -#include "lua/lgc.h" - - -namespace Lua { - -#define PERMANENT_TYPE 101 - -struct SerializationInfo { - lua_State *luaState; - Common::WriteStream *writeStream; - uint counter; -}; - -static void serialize(SerializationInfo *info); - -static void serializeBoolean(SerializationInfo *info); -static void serializeNumber(SerializationInfo *info); -static void serializeString(SerializationInfo *info); -static void serializeTable(SerializationInfo *info); -static void serializeFunction(SerializationInfo *info); -static void serializeThread(SerializationInfo *info); -static void serializeProto(SerializationInfo *info); -static void serializeUpValue(SerializationInfo *info); -static void serializeUserData(SerializationInfo *info); - - -void serializeLua(lua_State *luaState, Common::WriteStream *writeStream) { - SerializationInfo info; - info.luaState = luaState; - info.writeStream = writeStream; - info.counter = 0u; - - // The process starts with the lua stack as follows: - // >>>>> permTbl rootObj - // That's the table of permanents and the root object to be serialized - - // Make sure there is enough room on the stack - lua_checkstack(luaState, 4); - assert(lua_gettop(luaState) == 2); - // And that the root isn't nil - assert(!lua_isnil(luaState, 2)); - - // Create a table to hold indexes of everything that's serialized - // This allows us to only serialize an object once - // Every other time, just reference the index - lua_newtable(luaState); - // >>>>> permTbl rootObj indexTbl - - // Now we're going to make the table weakly keyed. This prevents the - // GC from visiting it and trying to mark things it doesn't want to - // mark in tables, e.g. upvalues. All objects in the table are - // a priori reachable, so it doesn't matter that we do this. - - // Create the metatable - lua_newtable(luaState); - // >>>>> permTbl rootObj indexTbl metaTbl - - lua_pushstring(luaState, "__mode"); - // >>>>> permTbl rootObj indexTbl metaTbl "__mode" - - lua_pushstring(luaState, "k"); - // >>>>> permTbl rootObj indexTbl metaTbl "__mode" "k" - - lua_settable(luaState, 4); - // >>>>> permTbl rootObj indexTbl metaTbl - - lua_setmetatable(luaState, 3); - // >>>>> permTbl rootObj indexTbl - - // Swap the indexTable and the rootObj - lua_insert(luaState, 2); - // >>>>> permTbl indexTbl rootObj - - // Serialize the root recursively - serialize(&info); - - // Return the stack back to the original state - lua_remove(luaState, 2); - // >>>>> permTbl rootObj -} - -static void serialize(SerializationInfo *info) { - // The stack can potentially have many things on it - // The object we want to serialize is the item on the top of the stack - // >>>>> permTbl indexTbl rootObj ...... obj - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - // If the object has already been written, don't write it again - // Instead write the index of the object from the indexTbl - - // Check the indexTbl - lua_pushvalue(info->luaState, -1); - // >>>>> permTbl indexTbl rootObj ...... obj obj - - lua_rawget(info->luaState, 2); - // >>>>> permTbl indexTbl rootObj ...... obj ?index? - - // If the index isn't nil, the object has already been written - if (!lua_isnil(info->luaState, -1)) { - // Write out a flag that indicates that it's an index - info->writeStream->writeByte(0); - - // Retrieve the index from the stack - uint *index = (uint *)lua_touserdata(info->luaState, -1); - - // Write out the index - info->writeStream->writeUint32LE(*index); - - // Pop the index off the stack - lua_pop(info->luaState, 1); - - return; - } - - // Pop the nil off the stack - lua_pop(info->luaState, 1); - - // Write out a flag that indicates that this is a real object - info->writeStream->writeByte(1); - - // If the object itself is nil, then write out a zero as a placeholder - if (lua_isnil(info->luaState, -1)) { - info->writeStream->writeByte(0); - - return; - } - - // Add the object to the indexTbl - - lua_pushvalue(info->luaState, -1); - // >>>>> permTbl indexTbl rootObj ...... obj obj - - uint *ref = (uint *)lua_newuserdata(info->luaState, sizeof(uint)); - *ref = ++(info->counter); - // >>>>> permTbl indexTbl rootObj ...... obj obj index - - lua_rawset(info->luaState, 2); - // >>>>> permTbl indexTbl rootObj ...... obj - - - // Write out the index - info->writeStream->writeUint32LE(info->counter); - - - // Objects that are in the permanents table are serialized in a special way - - lua_pushvalue(info->luaState, -1); - // >>>>> permTbl indexTbl rootObj ...... obj obj - - lua_gettable(info->luaState, 1); - // >>>>> permTbl indexTbl rootObj ...... obj obj ?permKey? - - if (!lua_isnil(info->luaState, -1)) { - // Write out the type - info->writeStream->writeSint32LE(PERMANENT_TYPE); - - // Serialize the key - serialize(info); - - // Pop the key off the stack - lua_pop(info->luaState, 1); - - return; - } - - // Pop the nil off the stack - lua_pop(info->luaState, 1); - - // Query the type of the object - int objType = lua_type(info->luaState, -1); - - // Write it out - info->writeStream->writeSint32LE(objType); - - // Serialize the object by its type - - switch (objType) { - case LUA_TBOOLEAN: - serializeBoolean(info); - break; - case LUA_TLIGHTUSERDATA: - // You can't serialize a pointer - // It would be meaningless on the next run - assert(0); - break; - case LUA_TNUMBER: - serializeNumber(info); - break; - case LUA_TSTRING: - serializeString(info); - break; - case LUA_TTABLE: - serializeTable(info); - break; - case LUA_TFUNCTION: - serializeFunction(info); - break; - case LUA_TTHREAD: - serializeThread(info); - break; - case LUA_TPROTO: - serializeProto(info); - break; - case LUA_TUPVAL: - serializeUpValue(info); - break; - case LUA_TUSERDATA: - serializeUserData(info); - break; - default: - assert(0); - } -} - -static void serializeBoolean(SerializationInfo *info) { - int value = lua_toboolean(info->luaState, -1); - - info->writeStream->writeSint32LE(value); -} - -static void serializeNumber(SerializationInfo *info) { - lua_Number value = lua_tonumber(info->luaState, -1); - - #if 1 - Util::SerializedDouble serializedValue(Util::encodeDouble(value)); - - info->writeStream->writeUint32LE(serializedValue.significandOne); - info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); - info->writeStream->writeSint16LE(serializedValue.exponent); - #else - // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. - // Also, I don't know if we can assume all compilers use IEEE double - // Therefore, I have chosen to store the double as a string. - Common::String buffer = Common::String::format("%f", value); - - info->writeStream->write(buffer.c_str(), buffer.size()); - #endif - -} - -static void serializeString(SerializationInfo *info) { - // Hard cast to a uint32 to force size_t to an explicit size - // *Theoretically* this could truncate, but if we have a 4gb string, we have bigger problems - uint32 length = static_cast(lua_strlen(info->luaState, -1)); - info->writeStream->writeUint32LE(length); - - const char *str = lua_tostring(info->luaState, -1); - info->writeStream->write(str, length); -} - -/* Choose whether to do a regular or special persistence based on an object's - * metatable. "default" is whether the object, if it doesn't have a __persist - * entry, is literally persistable or not. - * Pushes the unpersist closure and returns true if special persistence is - * used. */ -static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 4); - - // Check whether we should persist literally, or via the __persist metafunction - if (!lua_getmetatable(info->luaState, -1)) { - if (defaction) { - // Write out a flag declaring that the object isn't special and should be persisted normally - info->writeStream->writeSint32LE(0); - - return false; - } else { - lua_pushstring(info->luaState, "Type not literally persistable by default"); - lua_error(info->luaState); - - return false; // Not reached - } - } - - // >>>>> permTbl indexTbl ...... obj metaTbl - lua_pushstring(info->luaState, "__persist"); - // >>>>> permTbl indexTbl rootObj ...... obj metaTbl "__persist" - - lua_rawget(info->luaState, -2); - // >>>>> permTbl indexTbl ...... obj metaTbl ?__persist? - - if (lua_isnil(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... obj metaTbl nil - lua_pop(info->luaState, 2); - // >>>>> permTbl indexTbl ...... obj - - if (defaction) { - // Write out a flag declaring that the object isn't special and should be persisted normally - info->writeStream->writeSint32LE(0); - - return false; - } else { - lua_pushstring(info->luaState, "Type not literally persistable by default"); - lua_error(info->luaState); - - return false; // Return false - } - - } else if (lua_isboolean(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... obj metaTbl bool - if (lua_toboolean(info->luaState, -1)) { - // Write out a flag declaring that the object isn't special and should be persisted normally - info->writeStream->writeSint32LE(0); - - // >>>>> permTbl indexTbl ...... obj metaTbl true */ - lua_pop(info->luaState, 2); - // >>>>> permTbl indexTbl ...... obj - - return false; - } else { - lua_pushstring(info->luaState, "Metatable forbade persistence"); - lua_error(info->luaState); - - return false; // Not reached - } - } else if (!lua_isfunction(info->luaState, -1)) { - lua_pushstring(info->luaState, "__persist not nil, boolean, or function"); - lua_error(info->luaState); - } - - // >>>>> permTbl indexTbl ...... obj metaTbl __persist - lua_pushvalue(info->luaState, -3); - // >>>>> permTbl indexTbl ...... obj metaTbl __persist obj - - // >>>>> permTbl indexTbl ...... obj metaTbl ?func? - - if (!lua_isfunction(info->luaState, -1)) { - lua_pushstring(info->luaState, "__persist function did not return a function"); - lua_error(info->luaState); - } - - // >>>>> permTbl indexTbl ...... obj metaTbl func - - // Write out a flag that the function exists - info->writeStream->writeSint32LE(1); - - // Serialize the function - serialize(info); - - lua_pop(info->luaState, 2); - // >>>>> permTbl indexTbl ...... obj - - return true; -} - -static void serializeTable(SerializationInfo *info) { - // >>>>> permTbl indexTbl ...... tbl - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 3); - - // Test if the object needs special serialization - if (serializeSpecialObject(info, 1)) { - return; - } - - // >>>>> permTbl indexTbl ...... tbl - - // First, serialize the metatable (if any) - if (!lua_getmetatable(info->luaState, -1)) { - lua_pushnil(info->luaState); - } - - // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl - - - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... tbl nil - - // Now, persist all k/v pairs - while (lua_next(info->luaState, -2)) { - // >>>>> permTbl indexTbl ...... tbl k v */ - - lua_pushvalue(info->luaState, -2); - // >>>>> permTbl indexTbl ...... tbl k v k */ - - // Serialize the key - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl k v */ - - // Serialize the value - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl k */ - } - - // >>>>> permTbl indexTbl ...... tbl - - // Terminate the list with a nil - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... tbl - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl -} - -static void serializeFunction(SerializationInfo *info) { - // >>>>> permTbl indexTbl ...... func - Closure *cl = clvalue(getObject(info->luaState, -1)); - lua_checkstack(info->luaState, 2); - - if (cl->c.isC) { - /* It's a C function. For now, we aren't going to allow - * persistence of C closures, even if the "C proto" is - * already in the permanents table. */ - lua_pushstring(info->luaState, "Attempt to persist a C function"); - lua_error(info->luaState); - } else { - // It's a Lua closure - - // We don't really _NEED_ the number of upvals, but it'll simplify things a bit - info->writeStream->writeByte(cl->l.p->nups); - - // Serialize the prototype - pushProto(info->luaState, cl->l.p); - // >>>>> permTbl indexTbl ...... func proto */ - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - - // Serialize upvalue values (not the upvalue objects themselves) - for (byte i = 0; i < cl->l.p->nups; i++) { - // >>>>> permTbl indexTbl ...... func - pushUpValue(info->luaState, cl->l.upvals[i]); - // >>>>> permTbl indexTbl ...... func upval - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - } - - // >>>>> permTbl indexTbl ...... func - - // Serialize function environment - lua_getfenv(info->luaState, -1); - // >>>>> permTbl indexTbl ...... func fenv - - if (lua_equal(info->luaState, -1, LUA_GLOBALSINDEX)) { - // Function has the default fenv - - // >>>>> permTbl indexTbl ...... func _G - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... func nil - } - - // >>>>> permTbl indexTbl ...... func fenv/nil - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - } -} - -static void serializeThread(SerializationInfo *info) { - // >>>>> permTbl indexTbl ...... thread - lua_State *threadState = lua_tothread(info->luaState, -1); - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, threadState->top - threadState->stack + 1); - - if (info->luaState == threadState) { - lua_pushstring(info->luaState, "Can't persist currently running thread"); - lua_error(info->luaState); - return; /* not reached */ - } - - // Persist the stack - - // We *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems - uint32 stackSize = static_cast(appendStackToStack_reverse(threadState, info->luaState)); - info->writeStream->writeUint32LE(stackSize); - - // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ - for (; stackSize > 0; --stackSize) { - serialize(info); - - lua_pop(info->luaState, 1); - } - - // >>>>> permTbl indexTbl ...... thread - - // Now, serialize the CallInfo stack - - // Again, we *could* have truncation here, but if we have more than 4 billion items on a stack, we have bigger problems - uint32 numFrames = static_cast((threadState->ci - threadState->base_ci) + 1); - info->writeStream->writeUint32LE(numFrames); - - for (uint32 i = 0; i < numFrames; i++) { - CallInfo *ci = threadState->base_ci + i; - - // Same argument as above about truncation - uint32 stackBase = static_cast(ci->base - threadState->stack); - uint32 stackFunc = static_cast(ci->func - threadState->stack); - uint32 stackTop = static_cast(ci->top - threadState->stack); - - info->writeStream->writeUint32LE(stackBase); - info->writeStream->writeUint32LE(stackFunc); - info->writeStream->writeUint32LE(stackTop); - - info->writeStream->writeSint32LE(ci->nresults); - - uint32 savedpc = (ci != threadState->base_ci) ? static_cast(ci->savedpc - ci_func(ci)->l.p->code) : 0u; - info->writeStream->writeUint32LE(savedpc); - } - - - // Serialize the state's other parameters, with the exception of upval stuff - - assert(threadState->nCcalls <= 1); - info->writeStream->writeByte(threadState->status); - - // Same argument as above about truncation - uint32 stackBase = static_cast(threadState->base - threadState->stack); - uint32 stackFunc = static_cast(threadState->top - threadState->stack); - info->writeStream->writeUint32LE(stackBase); - info->writeStream->writeUint32LE(stackFunc); - - // Same argument as above about truncation - uint32 stackOffset = static_cast(threadState->errfunc); - info->writeStream->writeUint32LE(stackOffset); - - // Finally, record upvalues which need to be reopened - // See the comment above serializeUpVal() for why we do this - - UpVal *upVal; - - // >>>>> permTbl indexTbl ...... thread - for (GCObject *gcObject = threadState->openupval; gcObject != NULL; gcObject = upVal->next) { - upVal = gco2uv(gcObject); - - /* Make sure upvalue is really open */ - assert(upVal->v != &upVal->u.value); - - pushUpValue(info->luaState, upVal); - // >>>>> permTbl indexTbl ...... thread upVal - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... thread - - // Same argument as above about truncation - uint32 stackpos = static_cast(upVal->v - threadState->stack); - info->writeStream->writeUint32LE(stackpos); - } - - // >>>>> permTbl indexTbl ...... thread - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... thread nil - - // Use nil as a terminator - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... thread -} - -static void serializeProto(SerializationInfo *info) { - // >>>>> permTbl indexTbl ...... proto - Proto *proto = gco2p(getObject(info->luaState, -1)->value.gc); - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - // Serialize constant refs */ - info->writeStream->writeSint32LE(proto->sizek); - - for (int i = 0; i < proto->sizek; ++i) { - pushObject(info->luaState, &proto->k[i]); - // >>>>> permTbl indexTbl ...... proto const - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - - // >>>>> permTbl indexTbl ...... proto - - // Serialize inner Proto refs - info->writeStream->writeSint32LE(proto->sizep); - - for (int i = 0; i < proto->sizep; ++i) - { - pushProto(info->luaState, proto->p[i]); - // >>>>> permTbl indexTbl ...... proto subProto */ - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - - // >>>>> permTbl indexTbl ...... proto - - // Serialize the code - info->writeStream->writeSint32LE(proto->sizecode); - - uint32 len = static_cast(sizeof(Instruction) * proto->sizecode); - info->writeStream->write(proto->code, len); - - - // Serialize upvalue names - info->writeStream->writeSint32LE(proto->sizeupvalues); - - for (int i = 0; i < proto->sizeupvalues; ++i) - { - pushString(info->luaState, proto->upvalues[i]); - // >>>>> permTbl indexTbl ...... proto str - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - - - // Serialize local variable infos - info->writeStream->writeSint32LE(proto->sizelocvars); - - for (int i = 0; i < proto->sizelocvars; ++i) { - pushString(info->luaState, proto->locvars[i].varname); - // >>>>> permTbl indexTbl ...... proto str - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - - info->writeStream->writeSint32LE(proto->locvars[i].startpc); - info->writeStream->writeSint32LE(proto->locvars[i].endpc); - } - - - // Serialize source string - pushString(info->luaState, proto->source); - // >>>>> permTbl indexTbl ...... proto sourceStr - - serialize(info); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - - // Serialize line numbers - info->writeStream->writeSint32LE(proto->sizelineinfo); - - if (proto->sizelineinfo) { - uint32 len = static_cast(sizeof(int) * proto->sizelineinfo); - info->writeStream->write(proto->lineinfo, len); - } - - // Serialize linedefined and lastlinedefined - info->writeStream->writeSint32LE(proto->linedefined); - info->writeStream->writeSint32LE(proto->lastlinedefined); - - - // Serialize misc values - info->writeStream->writeByte(proto->nups); - info->writeStream->writeByte(proto->numparams); - info->writeStream->writeByte(proto->is_vararg); - info->writeStream->writeByte(proto->maxstacksize); -} - -/* Upvalues are tricky. Here's why. - * - * A particular upvalue may be either "open", in which case its member v - * points into a thread's stack, or "closed" in which case it points to the - * upvalue itself. An upvalue is closed under any of the following conditions: - * -- The function that initially declared the variable "local" returns - * -- The thread in which the closure was created is garbage collected - * - * To make things wackier, just because a thread is reachable by Lua doesn't - * mean it's in our root set. We need to be able to treat an open upvalue - * from an unreachable thread as a closed upvalue. - * - * The solution: - * (a) For the purposes of serializing, don't indicate whether an upvalue is - * closed or not. - * (b) When unserializing, pretend that all upvalues are closed. - * (c) When serializing, persist all open upvalues referenced by a thread - * that is persisted, and tag each one with the corresponding stack position - * (d) When unserializing, "reopen" each of these upvalues as the thread is - * unserialized - */ -static void serializeUpValue(SerializationInfo *info) { - // >>>>> permTbl indexTbl ...... upval - assert(ttype(getObject(info->luaState, -1)) == LUA_TUPVAL); - UpVal *upValue = gco2uv(getObject(info->luaState, -1)->value.gc); - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - // We can't permit the upValue to linger around on the stack, as Lua - // will bail if its GC finds it. - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... - - pushObject(info->luaState, upValue->v); - // >>>>> permTbl indexTbl ...... obj - - serialize(info); - // >>>>> permTbl indexTbl ...... obj -} - -static void serializeUserData(SerializationInfo *info) { - // >>>>> permTbl rootObj ...... udata - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - // Test if the object needs special serialization - if (serializeSpecialObject(info, 0)) { - return; - } - - // Use literal persistence - - // Hard cast to a uint32 length - // This could lead to truncation, but if we have a 4gb block of data, we have bigger problems - uint32 length = static_cast(uvalue(getObject(info->luaState, -1))->len); - info->writeStream->writeUint32LE(length); - - info->writeStream->write(lua_touserdata(info->luaState, -1), length); - - // Serialize the metatable (if any) - if (!lua_getmetatable(info->luaState, -1)) { - lua_pushnil(info->luaState); - } - - // >>>>> permTbl rootObj ...... udata metaTbl/nil - serialize(info); - - lua_pop(info->luaState, 1); - /* perms reftbl ... udata */ -} - - -} // End of namespace Lua diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp new file mode 100644 index 0000000000..aa924ff7c5 --- /dev/null +++ b/engines/sword25/util/lua_unpersist.cpp @@ -0,0 +1,698 @@ +/* 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 "sword25/util/lua_persistence.h" + +#include "sword25/util/double_serializer.h" +#include "sword25/util/lua_persistence_util.h" + +#include "common/stream.h" + +#include "lua/lobject.h" +#include "lua/lstate.h" +#include "lua/lgc.h" +#include "lua/lopcodes.h" + + +namespace Lua { + +struct UnSerializationInfo { + lua_State *luaState; + Common::ReadStream *readStream; +}; + +static void unserialize(UnSerializationInfo *info); + +static void unserializeBoolean(UnSerializationInfo *info); +static void unserializeNumber(UnSerializationInfo *info); +static void unserializeString(UnSerializationInfo *info); +static void unserializeTable(UnSerializationInfo *info, int index); +static void unserializeFunction(UnSerializationInfo *info, int index); +static void unserializeThread(UnSerializationInfo *info, int index); +static void unserializeProto(UnSerializationInfo *info, int index); +static void unserializeUpValue(UnSerializationInfo *info, int index); +static void unserializeUserData(UnSerializationInfo *info, int index); +static void unserializePermanent(UnSerializationInfo *info, int index); + + +void unpersistLua(lua_State *luaState, Common::ReadStream *readStream) { + UnSerializationInfo info; + info.luaState = luaState; + info.readStream = readStream; + + // The process starts with the lua stack as follows: + // >>>>> permTbl + // That's the table of permanents + + // Make sure there is enough room on the stack + lua_checkstack(luaState, 3); + + // Create a table to hold indexes of everything thats already been read + lua_newtable(luaState); + // >>>>> permTbl indexTbl + + // Prevent garbage collection while we unserialize + lua_gc(luaState, LUA_GCSTOP, 0); + + // Unserialize the root object + unserialize(&info); + // >>>>> permTbl indexTbl rootObj + + // Re-start garbage collection + lua_gc(luaState, LUA_GCRESTART, 0); + + // Remove the indexTbl + lua_replace(luaState, 2); + // >>>>> permTbl rootObj +} + +/* The object is left on the stack. This is primarily used by unserialize, but + * may be used by GCed objects that may incur cycles in order to preregister + * the object. */ +static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... obj + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + lua_pushlightuserdata(info->luaState, (void *)index); + // >>>>> permTbl indexTbl ...... obj index + + lua_pushvalue(info->luaState, -2); + // >>>>> permTbl indexTbl ...... obj index obj + + // Push the k/v pair into the indexTbl + lua_settable(info->luaState, 2); + // >>>>> permTbl indexTbl ...... obj +} + +static void unserialize(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + byte isARealValue = info->readStream->readByte(); + if (isARealValue) { + int index = info->readStream->readSint32LE(); + int type = info->readStream->readSint32LE(); + + switch (type) { + case LUA_TBOOLEAN: + unserializeBoolean(info); + break; + case LUA_TLIGHTUSERDATA: + // You can't serialize a pointer + // It would be meaningless on the next run + assert(0); + break; + case LUA_TNUMBER: + unserializeNumber(info); + break; + case LUA_TSTRING: + unserializeString(info); + break; + case LUA_TTABLE: + unserializeTable(info, index); + break; + case LUA_TFUNCTION: + unserializeFunction(info, index); + break; + case LUA_TTHREAD: + unserializeThread(info, index); + break; + case LUA_TPROTO: + unserializeProto(info, index); + break; + case LUA_TUPVAL: + unserializeUpValue(info, index); + break; + case LUA_TUSERDATA: + unserializeUserData(info, index); + break; + case PERMANENT_TYPE: + unserializePermanent(info, index); + break; + default: + assert(0); + } + + + // >>>>> permTbl indexTbl ...... obj + assert(lua_type(info->luaState, -1) == type || + type == PERMANENT_TYPE || + // Remember, upvalues get a special dispensation, as described in boxUpValue + (lua_type(info->luaState, -1) == LUA_TFUNCTION && type == LUA_TUPVAL)); + + registerObjectInIndexTable(info, index); + // >>>>> permTbl indexTbl ...... obj + } else { + int index = info->readStream->readSint32LE(); + + if (index == 0) { + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... nil + } else { + // Fetch the object from the indexTbl + + lua_pushlightuserdata(info->luaState, (void *)index); + // >>>>> permTbl indexTbl ...... index + + lua_gettable(info->luaState, 2); + // >>>>> permTbl indexTbl ...... ?obj? + + assert(!lua_isnil(info->luaState, -1)); + } + // >>>>> permTbl indexTbl ...... obj/nil + } + + // >>>>> permTbl indexTbl ...... obj/nil +} + +static void unserializeBoolean(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + int value = info->readStream->readSint32LE(); + + lua_pushboolean(info->luaState, value); + // >>>>> permTbl indexTbl ...... bool +} + +static void unserializeNumber(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + // Read the serialized double + Util::SerializedDouble serializedValue; + serializedValue.significandOne = info->readStream->readUint32LE(); + serializedValue.signAndSignificandTwo = info->readStream->readUint32LE(); + serializedValue.exponent = info->readStream->readSint16LE(); + + lua_Number value = Util::decodeDouble(serializedValue); + + lua_pushnumber(info->luaState, value); + // >>>>> permTbl indexTbl ...... num +} + +static void unserializeString(UnSerializationInfo *info) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + uint32 length = info->readStream->readUint32LE(); + char *string = new char[length]; + + info->readStream->read(string, length); + lua_pushlstring(info->luaState, string, length); + + // >>>>> permTbl indexTbl ...... string + + delete[] string; +} + +static void unserializeSpecialTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + unserialize(info); + + // >>>>> permTbl indexTbl ...... spfunc + lua_call(info->luaState, 0, 1); + // >>>>> permTbl indexTbl ...... tbl +} + +static void unserializeLiteralTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 3); + + // Preregister table for handling of cycles + lua_newtable(info->luaState); + + // >>>>> permTbl indexTbl ...... tbl + registerObjectInIndexTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + + // Unserialize metatable + unserialize(info); + // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? + + if (lua_istable(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... tbl metaTbl + lua_setmetatable(info->luaState, -2); + // >>>>> permTbl indexTbl ...... tbl + } else { + // >>>>> permTbl indexTbl ...... tbl nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + } + // >>>>> permTbl indexTbl ...... tbl + + + while (1) { + // >>>>> permTbl indexTbl ...... tbl + unserialize(info); + // >>>>> permTbl indexTbl ...... tbl key/nil + + // The table serialization is nil terminated + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... tbl nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... tbl + + break; + } + + // >>>>> permTbl indexTbl ...... tbl key + unserialize(info); + // >>>>> permTbl indexTbl ...... tbl value + + lua_rawset(info->luaState, -3); + // >>>>> permTbl indexTbl ...... tbl + } +} + +void unserializeTable(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 1); + + int isSpecial = info->readStream->readSint32LE(); + + if (isSpecial) { + unserializeSpecialTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + } else { + unserializeLiteralTable(info, index); + // >>>>> permTbl indexTbl ...... tbl + } +} + +void unserializeFunction(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + byte numUpValues = info->readStream->readByte(); + + LClosure *lclosure = (LClosure *)lua_newLclosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt)); + pushClosure(info->luaState, (Closure *)lclosure); + // >>>>> permTbl indexTbl ...... func + + // Put *some* proto in the closure, before the GC can find it + lclosure->p = makeFakeProto(info->luaState, numUpValues); + + //Also, we need to temporarily fill the upvalues + lua_pushnil(info->luaState); + // >>>>> permTbl indexTbl ...... func nil + + for (byte i = 0; i < numUpValues; ++i) { + lclosure->upvals[i] = createUpValue(info->luaState, -1); + } + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + // I can't see offhand how a function would ever get to be self- + // referential, but just in case let's register it early + registerObjectInIndexTable(info, index); + + // Now that it's safe, we can get the real proto + unserialize(info); + // >>>>> permTbl indexTbl ...... func proto + + lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + + for (byte i = 0; i < numUpValues; ++i) { + // >>>>> permTbl indexTbl ...... func + unserialize(info); + // >>>>> permTbl indexTbl ...... func func2 + + unboxUpValue(info->luaState); + // >>>>> permTbl indexTbl ...... func upValue + lclosure->upvals[i] = gco2uv(getObject(info->luaState, -1)->value.gc); + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // Finally, the fenv + unserialize(info); + + // >>>>> permTbl indexTbl ...... func ?fenv/nil? + if (!lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... func fenv + lua_setfenv(info->luaState, -2); + // >>>>> permTbl indexTbl ...... func + } else { + // >>>>> permTbl indexTbl ...... func nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... func + } + + // >>>>> permTbl indexTbl ...... func +} + +void unserializeThread(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + lua_State *L2; + uint32 stacklimit = 0; + + L2 = lua_newthread(info->luaState); + lua_checkstack(info->luaState, 3); + + // L1: permTbl indexTbl ...... thread + // L2: (empty) + registerObjectInIndexTable(info, index); + + // First, deserialize the object stack + uint32 stackSize = info->readStream->readUint32LE(); + lua_growstack(info->luaState, (int)stackSize); + + // Make sure that the first stack element (a nil, representing + // the imaginary top-level C function) is written to the very, + // very bottom of the stack + L2->top--; + for (uint32 i = 0; i < stackSize; ++i) { + unserialize(info); + // L1: permTbl indexTbl ...... thread obj* + } + + lua_xmove(info->luaState, L2, stackSize); + // L1: permTbl indexTbl ...... thread + // L2: obj* + + // Hereafter, stacks refer to L1 + + + // Now, deserialize the CallInfo stack + + uint32 numFrames = info->readStream->readUint32LE(); + + lua_reallocCallInfo(L2, numFrames * 2); + for (uint32 i = 0; i < numFrames; ++i) { + CallInfo *ci = L2->base_ci + i; + uint32 stackbase = info->readStream->readUint32LE(); + uint32 stackfunc = info->readStream->readUint32LE(); + uint32 stacktop = info->readStream->readUint32LE(); + + ci->nresults = info->readStream->readSint32LE(); + + uint32 savedpc = info->readStream->readUint32LE(); + + if (stacklimit < stacktop) { + stacklimit = stacktop; + } + + ci->base = L2->stack + stackbase; + ci->func = L2->stack + stackfunc; + ci->top = L2->stack + stacktop; + ci->savedpc = (ci != L2->base_ci) ? ci_func(ci)->l.p->code + savedpc : 0; + ci->tailcalls = 0; + + // Update the pointer each time, to keep the GC happy + L2->ci = ci; + } + + // >>>>> permTbl indexTbl ...... thread + // Deserialize the state's other parameters, with the exception of upval stuff + + L2->savedpc = L2->ci->savedpc; + L2->status = info->readStream->readByte(); + uint32 stackbase = info->readStream->readUint32LE(); + uint32 stacktop = info->readStream->readUint32LE(); + + + L2->errfunc = info->readStream->readUint32LE(); + + L2->base = L2->stack + stackbase; + L2->top = L2->stack + stacktop; + + // Finally, "reopen" upvalues. See serializeUpVal() for why we do this + UpVal *uv; + GCObject **nextslot = &L2->openupval; + global_State *g = G(L2); + + while (true) { + unserialize(info); + // >>>>> permTbl indexTbl ...... thread upVal/nil + + // The list is terminated by a nil + if (lua_isnil(info->luaState, -1)) { + // >>>>> permTbl indexTbl ...... thread nil + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + break; + } + + // >>>>> permTbl indexTbl ...... thread boxedUpVal + unboxUpValue(info->luaState); + // >>>>> permTbl indexTbl ...... thread boxedUpVal + + uv = &(getObject(info->luaState, -1)->value.gc->uv); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... thread + + uint32 stackpos = info->readStream->readUint32LE(); + uv->v = L2->stack + stackpos; + + GCUnlink(info->luaState, (GCObject *)uv); + + uv->marked = luaC_white(g); + *nextslot = (GCObject *)uv; + nextslot = &uv->next; + uv->u.l.prev = &G(L2)->uvhead; + uv->u.l.next = G(L2)->uvhead.u.l.next; + uv->u.l.next->u.l.prev = uv; + G(L2)->uvhead.u.l.next = uv; + lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); + } + *nextslot = NULL; + + // The stack must be valid at least to the highest value among the CallInfos + // 'top' and the values up to there must be filled with 'nil' + lua_checkstack(L2, (int)stacklimit); + for (StkId o = L2->top; o <= L2->top + stacklimit; ++o) { + setnilvalue(o); + } +} + +void unserializeProto(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // We have to be careful. The GC expects a lot out of protos. In particular, we need + // to give the function a valid string for its source, and valid code, even before we + // actually read in the real code. + TString *source = lua_newlstr(info->luaState, "", 0); + Proto *p = lua_newproto(info->luaState); + p->source = source; + p->sizecode = 1; + p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction)); + p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); + p->maxstacksize = 2; + p->sizek = 0; + p->sizep = 0; + + lua_checkstack(info->luaState, 2); + + pushProto(info->luaState, p); + // >>>>> permTbl indexTbl ...... proto + + // We don't need to register early, since protos can never ever be + // involved in cyclic references + + // Read in constant references + int sizek = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); + for (int i = 0; i < sizek; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserialize(info); + // >>>>> permTbl indexTbl ...... proto k + + setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); + p->sizek++; + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + // >>>>> permTbl indexTbl ...... proto + + // Read in sub-proto references + + int sizep = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); + for (int i = 0; i < sizep; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserialize(info); + // >>>>> permTbl indexTbl ...... proto subproto + + p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc; + p->sizep++; + + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + // >>>>> permTbl indexTbl ...... proto + + + // Read in code + p->sizecode = info->readStream->readSint32LE(); + lua_reallocvector(info->luaState, p->code, 1, p->sizecode, Instruction); + info->readStream->read(p->code, sizeof(Instruction) * p->sizecode); + + + /* Read in upvalue names */ + p->sizeupvalues = info->readStream->readSint32LE(); + if (p->sizeupvalues) { + lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); + for (int i = 0; i < p->sizeupvalues; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserialize(info); + // >>>>> permTbl indexTbl ...... proto str + + p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + } + } + // >>>>> permTbl indexTbl ...... proto + + // Read in local variable infos + p->sizelocvars = info->readStream->readSint32LE(); + if (p->sizelocvars) { + lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); + for (int i = 0; i < p->sizelocvars; ++i) { + // >>>>> permTbl indexTbl ...... proto + unserialize(info); + // >>>>> permTbl indexTbl ...... proto str + + p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + p->locvars[i].startpc = info->readStream->readSint32LE(); + p->locvars[i].endpc = info->readStream->readSint32LE(); + } + } + // >>>>> permTbl indexTbl ...... proto + + // Read in source string + unserialize(info); + // >>>>> permTbl indexTbl ...... proto sourceStr + + p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); + lua_pop(info->luaState, 1); + // >>>>> permTbl indexTbl ...... proto + + // Read in line numbers + p->sizelineinfo = info->readStream->readSint32LE(); + if (p->sizelineinfo) { + lua_reallocvector(info->luaState, p->lineinfo, 0, p->sizelineinfo, int); + info->readStream->read(p->lineinfo, sizeof(int) * p->sizelineinfo); + } + + + /* Read in linedefined and lastlinedefined */ + p->linedefined = info->readStream->readSint32LE(); + p->lastlinedefined = info->readStream->readSint32LE(); + + // Read in misc values + p->nups = info->readStream->readByte(); + p->numparams = info->readStream->readByte(); + p->is_vararg = info->readStream->readByte(); + p->maxstacksize = info->readStream->readByte(); +} + +void unserializeUpValue(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + lua_checkstack(info->luaState, 2); + + boxUpValue_start(info->luaState); + // >>>>> permTbl indexTbl ...... func + registerObjectInIndexTable(info, index); + + unserialize(info); + // >>>>> permTbl indexTbl ...... func obj + + boxUpValue_finish(info->luaState); + // >>>>> permTbl indexTbl ...... func +} + +void unserializeUserData(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + int isspecial = info->readStream->readSint32LE(); + if (isspecial) { + unserialize(info); + // >>>>> permTbl indexTbl ...... specialFunc + + lua_call(info->luaState, 0, 1); + // >>>>> permTbl indexTbl ...... udata + } else { + uint32 length = info->readStream->readUint32LE(); + lua_newuserdata(info->luaState, length); + // >>>>> permTbl indexTbl ...... udata + registerObjectInIndexTable(info, index); + + info->readStream->read(lua_touserdata(info->luaState, -1), length); + + unserialize(info); + // >>>>> permTbl indexTbl ...... udata metaTable/nil + + lua_setmetatable(info->luaState, -2); + // >>>>> permTbl indexTbl ...... udata + } + // >>>>> permTbl indexTbl ...... udata +} + +void unserializePermanent(UnSerializationInfo *info, int index) { + // >>>>> permTbl indexTbl ...... + + // Make sure there is enough room on the stack + lua_checkstack(info->luaState, 2); + + unserialize(info); + // >>>>> permTbl indexTbl ...... permKey + + lua_gettable(info->luaState, 1); + // >>>>> permTbl indexTbl ...... perm +} + +} // End of namespace Lua diff --git a/engines/sword25/util/lua_unserializer.cpp b/engines/sword25/util/lua_unserializer.cpp deleted file mode 100644 index 803c79c8c2..0000000000 --- a/engines/sword25/util/lua_unserializer.cpp +++ /dev/null @@ -1,698 +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 "sword25/util/lua_serialization.h" - -#include "sword25/util/double_serializer.h" -#include "sword25/util/lua_serialization_util.h" - -#include "common/stream.h" - -#include "lua/lobject.h" -#include "lua/lstate.h" -#include "lua/lgc.h" -#include "lua/lopcodes.h" - - -namespace Lua { - -struct UnSerializationInfo { - lua_State *luaState; - Common::ReadStream *readStream; -}; - -static void unserialize(UnSerializationInfo *info); - -static void unserializeBoolean(UnSerializationInfo *info); -static void unserializeNumber(UnSerializationInfo *info); -static void unserializeString(UnSerializationInfo *info); -static void unserializeTable(UnSerializationInfo *info, int index); -static void unserializeFunction(UnSerializationInfo *info, int index); -static void unserializeThread(UnSerializationInfo *info, int index); -static void unserializeProto(UnSerializationInfo *info, int index); -static void unserializeUpValue(UnSerializationInfo *info, int index); -static void unserializeUserData(UnSerializationInfo *info, int index); -static void unserializePermanent(UnSerializationInfo *info, int index); - - -void unserializeLua(lua_State *luaState, Common::ReadStream *readStream) { - UnSerializationInfo info; - info.luaState = luaState; - info.readStream = readStream; - - // The process starts with the lua stack as follows: - // >>>>> permTbl - // That's the table of permanents - - // Make sure there is enough room on the stack - lua_checkstack(luaState, 3); - - // Create a table to hold indexes of everything thats already been read - lua_newtable(luaState); - // >>>>> permTbl indexTbl - - // Prevent garbage collection while we unserialize - lua_gc(luaState, LUA_GCSTOP, 0); - - // Unserialize the root object - unserialize(&info); - // >>>>> permTbl indexTbl rootObj - - // Re-start garbage collection - lua_gc(luaState, LUA_GCRESTART, 0); - - // Remove the indexTbl - lua_replace(luaState, 2); - // >>>>> permTbl rootObj -} - -/* The object is left on the stack. This is primarily used by unserialize, but - * may be used by GCed objects that may incur cycles in order to preregister - * the object. */ -static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... obj - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - lua_pushlightuserdata(info->luaState, (void *)index); - // >>>>> permTbl indexTbl ...... obj index - - lua_pushvalue(info->luaState, -2); - // >>>>> permTbl indexTbl ...... obj index obj - - // Push the k/v pair into the indexTbl - lua_settable(info->luaState, 2); - // >>>>> permTbl indexTbl ...... obj -} - -static void unserialize(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - byte isARealValue = info->readStream->readByte(); - if (isARealValue) { - int index = info->readStream->readSint32LE(); - int type = info->readStream->readSint32LE(); - - switch (type) { - case LUA_TBOOLEAN: - unserializeBoolean(info); - break; - case LUA_TLIGHTUSERDATA: - // You can't serialize a pointer - // It would be meaningless on the next run - assert(0); - break; - case LUA_TNUMBER: - unserializeNumber(info); - break; - case LUA_TSTRING: - unserializeString(info); - break; - case LUA_TTABLE: - unserializeTable(info, index); - break; - case LUA_TFUNCTION: - unserializeFunction(info, index); - break; - case LUA_TTHREAD: - unserializeThread(info, index); - break; - case LUA_TPROTO: - unserializeProto(info, index); - break; - case LUA_TUPVAL: - unserializeUpValue(info, index); - break; - case LUA_TUSERDATA: - unserializeUserData(info, index); - break; - case PERMANENT_TYPE: - unserializePermanent(info, index); - break; - default: - assert(0); - } - - - // >>>>> permTbl indexTbl ...... obj - assert(lua_type(info->luaState, -1) == type || - type == PERMANENT_TYPE || - // Remember, upvalues get a special dispensation, as described in boxUpValue - (lua_type(info->luaState, -1) == LUA_TFUNCTION && type == LUA_TUPVAL)); - - registerObjectInIndexTable(info, index); - // >>>>> permTbl indexTbl ...... obj - } else { - int index = info->readStream->readSint32LE(); - - if (index == 0) { - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... nil - } else { - // Fetch the object from the indexTbl - - lua_pushlightuserdata(info->luaState, (void *)index); - // >>>>> permTbl indexTbl ...... index - - lua_gettable(info->luaState, 2); - // >>>>> permTbl indexTbl ...... ?obj? - - assert(!lua_isnil(info->luaState, -1)); - } - // >>>>> permTbl indexTbl ...... obj/nil - } - - // >>>>> permTbl indexTbl ...... obj/nil -} - -static void unserializeBoolean(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - int value = info->readStream->readSint32LE(); - - lua_pushboolean(info->luaState, value); - // >>>>> permTbl indexTbl ...... bool -} - -static void unserializeNumber(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - // Read the serialized double - Util::SerializedDouble serializedValue; - serializedValue.significandOne = info->readStream->readUint32LE(); - serializedValue.signAndSignificandTwo = info->readStream->readUint32LE(); - serializedValue.exponent = info->readStream->readSint16LE(); - - lua_Number value = Util::decodeDouble(serializedValue); - - lua_pushnumber(info->luaState, value); - // >>>>> permTbl indexTbl ...... num -} - -static void unserializeString(UnSerializationInfo *info) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - uint32 length = info->readStream->readUint32LE(); - char *string = new char[length]; - - info->readStream->read(string, length); - lua_pushlstring(info->luaState, string, length); - - // >>>>> permTbl indexTbl ...... string - - delete[] string; -} - -static void unserializeSpecialTable(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - unserialize(info); - - // >>>>> permTbl indexTbl ...... spfunc - lua_call(info->luaState, 0, 1); - // >>>>> permTbl indexTbl ...... tbl -} - -static void unserializeLiteralTable(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 3); - - // Preregister table for handling of cycles - lua_newtable(info->luaState); - - // >>>>> permTbl indexTbl ...... tbl - registerObjectInIndexTable(info, index); - // >>>>> permTbl indexTbl ...... tbl - - // Unserialize metatable - unserialize(info); - // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? - - if (lua_istable(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... tbl metaTbl - lua_setmetatable(info->luaState, -2); - // >>>>> permTbl indexTbl ...... tbl - } else { - // >>>>> permTbl indexTbl ...... tbl nil - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl - } - // >>>>> permTbl indexTbl ...... tbl - - - while (1) { - // >>>>> permTbl indexTbl ...... tbl - unserialize(info); - // >>>>> permTbl indexTbl ...... tbl key/nil - - // The table serialization is nil terminated - if (lua_isnil(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... tbl nil - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... tbl - - break; - } - - // >>>>> permTbl indexTbl ...... tbl key - unserialize(info); - // >>>>> permTbl indexTbl ...... tbl value - - lua_rawset(info->luaState, -3); - // >>>>> permTbl indexTbl ...... tbl - } -} - -void unserializeTable(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 1); - - int isSpecial = info->readStream->readSint32LE(); - - if (isSpecial) { - unserializeSpecialTable(info, index); - // >>>>> permTbl indexTbl ...... tbl - } else { - unserializeLiteralTable(info, index); - // >>>>> permTbl indexTbl ...... tbl - } -} - -void unserializeFunction(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - byte numUpValues = info->readStream->readByte(); - - LClosure *lclosure = (LClosure *)lua_newLclosure(info->luaState, numUpValues, hvalue(&info->luaState->l_gt)); - pushClosure(info->luaState, (Closure *)lclosure); - // >>>>> permTbl indexTbl ...... func - - // Put *some* proto in the closure, before the GC can find it - lclosure->p = makeFakeProto(info->luaState, numUpValues); - - //Also, we need to temporarily fill the upvalues - lua_pushnil(info->luaState); - // >>>>> permTbl indexTbl ...... func nil - - for (byte i = 0; i < numUpValues; ++i) { - lclosure->upvals[i] = createUpValue(info->luaState, -1); - } - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - - // I can't see offhand how a function would ever get to be self- - // referential, but just in case let's register it early - registerObjectInIndexTable(info, index); - - // Now that it's safe, we can get the real proto - unserialize(info); - // >>>>> permTbl indexTbl ...... func proto - - lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - - for (byte i = 0; i < numUpValues; ++i) { - // >>>>> permTbl indexTbl ...... func - unserialize(info); - // >>>>> permTbl indexTbl ...... func func2 - - unboxUpValue(info->luaState); - // >>>>> permTbl indexTbl ...... func upValue - lclosure->upvals[i] = gco2uv(getObject(info->luaState, -1)->value.gc); - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - } - - // Finally, the fenv - unserialize(info); - - // >>>>> permTbl indexTbl ...... func ?fenv/nil? - if (!lua_isnil(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... func fenv - lua_setfenv(info->luaState, -2); - // >>>>> permTbl indexTbl ...... func - } else { - // >>>>> permTbl indexTbl ...... func nil - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... func - } - - // >>>>> permTbl indexTbl ...... func -} - -void unserializeThread(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - lua_State *L2; - uint32 stacklimit = 0; - - L2 = lua_newthread(info->luaState); - lua_checkstack(info->luaState, 3); - - // L1: permTbl indexTbl ...... thread - // L2: (empty) - registerObjectInIndexTable(info, index); - - // First, deserialize the object stack - uint32 stackSize = info->readStream->readUint32LE(); - lua_growstack(info->luaState, (int)stackSize); - - // Make sure that the first stack element (a nil, representing - // the imaginary top-level C function) is written to the very, - // very bottom of the stack - L2->top--; - for (uint32 i = 0; i < stackSize; ++i) { - unserialize(info); - // L1: permTbl indexTbl ...... thread obj* - } - - lua_xmove(info->luaState, L2, stackSize); - // L1: permTbl indexTbl ...... thread - // L2: obj* - - // Hereafter, stacks refer to L1 - - - // Now, deserialize the CallInfo stack - - uint32 numFrames = info->readStream->readUint32LE(); - - lua_reallocCallInfo(L2, numFrames * 2); - for (uint32 i = 0; i < numFrames; ++i) { - CallInfo *ci = L2->base_ci + i; - uint32 stackbase = info->readStream->readUint32LE(); - uint32 stackfunc = info->readStream->readUint32LE(); - uint32 stacktop = info->readStream->readUint32LE(); - - ci->nresults = info->readStream->readSint32LE(); - - uint32 savedpc = info->readStream->readUint32LE(); - - if (stacklimit < stacktop) { - stacklimit = stacktop; - } - - ci->base = L2->stack + stackbase; - ci->func = L2->stack + stackfunc; - ci->top = L2->stack + stacktop; - ci->savedpc = (ci != L2->base_ci) ? ci_func(ci)->l.p->code + savedpc : 0; - ci->tailcalls = 0; - - // Update the pointer each time, to keep the GC happy - L2->ci = ci; - } - - // >>>>> permTbl indexTbl ...... thread - // Deserialize the state's other parameters, with the exception of upval stuff - - L2->savedpc = L2->ci->savedpc; - L2->status = info->readStream->readByte(); - uint32 stackbase = info->readStream->readUint32LE(); - uint32 stacktop = info->readStream->readUint32LE(); - - - L2->errfunc = info->readStream->readUint32LE(); - - L2->base = L2->stack + stackbase; - L2->top = L2->stack + stacktop; - - // Finally, "reopen" upvalues. See serializeUpVal() for why we do this - UpVal *uv; - GCObject **nextslot = &L2->openupval; - global_State *g = G(L2); - - while (true) { - unserialize(info); - // >>>>> permTbl indexTbl ...... thread upVal/nil - - // The list is terminated by a nil - if (lua_isnil(info->luaState, -1)) { - // >>>>> permTbl indexTbl ...... thread nil - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... thread - break; - } - - // >>>>> permTbl indexTbl ...... thread boxedUpVal - unboxUpValue(info->luaState); - // >>>>> permTbl indexTbl ...... thread boxedUpVal - - uv = &(getObject(info->luaState, -1)->value.gc->uv); - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... thread - - uint32 stackpos = info->readStream->readUint32LE(); - uv->v = L2->stack + stackpos; - - GCUnlink(info->luaState, (GCObject *)uv); - - uv->marked = luaC_white(g); - *nextslot = (GCObject *)uv; - nextslot = &uv->next; - uv->u.l.prev = &G(L2)->uvhead; - uv->u.l.next = G(L2)->uvhead.u.l.next; - uv->u.l.next->u.l.prev = uv; - G(L2)->uvhead.u.l.next = uv; - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); - } - *nextslot = NULL; - - // The stack must be valid at least to the highest value among the CallInfos - // 'top' and the values up to there must be filled with 'nil' - lua_checkstack(L2, (int)stacklimit); - for (StkId o = L2->top; o <= L2->top + stacklimit; ++o) { - setnilvalue(o); - } -} - -void unserializeProto(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // We have to be careful. The GC expects a lot out of protos. In particular, we need - // to give the function a valid string for its source, and valid code, even before we - // actually read in the real code. - TString *source = lua_newlstr(info->luaState, "", 0); - Proto *p = lua_newproto(info->luaState); - p->source = source; - p->sizecode = 1; - p->code = (Instruction *)lua_reallocv(info->luaState, NULL, 0, 1, sizeof(Instruction)); - p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); - p->maxstacksize = 2; - p->sizek = 0; - p->sizep = 0; - - lua_checkstack(info->luaState, 2); - - pushProto(info->luaState, p); - // >>>>> permTbl indexTbl ...... proto - - // We don't need to register early, since protos can never ever be - // involved in cyclic references - - // Read in constant references - int sizek = info->readStream->readSint32LE(); - lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); - for (int i = 0; i < sizek; ++i) { - // >>>>> permTbl indexTbl ...... proto - unserialize(info); - // >>>>> permTbl indexTbl ...... proto k - - setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); - p->sizek++; - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - // >>>>> permTbl indexTbl ...... proto - - // Read in sub-proto references - - int sizep = info->readStream->readSint32LE(); - lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); - for (int i = 0; i < sizep; ++i) { - // >>>>> permTbl indexTbl ...... proto - unserialize(info); - // >>>>> permTbl indexTbl ...... proto subproto - - p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc; - p->sizep++; - - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - // >>>>> permTbl indexTbl ...... proto - - - // Read in code - p->sizecode = info->readStream->readSint32LE(); - lua_reallocvector(info->luaState, p->code, 1, p->sizecode, Instruction); - info->readStream->read(p->code, sizeof(Instruction) * p->sizecode); - - - /* Read in upvalue names */ - p->sizeupvalues = info->readStream->readSint32LE(); - if (p->sizeupvalues) { - lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); - for (int i = 0; i < p->sizeupvalues; ++i) { - // >>>>> permTbl indexTbl ...... proto - unserialize(info); - // >>>>> permTbl indexTbl ...... proto str - - p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - } - } - // >>>>> permTbl indexTbl ...... proto - - // Read in local variable infos - p->sizelocvars = info->readStream->readSint32LE(); - if (p->sizelocvars) { - lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); - for (int i = 0; i < p->sizelocvars; ++i) { - // >>>>> permTbl indexTbl ...... proto - unserialize(info); - // >>>>> permTbl indexTbl ...... proto str - - p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - - p->locvars[i].startpc = info->readStream->readSint32LE(); - p->locvars[i].endpc = info->readStream->readSint32LE(); - } - } - // >>>>> permTbl indexTbl ...... proto - - // Read in source string - unserialize(info); - // >>>>> permTbl indexTbl ...... proto sourceStr - - p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); - lua_pop(info->luaState, 1); - // >>>>> permTbl indexTbl ...... proto - - // Read in line numbers - p->sizelineinfo = info->readStream->readSint32LE(); - if (p->sizelineinfo) { - lua_reallocvector(info->luaState, p->lineinfo, 0, p->sizelineinfo, int); - info->readStream->read(p->lineinfo, sizeof(int) * p->sizelineinfo); - } - - - /* Read in linedefined and lastlinedefined */ - p->linedefined = info->readStream->readSint32LE(); - p->lastlinedefined = info->readStream->readSint32LE(); - - // Read in misc values - p->nups = info->readStream->readByte(); - p->numparams = info->readStream->readByte(); - p->is_vararg = info->readStream->readByte(); - p->maxstacksize = info->readStream->readByte(); -} - -void unserializeUpValue(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - lua_checkstack(info->luaState, 2); - - boxUpValue_start(info->luaState); - // >>>>> permTbl indexTbl ...... func - registerObjectInIndexTable(info, index); - - unserialize(info); - // >>>>> permTbl indexTbl ...... func obj - - boxUpValue_finish(info->luaState); - // >>>>> permTbl indexTbl ...... func -} - -void unserializeUserData(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - int isspecial = info->readStream->readSint32LE(); - if (isspecial) { - unserialize(info); - // >>>>> permTbl indexTbl ...... specialFunc - - lua_call(info->luaState, 0, 1); - // >>>>> permTbl indexTbl ...... udata - } else { - uint32 length = info->readStream->readUint32LE(); - lua_newuserdata(info->luaState, length); - // >>>>> permTbl indexTbl ...... udata - registerObjectInIndexTable(info, index); - - info->readStream->read(lua_touserdata(info->luaState, -1), length); - - unserialize(info); - // >>>>> permTbl indexTbl ...... udata metaTable/nil - - lua_setmetatable(info->luaState, -2); - // >>>>> permTbl indexTbl ...... udata - } - // >>>>> permTbl indexTbl ...... udata -} - -void unserializePermanent(UnSerializationInfo *info, int index) { - // >>>>> permTbl indexTbl ...... - - // Make sure there is enough room on the stack - lua_checkstack(info->luaState, 2); - - unserialize(info); - // >>>>> permTbl indexTbl ...... permKey - - lua_gettable(info->luaState, 1); - // >>>>> permTbl indexTbl ...... perm -} - -} // End of namespace Lua -- cgit v1.2.3 From 08e3f21a8df184bc697e6c03adf968d0cbdbac21 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 15:22:43 -0600 Subject: SWORD25: Rename double serialization file to better represent what it is AKA functions, rather than a class --- engines/sword25/module.mk | 2 +- engines/sword25/util/double_serialization.cpp | 138 ++++++++++++++++++++++++++ engines/sword25/util/double_serialization.h | 95 ++++++++++++++++++ engines/sword25/util/double_serializer.cpp | 138 -------------------------- engines/sword25/util/double_serializer.h | 95 ------------------ engines/sword25/util/lua_persist.cpp | 2 +- engines/sword25/util/lua_unpersist.cpp | 2 +- 7 files changed, 236 insertions(+), 236 deletions(-) create mode 100644 engines/sword25/util/double_serialization.cpp create mode 100644 engines/sword25/util/double_serialization.h delete mode 100644 engines/sword25/util/double_serializer.cpp delete mode 100644 engines/sword25/util/double_serializer.h diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk index 129b4f040e..0842eb9aa8 100644 --- a/engines/sword25/module.mk +++ b/engines/sword25/module.mk @@ -82,7 +82,7 @@ MODULE_OBJS := \ util/lua/lvm.o \ util/lua/lzio.o \ util/lua/scummvm_file.o \ - util/double_serializer.o \ + util/double_serialization.o \ util/lua_persistence_util.o \ util/lua_persist.o \ util/lua_unpersist.o diff --git a/engines/sword25/util/double_serialization.cpp b/engines/sword25/util/double_serialization.cpp new file mode 100644 index 0000000000..48fd75cb33 --- /dev/null +++ b/engines/sword25/util/double_serialization.cpp @@ -0,0 +1,138 @@ +/* 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 "sword25/util/double_serialization.h" + +#include "common/scummsys.h" + + +namespace Util { + +SerializedDouble encodeDouble(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the the first part of the significand into the integer range + double shiftedsignificandPart = ldexp(abs(significand), 32); + uint32 significandOne = uint32(floor(shiftedsignificandPart)); + + // Shift the remainder of the significand into the integer range + shiftedsignificandPart -= significandOne; + uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 31)); + + SerializedDouble returnValue; + returnValue.significandOne = significandOne; // SignificandOne + returnValue.signAndSignificandTwo = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign + significandTwo; // SignificandTwo + returnValue.exponent = (int16)exponent; + return returnValue; +} + +double decodeDouble(SerializedDouble value) { + // Expand the exponent and the parts of the significand + int exponent = (int)value.exponent; + double expandedsignificandOne = (double)value.significandOne; + double expandedsignificandTwo = (double)(value.signAndSignificandTwo & 0x7FFFFFFF); + + // Deflate the significand + double shiftedsignificand = ldexp(expandedsignificandTwo, -21); + double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue; +} + +uint64 encodeDouble_64(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the significand into the integer range + double shiftedsignificand = ldexp(abs(significand), 53); + + // Combine everything using the IEEE standard + uint64 uintsignificand = (uint64)shiftedsignificand; + return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign + ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023 + (uintsignificand & 0x000FFFFFFFFFFFFF); // significand with MSB inferred +} + +double decodeDouble_64(uint64 value) { + // Expand the exponent and significand + int exponent = (int)((value >> 52) & 0x7FF) - 1023; + double expandedsignificand = (double)(0x10000000000000 /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFF)); + + // Deflate the significand + int temp; + double significand = frexp(expandedsignificand, &temp); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value & 0x8000000000000000) == 0x8000000000000000) ? -returnValue : returnValue; +} + +CompactSerializedDouble encodeDouble_Compact(double value) { + // Split the value into its significand and exponent + int exponent; + double significand = frexp(value, &exponent); + + // Shift the the first part of the significand into the integer range + double shiftedsignificandPart = ldexp(abs(significand), 32); + uint32 significandOne = uint32(floor(shiftedsignificandPart)); + + // Shift the remainder of the significand into the integer range + shiftedsignificandPart -= significandOne; + uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 21)); + + CompactSerializedDouble returnValue; + returnValue.signAndSignificandOne = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign + (significandOne & 0x7FFFFFFF); // significandOne with MSB inferred + // Exponent stored as an offset to 1023 + returnValue.exponentAndSignificandTwo = ((uint32)(exponent + 1023) << 21) | significandTwo; + + return returnValue; +} + +double decodeDouble_Compact(CompactSerializedDouble value) { + // Expand the exponent and the parts of the significand + int exponent = (int)(value.exponentAndSignificandTwo >> 21) - 1023; + double expandedsignificandOne = (double)(0x80000000 /* Inferred MSB */ | (value.signAndSignificandOne & 0x7FFFFFFF)); + double expandedsignificandTwo = (double)(value.exponentAndSignificandTwo & 0x1FFFFF); + + // Deflate the significand + double shiftedsignificand = ldexp(expandedsignificandTwo, -21); + double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); + + // Re-calculate the actual double + double returnValue = ldexp(significand, exponent); + + // Check the sign bit and return + return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue; +} + +} // End of namespace Sword25 diff --git a/engines/sword25/util/double_serialization.h b/engines/sword25/util/double_serialization.h new file mode 100644 index 0000000000..e90338c369 --- /dev/null +++ b/engines/sword25/util/double_serialization.h @@ -0,0 +1,95 @@ +/* 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 DOUBLE_SERIALIZATION_H +#define DOUBLE_SERIALIZATION_H + +#include "common/types.h" + + +namespace Util { + +struct SerializedDouble { + uint32 significandOne; + uint32 signAndSignificandTwo; + int16 exponent; +}; + +struct CompactSerializedDouble { + uint32 signAndSignificandOne; + uint32 exponentAndSignificandTwo; +}; + +/** + * Encodes a double as two uint32 and a one int16 + * + * Supports denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +SerializedDouble encodeDouble(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble(SerializedDouble value); + +/** + * Encodes a double as a uint64 + * + * Does NOT support denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +uint64 encodeDouble_64(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble_64(uint64 value); + +/** + * Encodes a double as two uint32 + * + * Does NOT support denormalized numbers. Does NOT support NaN, or Inf + * + * @param value The value to encode + * @return The encoded value + */ +CompactSerializedDouble encodeDouble_Compact(double value); +/** + * Decodes a previously encoded double + * + * @param value The value to decode + * @return The decoded value + */ +double decodeDouble_Compact(CompactSerializedDouble value); + +} // End of namespace Sword25 + +#endif diff --git a/engines/sword25/util/double_serializer.cpp b/engines/sword25/util/double_serializer.cpp deleted file mode 100644 index d7ba4f3052..0000000000 --- a/engines/sword25/util/double_serializer.cpp +++ /dev/null @@ -1,138 +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 "sword25/util/double_serializer.h" - -#include "common/scummsys.h" - - -namespace Util { - -SerializedDouble encodeDouble(double value) { - // Split the value into its significand and exponent - int exponent; - double significand = frexp(value, &exponent); - - // Shift the the first part of the significand into the integer range - double shiftedsignificandPart = ldexp(abs(significand), 32); - uint32 significandOne = uint32(floor(shiftedsignificandPart)); - - // Shift the remainder of the significand into the integer range - shiftedsignificandPart -= significandOne; - uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 31)); - - SerializedDouble returnValue; - returnValue.significandOne = significandOne; // SignificandOne - returnValue.signAndSignificandTwo = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign - significandTwo; // SignificandTwo - returnValue.exponent = (int16)exponent; - return returnValue; -} - -double decodeDouble(SerializedDouble value) { - // Expand the exponent and the parts of the significand - int exponent = (int)value.exponent; - double expandedsignificandOne = (double)value.significandOne; - double expandedsignificandTwo = (double)(value.signAndSignificandTwo & 0x7FFFFFFF); - - // Deflate the significand - double shiftedsignificand = ldexp(expandedsignificandTwo, -21); - double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); - - // Re-calculate the actual double - double returnValue = ldexp(significand, exponent); - - // Check the sign bit and return - return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue; -} - -uint64 encodeDouble_64(double value) { - // Split the value into its significand and exponent - int exponent; - double significand = frexp(value, &exponent); - - // Shift the significand into the integer range - double shiftedsignificand = ldexp(abs(significand), 53); - - // Combine everything using the IEEE standard - uint64 uintsignificand = (uint64)shiftedsignificand; - return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign - ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023 - (uintsignificand & 0x000FFFFFFFFFFFFF); // significand with MSB inferred -} - -double decodeDouble_64(uint64 value) { - // Expand the exponent and significand - int exponent = (int)((value >> 52) & 0x7FF) - 1023; - double expandedsignificand = (double)(0x10000000000000 /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFF)); - - // Deflate the significand - int temp; - double significand = frexp(expandedsignificand, &temp); - - // Re-calculate the actual double - double returnValue = ldexp(significand, exponent); - - // Check the sign bit and return - return ((value & 0x8000000000000000) == 0x8000000000000000) ? -returnValue : returnValue; -} - -CompactSerializedDouble encodeDouble_Compact(double value) { - // Split the value into its significand and exponent - int exponent; - double significand = frexp(value, &exponent); - - // Shift the the first part of the significand into the integer range - double shiftedsignificandPart = ldexp(abs(significand), 32); - uint32 significandOne = uint32(floor(shiftedsignificandPart)); - - // Shift the remainder of the significand into the integer range - shiftedsignificandPart -= significandOne; - uint32 significandTwo = (uint32)(ldexp(shiftedsignificandPart, 21)); - - CompactSerializedDouble returnValue; - returnValue.signAndSignificandOne = ((uint32)(value < 0 ? 1 : 0) << 31) | // Sign - (significandOne & 0x7FFFFFFF); // significandOne with MSB inferred - // Exponent stored as an offset to 1023 - returnValue.exponentAndSignificandTwo = ((uint32)(exponent + 1023) << 21) | significandTwo; - - return returnValue; -} - -double decodeDouble_Compact(CompactSerializedDouble value) { - // Expand the exponent and the parts of the significand - int exponent = (int)(value.exponentAndSignificandTwo >> 21) - 1023; - double expandedsignificandOne = (double)(0x80000000 /* Inferred MSB */ | (value.signAndSignificandOne & 0x7FFFFFFF)); - double expandedsignificandTwo = (double)(value.exponentAndSignificandTwo & 0x1FFFFF); - - // Deflate the significand - double shiftedsignificand = ldexp(expandedsignificandTwo, -21); - double significand = ldexp(expandedsignificandOne + shiftedsignificand, -32); - - // Re-calculate the actual double - double returnValue = ldexp(significand, exponent); - - // Check the sign bit and return - return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue; -} - -} // End of namespace Sword25 diff --git a/engines/sword25/util/double_serializer.h b/engines/sword25/util/double_serializer.h deleted file mode 100644 index e90338c369..0000000000 --- a/engines/sword25/util/double_serializer.h +++ /dev/null @@ -1,95 +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 DOUBLE_SERIALIZATION_H -#define DOUBLE_SERIALIZATION_H - -#include "common/types.h" - - -namespace Util { - -struct SerializedDouble { - uint32 significandOne; - uint32 signAndSignificandTwo; - int16 exponent; -}; - -struct CompactSerializedDouble { - uint32 signAndSignificandOne; - uint32 exponentAndSignificandTwo; -}; - -/** - * Encodes a double as two uint32 and a one int16 - * - * Supports denormalized numbers. Does NOT support NaN, or Inf - * - * @param value The value to encode - * @return The encoded value - */ -SerializedDouble encodeDouble(double value); -/** - * Decodes a previously encoded double - * - * @param value The value to decode - * @return The decoded value - */ -double decodeDouble(SerializedDouble value); - -/** - * Encodes a double as a uint64 - * - * Does NOT support denormalized numbers. Does NOT support NaN, or Inf - * - * @param value The value to encode - * @return The encoded value - */ -uint64 encodeDouble_64(double value); -/** - * Decodes a previously encoded double - * - * @param value The value to decode - * @return The decoded value - */ -double decodeDouble_64(uint64 value); - -/** - * Encodes a double as two uint32 - * - * Does NOT support denormalized numbers. Does NOT support NaN, or Inf - * - * @param value The value to encode - * @return The encoded value - */ -CompactSerializedDouble encodeDouble_Compact(double value); -/** - * Decodes a previously encoded double - * - * @param value The value to decode - * @return The decoded value - */ -double decodeDouble_Compact(CompactSerializedDouble value); - -} // End of namespace Sword25 - -#endif diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index b9c0b13e11..939dbf38a8 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -22,7 +22,7 @@ #include "sword25/util/lua_persistence.h" -#include "sword25/util/double_serializer.h" +#include "sword25/util/double_serialization.h" #include "sword25/util/lua_persistence_util.h" #include "common/stream.h" diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp index aa924ff7c5..8d644302f9 100644 --- a/engines/sword25/util/lua_unpersist.cpp +++ b/engines/sword25/util/lua_unpersist.cpp @@ -22,7 +22,7 @@ #include "sword25/util/lua_persistence.h" -#include "sword25/util/double_serializer.h" +#include "sword25/util/double_serialization.h" #include "sword25/util/lua_persistence_util.h" #include "common/stream.h" -- cgit v1.2.3 From 8668707f160fa171edfa68df036f28c7ba4e9a88 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 15:11:17 -0600 Subject: SWORD25: Fix how nils are persisted The unpersist code expects nils to be represented as an index with value 0. The persist code incorrectly wrote out this data --- engines/sword25/util/lua_persist.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index 939dbf38a8..6d758067ad 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -59,7 +59,7 @@ void persistLua(lua_State *luaState, Common::WriteStream *writeStream) { SerializationInfo info; info.luaState = luaState; info.writeStream = writeStream; - info.counter = 0u; + info.counter = 1u; // The process starts with the lua stack as follows: // >>>>> permTbl rootObj @@ -145,19 +145,22 @@ static void serialize(SerializationInfo *info) { return; } - // Pop the nil off the stack + // Pop the index/nil off the stack lua_pop(info->luaState, 1); - // Write out a flag that indicates that this is a real object - info->writeStream->writeByte(1); - - // If the object itself is nil, then write out a zero as a placeholder + // If the obj itself is nil, we represent it as an index of 0 if (lua_isnil(info->luaState, -1)) { + // Write out a flag that indicates that it's an index info->writeStream->writeByte(0); + // Write out the index + info->writeStream->writeUint32LE(0); return; } + // Write out a flag that indicates that this is a real object + info->writeStream->writeByte(1); + // Add the object to the indexTbl lua_pushvalue(info->luaState, -1); -- cgit v1.2.3 From 67114c3e7eafdd6ba8c7bc799a40f789acc1efa3 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 15:30:55 -0600 Subject: SWORD25: Remove old lua persistence files --- engines/sword25/util/pluto/CHANGELOG | 37 - engines/sword25/util/pluto/FILEFORMAT | 168 --- engines/sword25/util/pluto/README | 133 -- engines/sword25/util/pluto/THANKS | 9 - engines/sword25/util/pluto/pdep.cpp | 112 -- engines/sword25/util/pluto/pdep/README | 5 - engines/sword25/util/pluto/pdep/lzio.h | 65 - engines/sword25/util/pluto/pdep/pdep.h | 42 - engines/sword25/util/pluto/pluto.cpp | 2083 -------------------------------- engines/sword25/util/pluto/pluto.h | 25 - engines/sword25/util/pluto/plzio.cpp | 74 -- 11 files changed, 2753 deletions(-) delete mode 100644 engines/sword25/util/pluto/CHANGELOG delete mode 100644 engines/sword25/util/pluto/FILEFORMAT delete mode 100644 engines/sword25/util/pluto/README delete mode 100644 engines/sword25/util/pluto/THANKS delete mode 100644 engines/sword25/util/pluto/pdep.cpp delete mode 100644 engines/sword25/util/pluto/pdep/README delete mode 100644 engines/sword25/util/pluto/pdep/lzio.h delete mode 100644 engines/sword25/util/pluto/pdep/pdep.h delete mode 100644 engines/sword25/util/pluto/pluto.cpp delete mode 100644 engines/sword25/util/pluto/pluto.h delete mode 100644 engines/sword25/util/pluto/plzio.cpp diff --git a/engines/sword25/util/pluto/CHANGELOG b/engines/sword25/util/pluto/CHANGELOG deleted file mode 100644 index 1be321f898..0000000000 --- a/engines/sword25/util/pluto/CHANGELOG +++ /dev/null @@ -1,37 +0,0 @@ -$Id$ - --- 2.4 -- -* Changed upval unboxing to allow upvals which contain func-housed cycles -* Added stack checking to all stack-growing functions -* Serialized debug information for functions - --- 2.3 -- -* Added LUALIB_API declaration for luaopen_pluto - --- 2.2 -- -* Rolled all internal Lua dependencies into the Pluto distribution -* Made the unit tests depend on dynamically loading Pluto - --- 2.1 -- -* Various fixes to make the GC happy -* stack size always expanded where necessary -* fixed some memory leaks -* GC disabled during unpersist -* callstack initialized for traversal - -This changelog is maintained as of version 2.0alpha1. -Earlier versions are changelogged on the LuaForge site. - --- 2.0 -- -* Fixed a few format changes to 5.1.3 -* Fixed myriad warnings -* GCC compliance: not incrementing cast results -* Fix for self-referring upvals -* Renamed loading function to work with Lua module system -* Loading tables with __newindex works -* unpersist makes buffer copy - --- 2.0alpha1 -- -* Fixed all outstanding 5.0->5.1 conversion issues -* Made heavier use of size_t in preference to int -* Fixed GC/Upval issue (thanks to Eric Jacobs) diff --git a/engines/sword25/util/pluto/FILEFORMAT b/engines/sword25/util/pluto/FILEFORMAT deleted file mode 100644 index e7716675c7..0000000000 --- a/engines/sword25/util/pluto/FILEFORMAT +++ /dev/null @@ -1,168 +0,0 @@ -$Id$ - -pluto_persist() produces a "hunk" of objects. Here's the file format adhered -to by the function, and expected by pluto_unpersist(). - -As a developer, I feel that where file format information is given it is of -utmost importance that that information precisely and accurately reflects the -actual operation of the application. Therefore, if you find any discrepancy -between this and actual operation, please lambast me thoroughly over email. - -Pseudo-C is used to express the file format. Padding is assumed to be -nonexistent. The keyword "one_of" is used to express a concept similar to -"union", except that its size is the size of the actual datatype chosen. Thus, -objects which contain, directly or indirectly, a one_of, may vary in size. - - -struct Object { - int firstTime; /* Whether this is the first time the object - is being referenced */ - one_of { - RealObject o; /* if firstTime == 1 */ - Reference r; /* if firstTime == 0 */ - }; -}; - -struct Reference { - int ref; /* The index the object was registered with */ -}; - -struct RealObject { - int type; /* The type of the object */ - one_of { - Boolean b; /* If type == LUA_TBOOLEAN */ - LightUserData l; /* If type == LUA_TLIGHTUSERDATA */ - Number n; /* If type == LUA_TNUMBER */ - String s; /* If type == LUA_TSTRING */ - Table t; /* If type == LUA_TTABLE */ - Function f; /* If type == LUA_TFUNCTION */ - Userdata u; /* If type == LUA_TUSERDATA */ - Thread th; /* If type == LUA_TTHREAD */ - Proto p; /* If type == LUA_TPROTO (from lobject.h) */ - Upval uv; /* If type == LUA_TUPVAL (from lobject.h) */ - }; /* The actual object */ -}; - -struct Boolean { - int32 bvalue; /* 0 for false, 1 for true */ -}; - -struct LightUserData { - void* luvalue; /* The actual, literal pointer */ -}; - -struct Number { - lua_Number nvalue; /* The actual number */ -}; - -struct String { - int length; /* The length of the string */ - char str[length]; /* The actual string (not null terminated) */ -}; - -struct Table { - int isspecial; /* 1 if SP is used; 0 otherwise */ - one_of { - Closure c; /* if isspecial == 1; closure to refill the table */ - LiteralTable t; /* if isspecial == 0; literal table info */ - }; -}; - -struct LiteralTable { - Object metatable; /* nil for default metatable */ - Pair p[]; /* key/value pairs */ - Object nil = nil; /* Nil reference to terminate */ -}; - -struct Pair { - Object key; - Object value; -}; - -struct Function { /* Actually a closure */ - lu_byte nups; /* Number of upvalues the function uses */ - Object proto; /* The proto this function uses */ - Object upvals[nups]; /* All upvalues */ - Object fenv; /* The FEnv (nil for the global table) -}; - -struct Upval { - Object obj; /* The object this upval refers to */ -} - -struct Userdata { - int isSpecial; /* 1 for special persistence, 0 for literal - one_of { - LiteralUserdata lu; /* if is_special is 0 */ - SpecialUserdata su; /* if is_special is 1 */ - }; -}; - -struct LiteralUserdata { - Object metatable; /* The metatable (nil for default) */ - int length; /* Size of the data */ - char data[length]; /* The actual data */ -}; - -struct SpecialUserdata { - int length; /* The size of the data */ - Object func; /* The closure used to fill the userdata */ -}; - -struct Thread { - int stacksize; /* The size of the stack filled with objects, - * including the "nil" that is hidden below - * the bottom of the stack visible to C */ - Object stack[stacksize];/* Indices of all stack values, bottom up */ - int callinfosize; /* Number of elements in the CallInfo stack */ - CallInfo callinfostack[callinfosize]; /* The CallInfo stack */ - int base; /* base = L->base - L->stack; */ - int top; /* top = L->top - L->stack; */ - OpenUpval openupvals[]; /* Upvalues to open */ - Object nil = nil; /* To terminate the open upvalues list */ -}; - -struct OpenUpval { - Object upval; /* The upvalue */ - int stackpos; /* The stack position to "reopen" it to */ - -}; - -struct CallInfo { - int base; /* base = ci->base - L->stack; */ - int top; /* top = ci->top - L->stack; */ - int pc; /* pc = ci->pc - proto->code; */ - int state; /* flags used by the CallInfo */ -}; - -struct Proto { - int sizek; /* Number of constants referenced */ - Object k[sizek]; /* Constants referenced */ - int sizep; /* Number of inner Protos referenced */ - Object p[sizep]; /* Inner Protos referenced */ - int sizecode; /* Number of instructions in code */ - Instruction code[sizecode]; /* The proto's code */ - ProtoDebug debuginfo; /* Debug information for the proto */ - lu_byte nups; /* Number of upvalues used */ - lu_byte numparams; /* Number of parameters taken */ - lu_byte is_vararg; /* 1 if function accepts varargs, 0 otherwise */ - lu_byte maxstacksize; /* Size of stack reserved for the function */ -}; - -struct ProtoDebug { - int sizeupvals; /* Number of upvalue names */ - Object upvals; /* Upvalue names */ - int sizelocvars; /* Number of local variable names */ - LocVar[sizelocvars]; /* Local variable names */ - Object source; /* The source code */ - int sizelineinfo; /* Number of opcode-line mappings */ - int lineinfo[sizelineinfo]; /* opcode-line mappings */ - int linedefined; /* Start of line range */ - int lastlinedefined; /* End of line range */ -}; - -struct LocVar { - Object name; /* Name of the local variable */ - int startpc; /* Point where variable is active */ - int endpc; /* Point where variable is dead */ -}; diff --git a/engines/sword25/util/pluto/README b/engines/sword25/util/pluto/README deleted file mode 100644 index 838fce498b..0000000000 --- a/engines/sword25/util/pluto/README +++ /dev/null @@ -1,133 +0,0 @@ -$Id$ - -PLUTO - Heavy duty persistence for Lua - -Pluto is a library which allows users to write arbitrarily large portions -of the "Lua universe" into a flat file, and later read them back into the -same or a different Lua universe. Object references are appropriately -handled, such that the file contains everything needed to recreate the -objects in question. - -Pluto has the following major features: -* Can persist any Lua function -* Can persist threads -* Works with any Lua chunkreader/chunkwriter -* Support for "invariant" permanent objects, of all datatypes -* Can invoke metafunctions for custom persistence of tables and userdata - -Pluto 2.2 requires Lua 5.1.3. If you need to use Pluto with Lua -5.0, please use version 1.2 of Pluto. - -Starting with version 2.2, Pluto no longer depends on the Lua sources. -Instead, it subsumes the required headers into its own codebase. -As a result, it may not work properly with Lua version 5.1.4 or later. - -Pluto may have bugs. Users are advised to define lua_assert in -luaconf.h to something useful when compiling in debug mode, to catch -assertions by Pluto and Lua. - -The Pluto library consists of two public functions. - -int pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud) - -This function recursively persists the Lua object in stack position 2 -and all other objects which are directly or indirectly referenced by -it, except those referenced in the permanent object table. The data -is written using the chunk-writer given, and that writer is passed -the arbitrary pointer value ud. - -The Lua stack must contain exactly and only these two items, in order: - -1. A table of permanent objects, that should not be persisted. For each -permanent object, the object itself should be the key, and a unique -object of any type should be the value. Likely candidates for this table -include Lua functions (including those in the Lua libraries) that are -loaded at load-time. It must include all non-persistable objects that -are referenced by the object to be persisted. The table is not modified -by the function. Objects in this table are considered "opaque" and are -not examined or descended into. Objects should not appear in the table -multiple times; the result of doing this is undefined (though probably -harmless). NOTE: If you are planning to persist threads, keep in mind -that all yielded threads have coroutine.yield on the tops of their -stacks. Since it's a C function, it should be put here. For complex -permanents, it may be a good idea to use the __index meta-function of -the permanents table to "search" for permanents. - -2. The single object to be persisted. In many cases, this will be the -global table. For more flexibility, however, it may be something like a -table built for the occasion, with various values to keep track of. The -object may not be nil. - - -int pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud) - -This function loads in a Lua object and places it on top of the stack. All -objects directly or indirectly referenced by it are also loaded. - -The Lua stack must contain, as its top value, a table of permanent -objects. This table should be like the permanent object table used when -persisting, but with the key and value of each pair reversed. These -objects are used as substitutes for those referenced in their positions -when persisting, and under most circumstances should be identical objects -to those referenced in the permanents table used for persisting. It's -okay for multiple keys to refer to the same object. - - -RUNNING PLUTO FROM LUA: -It is also possible to invoke pluto from a Lua script. The C function -pluto_open() will register pluto.persist and pluto.unpersist, lua functions -which operate on strings. The first takes a permanents table and a root -object, and returns a string; the second takes a permanents table and a -string, and returns the root object. - -An error will be raised if pluto.persist is called from a thread which is -itself referenced by the root object. - -SPECIAL PERSISTENCE: -Tables and userdata have special persistence semantics. These semantics are -keyed to the value of the object's metatable's __persist member, if any. This -member may be any of the following four values: -1. Boolean "true": The table or userdata is persisted literally; tables are -persisted member-by-member, and userdata are written out as literal data. -2. Boolean "false": An error is returned, indicating that the object cannot -be persisted. -3. A function: This function should take one argument, the object in question, -and return one result, a closure. This "fixup closure", in turn, will be -persisted, and during unpersistence will be called. The closure will be -responsible for recreating the object with the appropriate data, based on -its upvalues. -4. Nil, or no metatable. In the case of tables, the table is literally -persisted. In the case of userdata, an error is returned. - -Here's an example of special persistence for a simple 3d vector object: - -vec = { x = 2, y = 1, z = 4 } -setmetatable(vec, { __persist = function(oldtbl) - local x = oldtbl.x - local y = oldtbl.y - local z = oldtbl.z - local mt = getmetatable(oldtbl) - return function() - newtbl = {} - newtbl.x = x - newtbl.y = y - newtbl.z = z - setmetatable(newtbl, mt) - return newtbl - end -end }) - -Note how x, y, z, and the mt are explicitly pulled out of the table. It is -important that the fixup closure returned not reference the original table -directly, as that table would again be persisted as an upvalue, leading to an -infinite loop. Also note that the object's metatable is NOT automatically -persisted; it is necessary for the fixup closure to reset it, if it wants. - -LIMITATIONS/TODO: -* Light userdata are persisted literally, as their pointer values. This -may or may not be what you want. -* Closures of C functions may not be persisted. Once it becomes possible -to specify a C function "proto" as a permanent object, this restriction -will be relaxed. - -BUGS: None known. Emphasis on the 'known'. diff --git a/engines/sword25/util/pluto/THANKS b/engines/sword25/util/pluto/THANKS deleted file mode 100644 index 443713fa61..0000000000 --- a/engines/sword25/util/pluto/THANKS +++ /dev/null @@ -1,9 +0,0 @@ -Pluto is surprisingly robust and useful. This would not be the case without -the hard work and helpfulness of the following people, mentioned in no -particular order: - -Ivko Stanilov -Goran Adrinek -Eric Jacobs -Anolan Milanes -Malte Thiesen diff --git a/engines/sword25/util/pluto/pdep.cpp b/engines/sword25/util/pluto/pdep.cpp deleted file mode 100644 index a32c43b42d..0000000000 --- a/engines/sword25/util/pluto/pdep.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* This file is derived from the Lua source code. Please see lua.h for -the copyright statement. -*/ - -#include "pdep/pdep.h" - -#define api_incr_top(L) {api_check(L, L->top < L->ci->top); L->top++;} - -void pdep_pushobject (lua_State *L, const TValue *o) { - setobj2s(L, L->top, o); - api_incr_top(L); -} - -void *pdep_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { - global_State *g = G(L); - lua_assert((osize == 0) == (block == NULL)); - block = (*g->frealloc)(g->ud, block, osize, nsize); - lua_assert((nsize == 0) == (block == NULL)); - g->totalbytes = (g->totalbytes - osize) + nsize; - return block; -} - -void pdep_link (lua_State *L, GCObject *o, lu_byte tt) { - global_State *g = G(L); - o->gch.next = g->rootgc; - g->rootgc = o; - o->gch.marked = luaC_white(g); - o->gch.tt = tt; -} - -Proto *pdep_newproto (lua_State *L) { - Proto *f = pdep_new(L, Proto); - pdep_link(L, obj2gco(f), LUA_TPROTO); - f->k = NULL; - f->sizek = 0; - f->p = NULL; - f->sizep = 0; - f->code = NULL; - f->sizecode = 0; - f->sizelineinfo = 0; - f->sizeupvalues = 0; - f->nups = 0; - f->upvalues = NULL; - f->numparams = 0; - f->is_vararg = 0; - f->maxstacksize = 0; - f->lineinfo = NULL; - f->sizelocvars = 0; - f->locvars = NULL; - f->linedefined = 0; - f->lastlinedefined = 0; - f->source = NULL; - return f; -} - -Closure *pdep_newLclosure (lua_State *L, int nelems, Table *e) { - Closure *c = cast(Closure *, pdep_malloc(L, sizeLclosure(nelems))); - pdep_link(L, obj2gco(c), LUA_TFUNCTION); - c->l.isC = 0; - c->l.env = e; - c->l.nupvalues = cast_byte(nelems); - while (nelems--) c->l.upvals[nelems] = NULL; - return c; -} - -static void correctstack (lua_State *L, TValue *oldstack) { - CallInfo *ci; - GCObject *up; - L->top = (L->top - oldstack) + L->stack; - for (up = L->openupval; up != NULL; up = up->gch.next) - gco2uv(up)->v = (gco2uv(up)->v - oldstack) + L->stack; - for (ci = L->base_ci; ci <= L->ci; ci++) { - ci->top = (ci->top - oldstack) + L->stack; - ci->base = (ci->base - oldstack) + L->stack; - ci->func = (ci->func - oldstack) + L->stack; - } - L->base = (L->base - oldstack) + L->stack; -} - - -void pdep_reallocstack (lua_State *L, int newsize) { - TValue *oldstack = L->stack; - int realsize = newsize + 1 + EXTRA_STACK; - lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); - pdep_reallocvector(L, L->stack, L->stacksize, realsize, TValue); - L->stacksize = realsize; - L->stack_last = L->stack+newsize; - correctstack(L, oldstack); -} - -void pdep_growstack (lua_State *L, int n) { - if (n <= L->stacksize) /* double size is enough? */ - pdep_reallocstack(L, 2*L->stacksize); - else - pdep_reallocstack(L, L->stacksize + n); -} - -void pdep_reallocCI (lua_State *L, int newsize) { - CallInfo *oldci = L->base_ci; - pdep_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); - L->size_ci = newsize; - L->ci = (L->ci - oldci) + L->base_ci; - L->end_ci = L->base_ci + L->size_ci - 1; -} - -TString *pdep_newlstr (lua_State *L, const char *str, size_t l) { - TString *res; - lua_pushlstring(L, str, l); - res = rawtsvalue(L->top-1); - lua_pop(L, 1); - return res; -} diff --git a/engines/sword25/util/pluto/pdep/README b/engines/sword25/util/pluto/pdep/README deleted file mode 100644 index 3592754da0..0000000000 --- a/engines/sword25/util/pluto/pdep/README +++ /dev/null @@ -1,5 +0,0 @@ -These files are directly copied from the Lua distribution, with the -exception of lzio.h, which is s/lua{ZM}/pdep/g and has an include removed. - -As such, unlike the rest of Pluto, they are released under the -same terms as Lua. See "lua.h" for the copyright notice. diff --git a/engines/sword25/util/pluto/pdep/lzio.h b/engines/sword25/util/pluto/pdep/lzio.h deleted file mode 100644 index 2e37f8d202..0000000000 --- a/engines/sword25/util/pluto/pdep/lzio.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -** $Id$ -** Buffered streams -** See Copyright Notice in lua.h -*/ - - -#ifndef lzio_h -#define lzio_h - -#include "sword25/util/lua/lua.h" - - -#define EOZ (-1) /* end of stream */ - -typedef struct Zio ZIO; - -#define char2int(c) cast(int, cast(unsigned char, (c))) - -#define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : pdep_fill(z)) - -typedef struct Mbuffer { - char *buffer; - size_t n; - size_t buffsize; -} Mbuffer; - -#define pdep_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) - -#define pdep_buffer(buff) ((buff)->buffer) -#define pdep_sizebuffer(buff) ((buff)->buffsize) -#define pdep_bufflen(buff) ((buff)->n) - -#define pdep_resetbuffer(buff) ((buff)->n = 0) - - -#define pdep_resizebuffer(L, buff, size) \ - (pdep_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ - (buff)->buffsize = size) - -#define pdep_freebuffer(L, buff) pdep_resizebuffer(L, buff, 0) - - -LUAI_FUNC char *pdep_openspace (lua_State *L, Mbuffer *buff, size_t n); -LUAI_FUNC void pdep_init (lua_State *L, ZIO *z, lua_Reader reader, - void *data); -LUAI_FUNC size_t pdep_read (ZIO* z, void* b, size_t n); /* read next n bytes */ -LUAI_FUNC int pdep_lookahead (ZIO *z); - - - -/* --------- Private Part ------------------ */ - -struct Zio { - size_t n; /* bytes still unread */ - const char *p; /* current position in buffer */ - lua_Reader reader; - void* data; /* additional data */ - lua_State *L; /* Lua state (for reader) */ -}; - - -LUAI_FUNC int pdep_fill (ZIO *z); - -#endif diff --git a/engines/sword25/util/pluto/pdep/pdep.h b/engines/sword25/util/pluto/pdep/pdep.h deleted file mode 100644 index 664fc812b5..0000000000 --- a/engines/sword25/util/pluto/pdep/pdep.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef PDEP_H -#define PDEP_H - -#include "sword25/util/lua/lua.h" -#include "sword25/util/pluto/pdep/lzio.h" -#include "sword25/util/lua/ldo.h" -#include "sword25/util/lua/lfunc.h" -#include "sword25/util/lua/lgc.h" -#include "sword25/util/lua/llimits.h" -#include "sword25/util/lua/lobject.h" -#include "sword25/util/lua/lopcodes.h" -#include "sword25/util/lua/lstate.h" -#include "sword25/util/lua/lstring.h" -#include "sword25/util/lua/lauxlib.h" - - -#define pdep_reallocv(L,b,on,n,e) \ - pdep_realloc_(L, (b), (on)*(e), (n)*(e)) -#define pdep_reallocvector(L, v,oldn,n,t) \ - ((v)=cast(t *, pdep_reallocv(L, v, oldn, n, sizeof(t)))) -#define pdep_freearray(L, b, n, t) pdep_reallocv(L, (b), n, 0, sizeof(t)) -#define pdep_newvector(L,n,t) \ - cast(t *, pdep_reallocv(L, NULL, 0, n, sizeof(t))) -#define pdep_new(L,t) cast(t *, pdep_malloc(L, sizeof(t))) -#define pdep_malloc(L,t) pdep_realloc_(L, NULL, 0, (t)) -#define pdep_checkstack(L,n) \ - if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ - pdep_growstack(L, n); \ - else pdep_reallocstack(L, L->stacksize - EXTRA_STACK - 1); - - -void pdep_pushobject (lua_State *L, const TValue *o); -void *pdep_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize); -void pdep_link (lua_State *L, GCObject *o, lu_byte tt); -Proto *pdep_newproto (lua_State *L); -Closure *pdep_newLclosure (lua_State *L, int nelems, Table *e); -void pdep_reallocstack (lua_State *L, int newsize); -void pdep_growstack (lua_State *L, int n); -void pdep_reallocCI (lua_State *L, int newsize); -TString *pdep_newlstr (lua_State *L, const char *str, size_t l); - -#endif diff --git a/engines/sword25/util/pluto/pluto.cpp b/engines/sword25/util/pluto/pluto.cpp deleted file mode 100644 index cbe16b0d5b..0000000000 --- a/engines/sword25/util/pluto/pluto.cpp +++ /dev/null @@ -1,2083 +0,0 @@ -/* $Id$ */ - -/* Tamed Pluto - Heavy-duty persistence for Lua - * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public - * domain. People making use of this software as part of an application - * are politely requested to email the author at sneftel@gmail.com - * with a brief description of the application, primarily to satisfy his - * curiosity. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Instrumented by Stefan Reich (info@luaos.net) - * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) - */ - -#include "sword25/util/lua/lua.h" -#include "pluto.h" - -#undef TOTEXT - -#define USE_PDEP - -#ifdef USE_PDEP -#include "pdep/pdep.h" -#define LIF(prefix, name) pdep ## _ ## name -#else -#include "lapi.h" -#include "ldo.h" -#include "lfunc.h" -#include "lgc.h" -#include "llimits.h" -#include "lmem.h" -#include "lobject.h" -#include "lopcodes.h" -#include "lstate.h" -#include "lstring.h" -#include "lauxlib.h" -#define LIF(prefix, name) lua ## prefix ## _ ## name -#endif - -#include - - -/* Define this if you want size_t values to be written in 64-bit - (even on 32-bit systems). Should eliminate at least one source of - 32/64 bit incompatibility. */ -#define SIZES64 - - -/* #define PLUTO_DEBUG */ - - -#ifdef SIZES64 -#define VERSION "Tamed Pluto 1.0 with SIZES64 flag" -#else -#define VERSION "Tamed Pluto 1.0" -#endif - - -#ifdef PLUTO_DEBUG -#include -#endif - -#define PLUTO_TPERMANENT 101 - -#define verify(x) { int v = (int)((x)); v=v; lua_assert(v); } - -#define NUMTYPES 9 -static const char* typenames[] = { - "nil", - "boolean", - "lightuserdata", - "number", - "string", - "table", - "function", - "userdata", - "thread" -}; - -static int humanReadable = 0; -#define hrBufSize 200 -static char hrBuf[hrBufSize]; - -typedef struct PersistInfo_t { - lua_State *L; - int counter; - lua_Chunkwriter writer; - void *ud; -#ifdef PLUTO_DEBUG - int level; -#endif -} PersistInfo; - -#ifdef PLUTO_DEBUG -void printindent(int indent) -{ - int il; - for(il=0; ilwriter(pi->L, hrBuf, strlen(hrBuf), ud); - for (i = 0; i < size; i++) { - char b = ((char *)p)[i]; - snprintf(hrBuf, hrBufSize, "%X%X", (b >> 4) & 0xF, b & 0xF); - pi->writer(pi->L, hrBuf, strlen(hrBuf), ud); - } - snprintf(hrBuf, hrBufSize, "\n"); - pi->writer(pi->L, hrBuf, strlen(hrBuf), ud); - } else { - pi->writer(pi->L, p, size, ud); - } -#ifdef TOTEXT - int i; - printf(" pi_write %d ", (int) size); - for (i = 0; i < size; i++) { - char b = ((char *)p)[i]; - printf("%X%X", (b >> 4) & 0xF, b & 0xF); - } - printf("\n"); -#endif -} - -static void hrOut(PersistInfo *pi) { - pi->writer(pi->L, hrBuf, strlen(hrBuf), pi->ud); -} - -static void write_size(PersistInfo *pi, size_t *val) -{ -#ifdef SIZES64 - int64 longval; /* yeah, you really need long long to get 8 bytes on win32... duh. */ - longval = *val; - pi_write(pi, &longval, 8, pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "write_size64 %ld\n", longval); - hrOut(pi); - } -#ifdef TOTEXT - printf("write_size64 %ld\n", longval); -#endif -#else - pi_write(pi, val, sizeof(size_t), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "write_size %ld\n", *((size_t *)val)); - hrOut(pi); - } -#ifdef TOTEXT - printf("write_size %ld\n", *val); -#endif -#endif -} - -static void read_size(ZIO *zio, size_t *val) -{ -#ifdef SIZES64 - int64 longval; - verify(LIF(Z,read)(zio, &longval, 8) == 0); - *val = longval; -#else - verify(LIF(Z,read)(zio, val, sizeof(size_t)) == 0); -#endif -} - - -/* Mutual recursion requires prototype */ -static void persist(PersistInfo *pi); - -/* A simple reimplementation of the unfortunately static function luaA_index. - * Does not support the global table, registry, or upvalues. */ -static StkId getobject(lua_State *L, int stackpos) -{ - if(stackpos > 0) { - lua_assert(L->base+stackpos-1 < L->top); - return L->base+stackpos-1; - } else { - lua_assert(L->top-stackpos >= L->base); - return L->top+stackpos; - } -} - -/* Choose whether to do a regular or special persistence based on an object's - * metatable. "default" is whether the object, if it doesn't have a __persist - * entry, is literally persistable or not. - * Pushes the unpersist closure and returns true if special persistence is - * used. */ -static int persistspecialobject(PersistInfo *pi, int defaction) -{ - /* perms reftbl ... obj */ - lua_checkstack(pi->L, 4); - /* Check whether we should persist literally, or via the __persist - * metafunction */ - if(!lua_getmetatable(pi->L, -1)) { - if(defaction) { - { - int zero = 0; - pi_write(pi, &zero, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistspecialobject_write_zero\n"); -#endif - } - return 0; - } else { - lua_pushstring(pi->L, "Type not literally persistable by default"); - lua_error(pi->L); - } - } - /* perms reftbl sptbl ... obj mt */ - lua_pushstring(pi->L, "__persist"); - /* perms reftbl sptbl ... obj mt "__persist" */ - lua_rawget(pi->L, -2); - /* perms reftbl sptbl ... obj mt __persist? */ - if(lua_isnil(pi->L, -1)) { - /* perms reftbl sptbl ... obj mt nil */ - lua_pop(pi->L, 2); - /* perms reftbl sptbl ... obj */ - if(defaction) { - { - int zero = 0; - pi_write(pi, &zero, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero2\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistspecialobject_write_zero2\n"); -#endif - } - return 0; - } else { - lua_pushstring(pi->L, "Type not literally persistable by default"); - lua_error(pi->L); - return 0; /* not reached */ - } - } else if(lua_isboolean(pi->L, -1)) { - /* perms reftbl sptbl ... obj mt bool */ - if(lua_toboolean(pi->L, -1)) { - /* perms reftbl sptbl ... obj mt true */ - lua_pop(pi->L, 2); - /* perms reftbl sptbl ... obj */ - { - int zero = 0; - pi_write(pi, &zero, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistspecialobject_write_zero3\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistspecialobject_write_zero3\n"); -#endif - } - return 0; - } else { - lua_pushstring(pi->L, "Metatable forbade persistence"); - lua_error(pi->L); - return 0; /* not reached */ - } - } else if(!lua_isfunction(pi->L, -1)) { - lua_pushstring(pi->L, "__persist not nil, boolean, or function"); - lua_error(pi->L); - } - /* perms reftbl ... obj mt __persist */ - lua_pushvalue(pi->L, -3); - /* perms reftbl ... obj mt __persist obj */ -#ifdef PLUTO_PASS_USERDATA_TO_PERSIST - lua_pushlightuserdata(pi->L, (void *)pi->writer); - lua_pushlightuserdata(pi->L, pi->ud); - /* perms reftbl ... obj mt __persist obj ud */ - lua_call(pi->L, 3, 1); - /* perms reftbl ... obj mt func? */ -#else - lua_call(pi->L, 1, 1); - /* perms reftbl ... obj mt func? */ -#endif - /* perms reftbl ... obj mt func? */ - if(!lua_isfunction(pi->L, -1)) { - lua_pushstring(pi->L, "__persist function did not return a function"); - lua_error(pi->L); - } - /* perms reftbl ... obj mt func */ - { - int one = 1; - pi_write(pi, &one, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistspecialobject_write_one\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistspecialobject_write_one\n"); -#endif - } - persist(pi); - /* perms reftbl ... obj mt func */ - lua_pop(pi->L, 2); - /* perms reftbl ... obj */ - return 1; -} - -static void persisttable(PersistInfo *pi) -{ - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persisttable\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persisttable\n"); -#endif - - /* perms reftbl ... tbl */ - lua_checkstack(pi->L, 3); - if(persistspecialobject(pi, 1)) { - /* perms reftbl ... tbl */ - return; - } - /* perms reftbl ... tbl */ - /* First, persist the metatable (if any) */ - if(!lua_getmetatable(pi->L, -1)) { - lua_pushnil(pi->L); - } - /* perms reftbl ... tbl mt/nil */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... tbl */ - - /* Now, persist all k/v pairs */ - lua_pushnil(pi->L); - /* perms reftbl ... tbl nil */ - while(lua_next(pi->L, -2)) { - /* perms reftbl ... tbl k v */ - lua_pushvalue(pi->L, -2); - /* perms reftbl ... tbl k v k */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... tbl k v */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... tbl k */ - } - /* perms reftbl ... tbl */ - /* Terminate list */ - lua_pushnil(pi->L); - /* perms reftbl ... tbl nil */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... tbl */ -} - -static void persistuserdata(PersistInfo *pi) { - /* perms reftbl ... udata */ - lua_checkstack(pi->L, 2); - if(persistspecialobject(pi, 0)) { - /* perms reftbl ... udata */ - return; - } else { - /* Use literal persistence */ - size_t length = uvalue(getobject(pi->L, -1))->len; - write_size(pi, &length); - pi_write(pi, lua_touserdata(pi->L, -1), length, pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistuserdata %ld\n", (long) length); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistuserdata %ld\n", (long) length); -#endif - if(!lua_getmetatable(pi->L, -1)) { - /* perms reftbl ... udata */ - lua_pushnil(pi->L); - /* perms reftbl ... udata mt/nil */ - } - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... udata */ - } -} - - -static Proto *toproto(lua_State *L, int stackpos) -{ - return gco2p(getobject(L, stackpos)->value.gc); -} - -static UpVal *toupval(lua_State *L, int stackpos) -{ - lua_assert(ttype(getobject(L, stackpos)) == LUA_TUPVAL); - return gco2uv(getobject(L, stackpos)->value.gc); -} - -static void pushproto(lua_State *L, Proto *proto) -{ - TValue o; - setptvalue(L, &o, proto); - LIF(A,pushobject)(L, &o); -} - -#define setuvvalue(L,obj,x) \ - { TValue *i_o=(obj); \ - i_o->value.gc=cast(GCObject *, (x)); i_o->tt=LUA_TUPVAL; \ - checkliveness(G(L),i_o); } - -static void pushupval(lua_State *L, UpVal *upval) -{ - TValue o; - setuvvalue(L, &o, upval); - LIF(A,pushobject)(L, &o); -} - -static void pushclosure(lua_State *L, Closure *closure) -{ - TValue o; - setclvalue(L, &o, closure); - LIF(A,pushobject)(L, &o); -} - -static void pushstring(lua_State *L, TString *s) -{ - TValue o; - setsvalue(L, &o, s); - LIF(A,pushobject)(L, &o); -} - -static void persistfunction(PersistInfo *pi) -{ - /* perms reftbl ... func */ - Closure *cl = clvalue(getobject(pi->L, -1)); - lua_checkstack(pi->L, 2); - if(cl->c.isC) { - /* It's a C function. For now, we aren't going to allow - * persistence of C closures, even if the "C proto" is - * already in the permanents table. */ - lua_pushstring(pi->L, "Attempt to persist a C function"); - lua_error(pi->L); - } else { - /* It's a Lua closure. */ - { - /* We don't really _NEED_ the number of upvals, - * but it'll simplify things a bit */ - pi_write(pi, &cl->l.p->nups, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistfunction_number_upvalues %d\n", (int) cl->l.p->nups); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistfunction_number_upvalues %d\n", (int) cl->l.p->nups); -#endif - } - /* Persist prototype */ - { - pushproto(pi->L, cl->l.p); - /* perms reftbl ... func proto */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... func */ - } - /* Persist upvalue values (not the upvalue objects - * themselves) */ - { - int i; - for(i=0; il.p->nups; i++) { - /* perms reftbl ... func */ - pushupval(pi->L, cl->l.upvals[i]); - /* perms reftbl ... func upval */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... func */ - } - /* perms reftbl ... func */ - } - /* Persist function environment */ - { - lua_getfenv(pi->L, -1); - /* perms reftbl ... func fenv */ - if(lua_equal(pi->L, -1, LUA_GLOBALSINDEX)) { - /* Function has the default fenv */ - /* perms reftbl ... func _G */ - lua_pop(pi->L, 1); - /* perms reftbl ... func */ - lua_pushnil(pi->L); - /* perms reftbl ... func nil */ - } - /* perms reftbl ... func fenv/nil */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... func */ - } - } -} - - -/* Upvalues are tricky. Here's why. - * - * A particular upvalue may be either "open", in which case its member v - * points into a thread's stack, or "closed" in which case it points to the - * upvalue itself. An upvalue is closed under any of the following conditions: - * -- The function that initially declared the variable "local" returns - * -- The thread in which the closure was created is garbage collected - * - * To make things wackier, just because a thread is reachable by Lua doesn't - * mean it's in our root set. We need to be able to treat an open upvalue - * from an unreachable thread as a closed upvalue. - * - * The solution: - * (a) For the purposes of persisting, don't indicate whether an upvalue is - * closed or not. - * (b) When unpersisting, pretend that all upvalues are closed. - * (c) When persisting, persist all open upvalues referenced by a thread - * that is persisted, and tag each one with the corresponding stack position - * (d) When unpersisting, "reopen" each of these upvalues as the thread is - * unpersisted - */ -static void persistupval(PersistInfo *pi) -{ - /* perms reftbl ... upval */ - UpVal *uv = toupval(pi->L, -1); - lua_checkstack(pi->L, 1); - - /* We can't permit the upval to linger around on the stack, as Lua - * will bail if its GC finds it. */ - - lua_pop(pi->L, 1); - /* perms reftbl ... */ - LIF(A,pushobject)(pi->L, uv->v); - /* perms reftbl ... obj */ - persist(pi); - /* perms reftbl ... obj */ -} - -static void persistproto(PersistInfo *pi) -{ - /* perms reftbl ... proto */ - Proto *p = toproto(pi->L, -1); - lua_checkstack(pi->L, 2); - - /* Persist constant refs */ - { - int i; - pi_write(pi, &p->sizek, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_sizek %d\n", p->sizek); - hrOut(pi); - } - #ifdef TOTEXT - printf("persistproto_sizek %d\n", p->sizek); - #endif - for(i=0; isizek; i++) { - LIF(A,pushobject)(pi->L, &p->k[i]); - /* perms reftbl ... proto const */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... proto */ - } - } - /* perms reftbl ... proto */ - - /* serialize inner Proto refs */ - { - int i; - pi_write(pi, &p->sizep, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_sizep %d\n", p->sizep); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_sizep %d\n", p->sizep); -#endif - for(i=0; isizep; i++) - { - pushproto(pi->L, p->p[i]); - /* perms reftbl ... proto subproto */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... proto */ - } - } - /* perms reftbl ... proto */ - - /* Serialize code */ - { - int len; - pi_write(pi, &p->sizecode, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_sizecode %d\n", p->sizecode); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_sizecode %d\n", p->sizecode); -#endif - len = sizeof(Instruction) * p->sizecode; - pi_write(pi, p->code, len, pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_code %d\n", len); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_code %d\n", len); -#endif - } - - /* Serialize upvalue names */ - { - int i; - pi_write(pi, &p->sizeupvalues, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_upvalues %d\n", p->sizeupvalues); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_upvalues %d\n", p->sizeupvalues); -#endif - for(i=0; isizeupvalues; i++) - { - pushstring(pi->L, p->upvalues[i]); - persist(pi); - lua_pop(pi->L, 1); - } - } - /* Serialize local variable infos */ - { - int i; - pi_write(pi, &p->sizelocvars, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_sizelocvars %d\n", p->sizelocvars); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_sizelocvars %d\n", p->sizelocvars); -#endif - for(i=0; isizelocvars; i++) - { - pushstring(pi->L, p->locvars[i].varname); - persist(pi); - lua_pop(pi->L, 1); - - pi_write(pi, &p->locvars[i].startpc, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_startpc %d\n", p->locvars[i].startpc); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_startpc %d\n", p->locvars[i].startpc); -#endif - pi_write(pi, &p->locvars[i].endpc, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_endpc %d\n", p->locvars[i].endpc); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_endpc %d\n", p->locvars[i].endpc); -#endif - } - } - - /* Serialize source string */ - pushstring(pi->L, p->source); - persist(pi); - lua_pop(pi->L, 1); - - /* Serialize line numbers */ - { - pi_write(pi, &p->sizelineinfo, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_sizelineinfo %d\n", p->sizelineinfo); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_sizelineinfo %d\n", p->sizelineinfo); -#endif - if (p->sizelineinfo) - { - int len; - len = sizeof(int) * p->sizelineinfo; - pi_write(pi, p->lineinfo, len, pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_lineinfo %d\n", len); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_lineinfo %d\n", len); -#endif - } - } - - /* Serialize linedefined and lastlinedefined */ - pi_write(pi, &p->linedefined, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_linedefined %d\n", p->linedefined); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_linedefined %d\n", p->linedefined); -#endif - pi_write(pi, &p->lastlinedefined, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_lastlinedefined %d\n", p->lastlinedefined); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_lastlinedefined %d\n", p->lastlinedefined); -#endif - - /* Serialize misc values */ - { - pi_write(pi, &p->nups, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_nups %d\n", (int) p->nups); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_nups %d\n", (int) p->nups); -#endif - pi_write(pi, &p->numparams, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_numparams %d\n", (int) p->numparams); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_numparams %d\n", (int) p->numparams); -#endif - pi_write(pi, &p->is_vararg, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_is_vararg %d\n", (int) p->is_vararg); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_is_vararg %d\n", (int) p->is_vararg); -#endif - pi_write(pi, &p->maxstacksize, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistproto_maxstacksize %d\n", (int) p->maxstacksize); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistproto_maxstacksize %d\n", (int) p->maxstacksize); -#endif - } - /* We do not currently persist upvalue names, local variable names, - * variable lifetimes, line info, or source code. */ -} - -/* Copies a stack, but the stack is reversed in the process - */ -static size_t revappendstack(lua_State *from, lua_State *to) -{ - StkId o; - for(o=from->top-1; o>=from->stack; o--) { - setobj2s(to, to->top, o); - to->top++; - } - return from->top - from->stack; -} - -/* Persist all stack members - */ -static void persistthread(PersistInfo *pi) -{ - size_t posremaining; - lua_State *L2; - /* perms reftbl ... thr */ - L2 = lua_tothread(pi->L, -1); - lua_checkstack(pi->L, L2->top - L2->stack + 1); - if(pi->L == L2) { - lua_pushstring(pi->L, "Can't persist currently running thread"); - lua_error(pi->L); - return; /* not reached */ - } - - /* Persist the stack */ - posremaining = revappendstack(L2, pi->L); - /* perms reftbl ... thr (rev'ed contents of L2) */ - write_size(pi, &posremaining); - for(; posremaining > 0; posremaining--) { - persist(pi); - lua_pop(pi->L, 1); - } - /* perms reftbl ... thr */ - /* Now, persist the CallInfo stack. */ - { - size_t i, numframes = (L2->ci - L2->base_ci) + 1; - write_size(pi, &numframes); - for(i=0; ibase_ci + i; - size_t stackbase = ci->base - L2->stack; - size_t stackfunc = ci->func - L2->stack; - size_t stacktop = ci->top - L2->stack; - size_t savedpc = (ci != L2->base_ci) ? - ci->savedpc - ci_func(ci)->l.p->code : - 0; - write_size(pi, &stackbase); - write_size(pi, &stackfunc); - write_size(pi, &stacktop); - pi_write(pi, &ci->nresults, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistthread %d\n", ci->nresults); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistthread %d\n", ci->nresults); -#endif - write_size(pi, &savedpc); - } - } - - /* Serialize the state's other parameters, with the exception of upval stuff */ - { - size_t stackbase = L2->base - L2->stack; - size_t stacktop = L2->top - L2->stack; - lua_assert(L2->nCcalls <= 1); - pi_write(pi, &L2->status, sizeof(lu_byte), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistthread_status %d\n", (int) L2->status); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistthread_status %d\n", (int) L2->status); -#endif - write_size(pi, &stackbase); - write_size(pi, &stacktop); - - // ptrdiff_t changes sizes based on 32/64 bit - // Hard cast to 64 bit size if SIZE64 is defined -#ifdef SIZES64 - uint64 ptrIndex = static_cast(L2->errfunc); - pi_write(pi, &ptrIndex, sizeof(uint64), pi->ud); -#else - pi_write(pi, &L2->errfunc, sizeof(ptrdiff_t), pi->ud); -#endif - //write_size(pi, (size_t *)&L2->errfunc); - } - - /* Finally, record upvalues which need to be reopened */ - /* See the comment above persistupval() for why we do this */ - { - GCObject *gco; - UpVal *uv; - /* perms reftbl ... thr */ - for(gco = L2->openupval; gco != NULL; gco = uv->next) { - size_t stackpos; - uv = gco2uv(gco); - - /* Make sure upvalue is really open */ - lua_assert(uv->v != &uv->u.value); - pushupval(pi->L, uv); - /* perms reftbl ... thr uv */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... thr */ - stackpos = uv->v - L2->stack; - write_size(pi, &stackpos); - } - /* perms reftbl ... thr */ - lua_pushnil(pi->L); - /* perms reftbl ... thr nil */ - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... thr */ - } - /* perms reftbl ... thr */ -} - -static void persistboolean(PersistInfo *pi) -{ - int b = lua_toboolean(pi->L, -1); - pi_write(pi, &b, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistboolean %d\n", b); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistboolean %d\n", b); -#endif -} - -static void persistlightuserdata(PersistInfo *pi) -{ - void *p = lua_touserdata(pi->L, -1); - pi_write(pi, &p, sizeof(void *), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistlightuserdata %p\n", p); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistlightuserdata %d\n", (int) p); -#endif -} - -static void persistnumber(PersistInfo *pi) -{ - lua_Number n = lua_tonumber(pi->L, -1); - pi_write(pi, &n, sizeof(lua_Number), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persistnumber %d (%d)\n", (int) n, (int) sizeof(lua_Number)); - hrOut(pi); - } -#ifdef TOTEXT - printf("persistnumber %d (%d)\n", (int) n, (int) sizeof(lua_Number)); -#endif -} - -static void persiststring(PersistInfo *pi) -{ - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persiststring\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persiststring\n"); -#endif - size_t length = lua_strlen(pi->L, -1); - write_size(pi, &length); - const char* s = lua_tostring(pi->L, -1); - pi_write(pi, s, length, pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persiststring %d \"%s\"\n", (int)length, s); - hrOut(pi); - } -#ifdef TOTEXT - printf("persiststring %d \"%s\"\n", length, s); -#endif -} - -/* Top-level delegating persist function - */ -static void persist(PersistInfo *pi) -{ - /* perms reftbl ... obj */ - lua_checkstack(pi->L, 2); - /* If the object has already been written, write a reference to it */ - lua_pushvalue(pi->L, -1); - /* perms reftbl ... obj obj */ - lua_rawget(pi->L, 2); - /* perms reftbl ... obj ref? */ - if(!lua_isnil(pi->L, -1)) { - /* perms reftbl ... obj ref */ - int zero = 0; - pi_write(pi, &zero, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_seenobject\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_seenobject\n"); -#endif - int *ref = (int *)lua_touserdata(pi->L, -1); - pi_write(pi, ref, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_touserdata_ref %d\n", ref); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_touserdata_ref %d\n", ref); -#endif - lua_pop(pi->L, 1); - /* perms reftbl ... obj ref */ -#ifdef PLUTO_DEBUG - printindent(pi->level); - printf("0 %d\n", ref); -#endif - return; - } - /* perms reftbl ... obj nil */ - lua_pop(pi->L, 1); - /* perms reftbl ... obj */ - /* If the object is nil, write the pseudoreference 0 */ - if(lua_isnil(pi->L, -1)) { - int zero = 0; - /* firsttime */ - pi_write(pi, &zero, sizeof(int), pi->ud); - /* ref */ - pi_write(pi, &zero, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_nil (last 2 lines)\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_nil (last 2 lines)\n"); -#endif -#ifdef PLUTO_DEBUG - printindent(pi->level); - printf("0 0\n"); -#endif - return; - } - { - /* indicate that it's the first time */ - int one = 1; - pi_write(pi, &one, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_newobject\n"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_newobject\n"); -#endif - } - lua_pushvalue(pi->L, -1); - /* perms reftbl ... obj obj */ - int *ref = (int *)lua_newuserdata(pi->L, sizeof(int)); - *ref = ++(pi->counter); - /* perms reftbl ... obj obj ref */ - lua_rawset(pi->L, 2); - /* perms reftbl ... obj */ - - pi_write(pi, &pi->counter, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_counter %d\n", pi->counter); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_counter %d\n", pi->counter); -#endif - - - /* At this point, we'll give the permanents table a chance to play. */ - { - lua_pushvalue(pi->L, -1); - /* perms reftbl ... obj obj */ - lua_gettable(pi->L, 1); - /* perms reftbl ... obj permkey? */ - if(!lua_isnil(pi->L, -1)) { - /* perms reftbl ... obj permkey */ - int type = PLUTO_TPERMANENT; -#ifdef PLUTO_DEBUG - printindent(pi->level); - printf("1 %d PERM\n", pi->counter); - pi->level++; -#endif - pi_write(pi, &type, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist_permtype %d\n", type); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist_permtype %d\n", type); -#endif - persist(pi); - lua_pop(pi->L, 1); - /* perms reftbl ... obj */ -#ifdef PLUTO_DEBUG - pi->level--; -#endif - return; - } else { - /* perms reftbl ... obj nil */ - lua_pop(pi->L, 1); - /* perms reftbl ... obj */ - } - /* perms reftbl ... obj */ - } - { - int type = lua_type(pi->L, -1); - pi_write(pi, &type, sizeof(int), pi->ud); - if (humanReadable) { - snprintf(hrBuf, hrBufSize, "persist %s\n", type >= 0 && type < NUMTYPES ? typenames[type] : "?"); - hrOut(pi); - } -#ifdef TOTEXT - printf("persist %s\n", type >= 0 && type < NUMTYPES ? typenames[type] : "?"); -#endif - -#ifdef PLUTO_DEBUG - printindent(pi->level); - printf("1 %d %d\n", pi->counter, type); - pi->level++; -#endif - } - - switch(lua_type(pi->L, -1)) { - case LUA_TBOOLEAN: - persistboolean(pi); - break; - case LUA_TLIGHTUSERDATA: - persistlightuserdata(pi); - break; - case LUA_TNUMBER: - persistnumber(pi); - break; - case LUA_TSTRING: - persiststring(pi); - break; - case LUA_TTABLE: - persisttable(pi); - break; - case LUA_TFUNCTION: - persistfunction(pi); - break; - case LUA_TTHREAD: - persistthread(pi); - break; - case LUA_TPROTO: - persistproto(pi); - break; - case LUA_TUPVAL: - persistupval(pi); - break; - case LUA_TUSERDATA: - persistuserdata(pi); - break; - default: - lua_assert(0); - } -#ifdef PLUTO_DEBUG - pi->level--; -#endif -} - -void pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud) -{ - PersistInfo pi; - - pi.counter = 0; - pi.L = L; - pi.writer = writer; - pi.ud = ud; -#ifdef PLUTO_DEBUG - pi.level = 0; -#endif - - lua_checkstack(L, 4); - /* perms? rootobj? ...? */ - lua_assert(lua_gettop(L) == 2); - /* perms rootobj */ - lua_assert(!lua_isnil(L, 2)); - /* perms rootobj */ - lua_newtable(L); - /* perms rootobj reftbl */ - - /* Now we're going to make the table weakly keyed. This prevents the - * GC from visiting it and trying to mark things it doesn't want to - * mark in tables, e.g. upvalues. All objects in the table are - * a priori reachable, so it doesn't matter that we do this. */ - lua_newtable(L); - /* perms rootobj reftbl mt */ - lua_pushstring(L, "__mode"); - /* perms rootobj reftbl mt "__mode" */ - lua_pushstring(L, "k"); - /* perms rootobj reftbl mt "__mode" "k" */ - lua_settable(L, 4); - /* perms rootobj reftbl mt */ - lua_setmetatable(L, 3); - /* perms rootobj reftbl */ - lua_insert(L, 2); - /* perms reftbl rootobj */ - persist(&pi); - /* perms reftbl rootobj */ - lua_remove(L, 2); - /* perms rootobj */ -} - -typedef struct WriterInfo_t { - char* buf; - size_t buflen; -} WriterInfo; - -static int bufwriter (lua_State *L, const void *p, size_t sz, void *ud) { - const char *cp = (const char *)p; - WriterInfo *wi = (WriterInfo *)ud; - - LIF(M,reallocvector)(L, wi->buf, wi->buflen, wi->buflen+sz, char); - while(sz) - { - /* how dearly I love ugly C pointer twiddling */ - wi->buf[wi->buflen++] = *cp++; - sz--; - } - return 0; -} - -int persist_l(lua_State *L) -{ - /* perms? rootobj? ...? */ - WriterInfo wi; - - wi.buf = NULL; - wi.buflen = 0; - - lua_settop(L, 2); - /* perms? rootobj? */ - luaL_checktype(L, 1, LUA_TTABLE); - /* perms rootobj? */ - luaL_checktype(L, 1, LUA_TTABLE); - /* perms rootobj */ - - pluto_persist(L, bufwriter, &wi); - - lua_settop(L, 0); - /* (empty) */ - lua_pushlstring(L, wi.buf, wi.buflen); - /* str */ - pdep_freearray(L, wi.buf, wi.buflen, char); - return 1; -} - -typedef struct UnpersistInfo_t { - lua_State *L; - ZIO zio; -#ifdef PLUTO_DEBUG - int level; -#endif -} UnpersistInfo; - -static void unpersist(UnpersistInfo *upi); - -/* The object is left on the stack. This is primarily used by unpersist, but - * may be used by GCed objects that may incur cycles in order to preregister - * the object. */ -static void registerobject(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... obj */ - lua_checkstack(upi->L, 2); - lua_pushlightuserdata(upi->L, (void *)ref); - /* perms reftbl ... obj ref */ - lua_pushvalue(upi->L, -2); - /* perms reftbl ... obj ref obj */ - lua_settable(upi->L, 2); - /* perms reftbl ... obj */ -} - -static void unpersistboolean(UnpersistInfo *upi) -{ - /* perms reftbl ... */ - int b; - lua_checkstack(upi->L, 1); - verify(LIF(Z,read)(&upi->zio, &b, sizeof(int)) == 0); - lua_pushboolean(upi->L, b); - /* perms reftbl ... bool */ -} - -static void unpersistlightuserdata(UnpersistInfo *upi) -{ - /* perms reftbl ... */ - void *p; - lua_checkstack(upi->L, 1); - verify(LIF(Z,read)(&upi->zio, &p, sizeof(void *)) == 0); - lua_pushlightuserdata(upi->L, p); - /* perms reftbl ... ludata */ -} - -static void unpersistnumber(UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_Number n; - lua_checkstack(upi->L, 1); - verify(LIF(Z,read)(&upi->zio, &n, sizeof(lua_Number)) == 0); - lua_pushnumber(upi->L, n); - /* perms reftbl ... num */ -} - -static void unpersiststring(UnpersistInfo *upi) -{ - /* perms reftbl sptbl ref */ - /*int length;*/ - size_t length; - char* string; - lua_checkstack(upi->L, 1); - /*verify(LIF(Z,read)(&upi->zio, &length, sizeof(int)) == 0);*/ - /*verify(LIF(Z,read)(&upi->zio, &length, sizeof(size_t)) == 0);*/ - read_size(&upi->zio, &length); - string = pdep_newvector(upi->L, length, char); - verify(LIF(Z,read)(&upi->zio, string, length) == 0); - lua_pushlstring(upi->L, string, length); - /* perms reftbl sptbl ref str */ - pdep_freearray(upi->L, string, length, char); -} - -static void unpersistspecialtable(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_checkstack(upi->L, 1); - unpersist(upi); - /* perms reftbl ... spfunc? */ - lua_assert(lua_isfunction(upi->L, -1)); - /* perms reftbl ... spfunc */ - lua_call(upi->L, 0, 1); - /* perms reftbl ... tbl? */ - lua_assert(lua_istable(upi->L, -1)); - /* perms reftbl ... tbl */ -} - -static void unpersistliteraltable(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_checkstack(upi->L, 3); - /* Preregister table for handling of cycles */ - lua_newtable(upi->L); - /* perms reftbl ... tbl */ - registerobject(ref, upi); - /* perms reftbl ... tbl */ - /* Unpersist metatable */ - { - unpersist(upi); - /* perms reftbl ... tbl mt/nil? */ - if(lua_istable(upi->L, -1)) { - /* perms reftbl ... tbl mt */ - lua_setmetatable(upi->L, -2); - /* perms reftbl ... tbl */ - } else { - /* perms reftbl ... tbl nil? */ - lua_assert(lua_isnil(upi->L, -1)); - /* perms reftbl ... tbl nil */ - lua_pop(upi->L, 1); - /* perms reftbl ... tbl */ - } - /* perms reftbl ... tbl */ - } - - while(1) - { - /* perms reftbl ... tbl */ - unpersist(upi); - /* perms reftbl ... tbl key/nil */ - if(lua_isnil(upi->L, -1)) { - /* perms reftbl ... tbl nil */ - lua_pop(upi->L, 1); - /* perms reftbl ... tbl */ - break; - } - /* perms reftbl ... tbl key */ - unpersist(upi); - /* perms reftbl ... tbl key value? */ - lua_assert(!lua_isnil(upi->L, -1)); - /* perms reftbl ... tbl key value */ - lua_rawset(upi->L, -3); - /* perms reftbl ... tbl */ - } -} - -static void unpersisttable(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_checkstack(upi->L, 1); - { - int isspecial; - verify(LIF(Z,read)(&upi->zio, &isspecial, sizeof(int)) == 0); - if(isspecial) { - unpersistspecialtable(ref, upi); - /* perms reftbl ... tbl */ - } else { - unpersistliteraltable(ref, upi); - /* perms reftbl ... tbl */ - } - /* perms reftbl ... tbl */ - } -} - -static UpVal *makeupval(lua_State *L, int stackpos) -{ - UpVal *uv = pdep_new(L, UpVal); - pdep_link(L, (GCObject *)uv, LUA_TUPVAL); - uv->tt = LUA_TUPVAL; - uv->v = &uv->u.value; - uv->u.l.prev = NULL; - uv->u.l.next = NULL; - setobj(L, uv->v, getobject(L, stackpos)); - return uv; -} - -static Proto *makefakeproto(lua_State *L, lu_byte nups) -{ - Proto *p = pdep_newproto(L); - p->sizelineinfo = 1; - p->lineinfo = pdep_newvector(L, 1, int); - p->lineinfo[0] = 1; - p->sizecode = 1; - p->code = pdep_newvector(L, 1, Instruction); - p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); - p->source = pdep_newlstr(L, "", 0); - p->maxstacksize = 2; - p->nups = nups; - p->sizek = 0; - p->sizep = 0; - - return p; -} - -/* The GC is not fond of finding upvalues in tables. We get around this - * during persistence using a weakly keyed table, so that the GC doesn't - * bother to mark them. This won't work in unpersisting, however, since - * if we make the values weak they'll be collected (since nothing else - * references them). Our solution, during unpersisting, is to represent - * upvalues as dummy functions, each with one upvalue. */ -static void boxupval_start(lua_State *L) -{ - LClosure *lcl; - lcl = (LClosure *)pdep_newLclosure(L, 1, hvalue(&L->l_gt)); - pushclosure(L, (Closure *)lcl); - /* ... func */ - lcl->p = makefakeproto(L, 1); - - /* Temporarily initialize the upvalue to nil */ - - lua_pushnil(L); - lcl->upvals[0] = makeupval(L, -1); - lua_pop(L, 1); -} - -static void boxupval_finish(lua_State *L) -{ - /* ... func obj */ - LClosure *lcl = (LClosure *) clvalue(getobject(L, -2)); - - lcl->upvals[0]->u.value = *getobject(L, -1); - lua_pop(L, 1); -} - - -static void unboxupval(lua_State *L) -{ - /* ... func */ - LClosure *lcl; - UpVal *uv; - - lcl = (LClosure *)clvalue(getobject(L, -1)); - uv = lcl->upvals[0]; - lua_pop(L, 1); - /* ... */ - pushupval(L, uv); - /* ... upval */ -} - -static void unpersistfunction(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - LClosure *lcl; - int i; - lu_byte nupvalues; - lua_checkstack(upi->L, 2); - - verify(LIF(Z,read)(&upi->zio, &nupvalues, sizeof(lu_byte)) == 0); - - lcl = (LClosure *)pdep_newLclosure(upi->L, nupvalues, hvalue(&upi->L->l_gt)); - pushclosure(upi->L, (Closure *)lcl); - - /* perms reftbl ... func */ - /* Put *some* proto in the closure, before the GC can find it */ - lcl->p = makefakeproto(upi->L, nupvalues); - - /* Also, we need to temporarily fill the upvalues */ - lua_pushnil(upi->L); - /* perms reftbl ... func nil */ - for(i=0; iupvals[i] = makeupval(upi->L, -1); - } - lua_pop(upi->L, 1); - /* perms reftbl ... func */ - - /* I can't see offhand how a function would ever get to be self- - * referential, but just in case let's register it early */ - registerobject(ref, upi); - - /* Now that it's safe, we can get the real proto */ - unpersist(upi); - /* perms reftbl ... func proto? */ - lua_assert(lua_type(upi->L, -1) == LUA_TPROTO); - /* perms reftbl ... func proto */ - lcl->p = toproto(upi->L, -1); - lua_pop(upi->L, 1); - /* perms reftbl ... func */ - - for(i=0; iL); - /* perms reftbl ... func upval */ - lcl->upvals[i] = toupval(upi->L, -1); - lua_pop(upi->L, 1); - /* perms reftbl ... func */ - } - /* perms reftbl ... func */ - - /* Finally, the fenv */ - unpersist(upi); - /* perms reftbl ... func fenv/nil? */ - lua_assert(lua_type(upi->L, -1) == LUA_TNIL || - lua_type(upi->L, -1) == LUA_TTABLE); - /* perms reftbl ... func fenv/nil */ - if(!lua_isnil(upi->L, -1)) { - /* perms reftbl ... func fenv */ - lua_setfenv(upi->L, -2); - /* perms reftbl ... func */ - } else { - /* perms reftbl ... func nil */ - lua_pop(upi->L, 1); - /* perms reftbl ... func */ - } - /* perms reftbl ... func */ -} - -static void unpersistupval(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_checkstack(upi->L, 2); - - boxupval_start(upi->L); - /* perms reftbl ... func */ - registerobject(ref, upi); - - unpersist(upi); - /* perms reftbl ... func obj */ - boxupval_finish(upi->L); - /* perms reftbl ... func */ -} - -static void unpersistproto(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - Proto *p; - int i; - int sizep, sizek; - - /* We have to be careful. The GC expects a lot out of protos. In - * particular, we need to give the function a valid string for its - * source, and valid code, even before we actually read in the real - * code. */ - TString *source = pdep_newlstr(upi->L, "", 0); - p = pdep_newproto(upi->L); - p->source = source; - p->sizecode=1; - p->code = pdep_newvector(upi->L, 1, Instruction); - p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); - p->maxstacksize = 2; - p->sizek = 0; - p->sizep = 0; - - lua_checkstack(upi->L, 2); - - pushproto(upi->L, p); - /* perms reftbl ... proto */ - /* We don't need to register early, since protos can never ever be - * involved in cyclic references */ - - /* Read in constant references */ - { - verify(LIF(Z,read)(&upi->zio, &sizek, sizeof(int)) == 0); - LIF(M,reallocvector)(upi->L, p->k, 0, sizek, TValue); - for(i=0; iL, &p->k[i], getobject(upi->L, -1)); - p->sizek++; - lua_pop(upi->L, 1); - /* perms reftbl ... proto */ - } - /* perms reftbl ... proto */ - } - /* Read in sub-proto references */ - { - verify(LIF(Z,read)(&upi->zio, &sizep, sizeof(int)) == 0); - LIF(M,reallocvector)(upi->L, p->p, 0, sizep, Proto*); - for(i=0; ip[i] = toproto(upi->L, -1); - p->sizep++; - lua_pop(upi->L, 1); - /* perms reftbl ... proto */ - } - /* perms reftbl ... proto */ - } - - /* Read in code */ - { - verify(LIF(Z,read)(&upi->zio, &p->sizecode, sizeof(int)) == 0); - LIF(M,reallocvector)(upi->L, p->code, 1, p->sizecode, Instruction); - verify(LIF(Z,read)(&upi->zio, p->code, - sizeof(Instruction) * p->sizecode) == 0); - } - - /* Read in upvalue names */ - { - verify(LIF(Z,read)(&upi->zio, &p->sizeupvalues, sizeof(int)) == 0); - if (p->sizeupvalues) - { - LIF(M,reallocvector)(upi->L, p->upvalues, 0, p->sizeupvalues, TString *); - for(i=0; isizeupvalues; i++) - { - unpersist(upi); - p->upvalues[i] = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1))); - lua_pop(upi->L, 1); - } - } - } - - /* Read in local variable infos */ - { - verify(LIF(Z,read)(&upi->zio, &p->sizelocvars, sizeof(int)) == 0); - if (p->sizelocvars) - { - LIF(M,reallocvector)(upi->L, p->locvars, 0, p->sizelocvars, LocVar); - for(i=0; isizelocvars; i++) - { - unpersist(upi); - p->locvars[i].varname = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1))); - lua_pop(upi->L, 1); - - verify(LIF(Z,read)(&upi->zio, &p->locvars[i].startpc, sizeof(int)) == 0); - verify(LIF(Z,read)(&upi->zio, &p->locvars[i].endpc, sizeof(int)) == 0); - } - } - } - - /* Read in source string*/ - unpersist(upi); - p->source = pdep_newlstr(upi->L, lua_tostring(upi->L, -1), strlen(lua_tostring(upi->L, -1))); - lua_pop(upi->L, 1); - - /* Read in line numbers */ - { - verify(LIF(Z,read)(&upi->zio, &p->sizelineinfo, sizeof(int)) == 0); - if (p->sizelineinfo) - { - LIF(M,reallocvector)(upi->L, p->lineinfo, 0, p->sizelineinfo, int); - verify(LIF(Z,read)(&upi->zio, p->lineinfo, - sizeof(int) * p->sizelineinfo) == 0); - } - } - - /* Read in linedefined and lastlinedefined */ - verify(LIF(Z,read)(&upi->zio, &p->linedefined, sizeof(int)) == 0); - verify(LIF(Z,read)(&upi->zio, &p->lastlinedefined, sizeof(int)) == 0); - - /* Read in misc values */ - { - verify(LIF(Z,read)(&upi->zio, &p->nups, sizeof(lu_byte)) == 0); - verify(LIF(Z,read)(&upi->zio, &p->numparams, sizeof(lu_byte)) == 0); - verify(LIF(Z,read)(&upi->zio, &p->is_vararg, sizeof(lu_byte)) == 0); - verify(LIF(Z,read)(&upi->zio, &p->maxstacksize, sizeof(lu_byte)) == 0); - } -} - - -/* Does basically the opposite of luaC_link(). - * Right now this function is rather inefficient; it requires traversing the - * entire root GC set in order to find one object. If the GC list were doubly - * linked this would be much easier, but there's no reason for Lua to have - * that. */ -static void gcunlink(lua_State *L, GCObject *gco) -{ - GCObject *prevslot; - if(G(L)->rootgc == gco) { - G(L)->rootgc = G(L)->rootgc->gch.next; - return; - } - - prevslot = G(L)->rootgc; - while(prevslot->gch.next != gco) { - lua_assert(prevslot->gch.next != NULL); - prevslot = prevslot->gch.next; - } - - prevslot->gch.next = prevslot->gch.next->gch.next; -} - -/* FIXME __ALL__ field ordering */ -static void unpersistthread(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_State *L2; - size_t stacklimit = 0; - L2 = lua_newthread(upi->L); - lua_checkstack(upi->L, 3); - /* L1: perms reftbl ... thr */ - /* L2: (empty) */ - registerobject(ref, upi); - - /* First, deserialize the object stack. */ - { - size_t i, stacksize; - read_size(&upi->zio, &stacksize); - LIF(D,growstack)(L2, (int)stacksize); - /* Make sure that the first stack element (a nil, representing - * the imaginary top-level C function) is written to the very, - * very bottom of the stack */ - L2->top--; - for(i=0; iL, L2, stacksize); - /* L1: perms reftbl ... thr */ - /* L2: obj* */ - } - /* (hereafter, stacks refer to L1) */ - - /* Now, deserialize the CallInfo stack. */ - { - size_t i, numframes; - read_size(&upi->zio, &numframes); - LIF(D,reallocCI)(L2,numframes*2); - for(i=0; ibase_ci + i; - size_t stackbase, stackfunc, stacktop, savedpc; - read_size(&upi->zio, &stackbase); - read_size(&upi->zio, &stackfunc); - read_size(&upi->zio, &stacktop); - verify(LIF(Z,read)(&upi->zio, &ci->nresults, sizeof(int)) == 0); - read_size(&upi->zio, &savedpc); - - if(stacklimit < stacktop) - stacklimit = stacktop; - - ci->base = L2->stack+stackbase; - ci->func = L2->stack+stackfunc; - ci->top = L2->stack+stacktop; - ci->savedpc = (ci != L2->base_ci) ? - ci_func(ci)->l.p->code+savedpc : - 0; - ci->tailcalls = 0; - /* Update the pointer each time, to keep the GC - * happy*/ - L2->ci = ci; - } - } - /* perms reftbl ... thr */ - /* Deserialize the state's other parameters, with the exception of upval stuff */ - { - size_t stackbase, stacktop; - L2->savedpc = L2->ci->savedpc; - verify(LIF(Z,read)(&upi->zio, &L2->status, sizeof(lu_byte)) == 0); - read_size(&upi->zio, &stackbase); - read_size(&upi->zio, &stacktop); - -#ifdef SIZES64 - uint64 value; - verify(LIF(Z,read)(&upi->zio, &value, sizeof(uint64)) == 0); - - L2->errfunc = static_cast(value); -#else - verify(LIF(Z,read)(&upi->zio, &L2->errfunc, sizeof(ptrdiff_t)) == 0); -#endif - - //read_size(&upi->zio, (size_t *)&L2->errfunc); - L2->base = L2->stack + stackbase; - L2->top = L2->stack + stacktop; - } - /* Finally, "reopen" upvalues (see persistupval() for why) */ - { - UpVal* uv; - GCObject **nextslot = &L2->openupval; - global_State *g = G(L2); - while(1) { - size_t stackpos; - unpersist(upi); - /* perms reftbl ... thr uv/nil */ - if(lua_isnil(upi->L, -1)) { - /* perms reftbl ... thr nil */ - lua_pop(upi->L, 1); - /* perms reftbl ... thr */ - break; - } - /* perms reftbl ... thr boxeduv */ - unboxupval(upi->L); - /* perms reftbl ... thr uv */ - uv = toupval(upi->L, -1); - lua_pop(upi->L, 1); - /* perms reftbl ... thr */ - - read_size(&upi->zio, &stackpos); - uv->v = L2->stack + stackpos; - gcunlink(upi->L, (GCObject *)uv); - uv->marked = luaC_white(g); - *nextslot = (GCObject *)uv; - nextslot = &uv->next; - uv->u.l.prev = &G(L2)->uvhead; - uv->u.l.next = G(L2)->uvhead.u.l.next; - uv->u.l.next->u.l.prev = uv; - G(L2)->uvhead.u.l.next = uv; - lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); - } - *nextslot = NULL; - } - - /* The stack must be valid at least to the highest value among the CallInfos */ - /* 'top' and the values up to there must be filled with 'nil' */ - { - StkId o; - LIF(D,checkstack)(L2, (int)stacklimit); - for (o = L2->top; o <= L2->top + stacklimit; o++) - setnilvalue(o); - } -} - -static void unpersistuserdata(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - int isspecial; - lua_checkstack(upi->L, 2); - verify(LIF(Z,read)(&upi->zio, &isspecial, sizeof(int)) == 0); - if(isspecial) { - unpersist(upi); - /* perms reftbl ... spfunc? */ - lua_assert(lua_isfunction(upi->L, -1)); - /* perms reftbl ... spfunc */ -#ifdef PLUTO_PASS_USERDATA_TO_PERSIST - lua_pushlightuserdata(upi->L, &upi->zio); - lua_call(upi->L, 1, 1); -#else - lua_call(upi->L, 0, 1); -#endif - /* perms reftbl ... udata? */ -/* This assertion might not be necessary; it's conceivable, for - * example, that the SP function might decide to return a table - * with equivalent functionality. For the time being, we'll - * ignore this possibility in favor of stricter and more testable - * requirements. */ - lua_assert(lua_isuserdata(upi->L, -1)); - /* perms reftbl ... udata */ - } else { - size_t length; - read_size(&upi->zio, &length); - - lua_newuserdata(upi->L, length); - /* perms reftbl ... udata */ - registerobject(ref, upi); - verify(LIF(Z,read)(&upi->zio, lua_touserdata(upi->L, -1), length) == 0); - - unpersist(upi); - /* perms reftbl ... udata mt/nil? */ - lua_assert(lua_istable(upi->L, -1) || lua_isnil(upi->L, -1)); - /* perms reftbl ... udata mt/nil */ - lua_setmetatable(upi->L, -2); - /* perms reftbl ... udata */ - } - /* perms reftbl ... udata */ -} - -static void unpersistpermanent(int ref, UnpersistInfo *upi) -{ - /* perms reftbl ... */ - lua_checkstack(upi->L, 2); - unpersist(upi); - /* perms reftbl permkey */ - lua_gettable(upi->L, 1); - /* perms reftbl perm? */ - /* We assume currently that the substituted permanent value - * shouldn't be nil. This may be a bad assumption. Real-life - * experience is needed to evaluate this. */ - lua_assert(!lua_isnil(upi->L, -1)); - /* perms reftbl perm */ -} - -#if 0 -/* For debugging only; not called when lua_assert is empty */ -static int inreftable(lua_State *L, int ref) -{ - int res; - lua_checkstack(L, 1); - /* perms reftbl ... */ - lua_pushlightuserdata(L, (void *)ref); - /* perms reftbl ... ref */ - lua_gettable(L, 2); - /* perms reftbl ... obj? */ - res = !lua_isnil(L, -1); - lua_pop(L, 1); - /* perms reftbl ... */ - return res; -} -#endif - -static void unpersist(UnpersistInfo *upi) -{ - /* perms reftbl ... */ - int firstTime; - int stacksize = lua_gettop(upi->L); stacksize = stacksize; /* DEBUG */ - lua_checkstack(upi->L, 2); - LIF(Z,read)(&upi->zio, &firstTime, sizeof(int)); - if(firstTime) { - int ref; - int type; - LIF(Z,read)(&upi->zio, &ref, sizeof(int)); - lua_assert(!inreftable(upi->L, ref)); - LIF(Z,read)(&upi->zio, &type, sizeof(int)); -#ifdef PLUTO_DEBUG - printindent(upi->level); - printf("1 %d %d\n", ref, type); - upi->level++; -#endif - switch(type) { - case LUA_TBOOLEAN: - unpersistboolean(upi); - break; - case LUA_TLIGHTUSERDATA: - unpersistlightuserdata(upi); - break; - case LUA_TNUMBER: - unpersistnumber(upi); - break; - case LUA_TSTRING: - unpersiststring(upi); - break; - case LUA_TTABLE: - unpersisttable(ref, upi); - break; - case LUA_TFUNCTION: - unpersistfunction(ref, upi); - break; - case LUA_TTHREAD: - unpersistthread(ref, upi); - break; - case LUA_TPROTO: - unpersistproto(ref, upi); - break; - case LUA_TUPVAL: - unpersistupval(ref, upi); - break; - case LUA_TUSERDATA: - unpersistuserdata(ref, upi); - break; - case PLUTO_TPERMANENT: - unpersistpermanent(ref, upi); - break; - default: - lua_assert(0); - } - /* perms reftbl ... obj */ - lua_assert(lua_type(upi->L, -1) == type || - type == PLUTO_TPERMANENT || - /* Remember, upvalues get a special dispensation, as - * described in boxupval */ - (lua_type(upi->L, -1) == LUA_TFUNCTION && - type == LUA_TUPVAL)); - registerobject(ref, upi); - /* perms reftbl ... obj */ -#ifdef PLUTO_DEBUG - upi->level--; -#endif - } else { - int ref; - LIF(Z,read)(&upi->zio, &ref, sizeof(int)); -#ifdef PLUTO_DEBUG - printindent(upi->level); - printf("0 %d\n", ref); -#endif - if(ref == 0) { - lua_pushnil(upi->L); - /* perms reftbl ... nil */ - } else { - lua_pushlightuserdata(upi->L, (void *)ref); - /* perms reftbl ... ref */ - lua_gettable(upi->L, 2); - /* perms reftbl ... obj? */ - lua_assert(!lua_isnil(upi->L, -1)); - } - /* perms reftbl ... obj/nil */ - } - /* perms reftbl ... obj/nil */ - lua_assert(lua_gettop(upi->L) == stacksize + 1); -} - -void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud) -{ - /* We use the graciously provided ZIO (what the heck does the Z stand - * for?) library so that we don't have to deal with the reader directly. - * Letting the reader function decide how much data to return can be - * very unpleasant. - */ - UnpersistInfo upi; - upi.L = L; -#ifdef PLUTO_DEBUG - upi.level = 0; -#endif - - lua_checkstack(L, 3); - LIF(Z,init)(L, &upi.zio, reader, ud); - - /* perms */ - lua_newtable(L); - /* perms reftbl */ - lua_gc(L, LUA_GCSTOP, 0); - unpersist(&upi); - lua_gc(L, LUA_GCRESTART, 0); - /* perms reftbl rootobj */ - lua_replace(L, 2); - /* perms rootobj */ -} - -typedef struct LoadInfo_t { - char *buf; - size_t size; -} LoadInfo; - - -static const char *bufreader(lua_State *L, void *ud, size_t *sz) { - LoadInfo *li = (LoadInfo *)ud; - if(li->size == 0) { - return NULL; - } - *sz = li->size; - li->size = 0; - return li->buf; -} - -int unpersist_l(lua_State *L) -{ - LoadInfo li; - char const *origbuf; - char *tempbuf; - size_t bufsize; - /* perms? str? ...? */ - lua_settop(L, 2); - /* perms? str? */ - origbuf = luaL_checklstring(L, 2, &bufsize); - tempbuf = LIF(M,newvector)(L, bufsize, char); - memcpy(tempbuf, origbuf, bufsize); - - li.buf = tempbuf; - li.size = bufsize; - - /* perms? str */ - lua_pop(L, 1); - /* perms? */ - luaL_checktype(L, 1, LUA_TTABLE); - /* perms */ - pluto_unpersist(L, bufreader, &li); - /* perms rootobj */ - LIF(M,freearray)(L, tempbuf, bufsize, char); - return 1; -} - -/* Stefan's first C function for Lua! :) - Returns a string describing the Pluto version you're using. */ - -int version_l(lua_State *L) -{ - const char *version = VERSION; - - lua_settop(L, 0); - /* (empty) */ - lua_pushlstring(L, version, strlen(version)); - /* str */ - return 1; -} - -/* Set human-readable output on or off. */ -int human_l(lua_State *L) -{ - /* flag? ...? */ - lua_settop(L, 1); - /* flag? */ - /*luaL_checktype(L, 1, LUA_TBOOLEAN);*/ - /* flag */ - - humanReadable = lua_toboolean(L, 1); - - lua_settop(L, 0); - /* (empty) */ - return 0; -} - -static luaL_reg pluto_reg[] = { - { "persist", persist_l }, - { "unpersist", unpersist_l }, - { "version", version_l }, - { "human", human_l }, - { NULL, NULL } -}; - -LUALIB_API int luaopen_pluto(lua_State *L) { - luaL_openlib(L, "pluto", pluto_reg, 0); - return 1; -} diff --git a/engines/sword25/util/pluto/pluto.h b/engines/sword25/util/pluto/pluto.h deleted file mode 100644 index 3674842d44..0000000000 --- a/engines/sword25/util/pluto/pluto.h +++ /dev/null @@ -1,25 +0,0 @@ -/* $Id$ */ - -/* Pluto - Heavy-duty persistence for Lua - * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public - * domain. People making use of this software as part of an application - * are politely requested to email the author at sneftel@gmail.com - * with a brief description of the application, primarily to satisfy his - * curiosity. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* lua.h must be included before this file */ - -void pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud); - -void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud); - -LUALIB_API int luaopen_pluto(lua_State *L); diff --git a/engines/sword25/util/pluto/plzio.cpp b/engines/sword25/util/pluto/plzio.cpp deleted file mode 100644 index 21f69a9e8d..0000000000 --- a/engines/sword25/util/pluto/plzio.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* -** $Id$ -** a generic input stream interface -** See Copyright Notice in lua.h -*/ - - -#include - -#define lzio_c -#define LUA_CORE - -#include "pdep/pdep.h" - -int pdep_fill (ZIO *z) { - size_t size; - lua_State *L = z->L; - const char *buff; - lua_unlock(L); - buff = z->reader(L, z->data, &size); - lua_lock(L); - if (buff == NULL || size == 0) return EOZ; - z->n = size - 1; - z->p = buff; - return char2int(*(z->p++)); -} - - -int pdep_lookahead (ZIO *z) { - if (z->n == 0) { - if (pdep_fill(z) == EOZ) - return EOZ; - else { - z->n++; /* pdep_fill removed first byte; put back it */ - z->p--; - } - } - return char2int(*z->p); -} - - -void pdep_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { - z->L = L; - z->reader = reader; - z->data = data; - z->n = 0; - z->p = NULL; -} - - -/* --------------------------------------------------------------- read --- */ -size_t pdep_read (ZIO *z, void *b, size_t n) { - while (n) { - size_t m; - if (pdep_lookahead(z) == EOZ) - return n; /* return number of missing bytes */ - m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ - memcpy(b, z->p, m); - z->n -= m; - z->p += m; - b = (char *)b + m; - n -= m; - } - return 0; -} - -/* ------------------------------------------------------------------------ */ -char *pdep_openspace (lua_State *L, Mbuffer *buff, size_t n) { - if (n > buff->buffsize) { - if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; - pdep_resizebuffer(L, buff, n); - } - return buff->buffer; -} -- cgit v1.2.3 From eaff6a40f6f9cb8a5817c7b90a7e24c8c12da3fe Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 18:21:43 -0600 Subject: SWORD25: Correct include guards to reflect the changes to the file names --- engines/sword25/util/lua_persistence.h | 4 ++-- engines/sword25/util/lua_persistence_util.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engines/sword25/util/lua_persistence.h b/engines/sword25/util/lua_persistence.h index cf7d7e03ca..88cbb04ad2 100644 --- a/engines/sword25/util/lua_persistence.h +++ b/engines/sword25/util/lua_persistence.h @@ -20,8 +20,8 @@ * */ -#ifndef LUA_SERIALIZATION_H -#define LUA_SERIALIZATION_H +#ifndef LUA_PERSISTENCE_H +#define LUA_PERSISTENCE_H #include "sword25/util/lua/lua.h" diff --git a/engines/sword25/util/lua_persistence_util.h b/engines/sword25/util/lua_persistence_util.h index 345996f606..305eea4aaf 100644 --- a/engines/sword25/util/lua_persistence_util.h +++ b/engines/sword25/util/lua_persistence_util.h @@ -20,8 +20,8 @@ * */ -#ifndef LUA_SERIALIZATION_UTIL_H -#define LUA_SERIALIZATION_UTIL_H +#ifndef LUA_PERISTENCE_UTIL_H +#define LUA_PERISTENCE_UTIL_H struct lua_State; -- cgit v1.2.3 From 8ee75e1dc56681337a3ae98c9d207e70e28c5ff5 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 18:22:15 -0600 Subject: SWORD25: Add Pluto copyright message to new persistence code Since the code is based off the Pluto code --- engines/sword25/util/lua_persist.cpp | 24 ++++++++++++++ engines/sword25/util/lua_persistence.h | 23 +++++++++++++ engines/sword25/util/lua_persistence_util.cpp | 47 +++++++++++++++++++++++++++ engines/sword25/util/lua_persistence_util.h | 24 ++++++++++++++ engines/sword25/util/lua_unpersist.cpp | 24 ++++++++++++++ 5 files changed, 142 insertions(+) diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index 6d758067ad..aea4e70036 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -20,6 +20,30 @@ * */ +/** + * This code is heavily based on the Pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + + #include "sword25/util/lua_persistence.h" #include "sword25/util/double_serialization.h" diff --git a/engines/sword25/util/lua_persistence.h b/engines/sword25/util/lua_persistence.h index 88cbb04ad2..53e3dee02e 100644 --- a/engines/sword25/util/lua_persistence.h +++ b/engines/sword25/util/lua_persistence.h @@ -20,6 +20,29 @@ * */ +/** + * This code is heavily based on the Pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + #ifndef LUA_PERSISTENCE_H #define LUA_PERSISTENCE_H diff --git a/engines/sword25/util/lua_persistence_util.cpp b/engines/sword25/util/lua_persistence_util.cpp index 8365f5d483..958fb7ac3c 100644 --- a/engines/sword25/util/lua_persistence_util.cpp +++ b/engines/sword25/util/lua_persistence_util.cpp @@ -20,6 +20,53 @@ * */ +/** + * This code is heavily based on the pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + +/** + * This code is heavily based on the Pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + + #include "sword25/util/lua_persistence_util.h" #include "common/scummsys.h" diff --git a/engines/sword25/util/lua_persistence_util.h b/engines/sword25/util/lua_persistence_util.h index 305eea4aaf..4d0085e242 100644 --- a/engines/sword25/util/lua_persistence_util.h +++ b/engines/sword25/util/lua_persistence_util.h @@ -20,6 +20,30 @@ * */ +/** + * This code is heavily based on the Pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + + #ifndef LUA_PERISTENCE_UTIL_H #define LUA_PERISTENCE_UTIL_H diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp index 8d644302f9..6f3275741a 100644 --- a/engines/sword25/util/lua_unpersist.cpp +++ b/engines/sword25/util/lua_unpersist.cpp @@ -20,6 +20,30 @@ * */ +/** + * This code is heavily based on the Pluto code base. Copyright below + */ + +/* Tamed Pluto - Heavy-duty persistence for Lua + * Copyright (C) 2004 by Ben Sunshine-Hill, and released into the public + * domain. People making use of this software as part of an application + * are politely requested to email the author at sneftel@gmail.com + * with a brief description of the application, primarily to satisfy his + * curiosity. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Instrumented by Stefan Reich (info@luaos.net) + * for Mobile Lua (http://luaos.net/pages/mobile-lua.php) + */ + + #include "sword25/util/lua_persistence.h" #include "sword25/util/double_serialization.h" -- cgit v1.2.3 From 9a4d62e76a29647ed7f2c0b16f009ff143fdf739 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 18:26:59 -0600 Subject: SWORD25: Change function names to use persist instead of serialize Same argument as in 97c35714ce3986b99848a780f6b195a63f8910b7. To match the rest of the SWORD25 code base --- engines/sword25/util/lua_persist.cpp | 98 +++++++++++++++---------------- engines/sword25/util/lua_unpersist.cpp | 102 ++++++++++++++++----------------- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index aea4e70036..6038111bbc 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -66,17 +66,17 @@ struct SerializationInfo { uint counter; }; -static void serialize(SerializationInfo *info); +static void persist(SerializationInfo *info); -static void serializeBoolean(SerializationInfo *info); -static void serializeNumber(SerializationInfo *info); -static void serializeString(SerializationInfo *info); -static void serializeTable(SerializationInfo *info); -static void serializeFunction(SerializationInfo *info); -static void serializeThread(SerializationInfo *info); -static void serializeProto(SerializationInfo *info); -static void serializeUpValue(SerializationInfo *info); -static void serializeUserData(SerializationInfo *info); +static void persistBoolean(SerializationInfo *info); +static void persistNumber(SerializationInfo *info); +static void persistString(SerializationInfo *info); +static void persistTable(SerializationInfo *info); +static void persistFunction(SerializationInfo *info); +static void persistThread(SerializationInfo *info); +static void persistProto(SerializationInfo *info); +static void persistUpValue(SerializationInfo *info); +static void persistUserData(SerializationInfo *info); void persistLua(lua_State *luaState, Common::WriteStream *writeStream) { @@ -127,14 +127,14 @@ void persistLua(lua_State *luaState, Common::WriteStream *writeStream) { // >>>>> permTbl indexTbl rootObj // Serialize the root recursively - serialize(&info); + persist(&info); // Return the stack back to the original state lua_remove(luaState, 2); // >>>>> permTbl rootObj } -static void serialize(SerializationInfo *info) { +static void persist(SerializationInfo *info) { // The stack can potentially have many things on it // The object we want to serialize is the item on the top of the stack // >>>>> permTbl indexTbl rootObj ...... obj @@ -215,7 +215,7 @@ static void serialize(SerializationInfo *info) { info->writeStream->writeSint32LE(PERMANENT_TYPE); // Serialize the key - serialize(info); + persist(info); // Pop the key off the stack lua_pop(info->luaState, 1); @@ -236,7 +236,7 @@ static void serialize(SerializationInfo *info) { switch (objType) { case LUA_TBOOLEAN: - serializeBoolean(info); + persistBoolean(info); break; case LUA_TLIGHTUSERDATA: // You can't serialize a pointer @@ -244,41 +244,41 @@ static void serialize(SerializationInfo *info) { assert(0); break; case LUA_TNUMBER: - serializeNumber(info); + persistNumber(info); break; case LUA_TSTRING: - serializeString(info); + persistString(info); break; case LUA_TTABLE: - serializeTable(info); + persistTable(info); break; case LUA_TFUNCTION: - serializeFunction(info); + persistFunction(info); break; case LUA_TTHREAD: - serializeThread(info); + persistThread(info); break; case LUA_TPROTO: - serializeProto(info); + persistProto(info); break; case LUA_TUPVAL: - serializeUpValue(info); + persistUpValue(info); break; case LUA_TUSERDATA: - serializeUserData(info); + persistUserData(info); break; default: assert(0); } } -static void serializeBoolean(SerializationInfo *info) { +static void persistBoolean(SerializationInfo *info) { int value = lua_toboolean(info->luaState, -1); info->writeStream->writeSint32LE(value); } -static void serializeNumber(SerializationInfo *info) { +static void persistNumber(SerializationInfo *info) { lua_Number value = lua_tonumber(info->luaState, -1); #if 1 @@ -298,7 +298,7 @@ static void serializeNumber(SerializationInfo *info) { } -static void serializeString(SerializationInfo *info) { +static void persistString(SerializationInfo *info) { // Hard cast to a uint32 to force size_t to an explicit size // *Theoretically* this could truncate, but if we have a 4gb string, we have bigger problems uint32 length = static_cast(lua_strlen(info->luaState, -1)); @@ -395,7 +395,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { info->writeStream->writeSint32LE(1); // Serialize the function - serialize(info); + persist(info); lua_pop(info->luaState, 2); // >>>>> permTbl indexTbl ...... obj @@ -403,7 +403,7 @@ static bool serializeSpecialObject(SerializationInfo *info, bool defaction) { return true; } -static void serializeTable(SerializationInfo *info) { +static void persistTable(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... tbl // Make sure there is enough room on the stack @@ -422,7 +422,7 @@ static void serializeTable(SerializationInfo *info) { } // >>>>> permTbl indexTbl ...... tbl metaTbl/nil */ - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl @@ -439,13 +439,13 @@ static void serializeTable(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... tbl k v k */ // Serialize the key - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl k v */ // Serialize the value - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl k */ @@ -457,13 +457,13 @@ static void serializeTable(SerializationInfo *info) { lua_pushnil(info->luaState); // >>>>> permTbl indexTbl ...... tbl - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... tbl } -static void serializeFunction(SerializationInfo *info) { +static void persistFunction(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... func Closure *cl = clvalue(getObject(info->luaState, -1)); lua_checkstack(info->luaState, 2); @@ -484,7 +484,7 @@ static void serializeFunction(SerializationInfo *info) { pushProto(info->luaState, cl->l.p); // >>>>> permTbl indexTbl ...... func proto */ - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func @@ -495,7 +495,7 @@ static void serializeFunction(SerializationInfo *info) { pushUpValue(info->luaState, cl->l.upvals[i]); // >>>>> permTbl indexTbl ...... func upval - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func @@ -519,14 +519,14 @@ static void serializeFunction(SerializationInfo *info) { } // >>>>> permTbl indexTbl ...... func fenv/nil - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... func } } -static void serializeThread(SerializationInfo *info) { +static void persistThread(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... thread lua_State *threadState = lua_tothread(info->luaState, -1); @@ -547,7 +547,7 @@ static void serializeThread(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... thread (reversed contents of thread stack) */ for (; stackSize > 0; --stackSize) { - serialize(info); + persist(info); lua_pop(info->luaState, 1); } @@ -609,7 +609,7 @@ static void serializeThread(SerializationInfo *info) { pushUpValue(info->luaState, upVal); // >>>>> permTbl indexTbl ...... thread upVal - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... thread @@ -624,13 +624,13 @@ static void serializeThread(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... thread nil // Use nil as a terminator - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... thread } -static void serializeProto(SerializationInfo *info) { +static void persistProto(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... proto Proto *proto = gco2p(getObject(info->luaState, -1)->value.gc); @@ -644,7 +644,7 @@ static void serializeProto(SerializationInfo *info) { pushObject(info->luaState, &proto->k[i]); // >>>>> permTbl indexTbl ...... proto const - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -660,7 +660,7 @@ static void serializeProto(SerializationInfo *info) { pushProto(info->luaState, proto->p[i]); // >>>>> permTbl indexTbl ...... proto subProto */ - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -683,7 +683,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->upvalues[i]); // >>>>> permTbl indexTbl ...... proto str - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -697,7 +697,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->locvars[i].varname); // >>>>> permTbl indexTbl ...... proto str - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -711,7 +711,7 @@ static void serializeProto(SerializationInfo *info) { pushString(info->luaState, proto->source); // >>>>> permTbl indexTbl ...... proto sourceStr - serialize(info); + persist(info); lua_pop(info->luaState, 1); // >>>>> permTbl indexTbl ...... proto @@ -757,7 +757,7 @@ static void serializeProto(SerializationInfo *info) { * (d) When unserializing, "reopen" each of these upvalues as the thread is * unserialized */ -static void serializeUpValue(SerializationInfo *info) { +static void persistUpValue(SerializationInfo *info) { // >>>>> permTbl indexTbl ...... upval assert(ttype(getObject(info->luaState, -1)) == LUA_TUPVAL); UpVal *upValue = gco2uv(getObject(info->luaState, -1)->value.gc); @@ -774,11 +774,11 @@ static void serializeUpValue(SerializationInfo *info) { pushObject(info->luaState, upValue->v); // >>>>> permTbl indexTbl ...... obj - serialize(info); + persist(info); // >>>>> permTbl indexTbl ...... obj } -static void serializeUserData(SerializationInfo *info) { +static void persistUserData(SerializationInfo *info) { // >>>>> permTbl rootObj ...... udata // Make sure there is enough room on the stack @@ -804,7 +804,7 @@ static void serializeUserData(SerializationInfo *info) { } // >>>>> permTbl rootObj ...... udata metaTbl/nil - serialize(info); + persist(info); lua_pop(info->luaState, 1); /* perms reftbl ... udata */ diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp index 6f3275741a..ef0ef31041 100644 --- a/engines/sword25/util/lua_unpersist.cpp +++ b/engines/sword25/util/lua_unpersist.cpp @@ -64,18 +64,18 @@ struct UnSerializationInfo { Common::ReadStream *readStream; }; -static void unserialize(UnSerializationInfo *info); +static void unpersist(UnSerializationInfo *info); -static void unserializeBoolean(UnSerializationInfo *info); -static void unserializeNumber(UnSerializationInfo *info); -static void unserializeString(UnSerializationInfo *info); -static void unserializeTable(UnSerializationInfo *info, int index); -static void unserializeFunction(UnSerializationInfo *info, int index); -static void unserializeThread(UnSerializationInfo *info, int index); -static void unserializeProto(UnSerializationInfo *info, int index); -static void unserializeUpValue(UnSerializationInfo *info, int index); -static void unserializeUserData(UnSerializationInfo *info, int index); -static void unserializePermanent(UnSerializationInfo *info, int index); +static void unpersistBoolean(UnSerializationInfo *info); +static void unpersistNumber(UnSerializationInfo *info); +static void unpersistString(UnSerializationInfo *info); +static void unpersistTable(UnSerializationInfo *info, int index); +static void unpersistFunction(UnSerializationInfo *info, int index); +static void unpersistThread(UnSerializationInfo *info, int index); +static void unpersistProto(UnSerializationInfo *info, int index); +static void unpersistUpValue(UnSerializationInfo *info, int index); +static void unpersistUserData(UnSerializationInfo *info, int index); +static void unpersistPermanent(UnSerializationInfo *info, int index); void unpersistLua(lua_State *luaState, Common::ReadStream *readStream) { @@ -98,7 +98,7 @@ void unpersistLua(lua_State *luaState, Common::ReadStream *readStream) { lua_gc(luaState, LUA_GCSTOP, 0); // Unserialize the root object - unserialize(&info); + unpersist(&info); // >>>>> permTbl indexTbl rootObj // Re-start garbage collection @@ -129,7 +129,7 @@ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... obj } -static void unserialize(UnSerializationInfo *info) { +static void unpersist(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -142,7 +142,7 @@ static void unserialize(UnSerializationInfo *info) { switch (type) { case LUA_TBOOLEAN: - unserializeBoolean(info); + unpersistBoolean(info); break; case LUA_TLIGHTUSERDATA: // You can't serialize a pointer @@ -150,31 +150,31 @@ static void unserialize(UnSerializationInfo *info) { assert(0); break; case LUA_TNUMBER: - unserializeNumber(info); + unpersistNumber(info); break; case LUA_TSTRING: - unserializeString(info); + unpersistString(info); break; case LUA_TTABLE: - unserializeTable(info, index); + unpersistTable(info, index); break; case LUA_TFUNCTION: - unserializeFunction(info, index); + unpersistFunction(info, index); break; case LUA_TTHREAD: - unserializeThread(info, index); + unpersistThread(info, index); break; case LUA_TPROTO: - unserializeProto(info, index); + unpersistProto(info, index); break; case LUA_TUPVAL: - unserializeUpValue(info, index); + unpersistUpValue(info, index); break; case LUA_TUSERDATA: - unserializeUserData(info, index); + unpersistUserData(info, index); break; case PERMANENT_TYPE: - unserializePermanent(info, index); + unpersistPermanent(info, index); break; default: assert(0); @@ -212,7 +212,7 @@ static void unserialize(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... obj/nil } -static void unserializeBoolean(UnSerializationInfo *info) { +static void unpersistBoolean(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -224,7 +224,7 @@ static void unserializeBoolean(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... bool } -static void unserializeNumber(UnSerializationInfo *info) { +static void unpersistNumber(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -242,7 +242,7 @@ static void unserializeNumber(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... num } -static void unserializeString(UnSerializationInfo *info) { +static void unpersistString(UnSerializationInfo *info) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -265,7 +265,7 @@ static void unserializeSpecialTable(UnSerializationInfo *info, int index) { // Make sure there is enough room on the stack lua_checkstack(info->luaState, 1); - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... spfunc lua_call(info->luaState, 0, 1); @@ -286,7 +286,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... tbl // Unserialize metatable - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... tbl ?metaTbl/nil? if (lua_istable(info->luaState, -1)) { @@ -303,7 +303,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { while (1) { // >>>>> permTbl indexTbl ...... tbl - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... tbl key/nil // The table serialization is nil terminated @@ -316,7 +316,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { } // >>>>> permTbl indexTbl ...... tbl key - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... tbl value lua_rawset(info->luaState, -3); @@ -324,7 +324,7 @@ static void unserializeLiteralTable(UnSerializationInfo *info, int index) { } } -void unserializeTable(UnSerializationInfo *info, int index) { +void unpersistTable(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -341,7 +341,7 @@ void unserializeTable(UnSerializationInfo *info, int index) { } } -void unserializeFunction(UnSerializationInfo *info, int index) { +void unpersistFunction(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -372,7 +372,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { registerObjectInIndexTable(info, index); // Now that it's safe, we can get the real proto - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... func proto lclosure->p = gco2p(getObject(info->luaState, -1)->value.gc); @@ -382,7 +382,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { for (byte i = 0; i < numUpValues; ++i) { // >>>>> permTbl indexTbl ...... func - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... func func2 unboxUpValue(info->luaState); @@ -394,7 +394,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { } // Finally, the fenv - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... func ?fenv/nil? if (!lua_isnil(info->luaState, -1)) { @@ -410,7 +410,7 @@ void unserializeFunction(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... func } -void unserializeThread(UnSerializationInfo *info, int index) { +void unpersistThread(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... lua_State *L2; @@ -432,7 +432,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { // very bottom of the stack L2->top--; for (uint32 i = 0; i < stackSize; ++i) { - unserialize(info); + unpersist(info); // L1: permTbl indexTbl ...... thread obj* } @@ -492,7 +492,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { global_State *g = G(L2); while (true) { - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... thread upVal/nil // The list is terminated by a nil @@ -535,7 +535,7 @@ void unserializeThread(UnSerializationInfo *info, int index) { } } -void unserializeProto(UnSerializationInfo *info, int index) { +void unpersistProto(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... // We have to be careful. The GC expects a lot out of protos. In particular, we need @@ -564,7 +564,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->k, 0, sizek, TValue); for (int i = 0; i < sizek; ++i) { // >>>>> permTbl indexTbl ...... proto - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... proto k setobj2s(info->luaState, &p->k[i], getObject(info->luaState, -1)); @@ -581,7 +581,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->p, 0, sizep, Proto *); for (int i = 0; i < sizep; ++i) { // >>>>> permTbl indexTbl ...... proto - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... proto subproto p->p[i] = (Proto *)getObject(info->luaState, -1)->value.gc; @@ -605,7 +605,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->upvalues, 0, p->sizeupvalues, TString *); for (int i = 0; i < p->sizeupvalues; ++i) { // >>>>> permTbl indexTbl ...... proto - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... proto str p->upvalues[i] = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -621,7 +621,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { lua_reallocvector(info->luaState, p->locvars, 0, p->sizelocvars, LocVar); for (int i = 0; i < p->sizelocvars; ++i) { // >>>>> permTbl indexTbl ...... proto - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... proto str p->locvars[i].varname = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -635,7 +635,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... proto // Read in source string - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... proto sourceStr p->source = lua_newlstr(info->luaState, lua_tostring(info->luaState, -1), strlen(lua_tostring(info->luaState, -1))); @@ -661,7 +661,7 @@ void unserializeProto(UnSerializationInfo *info, int index) { p->maxstacksize = info->readStream->readByte(); } -void unserializeUpValue(UnSerializationInfo *info, int index) { +void unpersistUpValue(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... lua_checkstack(info->luaState, 2); @@ -669,14 +669,14 @@ void unserializeUpValue(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... func registerObjectInIndexTable(info, index); - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... func obj boxUpValue_finish(info->luaState); // >>>>> permTbl indexTbl ...... func } -void unserializeUserData(UnSerializationInfo *info, int index) { +void unpersistUserData(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack @@ -684,7 +684,7 @@ void unserializeUserData(UnSerializationInfo *info, int index) { int isspecial = info->readStream->readSint32LE(); if (isspecial) { - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... specialFunc lua_call(info->luaState, 0, 1); @@ -697,7 +697,7 @@ void unserializeUserData(UnSerializationInfo *info, int index) { info->readStream->read(lua_touserdata(info->luaState, -1), length); - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... udata metaTable/nil lua_setmetatable(info->luaState, -2); @@ -706,13 +706,13 @@ void unserializeUserData(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... udata } -void unserializePermanent(UnSerializationInfo *info, int index) { +void unpersistPermanent(UnSerializationInfo *info, int index) { // >>>>> permTbl indexTbl ...... // Make sure there is enough room on the stack lua_checkstack(info->luaState, 2); - unserialize(info); + unpersist(info); // >>>>> permTbl indexTbl ...... permKey lua_gettable(info->luaState, 1); -- cgit v1.2.3 From e4f74b6c346023608841d9f871b16069e5b54194 Mon Sep 17 00:00:00 2001 From: RichieSams Date: Tue, 30 Dec 2014 18:28:14 -0600 Subject: SWORD25: Remove the option to persist a double as a string Since the current method *should* be more accurate --- engines/sword25/util/lua_persist.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index 6038111bbc..6fe88fe9a3 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -281,21 +281,11 @@ static void persistBoolean(SerializationInfo *info) { static void persistNumber(SerializationInfo *info) { lua_Number value = lua_tonumber(info->luaState, -1); - #if 1 - Util::SerializedDouble serializedValue(Util::encodeDouble(value)); - - info->writeStream->writeUint32LE(serializedValue.significandOne); - info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); - info->writeStream->writeSint16LE(serializedValue.exponent); - #else - // NOTE: We need to store a double. Unfortunately, we have to accommodate endianness. - // Also, I don't know if we can assume all compilers use IEEE double - // Therefore, I have chosen to store the double as a string. - Common::String buffer = Common::String::format("%f", value); - - info->writeStream->write(buffer.c_str(), buffer.size()); - #endif + Util::SerializedDouble serializedValue(Util::encodeDouble(value)); + info->writeStream->writeUint32LE(serializedValue.significandOne); + info->writeStream->writeUint32LE(serializedValue.signAndSignificandTwo); + info->writeStream->writeSint16LE(serializedValue.exponent); } static void persistString(SerializationInfo *info) { -- cgit v1.2.3 From 0c54278f6c2ea6d2a2ba10ed1e833695620625ca Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 2 Jan 2015 00:28:20 +0200 Subject: ZVISION: Fix newline in truetype_font.cpp --- engines/zvision/text/truetype_font.cpp | 454 ++++++++++++++++----------------- 1 file changed, 227 insertions(+), 227 deletions(-) diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 85d9fa5a29..e378ccd127 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -1,228 +1,228 @@ -/* 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 "common/scummsys.h" -#include "common/config-manager.h" -#include "common/debug.h" -#include "common/file.h" -#include "common/system.h" -#include "common/unzip.h" -#include "graphics/font.h" -#include "graphics/fonts/ttf.h" -#include "graphics/surface.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/text/truetype_font.h" - -namespace ZVision { - -StyledTTFont::StyledTTFont(ZVision *engine) { - _engine = engine; - _style = 0; - _font = NULL; - _lineHeight = 0; -} - -StyledTTFont::~StyledTTFont() { - if (_font) - delete _font; -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { - _style = style; - return loadFont(fontName, point); -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { - struct FontStyle { - const char *zorkFont; - const char *fontBase; - const char *freeFontBase; - const char *freeFontItalicName; - }; - - const FontStyle systemFonts[] = { - { "*times new roman*", "times", "FreeSerif", "Italic" }, - { "*times*", "times", "FreeSerif", "Italic" }, - { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, - { "*garamond*", "gara", "FreeSerif", "Italic" }, - { "*courier new*", "cour", "FreeMono", "Oblique" }, - { "*courier*", "cour", "FreeMono", "Oblique" }, - { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, - { "*arial*", "arial", "FreeSans", "Oblique" }, - { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, - }; - - Common::String newFontName; - Common::String freeFontName; - - for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { - if (fontName.matchString(systemFonts[i].zorkFont, true)) { - newFontName = systemFonts[i].fontBase; - freeFontName = systemFonts[i].freeFontBase; - - if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { - newFontName += "bi"; - freeFontName += "Bold"; - freeFontName += systemFonts[i].freeFontItalicName; - } else if (_style & STTF_BOLD) { - newFontName += "bd"; - freeFontName += "Bold"; - } else if (_style & STTF_ITALIC) { - newFontName += "i"; - freeFontName += systemFonts[i].freeFontItalicName; - } - - newFontName += ".ttf"; - freeFontName += ".ttf"; - break; - } - } - - if (newFontName.empty()) { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - newFontName = "arial.ttf"; - freeFontName = "FreeSans.ttf"; - } - - bool sharp = (_style & STTF_SHARP) == STTF_SHARP; - - Common::File file; +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/system.h" +#include "common/unzip.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/text/truetype_font.h" + +namespace ZVision { + +StyledTTFont::StyledTTFont(ZVision *engine) { + _engine = engine; + _style = 0; + _font = NULL; + _lineHeight = 0; +} + +StyledTTFont::~StyledTTFont() { + if (_font) + delete _font; +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { + _style = style; + return loadFont(fontName, point); +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + struct FontStyle { + const char *zorkFont; + const char *fontBase; + const char *freeFontBase; + const char *freeFontItalicName; + }; + + const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic" }, + { "*times*", "times", "FreeSerif", "Italic" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, + { "*garamond*", "gara", "FreeSerif", "Italic" }, + { "*courier new*", "cour", "FreeMono", "Oblique" }, + { "*courier*", "cour", "FreeMono", "Oblique" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, + { "*arial*", "arial", "FreeSans", "Oblique" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, + }; + + Common::String newFontName; + Common::String freeFontName; + + for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { + if (fontName.matchString(systemFonts[i].zorkFont, true)) { + newFontName = systemFonts[i].fontBase; + freeFontName = systemFonts[i].freeFontBase; + + if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { + newFontName += "bi"; + freeFontName += "Bold"; + freeFontName += systemFonts[i].freeFontItalicName; + } else if (_style & STTF_BOLD) { + newFontName += "bd"; + freeFontName += "Bold"; + } else if (_style & STTF_ITALIC) { + newFontName += "i"; + freeFontName += systemFonts[i].freeFontItalicName; + } + + newFontName += ".ttf"; + freeFontName += ".ttf"; + break; + } + } + + if (newFontName.empty()) { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + newFontName = "arial.ttf"; + freeFontName = "FreeSans.ttf"; + } + + bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + + Common::File file; if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) - error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); - - Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - - _fntName = fontName; - _lineHeight = point; - - if (_font) - return true; - return false; -} - -void StyledTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { - _style = newStyle; - loadFont(_fntName, _lineHeight); - } else { - _style = newStyle; - } -} - -int StyledTTFont::getFontHeight() { - if (_font) - return _font->getFontHeight(); - return 0; -} - -int StyledTTFont::getMaxCharWidth() { - if (_font) - return _font->getMaxCharWidth(); - return 0; -} - -int StyledTTFont::getCharWidth(byte chr) { - if (_font) - return _font->getCharWidth(chr); - return 0; -} - -int StyledTTFont::getKerningOffset(byte left, byte right) { - if (_font) - return _font->getKerningOffset(left, right); - return 0; -} - -void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { - if (_font) { - _font->drawChar(dst, chr, x, y, color); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - } -} - -void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { - if (_font) { - _font->drawString(dst, str, x, y, w, color, align); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - } -} - -int StyledTTFont::getStringWidth(const Common::String &str) { - if (_font) - return _font->getStringWidth(str); - return 0; -} - -Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { - Graphics::Surface *tmp = new Graphics::Surface; - if (_font) { - int16 w = _font->getStringWidth(str); - if (w && w < 1024) { - tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat); - drawString(tmp, str, 0, 0, w, color); - } - } - return tmp; -} - -} // End of namespace ZVision + error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); + + Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + + _fntName = fontName; + _lineHeight = point; + + if (_font) + return true; + return false; +} + +void StyledTTFont::setStyle(uint newStyle) { + if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { + _style = newStyle; + loadFont(_fntName, _lineHeight); + } else { + _style = newStyle; + } +} + +int StyledTTFont::getFontHeight() { + if (_font) + return _font->getFontHeight(); + return 0; +} + +int StyledTTFont::getMaxCharWidth() { + if (_font) + return _font->getMaxCharWidth(); + return 0; +} + +int StyledTTFont::getCharWidth(byte chr) { + if (_font) + return _font->getCharWidth(chr); + return 0; +} + +int StyledTTFont::getKerningOffset(byte left, byte right) { + if (_font) + return _font->getKerningOffset(left, right); + return 0; +} + +void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { + if (_font) { + _font->drawChar(dst, chr, x, y, color); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + } +} + +void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { + if (_font) { + _font->drawString(dst, str, x, y, w, color, align); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + } +} + +int StyledTTFont::getStringWidth(const Common::String &str) { + if (_font) + return _font->getStringWidth(str); + return 0; +} + +Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { + Graphics::Surface *tmp = new Graphics::Surface; + if (_font) { + int16 w = _font->getStringWidth(str); + if (w && w < 1024) { + tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat); + drawString(tmp, str, 0, 0, w, color); + } + } + return tmp; +} + +} // End of namespace ZVision -- cgit v1.2.3 From 976b4adb4e114c19e47efb3b18a52b1c1c1f44c4 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 2 Jan 2015 00:31:19 +0200 Subject: ZVISION: Add support for unmodified INQUIS.ZIX files This will greatly help users copy the unmodified file from the game CDs of ZGI and get the game working straight away --- engines/zvision/file/search_manager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 7a907df39c..ec250ff648 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -169,8 +169,13 @@ void SearchManager::loadZix(const Common::String &name) { line.trim(); if (line.matchString("----------*", true)) break; - else if (line.matchString("DIR:*", true)) { + else if (line.matchString("DIR:*", true) || line.matchString("CD0:*", true) || line.matchString("CD1:*", true)) { Common::String path(line.c_str() + 5); + // Check if INQUIS.ZIX refers to the ZGI folder, and check the game + // root folder instead + if (path.hasPrefix("zgi\\")) + path = Common::String(path.c_str() + 4); + Common::Archive *arc; char tempPath[128]; strcpy(tempPath, path.c_str()); -- cgit v1.2.3 From 34ec4ed6b51b81afa012543040951091ee1208ee Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 1 Jan 2015 17:36:12 -0500 Subject: ZVISION: Really fix truetype_font.cpp newlines They are now all LF. --- engines/zvision/text/truetype_font.cpp | 456 ++++++++++++++++----------------- 1 file changed, 228 insertions(+), 228 deletions(-) diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index e378ccd127..622a02a6a8 100644 --- a/engines/zvision/text/truetype_font.cpp +++ b/engines/zvision/text/truetype_font.cpp @@ -1,228 +1,228 @@ -/* 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 "common/scummsys.h" -#include "common/config-manager.h" -#include "common/debug.h" -#include "common/file.h" -#include "common/system.h" -#include "common/unzip.h" -#include "graphics/font.h" -#include "graphics/fonts/ttf.h" -#include "graphics/surface.h" - -#include "zvision/zvision.h" -#include "zvision/graphics/render_manager.h" -#include "zvision/text/truetype_font.h" - -namespace ZVision { - -StyledTTFont::StyledTTFont(ZVision *engine) { - _engine = engine; - _style = 0; - _font = NULL; - _lineHeight = 0; -} - -StyledTTFont::~StyledTTFont() { - if (_font) - delete _font; -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { - _style = style; - return loadFont(fontName, point); -} - -bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { - struct FontStyle { - const char *zorkFont; - const char *fontBase; - const char *freeFontBase; - const char *freeFontItalicName; - }; - - const FontStyle systemFonts[] = { - { "*times new roman*", "times", "FreeSerif", "Italic" }, - { "*times*", "times", "FreeSerif", "Italic" }, - { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, - { "*garamond*", "gara", "FreeSerif", "Italic" }, - { "*courier new*", "cour", "FreeMono", "Oblique" }, - { "*courier*", "cour", "FreeMono", "Oblique" }, - { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, - { "*arial*", "arial", "FreeSans", "Oblique" }, - { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, - }; - - Common::String newFontName; - Common::String freeFontName; - - for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { - if (fontName.matchString(systemFonts[i].zorkFont, true)) { - newFontName = systemFonts[i].fontBase; - freeFontName = systemFonts[i].freeFontBase; - - if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { - newFontName += "bi"; - freeFontName += "Bold"; - freeFontName += systemFonts[i].freeFontItalicName; - } else if (_style & STTF_BOLD) { - newFontName += "bd"; - freeFontName += "Bold"; - } else if (_style & STTF_ITALIC) { - newFontName += "i"; - freeFontName += systemFonts[i].freeFontItalicName; - } - - newFontName += ".ttf"; - freeFontName += ".ttf"; - break; - } - } - - if (newFontName.empty()) { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - newFontName = "arial.ttf"; - freeFontName = "FreeSans.ttf"; - } - - bool sharp = (_style & STTF_SHARP) == STTF_SHARP; - - Common::File file; - if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) - error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); - - Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display - if (_newFont) { - if (!_font) - delete _font; - _font = _newFont; - } - - _fntName = fontName; - _lineHeight = point; - - if (_font) - return true; - return false; -} - -void StyledTTFont::setStyle(uint newStyle) { - if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { - _style = newStyle; - loadFont(_fntName, _lineHeight); - } else { - _style = newStyle; - } -} - -int StyledTTFont::getFontHeight() { - if (_font) - return _font->getFontHeight(); - return 0; -} - -int StyledTTFont::getMaxCharWidth() { - if (_font) - return _font->getMaxCharWidth(); - return 0; -} - -int StyledTTFont::getCharWidth(byte chr) { - if (_font) - return _font->getCharWidth(chr); - return 0; -} - -int StyledTTFont::getKerningOffset(byte left, byte right) { - if (_font) - return _font->getKerningOffset(left, right); - return 0; -} - -void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { - if (_font) { - _font->drawChar(dst, chr, x, y, color); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); - } - } -} - -void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { - if (_font) { - _font->drawString(dst, str, x, y, w, color, align); - if (_style & STTF_UNDERLINE) { - int16 pos = floor(_font->getFontHeight() * 0.87); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - if (_style & STTF_STRIKEOUT) { - int16 pos = floor(_font->getFontHeight() * 0.60); - int16 wd = MIN(_font->getStringWidth(str), w); - int16 stX = x; - if (align == Graphics::kTextAlignCenter) - stX += (w - wd) / 2; - else if (align == Graphics::kTextAlignRight) - stX += (w - wd); - - int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); - - dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); - } - } -} - -int StyledTTFont::getStringWidth(const Common::String &str) { - if (_font) - return _font->getStringWidth(str); - return 0; -} - -Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { - Graphics::Surface *tmp = new Graphics::Surface; - if (_font) { - int16 w = _font->getStringWidth(str); - if (w && w < 1024) { - tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat); - drawString(tmp, str, 0, 0, w, color); - } - } - return tmp; -} - -} // End of namespace ZVision +/* 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 "common/scummsys.h" +#include "common/config-manager.h" +#include "common/debug.h" +#include "common/file.h" +#include "common/system.h" +#include "common/unzip.h" +#include "graphics/font.h" +#include "graphics/fonts/ttf.h" +#include "graphics/surface.h" + +#include "zvision/zvision.h" +#include "zvision/graphics/render_manager.h" +#include "zvision/text/truetype_font.h" + +namespace ZVision { + +StyledTTFont::StyledTTFont(ZVision *engine) { + _engine = engine; + _style = 0; + _font = NULL; + _lineHeight = 0; +} + +StyledTTFont::~StyledTTFont() { + if (_font) + delete _font; +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint style) { + _style = style; + return loadFont(fontName, point); +} + +bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) { + struct FontStyle { + const char *zorkFont; + const char *fontBase; + const char *freeFontBase; + const char *freeFontItalicName; + }; + + const FontStyle systemFonts[] = { + { "*times new roman*", "times", "FreeSerif", "Italic" }, + { "*times*", "times", "FreeSerif", "Italic" }, + { "*century schoolbook*", "censcbk", "FreeSerif", "Italic" }, + { "*garamond*", "gara", "FreeSerif", "Italic" }, + { "*courier new*", "cour", "FreeMono", "Oblique" }, + { "*courier*", "cour", "FreeMono", "Oblique" }, + { "*ZorkDeath*", "cour", "FreeMono", "Oblique" }, + { "*arial*", "arial", "FreeSans", "Oblique" }, + { "*ZorkNormal*", "arial", "FreeSans", "Oblique" }, + }; + + Common::String newFontName; + Common::String freeFontName; + + for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { + if (fontName.matchString(systemFonts[i].zorkFont, true)) { + newFontName = systemFonts[i].fontBase; + freeFontName = systemFonts[i].freeFontBase; + + if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { + newFontName += "bi"; + freeFontName += "Bold"; + freeFontName += systemFonts[i].freeFontItalicName; + } else if (_style & STTF_BOLD) { + newFontName += "bd"; + freeFontName += "Bold"; + } else if (_style & STTF_ITALIC) { + newFontName += "i"; + freeFontName += systemFonts[i].freeFontItalicName; + } + + newFontName += ".ttf"; + freeFontName += ".ttf"; + break; + } + } + + if (newFontName.empty()) { + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + newFontName = "arial.ttf"; + freeFontName = "FreeSans.ttf"; + } + + bool sharp = (_style & STTF_SHARP) == STTF_SHARP; + + Common::File file; + if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName)) + error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str()); + + Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display + if (_newFont) { + if (!_font) + delete _font; + _font = _newFont; + } + + _fntName = fontName; + _lineHeight = point; + + if (_font) + return true; + return false; +} + +void StyledTTFont::setStyle(uint newStyle) { + if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) { + _style = newStyle; + loadFont(_fntName, _lineHeight); + } else { + _style = newStyle; + } +} + +int StyledTTFont::getFontHeight() { + if (_font) + return _font->getFontHeight(); + return 0; +} + +int StyledTTFont::getMaxCharWidth() { + if (_font) + return _font->getMaxCharWidth(); + return 0; +} + +int StyledTTFont::getCharWidth(byte chr) { + if (_font) + return _font->getCharWidth(chr); + return 0; +} + +int StyledTTFont::getKerningOffset(byte left, byte right) { + if (_font) + return _font->getKerningOffset(left, right); + return 0; +} + +void StyledTTFont::drawChar(Graphics::Surface *dst, byte chr, int x, int y, uint32 color) { + if (_font) { + _font->drawChar(dst, chr, x, y, color); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + dst->fillRect(Common::Rect(x, y + pos, x + _font->getCharWidth(chr), y + pos + thk), color); + } + } +} + +void StyledTTFont::drawString(Graphics::Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, Graphics::TextAlign align) { + if (_font) { + _font->drawString(dst, str, x, y, w, color, align); + if (_style & STTF_UNDERLINE) { + int16 pos = floor(_font->getFontHeight() * 0.87); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + if (_style & STTF_STRIKEOUT) { + int16 pos = floor(_font->getFontHeight() * 0.60); + int16 wd = MIN(_font->getStringWidth(str), w); + int16 stX = x; + if (align == Graphics::kTextAlignCenter) + stX += (w - wd) / 2; + else if (align == Graphics::kTextAlignRight) + stX += (w - wd); + + int thk = MAX((int)(_font->getFontHeight() * 0.05), 1); + + dst->fillRect(Common::Rect(stX, y + pos, stX + wd, y + pos + thk), color); + } + } +} + +int StyledTTFont::getStringWidth(const Common::String &str) { + if (_font) + return _font->getStringWidth(str); + return 0; +} + +Graphics::Surface *StyledTTFont::renderSolidText(const Common::String &str, uint32 color) { + Graphics::Surface *tmp = new Graphics::Surface; + if (_font) { + int16 w = _font->getStringWidth(str); + if (w && w < 1024) { + tmp->create(w, _font->getFontHeight(), _engine->_resourcePixelFormat); + drawString(tmp, str, 0, 0, w, color); + } + } + return tmp; +} + +} // End of namespace ZVision -- cgit v1.2.3 From f4a99656ceab94cfc1c75d34180a5a49dfd43c0f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 2 Jan 2015 01:38:49 +0100 Subject: FULLPIPE: Fix bug with spring in scene04 --- engines/fullpipe/scenes/scene04.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index fd1ececdf2..6b3ddf9640 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -949,7 +949,7 @@ void sceneHandler04_springWobble() { if (g_vars->scene04_bottleWeight < newdelta) g_vars->scene04_springOffset--; - if ((oldDynIndex > g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) { + if ((oldDynIndex <= g_vars->scene04_bottleWeight && newdelta > g_vars->scene04_bottleWeight) || newdelta <= g_vars->scene04_bottleWeight) { g_vars->scene04_springDelay++; if (g_vars->scene04_springOffset && g_vars->scene04_springDelay > 1) { -- cgit v1.2.3 From 76b71cabb9946b443afc803d04b1ca9e71cf5143 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 2 Jan 2015 13:10:04 +0100 Subject: FULLPIPE: Fix bug with unmovable jar in scene04 --- engines/fullpipe/scenes/scene04.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index 6b3ddf9640..4a87ae5b87 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -960,6 +960,8 @@ void sceneHandler04_springWobble() { Common::Point point; + int oldpos = g_vars->scene04_spring->getCurrDimensions(point)->y - oldDynIndex; + if (g_vars->scene04_dynamicPhaseIndex) { if (!g_vars->scene04_spring->_movement) g_vars->scene04_spring->startAnim(MV_SPR_LOWER, 0, -1); @@ -969,8 +971,9 @@ void sceneHandler04_springWobble() { g_vars->scene04_spring->changeStatics2(ST_SPR_UP); } - if (g_vars->scene04_dynamicPhaseIndex != oldDynIndex) - sceneHandler04_bottleUpdateObjects(oldDynIndex - g_vars->scene04_dynamicPhaseIndex); + if (g_vars->scene04_dynamicPhaseIndex != oldDynIndex) { + sceneHandler04_bottleUpdateObjects(oldpos - (g_vars->scene04_spring->getCurrDimensions(point)->y - g_vars->scene04_dynamicPhaseIndex)); + } } void sceneHandler04_leaveScene() { -- cgit v1.2.3 From c3def28b9964066165b8627d0129578504734ab2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 3 Jan 2015 20:17:47 +0100 Subject: FULLPIPE: Fix crash in scene04 --- engines/fullpipe/mgm.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/engines/fullpipe/mgm.cpp b/engines/fullpipe/mgm.cpp index aacfd5452a..1c8ca2a7b1 100644 --- a/engines/fullpipe/mgm.cpp +++ b/engines/fullpipe/mgm.cpp @@ -155,13 +155,14 @@ void MGM::rebuildTables(int objId) { if (!obj) return; - for (uint i = 0; i < obj->_staticsList.size(); i++) + for (uint i = 0; i < obj->_staticsList.size(); i++) { _items[idx]->statics.push_back((Statics *)obj->_staticsList[i]); + _items[idx]->subItems.push_back(new MGMSubItem); + } + for (uint i = 0; i < obj->_movements.size(); i++) _items[idx]->movements1.push_back((Movement *)obj->_movements[i]); - - _items[idx]->subItems.clear(); } int MGM::getItemIndexById(int objId) { -- cgit v1.2.3 From ee9b60676a3efe015638763eed69161ee76ed846 Mon Sep 17 00:00:00 2001 From: Joel Teichroeb Date: Sun, 4 Jan 2015 09:39:55 -0800 Subject: SDL: Warn if the selected joystick does not exist --- backends/events/sdl/sdl-events.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 2480e7c370..284e0970fd 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -55,16 +55,18 @@ SdlEventSource::SdlEventSource() memset(&_km, 0, sizeof(_km)); int joystick_num = ConfMan.getInt("joystick_num"); - if (joystick_num > -1) { + if (joystick_num >= 0) { // Initialize SDL joystick subsystem if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) { error("Could not initialize SDL: %s", SDL_GetError()); } // Enable joystick - if (SDL_NumJoysticks() > 0) { - debug("Using joystick: %s", SDL_JoystickName(0)); + if (SDL_NumJoysticks() > joystick_num) { + debug("Using joystick: %s", SDL_JoystickName(joystick_num)); _joystick = SDL_JoystickOpen(joystick_num); + } else { + warning("Invalid joystick: %d", joystick_num); } } } -- cgit v1.2.3 From 308bfe3b9cfda6ae2dd0558fcecfaa628e816b60 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 19:16:34 +0100 Subject: FULLPIPE: Remove redundant check --- engines/fullpipe/scenes/scene16.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/fullpipe/scenes/scene16.cpp b/engines/fullpipe/scenes/scene16.cpp index e9d3a37efd..df005950d2 100644 --- a/engines/fullpipe/scenes/scene16.cpp +++ b/engines/fullpipe/scenes/scene16.cpp @@ -182,7 +182,7 @@ void sceneHandler16_fillMug() { mq = new MessageQueue(g_fp->_currentScene->getMessageQueueById(QU_SC16_BOYOUT), 0, 1); mq->replaceKeyCode(-1, g_vars->scene16_walkingBoy->_okeyCode); - if (!mq || mq->chain(g_vars->scene16_walkingBoy)) + if (mq->chain(g_vars->scene16_walkingBoy)) return; } else { if (!g_vars->scene16_walkingGirl) -- cgit v1.2.3 From 4393d38a311df69f473febc5c2fdf135694609e9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 19:18:41 +0100 Subject: FULLPIPE: Plug memory leak --- engines/fullpipe/statics.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 880c2eb0df..6b35159fd1 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -1048,8 +1048,11 @@ MessageQueue *StaticANIObject::changeStatics1(int msgNum) { if (_flags & 1) _messageQueueId = mq->_id; } else { - if (!queueMessageQueue(mq)) + if (!queueMessageQueue(mq)) { + delete mq; + return 0; + } g_fp->_globalMessageQueueList->addMessageQueue(mq); } -- cgit v1.2.3 From 882e0ca8cbc507cfba8dec1a340be9f5462069c3 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 19:23:43 +0100 Subject: FULLPIPE: Sanity check --- engines/fullpipe/statics.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 6b35159fd1..de3e1ea728 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -1597,6 +1597,12 @@ Movement::Movement(Movement *src, int *oldIdxs, int newSize, StaticANIObject *an newSize = src->_dynamicPhases.size(); } + if (!newSize) { + warning("Movement::Movement: newSize = 0"); + + return; + } + _framePosOffsets = (Common::Point **)calloc(newSize, sizeof(Common::Point *)); for (int i = 0; i < newSize; i++) -- cgit v1.2.3 From 7da48233ce9a0154364bf26c1e419d24e70f2a26 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 19:32:26 +0100 Subject: FULLPIPE: Fix bug in inventory --- engines/fullpipe/inventory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index e79f9c54df..f9b507c50b 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -126,7 +126,7 @@ void Inventory2::removeItem2(Scene *sceneObj, int itemId, int x, int y, int prio int idx = getInventoryItemIndexById(itemId); if (idx >= 0) { - if (_inventoryItems[idx]->itemId >> 16) { + if (_inventoryItems[idx]->count) { removeItem(itemId, 1); Scene *sc = g_fp->accessScene(_sceneId); -- cgit v1.2.3 From 5b19913eb83d7f82ac0d2a153e11db43e7e88616 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 20:22:04 +0100 Subject: CONFIGURE: define HAVE_INT64 when we have 64-bit types. This has been hanging in the air forever, but for the sake of cleanness now is defined. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index eba1ebcb32..7c4c87e3af 100755 --- a/configure +++ b/configure @@ -4504,6 +4504,7 @@ $_def_64bit_type_unsigned #else $_def_64bit_type_unsigned #endif +#define HAVE_INT64 EOF fi -- cgit v1.2.3 From f1765db70fd7d1350e163a306a78ca293ef119cb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 20:41:50 +0100 Subject: COMMON: Put all 64-bit code under new HAVE_INT64 constant I regrouped all functions in order to make the code less noisy with #ifdefs --- common/endian.h | 126 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 77 insertions(+), 49 deletions(-) diff --git a/common/endian.h b/common/endian.h index a18e6f088b..70cc8b434f 100644 --- a/common/endian.h +++ b/common/endian.h @@ -49,7 +49,7 @@ # error No endianness defined #endif - +#ifdef HAVE_INT64 #define SWAP_CONSTANT_64(a) \ ((uint64)((((a) >> 56) & 0x000000FF) | \ (((a) >> 40) & 0x0000FF00) | \ @@ -59,6 +59,7 @@ (((a) & 0x00FF0000) << 24) | \ (((a) & 0x0000FF00) << 40) | \ (((a) & 0x000000FF) << 56) )) +#endif #define SWAP_CONSTANT_32(a) \ ((uint32)((((a) >> 24) & 0x00FF) | \ @@ -70,6 +71,7 @@ ((uint16)((((a) >> 8) & 0x00FF) | \ (((a) << 8) & 0xFF00) )) +#ifdef HAVE_INT64 /** * Swap the bytes in a 64 bit word in order to convert LE encoded data to BE * and vice versa. @@ -122,10 +124,11 @@ return ((uint64)(((uint32)(uint16)((lowLow >> 8) | (lowLow << 8)) << 16) | (uint16)((lowHigh >> 8) | (lowHigh << 8))) << 32) | (((uint32)(uint16)((highLow >> 8) | (highLow << 8)) << 16) | - (uint16)((highHigh >> 8) | (highHigh << 8))) + (uint16)((highHigh >> 8) | (highHigh << 8))); } #endif +#endif // HAVE_INT64 /** * Swap the bytes in a 32 bit word in order to convert LE encoded data to BE * and vice versa. @@ -240,11 +243,6 @@ return ((const Unaligned32 *)ptr)->val; } - FORCEINLINE uint64 READ_UINT64(const void *ptr) { - struct Unaligned64 { uint64 val; } __attribute__ ((__packed__, __may_alias__)); - return ((const Unaligned64 *)ptr)->val; - } - FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { struct Unaligned16 { uint16 val; } __attribute__ ((__packed__, __may_alias__)); ((Unaligned16 *)ptr)->val = value; @@ -255,10 +253,17 @@ ((Unaligned32 *)ptr)->val = value; } +#ifdef HAVE_INT64 + FORCEINLINE uint64 READ_UINT64(const void *ptr) { + struct Unaligned64 { uint64 val; } __attribute__ ((__packed__, __may_alias__)); + return ((const Unaligned64 *)ptr)->val; + } + FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) { struct Unaligned64 { uint64 val; } __attribute__((__packed__, __may_alias__)); ((Unaligned64 *)ptr)->val = value; } +#endif #elif !defined(SCUMM_NEED_ALIGNMENT) @@ -270,10 +275,6 @@ return *(const uint32 *)(ptr); } - FORCEINLINE uint64 READ_UINT64(const void *ptr) { - return *(const uint64 *)(ptr); - } - FORCEINLINE void WRITE_UINT16(void *ptr, uint16 value) { *(uint16 *)(ptr) = value; } @@ -282,9 +283,15 @@ *(uint32 *)(ptr) = value; } +#ifdef HAVE_INT64 + FORCEINLINE uint64 READ_UINT64(const void *ptr) { + return *(const uint64 *)(ptr); + } + FORCEINLINE void WRITE_UINT64(void *ptr, uint64 value) { *(uint64 *)(ptr) = value; } +#endif // use software fallback by loading each byte explicitely @@ -300,10 +307,6 @@ const uint8 *b = (const uint8 *)ptr; return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); } - inline uint64 READ_UINT64(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); - } inline void WRITE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -316,6 +319,11 @@ b[2] = (uint8)(value >> 16); b[3] = (uint8)(value >> 24); } +#ifdef HAVE_INT64 + inline uint64 READ_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); + } inline void WRITE_UINT64(void *ptr, uint64 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -327,6 +335,7 @@ b[6] = (uint8)(value >> 48); b[7] = (uint8)(value >> 56); } +#endif # elif defined(SCUMM_BIG_ENDIAN) @@ -338,10 +347,6 @@ const uint8 *b = (const uint8 *)ptr; return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]); } - inline uint64 READ_UINT64(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[0] << 56) | (b[1] << 48) | (b[2] << 40) | (b[3] << 32) | (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); - } inline void WRITE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 8); @@ -354,6 +359,11 @@ b[2] = (uint8)(value >> 8); b[3] = (uint8)(value >> 0); } +#ifdef HAVE_INT64 + inline uint64 READ_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[0] << 56) | (b[1] << 48) | (b[2] << 40) | (b[3] << 32) | (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); + } inline void WRITE_UINT64(void *ptr, uint64 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 56); @@ -365,6 +375,7 @@ b[6] = (uint8)(value >> 8); b[7] = (uint8)(value >> 0); } +#endif # endif @@ -376,36 +387,39 @@ #define READ_LE_UINT16(a) READ_UINT16(a) #define READ_LE_UINT32(a) READ_UINT32(a) - #define READ_LE_UINT64(a) READ_UINT64(a) #define WRITE_LE_UINT16(a, v) WRITE_UINT16(a, v) #define WRITE_LE_UINT32(a, v) WRITE_UINT32(a, v) - #define WRITE_LE_UINT64(a, v) WRITE_UINT64(a, v) - #define FROM_LE_64(a) ((uint64)(a)) #define FROM_LE_32(a) ((uint32)(a)) #define FROM_LE_16(a) ((uint16)(a)) - #define FROM_BE_64(a) SWAP_BYTES_64(a) #define FROM_BE_32(a) SWAP_BYTES_32(a) #define FROM_BE_16(a) SWAP_BYTES_16(a) - #define TO_LE_64(a) ((uint64)(a)) #define TO_LE_32(a) ((uint32)(a)) #define TO_LE_16(a) ((uint16)(a)) - #define TO_BE_64(a) SWAP_BYTES_64(a) #define TO_BE_32(a) SWAP_BYTES_32(a) #define TO_BE_16(a) SWAP_BYTES_16(a) - #define CONSTANT_LE_64(a) ((uint64)(a)) #define CONSTANT_LE_32(a) ((uint32)(a)) #define CONSTANT_LE_16(a) ((uint16)(a)) - #define CONSTANT_BE_64(a) SWAP_CONSTANT_64(a) #define CONSTANT_BE_32(a) SWAP_CONSTANT_32(a) #define CONSTANT_BE_16(a) SWAP_CONSTANT_16(a) +#ifdef HAVE_INT64 + #define READ_LE_UINT64(a) READ_UINT64(a) + #define WRITE_LE_UINT64(a, v) WRITE_UINT64(a, v) + #define FROM_LE_64(a) ((uint64)(a)) + #define FROM_BE_64(a) SWAP_BYTES_64(a) + #define TO_LE_64(a) ((uint64)(a)) + #define TO_BE_64(a) SWAP_BYTES_64(a) + #define CONSTANT_LE_64(a) ((uint64)(a)) + #define CONSTANT_BE_64(a) SWAP_CONSTANT_64(a) +#endif + // if the unaligned load and the byteswap take alot instructions its better to directly read and invert # if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__) @@ -417,10 +431,6 @@ const uint8 *b = (const uint8 *)ptr; return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]); } - inline uint64 READ_BE_UINT64(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[0] << 56) | b[1] << 48) | b[2] << 40) | b[3] << 32) | b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); - } inline void WRITE_BE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 8); @@ -433,6 +443,11 @@ b[2] = (uint8)(value >> 8); b[3] = (uint8)(value >> 0); } +#ifdef HAVE_INT64 + inline uint64 READ_BE_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[0] << 56) | b[1] << 48) | b[2] << 40) | b[3] << 32) | b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); + } inline void WRITE_BE_UINT64(void *ptr, uint64 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 56); @@ -444,6 +459,8 @@ b[6] = (uint8)(value >> 8); b[7] = (uint8)(value >> 0); } +#endif + # else inline uint16 READ_BE_UINT16(const void *ptr) { @@ -452,18 +469,20 @@ inline uint32 READ_BE_UINT32(const void *ptr) { return SWAP_BYTES_32(READ_UINT32(ptr)); } - inline uint32 READ_BE_UINT64(const void *ptr) { - return SWAP_BYTES_64(READ_UINT64(ptr)); - } inline void WRITE_BE_UINT16(void *ptr, uint16 value) { WRITE_UINT16(ptr, SWAP_BYTES_16(value)); } inline void WRITE_BE_UINT32(void *ptr, uint32 value) { WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } +#ifdef HAVE_INT64 + inline uint32 READ_BE_UINT64(const void *ptr) { + return SWAP_BYTES_64(READ_UINT64(ptr)); + } inline void WRITE_BE_UINT64(void *ptr, uint64 value) { WRITE_UINT64(ptr, SWAP_BYTES_64(value)); } +#endif # endif // if defined(SCUMM_NEED_ALIGNMENT) @@ -471,36 +490,39 @@ #define READ_BE_UINT16(a) READ_UINT16(a) #define READ_BE_UINT32(a) READ_UINT32(a) - #define READ_BE_UINT64(a) READ_UINT64(a) #define WRITE_BE_UINT16(a, v) WRITE_UINT16(a, v) #define WRITE_BE_UINT32(a, v) WRITE_UINT32(a, v) - #define WRITE_BE_UINT64(a, v) WRITE_UINT64(a, v) - #define FROM_LE_64(a) SWAP_BYTES_64(a) #define FROM_LE_32(a) SWAP_BYTES_32(a) #define FROM_LE_16(a) SWAP_BYTES_16(a) - #define FROM_BE_64(a) ((uint64)(a)) #define FROM_BE_32(a) ((uint32)(a)) #define FROM_BE_16(a) ((uint16)(a)) - #define TO_LE_64(a) SWAP_BYTES_64(a) #define TO_LE_32(a) SWAP_BYTES_32(a) #define TO_LE_16(a) SWAP_BYTES_16(a) - #define TO_BE_64(a) ((uint64)(a)) #define TO_BE_32(a) ((uint32)(a)) #define TO_BE_16(a) ((uint16)(a)) - #define CONSTANT_LE_64(a) SWAP_CONSTANT_64(a) #define CONSTANT_LE_32(a) SWAP_CONSTANT_32(a) #define CONSTANT_LE_16(a) SWAP_CONSTANT_16(a) - #define CONSTANT_BE_64(a) ((uint64)(a)) #define CONSTANT_BE_32(a) ((uint32)(a)) #define CONSTANT_BE_16(a) ((uint16)(a)) +#ifdef HAVE_INT64 + #define READ_BE_UINT64(a) READ_UINT64(a) + #define WRITE_BE_UINT64(a, v) WRITE_UINT64(a, v) + #define FROM_LE_64(a) SWAP_BYTES_64(a) + #define FROM_BE_64(a) ((uint64)(a)) + #define TO_LE_64(a) SWAP_BYTES_64(a) + #define TO_BE_64(a) ((uint64)(a)) + #define CONSTANT_LE_64(a) SWAP_CONSTANT_64(a) + #define CONSTANT_BE_64(a) ((uint64)(a)) +#endif + // if the unaligned load and the byteswap take alot instructions its better to directly read and invert # if defined(SCUMM_NEED_ALIGNMENT) && !defined(__mips__) @@ -512,10 +534,6 @@ const uint8 *b = (const uint8 *)ptr; return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); } - inline uint64 READ_LE_UINT64(const void *ptr) { - const uint8 *b = (const uint8 *)ptr; - return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); - } inline void WRITE_LE_UINT16(void *ptr, uint16 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -528,6 +546,12 @@ b[2] = (uint8)(value >> 16); b[3] = (uint8)(value >> 24); } + +#ifdef HAVE_INT64 + inline uint64 READ_LE_UINT64(const void *ptr) { + const uint8 *b = (const uint8 *)ptr; + return (b[7] << 56) | (b[6] << 48) | (b[5] << 40) | (b[4] << 32) | (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0]); + } inline void WRITE_LE_UINT64(void *ptr, uint64 value) { uint8 *b = (uint8 *)ptr; b[0] = (uint8)(value >> 0); @@ -539,6 +563,8 @@ b[6] = (uint8)(value >> 48); b[7] = (uint8)(value >> 56); } +#endif + # else inline uint16 READ_LE_UINT16(const void *ptr) { @@ -547,18 +573,20 @@ inline uint32 READ_LE_UINT32(const void *ptr) { return SWAP_BYTES_32(READ_UINT32(ptr)); } - inline uint64 READ_LE_UINT64(const void *ptr) { - return SWAP_BYTES_64(READ_UINT64(ptr)); - } inline void WRITE_LE_UINT16(void *ptr, uint16 value) { WRITE_UINT16(ptr, SWAP_BYTES_16(value)); } inline void WRITE_LE_UINT32(void *ptr, uint32 value) { WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } +#ifdef HAVE_INT64 + inline uint64 READ_LE_UINT64(const void *ptr) { + return SWAP_BYTES_64(READ_UINT64(ptr)); + } inline void WRITE_LE_UINT64(void *ptr, uint64 value) { WRITE_UINT64(ptr, SWAP_BYTES_64(value)); } +#endif # endif // if defined(SCUMM_NEED_ALIGNMENT) -- cgit v1.2.3 From 7865c7821140a2b83a1473c66e90644cbf39a2c9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 20:47:12 +0100 Subject: COMMON: Put more 64-bit stuff under HAVE_INT64 --- common/stream.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/stream.h b/common/stream.h index 251995001c..3021df304c 100644 --- a/common/stream.h +++ b/common/stream.h @@ -125,10 +125,12 @@ public: write(&value, 4); } +#ifdef HAVE_INT64 void writeUint64LE(uint64 value) { value = TO_LE_64(value); write(&value, 8); } +#endif void writeUint16BE(uint16 value) { value = TO_BE_16(value); @@ -140,10 +142,12 @@ public: write(&value, 4); } +#ifdef HAVE_INT64 void writeUint64BE(uint64 value) { value = TO_BE_64(value); write(&value, 8); } +#endif FORCEINLINE void writeSint16LE(int16 value) { writeUint16LE((uint16)value); @@ -153,9 +157,11 @@ public: writeUint32LE((uint32)value); } +#ifdef HAVE_INT64 FORCEINLINE void writeSint64LE(int64 value) { writeUint64LE((uint64)value); } +#endif FORCEINLINE void writeSint16BE(int16 value) { writeUint16BE((uint16)value); @@ -165,9 +171,11 @@ public: writeUint32BE((uint32)value); } +#ifdef HAVE_INT64 FORCEINLINE void writeSint64BE(int64 value) { writeUint64BE((uint64)value); } +#endif /** * Write the given string to the stream. @@ -259,6 +267,7 @@ public: return FROM_LE_32(val); } +#ifdef HAVE_INT64 /** * Read an unsigned 64-bit word stored in little endian (LSB first) order * from the stream and return it. @@ -271,6 +280,7 @@ public: read(&val, 8); return FROM_LE_64(val); } +#endif /** * Read an unsigned 16-bit word stored in big endian (MSB first) order @@ -298,6 +308,7 @@ public: return FROM_BE_32(val); } +#ifdef HAVE_INT64 /** * Read an unsigned 64-bit word stored in big endian (MSB first) order * from the stream and return it. @@ -310,6 +321,7 @@ public: read(&val, 8); return FROM_BE_64(val); } +#endif /** * Read a signed 16-bit word stored in little endian (LSB first) order @@ -333,6 +345,7 @@ public: return (int32)readUint32LE(); } +#ifdef HAVE_INT64 /** * Read a signed 64-bit word stored in little endian (LSB first) order * from the stream and return it. @@ -343,6 +356,7 @@ public: FORCEINLINE int64 readSint64LE() { return (int64)readUint64LE(); } +#endif /** * Read a signed 16-bit word stored in big endian (MSB first) order @@ -366,6 +380,7 @@ public: return (int32)readUint32BE(); } +#ifdef HAVE_INT64 /** * Read a signed 64-bit word stored in big endian (MSB first) order * from the stream and return it. @@ -376,6 +391,7 @@ public: FORCEINLINE int64 readSint64BE() { return (int64)readUint64BE(); } +#endif /** * Read the specified amount of data into a malloc'ed buffer -- cgit v1.2.3 From ce45caaf83cae5990416aa2d6e833f309f7ce5c0 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 21:06:49 +0100 Subject: SWORD25: Fix warning --- engines/sword25/util/lua_persist.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/engines/sword25/util/lua_persist.cpp b/engines/sword25/util/lua_persist.cpp index 6fe88fe9a3..03f305b2c5 100644 --- a/engines/sword25/util/lua_persist.cpp +++ b/engines/sword25/util/lua_persist.cpp @@ -645,8 +645,7 @@ static void persistProto(SerializationInfo *info) { // Serialize inner Proto refs info->writeStream->writeSint32LE(proto->sizep); - for (int i = 0; i < proto->sizep; ++i) - { + for (int i = 0; i < proto->sizep; ++i) { pushProto(info->luaState, proto->p[i]); // >>>>> permTbl indexTbl ...... proto subProto */ @@ -668,8 +667,7 @@ static void persistProto(SerializationInfo *info) { // Serialize upvalue names info->writeStream->writeSint32LE(proto->sizeupvalues); - for (int i = 0; i < proto->sizeupvalues; ++i) - { + for (int i = 0; i < proto->sizeupvalues; ++i) { pushString(info->luaState, proto->upvalues[i]); // >>>>> permTbl indexTbl ...... proto str @@ -710,7 +708,7 @@ static void persistProto(SerializationInfo *info) { info->writeStream->writeSint32LE(proto->sizelineinfo); if (proto->sizelineinfo) { - uint32 len = static_cast(sizeof(int) * proto->sizelineinfo); + len = static_cast(sizeof(int) * proto->sizelineinfo); info->writeStream->write(proto->lineinfo, len); } -- cgit v1.2.3 From f1e58efe90e2c3ae6740a41db4642b3e47c0c81f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 20:55:01 +0100 Subject: TEST: Fix C++11 compat warnings. --- test/common/endian.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/common/endian.h b/test/common/endian.h index f083d1248c..08e93e41ef 100644 --- a/test/common/endian.h +++ b/test/common/endian.h @@ -11,13 +11,13 @@ class EndianTestSuite : public CxxTest::TestSuite } void test_READ_BE_UINT64() { - const char data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; + const byte data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; uint64 value = READ_BE_UINT64(data); TS_ASSERT_EQUALS(value, 0x123456789ABCDEFFULL); } void test_READ_LE_UINT64() { - const char data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; + const byte data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; uint64 value = READ_LE_UINT64(data); TS_ASSERT_EQUALS(value, 0xFFEDCBA978563412ULL); } -- cgit v1.2.3 From eb4d1a69255b06f93c497aabd9cf950bfe0756ec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 21:07:36 +0100 Subject: COMMON: Add missing readUint64/readSint64 to ReadStreamEndian. --- common/stream.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/stream.h b/common/stream.h index 3021df304c..abe5192b70 100644 --- a/common/stream.h +++ b/common/stream.h @@ -517,6 +517,14 @@ public: return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val); } +#ifdef HAVE_INT64 + uint64 readUint64() { + uint64 val; + read(&val, 8); + return (_bigEndian) ? TO_BE_64(val) : TO_LE_64(val); + } +#endif + FORCEINLINE int16 readSint16() { return (int16)readUint16(); } @@ -524,6 +532,12 @@ public: FORCEINLINE int32 readSint32() { return (int32)readUint32(); } + +#ifdef HAVE_INT64 + FORCEINLINE int64 readSint64() { + return (int64)readUint64(); + } +#endif }; /** -- cgit v1.2.3 From daa8fca001c0eddd5b0856d60aa7ecd59c7d6acc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 20:58:19 +0100 Subject: TEST: Fix uint64 endian related test code. This does not fix the actual implementation issues which are present right now! --- test/common/endian.h | 2 +- test/common/memoryreadstreamendian.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/endian.h b/test/common/endian.h index 08e93e41ef..065b6997fc 100644 --- a/test/common/endian.h +++ b/test/common/endian.h @@ -19,7 +19,7 @@ class EndianTestSuite : public CxxTest::TestSuite void test_READ_LE_UINT64() { const byte data[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xFF}; uint64 value = READ_LE_UINT64(data); - TS_ASSERT_EQUALS(value, 0xFFEDCBA978563412ULL); + TS_ASSERT_EQUALS(value, 0xFFDEBC9A78563412ULL); } void test_READ_BE_UINT32() { diff --git a/test/common/memoryreadstreamendian.h b/test/common/memoryreadstreamendian.h index 515128ea2a..c25ec29e1a 100644 --- a/test/common/memoryreadstreamendian.h +++ b/test/common/memoryreadstreamendian.h @@ -82,7 +82,7 @@ class MemoryReadStreamEndianTestSuite : public CxxTest::TestSuite { TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32BE(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.readUint64BE(), 0x0708090A0B0C0D0EULL); TS_ASSERT_EQUALS(ms.pos(), 14); TS_ASSERT_EQUALS(ms.readByte(), 0x0F); TS_ASSERT_EQUALS(ms.pos(), 15); @@ -97,7 +97,7 @@ class MemoryReadStreamEndianTestSuite : public CxxTest::TestSuite { TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32(), 0x06050403UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0E0D0C0B0A090807ULL); + TS_ASSERT_EQUALS(ms.readUint64(), 0x0E0D0C0B0A090807ULL); TS_ASSERT_EQUALS(ms.pos(), 14); TS_ASSERT_EQUALS(ms.readByte(), 0x0F); TS_ASSERT_EQUALS(ms.pos(), 15); @@ -112,7 +112,7 @@ class MemoryReadStreamEndianTestSuite : public CxxTest::TestSuite { TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.readUint64(), 0x0708090A0B0C0D0EULL); TS_ASSERT_EQUALS(ms.pos(), 14); TS_ASSERT_EQUALS(ms.readByte(), 0x0F); TS_ASSERT_EQUALS(ms.pos(), 15); -- cgit v1.2.3 From 64bad2ec4a2bfe9d607883ca06df03279ba83943 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 21:17:33 +0100 Subject: COMMON: Fix some syntax issues. Not compile tested. Then again it didn't look test before either. So, yay! --- common/endian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/endian.h b/common/endian.h index 70cc8b434f..21e0d9ee11 100644 --- a/common/endian.h +++ b/common/endian.h @@ -446,7 +446,7 @@ #ifdef HAVE_INT64 inline uint64 READ_BE_UINT64(const void *ptr) { const uint8 *b = (const uint8 *)ptr; - return (b[0] << 56) | b[1] << 48) | b[2] << 40) | b[3] << 32) | b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); + return (b[0] << 56) | (b[1] << 48) | (b[2] << 40) | (b[3] << 32) | (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | (b[7]); } inline void WRITE_BE_UINT64(void *ptr, uint64 value) { uint8 *b = (uint8 *)ptr; -- cgit v1.2.3 From ba228f2bea145f6f8c6d575affc8efac4ed5e87f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 21:22:43 +0100 Subject: TEST: Fix another typo in uint64 endian tests. --- test/common/memoryreadstream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/memoryreadstream.h b/test/common/memoryreadstream.h index 79c4079e9b..3e1472f408 100644 --- a/test/common/memoryreadstream.h +++ b/test/common/memoryreadstream.h @@ -82,7 +82,7 @@ class MemoryReadStreamTestSuite : public CxxTest::TestSuite { TS_ASSERT_EQUALS(ms.pos(), 2); TS_ASSERT_EQUALS(ms.readUint32BE(), 0x03040506UL); TS_ASSERT_EQUALS(ms.pos(), 6); - TS_ASSERT_EQUALS(ms.readUint64LE(), 0x0708090A0B0C0D0EULL); + TS_ASSERT_EQUALS(ms.readUint64BE(), 0x0708090A0B0C0D0EULL); TS_ASSERT_EQUALS(ms.pos(), 14); TS_ASSERT_EQUALS(ms.readByte(), 0x0F); TS_ASSERT_EQUALS(ms.pos(), 15); -- cgit v1.2.3 From e2e61184c6c75554702721434920d0e5772976cf Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 4 Jan 2015 21:30:05 +0100 Subject: COMMON: Fix return type of one READ_BE_UINT64 implementation. This makes all unit tests pass for my on amd64 again. Thanks clone2727. --- common/endian.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/endian.h b/common/endian.h index 21e0d9ee11..9a6c0cd42c 100644 --- a/common/endian.h +++ b/common/endian.h @@ -476,7 +476,7 @@ WRITE_UINT32(ptr, SWAP_BYTES_32(value)); } #ifdef HAVE_INT64 - inline uint32 READ_BE_UINT64(const void *ptr) { + inline uint64 READ_BE_UINT64(const void *ptr) { return SWAP_BYTES_64(READ_UINT64(ptr)); } inline void WRITE_BE_UINT64(void *ptr, uint64 value) { -- cgit v1.2.3 From 7c7bdf3543ee198b4dfbb06c9a95ea387342b56d Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 4 Jan 2015 21:49:56 +0100 Subject: COMMON: Swap order of functions to 16, 32, 64 --- common/endian.h | 101 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/common/endian.h b/common/endian.h index 9a6c0cd42c..9f10b63053 100644 --- a/common/endian.h +++ b/common/endian.h @@ -71,64 +71,36 @@ ((uint16)((((a) >> 8) & 0x00FF) | \ (((a) << 8) & 0xFF00) )) -#ifdef HAVE_INT64 + + /** - * Swap the bytes in a 64 bit word in order to convert LE encoded data to BE + * Swap the bytes in a 16 bit word in order to convert LE encoded data to BE * and vice versa. */ -// machine/compiler-specific variants come first, fallback last +// compilerspecific variants come first, fallback last // Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does) -// -// TODO: Fix this #if statement. It isn't changed from 32 bit. Is there a 64 bit swap instruction? #if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2)) - FORCEINLINE uint32 SWAP_BYTES_32(const uint32 a) { + FORCEINLINE uint16 SWAP_BYTES_16(const uint16 a) { if (__builtin_constant_p(a)) { - return SWAP_CONSTANT_32(a); + return SWAP_CONSTANT_16(a); } else { - uint32 result; -# if defined(__psp__) - // use special allegrex instruction - __asm__ ("wsbw %0,%1" : "=r" (result) : "r" (a)); -# else - __asm__ ("wsbh %0,%1\n" - "rotr %0,%0,16" : "=r" (result) : "r" (a)); -# endif + uint16 result; + __asm__ ("wsbh %0,%1" : "=r" (result) : "r" (a)); return result; } } - -// Test for GCC >= 4.3.0 as this version added the bswap builtin -#elif GCC_ATLEAST(4, 3) - - FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { - return __builtin_bswap64(a); - } - -#elif defined(_MSC_VER) - - FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { - return _byteswap_uint64(a); - } - -// generic fallback #else - inline uint64 SWAP_BYTES_64(uint64 a) { - uint32 low = (uint32)a, high = (uint32)(a >> 32); - uint16 lowLow = (uint16)low, lowHigh = (uint16)(low >> 16), - highLow = (uint16)high, highHigh = (uint16)(high >> 16); - - return ((uint64)(((uint32)(uint16)((lowLow >> 8) | (lowLow << 8)) << 16) | - (uint16)((lowHigh >> 8) | (lowHigh << 8))) << 32) | - (((uint32)(uint16)((highLow >> 8) | (highLow << 8)) << 16) | - (uint16)((highHigh >> 8) | (highHigh << 8))); + inline uint16 SWAP_BYTES_16(const uint16 a) { + return (a >> 8) | (a << 8); } #endif -#endif // HAVE_INT64 + + /** * Swap the bytes in a 32 bit word in order to convert LE encoded data to BE * and vice versa. @@ -178,32 +150,65 @@ } #endif +#ifdef HAVE_INT64 /** - * Swap the bytes in a 16 bit word in order to convert LE encoded data to BE + * Swap the bytes in a 64 bit word in order to convert LE encoded data to BE * and vice versa. */ -// compilerspecific variants come first, fallback last +// machine/compiler-specific variants come first, fallback last // Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does) +// +// TODO: Fix this #if statement. It isn't changed from 32 bit. Is there a 64 bit swap instruction? #if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2)) - FORCEINLINE uint16 SWAP_BYTES_16(const uint16 a) { + FORCEINLINE uint32 SWAP_BYTES_32(const uint32 a) { if (__builtin_constant_p(a)) { - return SWAP_CONSTANT_16(a); + return SWAP_CONSTANT_32(a); } else { - uint16 result; - __asm__ ("wsbh %0,%1" : "=r" (result) : "r" (a)); + uint32 result; +# if defined(__psp__) + // use special allegrex instruction + __asm__ ("wsbw %0,%1" : "=r" (result) : "r" (a)); +# else + __asm__ ("wsbh %0,%1\n" + "rotr %0,%0,16" : "=r" (result) : "r" (a)); +# endif return result; } } + +// Test for GCC >= 4.3.0 as this version added the bswap builtin +#elif GCC_ATLEAST(4, 3) + + FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { + return __builtin_bswap64(a); + } + +#elif defined(_MSC_VER) + + FORCEINLINE uint64 SWAP_BYTES_64(uint64 a) { + return _byteswap_uint64(a); + } + +// generic fallback #else - inline uint16 SWAP_BYTES_16(const uint16 a) { - return (a >> 8) | (a << 8); + inline uint64 SWAP_BYTES_64(uint64 a) { + uint32 low = (uint32)a, high = (uint32)(a >> 32); + uint16 lowLow = (uint16)low, lowHigh = (uint16)(low >> 16), + highLow = (uint16)high, highHigh = (uint16)(high >> 16); + + return ((uint64)(((uint32)(uint16)((lowLow >> 8) | (lowLow << 8)) << 16) | + (uint16)((lowHigh >> 8) | (lowHigh << 8))) << 32) | + (((uint32)(uint16)((highLow >> 8) | (highLow << 8)) << 16) | + (uint16)((highHigh >> 8) | (highHigh << 8))); } #endif +#endif // HAVE_INT64 + /** * A wrapper macro used around four character constants, like 'DATA', to -- cgit v1.2.3 From 1084f2eea67d3a7f2293392af0c7a2c1d97b1b2b Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 4 Jan 2015 21:54:11 +0100 Subject: COMMON: Implement MIPS SWAP_BYTES_64 in terms of SWAP_BYTES_32 --- common/endian.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/common/endian.h b/common/endian.h index 9f10b63053..0c6b3db621 100644 --- a/common/endian.h +++ b/common/endian.h @@ -160,22 +160,17 @@ // Test for GCC and if the target has the MIPS rel.2 instructions (we know the psp does) // -// TODO: Fix this #if statement. It isn't changed from 32 bit. Is there a 64 bit swap instruction? #if defined(__GNUC__) && (defined(__psp__) || defined(_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS64R2)) - FORCEINLINE uint32 SWAP_BYTES_32(const uint32 a) { + FORCEINLINE uint64 SWAP_BYTES_64(const uint64 a) { if (__builtin_constant_p(a)) { - return SWAP_CONSTANT_32(a); + return SWAP_CONSTANT_64(a); } else { - uint32 result; -# if defined(__psp__) - // use special allegrex instruction - __asm__ ("wsbw %0,%1" : "=r" (result) : "r" (a)); -# else - __asm__ ("wsbh %0,%1\n" - "rotr %0,%0,16" : "=r" (result) : "r" (a)); -# endif - return result; + uint32 low = (uint32)a, high = (uint32)(a >> 32); + low = SWAP_BYTES_32(low); + high = SWAP_BYTES_32(high); + + return (((uint64)low) << 32) | high; } } -- cgit v1.2.3 From 17fe53a34c442da7ccf28721179a88ed2087f7b2 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 22:09:46 +0100 Subject: SWORD25: Hopefully fix compilation errors --- engines/sword25/util/double_serialization.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/sword25/util/double_serialization.cpp b/engines/sword25/util/double_serialization.cpp index 48fd75cb33..0d41ddc503 100644 --- a/engines/sword25/util/double_serialization.cpp +++ b/engines/sword25/util/double_serialization.cpp @@ -77,13 +77,13 @@ uint64 encodeDouble_64(double value) { uint64 uintsignificand = (uint64)shiftedsignificand; return ((uint64)(value < 0 ? 1 : 0) << 63) | // Sign ((uint64)(exponent + 1023) << 52) | // Exponent stored as an offset to 1023 - (uintsignificand & 0x000FFFFFFFFFFFFF); // significand with MSB inferred + (uintsignificand & 0x000FFFFFFFFFFFFFLL); // significand with MSB inferred } double decodeDouble_64(uint64 value) { // Expand the exponent and significand int exponent = (int)((value >> 52) & 0x7FF) - 1023; - double expandedsignificand = (double)(0x10000000000000 /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFF)); + double expandedsignificand = (double)(0x10000000000000LL /* Inferred MSB */ | (value & 0x000FFFFFFFFFFFFFLL)); // Deflate the significand int temp; @@ -93,7 +93,7 @@ double decodeDouble_64(uint64 value) { double returnValue = ldexp(significand, exponent); // Check the sign bit and return - return ((value & 0x8000000000000000) == 0x8000000000000000) ? -returnValue : returnValue; + return ((value & 0x8000000000000000LL) == 0x8000000000000000LL) ? -returnValue : returnValue; } CompactSerializedDouble encodeDouble_Compact(double value) { -- cgit v1.2.3 From baacf0be61cf8f31a72b593d320c62393241e951 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 22:16:50 +0100 Subject: SWORD25: Commend unused and unportable functions --- engines/sword25/util/double_serialization.cpp | 6 ++++++ engines/sword25/util/double_serialization.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/engines/sword25/util/double_serialization.cpp b/engines/sword25/util/double_serialization.cpp index 0d41ddc503..a34eb0fbff 100644 --- a/engines/sword25/util/double_serialization.cpp +++ b/engines/sword25/util/double_serialization.cpp @@ -65,6 +65,10 @@ double decodeDouble(SerializedDouble value) { return ((value.signAndSignificandTwo & 0x80000000) == 0x80000000) ? -returnValue : returnValue; } +#if 0 + +// Why these are needed? + uint64 encodeDouble_64(double value) { // Split the value into its significand and exponent int exponent; @@ -135,4 +139,6 @@ double decodeDouble_Compact(CompactSerializedDouble value) { return ((value.signAndSignificandOne & 0x80000000) == 0x80000000) ? -returnValue : returnValue; } +#endif + } // End of namespace Sword25 diff --git a/engines/sword25/util/double_serialization.h b/engines/sword25/util/double_serialization.h index e90338c369..a910a66f20 100644 --- a/engines/sword25/util/double_serialization.h +++ b/engines/sword25/util/double_serialization.h @@ -56,6 +56,7 @@ SerializedDouble encodeDouble(double value); */ double decodeDouble(SerializedDouble value); +#if 0 /** * Encodes a double as a uint64 * @@ -90,6 +91,8 @@ CompactSerializedDouble encodeDouble_Compact(double value); */ double decodeDouble_Compact(CompactSerializedDouble value); +#endif + } // End of namespace Sword25 #endif -- cgit v1.2.3 From f7ba09dcfcef0b7009e0b48bee2daf3f7b09194c Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 23:18:16 +0100 Subject: NEWS: Mention DOTT easter egg support --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 470ddc01bd..d66eb55d0e 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,10 @@ For a more comprehensive changelog of the latest experimental code, see: head scene (bug #6728). It may have been happening in other scenes as well. +SCUMM: + - It is now possible to play Maniac Mansion from within Day of the + Tentacle, with a few caveats. See README for details. + 1.7.0 (2014-07-21) New Games: - Added support for Chivalry is Not Dead. -- cgit v1.2.3 From c44c0f09bfdff1567f2560962c5f2053156245f8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 23:18:37 +0100 Subject: README: Describe DOTT easter egg support. Text by eriktorbjorn. --- README | 111 +++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 44 deletions(-) diff --git a/README b/README index 5b0569089c..b78ee24dfd 100644 --- a/README +++ b/README @@ -15,26 +15,27 @@ Table of Contents: * 2.1 Reporting Bugs 3.0) Supported Games * 3.1 Copy Protection - * 3.2 Commodore64 games notes - * 3.3 Maniac Mansion NES notes - * 3.4 Macintosh games notes - * 3.5 Multi-CD games notes - * 3.6 The Curse of Monkey Island notes - * 3.7 Broken Sword games notes - * 3.8 Beneath a Steel Sky notes - * 3.9 Flight of the Amazon Queen notes - * 3.10 Gobliiins notes - * 3.11 Inherit the Earth: Quest for the Orb notes - * 3.12 Simon the Sorcerer notes - * 3.13 The Feeble Files notes - * 3.14 The Legend of Kyrandia notes - * 3.15 Sierra AGI games Predictive Input Dialog notes - * 3.16 Mickey's Space Adventure notes - * 3.17 Winnie the Pooh notes - * 3.18 Troll's Tale notes - * 3.19 Dragon History notes - * 3.20 Simultaneous speech and subtitles in Sierra SCI games - * 3.21 Known Problems + * 3.2 Day of the Tentacle notes + * 3.3 Commodore64 games notes + * 3.4 Maniac Mansion NES notes + * 3.5 Macintosh games notes + * 3.6 Multi-CD games notes + * 3.7 The Curse of Monkey Island notes + * 3.8 Broken Sword games notes + * 3.9 Beneath a Steel Sky notes + * 3.10 Flight of the Amazon Queen notes + * 3.11 Gobliiins notes + * 3.12 Inherit the Earth: Quest for the Orb notes + * 3.13 Simon the Sorcerer notes + * 3.14 The Feeble Files notes + * 3.15 The Legend of Kyrandia notes + * 3.16 Sierra AGI games Predictive Input Dialog notes + * 3.17 Mickey's Space Adventure notes + * 3.18 Winnie the Pooh notes + * 3.19 Troll's Tale notes + * 3.20 Dragon History notes + * 3.21 Simultaneous speech and subtitles in Sierra SCI games + * 3.22 Known Problems 4.0) Supported Platforms 5.0) Running ScummVM * 5.1 Command Line Options @@ -410,7 +411,29 @@ ScummVM will skip copy protection in the following games: * Zak McKracken and the Alien Mindbenders -3.2) Commodore64 games notes: +3.2) Day of the Tentacle notes: +---- -------------------------- + +At one point in the game, you come across a computer that allows you +to play the original Maniac Mansion as an easter egg. ScummVM supports +this, with a few caveats: + +ScummVM will scan your configuration file for a game that's in a +'Maniac' sub-folder of your Day of the Tentacle folder. If you've +copied the data files from the CD version, this should already be the +case but you have to add the game to ScummVM as well. + +To return to Day of the Tentacle, press F5 and select "Return to +Launcher". + +This means that you could in theory use any game as the easter egg. +Indeed, there is a "secret" configuration setting, "easter_egg", to +override the ID of the game to run. Be aware, though, that not all +games support returning to the launcher, and setting it up to use Day +of the Tentacle itself as the easter egg game is not recommended. + + +3.3) Commodore64 games notes: ---- ------------------------ Both Maniac Mansion and Zak McKracken run but Maniac Mansion is not yet playable. Simply name the D64 disks "maniac1.d64" and "maniac2.d64" @@ -424,7 +447,7 @@ to Commodore64. We recommend using the much simpler approach described in the previous paragraph. -3.3) Maniac Mansion NES notes: +3.4) Maniac Mansion NES notes: ---- ------------------------- Supported versions are English GB (E), French (F), German (G), Italian (I), Swedish (SW) and English US (U). ScummVM requires just the PRG section @@ -453,7 +476,7 @@ section. To do so use the 'extract_mm_nes' utility from the tools package. -3.4) Macintosh games notes: +3.5) Macintosh games notes: ---- ---------------------- All LucasArts SCUMM based adventures, except COMI, also exist in versions for the Macintosh. ScummVM can use most (all?) of them, however, in some @@ -481,7 +504,7 @@ disk see: http://wiki.scummvm.org/index.php/HOWTO-Mac_Games -3.5) Multi-CD games notes: +3.6) Multi-CD games notes: ---- --------------------- In general, ScummVM does not deal very well with Multi-CD games. This is because ScummVM assumes everything about a game can be found in one @@ -496,7 +519,7 @@ files. Usually, when a file appears on more than one CD you can pick either of them. -3.6) The Curse of Monkey Island notes: +3.7) The Curse of Monkey Island notes: ---- --------------------------------- For this game, you will need the comi.la0, comi.la1 and comi.la2 files. The comi.la0 file can be found on either CD, but since they are @@ -508,7 +531,7 @@ two CDs. Some of the files appear on both CDs, but again they're identical. -3.7) Broken Sword games notes: +3.8) Broken Sword games notes: ---- ------------------------- The instructions for the Broken Sword games are for the Sold-Out Software versions, with each game on two CDs, since these were the @@ -517,7 +540,7 @@ them. Hopefully they are general enough to be useful to other releases as well. -3.7.1) Broken Sword games cutscenes: +3.8.1) Broken Sword games cutscenes: ------ ----------------------------- The cutscenes for the Broken Sword games have a bit of a history (see the next section, if you are interested), but in general all you need to @@ -558,7 +581,7 @@ currently does not work when running PlayStation videos. (Broken Sword II already has subtitles; no extra work is needed for them.) -3.7.2) Broken Sword games cutscenes, in retrospect: +3.8.2) Broken Sword games cutscenes, in retrospect: ------ -------------------------------------------- The original releases of the Broken Sword games used RAD Game Tools's Smacker(tm) format. As RAD was unwilling to open the older legacy @@ -583,7 +606,7 @@ decoding MPEG movies added a lot of complexity, and they didn't look as good as the Smacker and DXA versions anyway. -3.7.3) Broken Sword: +3.8.3) Broken Sword: ------ ------------- For this game, you will need all of the files from the clusters directories on both CDs. For the Windows and Macintosh versions, you @@ -600,7 +623,7 @@ makes little difference. The PlayStation version requires tunes.dat and tunes.tab. -3.7.4) Broken Sword II: +3.8.4) Broken Sword II: ------ ---------------- For this game, you will need all of the files from the clusters directories on both CDs. (Actually, a few of them may not be strictly @@ -615,7 +638,7 @@ In addition, you will need the cd.inf and, optionally, the startup.inf files from the sword2 directory on CD 1. -3.8) Beneath a Steel Sky notes: +3.9) Beneath a Steel Sky notes: ---- -------------------------- Starting with ScummVM 0.8.0 you need the additional 'SKY.CPT' file to run Beneath a Steel Sky. @@ -626,7 +649,7 @@ files (SKY.DNR, SKY.DSK), in your extrapath, or in the directory where your ScummVM executable resides. -3.9) Flight of the Amazon Queen notes: +3.10) Flight of the Amazon Queen notes: ---- --------------------------------- In order to use a non-freeware version of Flight of the Amazon Queen (from original CD), you will need to place the 'queen.tbl' file @@ -641,7 +664,7 @@ specific version, and thus removing the run-time dependency on the sound effects with MP3, OGG or FLAC. -3.10) Gobliiins notes: +3.11) Gobliiins notes: ----- ---------------- The CD versions of the Gobliiins series contain one big audio track which you need to rip (see the section on using compressed audio files) @@ -651,7 +674,7 @@ track and its volume is therefore changed with the music volume control as well. -3.11) Inherit the Earth: Quest for the Orb notes: +3.12) Inherit the Earth: Quest for the Orb notes: ----- ------------------------------------------- In order to run the Mac OS X Wyrmkeep re-release of the game you will need to copy over data from the CD to your hard disk. If you're on a PC @@ -671,14 +694,14 @@ format, as they should include both resource and data forks. Copy all 'ITE *' files. -3.12) Simon the Sorcerer 1 and 2 notes: +3.13) Simon the Sorcerer 1 and 2 notes: ----- --------------------------------- If you have the dual version of Simon the Sorcerer 1 or 2 on CD, you will find the Windows version in the main directory of the CD and the DOS version in the DOS directory of the CD. -3.13) The Feeble Files notes: +3.14) The Feeble Files notes: ----- ----------------------- If you have the Windows version of The Feeble Files, there are several things to note. @@ -696,7 +719,7 @@ Rename voices.wav on CD3 to voices3.wav Rename voices.wav on CD4 to voices4.wav -3.14) The Legend of Kyrandia notes: +3.15) The Legend of Kyrandia notes: ----- ----------------------------- To run The Legend of Kyrandia under ScummVM you need the 'kyra.dat' file. The file should always be included in official ScummVM packages. @@ -707,7 +730,7 @@ thus you only need to grab it in case ScummVM complains about the file being missing. -3.15) Sierra AGI games Predictive Input Dialog notes: +3.16) Sierra AGI games Predictive Input Dialog notes: ----- ----------------------------------------------- The Predictive Input Dialog is a ScummVM aid for running AGI engine games (which notoriously require command line input) on devices with @@ -761,7 +784,7 @@ naturally mapping the functionality to the numeric keypad. Also, the dialog's buttons can be navigated with the arrow and the enter keys. -3.16) Mickey's Space Adventure notes: +3.17) Mickey's Space Adventure notes: ----- ------------------------------- To run Mickey's Space Adventure under ScummVM, the original executable of the game (mickey.exe) is needed together with the game's data files. @@ -776,7 +799,7 @@ game's screen to change location, similar to many adventure games, which is simpler and more straightforward than moving around using the menu. -3.17) Winnie the Pooh notes: +3.18) Winnie the Pooh notes: ----- ---------------------- It is possible to import saved games from the original interpreter of the game into ScummVM. @@ -791,14 +814,14 @@ game's screen to change location, similar to many adventure games, which is simpler and more straightforward than moving around using the menu. -3.18) Troll's Tale notes: +3.19) Troll's Tale notes: ----- ------------------- The original game came in a PC booter disk, therefore it is necessary to dump the contents of that disk in an image file and name it "troll.img" to be able to play the game under ScummVM. -3.19) Dragon History notes: +3.20) Dragon History notes: ----- --------------------- There are 4 language variants of the game: Czech, English, Polish and German. Each of them is distributed in a separate archive. The only @@ -816,7 +839,7 @@ All game files and the walkthrough can be downloaded from http://www.ucw.cz/draci-historie/index-en.html -3.20) Simultaneous speech and subtitles in Sierra SCI games: +3.21) Simultaneous speech and subtitles in Sierra SCI games: ----- ------------------------------------------------------ Certain CD versions of Sierra SCI games had both speech and text resources. Some have an option to toggle between the two, but there are @@ -864,7 +887,7 @@ Space Quest 4 CD: options dialog, or via ScummVM's audio options. -3.21) Known Problems: +3.22) Known Problems: ----- --------------- This release has the following known problems. There is no need to report them, although patches to fix them are welcome. If you discover a -- cgit v1.2.3 From 1d596b023024abe7b4781803ee7442462719bcc8 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 4 Jan 2015 23:55:54 +0100 Subject: README: A (huge) update of compatible games Somehow we missed to update it for ages! --- README | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 97 insertions(+), 20 deletions(-) diff --git a/README b/README index b78ee24dfd..e5a4229afd 100644 --- a/README +++ b/README @@ -201,7 +201,7 @@ SCUMM Games by LucasArts: The Dig [dig] The Curse of Monkey Island [comi] -AGI Games by Sierra: +AGI and preAGI Games by Sierra: The Black Cauldron [bc] Gold Rush! [goldrush] King's Quest I [kq1] @@ -218,6 +218,9 @@ AGI Games by Sierra: Space Quest I: The Sarien Encounter [sq1] Space Quest II: Vohaul's Revenge [sq2] Fanmade Games [agi-fanmade] + Mickey's Space Adventure [mickey] + Troll's Tale [troll] + Winnie the Pooh in the Hundred Acre Wood [winnie] AGOS Games by Adventuresoft/Horrorsoft: Elvira - Mistress of the Dark [elvira1] @@ -236,6 +239,13 @@ AGOS Games by Adventuresoft/Horrorsoft: - Swampy Adventures [swampy] The Feeble Files [feeble] +Composer Games by Animation Magic: + Darby the Dragon [darby] + Gregory and the Hot Air Balloon [gregory] + Magic Tales: Liam Finds a Story [liam] + The Princess and the Crab [princess] + Sleeping Cub's Test of Courage [sleepingcub] + GOB Games by Coktel Vision: Bambou le sauveur de la jungle [bambou] Bargon Attack [bargon] @@ -251,6 +261,22 @@ GOB Games by Coktel Vision: Urban Runner [urban] Ween: The Prophecy [ween] +Living Books Games: + Aesop's Fables: The Tortoise and the Hare [tortoise] + Arthur's Birthday [arthurbday] + Arthur's Teacher Trouble [arthur] + Dr. Seuss's ABC [seussabc] + Green Eggs and Ham [greeneggs] + Harry and the Haunted House [harryhh] + Just Grandma and Me [grandma] + Little Monster at School [lilmonster] + Ruff's Bone [ruff] + Sheila Rae, the Brave [sheila] + Stellaluna [stellaluna] + The Berenstain Bears Get in a Fight [bearfight] + The Berenstain Bears in the Dark [beardark] + The New Kid on the Block [newkid] + MADE Games by Activision: Leather Goddesses of Phobos 2 [lgop2] Return to Zork [rtz] @@ -258,34 +284,102 @@ MADE Games by Activision: The Manhole [manhole] Other Games: + 3 Skulls of the Toltecs [toltecs] + Blue Force [blueforce] Beneath a Steel Sky [sky] Broken Sword: The Shadow of the Templars [sword1] Broken Sword II: The Smoking Mirror [sword2] + Bud Tucker in Double Trouble [tucker] Cruise for a Corpse [cruise] Discworld [dw] Discworld 2: Missing Presumed ...!? [dw2] Dragon History [draci] Drascula: The Vampire Strikes Back [drascula] + DreamWeb [dreamweb] Eye of the Beholder [eob] Eye of the Beholder II: The Legend of Darkmoon [eob2] Flight of the Amazon Queen [queen] Future Wars [fw] + Hopkins FBI [hopkins] + Hugo's House of Horrors [hugo1] + Hugo 2: Whodunit? [hugo2] + Hugo 3: Jungle of Doom [hugo3] + I Have No Mouth, and I Must Scream [ihnm] Inherit the Earth: Quest for the Orb [ite] Nippon Safes Inc. [nippon] Lands of Lore: The Throne of Chaos [lol] + Lure of the Temptress [lure] + Mortville Manor [mortevielle] + Nippon Safes Inc. [nippon] + Ringworld: Revenge Of The Patriarch [ringworld] + Return to Ringworld [ringworld2] + Sfinx [sfinx] + Soltys [soltys] + TeenAgent [teenagent] The Journeyman Project: Pegasus Prime [pegasus] The Legend of Kyrandia [kyra1] The Legend of Kyrandia: The Hand of Fate [kyra2] The Legend of Kyrandia: Malcolm's Revenge [kyra3] + The 7th Guest [t7g] + The Neverhood [neverhood] + Tony Tough and the Night of Roasted Moths [tony] + Toonstruck [toon] Touche: The Adventures of the Fifth Musketeer [touche] + Voyeur [voyeur] + +SCI Games by Sierra Entertainment: + Castle of Dr. Brain [castlebrain] + Codename: ICEMAN [iceman] + Conquests of Camelot [camelot] + Conquests of the Longbow [longbow] + EcoQuest: The Search for Cetus [ecoquest] + EcoQuest 2: Lost Secret of the Rainforest [ecoquest2] + Freddy Pharkas: Frontier Pharmacist [freddypharkas] + Hoyle's Book of Games 1 [hoyle1] + Hoyle's Book of Games 2 [hoyle2] + Hoyle's Book of Games 3 [hoyle3] + Hoyle Classic Card Games [hoyle4] + Jones in the Fast Lane [jones] + King's Quest I [kq1sci] + King's Quest IV [kq4sci] + King's Quest V [kq5] + King's Quest VI [kq6] + Laura Bow: The Colonel's Bequest [laurabow] + Laura Bow 2: The Dagger of Amon Ra [laurabow2] + Leisure Suit Larry 1 [lsl1sci] + Leisure Suit Larry 2 [lsl2] + Leisure Suit Larry 3 [lsl3] + Leisure Suit Larry 5 [lsl5] + Leisure Suit Larry 6 [lsl6] + Mixed-up Fairy Tales [fairytales] + Mixed-up Mother Goose [mothergoose] + Pepper's Adventures in Time [pepper] + Police Quest 1 [pq1sci] + Police Quest 2 [pq2] + Police Quest 3 [pq3] + Quest for Glory 1/Hero's Quest [qfg1] + Quest for Glory 1 [qfg1vga] + Quest for Glory 2 [qfg2] + Quest for Glory 3 [qfg3] + Slater & Charlie Go Camping [slater] + Space Quest I [sq1sci] + Space Quest III [sq3] + Space Quest IV [sq4] + Space Quest V [sq5] + The Island of Dr. Brain [islandbrain] + +Wintermute Games: + Chivalry is Not Dead [chivalry] SCUMM Games by Humongous Entertainment: Backyard Baseball [baseball] Backyard Baseball 2001 [baseball2001] Backyard Baseball 2003 [baseball2003] Backyard Football [football] + Backyard Football 2002 [football2002] + Bear Stormin' [brstorm] Big Thinkers First Grade [thinker1] Big Thinkers Kindergarten [thinkerk] Blue's 123 Time Activities [Blues123Time] @@ -310,6 +404,7 @@ SCUMM Games by Humongous Entertainment: Let's Explore the Airport with Buzzy [airport] Let's Explore the Farm with Buzzy [farm] Let's Explore the Jungle with Buzzy [jungle] + Pajama Sam: Games to Play on Any Day [pjgames] Pajama Sam 1: No Need to Hide When It's Dark Outside [pajama] Pajama Sam 2: Thunder and Lightning @@ -334,38 +429,20 @@ SCUMM Games by Humongous Entertainment: SPY Fox in Cheese Chase [chase] SPY Fox in Hold the Mustard [mustard] -Living Books Games: - Aesop's Fables: The Tortoise and the Hare [tortoise] - Arthur's Birthday [arthurbday] - Arthur's Teacher Trouble [arthur] - Dr. Seuss's ABC [seussabc] - Green Eggs and Ham [greeneggs] - Harry and the Haunted House [harryhh] - Just Grandma and Me [grandma] - Little Monster at School [lilmonster] - Ruff's Bone [ruff] - Sheila Rae, the Brave [sheila] - Stellaluna [stellaluna] - The Berenstain Bears Get in a Fight [bearfight] - The Berenstain Bears in the Dark [beardark] - The New Kid on the Block [newkid] - The following games should load, but are not yet fully playable. Play these at your own risk, and please do not file bug reports about them. If you want the latest updates on game compatibility, visit our web site and view the compatibility chart. - Backyard Football 2002 [football2002] Backyard Soccer [soccer] Backyard Soccer MLS [soccermls] Backyard Soccer 2004 [soccer2004] Blue's Treasure Hunt [BluesTreasureHunt] - Pajama Sam: Games to Play on Any Day [pjgames] The following games are based on the SCUMM engine, but NOT supported by ScummVM (yet): - Other Humongous Entertainment games + Moonbase Commander Please be aware that the engines may contain bugs and unimplemented features that sometimes make it impossible to finish the game. Save -- cgit v1.2.3 From 02e3e82e8210abe9f496f978917c9b134b5e0ad9 Mon Sep 17 00:00:00 2001 From: Kirben Date: Mon, 5 Jan 2015 22:33:19 +1100 Subject: SCUMM: Correct game flags for HE72 version of Putt-Putt Saves the Zoo. --- engines/scumm/detection_tables.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/scumm/detection_tables.h b/engines/scumm/detection_tables.h index 82a8b4452b..6eab5c752f 100644 --- a/engines/scumm/detection_tables.h +++ b/engines/scumm/detection_tables.h @@ -310,7 +310,7 @@ static const GameSettings gameVariantsTable[] = { // Changed o_getResourceSize to cover all resource types {"farm", "", 0, GID_HEGAME, 6, 73, MDT_NONE, GF_USE_KEY, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, {"puttzoo", "", 0, GID_PUTTZOO, 6, 73, MDT_NONE, GF_USE_KEY, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, - {"puttzoo", "HE 72", 0, GID_PUTTZOO, 6, 72, MDT_NONE, GF_USE_KEY | GF_HE_985, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, + {"puttzoo", "HE 72", 0, GID_PUTTZOO, 6, 72, MDT_NONE, GF_USE_KEY, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, {"puttzoo", "HE 98.5", 0, GID_PUTTZOO, 6, 98, MDT_NONE, GF_USE_KEY | GF_HE_985, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, {"puttzoo", "HE 99", 0, GID_PUTTZOO, 6, 99, MDT_NONE, GF_USE_KEY, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, {"puttzoo", "HE 100", 0, GID_PUTTZOO, 6, 100, MDT_NONE, GF_USE_KEY, UNK, GUIO3(GUIO_NOLAUNCHLOAD, GUIO_NOMIDI, GUIO_NOASPECT)}, -- cgit v1.2.3 From 7225101e6257d0574fb94be8a6016a3b67a09855 Mon Sep 17 00:00:00 2001 From: Fedor Strizhnev Date: Mon, 5 Jan 2015 16:53:35 +0300 Subject: Add Theora support to systems which use libtremor --- video/theora_decoder.cpp | 4 ++++ video/theora_decoder.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/video/theora_decoder.cpp b/video/theora_decoder.cpp index cb6289bd60..ba596c6032 100644 --- a/video/theora_decoder.cpp +++ b/video/theora_decoder.cpp @@ -360,7 +360,11 @@ static double rint(double v) { } bool TheoraDecoder::VorbisAudioTrack::decodeSamples() { +#ifdef USE_TREMOR + ogg_int32_t **pcm; +#else float **pcm; +#endif // if there's pending, decoded audio, grab it int ret = vorbis_synthesis_pcmout(&_vorbisDSP, &pcm); diff --git a/video/theora_decoder.h b/video/theora_decoder.h index feb4c6b49e..5b683cf6af 100644 --- a/video/theora_decoder.h +++ b/video/theora_decoder.h @@ -33,7 +33,12 @@ #include "graphics/surface.h" #include + +#ifdef USE_TREMOR +#include +#else #include +#endif namespace Common { class SeekableReadStream; -- cgit v1.2.3 From 59934881a1dc27e0c6030d2133ec3f9aae583df7 Mon Sep 17 00:00:00 2001 From: Joel Teichroeb Date: Mon, 5 Jan 2015 20:14:17 -0800 Subject: ANDROID: Remove unpacker and fix support for non arm --- backends/platform/android/android.cpp | 12 - backends/platform/android/android.h | 8 - backends/platform/android/android.mk | 6 +- backends/platform/android/jni.cpp | 46 --- backends/platform/android/jni.h | 2 - .../org/scummvm/scummvm/PluginProvider.java | 63 ---- .../android/org/scummvm/scummvm/ScummVM.java | 7 +- .../org/scummvm/scummvm/ScummVMActivity.java | 7 - .../org/scummvm/scummvm/ScummVMApplication.java | 31 -- .../android/org/scummvm/scummvm/Unpacker.java | 388 --------------------- configure | 2 + dists/android/AndroidManifest.xml | 19 +- dists/android/AndroidManifest.xml.in | 19 +- dists/android/jni/Android.mk | 2 +- dists/android/mkplugin.sh | 16 - dists/android/plugin-manifest.xml | 35 -- dists/android/plugin-manifest.xml.in | 35 -- dists/android/plugin-strings.xml | 6 - dists/android/res/drawable/gradient.xml | 7 - dists/android/res/layout/splash.xml | 19 - 20 files changed, 8 insertions(+), 722 deletions(-) delete mode 100644 backends/platform/android/org/scummvm/scummvm/PluginProvider.java delete mode 100644 backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java delete mode 100644 backends/platform/android/org/scummvm/scummvm/Unpacker.java delete mode 100755 dists/android/mkplugin.sh delete mode 100644 dists/android/plugin-manifest.xml delete mode 100644 dists/android/plugin-manifest.xml.in delete mode 100644 dists/android/plugin-strings.xml delete mode 100644 dists/android/res/drawable/gradient.xml delete mode 100644 dists/android/res/layout/splash.xml diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index 3ff1b939ef..798772cc24 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -396,12 +396,6 @@ void OSystem_Android::initBackend() { EventsBaseBackend::initBackend(); } -void OSystem_Android::addPluginDirectories(Common::FSList &dirs) const { - ENTER(); - - JNI::getPluginDirectories(dirs); -} - bool OSystem_Android::hasFeature(Feature f) { return (f == kFeatureFullscreenMode || f == kFeatureAspectRatioCorrection || @@ -600,10 +594,4 @@ Common::String OSystem_Android::getSystemProperty(const char *name) const { return Common::String(value, len); } -#ifdef DYNAMIC_MODULES -void AndroidPluginProvider::addCustomDirectories(Common::FSList &dirs) const { - ((OSystem_Android *)g_system)->addPluginDirectories(dirs); -} -#endif - #endif diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 28016f5e3e..ade84dd42d 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -96,13 +96,6 @@ extern void checkGlError(const char *expr, const char *file, int line); #define GLTHREADCHECK do { } while (false) #endif -#ifdef DYNAMIC_MODULES -class AndroidPluginProvider : public POSIXPluginProvider { -protected: - virtual void addCustomDirectories(Common::FSList &dirs) const; -}; -#endif - class OSystem_Android : public EventsBaseBackend, public PaletteManager { private: // passed from the dark side @@ -177,7 +170,6 @@ public: virtual ~OSystem_Android(); virtual void initBackend(); - void addPluginDirectories(Common::FSList &dirs) const; void enableZoning(bool enable) { _enable_zoning = enable; } virtual bool hasFeature(Feature f); diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index f9a2bc9813..5be9f86770 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -5,7 +5,7 @@ ANDROID_VERSIONCODE = 6 ANDROID_TARGET_VERSION = 14 -NDK_BUILD = $(ANDROID_NDK)/ndk-build +NDK_BUILD = $(ANDROID_NDK)/ndk-build APP_ABI=$(ABI) SDK_ANDROID = $(ANDROID_SDK)/tools/android PATH_DIST = $(srcdir)/dists/android @@ -18,8 +18,6 @@ RESOURCES = \ $(PATH_BUILD_RES)/values/strings.xml \ $(PATH_BUILD_RES)/values-television/margins.xml \ $(PATH_BUILD_RES)/layout/main.xml \ - $(PATH_BUILD_RES)/layout/splash.xml \ - $(PATH_BUILD_RES)/drawable/gradient.xml \ $(PATH_BUILD_RES)/drawable/scummvm.png \ $(PATH_BUILD_RES)/drawable/scummvm_big.png \ $(PATH_BUILD_RES)/drawable-xhdpi/ouya_icon.png @@ -30,7 +28,7 @@ DIST_BUILD_XML = $(PATH_DIST)/custom_rules.xml PATH_BUILD = ./build.tmp PATH_BUILD_ASSETS = $(PATH_BUILD)/assets PATH_BUILD_RES = $(PATH_BUILD)/res -PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/mylib/armeabi/libscummvm.so +PATH_BUILD_LIBSCUMMVM = $(PATH_BUILD)/lib/$(ABI)/libscummvm.so FILE_MANIFEST_SRC = $(srcdir)/dists/android/AndroidManifest.xml FILE_MANIFEST = $(PATH_BUILD)/AndroidManifest.xml diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index 764c84ce1c..22e6a749c2 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -79,7 +79,6 @@ jmethodID JNI::_MID_displayMessageOnOSD = 0; jmethodID JNI::_MID_setWindowCaption = 0; jmethodID JNI::_MID_showVirtualKeyboard = 0; jmethodID JNI::_MID_getSysArchives = 0; -jmethodID JNI::_MID_getPluginDirectories = 0; jmethodID JNI::_MID_initSurface = 0; jmethodID JNI::_MID_deinitSurface = 0; @@ -293,46 +292,6 @@ void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { } } -void JNI::getPluginDirectories(Common::FSList &dirs) { - JNIEnv *env = JNI::getEnv(); - - jobjectArray array = - (jobjectArray)env->CallObjectMethod(_jobj, _MID_getPluginDirectories); - - if (env->ExceptionCheck()) { - LOGE("Error finding plugin directories"); - - env->ExceptionDescribe(); - env->ExceptionClear(); - - return; - } - - jsize size = env->GetArrayLength(array); - for (jsize i = 0; i < size; ++i) { - jstring path_obj = (jstring)env->GetObjectArrayElement(array, i); - - if (path_obj == 0) - continue; - - const char *path = env->GetStringUTFChars(path_obj, 0); - - if (path == 0) { - LOGE("Error getting string characters from plugin directory"); - - env->ExceptionClear(); - env->DeleteLocalRef(path_obj); - - continue; - } - - dirs.push_back(Common::FSNode(path)); - - env->ReleaseStringUTFChars(path_obj, path); - env->DeleteLocalRef(path_obj); - } -} - bool JNI::initSurface() { JNIEnv *env = JNI::getEnv(); @@ -454,7 +413,6 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager, FIND_METHOD(, displayMessageOnOSD, "(Ljava/lang/String;)V"); FIND_METHOD(, showVirtualKeyboard, "(Z)V"); FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;"); - FIND_METHOD(, getPluginDirectories, "()[Ljava/lang/String;"); FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;"); FIND_METHOD(, deinitSurface, "()V"); @@ -543,10 +501,6 @@ jint JNI::main(JNIEnv *env, jobject self, jobjectArray args) { env->DeleteLocalRef(arg); } -#ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new AndroidPluginProvider()); -#endif - LOGI("Entering scummvm_main with %d args", argc); res = scummvm_main(argc, argv); diff --git a/backends/platform/android/jni.h b/backends/platform/android/jni.h index 326869b1ee..70feaaf72a 100644 --- a/backends/platform/android/jni.h +++ b/backends/platform/android/jni.h @@ -55,7 +55,6 @@ public: static void setReadyForEvents(bool ready); - static void getPluginDirectories(Common::FSList &dirs); static void setWindowCaption(const char *caption); static void getDPI(float *values); static void displayMessageOnOSD(const char *msg); @@ -93,7 +92,6 @@ private: static jmethodID _MID_setWindowCaption; static jmethodID _MID_showVirtualKeyboard; static jmethodID _MID_getSysArchives; - static jmethodID _MID_getPluginDirectories; static jmethodID _MID_initSurface; static jmethodID _MID_deinitSurface; diff --git a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java deleted file mode 100644 index e27e8d41a8..0000000000 --- a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.scummvm.scummvm; - -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; - -import java.util.ArrayList; - -public class PluginProvider extends BroadcastReceiver { - private final static String LOG_TAG = "ScummVM"; - - public final static String META_UNPACK_LIB = - "org.scummvm.scummvm.meta.UNPACK_LIB"; - - public void onReceive(Context context, Intent intent) { - if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) - return; - - Bundle extras = getResultExtras(true); - - final ActivityInfo info; - final PackageInfo pinfo; - try { - info = context.getPackageManager() - .getReceiverInfo(new ComponentName(context, this.getClass()), - PackageManager.GET_META_DATA); - pinfo = context.getPackageManager() - .getPackageInfo(context.getPackageName(), 0); - } catch (PackageManager.NameNotFoundException e) { - Log.e(LOG_TAG, "Error finding my own info?", e); - return; - } - - String host_version = extras.getString(ScummVMApplication.EXTRA_VERSION); - if (!pinfo.versionName.equals(host_version)) { - Log.e(LOG_TAG, "Plugin version " + pinfo.versionName + " is not equal to ScummVM version " + host_version); - return; - } - - String mylib = info.metaData.getString(META_UNPACK_LIB); - if (mylib != null) { - ArrayList all_libs = - extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); - all_libs.add(new Uri.Builder() - .scheme("plugin") - .authority(context.getPackageName()) - .path(mylib) - .toString()); - - extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, - all_libs); - } - - setResultExtras(extras); - } -} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java index 5047502e61..3b370a583d 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -54,7 +54,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { abstract protected void getDPI(float[] values); abstract protected void displayMessageOnOSD(String msg); abstract protected void setWindowCaption(String caption); - abstract protected String[] getPluginDirectories(); abstract protected void showVirtualKeyboard(boolean enable); abstract protected String[] getSysArchives(); @@ -444,10 +443,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { } } - File cache_dir = ScummVMApplication.getLastCacheDir(); - String libname = System.mapLibraryName("scummvm"); - File libpath = new File(cache_dir, libname); - - System.load(libpath.getPath()); + System.loadLibrary("scummvm"); } } diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index f4eb7ddd0b..5b2dcae175 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -83,13 +83,6 @@ public class ScummVMActivity extends Activity { }); } - @Override - protected String[] getPluginDirectories() { - String[] dirs = new String[1]; - dirs[0] = ScummVMApplication.getLastCacheDir().getPath(); - return dirs; - } - @Override protected void showVirtualKeyboard(final boolean enable) { runOnUiThread(new Runnable() { diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java deleted file mode 100644 index 0adc166222..0000000000 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.scummvm.scummvm; - -import android.app.Application; - -import java.io.File; - -public class ScummVMApplication extends Application { - public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY"; - public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS"; - public final static String EXTRA_VERSION = "org.scummvm.scummvm.extra.VERSION"; - - private static File _cache_dir; - - @Override - public void onCreate() { - super.onCreate(); - - // This is still on /data :( - _cache_dir = getCacheDir(); - // This is mounted noexec :( - //cache_dir = new File(Environment.getExternalStorageDirectory(), - // "/.ScummVM.tmp"); - // This is owned by download manager and requires special - // permissions to access :( - //cache_dir = Environment.getDownloadCacheDirectory(); - } - - public static File getLastCacheDir() { - return _cache_dir; - } -} diff --git a/backends/platform/android/org/scummvm/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java deleted file mode 100644 index da76ceb5e5..0000000000 --- a/backends/platform/android/org/scummvm/scummvm/Unpacker.java +++ /dev/null @@ -1,388 +0,0 @@ -package org.scummvm.scummvm; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ActivityNotFoundException; -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.ContextWrapper; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.util.Log; -import android.widget.ProgressBar; - -import java.io.IOException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; - -public class Unpacker extends Activity { - protected final static String LOG_TAG = "ScummVM"; - // TODO don't hardcode this - private final static boolean PLUGINS_ENABLED = false; - private final static String META_NEXT_ACTIVITY = - "org.scummvm.unpacker.nextActivity"; - private ProgressBar mProgress; - private File mUnpackDest; // location to unpack into - private AsyncTask mUnpacker; - private final static int REQUEST_MARKET = 1; - - // Android 3.1+ only - public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32; - - private static class UnpackJob { - public ZipFile zipfile; - public Set paths; - - public UnpackJob(ZipFile zipfile, Set paths) { - this.zipfile = zipfile; - this.paths = paths; - } - - public long UnpackSize() { - long size = 0; - for (String path: paths) { - ZipEntry entry = zipfile.getEntry(path); - if (entry != null) size += entry.getSize(); - } - return size; - } - } - - private class UnpackTask extends AsyncTask { - @Override - protected void onProgressUpdate(Integer... progress) { - mProgress.setIndeterminate(false); - mProgress.setMax(progress[1]); - mProgress.setProgress(progress[0]); - mProgress.postInvalidate(); - } - - @Override - protected void onPostExecute(Void result) { - Bundle md = getMetaData(); - String nextActivity = md.getString(META_NEXT_ACTIVITY); - if (nextActivity != null) { - final ComponentName cn = - ComponentName.unflattenFromString(nextActivity); - if (cn != null) { - final Intent origIntent = getIntent(); - Intent intent = new Intent(); - intent.setComponent(cn); - if (origIntent.getExtras() != null) - intent.putExtras(origIntent.getExtras()); - intent.putExtra(Intent.EXTRA_INTENT, origIntent); - intent.setDataAndType(origIntent.getData(), - origIntent.getType()); - //intent.fillIn(getIntent(), 0); - intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); - Log.i(LOG_TAG, - "Starting next activity with intent " + intent); - startActivity(intent); - } else { - Log.w(LOG_TAG, - "Unable to extract a component name from " + nextActivity); - } - } - - finish(); - } - - @Override - protected Void doInBackground(String... all_libs) { - // This will contain all unpack jobs - Map unpack_jobs = - new HashMap(all_libs.length); - - // This will contain all unpack filenames (so we can - // detect stale files in the unpack directory) - Set all_files = new HashSet(all_libs.length); - - for (String lib: all_libs) { - final Uri uri = Uri.parse(lib); - final String pkg = uri.getAuthority(); - final String path = uri.getPath().substring(1); // skip first / - - all_files.add(new File(path).getName()); - - UnpackJob job = unpack_jobs.get(pkg); - if (job == null) { - try { - // getPackageResourcePath is hidden in Context, - // but exposed in ContextWrapper... - ContextWrapper context = - new ContextWrapper(createPackageContext(pkg, 0)); - ZipFile zipfile = - new ZipFile(context.getPackageResourcePath()); - job = new UnpackJob(zipfile, new HashSet(1)); - } catch (PackageManager.NameNotFoundException e) { - Log.e(LOG_TAG, "Package " + pkg + - " not found", e); - continue; - } catch (IOException e) { - // FIXME: show some sort of GUI error dialog - Log.e(LOG_TAG, - "Error opening ZIP for package " + pkg, e); - continue; - } - unpack_jobs.put(pkg, job); - } - job.paths.add(path); - } - - // Delete stale filenames from mUnpackDest - for (File file: mUnpackDest.listFiles()) { - if (!all_files.contains(file.getName())) { - Log.i(LOG_TAG, - "Deleting stale cached file " + file); - file.delete(); - } - } - - int total_size = 0; - for (UnpackJob job: unpack_jobs.values()) - total_size += job.UnpackSize(); - - publishProgress(0, total_size); - - mUnpackDest.mkdirs(); - - int progress = 0; - - for (UnpackJob job: unpack_jobs.values()) { - try { - ZipFile zipfile = job.zipfile; - for (String path: job.paths) { - ZipEntry zipentry = zipfile.getEntry(path); - if (zipentry == null) - throw new FileNotFoundException( - "Couldn't find " + path + " in zip"); - File dest = new File(mUnpackDest, new File(path).getName()); - if (dest.exists() && - dest.lastModified() == zipentry.getTime() && - dest.length() == zipentry.getSize()) { - // Already unpacked - progress += zipentry.getSize(); - } else { - if (dest.exists()) - Log.d(LOG_TAG, - "Replacing " + dest.getPath() + - " old.mtime=" + dest.lastModified() + - " new.mtime=" + zipentry.getTime() + - " old.size=" + dest.length() + - " new.size=" + zipentry.getSize()); - else - Log.i(LOG_TAG, - "Extracting " + zipentry.getName() + - " from " + zipfile.getName() + - " to " + dest.getPath()); - - long next_update = progress; - - InputStream in = zipfile.getInputStream(zipentry); - OutputStream out = new FileOutputStream(dest); - int len; - byte[] buffer = new byte[4096]; - while ((len = in.read(buffer)) != -1) { - out.write(buffer, 0, len); - progress += len; - if (progress >= next_update) { - publishProgress(progress, total_size); - // Arbitrary limit of 2% update steps - next_update += total_size / 50; - } - } - - in.close(); - out.close(); - dest.setLastModified(zipentry.getTime()); - } - publishProgress(progress, total_size); - } - - zipfile.close(); - } catch (IOException e) { - // FIXME: show some sort of GUI error dialog - Log.e(LOG_TAG, "Error unpacking plugin", e); - } - } - - if (progress != total_size) - Log.d(LOG_TAG, "Ended with progress " + progress + - " != total size " + total_size); - - setResult(RESULT_OK); - - return null; - } - } - - private class PluginBroadcastReciever extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - if (!intent.getAction() - .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) { - Log.e(LOG_TAG, - "Received unexpected action " + intent.getAction()); - return; - } - - Bundle extras = getResultExtras(false); - if (extras == null) { - // Nothing for us to do. - Unpacker.this.setResult(RESULT_OK); - finish(); - } - - ArrayList unpack_libs = - extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); - - if (unpack_libs != null && !unpack_libs.isEmpty()) { - final String[] libs = - unpack_libs.toArray(new String[unpack_libs.size()]); - mUnpacker = new UnpackTask().execute(libs); - } - } - } - - private void initPlugins() { - Bundle extras = new Bundle(1); - - ArrayList unpack_libs = new ArrayList(1); - // This is the common ScummVM code (not really a "plugin" as such) - unpack_libs.add(new Uri.Builder() - .scheme("plugin") - .authority(getPackageName()) - .path("mylib/armeabi/libscummvm.so") - .toString()); - extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, - unpack_libs); - - final PackageInfo info; - try { - info = getPackageManager().getPackageInfo(getPackageName(), 0); - } catch (PackageManager.NameNotFoundException e) { - Log.e(LOG_TAG, "Error finding my own info?", e); - return; - } - extras.putString(ScummVMApplication.EXTRA_VERSION, info.versionName); - - Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); - // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since - // none of our plugins will ever be running, that is not helpful - intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES); - sendOrderedBroadcast(intent, Manifest.permission.SCUMMVM_PLUGIN, - new PluginBroadcastReciever(), - null, RESULT_OK, null, extras); - } - - @Override - public void onCreate(Bundle b) { - super.onCreate(b); - - mUnpackDest = ScummVMApplication.getLastCacheDir(); - - setContentView(R.layout.splash); - mProgress = (ProgressBar)findViewById(R.id.progress); - - setResult(RESULT_CANCELED); - - tryUnpack(); - } - - private void tryUnpack() { - Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); - List plugins = getPackageManager() - .queryBroadcastReceivers(intent, 0); - if (PLUGINS_ENABLED && plugins.isEmpty()) { - // No plugins installed - AlertDialog.Builder alert = new AlertDialog.Builder(this) - .setTitle(R.string.no_plugins_title) - .setMessage(R.string.no_plugins_found) - .setIcon(android.R.drawable.ic_dialog_alert) - .setOnCancelListener(new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - finish(); - } - }) - .setNegativeButton(R.string.quit, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }); - - final Uri uri = Uri.parse("market://search?q=ScummVM plugin"); - final Intent market_intent = new Intent(Intent.ACTION_VIEW, uri); - if (getPackageManager().resolveActivity(market_intent, 0) != null) { - alert.setPositiveButton(R.string.to_market, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - try { - startActivityForResult(market_intent, - REQUEST_MARKET); - } catch (ActivityNotFoundException e) { - Log.e(LOG_TAG, - "Error starting market", e); - } - } - }); - } - - alert.show(); - - } else { - // Already have at least one plugin installed - initPlugins(); - } - } - - @Override - public void onStop() { - if (mUnpacker != null) - mUnpacker.cancel(true); - super.onStop(); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, - Intent data) { - switch (requestCode) { - case REQUEST_MARKET: - if (resultCode != RESULT_OK) - Log.w(LOG_TAG, "Market returned " + resultCode); - tryUnpack(); - break; - } - } - - private Bundle getMetaData() { - try { - ActivityInfo ai = getPackageManager() - .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); - return ai.metaData; - } catch (PackageManager.NameNotFoundException e) { - Log.w(LOG_TAG, "Unable to find my own meta-data", e); - return new Bundle(); - } - } -} diff --git a/configure b/configure index 7c4c87e3af..5f73d77242 100755 --- a/configure +++ b/configure @@ -4533,6 +4533,8 @@ WIN32PATH=$_win32path AMIGAOSPATH=$_amigaospath STATICLIBPATH=$_staticlibpath +ABI := $ABI + BACKEND := $_backend MODULES += $MODULES MODULE_DIRS += $MODULE_DIRS diff --git a/dists/android/AndroidManifest.xml b/dists/android/AndroidManifest.xml index db8a9adc54..ba1046e85c 100644 --- a/dists/android/AndroidManifest.xml +++ b/dists/android/AndroidManifest.xml @@ -5,7 +5,6 @@ package="org.scummvm.scummvm" android:versionCode="@ANDROID_VERSIONCODE@" android:versionName="1.8.0git" - android:installLocation="preferExternal" android:sharedUserId="org.scummvm.scummvm">